From 7e24dd8a583518398b30064b2c45018aa8e78e61 Mon Sep 17 00:00:00 2001 From: larry-aptos <112209412+larry-aptos@users.noreply.github.com> Date: Fri, 12 Jul 2024 13:14:43 -0700 Subject: [PATCH] [Validator API Fix]support validator txn with its events. (#454) * support validator txn with its events. * update. * update. --- rust/Cargo.lock | 4 +- rust/Cargo.toml | 2 +- .../account_transactions.rs | 1 + .../default_models/parquet_transactions.rs | 37 ++++++++++++------- .../models/default_models/transactions.rs | 4 +- .../stake_models/delegator_activities.rs | 1 + .../src/processors/events_processor.rs | 1 + .../processors/fungible_asset_processor.rs | 1 + 8 files changed, 32 insertions(+), 19 deletions(-) diff --git a/rust/Cargo.lock b/rust/Cargo.lock index 9d541daa7..0b6b51ac1 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -160,8 +160,8 @@ dependencies = [ [[package]] name = "aptos-protos" -version = "1.3.0" -source = "git+https://github.com/aptos-labs/aptos-core.git?rev=d76b5bb423b78b2b9affc72d3853f0d973d3f11f#d76b5bb423b78b2b9affc72d3853f0d973d3f11f" +version = "1.3.1" +source = "git+https://github.com/aptos-labs/aptos-core.git?rev=5c48aee129b5a141be2792ffa3d9bd0a1a61c9cb#5c48aee129b5a141be2792ffa3d9bd0a1a61c9cb" dependencies = [ "futures-core", "pbjson", diff --git a/rust/Cargo.toml b/rust/Cargo.toml index 64bacc3a9..12e7584cf 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -19,7 +19,7 @@ aptos-moving-average = { path = "moving-average" } ahash = { version = "0.8.7", features = ["serde"] } anyhow = "1.0.62" -aptos-protos = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "d76b5bb423b78b2b9affc72d3853f0d973d3f11f" } +aptos-protos = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "5c48aee129b5a141be2792ffa3d9bd0a1a61c9cb" } aptos-system-utils = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "4541add3fd29826ec57f22658ca286d2d6134b93" } async-trait = "0.1.53" backtrace = "0.3.58" diff --git a/rust/processor/src/db/common/models/account_transaction_models/account_transactions.rs b/rust/processor/src/db/common/models/account_transaction_models/account_transactions.rs index fcf0c4666..9baa02b7b 100644 --- a/rust/processor/src/db/common/models/account_transaction_models/account_transactions.rs +++ b/rust/processor/src/db/common/models/account_transaction_models/account_transactions.rs @@ -71,6 +71,7 @@ impl AccountTransaction { ), TxnData::Genesis(inner) => (&inner.events, vec![]), TxnData::BlockMetadata(inner) => (&inner.events, vec![]), + TxnData::Validator(inner) => (&inner.events, vec![]), _ => { return AHashMap::new(); }, diff --git a/rust/processor/src/db/common/models/default_models/parquet_transactions.rs b/rust/processor/src/db/common/models/default_models/parquet_transactions.rs index 8e44c9dbc..488867879 100644 --- a/rust/processor/src/db/common/models/default_models/parquet_transactions.rs +++ b/rust/processor/src/db/common/models/default_models/parquet_transactions.rs @@ -321,23 +321,32 @@ impl Transaction { vec![], vec![], ), - TxnData::Validator(_) => ( - Self::from_transaction_info_with_data( - transaction_info, - None, - None, + TxnData::Validator(inner) => { + let (wsc, wsc_detail) = WriteSetChangeModel::from_write_set_changes( + &transaction_info.changes, txn_version, - transaction_type, - 0, block_height, - epoch, block_timestamp, - txn_size_info, - ), - None, - vec![], - vec![], - ), + write_set_size_info, + ); + ( + Self::from_transaction_info_with_data( + transaction_info, + None, + None, + txn_version, + transaction_type, + inner.events.len() as i64, + block_height, + epoch, + block_timestamp, + txn_size_info, + ), + None, + wsc, + wsc_detail, + ) + }, TxnData::BlockEpilogue(_) => ( Self::from_transaction_info_with_data( transaction_info, diff --git a/rust/processor/src/db/common/models/default_models/transactions.rs b/rust/processor/src/db/common/models/default_models/transactions.rs index 5b4c17eb2..2201da4e7 100644 --- a/rust/processor/src/db/common/models/default_models/transactions.rs +++ b/rust/processor/src/db/common/models/default_models/transactions.rs @@ -296,8 +296,8 @@ impl Transaction { epoch, ), None, - vec![], - vec![], + wsc, + wsc_detail, ), TxnData::BlockEpilogue(_) => ( Self::from_transaction_info_with_data( diff --git a/rust/processor/src/db/common/models/stake_models/delegator_activities.rs b/rust/processor/src/db/common/models/stake_models/delegator_activities.rs index 846f10f7f..e087480bb 100644 --- a/rust/processor/src/db/common/models/stake_models/delegator_activities.rs +++ b/rust/processor/src/db/common/models/stake_models/delegator_activities.rs @@ -50,6 +50,7 @@ impl DelegatedStakingActivity { let events = match txn_data { TxnData::User(txn) => &txn.events, TxnData::BlockMetadata(txn) => &txn.events, + TxnData::Validator(txn) => &txn.events, _ => return Ok(delegator_activities), }; for (index, event) in events.iter().enumerate() { diff --git a/rust/processor/src/processors/events_processor.rs b/rust/processor/src/processors/events_processor.rs index 409914275..9956d2c7b 100644 --- a/rust/processor/src/processors/events_processor.rs +++ b/rust/processor/src/processors/events_processor.rs @@ -130,6 +130,7 @@ impl ProcessorTrait for EventsProcessor { TxnData::BlockMetadata(tx_inner) => &tx_inner.events, TxnData::Genesis(tx_inner) => &tx_inner.events, TxnData::User(tx_inner) => &tx_inner.events, + TxnData::Validator(tx_inner) => &tx_inner.events, _ => &default, }; diff --git a/rust/processor/src/processors/fungible_asset_processor.rs b/rust/processor/src/processors/fungible_asset_processor.rs index a4219be22..891b33d6f 100644 --- a/rust/processor/src/processors/fungible_asset_processor.rs +++ b/rust/processor/src/processors/fungible_asset_processor.rs @@ -482,6 +482,7 @@ async fn parse_v2_coin( let default = vec![]; let (events, user_request, entry_function_id_str) = match txn_data { TxnData::BlockMetadata(tx_inner) => (&tx_inner.events, None, None), + TxnData::Validator(tx_inner) => (&tx_inner.events, None, None), TxnData::Genesis(tx_inner) => (&tx_inner.events, None, None), TxnData::User(tx_inner) => { let user_request = tx_inner