diff --git a/rust/Cargo.lock b/rust/Cargo.lock index 65ab8faa4..8734430ab 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -142,12 +142,12 @@ checksum = "34ac096ce696dc2fcabef30516bb13c0a68a11d30131d3df6f04711467681b04" [[package]] name = "aptos-indexer-processor-sdk" version = "0.1.0" -source = "git+https://github.com/aptos-labs/aptos-indexer-processor-sdk.git?rev=a56b641a6aaca60092fcc9bbd98252f3cd703299#a56b641a6aaca60092fcc9bbd98252f3cd703299" +source = "git+https://github.com/aptos-labs/aptos-indexer-processor-sdk.git?rev=b79ed8b5864b2a12a1f9c5fd01579462e029b2ae#b79ed8b5864b2a12a1f9c5fd01579462e029b2ae" dependencies = [ "ahash", "anyhow", "aptos-indexer-transaction-stream", - "aptos-protos 1.3.1 (git+https://github.com/aptos-labs/aptos-core.git?rev=6116af69aa173ca49e1761daabd6fe103fe2c65e)", + "aptos-protos", "async-trait", "bcs", "bigdecimal", @@ -175,7 +175,7 @@ dependencies = [ [[package]] name = "aptos-indexer-processor-sdk-server-framework" version = "1.0.0" -source = "git+https://github.com/aptos-labs/aptos-indexer-processor-sdk.git?rev=a56b641a6aaca60092fcc9bbd98252f3cd703299#a56b641a6aaca60092fcc9bbd98252f3cd703299" +source = "git+https://github.com/aptos-labs/aptos-indexer-processor-sdk.git?rev=b79ed8b5864b2a12a1f9c5fd01579462e029b2ae#b79ed8b5864b2a12a1f9c5fd01579462e029b2ae" dependencies = [ "anyhow", "aptos-indexer-processor-sdk", @@ -199,20 +199,20 @@ dependencies = [ [[package]] name = "aptos-indexer-test-transactions" version = "1.0.0" -source = "git+https://github.com/aptos-labs/aptos-core.git?rev=ef80673093aa4df271ad33c2401421d642e7ff3c#ef80673093aa4df271ad33c2401421d642e7ff3c" +source = "git+https://github.com/aptos-labs/aptos-core.git?rev=1d8460a995503574ec4e9699d3442d0150d7f3b9#1d8460a995503574ec4e9699d3442d0150d7f3b9" dependencies = [ - "aptos-protos 1.3.1 (git+https://github.com/aptos-labs/aptos-core.git?rev=ef80673093aa4df271ad33c2401421d642e7ff3c)", + "aptos-protos", "serde_json", ] [[package]] name = "aptos-indexer-testing-framework" version = "0.1.0" -source = "git+https://github.com/aptos-labs/aptos-indexer-processor-sdk.git?rev=a56b641a6aaca60092fcc9bbd98252f3cd703299#a56b641a6aaca60092fcc9bbd98252f3cd703299" +source = "git+https://github.com/aptos-labs/aptos-indexer-processor-sdk.git?rev=b79ed8b5864b2a12a1f9c5fd01579462e029b2ae#b79ed8b5864b2a12a1f9c5fd01579462e029b2ae" dependencies = [ "anyhow", "aptos-indexer-processor-sdk", - "aptos-protos 1.3.1 (git+https://github.com/aptos-labs/aptos-core.git?rev=6116af69aa173ca49e1761daabd6fe103fe2c65e)", + "aptos-protos", "async-trait", "diesel", "diesel-async", @@ -236,11 +236,11 @@ dependencies = [ [[package]] name = "aptos-indexer-transaction-stream" version = "0.1.0" -source = "git+https://github.com/aptos-labs/aptos-indexer-processor-sdk.git?rev=a56b641a6aaca60092fcc9bbd98252f3cd703299#a56b641a6aaca60092fcc9bbd98252f3cd703299" +source = "git+https://github.com/aptos-labs/aptos-indexer-processor-sdk.git?rev=b79ed8b5864b2a12a1f9c5fd01579462e029b2ae#b79ed8b5864b2a12a1f9c5fd01579462e029b2ae" dependencies = [ "anyhow", - "aptos-moving-average 0.1.0 (git+https://github.com/aptos-labs/aptos-indexer-processor-sdk.git?rev=a56b641a6aaca60092fcc9bbd98252f3cd703299)", - "aptos-protos 1.3.1 (git+https://github.com/aptos-labs/aptos-core.git?rev=6116af69aa173ca49e1761daabd6fe103fe2c65e)", + "aptos-moving-average 0.1.0 (git+https://github.com/aptos-labs/aptos-indexer-processor-sdk.git?rev=b79ed8b5864b2a12a1f9c5fd01579462e029b2ae)", + "aptos-protos", "chrono", "futures-util", "once_cell", @@ -264,7 +264,7 @@ dependencies = [ [[package]] name = "aptos-moving-average" version = "0.1.0" -source = "git+https://github.com/aptos-labs/aptos-indexer-processor-sdk.git?rev=a56b641a6aaca60092fcc9bbd98252f3cd703299#a56b641a6aaca60092fcc9bbd98252f3cd703299" +source = "git+https://github.com/aptos-labs/aptos-indexer-processor-sdk.git?rev=b79ed8b5864b2a12a1f9c5fd01579462e029b2ae#b79ed8b5864b2a12a1f9c5fd01579462e029b2ae" dependencies = [ "chrono", ] @@ -298,18 +298,7 @@ dependencies = [ [[package]] name = "aptos-protos" version = "1.3.1" -source = "git+https://github.com/aptos-labs/aptos-core.git?rev=6116af69aa173ca49e1761daabd6fe103fe2c65e#6116af69aa173ca49e1761daabd6fe103fe2c65e" -dependencies = [ - "pbjson", - "prost 0.13.4", - "serde", - "tonic 0.12.3", -] - -[[package]] -name = "aptos-protos" -version = "1.3.1" -source = "git+https://github.com/aptos-labs/aptos-core.git?rev=ef80673093aa4df271ad33c2401421d642e7ff3c#ef80673093aa4df271ad33c2401421d642e7ff3c" +source = "git+https://github.com/aptos-labs/aptos-core.git?rev=1d8460a995503574ec4e9699d3442d0150d7f3b9#1d8460a995503574ec4e9699d3442d0150d7f3b9" dependencies = [ "pbjson", "prost 0.13.4", @@ -2421,7 +2410,7 @@ dependencies = [ [[package]] name = "instrumented-channel" version = "0.1.0" -source = "git+https://github.com/aptos-labs/aptos-indexer-processor-sdk.git?rev=a56b641a6aaca60092fcc9bbd98252f3cd703299#a56b641a6aaca60092fcc9bbd98252f3cd703299" +source = "git+https://github.com/aptos-labs/aptos-indexer-processor-sdk.git?rev=b79ed8b5864b2a12a1f9c5fd01579462e029b2ae#b79ed8b5864b2a12a1f9c5fd01579462e029b2ae" dependencies = [ "delegate", "derive_builder", @@ -2446,7 +2435,7 @@ dependencies = [ "aptos-indexer-processor-sdk", "aptos-indexer-test-transactions", "aptos-indexer-testing-framework", - "aptos-protos 1.3.1 (git+https://github.com/aptos-labs/aptos-core.git?rev=6116af69aa173ca49e1761daabd6fe103fe2c65e)", + "aptos-protos", "assert-json-diff", "bigdecimal", "chrono", @@ -3552,7 +3541,7 @@ dependencies = [ "allocative_derive", "anyhow", "aptos-moving-average 0.1.0", - "aptos-protos 1.3.1 (git+https://github.com/aptos-labs/aptos-core.git?rev=6116af69aa173ca49e1761daabd6fe103fe2c65e)", + "aptos-protos", "async-trait", "bcs", "bigdecimal", @@ -4305,7 +4294,7 @@ checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" [[package]] name = "sample" version = "0.1.0" -source = "git+https://github.com/aptos-labs/aptos-indexer-processor-sdk.git?rev=a56b641a6aaca60092fcc9bbd98252f3cd703299#a56b641a6aaca60092fcc9bbd98252f3cd703299" +source = "git+https://github.com/aptos-labs/aptos-indexer-processor-sdk.git?rev=b79ed8b5864b2a12a1f9c5fd01579462e029b2ae#b79ed8b5864b2a12a1f9c5fd01579462e029b2ae" dependencies = [ "tracing", ] diff --git a/rust/Cargo.toml b/rust/Cargo.toml index d299db675..92c5fd594 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -28,11 +28,11 @@ sdk-processor = { path = "sdk-processor" } ahash = { version = "0.8.7", features = ["serde"] } anyhow = "1.0.86" -aptos-indexer-processor-sdk = { git = "https://github.com/aptos-labs/aptos-indexer-processor-sdk.git", rev = "a56b641a6aaca60092fcc9bbd98252f3cd703299" } -aptos-indexer-processor-sdk-server-framework = { git = "https://github.com/aptos-labs/aptos-indexer-processor-sdk.git", rev = "a56b641a6aaca60092fcc9bbd98252f3cd703299" } -aptos-protos = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "6116af69aa173ca49e1761daabd6fe103fe2c65e" } -aptos-indexer-test-transactions = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "ef80673093aa4df271ad33c2401421d642e7ff3c" } -aptos-indexer-testing-framework = { git = "https://github.com/aptos-labs/aptos-indexer-processor-sdk.git", rev = "a56b641a6aaca60092fcc9bbd98252f3cd703299" } +aptos-indexer-processor-sdk = { git = "https://github.com/aptos-labs/aptos-indexer-processor-sdk.git", rev = "b79ed8b5864b2a12a1f9c5fd01579462e029b2ae" } +aptos-indexer-processor-sdk-server-framework = { git = "https://github.com/aptos-labs/aptos-indexer-processor-sdk.git", rev = "b79ed8b5864b2a12a1f9c5fd01579462e029b2ae" } +aptos-protos = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "1d8460a995503574ec4e9699d3442d0150d7f3b9" } +aptos-indexer-test-transactions = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "1d8460a995503574ec4e9699d3442d0150d7f3b9" } +aptos-indexer-testing-framework = { git = "https://github.com/aptos-labs/aptos-indexer-processor-sdk.git", rev = "b79ed8b5864b2a12a1f9c5fd01579462e029b2ae" } async-trait = "0.1.53" backtrace = "0.3.58" base64 = "0.13.0" diff --git a/rust/processor/src/db/parquet/models/user_transaction_models/parquet_signatures.rs b/rust/processor/src/db/parquet/models/user_transaction_models/parquet_signatures.rs index 51b7deb3f..e3d105bae 100644 --- a/rust/processor/src/db/parquet/models/user_transaction_models/parquet_signatures.rs +++ b/rust/processor/src/db/parquet/models/user_transaction_models/parquet_signatures.rs @@ -16,6 +16,7 @@ use aptos_protos::transaction::v1::{ SingleSender as SingleSenderPb, }; use serde::{Deserialize, Serialize}; +use tracing::warn; #[derive(Clone, Debug, Deserialize, Serialize)] pub struct Signature { @@ -79,7 +80,14 @@ impl Signature { } } - pub fn get_signature_type(t: &TransactionSignaturePb) -> String { + pub fn get_signature_type(t: &TransactionSignaturePb, transaction_version: i64) -> String { + if t.signature.is_none() { + warn!( + transaction_version = transaction_version, + "Transaction signature is unknown" + ); + return String::from("unknown"); + } match t.signature.as_ref().unwrap() { SignatureEnum::Ed25519(_) => String::from("ed25519_signature"), SignatureEnum::MultiEd25519(_) => String::from("multi_ed25519_signature"), @@ -87,6 +95,13 @@ impl Signature { SignatureEnum::FeePayer(_) => String::from("fee_payer_signature"), SignatureEnum::SingleSender(sender) => { let account_signature = sender.sender.as_ref().unwrap(); + if account_signature.signature.is_none() { + warn!( + transaction_version = transaction_version, + "Transaction signature is unknown" + ); + return String::from("unknown"); + } let signature = account_signature.signature.as_ref().unwrap(); match signature { AccountSignatureEnum::Ed25519(_) => String::from("ed25519_signature"), @@ -99,6 +114,7 @@ impl Signature { AccountSignatureEnum::MultiKeySignature(_) => { String::from("multi_key_signature") }, + AccountSignatureEnum::Abstraction(_) => String::from("abstraction_signature"), } }, } @@ -145,6 +161,29 @@ impl Signature { } } + fn parse_abstraction_signature( + sender: &String, + transaction_version: i64, + transaction_block_height: i64, + is_sender_primary: bool, + multi_agent_index: i64, + override_address: Option<&String>, + ) -> Self { + let signer = standardize_address(override_address.unwrap_or(sender)); + Self { + txn_version: transaction_version, + transaction_block_height, + signer, + is_sender_primary, + type_: String::from("abstraction_signature"), + public_key: "Not implemented".into(), + threshold: 1, + signature: "Not implemented".into(), + multi_agent_index, + multi_sig_index: 0, + } + } + fn parse_multi_ed25519_signature( s: &MultiEd25519SignaturePb, sender: &String, @@ -263,6 +302,13 @@ impl Signature { multi_agent_index: i64, override_address: Option<&String>, ) -> Vec { + if s.signature.is_none() { + warn!( + transaction_version = transaction_version, + "Transaction signature is unknown" + ); + return vec![]; + } let signature = s.signature.as_ref().unwrap(); match signature { AccountSignatureEnum::Ed25519(sig) => vec![Self::parse_ed25519_signature( @@ -303,6 +349,14 @@ impl Signature { multi_agent_index, override_address, ), + AccountSignatureEnum::Abstraction(_sig) => vec![Self::parse_abstraction_signature( + sender, + transaction_version, + transaction_block_height, + is_sender_primary, + multi_agent_index, + override_address, + )], } } @@ -494,6 +548,13 @@ impl Signature { transaction_version: i64, transaction_block_height: i64, ) -> Vec { + if s.sender.is_none() { + warn!( + transaction_version = transaction_version, + "Transaction signature is unknown" + ); + return vec![]; + } let signature = s.sender.as_ref().unwrap(); match signature.signature.as_ref() { Some(AccountSignatureEnum::SingleKeySignature(s)) => { @@ -534,6 +595,16 @@ impl Signature { 0, None, ), + Some(AccountSignatureEnum::Abstraction(_sig)) => { + vec![Self::parse_abstraction_signature( + sender, + transaction_version, + transaction_block_height, + true, + 0, + None, + )] + }, None => vec![], } } diff --git a/rust/processor/src/db/parquet/models/user_transaction_models/parquet_user_transactions.rs b/rust/processor/src/db/parquet/models/user_transaction_models/parquet_user_transactions.rs index 4adeb71ca..977f5572c 100644 --- a/rust/processor/src/db/parquet/models/user_transaction_models/parquet_user_transactions.rs +++ b/rust/processor/src/db/parquet/models/user_transaction_models/parquet_user_transactions.rs @@ -90,7 +90,7 @@ impl UserTransaction { .unwrap() .signature .as_ref() - .map(Signature::get_signature_type) + .map(|s| Signature::get_signature_type(s, version)) .unwrap_or_default(), sender: standardize_address(&user_request.sender), sequence_number: user_request.sequence_number as i64, diff --git a/rust/processor/src/db/postgres/models/account_restoration_models/account_restoration_utils.rs b/rust/processor/src/db/postgres/models/account_restoration_models/account_restoration_utils.rs index c548906e1..62302d5c9 100644 --- a/rust/processor/src/db/postgres/models/account_restoration_models/account_restoration_utils.rs +++ b/rust/processor/src/db/postgres/models/account_restoration_models/account_restoration_utils.rs @@ -12,6 +12,7 @@ use aptos_protos::transaction::v1::{ account_signature::Signature as AccountSignature, signature::Signature, transaction::TxnData, Transaction, }; +use tracing::warn; trait AuthKeyScheme { const SCHEME: u8; @@ -253,7 +254,7 @@ impl SignatureInfo { } } - fn from_transaction_signature(signature: &Signature) -> Option { + fn from_transaction_signature(signature: &Signature, transaction_version: i64) -> Option { let info = match signature { Signature::Ed25519(sig) => Self::ed25519(sig.public_key.clone()), Signature::MultiEd25519(sigs) => { @@ -265,7 +266,13 @@ impl SignatureInfo { }, Signature::SingleSender(single_sender) => { let account_signature = single_sender.sender.as_ref().unwrap(); - + if account_signature.signature.is_none() { + warn!( + transaction_version = transaction_version, + "Transaction signature is unknown" + ); + return None; + } let signature_info = match account_signature.signature.as_ref().unwrap() { AccountSignature::Ed25519(sig) => Self::ed25519(sig.public_key.clone()), AccountSignature::MultiEd25519(sigs) => { @@ -301,6 +308,7 @@ impl SignatureInfo { .collect::>(); Self::multi_key(threshold, prefixes, public_keys, verified) }, + AccountSignature::Abstraction(_sig) => return None, }; signature_info }, @@ -322,6 +330,7 @@ pub fn parse_account_restoration_models_from_transaction( TxnData::User(user_txn) => user_txn, _ => return None, }; + let txn_version = txn.version as i64; let address = user_txn.request.as_ref()?.sender.clone(); let signature_info = SignatureInfo::from_transaction_signature( user_txn @@ -331,9 +340,9 @@ pub fn parse_account_restoration_models_from_transaction( .as_ref()? .signature .as_ref()?, + txn_version, )?; let auth_key = signature_info.auth_key().unwrap_or_default(); - let txn_version = txn.version as i64; let auth_key_account_address = AuthKeyAccountAddress { auth_key: auth_key.clone(), diff --git a/rust/processor/src/db/postgres/models/user_transactions_models/signatures.rs b/rust/processor/src/db/postgres/models/user_transactions_models/signatures.rs index 0ff2ea1c1..314df7a25 100644 --- a/rust/processor/src/db/postgres/models/user_transactions_models/signatures.rs +++ b/rust/processor/src/db/postgres/models/user_transactions_models/signatures.rs @@ -20,6 +20,7 @@ use aptos_protos::transaction::v1::{ }; use field_count::FieldCount; use serde::{Deserialize, Serialize}; +use tracing::warn; #[derive(Clone, Debug, Deserialize, FieldCount, Identifiable, Insertable, Serialize)] #[diesel(primary_key( @@ -91,7 +92,14 @@ impl Signature { } } - pub fn get_signature_type(t: &TransactionSignaturePb) -> String { + pub fn get_signature_type(t: &TransactionSignaturePb, transaction_version: i64) -> String { + if t.signature.as_ref().is_none() { + warn!( + transaction_version = transaction_version, + "Transaction signature is unknown" + ); + return String::from("unknown"); + } match t.signature.as_ref().unwrap() { SignatureEnum::Ed25519(_) => String::from("ed25519_signature"), SignatureEnum::MultiEd25519(_) => String::from("multi_ed25519_signature"), @@ -111,6 +119,7 @@ impl Signature { AccountSignatureEnum::MultiKeySignature(_) => { String::from("multi_key_signature") }, + AccountSignatureEnum::Abstraction(_) => String::from("abstraction_signature"), } }, } @@ -158,6 +167,30 @@ impl Signature { } } + fn parse_abstraction_signature( + sender: &String, + transaction_version: i64, + transaction_block_height: i64, + is_sender_primary: bool, + multi_agent_index: i64, + override_address: Option<&String>, + ) -> Self { + let signer = standardize_address(override_address.unwrap_or(sender)); + Self { + transaction_version, + transaction_block_height, + signer, + is_sender_primary, + type_: String::from("abstraction_signature"), + public_key: "Not implemented".into(), + threshold: 1, + public_key_indices: serde_json::Value::Array(vec![]), + signature: "Not implemented".into(), + multi_agent_index, + multi_sig_index: 0, + } + } + fn parse_multi_ed25519_signature( s: &MultiEd25519SignaturePb, sender: &String, @@ -284,6 +317,15 @@ impl Signature { multi_agent_index: i64, override_address: Option<&String>, ) -> Vec { + // Skip parsing if unknow signagure is found. + if s.signature.as_ref().is_none() { + warn!( + transaction_version = transaction_version, + "Unknown signature is found!" + ); + return vec![]; + } + let signature = s.signature.as_ref().unwrap(); match signature { AccountSignatureEnum::Ed25519(sig) => vec![Self::parse_ed25519_signature( @@ -324,6 +366,16 @@ impl Signature { multi_agent_index, override_address, ), + AccountSignatureEnum::Abstraction(_sig) => { + vec![Self::parse_abstraction_signature( + sender, + transaction_version, + transaction_block_height, + is_sender_primary, + multi_agent_index, + override_address, + )] + }, } } @@ -528,6 +580,13 @@ impl Signature { transaction_block_height: i64, ) -> Vec { let signature = s.sender.as_ref().unwrap(); + if signature.signature.is_none() { + warn!( + transaction_version = transaction_version, + "Transaction signature is unknown" + ); + return vec![]; + } match signature.signature.as_ref() { Some(AccountSignatureEnum::SingleKeySignature(s)) => { vec![Self::parse_single_key_signature( @@ -567,6 +626,14 @@ impl Signature { 0, None, ), + Some(AccountSignatureEnum::Abstraction(_s)) => vec![Self::parse_abstraction_signature( + sender, + transaction_version, + transaction_block_height, + true, + 0, + None, + )], None => vec![], } } diff --git a/rust/processor/src/db/postgres/models/user_transactions_models/user_transactions.rs b/rust/processor/src/db/postgres/models/user_transactions_models/user_transactions.rs index 40983a4b6..a01a4c87f 100644 --- a/rust/processor/src/db/postgres/models/user_transactions_models/user_transactions.rs +++ b/rust/processor/src/db/postgres/models/user_transactions_models/user_transactions.rs @@ -67,7 +67,7 @@ impl UserTransaction { .unwrap() .signature .as_ref() - .map(Signature::get_signature_type) + .map(|sig| Signature::get_signature_type(sig, version)) .unwrap_or_default(), sender: standardize_address(&user_request.sender), sequence_number: user_request.sequence_number as i64,