Skip to content

Commit

Permalink
eth2near-relay: option for some arg for contract init
Browse files Browse the repository at this point in the history
  • Loading branch information
olga24912 committed Oct 17, 2022
1 parent adeeb5b commit 0a4366e
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 30 deletions.
8 changes: 4 additions & 4 deletions eth2near/contract_wrapper/src/eth_client_contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<bool>,
verify_bls_signatures: Option<bool>,
hashes_gc_threshold: Option<u64>,
max_submitted_blocks_by_account: Option<u32>,
trusted_signer: Option<AccountId>,
Expand All @@ -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,
Expand Down
1 change: 1 addition & 0 deletions eth2near/eth2-contract-init/Cargo.lock

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

10 changes: 5 additions & 5 deletions eth2near/eth2-contract-init/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ pub struct Config {
pub output_dir: Option<String>,

// Timeout for ETH RPC requests in seconds
pub eth_requests_timeout_seconds: u64,
pub eth_requests_timeout_seconds: Option<u64>,

pub validate_updates: bool,
pub validate_updates: Option<bool>,

pub verify_bls_signature: bool,
pub verify_bls_signature: Option<bool>,

pub hashes_gc_threshold: u64,
pub hashes_gc_threshold: Option<u64>,

pub max_submitted_blocks_by_account: u32,
pub max_submitted_blocks_by_account: Option<u32>,

pub trusted_signature: Option<String>,

Expand Down
24 changes: 12 additions & 12 deletions eth2near/eth2-contract-init/src/init_contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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,
);

Expand Down Expand Up @@ -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,
}
Expand All @@ -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, &eth_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();
Expand Down
18 changes: 9 additions & 9 deletions eth2near/eth2near-block-relay-rs/src/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
Expand Down Expand Up @@ -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()),
Expand Down Expand Up @@ -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,
}
Expand Down

0 comments on commit 0a4366e

Please sign in to comment.