Skip to content

Commit

Permalink
Address nits
Browse files Browse the repository at this point in the history
  • Loading branch information
ilitteri committed Mar 1, 2024
1 parent d7789fc commit ac7f5fb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
13 changes: 9 additions & 4 deletions core/lib/config/src/configs/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use zksync_basic_types::{
network::Network,
web3::{
contract::{tokens::Detokenize, Error as Web3ContractError},
ethabi,
ethabi, Error as Web3ApiError,
},
Address, L2ChainId, U256,
};
Expand Down Expand Up @@ -66,18 +66,23 @@ pub enum L1BatchCommitDataGeneratorMode {
// Other values are incorrect.
impl Detokenize for L1BatchCommitDataGeneratorMode {
fn from_tokens(tokens: Vec<ethabi::Token>) -> Result<Self, Web3ContractError> {
let error = Err(Web3ContractError::Abi(ethabi::Error::InvalidData));
fn error(tokens: &[ethabi::Token]) -> Web3ContractError {
Web3ContractError::Api(Web3ApiError::Decoder(format!(
"L1BatchCommitDataGeneratorMode::from_tokens: {tokens:?}"
)))
}

match tokens.as_slice() {
[ethabi::Token::Uint(enum_value)] => {
if enum_value == &U256::zero() {
Ok(L1BatchCommitDataGeneratorMode::Rollup)
} else if enum_value == &U256::one() {
Ok(L1BatchCommitDataGeneratorMode::Validium)
} else {
error
Err(error(&tokens))
}
}
_ => error,
_ => Err(error(&tokens)),
}
}
}
Expand Down
5 changes: 4 additions & 1 deletion core/lib/zksync_core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,10 @@ async fn ensure_l1_batch_commit_data_generation_mode(
// Getters contract support getPubdataPricingMode method
Ok(l1_contract_pubdata_pricing_mode) => {
let l1_contract_batch_commitment_mode =
L1BatchCommitDataGeneratorMode::from_tokens(l1_contract_pubdata_pricing_mode)?;
L1BatchCommitDataGeneratorMode::from_tokens(l1_contract_pubdata_pricing_mode)
.context(
"Unable to parse L1BatchCommitDataGeneratorMode received from L1 contract",
)?;

// contracts mode == server mode
anyhow::ensure!(
Expand Down

0 comments on commit ac7f5fb

Please sign in to comment.