-
Notifications
You must be signed in to change notification settings - Fork 52
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
feat: L3 support #437
base: main
Are you sure you want to change the base?
feat: L3 support #437
Changes from 7 commits
8949443
abc808e
a49e209
0d6168e
76bc944
75229a4
661cd33
62fb337
d4aa988
a4314be
9dea223
fafd2c3
aa7834e
6c1ff95
26c9319
2a19391
8abf999
749df1c
b63cf61
c837570
1d4d3a4
fffd9dd
71c5524
62d1df3
79ef5ab
8657da3
7afd1a3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,6 +30,14 @@ jobs: | |
while ! nc -z localhost 8545; do | ||
sleep 1 | ||
done | ||
# TODO : For now madara binary is stored in aws s3 bucket : | ||
# After the proper release binaries are implemented | ||
# We can directly use that and we can remove this | ||
# temporary AWS implementation | ||
- name: Download madara binary for l2 client testing | ||
run: | | ||
curl -L https://madara-test-binary.s3.us-west-1.amazonaws.com/madara-linux -o ./test-artifacts/madara | ||
chmod +x ./test-artifacts/madara | ||
Comment on lines
+37
to
+40
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto |
||
|
||
- name: Run unit tests | ||
run: | | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
|
||
## Next release | ||
|
||
- feat : l3 support | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you can remove it |
||
- fix: devnet accounts getting deployed in sequencer mode | ||
- fix(rpc): fix BroadcastedDeclareTxn V3 in starknet-types-rpc | ||
- fix: oracle need condition | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
use crate::eth::StarknetCoreContract::StarknetCoreContractInstance; | ||
use crate::gas_price::L1BlockMetrics; | ||
use crate::state_update::StateUpdate; | ||
use alloy::contract::Event; | ||
use alloy::primitives::FixedBytes; | ||
use alloy::providers::RootProvider; | ||
use alloy::sol_types::SolEvent; | ||
use alloy::transports::http::{Client, Http}; | ||
use async_trait::async_trait; | ||
use mc_db::MadaraBackend; | ||
use mp_utils::service::ServiceContext; | ||
use starknet_types_core::felt::Felt; | ||
use std::sync::Arc; | ||
|
||
pub enum ClientType { | ||
ETH, | ||
STARKNET, | ||
} | ||
|
||
pub enum CoreContractInstance { | ||
Ethereum(StarknetCoreContractInstance<Http<Client>, RootProvider<Http<Client>>>), | ||
Starknet(Felt), | ||
} | ||
|
||
impl CoreContractInstance { | ||
#[allow(clippy::type_complexity)] | ||
pub fn event_filter<T: SolEvent>(&self) -> anyhow::Result<Event<Http<Client>, &RootProvider<Http<Client>>, T>> { | ||
match self { | ||
CoreContractInstance::Ethereum(contract) => Ok(contract.event_filter()), | ||
CoreContractInstance::Starknet(_) => Err(anyhow::anyhow!("Starknet doesn't support event filters")), | ||
apoorvsadana marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
} | ||
} | ||
|
||
#[async_trait] | ||
pub trait ClientTrait: Send + Sync { | ||
// Provider type used by the implementation | ||
type Provider; | ||
apoorvsadana marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// Configuration type used for initialization | ||
type Config; | ||
|
||
// Basic getter functions | ||
fn get_l1_block_metrics(&self) -> &L1BlockMetrics; | ||
fn get_core_contract_instance(&self) -> CoreContractInstance; | ||
fn get_client_type(&self) -> ClientType; | ||
|
||
// Create a new instance of the client | ||
async fn new(config: Self::Config) -> anyhow::Result<Self> | ||
where | ||
Self: Sized; | ||
|
||
// Get the latest block number | ||
async fn get_latest_block_number(&self) -> anyhow::Result<u64>; | ||
|
||
// Get the block number of the last occurrence of a specific event | ||
async fn get_last_event_block_number(&self) -> anyhow::Result<u64>; | ||
|
||
// Get the last verified block number | ||
async fn get_last_verified_block_number(&self) -> anyhow::Result<u64>; | ||
|
||
// Get the last state root | ||
// - change this to Felt in implementation | ||
// - write tests for conversion to Felt from <native-type> | ||
async fn get_last_state_root(&self) -> anyhow::Result<Felt>; | ||
Mohiiit marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
// Get the last verified block hash | ||
async fn get_last_verified_block_hash(&self) -> anyhow::Result<Felt>; | ||
|
||
// Get initial state from client | ||
async fn get_initial_state(&self) -> anyhow::Result<StateUpdate>; | ||
async fn listen_for_update_state_events( | ||
&self, | ||
backend: Arc<MadaraBackend>, | ||
ctx: ServiceContext, | ||
) -> anyhow::Result<()>; | ||
|
||
// get gas prices | ||
async fn get_eth_gas_prices(&self) -> anyhow::Result<(u128, u128)>; | ||
apoorvsadana marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
/// Get cancellation status of an L1 to L2 message | ||
/// | ||
/// This function query the core contract to know if a L1->L2 message has been cancelled | ||
/// # Arguments | ||
/// | ||
/// - msg_hash : Hash of L1 to L2 message | ||
/// | ||
/// # Return | ||
/// | ||
/// - A felt representing a timestamp : | ||
/// - 0 if the message has not been cancelled | ||
/// - timestamp of the cancellation if it has been cancelled | ||
/// - An Error if the call fail | ||
async fn get_l1_to_l2_message_cancellations(&self, msg_hash: FixedBytes<32>) -> anyhow::Result<Felt>; | ||
} |
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.
Why are we downloading a madara binary for testing instead of running against a build of the code in the pr?