diff --git a/abi/IZkSyncV2.json b/abi/IZkSyncV2.json index 4e3d572..a82b32f 100644 --- a/abi/IZkSyncV2.json +++ b/abi/IZkSyncV2.json @@ -6,25 +6,42 @@ "name": "_initialOwner", "type": "address" }, - { - "internalType": "address", - "name": "_zkSyncContract", - "type": "address" - }, { "internalType": "uint32", "name": "_executionDelay", "type": "uint32" }, { - "internalType": "address", - "name": "_validator", - "type": "address" + "internalType": "uint256", + "name": "_eraChainId", + "type": "uint256" } ], "stateMutability": "nonpayable", "type": "constructor" }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_chainId", + "type": "uint256" + } + ], + "name": "AddressAlreadyValidator", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_chainId", + "type": "uint256" + } + ], + "name": "ValidatorDoesNotExist", + "type": "error" + }, { "anonymous": false, "inputs": [ @@ -136,19 +153,19 @@ "anonymous": false, "inputs": [ { - "indexed": false, + "indexed": true, "internalType": "address", - "name": "_oldValidator", + "name": "previousOwner", "type": "address" }, { - "indexed": false, + "indexed": true, "internalType": "address", - "name": "_newValidator", + "name": "newOwner", "type": "address" } ], - "name": "NewValidator", + "name": "OwnershipTransferStarted", "type": "event" }, { @@ -167,7 +184,7 @@ "type": "address" } ], - "name": "OwnershipTransferStarted", + "name": "OwnershipTransferred", "type": "event" }, { @@ -175,18 +192,37 @@ "inputs": [ { "indexed": true, + "internalType": "uint256", + "name": "_chainId", + "type": "uint256" + }, + { + "indexed": false, "internalType": "address", - "name": "previousOwner", + "name": "_addedValidator", "type": "address" - }, + } + ], + "name": "ValidatorAdded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ { "indexed": true, + "internalType": "uint256", + "name": "_chainId", + "type": "uint256" + }, + { + "indexed": false, "internalType": "address", - "name": "newOwner", + "name": "_removedValidator", "type": "address" } ], - "name": "OwnershipTransferred", + "name": "ValidatorRemoved", "type": "event" }, { @@ -196,6 +232,24 @@ "stateMutability": "nonpayable", "type": "function" }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_chainId", + "type": "uint256" + }, + { + "internalType": "address", + "name": "_newValidator", + "type": "address" + } + ], + "name": "addValidator", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, { "inputs": [ { @@ -294,7 +348,7 @@ }, { "internalType": "bytes", - "name": "totalL2ToL1Pubdata", + "name": "pubdataCommitments", "type": "bytes" } ], @@ -308,6 +362,123 @@ "stateMutability": "nonpayable", "type": "function" }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_chainId", + "type": "uint256" + }, + { + "components": [ + { + "internalType": "uint64", + "name": "batchNumber", + "type": "uint64" + }, + { + "internalType": "bytes32", + "name": "batchHash", + "type": "bytes32" + }, + { + "internalType": "uint64", + "name": "indexRepeatedStorageChanges", + "type": "uint64" + }, + { + "internalType": "uint256", + "name": "numberOfLayer1Txs", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "priorityOperationsHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "l2LogsTreeRoot", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "timestamp", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "commitment", + "type": "bytes32" + } + ], + "internalType": "struct IExecutor.StoredBatchInfo", + "name": "", + "type": "tuple" + }, + { + "components": [ + { + "internalType": "uint64", + "name": "batchNumber", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "timestamp", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "indexRepeatedStorageChanges", + "type": "uint64" + }, + { + "internalType": "bytes32", + "name": "newStateRoot", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "numberOfLayer1Txs", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "priorityOperationsHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "bootloaderHeapInitialContentsHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "eventsQueueStateHash", + "type": "bytes32" + }, + { + "internalType": "bytes", + "name": "systemLogs", + "type": "bytes" + }, + { + "internalType": "bytes", + "name": "pubdataCommitments", + "type": "bytes" + } + ], + "internalType": "struct IExecutor.CommitBatchInfo[]", + "name": "_newBatchesData", + "type": "tuple[]" + } + ], + "name": "commitBatchesSharedBridge", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, { "inputs": [ { @@ -363,6 +534,66 @@ "stateMutability": "nonpayable", "type": "function" }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_chainId", + "type": "uint256" + }, + { + "components": [ + { + "internalType": "uint64", + "name": "batchNumber", + "type": "uint64" + }, + { + "internalType": "bytes32", + "name": "batchHash", + "type": "bytes32" + }, + { + "internalType": "uint64", + "name": "indexRepeatedStorageChanges", + "type": "uint64" + }, + { + "internalType": "uint256", + "name": "numberOfLayer1Txs", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "priorityOperationsHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "l2LogsTreeRoot", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "timestamp", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "commitment", + "type": "bytes32" + } + ], + "internalType": "struct IExecutor.StoredBatchInfo[]", + "name": "_newBatchesData", + "type": "tuple[]" + } + ], + "name": "executeBatchesSharedBridge", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, { "inputs": [], "name": "executionDelay", @@ -378,6 +609,11 @@ }, { "inputs": [ + { + "internalType": "uint256", + "name": "_chainId", + "type": "uint256" + }, { "internalType": "uint256", "name": "_l2BatchNumber", @@ -553,6 +789,148 @@ "stateMutability": "nonpayable", "type": "function" }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_chainId", + "type": "uint256" + }, + { + "components": [ + { + "internalType": "uint64", + "name": "batchNumber", + "type": "uint64" + }, + { + "internalType": "bytes32", + "name": "batchHash", + "type": "bytes32" + }, + { + "internalType": "uint64", + "name": "indexRepeatedStorageChanges", + "type": "uint64" + }, + { + "internalType": "uint256", + "name": "numberOfLayer1Txs", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "priorityOperationsHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "l2LogsTreeRoot", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "timestamp", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "commitment", + "type": "bytes32" + } + ], + "internalType": "struct IExecutor.StoredBatchInfo", + "name": "", + "type": "tuple" + }, + { + "components": [ + { + "internalType": "uint64", + "name": "batchNumber", + "type": "uint64" + }, + { + "internalType": "bytes32", + "name": "batchHash", + "type": "bytes32" + }, + { + "internalType": "uint64", + "name": "indexRepeatedStorageChanges", + "type": "uint64" + }, + { + "internalType": "uint256", + "name": "numberOfLayer1Txs", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "priorityOperationsHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "l2LogsTreeRoot", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "timestamp", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "commitment", + "type": "bytes32" + } + ], + "internalType": "struct IExecutor.StoredBatchInfo[]", + "name": "", + "type": "tuple[]" + }, + { + "components": [ + { + "internalType": "uint256[]", + "name": "recursiveAggregationInput", + "type": "uint256[]" + }, + { + "internalType": "uint256[]", + "name": "serializedProof", + "type": "uint256[]" + } + ], + "internalType": "struct IExecutor.ProofInput", + "name": "", + "type": "tuple" + } + ], + "name": "proveBatchesSharedBridge", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_chainId", + "type": "uint256" + }, + { + "internalType": "address", + "name": "_validator", + "type": "address" + } + ], + "name": "removeValidator", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, { "inputs": [], "name": "renounceOwnership", @@ -573,6 +951,24 @@ "stateMutability": "nonpayable", "type": "function" }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_chainId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "revertBatchesSharedBridge", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, { "inputs": [ { @@ -589,16 +985,29 @@ { "inputs": [ { - "internalType": "address", - "name": "_newValidator", + "internalType": "contract IStateTransitionManager", + "name": "_stateTransitionManager", "type": "address" } ], - "name": "setValidator", + "name": "setStateTransitionManager", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, + { + "inputs": [], + "name": "stateTransitionManager", + "outputs": [ + { + "internalType": "contract IStateTransitionManager", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, { "inputs": [ { @@ -613,26 +1022,24 @@ "type": "function" }, { - "inputs": [], - "name": "validator", - "outputs": [ + "inputs": [ + { + "internalType": "uint256", + "name": "_chainId", + "type": "uint256" + }, { "internalType": "address", - "name": "", + "name": "_validator", "type": "address" } ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "zkSyncContract", + "name": "validators", "outputs": [ { - "internalType": "address", + "internalType": "bool", "name": "", - "type": "address" + "type": "bool" } ], "stateMutability": "view", diff --git a/state-reconstruct-fetcher/src/l1_fetcher.rs b/state-reconstruct-fetcher/src/l1_fetcher.rs index 540fc2e..2d3bdba 100644 --- a/state-reconstruct-fetcher/src/l1_fetcher.rs +++ b/state-reconstruct-fetcher/src/l1_fetcher.rs @@ -501,8 +501,8 @@ impl L1Fetcher { Ok(tokio::spawn({ async move { let mut boojum_mode = false; - let mut function = - contracts.v1.functions_by_name("commitBlocks").unwrap()[0].clone(); + let mut functions = + vec![contracts.v1.functions_by_name("commitBlocks").unwrap()[0].clone()]; let mut last_block_number_processed = None; while let Some(tx) = l1_tx_rx.recv().await { @@ -521,12 +521,18 @@ impl L1Fetcher { if !boojum_mode && block_number >= BOOJUM_BLOCK { tracing::debug!("Reached `BOOJUM_BLOCK`, changing commit block format"); boojum_mode = true; - function = - contracts.v2.functions_by_name("commitBatches").unwrap()[0].clone(); + functions = vec![ + contracts.v2.functions_by_name("commitBatches").unwrap()[0].clone(), + contracts + .v2 + .functions_by_name("commitBatchesSharedBridge") + .unwrap()[0] + .clone(), + ]; } let blocks = loop { - match parse_calldata(block_number, &function, &tx.input, &client).await { + match parse_calldata(block_number, &functions, &tx.input, &client).await { Ok(blks) => break blks, Err(e) => match e { ParseError::BlobStorageError(_) => { @@ -595,18 +601,27 @@ impl L1Fetcher { pub async fn parse_calldata( l1_block_number: u64, - commit_blocks_fn: &Function, + commit_candidates: &Vec, calldata: &[u8], client: &BlobHttpClient, ) -> Result, ParseError> { - let mut parsed_input = commit_blocks_fn + if calldata.len() < 4 { + return Err(ParseError::InvalidCalldata("too short".to_string())); + } + + let commit_fn = commit_candidates + .iter() + .find(|f| f.short_signature() == calldata[..4]) + .ok_or_else(|| ParseError::InvalidCalldata("signature not found".to_string()))?; + let mut parsed_input = commit_fn .decode_input(&calldata[4..]) .map_err(|e| ParseError::InvalidCalldata(e.to_string()))?; - if parsed_input.len() != 2 { + let argc = parsed_input.len(); + if argc != 2 && argc != 3 { return Err(ParseError::InvalidCalldata(format!( - "invalid number of parameters (got {}, expected 2) for commitBlocks function", - parsed_input.len() + "invalid number of parameters (got {}, expected 2 or 3) for commitBlocks function", + argc ))); }