Skip to content

Commit

Permalink
fix: fix forking for [email protected] (#194)
Browse files Browse the repository at this point in the history
  • Loading branch information
nbaztec authored Oct 19, 2023
1 parent f88cefb commit 5364ad0
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 45 deletions.
60 changes: 30 additions & 30 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ categories = ["cryptography"]
publish = false # We don't want to publish our binaries.

[dependencies]
zksync_basic_types = { git = "https://github.com/matter-labs/zksync-era.git", rev = "691a7008f6d1f88fb9a5b6b8d92592e1199f37ea" }
zksync_core = { git = "https://github.com/matter-labs/zksync-era.git", rev = "691a7008f6d1f88fb9a5b6b8d92592e1199f37ea" }
vm = { git = "https://github.com/matter-labs/zksync-era.git", rev = "691a7008f6d1f88fb9a5b6b8d92592e1199f37ea" }
zksync_contracts = { git = "https://github.com/matter-labs/zksync-era.git", rev = "691a7008f6d1f88fb9a5b6b8d92592e1199f37ea" }
zksync_types = { git = "https://github.com/matter-labs/zksync-era.git", rev = "691a7008f6d1f88fb9a5b6b8d92592e1199f37ea" }
zksync_utils = { git = "https://github.com/matter-labs/zksync-era.git", rev = "691a7008f6d1f88fb9a5b6b8d92592e1199f37ea" }
zksync_state = { git = "https://github.com/matter-labs/zksync-era.git", rev = "691a7008f6d1f88fb9a5b6b8d92592e1199f37ea" }
zksync_web3_decl = { git = "https://github.com/matter-labs/zksync-era.git", rev = "691a7008f6d1f88fb9a5b6b8d92592e1199f37ea" }
zksync_basic_types = { git = "https://github.com/matter-labs/zksync-era.git", rev = "e1deecd697e488831de3133e7507cc1cdb06a141" }
zksync_core = { git = "https://github.com/matter-labs/zksync-era.git", rev = "e1deecd697e488831de3133e7507cc1cdb06a141" }
vm = { git = "https://github.com/matter-labs/zksync-era.git", rev = "e1deecd697e488831de3133e7507cc1cdb06a141" }
zksync_contracts = { git = "https://github.com/matter-labs/zksync-era.git", rev = "e1deecd697e488831de3133e7507cc1cdb06a141" }
zksync_types = { git = "https://github.com/matter-labs/zksync-era.git", rev = "e1deecd697e488831de3133e7507cc1cdb06a141" }
zksync_utils = { git = "https://github.com/matter-labs/zksync-era.git", rev = "e1deecd697e488831de3133e7507cc1cdb06a141" }
zksync_state = { git = "https://github.com/matter-labs/zksync-era.git", rev = "e1deecd697e488831de3133e7507cc1cdb06a141" }
zksync_web3_decl = { git = "https://github.com/matter-labs/zksync-era.git", rev = "e1deecd697e488831de3133e7507cc1cdb06a141" }



Expand Down
12 changes: 7 additions & 5 deletions src/fork.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ const SUPPORTED_VERSIONS: &[ProtocolVersionId] = &[
ProtocolVersionId::Version13,
ProtocolVersionId::Version14,
ProtocolVersionId::Version15,
ProtocolVersionId::Version16,
];

pub fn supported_protocol_versions(version: ProtocolVersionId) -> bool {
Expand Down Expand Up @@ -318,8 +319,7 @@ impl ForkDetails<HttpForkSource> {
let block = client
.get_block_by_hash(root_hash, true)
.await
.ok()
.flatten()
.expect("failed retrieving block")
.unwrap_or_else(|| {
panic!(
"Could not find block #{:?} ({:#x}) in {:?}",
Expand Down Expand Up @@ -372,9 +372,11 @@ impl ForkDetails<HttpForkSource> {
pub async fn from_network_tx(fork: &str, tx: H256, cache_config: CacheConfig) -> Self {
let (url, client) = Self::fork_to_url_and_client(fork);
let tx_details = client.get_transaction_by_hash(tx).await.unwrap().unwrap();
let overwrite_chain_id = Some(L2ChainId::try_from(tx_details.chain_id).unwrap_or_else(
|err| panic!("erroneous chain id {}: {:?}", tx_details.chain_id, err,),
));
let overwrite_chain_id = Some(
L2ChainId::try_from(tx_details.chain_id.as_u64()).unwrap_or_else(|err| {
panic!("erroneous chain id {}: {:?}", tx_details.chain_id, err,)
}),
);
let miniblock_number = MiniblockNumber(tx_details.block_number.unwrap().as_u32());
// We have to sync to the one-miniblock before the one where transaction is.
let l2_miniblock = miniblock_number.saturating_sub(1) as u64;
Expand Down
2 changes: 1 addition & 1 deletion src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2121,7 +2121,7 @@ impl<S: Send + Sync + 'static + ForkSource + std::fmt::Debug> EthNamespaceT for
max_priority_fee_per_gas: Some(
info.tx.common_data.fee.max_priority_fee_per_gas,
),
chain_id,
chain_id: U256::from(chain_id),
l1_batch_number: Some(U64::from(info.batch_number as u64)),
l1_batch_tx_index: None,
})
Expand Down
2 changes: 1 addition & 1 deletion src/testing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ impl TransactionResponseBuilder {
"type": "0xff",
"maxFeePerGas": "0x0",
"maxPriorityFeePerGas": "0x0",
"chainId": 260,
"chainId": "0x104",
"l1BatchNumber": "0x1",
"l1BatchTxIndex": "0x0",
})
Expand Down

0 comments on commit 5364ad0

Please sign in to comment.