Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: prefer finalize_signed_extrinsic in engine #3956

Merged
merged 3 commits into from
Sep 6, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion engine/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ async fn start(
.await?;

state_chain_client
.submit_signed_extrinsic(pallet_cf_validator::Call::cfe_version {
.finalize_signed_extrinsic(pallet_cf_validator::Call::cfe_version {
new_version: *CFE_VERSION,
})
.await
Expand Down
2 changes: 1 addition & 1 deletion engine/src/p2p/peer_info_submitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ async fn update_registered_peer_id<StateChainClient>(
};

state_chain_client
.submit_signed_extrinsic(pallet_cf_validator::Call::register_peer_id {
.finalize_signed_extrinsic(pallet_cf_validator::Call::register_peer_id {
peer_id,
port: cfe_port,
ip_address: ip_address.into(),
Expand Down
38 changes: 19 additions & 19 deletions engine/src/state_chain_observer/sc_observer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,17 @@ async fn handle_keygen_request<'a, StateChainClient, MultisigClient, C, I>(
multisig_client.initiate_keygen(ceremony_id, epoch_index, keygen_participants);
scope.spawn(async move {
state_chain_client
.submit_signed_extrinsic(pallet_cf_vaults::Call::<
state_chain_runtime::Runtime,
I,
>::report_keygen_outcome {
ceremony_id,
reported_outcome: keygen_result_future
.await
.map(I::pubkey_to_aggkey)
.map_err(|(bad_account_ids, _reason)| bad_account_ids),
})
.await;
.finalize_signed_extrinsic(pallet_cf_vaults::Call::<
state_chain_runtime::Runtime,
I,
>::report_keygen_outcome {
ceremony_id,
reported_outcome: keygen_result_future
.await
.map(I::pubkey_to_aggkey)
.map_err(|(bad_account_ids, _reason)| bad_account_ids),
})
.await;
Ok(())
});
} else {
Expand Down Expand Up @@ -116,7 +116,7 @@ async fn handle_key_handover_request<'a, StateChainClient, MultisigClient>(
);
scope.spawn(async move {
let _result = state_chain_client
.submit_signed_extrinsic(pallet_cf_vaults::Call::<
.finalize_signed_extrinsic(pallet_cf_vaults::Call::<
state_chain_runtime::Runtime,
BitcoinInstance,
>::report_key_handover_outcome {
Expand Down Expand Up @@ -165,7 +165,7 @@ async fn handle_signing_request<'a, StateChainClient, MultisigClient, C, I>(
match signing_result_future.await {
Ok(signatures) => {
state_chain_client
.submit_unsigned_extrinsic(pallet_cf_threshold_signature::Call::<
.finalize_signed_extrinsic(pallet_cf_threshold_signature::Call::<
state_chain_runtime::Runtime,
I,
>::signature_success {
Expand All @@ -176,7 +176,7 @@ async fn handle_signing_request<'a, StateChainClient, MultisigClient, C, I>(
},
Err((bad_account_ids, _reason)) => {
state_chain_client
.submit_signed_extrinsic(pallet_cf_threshold_signature::Call::<
.finalize_signed_extrinsic(pallet_cf_threshold_signature::Call::<
state_chain_runtime::Runtime,
I,
>::report_signature_failed {
Expand Down Expand Up @@ -264,7 +264,7 @@ where
async move {
tokio::time::sleep(Duration::from_secs(60)).await;
state_chain_client
.submit_signed_extrinsic(
.finalize_signed_extrinsic(
pallet_cf_reputation::Call::heartbeat {},
)
.await
Expand Down Expand Up @@ -514,7 +514,7 @@ where
// a problem with the ethereum rpc node, or with the configured account. For example
// if the account balance is too low to pay for required gas.
error!("Error on Ethereum TransactionBroadcastRequest {broadcast_attempt_id:?}: {error:?}");
state_chain_client.submit_signed_extrinsic(
state_chain_client.finalize_signed_extrinsic(
state_chain_runtime::RuntimeCall::EthereumBroadcaster(
pallet_cf_broadcast::Call::transaction_signing_failure {
broadcast_attempt_id,
Expand Down Expand Up @@ -544,7 +544,7 @@ where
Ok(tx_hash) => info!("Polkadot TransactionBroadcastRequest {broadcast_attempt_id:?} success: tx_hash: {tx_hash:#x}"),
Err(error) => {
error!("Error on Polkadot TransactionBroadcastRequest {broadcast_attempt_id:?}: {error:?}");
state_chain_client.submit_signed_extrinsic(
state_chain_client.finalize_signed_extrinsic(
state_chain_runtime::RuntimeCall::PolkadotBroadcaster(
pallet_cf_broadcast::Call::transaction_signing_failure {
broadcast_attempt_id,
Expand Down Expand Up @@ -574,7 +574,7 @@ where
Ok(tx_hash) => info!("Bitcoin TransactionBroadcastRequest {broadcast_attempt_id:?} success: tx_hash: {tx_hash:#x}"),
Err(error) => {
error!("Error on Bitcoin TransactionBroadcastRequest {broadcast_attempt_id:?}: {error:?}");
state_chain_client.submit_signed_extrinsic(
state_chain_client.finalize_signed_extrinsic(
state_chain_runtime::RuntimeCall::BitcoinBroadcaster(
pallet_cf_broadcast::Call::transaction_signing_failure {
broadcast_attempt_id,
Expand Down Expand Up @@ -602,7 +602,7 @@ where
{
info!("Sending heartbeat at block: {}", current_block_header.number);
state_chain_client
.submit_signed_extrinsic(
.finalize_signed_extrinsic(
pallet_cf_reputation::Call::heartbeat {},
)
.await;
Expand Down
6 changes: 3 additions & 3 deletions engine/src/state_chain_observer/sc_observer/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ ChainCrypto>::ThresholdSignature: std::convert::From<<C as CryptoScheme>::Signat
.boxed()
});
state_chain_client
.expect_submit_signed_extrinsic::<pallet_cf_threshold_signature::Call<Runtime, I>>()
.expect_finalize_signed_extrinsic::<pallet_cf_threshold_signature::Call<Runtime, I>>()
.with(eq(pallet_cf_threshold_signature::Call::<Runtime, I>::report_signature_failed {
ceremony_id: ceremony_id_2,
offenders: BTreeSet::default(),
Expand Down Expand Up @@ -326,7 +326,7 @@ where
.times(2)
.return_const(our_account_id.clone());
state_chain_client
.expect_submit_signed_extrinsic::<pallet_cf_vaults::Call<Runtime, I>>()
.expect_finalize_signed_extrinsic::<pallet_cf_vaults::Call<Runtime, I>>()
.once()
.return_once(|_| (H256::default(), extrinsic_api::signed::MockUntilFinalized::new()));
let state_chain_client = Arc::new(state_chain_client);
Expand Down Expand Up @@ -448,7 +448,7 @@ where
.boxed()
});
state_chain_client
.expect_submit_signed_extrinsic::<pallet_cf_vaults::Call<Runtime, BitcoinInstance>>()
.expect_finalize_signed_extrinsic::<pallet_cf_vaults::Call<Runtime, BitcoinInstance>>()
.once()
.return_once(|_| (H256::default(), extrinsic_api::signed::MockUntilFinalized::new()));

Expand Down
4 changes: 2 additions & 2 deletions engine/src/witness/btc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ where
// Submit all deposit witnesses for the block.
if !deposit_witnesses.is_empty() {
state_chain_client
.submit_signed_extrinsic(pallet_cf_witnesser::Call::witness_at_epoch {
.finalize_signed_extrinsic(pallet_cf_witnesser::Call::witness_at_epoch {
call: Box::new(
pallet_cf_ingress_egress::Call::<_, BitcoinInstance>::process_deposits {
deposit_witnesses,
Expand All @@ -107,7 +107,7 @@ where

for tx_hash in success_witnesses(&monitored_tx_hashes, &txs) {
state_chain_client
.submit_signed_extrinsic(pallet_cf_witnesser::Call::witness_at_epoch {
.finalize_signed_extrinsic(pallet_cf_witnesser::Call::witness_at_epoch {
call: Box::new(state_chain_runtime::RuntimeCall::BitcoinBroadcaster(
pallet_cf_broadcast::Call::transaction_succeeded {
tx_out_id: tx_hash,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ impl<Inner: ChunkedByTime> ChunkedByTimeBuilder<Inner> {
.into(),
);
state_chain_client
.submit_signed_extrinsic(pallet_cf_witnesser::Call::witness_at_epoch {
.finalize_signed_extrinsic(pallet_cf_witnesser::Call::witness_at_epoch {
call,
epoch_index: epoch.index,
})
Expand Down
6 changes: 3 additions & 3 deletions engine/src/witness/dot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ where

if !deposit_witnesses.is_empty() {
state_chain_client
.submit_signed_extrinsic(pallet_cf_witnesser::Call::witness_at_epoch {
.finalize_signed_extrinsic(pallet_cf_witnesser::Call::witness_at_epoch {
call: Box::new(
pallet_cf_ingress_egress::Call::<_, PolkadotInstance>::process_deposits {
deposit_witnesses,
Expand Down Expand Up @@ -170,7 +170,7 @@ where

for call in vault_key_rotated_calls {
state_chain_client
.submit_signed_extrinsic(pallet_cf_witnesser::Call::witness_at_epoch {
.finalize_signed_extrinsic(pallet_cf_witnesser::Call::witness_at_epoch {
call,
epoch_index: epoch.index,
})
Expand Down Expand Up @@ -207,7 +207,7 @@ where
if monitored_egress_ids.contains(&signature) {
tracing::info!("Witnessing transaction_succeeded. signature: {signature:?}");
state_chain_client
.submit_signed_extrinsic(
.finalize_signed_extrinsic(
pallet_cf_witnesser::Call::witness_at_epoch {
call:
Box::new(
Expand Down
2 changes: 1 addition & 1 deletion engine/src/witness/eth/erc20_deposits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ impl<Inner: ChunkedByVault> ChunkedByVaultBuilder<Inner> {

if !deposit_witnesses.is_empty() {
state_chain_client
.submit_signed_extrinsic(pallet_cf_witnesser::Call::witness_at_epoch {
.finalize_signed_extrinsic(pallet_cf_witnesser::Call::witness_at_epoch {
call: Box::new(
pallet_cf_ingress_egress::Call::<
_,
Expand Down
2 changes: 1 addition & 1 deletion engine/src/witness/eth/ethereum_deposits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ impl<Inner: ChunkedByVault> ChunkedByVaultBuilder<Inner> {

if !ingresses.is_empty() {
state_chain_client
.submit_signed_extrinsic(
.finalize_signed_extrinsic(
pallet_cf_witnesser::Call::witness_at_epoch {
call: Box::new(
pallet_cf_ingress_egress::Call::<
Expand Down
8 changes: 4 additions & 4 deletions engine/src/witness/eth/key_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ impl<Inner: ChunkedByVault> ChunkedByVaultBuilder<Inner> {
match event.event_parameters {
KeyManagerEvents::AggKeySetByAggKeyFilter(_) => {
state_chain_client
.submit_signed_extrinsic(
.finalize_signed_extrinsic(
pallet_cf_witnesser::Call::witness_at_epoch {
call: Box::new(
pallet_cf_vaults::Call::<
Expand All @@ -100,7 +100,7 @@ impl<Inner: ChunkedByVault> ChunkedByVaultBuilder<Inner> {
..
}) => {
state_chain_client
.submit_signed_extrinsic(
.finalize_signed_extrinsic(
pallet_cf_witnesser::Call::witness_at_epoch {
call: Box::new(
pallet_cf_vaults::Call::<
Expand Down Expand Up @@ -146,7 +146,7 @@ impl<Inner: ChunkedByVault> ChunkedByVaultBuilder<Inner> {
.try_into()
.map_err(anyhow::Error::msg)?;
state_chain_client
.submit_signed_extrinsic(
.finalize_signed_extrinsic(
pallet_cf_witnesser::Call::witness_at_epoch {
call: Box::new(
pallet_cf_broadcast::Call::<
Expand Down Expand Up @@ -176,7 +176,7 @@ impl<Inner: ChunkedByVault> ChunkedByVaultBuilder<Inner> {
message,
}) => {
state_chain_client
.submit_signed_extrinsic(
.finalize_signed_extrinsic(
pallet_cf_witnesser::Call::witness_at_epoch {
call: Box::new(
pallet_cf_governance::Call::set_whitelisted_call_hash {
Expand Down
6 changes: 3 additions & 3 deletions engine/src/witness/eth/state_chain_gateway.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ impl<Inner: ChunkedByVault> ChunkedByVaultBuilder<Inner> {
funder,
}) => {
state_chain_client
.submit_signed_extrinsic(
.finalize_signed_extrinsic(
pallet_cf_witnesser::Call::witness_at_epoch {
call: Box::new(
pallet_cf_funding::Call::funded {
Expand All @@ -80,7 +80,7 @@ impl<Inner: ChunkedByVault> ChunkedByVaultBuilder<Inner> {
RedemptionExecutedFilter { node_id: account_id, amount },
) => {
state_chain_client
.submit_signed_extrinsic(
.finalize_signed_extrinsic(
pallet_cf_witnesser::Call::witness_at_epoch {
call: Box::new(
pallet_cf_funding::Call::redeemed {
Expand All @@ -101,7 +101,7 @@ impl<Inner: ChunkedByVault> ChunkedByVaultBuilder<Inner> {
RedemptionExpiredFilter { node_id: account_id, amount: _ },
) => {
state_chain_client
.submit_signed_extrinsic(
.finalize_signed_extrinsic(
pallet_cf_witnesser::Call::witness_at_epoch {
call: Box::new(
pallet_cf_funding::Call::redemption_expired {
Expand Down
2 changes: 1 addition & 1 deletion engine/src/witness/eth/vault.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ impl<Inner: ChunkedByVault> ChunkedByVaultBuilder<Inner> {
Ok(option_call) =>
if let Some(call) = option_call {
state_chain_client
.submit_signed_extrinsic(
.finalize_signed_extrinsic(
pallet_cf_witnesser::Call::witness_at_epoch {
call: Box::new(call),
epoch_index: epoch.index,
Expand Down
Loading