-
-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add StarknetLightClientPlugin #146
base: main
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Need to set data_dir config? https://github.com/a16z/helios/blob/master/client/src/database.rs#L27...L36 |
This PR seems to fix the issue above. |
Workaround for now is to spawn thread and listening to rpc request events via mpsc channel. |
starknet-light-client-plugin-demo-compressed.mp4Improvement needed:
Something like
|
|
||
#[derive(Debug)] | ||
pub enum RpcRequest { | ||
GetBlockNumber, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: support all JSON-RPC requests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some improvements/concerns for the future iterations.
while let Some(msg) = rx.recv().await { | ||
let block_tx_count = client.starknet_lightclient.block_number().await.unwrap(); | ||
|
||
println!("{block_tx_count}"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO:
- support other methods with match
- Update
UiState
with the request result so that UI component re-renders
}); | ||
|
||
let runner = StarketLightClientRunner::new(); | ||
let tx = runner.start(client); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: This takes some time. Should be triggered from startup_system so that it doesn't block UI window to spawn.
eyre = "0.6" | ||
# beerus_core = { git = "https://github.com/keep-starknet-strange/beerus" } | ||
# beerus_core = { path = "../../../../../JunichiSugiura/beerus/beerus_core" } | ||
beerus_core = { git = "https://github.com/danilowhk/beerus", branch = "helios_0.2.0_implementation" } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: Change to main
branch once it's merged
#145
Only Dust Tel Aviv Hacker Building Report
WTF is dip
Dip is a composable cross-platform application framework in Rust. It allows you build desktop apps, command line tools, games, and [WIP] web, mobile apps under the same scalable Entity Component System architecture. Unique point is that you can share logic between different platforms as a form of plugin. Transforming dip based desktop/web application into a 2D/3D game is as simple as swapping UI plugins targeting different platform. Your core logic stay the same no matter what platform you're targeting. Dip is based on a game engine called Bevy.
Scope of this PR
Provide
StarknetLightClientPlugin
that wraps Beerus and provide event driven interface for dip/bevy based developers. This is the first web3 plugin that dip offers besides Ledger device integration.Demo
Very primitive demo of
StarknetLightClientPlugin
for Bevy game engine. It has desktop window made with React-like declarative UI (dip DesktopPlugin) with a button to fetch block number via Beerus.I didn't have time to PoC yet but this plugin should also work in other platforms such as Bevy's 3D render plugins, dip
CLIPlugin
, etc.starknet-light-client-plugin-demo-compressed.mp4
[TODO] Architecture
Things to improve in the future
What's next
On this plugin (StraknetLightClientPlugin)
My initial intention for this experiment is to be used by Dojo project as a gaming client layer. As described in the previous section, the light client is still in a breeding edge. In the long-run, be able to verify on-chain data via Beerus light client provides great values because we don't have to trust untrusted data coming from full-node provider such as Alchemy or Infura. But for a sake of making playable games, we need more practical solution at least for now.
Apibara plugin
That being said, the next step for dip is to create another plugin that wraps Apibara Rust SDK which Dojo WG is already started working on. It requires game client to trust a server that Apibara is hosted but that would provide more realistic UX.
StarknetRsPlugin
Plugin to directly send JSON-RPC request to full-node without verification. You need to trust full-node provider but it's simpler than going through light client.
Auto Dojo <-> Bevy ECS synchronisation
The plugin should automatically sync on-chain ECS state with ECS on the client side (Bevy). As a gaming/application developer standpoint, they just query Entity/Component in Bevy instead of manually implementing logics to fetch data from the chain and store.