Skip to content

Commit

Permalink
Call updateValidatorsSet()
Browse files Browse the repository at this point in the history
  • Loading branch information
sug0 committed Feb 14, 2023
1 parent 71b084d commit dfcb99b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 7 deletions.
5 changes: 5 additions & 0 deletions apps/src/lib/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1909,6 +1909,7 @@ pub mod args {
const DRY_RUN_TX: ArgFlag = flag("dry-run");
const EPOCH: ArgOpt<Epoch> = arg_opt("epoch");
const ERC20: Arg<EthAddress> = arg("erc20");
const ETH_CONFIRMATIONS: Arg<u64> = arg("confirmations");
const ETH_GAS: ArgOpt<u64> = arg_opt("eth-gas");
const ETH_GAS_PRICE: ArgOpt<u64> = arg_opt("eth-gas-price");
const ETH_ADDRESS: Arg<EthAddress> = arg("ethereum-address");
Expand Down Expand Up @@ -2237,6 +2238,8 @@ pub mod args {
pub struct ValidatorSetUpdateRelay {
/// The query parameters.
pub query: Query,
/// The number of block confirmations on Ethereum.
pub confirmations: u64,
/// The Ethereum RPC endpoint.
pub eth_rpc_endpoint: String,
/// The epoch of the validator set to relay.
Expand All @@ -2256,11 +2259,13 @@ pub mod args {
let gas = ETH_GAS.parse(matches);
let gas_price = ETH_GAS_PRICE.parse(matches);
let eth_rpc_endpoint = ETH_RPC_ENDPOINT.parse(matches);
let confirmations = ETH_CONFIRMATIONS.parse(matches);
Self {
query,
epoch,
gas,
gas_price,
confirmations,
eth_rpc_endpoint,
}
}
Expand Down
28 changes: 21 additions & 7 deletions apps/src/lib/client/eth_bridge/validator_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,17 +89,31 @@ pub async fn relay_validator_set_update(args: args::ValidatorSetUpdateRelay) {
let active_set: ValidatorSetArgs =
abi_decode_struct(encoded_validator_set_args);

println!("Bridge hash: {bridge_hash:?}");
println!("Governance hash: {gov_hash:?}");
println!("Active: {active_set:?}");
println!("Sigs: {signatures:?}");
println!("Governance addr: {}", governance_contract.address);

let eth_client =
Arc::new(Provider::<Http>::try_from(&args.eth_rpc_endpoint).unwrap());
let governance = Governance::new(governance_contract.address, eth_client);

drop(governance);
let mut relay_op = governance.update_validators_set(
active_set,
bridge_hash,
gov_hash,
signatures,
epoch_to_relay.0.into(),
);
if let Some(gas) = args.gas {
relay_op.tx.set_gas(gas);
}
if let Some(gas_price) = args.gas_price {
relay_op.tx.set_gas_price(gas_price);
}

let pending_tx = relay_op.send().await.unwrap();
let transf_result = pending_tx
.confirmations(args.confirmations as usize)
.await
.unwrap();

println!("{transf_result:?}");
}

// NOTE: there's a bug (or feature?!) in ethers, where
Expand Down

0 comments on commit dfcb99b

Please sign in to comment.