From c1b983526bc0136b35f76d6ff654d32b86f2c297 Mon Sep 17 00:00:00 2001 From: catalyst17 <37663786+catalyst17@users.noreply.github.com> Date: Wed, 29 Nov 2023 16:52:02 +0100 Subject: [PATCH 1/3] feat: add module producing combined trxs --- Makefile | 2 +- proto/combined_transactions.proto | 11 +++++++++++ src/lib.rs | 1 + src/map_combine_transactions.rs | 14 ++++++++++++++ src/pb/eth.transaction.v1.rs | 8 ++++++++ substreams.yaml | 10 ++++++++++ 6 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 proto/combined_transactions.proto create mode 100644 src/map_combine_transactions.rs diff --git a/Makefile b/Makefile index bcf51ae..8057f37 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,7 @@ build: .PHONY: run run: build - substreams run -e $(ENDPOINT) substreams.yaml db_out -s $(START_BLOCK) -t $(STOP_BLOCK) + substreams run -e $(ENDPOINT) substreams.yaml map_combine_transactions -s $(START_BLOCK) -t $(STOP_BLOCK) .PHONY: sink sink: build diff --git a/proto/combined_transactions.proto b/proto/combined_transactions.proto new file mode 100644 index 0000000..165c616 --- /dev/null +++ b/proto/combined_transactions.proto @@ -0,0 +1,11 @@ +syntax = "proto3"; + +package eth.transaction.v1; + +import "aa_transaction.proto"; +import "chronicle_transaction.proto"; + +message CombinedTransactions { + AccountAbstractionTransactions accountAbstractionTransactions = 1; + ChronicleTransactions chronicleTransactions = 2; +} \ No newline at end of file diff --git a/src/lib.rs b/src/lib.rs index c860a32..f0d8d63 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,5 +1,6 @@ mod map_filter_chronicle_transactions; mod map_filter_aa_transactions; +mod map_combine_transactions; mod db_out; mod pb; mod abi; diff --git a/src/map_combine_transactions.rs b/src/map_combine_transactions.rs new file mode 100644 index 0000000..46ce1d3 --- /dev/null +++ b/src/map_combine_transactions.rs @@ -0,0 +1,14 @@ +use crate::pb::eth::transaction::v1::{CombinedTransactions, AccountAbstractionTransactions, ChronicleTransactions}; + +#[substreams::handlers::map] +fn map_combine_transactions( + aa_trxs: AccountAbstractionTransactions, + chronicle_trxs: ChronicleTransactions +) -> Result> { + let transactions = CombinedTransactions { + account_abstraction_transactions: Some(aa_trxs), + chronicle_transactions: Some(chronicle_trxs) + }; + + Ok(transactions) +} \ No newline at end of file diff --git a/src/pb/eth.transaction.v1.rs b/src/pb/eth.transaction.v1.rs index 5afcb2f..9abd0a3 100644 --- a/src/pb/eth.transaction.v1.rs +++ b/src/pb/eth.transaction.v1.rs @@ -45,4 +45,12 @@ pub struct AccountAbstractionTransaction { #[prost(message, optional, tag="7")] pub timestamp: ::core::option::Option<::prost_types::Timestamp>, } +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct CombinedTransactions { + #[prost(message, optional, tag="1")] + pub account_abstraction_transactions: ::core::option::Option, + #[prost(message, optional, tag="2")] + pub chronicle_transactions: ::core::option::Option, +} // @@protoc_insertion_point(module) diff --git a/substreams.yaml b/substreams.yaml index 562cf7f..ee6a805 100644 --- a/substreams.yaml +++ b/substreams.yaml @@ -12,6 +12,7 @@ protobuf: files: - chronicle_transaction.proto - aa_transaction.proto + - combined_transactions.proto importPaths: - ./proto @@ -36,6 +37,15 @@ modules: - source: sf.ethereum.type.v2.Block output: type: proto:eth.transaction.v1.ChronicleTransactions + + - name: map_combine_transactions + kind: map + initialBlock: 18664500 + inputs: + - map: map_filter_aa_transactions + - map: map_filter_chronicle_transactions + output: + type: proto:eth.transaction.v1.CombinedTransactions - name: db_out kind: map From 603cc8ba70c6b6581f866b13a86308f297837670 Mon Sep 17 00:00:00 2001 From: catalyst17 <37663786+catalyst17@users.noreply.github.com> Date: Thu, 30 Nov 2023 13:23:49 +0100 Subject: [PATCH 2/3] feat: remove initialBlock to not depend on network --- substreams.yaml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/substreams.yaml b/substreams.yaml index ee6a805..96487d2 100644 --- a/substreams.yaml +++ b/substreams.yaml @@ -24,7 +24,6 @@ binaries: modules: - name: map_filter_aa_transactions kind: map - initialBlock: 18664500 inputs: - source: sf.ethereum.type.v2.Block output: @@ -32,7 +31,6 @@ modules: - name: map_filter_chronicle_transactions kind: map - initialBlock: 18664500 inputs: - source: sf.ethereum.type.v2.Block output: @@ -40,7 +38,6 @@ modules: - name: map_combine_transactions kind: map - initialBlock: 18664500 inputs: - map: map_filter_aa_transactions - map: map_filter_chronicle_transactions @@ -49,7 +46,6 @@ modules: - name: db_out kind: map - initialBlock: 18664500 inputs: - map: map_filter_aa_transactions - map: map_filter_chronicle_transactions From e90e5bad39bb9d240d9e93f3121f2e4fbfb8048c Mon Sep 17 00:00:00 2001 From: catalyst17 <37663786+catalyst17@users.noreply.github.com> Date: Thu, 30 Nov 2023 13:24:18 +0100 Subject: [PATCH 3/3] refactor: combined trxs format --- proto/combined_transactions.proto | 4 ++-- src/map_combine_transactions.rs | 7 +------ src/pb/eth.transaction.v1.rs | 8 ++++---- 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/proto/combined_transactions.proto b/proto/combined_transactions.proto index 165c616..4fc3284 100644 --- a/proto/combined_transactions.proto +++ b/proto/combined_transactions.proto @@ -6,6 +6,6 @@ import "aa_transaction.proto"; import "chronicle_transaction.proto"; message CombinedTransactions { - AccountAbstractionTransactions accountAbstractionTransactions = 1; - ChronicleTransactions chronicleTransactions = 2; + repeated AccountAbstractionTransaction accountAbstractionTransactions = 1; + repeated ChronicleTransaction chronicleTransactions = 2; } \ No newline at end of file diff --git a/src/map_combine_transactions.rs b/src/map_combine_transactions.rs index 46ce1d3..2567187 100644 --- a/src/map_combine_transactions.rs +++ b/src/map_combine_transactions.rs @@ -5,10 +5,5 @@ fn map_combine_transactions( aa_trxs: AccountAbstractionTransactions, chronicle_trxs: ChronicleTransactions ) -> Result> { - let transactions = CombinedTransactions { - account_abstraction_transactions: Some(aa_trxs), - chronicle_transactions: Some(chronicle_trxs) - }; - - Ok(transactions) + Ok(CombinedTransactions { account_abstraction_transactions: aa_trxs.transactions, chronicle_transactions: chronicle_trxs.transactions }) } \ No newline at end of file diff --git a/src/pb/eth.transaction.v1.rs b/src/pb/eth.transaction.v1.rs index 9abd0a3..8b840f5 100644 --- a/src/pb/eth.transaction.v1.rs +++ b/src/pb/eth.transaction.v1.rs @@ -48,9 +48,9 @@ pub struct AccountAbstractionTransaction { #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct CombinedTransactions { - #[prost(message, optional, tag="1")] - pub account_abstraction_transactions: ::core::option::Option, - #[prost(message, optional, tag="2")] - pub chronicle_transactions: ::core::option::Option, + #[prost(message, repeated, tag="1")] + pub account_abstraction_transactions: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag="2")] + pub chronicle_transactions: ::prost::alloc::vec::Vec, } // @@protoc_insertion_point(module)