From 2f1d93f6c67cf48269f1e1087b0d385e6770fe44 Mon Sep 17 00:00:00 2001 From: Yin Guanhao Date: Sun, 12 Feb 2023 22:02:30 +0800 Subject: [PATCH 1/2] Remove dry_run_transaction and fix error display in withdrawal unlocker --- crates/block-producer/src/runner.rs | 45 +++++++------- .../block-producer/src/withdrawal_unlocker.rs | 58 +++++++------------ crates/rpc-client/src/utils.rs | 2 +- 3 files changed, 47 insertions(+), 58 deletions(-) diff --git a/crates/block-producer/src/runner.rs b/crates/block-producer/src/runner.rs index 379f03f84..6e6313286 100644 --- a/crates/block-producer/src/runner.rs +++ b/crates/block-producer/src/runner.rs @@ -1,14 +1,10 @@ -use crate::{ - block_producer::{BlockProducer, BlockProducerCreateArgs}, - block_sync_client::{block_sync_client_protocol, BlockSyncClient, P2PStream}, - chain_updater::ChainUpdater, - challenger::{Challenger, ChallengerNewArgs}, - cleaner::Cleaner, - psc::{PSCContext, ProduceSubmitConfirm}, - test_mode_control::TestModeControl, - types::ChainEvent, - withdrawal_unlocker::FinalizedWithdrawalUnlocker, +use std::{ + collections::HashMap, + net::{SocketAddr, ToSocketAddrs}, + sync::Arc, + time::{Duration, Instant}, }; + use anyhow::{anyhow, bail, Context, Result}; use futures::future::OptionFuture; use gw_chain::chain::Chain; @@ -39,8 +35,10 @@ use gw_rpc_server::{ registry::{BoxedTestModeRpc, Registry, RegistryArgs}, server::start_jsonrpc_server, }; -use gw_store::migrate::{init_migration_factory, open_or_create_db}; -use gw_store::Store; +use gw_store::{ + migrate::{init_migration_factory, open_or_create_db}, + Store, +}; use gw_types::{ bytes::Bytes, core::AllowedEoaType, @@ -48,18 +46,11 @@ use gw_types::{ packed::{Byte32, CellDep, NumberHash, RollupConfig, Script}, prelude::*, }; -use gw_utils::RollupContext; use gw_utils::{ exponential_backoff::ExponentialBackoff, genesis_info::CKBGenesisInfo, liveness::Liveness, - local_cells::LocalCellsManager, wallet::Wallet, + local_cells::LocalCellsManager, wallet::Wallet, RollupContext, }; use semver::Version; -use std::{ - collections::HashMap, - net::{SocketAddr, ToSocketAddrs}, - sync::Arc, - time::{Duration, Instant}, -}; use tentacle::service::ProtocolMeta; use tokio::{ spawn, @@ -67,6 +58,18 @@ use tokio::{ }; use tracing::{info_span, instrument}; +use crate::{ + block_producer::{BlockProducer, BlockProducerCreateArgs}, + block_sync_client::{block_sync_client_protocol, BlockSyncClient, P2PStream}, + chain_updater::ChainUpdater, + challenger::{Challenger, ChallengerNewArgs}, + cleaner::Cleaner, + psc::{PSCContext, ProduceSubmitConfirm}, + test_mode_control::TestModeControl, + types::ChainEvent, + withdrawal_unlocker::FinalizedWithdrawalUnlocker, +}; + const MIN_CKB_VERSION: &str = "0.40.0"; const EVENT_TIMEOUT_SECONDS: u64 = 30; @@ -167,7 +170,7 @@ impl ChainTask { if let Some(ref mut withdrawal_unlocker) = ctx.withdrawal_unlocker { if let Err(err) = withdrawal_unlocker.handle_event(&event).await { - log::error!("[unlock withdrawal] {}", err); + log::error!("[unlock withdrawal] {:#}", err); } } diff --git a/crates/block-producer/src/withdrawal_unlocker.rs b/crates/block-producer/src/withdrawal_unlocker.rs index 18d019277..8b29e8862 100644 --- a/crates/block-producer/src/withdrawal_unlocker.rs +++ b/crates/block-producer/src/withdrawal_unlocker.rs @@ -1,33 +1,29 @@ #![allow(clippy::mutable_key_type)] -use std::collections::{HashMap, HashSet}; -use std::sync::Arc; +use std::{ + collections::{HashMap, HashSet}, + sync::Arc, +}; use anyhow::{bail, Result}; use async_trait::async_trait; use gw_config::{ContractsCellDep, DebugConfig}; -use gw_rpc_client::contract::ContractsCellDepManager; -use gw_rpc_client::rpc_client::RPCClient; -use gw_types::h256::*; -use gw_types::offchain::{global_state_from_slice, CellInfo, CompatibleFinalizedTimepoint}; -use gw_types::packed::{OutPoint, RollupConfig, Transaction}; -use gw_types::prelude::*; -use gw_utils::fee::fill_tx_fee; -use gw_utils::genesis_info::CKBGenesisInfo; -use gw_utils::local_cells::LocalCellsManager; -use gw_utils::query_rollup_cell; -use gw_utils::transaction_skeleton::TransactionSkeleton; -use gw_utils::wallet::Wallet; +pub use gw_rpc_client::contract::Guard; +use gw_rpc_client::{contract::ContractsCellDepManager, rpc_client::RPCClient}; +use gw_types::{ + h256::*, + offchain::{global_state_from_slice, CellInfo, CompatibleFinalizedTimepoint}, + packed::{OutPoint, RollupConfig, Transaction}, + prelude::*, +}; +use gw_utils::{ + fee::fill_tx_fee, genesis_info::CKBGenesisInfo, local_cells::LocalCellsManager, + query_rollup_cell, transaction_skeleton::TransactionSkeleton, wallet::Wallet, +}; use tokio::sync::Mutex; use tracing::instrument; -use crate::types::ChainEvent; -use crate::utils; - -use crate::utils::global_state_last_finalized_timepoint_to_since; -pub use gw_rpc_client::contract::Guard; - -const TRANSACTION_FAILED_TO_RESOLVE_ERROR: &str = "TransactionFailedToResolve"; +use crate::{types::ChainEvent, utils, utils::global_state_last_finalized_timepoint_to_since}; pub struct FinalizedWithdrawalUnlocker { unlocker: DefaultUnlocker, @@ -68,25 +64,12 @@ impl FinalizedWithdrawalUnlocker { let unlocked = &self.unlocked_set; let rpc_client = &self.unlocker.rpc_client; if let Some((tx, to_unlock)) = self.unlocker.query_and_unlock_to_owner(unlocked).await? { - if let Err(err) = rpc_client.dry_run_transaction(&tx).await { - let err_string = err.to_string(); - if err_string.contains(TRANSACTION_FAILED_TO_RESOLVE_ERROR) { - // NOTE: Maybe unlocked withdrawals are included, this happens after restart. - // Wait indexer remove these cells. - log::info!( - "[unlock withdrawal] failed to resolve, wait unlocked become committed" - ); - return Ok(()); - } - bail!("dry unlock tx failed {}", err); - } - let tx_hash = match rpc_client.send_transaction(&tx).await { Ok(tx_hash) => tx_hash, Err(err) => { let debug_tx_dump_path = &self.debug_config.debug_tx_dump_path; utils::dump_transaction(debug_tx_dump_path, rpc_client, &tx).await; - bail!("send tx failed {}", err); + bail!(err); } }; @@ -106,7 +89,10 @@ impl FinalizedWithdrawalUnlocker { match rpc_client.ckb.get_transaction_status(*tx_hash).await { Err(err) => { // Always drop this unlock tx and retry to avoid "lock" withdrawal cell - log::info!("[unlock withdrawal] get unlock tx failed {}, drop it", err); + log::info!( + "[unlock withdrawal] get unlock tx failed {:#}, drop it", + err + ); drop_txs.push(*tx_hash); } Ok(None) => { diff --git a/crates/rpc-client/src/utils.rs b/crates/rpc-client/src/utils.rs index 0c23bdfe6..ca604f674 100644 --- a/crates/rpc-client/src/utils.rs +++ b/crates/rpc-client/src/utils.rs @@ -30,7 +30,7 @@ impl TracingHttpClient { self.inner.url() } - #[instrument(target = "gw-rpc-client", skip_all, err, fields(method, params = field::Empty))] + #[instrument(target = "gw-rpc-client", skip_all, fields(method, params = field::Empty))] pub async fn rpc( &self, method: &str, From f9ebfeaa15f4e8eee904ba4249f7a699362a596f Mon Sep 17 00:00:00 2001 From: Yin Guanhao Date: Mon, 20 Feb 2023 14:38:54 +0800 Subject: [PATCH 2/2] Use kicker develop --- .github/workflows/godwoken-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/godwoken-tests.yml b/.github/workflows/godwoken-tests.yml index 572410c95..2fb85587c 100644 --- a/.github/workflows/godwoken-tests.yml +++ b/.github/workflows/godwoken-tests.yml @@ -28,4 +28,4 @@ jobs: POLYJUICE_GIT_URL=https://github.com/${{ github.repository }} POLYJUICE_GIT_CHECKOUT=${{ github.ref }} GODWOKEN_KICKER_REPO=godwokenrises/godwoken-kicker - GODWOKEN_KICKER_REF=refs/pull/343/merge + GODWOKEN_KICKER_REF=develop