eigerco / beerus Goto Github PK
View Code? Open in Web Editor NEWA stateless trustless Starknet light client in Rust ๐ฆ
License: MIT License
A stateless trustless Starknet light client in Rust ๐ฆ
License: MIT License
We should add test coverage measurement in the project and add it in the CI
Add a Rest API wrapper to interact with Beerus Light Client Features
Increase test coverage. First pass.
Implement "get_class" Starknet RPC call
Starknet-RS Implementation
https://github.com/xJonathanLEI/starknet-rs/blob/da72d0130eb48cc84288c9948d983f5f78cf6054/starknet-providers/src/jsonrpc/mod.rs#L227
Implement "get_transaction_count" Ethereum RPC call
Helios implmentation: https://github.com/a16z/helios/blob/94bf458d941f30e34faeaa7d2484898dba54234d/client/src/rpc.rs#L59
Beerus-cli usage is inaccessible without setting appropriate environment variables making it impossible to get usage like beerus-cli -v
or beerus-cli -h
. Things like tag checking to implement #6 will be easier with proper usage implementation.
beerus-cli -v
available when environment variables aren't setbeerus-cli -h
available when environment variables aren't setImplement "get_transaction_by_hash" Ethereum RPC call
Helios implmentation: https://github.com/a16z/helios/blob/94bf458d941f30e34faeaa7d2484898dba54234d/client/src/rpc.rs#L94
Currently block Number is set to "latest", there is a need to change it so the argument comes from the command line or the REST API call.
CI workflows are currently slow, we can speed up the process by caching dependencies.
Implement "get_code" Ethereum RPC call
Helios implmentation: https://github.com/a16z/helios/blob/94bf458d941f30e34faeaa7d2484898dba54234d/client/src/rpc.rs#L61
Implement "get_logs" Ethereum RPC call
Helios implmentation: https://github.com/a16z/helios/blob/ac8a145ae33e72b62e017749fd0d3e1887d3999e/client/src/rpc.rs#L101
Implement "get_block_by_hash" Ethereum RPC call
Helios implmentation: https://github.com/a16z/helios/blob/94bf458d941f30e34faeaa7d2484898dba54234d/client/src/rpc.rs#L81
Mock ethereum full node and StarkNet full node for integration tests
This beerus endpoint will return the specified storage value after being verified with the contract state root + the starknet state root
Function:
pub fn get_contract_storage_value(contract_address: Felt, storage_var_key: Felt) -> Result<Felt, Error>
get_contract_storage_value
get_contract_storage_value
has associated unit tests and integration testsCurrently the project is not really test friendly since it has a lot of external dependencies.
We need to make it more flexible and suitable for proper testing architecture.
The plan is to be able to use mockall to mock external dependencies.
Describe the Feature Request
As a user, I would like to query l2ToL1Messages
of the StarkNetCore
contract.
Describe Preferred Solution
l2ToL1Messages
is accessible in the core library, and as a CLI command, and a REST API endpoint.
Describe Alternatives
Related Code
beerus_core
beerus_cli
beerus_rest_api
Yes
No
We need to implement the verification of the storage proof when we access StarkNet state.
To do that we must use pathfinder_getStorageProofs
endpoint.
The PR in PathFinder is here: eqlabs/pathfinder#726
It has been merge.
CLI and Rest API Wrapper will be done in follow up PRs.
Describe the Feature Request
As a user, I would like to query l1ToL2Messages
of the StarkNetCore
contract.
Describe Preferred Solution
l1ToL2Messages
is accessible in the core library, and as a CLI command, and a REST API endpoint.
Describe Alternatives
Related Code
beerus_core
beerus_cli
beerus_rest_api
Yes
No
Implement "get_transaction_by_hash" Starknet RPC call
Starknet-RS Implementation
https://github.com/xJonathanLEI/starknet-rs/blob/da72d0130eb48cc84288c9948d983f5f78cf6054/starknet-providers/src/jsonrpc/mod.rs#L187
Beerus version: 0.1.0
Current behavior:
When doing a fresh install of beerusup
using
curl -sL https://raw.githubusercontent.com/keep-starknet-strange/beerus/main/beerusup | sh
beerus_cli
is added to path but line 121 throws an error because it's being called as if it has been added to $PATH
but the $PROFILE
hasn't been sourced yet.
Expected behavior:
No error and instead version is shown.
Steps to reproduce:
Do a fresh install of beerusup
using
curl -sL https://raw.githubusercontent.com/keep-starknet-strange/beerus/main/beerusup | sh
Related code:
Other information:
Implement "get_block_transaction_count_by_hash" Ethereum RPC call
Helios implmentation: https://github.com/a16z/helios/blob/ac8a145ae33e72b62e017749fd0d3e1887d3999e/client/src/rpc.rs#L61
Implement "chain_id" Starknet RPC call
Starknet-RS Implementation
https://github.com/xJonathanLEI/starknet-rs/blob/da72d0130eb48cc84288c9948d983f5f78cf6054/starknet-providers/src/jsonrpc/mod.rs#L342
Use Rust workspace for the project.
Specifically the workspace must have the following members:
Implement "estimate_gas" Ethereum RPC call
Helios implmentation: https://github.com/a16z/helios/blob/ac8a145ae33e72b62e017749fd0d3e1887d3999e/client/src/rpc.rs#L70
We need to implement a client to consume PathFinder endpoints
Implement "chain_id" Ethereum RPC call
Helios implmentation: https://github.com/a16z/helios/blob/94bf458d941f30e34faeaa7d2484898dba54234d/client/src/rpc.rs#L67
Beerus needs to be fully tested so we need to increase the test coverage
Beerus core coverage is at least at 90%
Add a handy script to install beerus.
Inspiration: https://github.com/a16z/helios/blob/master/heliosup/install
Implement "estimate_gas" Ethereum RPC call
Helios implmentation: https://github.com/a16z/helios/blob/94bf458d941f30e34faeaa7d2484898dba54234d/client/src/rpc.rs#L65
Implement "block_number" Starknet RPC call
Starknet-RS Implementation
https://github.com/xJonathanLEI/starknet-rs/blob/da72d0130eb48cc84288c9948d983f5f78cf6054/starknet-providers/src/jsonrpc/mod.rs#L329
The Rest API should support Open API specification.
Describe the Feature Request
As a user, I would like to query l1ToL2MessageCancellations
of the StarkNetCore
contract.
Describe Preferred Solution
l1ToL2MessageCancellations
is accessible in the core library, and as a CLI command, and a REST API endpoint.
Describe Alternatives
Related Code
beerus_core
beerus_cli
beerus_rest_api
Yes
No
Implement "get_transaction_count" Ethereum RPC call
Helios implmentation: https://github.com/a16z/helios/blob/ac8a145ae33e72b62e017749fd0d3e1887d3999e/client/src/rpc.rs#L59
Implement "max_priority_fee_per_gas" Ethereum RPC call
Helios implmentation: https://github.com/a16z/helios/blob/ac8a145ae33e72b62e017749fd0d3e1887d3999e/client/src/rpc.rs#L76
Describe the Feature Request
As a user, I would like to query l1ToL2MessageNonce
of the StarkNetCore
contract.
Describe Preferred Solution
l1ToL2MessageNonce
is accessible in the core library, and as a CLI command, and a REST API endpoint.
Describe Alternatives
Related Code
beerus_core
beerus_cli
beerus_rest_api
Yes
No
We should expose a library endpoint to retrieve StarkNet state root.
Things to consider:
- What is the value of the StarkNet contract address? (hardcoded, configurable, etc)
We decided to have the StarkNet contract address configurable, defaulted with a hardcoded value (likely a mapping of known networks to contract address).
Now that we have a testable and mockable architecture, we can start to increase the test coverage of the project.
Let's start with the starknet_state_root
of BeerusLightClient
.
mockall
crate and setup test archistarknet_state_root
is testedstarknet_state_root
are testedThe light client needs a connection to a full node in order to operate.
Note that this connection is trustless and can be insecure, since the light client verifies storage proofs.
Implement "query_block_number" Ethereum RPC call
Helios implmentation: https://github.com/a16z/helios/blob/94bf458d941f30e34faeaa7d2484898dba54234d/client/src/rpc.rs#L73
Implement "get_block_by_number" Ethereum RPC call
Helios implmentation: https://github.com/a16z/helios/blob/94bf458d941f30e34faeaa7d2484898dba54234d/client/src/rpc.rs#L75
Setup an infrastructure for integration testing.
Should include:
In order to prepare the get_contract_storage_value
we need to have the structure of the endpoint in the library, cli and rest api.
get_contract_storage_value
We should test the REST API endpoints using rocket testing capabilities. See https://rocket.rs/v0.5-rc/guide/testing/
Implement "block_hash_and_number" Starknet RPC call
Starknet-RS Implementation
https://github.com/xJonathanLEI/starknet-rs/blob/da72d0130eb48cc84288c9948d983f5f78cf6054/starknet-providers/src/jsonrpc/mod.rs#L334
Implement "gas_price" Ethereum RPC call
Helios implmentation: https://github.com/a16z/helios/blob/94bf458d941f30e34faeaa7d2484898dba54234d/client/src/rpc.rs#L69
In order to verify the value sent by the full node we need the contract storage proof.
We need the latest proved block for starknet to know the block number for pathfinder query
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.