From e53be36532eacdff2f4eafc06af1a98b99d3751b Mon Sep 17 00:00:00 2001 From: arnaudberger Date: Tue, 6 Aug 2024 15:50:39 -0400 Subject: [PATCH 1/8] add index module on codegens --- .../templates/entities/substreams.yaml.gotmpl | 96 +++++++++++++++++++ ethfull/templates/substreams.yaml.gotmpl | 0 evm-events-calls/convo.go | 8 +- evm-events-calls/state.go | 59 ++++++++++-- .../templates/sql/substreams.yaml.gotmpl | 11 +++ .../templates/substreams.yaml.gotmpl | 13 +++ 6 files changed, 177 insertions(+), 10 deletions(-) create mode 100644 ethfull/templates/entities/substreams.yaml.gotmpl create mode 100644 ethfull/templates/substreams.yaml.gotmpl diff --git a/ethfull/templates/entities/substreams.yaml.gotmpl b/ethfull/templates/entities/substreams.yaml.gotmpl new file mode 100644 index 0000000..b7cda24 --- /dev/null +++ b/ethfull/templates/entities/substreams.yaml.gotmpl @@ -0,0 +1,96 @@ +specVersion: v0.1.0 +package: + name: {{ .ModuleName }} + version: v0.1.0 + +imports: + graph: https://github.com/streamingfast/substreams-sink-subgraph/releases/download/v{{ .GraphImportVersion }}/substreams-sink-subgraph-protodefs-v{{ .GraphImportVersion }}.spkg + entity: https://github.com/streamingfast/substreams-entity-change/releases/download/v{{ .EntityChangeImportVersion }}/substreams-entity-change-v{{ .EntityChangeImportVersion }}.spkg + ethcommon: https://spkg.io/streamingfast/ethereum-common-v0.3.0.spkg + +protobuf: + files: + - contract.proto + importPaths: + - ./proto + +binaries: + default: + type: wasm/rust-v1 + file: ./target/wasm32-unknown-unknown/release/substreams.wasm + +modules: +{{ range $ddsContract := .DynamicContracts }} + - name: store_{{ $ddsContract.Identifier }}_created + kind: store + initialBlock: {{ with $ddsContract.FactoryInitialBlock }}{{ . }}{{ else }}0{{ end }} + updatePolicy: set + valueType: proto:dynamic_datasource + inputs: + - source: sf.ethereum.type.v2.Block +{{- end}} +{{- if .TrackAnyEvents }} + - name: map_events + kind: map + blockFilter: + module: ethcommon:index_events + {{- $eventQuery := .GenerateEventsBlockFilterQuery }} + query: + string: {{ $eventQuery }} + initialBlock: {{ .MustLowestStartBlock }} + inputs: + - source: sf.ethereum.type.v2.Block +{{- range $ddsContract := .DynamicContracts }} + {{- if $ddsContract.TrackEvents }} + - store: store_{{ $ddsContract.Identifier }}_created + {{- end }} +{{- end }} + output: + type: proto:contract.v1.Events +{{- end }} + +{{- if and $.TrackAnyEvents $.TrackAnyCalls }} + - name: map_events_calls + kind: map + initialBlock: {{ .MustLowestStartBlock }} + inputs: + - map: map_events + - map: map_calls + output: + type: proto:contract.v1.EventsCalls +{{- end }} + +{{- if .TrackAnyCalls }} + - name: map_calls + kind: map + initialBlock: {{ .MustLowestStartBlock }} + blockFilter: + module: ethcommon:index_calls + {{ $callQuery := .GenerateCallsBlockFilterQuery }} + query: + string: {{ $callQuery }} + inputs: + - source: sf.ethereum.type.v2.Block +{{- range $ddsContract := .DynamicContracts }} + {{- if $ddsContract.TrackCalls }} + - store: store_{{ $ddsContract.Identifier }}_created + {{- end }} +{{- end }} + output: + type: proto:contract.v1.Calls +{{- end }}{{/* if TrackAnyCalls */}} + + - name: graph_out + kind: map + initialBlock: {{ .MustLowestStartBlock }} + inputs: +{{- if .TrackAnyEvents }} + - map: map_events +{{- end }} +{{- if .TrackAnyCalls }} + - map: map_calls +{{- end }} + output: + type: proto:sf.substreams.entity.v1.EntityChanges + +network: {{ .ChainName }} diff --git a/ethfull/templates/substreams.yaml.gotmpl b/ethfull/templates/substreams.yaml.gotmpl new file mode 100644 index 0000000..e69de29 diff --git a/evm-events-calls/convo.go b/evm-events-calls/convo.go index 5847896..178e3c3 100644 --- a/evm-events-calls/convo.go +++ b/evm-events-calls/convo.go @@ -136,12 +136,12 @@ func (c *Convo) NextStep() (out loop.Cmd) { if dynContract.Abi == nil { // if the user pasted an empty ABI, we would restart the process or choosing a contract address if dynContract.emptyABI { - dynContract.referenceContractAddress = "" // reset the reference address + dynContract.ReferenceContractAddress = "" // reset the reference address dynContract.emptyABI = false // reset the flag return notifyContext(cmd(AskContractAddress{})) } if dynContract.RawABI == nil { - if dynContract.referenceContractAddress == "" { + if dynContract.ReferenceContractAddress == "" { if p.ChainConfig().ApiEndpoint == "" { return notifyContext(cmd(AskDynamicContractABI{})) } @@ -275,7 +275,7 @@ func (c *Convo) Update(msg loop.Msg) loop.Cmd { } contract := c.State.dynamicContractOf(factory.Name) - contract.referenceContractAddress = inputAddress + contract.ReferenceContractAddress = inputAddress return c.NextStep() @@ -422,7 +422,7 @@ func (c *Convo) Update(msg loop.Msg) loop.Cmd { contract := c.State.dynamicContractOf(factory.Name) if msg.err != nil { return loop.Seq( - c.Msg().Messagef("Cannot fetch the ABI for dynamic contract %q (%s)", contract.referenceContractAddress, msg.err).Cmd(), + c.Msg().Messagef("Cannot fetch the ABI for dynamic contract %q (%s)", contract.ReferenceContractAddress, msg.err).Cmd(), cmd(AskDynamicContractABI{}), ) } diff --git a/evm-events-calls/state.go b/evm-events-calls/state.go index f0af20b..60275a5 100644 --- a/evm-events-calls/state.go +++ b/evm-events-calls/state.go @@ -75,6 +75,53 @@ func isValidChainName(input string) bool { return ChainConfigByID[input] != nil } +func (p *Project) GenerateEventsBlockFilterQuery() string { + var query string + for i, contract := range p.Contracts { + if i == 0 { + query = fmt.Sprintf("evt_addr:%s", contract.Address) + continue + } + + query += fmt.Sprintf(" || evt_addr:%s", contract.Address) + } + + for i, dynamicContract := range p.DynamicContracts { + if i == 0 { + query += fmt.Sprintf(" || evt_addr:%s", dynamicContract.ReferenceContractAddress) + fmt.Println("query", query) + continue + } + + query += fmt.Sprintf(" || evt_addr:%s", dynamicContract.ReferenceContractAddress) + fmt.Println("query", query) + } + + return query +} + +func (p *Project) GenerateCallsBlockFilterQuery() string { + var query string + for i, contract := range p.Contracts { + if i == 0 { + query = fmt.Sprintf("call_to:%s", contract.Address) + continue + } + + query += fmt.Sprintf(" || call_to:%s", contract.Address) + } + + for i, dynamicContract := range p.DynamicContracts { + if i == 0 { + query += fmt.Sprintf(" || call_to:%s", dynamicContract.ReferenceContractAddress) + continue + } + + query += fmt.Sprintf(" || call_to:%s", dynamicContract.ReferenceContractAddress) + } + return query +} + func (p *Project) TrackAnyCalls() bool { for _, contract := range p.Contracts { if contract.TrackCalls { @@ -268,7 +315,7 @@ type DynamicContract struct { ParentContractName string `json:"parentContractName"` parentContract *Contract - referenceContractAddress string + ReferenceContractAddress string `json:"referenceContractAddress"` } func (d DynamicContract) FactoryInitialBlock() uint64 { @@ -279,7 +326,7 @@ func (d DynamicContract) ParentContract() *Contract { return d.parentContract func (d DynamicContract) Identifier() string { return d.Name } func (d DynamicContract) IdentifierSnakeCase() string { return kace.Snake(d.Name) } func (d DynamicContract) FetchABI(chainConfig *ChainConfig) (abi string, err error) { - a, err := getContractABIFollowingProxy(context.Background(), d.referenceContractAddress, chainConfig) + a, err := getContractABIFollowingProxy(context.Background(), d.ReferenceContractAddress, chainConfig) if err != nil { return "", err } @@ -317,7 +364,7 @@ func validateContractAddress(p *Project, address string) error { } for _, dynamicContract := range p.DynamicContracts { - if dynamicContract.referenceContractAddress == address { + if dynamicContract.ReferenceContractAddress == address { return fmt.Errorf("contract address %s already exists in the project", address) } } @@ -347,12 +394,12 @@ func validateIncomingState(p *Project) error { return fmt.Errorf("contract with name %s already exists in the project", dynamicContract.Name) } - if _, found := uniqueContractAddresses[dynamicContract.referenceContractAddress]; found { - return fmt.Errorf("contract address %s already exists in the project", dynamicContract.referenceContractAddress) + if _, found := uniqueContractAddresses[dynamicContract.ReferenceContractAddress]; found { + return fmt.Errorf("contract address %s already exists in the project", dynamicContract.ReferenceContractAddress) } uniqueContractNames[dynamicContract.Name] = struct{}{} - uniqueContractAddresses[dynamicContract.referenceContractAddress] = struct{}{} + uniqueContractAddresses[dynamicContract.ReferenceContractAddress] = struct{}{} } return nil diff --git a/evm-events-calls/templates/sql/substreams.yaml.gotmpl b/evm-events-calls/templates/sql/substreams.yaml.gotmpl index 547fedd..0d3ec95 100644 --- a/evm-events-calls/templates/sql/substreams.yaml.gotmpl +++ b/evm-events-calls/templates/sql/substreams.yaml.gotmpl @@ -6,6 +6,7 @@ package: imports: sql: https://github.com/streamingfast/substreams-sink-sql/releases/download/protodefs-v{{ .SQLImportVersion }}/substreams-sink-sql-protodefs-v{{ .SQLImportVersion }}.spkg database_change: https://github.com/streamingfast/substreams-sink-database-changes/releases/download/v{{ .DatabaseChangeImportVersion }}/substreams-database-change-v{{ .DatabaseChangeImportVersion }}.spkg + ethcommon: https://spkg.io/streamingfast/ethereum-common-v0.3.0.spkg protobuf: files: @@ -33,6 +34,11 @@ modules: - name: map_events kind: map initialBlock: {{ .MustLowestStartBlock }} + blockFilter: + module: ethcommon:index_events + {{- $eventQuery := .GenerateEventsBlockFilterQuery }} + query: + string: {{ $eventQuery }} inputs: - source: sf.ethereum.type.v2.Block {{- range $index, $ddsContract := .DynamicContracts }} @@ -60,6 +66,11 @@ modules: - name: map_calls kind: map initialBlock: {{ .MustLowestStartBlock }} + blockFilter: + module: ethcommon:index_calls + {{ $callQuery := .GenerateCallsBlockFilterQuery }} + query: + string: {{ $callQuery }} inputs: - source: sf.ethereum.type.v2.Block {{- range $ddsContract := .DynamicContracts }} diff --git a/evm-events-calls/templates/substreams.yaml.gotmpl b/evm-events-calls/templates/substreams.yaml.gotmpl index c6c65ed..aa04a9b 100644 --- a/evm-events-calls/templates/substreams.yaml.gotmpl +++ b/evm-events-calls/templates/substreams.yaml.gotmpl @@ -3,6 +3,9 @@ package: name: {{ .ModuleName }} version: v0.1.0 +imports: + ethcommon: https://spkg.io/streamingfast/ethereum-common-v0.3.0.spkg + protobuf: files: - contract.proto @@ -32,6 +35,11 @@ modules: - name: map_events kind: map initialBlock: {{ .MustLowestStartBlock }} + blockFilter: + module: ethcommon:index_events + {{- $eventQuery := .GenerateEventsBlockFilterQuery }} + query: + string: {{ $eventQuery }} inputs: - source: sf.ethereum.type.v2.Block {{- range $index, $ddsContract := .DynamicContracts }} @@ -46,6 +54,11 @@ modules: - name: map_calls kind: map initialBlock: {{ .MustLowestStartBlock }} + blockFilter: + module: ethcommon:index_calls + {{ $callQuery := .GenerateCallsBlockFilterQuery }} + query: + string: {{ $callQuery }} inputs: - source: sf.ethereum.type.v2.Block {{- range $index, $ddsContract := .DynamicContracts }} From 4157cdd161b43bb1a84607780f465375f4469857 Mon Sep 17 00:00:00 2001 From: arnaudberger Date: Tue, 22 Oct 2024 12:06:19 -0400 Subject: [PATCH 2/8] remove prints --- evm-events-calls/state.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/evm-events-calls/state.go b/evm-events-calls/state.go index 60275a5..4370160 100644 --- a/evm-events-calls/state.go +++ b/evm-events-calls/state.go @@ -89,12 +89,10 @@ func (p *Project) GenerateEventsBlockFilterQuery() string { for i, dynamicContract := range p.DynamicContracts { if i == 0 { query += fmt.Sprintf(" || evt_addr:%s", dynamicContract.ReferenceContractAddress) - fmt.Println("query", query) continue } query += fmt.Sprintf(" || evt_addr:%s", dynamicContract.ReferenceContractAddress) - fmt.Println("query", query) } return query From add77bd89bd98e4844390b761315b0ec142d0c71 Mon Sep 17 00:00:00 2001 From: arnaudberger Date: Tue, 22 Oct 2024 12:07:11 -0400 Subject: [PATCH 3/8] remove ethfull entities --- .../templates/entities/substreams.yaml.gotmpl | 96 ------------------- ethfull/templates/substreams.yaml.gotmpl | 0 2 files changed, 96 deletions(-) delete mode 100644 ethfull/templates/entities/substreams.yaml.gotmpl delete mode 100644 ethfull/templates/substreams.yaml.gotmpl diff --git a/ethfull/templates/entities/substreams.yaml.gotmpl b/ethfull/templates/entities/substreams.yaml.gotmpl deleted file mode 100644 index b7cda24..0000000 --- a/ethfull/templates/entities/substreams.yaml.gotmpl +++ /dev/null @@ -1,96 +0,0 @@ -specVersion: v0.1.0 -package: - name: {{ .ModuleName }} - version: v0.1.0 - -imports: - graph: https://github.com/streamingfast/substreams-sink-subgraph/releases/download/v{{ .GraphImportVersion }}/substreams-sink-subgraph-protodefs-v{{ .GraphImportVersion }}.spkg - entity: https://github.com/streamingfast/substreams-entity-change/releases/download/v{{ .EntityChangeImportVersion }}/substreams-entity-change-v{{ .EntityChangeImportVersion }}.spkg - ethcommon: https://spkg.io/streamingfast/ethereum-common-v0.3.0.spkg - -protobuf: - files: - - contract.proto - importPaths: - - ./proto - -binaries: - default: - type: wasm/rust-v1 - file: ./target/wasm32-unknown-unknown/release/substreams.wasm - -modules: -{{ range $ddsContract := .DynamicContracts }} - - name: store_{{ $ddsContract.Identifier }}_created - kind: store - initialBlock: {{ with $ddsContract.FactoryInitialBlock }}{{ . }}{{ else }}0{{ end }} - updatePolicy: set - valueType: proto:dynamic_datasource - inputs: - - source: sf.ethereum.type.v2.Block -{{- end}} -{{- if .TrackAnyEvents }} - - name: map_events - kind: map - blockFilter: - module: ethcommon:index_events - {{- $eventQuery := .GenerateEventsBlockFilterQuery }} - query: - string: {{ $eventQuery }} - initialBlock: {{ .MustLowestStartBlock }} - inputs: - - source: sf.ethereum.type.v2.Block -{{- range $ddsContract := .DynamicContracts }} - {{- if $ddsContract.TrackEvents }} - - store: store_{{ $ddsContract.Identifier }}_created - {{- end }} -{{- end }} - output: - type: proto:contract.v1.Events -{{- end }} - -{{- if and $.TrackAnyEvents $.TrackAnyCalls }} - - name: map_events_calls - kind: map - initialBlock: {{ .MustLowestStartBlock }} - inputs: - - map: map_events - - map: map_calls - output: - type: proto:contract.v1.EventsCalls -{{- end }} - -{{- if .TrackAnyCalls }} - - name: map_calls - kind: map - initialBlock: {{ .MustLowestStartBlock }} - blockFilter: - module: ethcommon:index_calls - {{ $callQuery := .GenerateCallsBlockFilterQuery }} - query: - string: {{ $callQuery }} - inputs: - - source: sf.ethereum.type.v2.Block -{{- range $ddsContract := .DynamicContracts }} - {{- if $ddsContract.TrackCalls }} - - store: store_{{ $ddsContract.Identifier }}_created - {{- end }} -{{- end }} - output: - type: proto:contract.v1.Calls -{{- end }}{{/* if TrackAnyCalls */}} - - - name: graph_out - kind: map - initialBlock: {{ .MustLowestStartBlock }} - inputs: -{{- if .TrackAnyEvents }} - - map: map_events -{{- end }} -{{- if .TrackAnyCalls }} - - map: map_calls -{{- end }} - output: - type: proto:sf.substreams.entity.v1.EntityChanges - -network: {{ .ChainName }} diff --git a/ethfull/templates/substreams.yaml.gotmpl b/ethfull/templates/substreams.yaml.gotmpl deleted file mode 100644 index e69de29..0000000 From 16f01f3fa33742095dc6087a43f3ed111c61da0c Mon Sep 17 00:00:00 2001 From: arnaudberger Date: Tue, 22 Oct 2024 12:08:05 -0400 Subject: [PATCH 4/8] clean yaml --- evm-events-calls/templates/substreams.yaml.gotmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/evm-events-calls/templates/substreams.yaml.gotmpl b/evm-events-calls/templates/substreams.yaml.gotmpl index aa04a9b..b420598 100644 --- a/evm-events-calls/templates/substreams.yaml.gotmpl +++ b/evm-events-calls/templates/substreams.yaml.gotmpl @@ -56,7 +56,7 @@ modules: initialBlock: {{ .MustLowestStartBlock }} blockFilter: module: ethcommon:index_calls - {{ $callQuery := .GenerateCallsBlockFilterQuery }} + {{- $callQuery := .GenerateCallsBlockFilterQuery }} query: string: {{ $callQuery }} inputs: From 5a724682eb7c81eb4ca912113e42c8339395a031 Mon Sep 17 00:00:00 2001 From: arnaudberger Date: Wed, 30 Oct 2024 13:25:06 -0400 Subject: [PATCH 5/8] fix event_calls block filters --- evm-events-calls/state.go | 63 +++++++++++++------ .../templates/substreams.yaml.gotmpl | 8 +++ 2 files changed, 51 insertions(+), 20 deletions(-) diff --git a/evm-events-calls/state.go b/evm-events-calls/state.go index 4370160..dfb2afa 100644 --- a/evm-events-calls/state.go +++ b/evm-events-calls/state.go @@ -75,24 +75,51 @@ func isValidChainName(input string) bool { return ChainConfigByID[input] != nil } +func (p *Project) ApplyEventsBlockFilter() bool { + for _, dcontract := range p.DynamicContracts { + if dcontract.TrackEvents { + return false + } + } + + for _, contract := range p.Contracts { + if contract.TrackEvents { + return true + } + } + + return false +} + +func (p *Project) ApplyCallsBlockFilter() bool { + for _, dcontract := range p.DynamicContracts { + if dcontract.TrackCalls { + return false + } + } + + for _, contract := range p.Contracts { + if contract.TrackCalls { + return true + } + } + + return false +} + func (p *Project) GenerateEventsBlockFilterQuery() string { var query string - for i, contract := range p.Contracts { - if i == 0 { - query = fmt.Sprintf("evt_addr:%s", contract.Address) + for _, contract := range p.Contracts { + if !contract.TrackEvents { continue } - query += fmt.Sprintf(" || evt_addr:%s", contract.Address) - } - - for i, dynamicContract := range p.DynamicContracts { - if i == 0 { - query += fmt.Sprintf(" || evt_addr:%s", dynamicContract.ReferenceContractAddress) + if query == "" { + query = fmt.Sprintf("evt_addr:%s", contract.Address) continue } - query += fmt.Sprintf(" || evt_addr:%s", dynamicContract.ReferenceContractAddress) + query += fmt.Sprintf(" || evt_addr:%s", contract.Address) } return query @@ -100,23 +127,19 @@ func (p *Project) GenerateEventsBlockFilterQuery() string { func (p *Project) GenerateCallsBlockFilterQuery() string { var query string - for i, contract := range p.Contracts { - if i == 0 { - query = fmt.Sprintf("call_to:%s", contract.Address) + for _, contract := range p.Contracts { + if !contract.TrackCalls { continue } - query += fmt.Sprintf(" || call_to:%s", contract.Address) - } - - for i, dynamicContract := range p.DynamicContracts { - if i == 0 { - query += fmt.Sprintf(" || call_to:%s", dynamicContract.ReferenceContractAddress) + if query == "" { + query = fmt.Sprintf("call_to:%s", contract.Address) continue } - query += fmt.Sprintf(" || call_to:%s", dynamicContract.ReferenceContractAddress) + query += fmt.Sprintf(" || call_to:%s", contract.Address) } + return query } diff --git a/evm-events-calls/templates/substreams.yaml.gotmpl b/evm-events-calls/templates/substreams.yaml.gotmpl index b420598..6419e36 100644 --- a/evm-events-calls/templates/substreams.yaml.gotmpl +++ b/evm-events-calls/templates/substreams.yaml.gotmpl @@ -27,6 +27,10 @@ modules: initialBlock: {{ with $ddsContract.ParentContract.InitialBlock }}{{ . }}{{ else }}0{{ end }} updatePolicy: set valueType: proto:dynamic_datasource + blockFilter: + module: ethcommon:index_events + query: + string: evt_addr:{{ $ddsContract.ParentContract.Address }} inputs: - source: sf.ethereum.type.v2.Block {{- end}} @@ -35,11 +39,13 @@ modules: - name: map_events kind: map initialBlock: {{ .MustLowestStartBlock }} + {{- if .ApplyEventsBlockFilter }} blockFilter: module: ethcommon:index_events {{- $eventQuery := .GenerateEventsBlockFilterQuery }} query: string: {{ $eventQuery }} + {{- end }} inputs: - source: sf.ethereum.type.v2.Block {{- range $index, $ddsContract := .DynamicContracts }} @@ -54,11 +60,13 @@ modules: - name: map_calls kind: map initialBlock: {{ .MustLowestStartBlock }} + {{- if .ApplyCallsBlockFilter }} blockFilter: module: ethcommon:index_calls {{- $callQuery := .GenerateCallsBlockFilterQuery }} query: string: {{ $callQuery }} + {{- end }} inputs: - source: sf.ethereum.type.v2.Block {{- range $index, $ddsContract := .DynamicContracts }} From 3a3855c88d2ad6d199d37e10be40f3c987008ddc Mon Sep 17 00:00:00 2001 From: arnaudberger Date: Wed, 30 Oct 2024 14:59:35 -0400 Subject: [PATCH 6/8] fix spaces --- .../templates/substreams.yaml.gotmpl | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/evm-events-calls/templates/substreams.yaml.gotmpl b/evm-events-calls/templates/substreams.yaml.gotmpl index 6419e36..596ac30 100644 --- a/evm-events-calls/templates/substreams.yaml.gotmpl +++ b/evm-events-calls/templates/substreams.yaml.gotmpl @@ -28,9 +28,9 @@ modules: updatePolicy: set valueType: proto:dynamic_datasource blockFilter: - module: ethcommon:index_events - query: - string: evt_addr:{{ $ddsContract.ParentContract.Address }} + module: ethcommon:index_events + query: + string: evt_addr:{{ $ddsContract.ParentContract.Address }} inputs: - source: sf.ethereum.type.v2.Block {{- end}} @@ -41,10 +41,10 @@ modules: initialBlock: {{ .MustLowestStartBlock }} {{- if .ApplyEventsBlockFilter }} blockFilter: - module: ethcommon:index_events - {{- $eventQuery := .GenerateEventsBlockFilterQuery }} - query: - string: {{ $eventQuery }} + module: ethcommon:index_events + {{- $eventQuery := .GenerateEventsBlockFilterQuery }} + query: + string: {{ $eventQuery }} {{- end }} inputs: - source: sf.ethereum.type.v2.Block @@ -62,10 +62,10 @@ modules: initialBlock: {{ .MustLowestStartBlock }} {{- if .ApplyCallsBlockFilter }} blockFilter: - module: ethcommon:index_calls - {{- $callQuery := .GenerateCallsBlockFilterQuery }} - query: - string: {{ $callQuery }} + module: ethcommon:index_calls + {{- $callQuery := .GenerateCallsBlockFilterQuery }} + query: + string: {{ $callQuery }} {{- end }} inputs: - source: sf.ethereum.type.v2.Block From 73c24c3b1c43d64c2534a2e04bac00b8db0c1334 Mon Sep 17 00:00:00 2001 From: arnaudberger Date: Wed, 30 Oct 2024 15:40:46 -0400 Subject: [PATCH 7/8] add evt_sig to filter --- evm-events-calls/state.go | 4 +++- evm-events-calls/templates/substreams.yaml.gotmpl | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/evm-events-calls/state.go b/evm-events-calls/state.go index dfb2afa..4d69dfe 100644 --- a/evm-events-calls/state.go +++ b/evm-events-calls/state.go @@ -342,7 +342,9 @@ type DynamicContract struct { func (d DynamicContract) FactoryInitialBlock() uint64 { return *d.parentContract.InitialBlock } - +func (d DynamicContract) GenerateStoreQuery() string { + return fmt.Sprintf("evt_addr:%s || evt_sig:%s", d.parentContract.Address, "0x"+d.parentContract.FactoryCreationEvent) +} func (d DynamicContract) ParentContract() *Contract { return d.parentContract } func (d DynamicContract) Identifier() string { return d.Name } func (d DynamicContract) IdentifierSnakeCase() string { return kace.Snake(d.Name) } diff --git a/evm-events-calls/templates/substreams.yaml.gotmpl b/evm-events-calls/templates/substreams.yaml.gotmpl index 596ac30..0af7026 100644 --- a/evm-events-calls/templates/substreams.yaml.gotmpl +++ b/evm-events-calls/templates/substreams.yaml.gotmpl @@ -30,7 +30,7 @@ modules: blockFilter: module: ethcommon:index_events query: - string: evt_addr:{{ $ddsContract.ParentContract.Address }} + string: {{ $ddsContract.GenerateStoreQuery }} inputs: - source: sf.ethereum.type.v2.Block {{- end}} From 0ec39822397a848c862730def002f6177f7d6462 Mon Sep 17 00:00:00 2001 From: arnaudberger Date: Wed, 30 Oct 2024 15:54:47 -0400 Subject: [PATCH 8/8] change or to && --- evm-events-calls/state.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/evm-events-calls/state.go b/evm-events-calls/state.go index 4d69dfe..51983a2 100644 --- a/evm-events-calls/state.go +++ b/evm-events-calls/state.go @@ -343,7 +343,7 @@ func (d DynamicContract) FactoryInitialBlock() uint64 { return *d.parentContract.InitialBlock } func (d DynamicContract) GenerateStoreQuery() string { - return fmt.Sprintf("evt_addr:%s || evt_sig:%s", d.parentContract.Address, "0x"+d.parentContract.FactoryCreationEvent) + return fmt.Sprintf("evt_addr:%s && evt_sig:%s", d.parentContract.Address, "0x"+d.parentContract.FactoryCreationEvent) } func (d DynamicContract) ParentContract() *Contract { return d.parentContract } func (d DynamicContract) Identifier() string { return d.Name }