diff --git a/eth2near/contract_wrapper/src/eth_client_contract.rs b/eth2near/contract_wrapper/src/eth_client_contract.rs index 28156ba5c..b5c5e639d 100644 --- a/eth2near/contract_wrapper/src/eth_client_contract.rs +++ b/eth2near/contract_wrapper/src/eth_client_contract.rs @@ -52,8 +52,8 @@ impl EthClientContract { finalized_beacon_header: ExtendedBeaconBlockHeader, current_sync_committee: SyncCommittee, next_sync_committee: SyncCommittee, - validate_updates: bool, - verify_bls_signatures: bool, + validate_updates: Option, + verify_bls_signatures: Option, hashes_gc_threshold: Option, max_submitted_blocks_by_account: Option, trusted_signer: Option, @@ -78,8 +78,8 @@ impl EthClientContract { finalized_beacon_header, current_sync_committee, next_sync_committee, - validate_updates, - verify_bls_signatures, + validate_updates: validate_updates.unwrap_or(true), + verify_bls_signatures: verify_bls_signatures.unwrap_or(false), hashes_gc_threshold: hashes_gc_threshold.unwrap_or(51_000), max_submitted_blocks_by_account: max_submitted_blocks_by_account.unwrap_or(8000), trusted_signer, diff --git a/eth2near/eth2-contract-init/Cargo.lock b/eth2near/eth2-contract-init/Cargo.lock index 210cc244a..48dd473eb 100644 --- a/eth2near/eth2-contract-init/Cargo.lock +++ b/eth2near/eth2-contract-init/Cargo.lock @@ -1257,6 +1257,7 @@ dependencies = [ "near-jsonrpc-primitives", "near-primitives 0.14.0", "near-sdk", + "primitive-types 0.7.3", "prometheus", "reqwest", "serde", diff --git a/eth2near/eth2-contract-init/src/config.rs b/eth2near/eth2-contract-init/src/config.rs index f7963a68d..6f8fc829e 100644 --- a/eth2near/eth2-contract-init/src/config.rs +++ b/eth2near/eth2-contract-init/src/config.rs @@ -36,15 +36,15 @@ pub struct Config { pub output_dir: Option, // Timeout for ETH RPC requests in seconds - pub eth_requests_timeout_seconds: u64, + pub eth_requests_timeout_seconds: Option, - pub validate_updates: bool, + pub validate_updates: Option, - pub verify_bls_signature: bool, + pub verify_bls_signature: Option, - pub hashes_gc_threshold: u64, + pub hashes_gc_threshold: Option, - pub max_submitted_blocks_by_account: u32, + pub max_submitted_blocks_by_account: Option, pub trusted_signature: Option, diff --git a/eth2near/eth2-contract-init/src/init_contract.rs b/eth2near/eth2-contract-init/src/init_contract.rs index 5cb9c5016..18c46d752 100644 --- a/eth2near/eth2-contract-init/src/init_contract.rs +++ b/eth2near/eth2-contract-init/src/init_contract.rs @@ -47,14 +47,14 @@ pub fn init_contract( info!(target: "relay", "=== Contract initialization ==="); if let NearNetwork::Mainnet = config.near_network_id { - assert!(config.validate_updates, "The updates validation can't be disabled for mainnet"); - assert!(config.verify_bls_signature || config.trusted_signature.is_some(), "The client can't be executed in the trustless mode without BLS sigs verification on Mainnet"); + assert!(config.validate_updates.unwrap_or(true), "The updates validation can't be disabled for mainnet"); + assert!(config.verify_bls_signature.unwrap_or(false) || config.trusted_signature.is_some(), "The client can't be executed in the trustless mode without BLS sigs verification on Mainnet"); } let beacon_rpc_client = BeaconRPCClient::new( &config.beacon_endpoint, - config.eth_requests_timeout_seconds, - config.eth_requests_timeout_seconds, + config.eth_requests_timeout_seconds.unwrap_or(10), + config.eth_requests_timeout_seconds.unwrap_or(10), ); let eth1_rpc_client = Eth1RPCClient::new(&config.eth1_endpoint); @@ -126,8 +126,8 @@ pub fn init_contract( next_sync_committee, config.validate_updates, config.verify_bls_signature, - Some(config.hashes_gc_threshold), - Some(config.max_submitted_blocks_by_account), + config.hashes_gc_threshold, + config.max_submitted_blocks_by_account, trusted_signature, ); @@ -169,11 +169,11 @@ mod tests { ethereum_network: config_for_test.network_name.clone(), near_network_id: NearNetwork::Testnet, output_dir: None, - eth_requests_timeout_seconds: 30, - validate_updates: true, - verify_bls_signature: false, - hashes_gc_threshold: 51000, - max_submitted_blocks_by_account: 8000, + eth_requests_timeout_seconds: Some(30), + validate_updates: Some(true), + verify_bls_signature: Some(false), + hashes_gc_threshold: Some(51000), + max_submitted_blocks_by_account: Some(8000), trusted_signature: Some(eth_client_contract.get_signer_account_id().to_string()), init_block_root: None, } @@ -189,7 +189,7 @@ mod tests { let mut eth_client_contract = EthClientContract::new(contract_wrapper); let mut init_config = get_init_config(&config_for_test, ð_client_contract); - init_config.validate_updates = false; + init_config.validate_updates = Some(false); init_config.near_network_id = NearNetwork::Mainnet; init_contract(&init_config, &mut eth_client_contract).unwrap(); diff --git a/eth2near/eth2near-block-relay-rs/src/test_utils.rs b/eth2near/eth2near-block-relay-rs/src/test_utils.rs index 2abd42608..ef0275735 100644 --- a/eth2near/eth2near-block-relay-rs/src/test_utils.rs +++ b/eth2near/eth2near-block-relay-rs/src/test_utils.rs @@ -79,8 +79,8 @@ pub fn init_contract_from_files( finalized_beacon_header, current_sync_committee, next_sync_committee, - true, - false, + Some(true), + Some(false), None, None, Some(eth_client_contract.contract_wrapper.get_signer_account_id()), @@ -155,8 +155,8 @@ pub fn init_contract_from_specific_slot( finalized_beacon_header, current_sync_committee, next_sync_committee, - true, - false, + Some(true), + Some(false), None, None, Some(eth_client_contract.contract_wrapper.get_signer_account_id()), @@ -220,11 +220,11 @@ fn get_init_config( ethereum_network: config_for_test.network_name.clone(), near_network_id: NearNetwork::Testnet, output_dir: None, - eth_requests_timeout_seconds: 30, - validate_updates: true, - verify_bls_signature: false, - hashes_gc_threshold: 51000, - max_submitted_blocks_by_account: 8000, + eth_requests_timeout_seconds: Some(30), + validate_updates: Some(true), + verify_bls_signature: Some(false), + hashes_gc_threshold: Some(51000), + max_submitted_blocks_by_account: Some(8000), trusted_signature: Some(eth_client_contract.get_signer_account_id().to_string()), init_block_root: None, }