Skip to content

Commit ba74aa5

Browse files
mergify[bot]cool-developejulienrbrt
authored
feat(server/v2): refactor the server/v2 events (backport #21785) (#21807)
Co-authored-by: cool-developer <[email protected]> Co-authored-by: Julien Robert <[email protected]>
1 parent e42e270 commit ba74aa5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+275
-239
lines changed

client/v2/go.mod

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ go 1.23.1
44

55
require (
66
cosmossdk.io/api v0.8.0
7-
cosmossdk.io/core v1.0.0-alpha.2 // main
7+
cosmossdk.io/core v1.0.0-alpha.3 // main
88
cosmossdk.io/depinject v1.0.0
99
cosmossdk.io/x/bank v0.0.0-20240226161501-23359a0b6d91
1010
cosmossdk.io/x/gov v0.0.0-20231113122742-912390d5fc4a
@@ -27,7 +27,7 @@ require (
2727
cosmossdk.io/errors v1.0.1 // indirect
2828
cosmossdk.io/log v1.4.1 // indirect
2929
cosmossdk.io/math v1.3.0
30-
cosmossdk.io/schema v0.2.0 // indirect
30+
cosmossdk.io/schema v0.3.0 // indirect
3131
cosmossdk.io/store v1.1.1-0.20240909133312-50288938d1b6 // indirect
3232
cosmossdk.io/x/staking v0.0.0-00010101000000-000000000000 // indirect
3333
filippo.io/edwards25519 v1.1.0 // indirect

client/v2/go.sum

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ cosmossdk.io/api v0.7.3-0.20240815194237-858ec2fcb897 h1:YV9M+9pClbzPncO5XMSc3kI
88
cosmossdk.io/api v0.7.3-0.20240815194237-858ec2fcb897/go.mod h1:oqpDMZQpEgSo0Cm4F+0yxoC9UQbo/SlodZR4zeOqBsE=
99
cosmossdk.io/collections v0.4.1-0.20240802064046-23fac2f1b8ab h1:E/IWad76v1Nc4Atswaccpt7twJ0VwHkbY94/PhmZfTo=
1010
cosmossdk.io/collections v0.4.1-0.20240802064046-23fac2f1b8ab/go.mod h1:Or+5eVAo1aiS1DnPK90eQykGc59LGBWtqwBoJcxXTmw=
11-
cosmossdk.io/core v1.0.0-alpha.2 h1:epU0Xwces4Rgl5bMhHHkXGaGDcyucNGlC/JDH+Suckg=
12-
cosmossdk.io/core v1.0.0-alpha.2/go.mod h1:abgLjeFLhtuKIYZWSPlVUgQBrKObO7ULV35KYfexE90=
11+
cosmossdk.io/core v1.0.0-alpha.3 h1:pnxaYAas7llXgVz1lM7X6De74nWrhNKnB3yMKe4OUUA=
12+
cosmossdk.io/core v1.0.0-alpha.3/go.mod h1:3u9cWq1FAVtiiCrDPpo4LhR+9V6k/ycSG4/Y/tREWCY=
1313
cosmossdk.io/core/testing v0.0.0-20240913164418-aaf72f20c10b h1:uEMbr7Hdpz0fU+GXU6mSN2vgoQnr66WYUpRuiba2aEk=
1414
cosmossdk.io/core/testing v0.0.0-20240913164418-aaf72f20c10b/go.mod h1:FllCSj/ZYskfb982HKqBSISO8DkBY4Euqq768HSFz68=
1515
cosmossdk.io/depinject v1.0.0 h1:dQaTu6+O6askNXO06+jyeUAnF2/ssKwrrszP9t5q050=
@@ -20,8 +20,8 @@ cosmossdk.io/log v1.4.1 h1:wKdjfDRbDyZRuWa8M+9nuvpVYxrEOwbD/CA8hvhU8QM=
2020
cosmossdk.io/log v1.4.1/go.mod h1:k08v0Pyq+gCP6phvdI6RCGhLf/r425UT6Rk/m+o74rU=
2121
cosmossdk.io/math v1.3.0 h1:RC+jryuKeytIiictDslBP9i1fhkVm6ZDmZEoNP316zE=
2222
cosmossdk.io/math v1.3.0/go.mod h1:vnRTxewy+M7BtXBNFybkuhSH4WfedVAAnERHgVFhp3k=
23-
cosmossdk.io/schema v0.2.0 h1:UH5CR1DqUq8yP+5Np8PbvG4YX0zAUsTN2Qk6yThmfMk=
24-
cosmossdk.io/schema v0.2.0/go.mod h1:RDAhxIeNB4bYqAlF4NBJwRrgtnciMcyyg0DOKnhNZQQ=
23+
cosmossdk.io/schema v0.3.0 h1:01lcaM4trhzZ1HQTfTV8z6Ma1GziOZ/YmdzBN3F720c=
24+
cosmossdk.io/schema v0.3.0/go.mod h1:RDAhxIeNB4bYqAlF4NBJwRrgtnciMcyyg0DOKnhNZQQ=
2525
cosmossdk.io/store v1.0.0-rc.0.0.20240913190136-3bc707a5a214 h1:UUW0+2UgbDwQ452o2aw4DrVSWmowcad7DB7Vln+N94I=
2626
cosmossdk.io/store v1.0.0-rc.0.0.20240913190136-3bc707a5a214/go.mod h1:ct8HATr+s48YYTRXEyP3HF33v9qEVWHMxwOL8P/v4iQ=
2727
cosmossdk.io/x/protocolpool v0.0.0-20230925135524-a1bc045b3190 h1:XQJj9Dv9Gtze0l2TF79BU5lkP6MkUveTUuKICmxoz+o=

go.mod

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ require (
66
buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2 // indirect
77
cosmossdk.io/api v0.8.0 // main
88
cosmossdk.io/collections v0.4.1-0.20240802064046-23fac2f1b8ab // main
9-
cosmossdk.io/core v1.0.0-alpha.2
9+
cosmossdk.io/core v1.0.0-alpha.3
1010
cosmossdk.io/core/testing v0.0.0-20240913164418-aaf72f20c10b // main
1111
cosmossdk.io/depinject v1.0.0
1212
cosmossdk.io/errors v1.0.1
1313
cosmossdk.io/log v1.4.1
1414
cosmossdk.io/math v1.3.0
15-
cosmossdk.io/schema v0.2.0
15+
cosmossdk.io/schema v0.3.0
1616
cosmossdk.io/store v1.1.1-0.20240909133312-50288938d1b6
1717
cosmossdk.io/x/bank v0.0.0-20240226161501-23359a0b6d91
1818
cosmossdk.io/x/staking v0.0.0-00010101000000-000000000000

go.sum

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ cosmossdk.io/api v0.7.3-0.20240815194237-858ec2fcb897 h1:YV9M+9pClbzPncO5XMSc3kI
88
cosmossdk.io/api v0.7.3-0.20240815194237-858ec2fcb897/go.mod h1:oqpDMZQpEgSo0Cm4F+0yxoC9UQbo/SlodZR4zeOqBsE=
99
cosmossdk.io/collections v0.4.1-0.20240802064046-23fac2f1b8ab h1:E/IWad76v1Nc4Atswaccpt7twJ0VwHkbY94/PhmZfTo=
1010
cosmossdk.io/collections v0.4.1-0.20240802064046-23fac2f1b8ab/go.mod h1:Or+5eVAo1aiS1DnPK90eQykGc59LGBWtqwBoJcxXTmw=
11-
cosmossdk.io/core v1.0.0-alpha.2 h1:epU0Xwces4Rgl5bMhHHkXGaGDcyucNGlC/JDH+Suckg=
12-
cosmossdk.io/core v1.0.0-alpha.2/go.mod h1:abgLjeFLhtuKIYZWSPlVUgQBrKObO7ULV35KYfexE90=
11+
cosmossdk.io/core v1.0.0-alpha.3 h1:pnxaYAas7llXgVz1lM7X6De74nWrhNKnB3yMKe4OUUA=
12+
cosmossdk.io/core v1.0.0-alpha.3/go.mod h1:3u9cWq1FAVtiiCrDPpo4LhR+9V6k/ycSG4/Y/tREWCY=
1313
cosmossdk.io/core/testing v0.0.0-20240913164418-aaf72f20c10b h1:uEMbr7Hdpz0fU+GXU6mSN2vgoQnr66WYUpRuiba2aEk=
1414
cosmossdk.io/core/testing v0.0.0-20240913164418-aaf72f20c10b/go.mod h1:FllCSj/ZYskfb982HKqBSISO8DkBY4Euqq768HSFz68=
1515
cosmossdk.io/depinject v1.0.0 h1:dQaTu6+O6askNXO06+jyeUAnF2/ssKwrrszP9t5q050=
@@ -20,8 +20,8 @@ cosmossdk.io/log v1.4.1 h1:wKdjfDRbDyZRuWa8M+9nuvpVYxrEOwbD/CA8hvhU8QM=
2020
cosmossdk.io/log v1.4.1/go.mod h1:k08v0Pyq+gCP6phvdI6RCGhLf/r425UT6Rk/m+o74rU=
2121
cosmossdk.io/math v1.3.0 h1:RC+jryuKeytIiictDslBP9i1fhkVm6ZDmZEoNP316zE=
2222
cosmossdk.io/math v1.3.0/go.mod h1:vnRTxewy+M7BtXBNFybkuhSH4WfedVAAnERHgVFhp3k=
23-
cosmossdk.io/schema v0.2.0 h1:UH5CR1DqUq8yP+5Np8PbvG4YX0zAUsTN2Qk6yThmfMk=
24-
cosmossdk.io/schema v0.2.0/go.mod h1:RDAhxIeNB4bYqAlF4NBJwRrgtnciMcyyg0DOKnhNZQQ=
23+
cosmossdk.io/schema v0.3.0 h1:01lcaM4trhzZ1HQTfTV8z6Ma1GziOZ/YmdzBN3F720c=
24+
cosmossdk.io/schema v0.3.0/go.mod h1:RDAhxIeNB4bYqAlF4NBJwRrgtnciMcyyg0DOKnhNZQQ=
2525
cosmossdk.io/store v1.0.0-rc.0.0.20240913190136-3bc707a5a214 h1:UUW0+2UgbDwQ452o2aw4DrVSWmowcad7DB7Vln+N94I=
2626
cosmossdk.io/store v1.0.0-rc.0.0.20240913190136-3bc707a5a214/go.mod h1:ct8HATr+s48YYTRXEyP3HF33v9qEVWHMxwOL8P/v4iQ=
2727
cosmossdk.io/x/tx v0.13.4-0.20240918094839-0c8ad9d2c64b h1:FyLcX6eZh9c4FqWla3pXubLIIVlndfQohvf+IcXg99M=

server/v2/cometbft/abci.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,16 @@ func (c *Consensus[T]) CheckTx(ctx context.Context, req *abciproto.CheckTxReques
126126
return nil, err
127127
}
128128

129+
events, err := intoABCIEvents(resp.Events, c.indexedEvents)
130+
if err != nil {
131+
return nil, err
132+
}
133+
129134
cometResp := &abciproto.CheckTxResponse{
130135
Code: resp.Code,
131136
GasWanted: uint64ToInt64(resp.GasWanted),
132137
GasUsed: uint64ToInt64(resp.GasUsed),
133-
Events: intoABCIEvents(resp.Events, c.indexedEvents),
138+
Events: events,
134139
}
135140
if resp.Error != nil {
136141
cometResp.Code = 1

server/v2/cometbft/go.mod

+6-6
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ replace (
66
// pseudo version lower than the latest tag
77
cosmossdk.io/api => cosmossdk.io/api v0.7.3-0.20240815194237-858ec2fcb897 // main
88
// pseudo version lower than the latest tag
9-
cosmossdk.io/core => cosmossdk.io/core v1.0.0-alpha.2 // main
9+
cosmossdk.io/core => cosmossdk.io/core v1.0.0-alpha.3 // main
1010
// pseudo version lower than the latest tag
1111
cosmossdk.io/store => cosmossdk.io/store v1.0.0-rc.0.0.20240913190136-3bc707a5a214 // main
1212
cosmossdk.io/x/bank => ../../../x/bank
@@ -20,9 +20,9 @@ require (
2020
cosmossdk.io/core v1.0.0 // main
2121
cosmossdk.io/errors v1.0.1
2222
cosmossdk.io/log v1.4.1
23-
cosmossdk.io/server/v2 v2.0.0-20240916221850-7856d226038c // main
24-
cosmossdk.io/server/v2/appmanager v0.0.0-20240916221850-7856d226038c // main
25-
cosmossdk.io/server/v2/stf v0.0.0-20240916221850-7856d226038c // main
23+
cosmossdk.io/server/v2 v2.0.0-20240918153713-01212de2d9dc // main
24+
cosmossdk.io/server/v2/appmanager v0.0.0-20240918153713-01212de2d9dc // main
25+
cosmossdk.io/server/v2/stf v0.0.0-20240918153713-01212de2d9dc // main
2626
cosmossdk.io/store/v2 v2.0.0-20240916221850-7856d226038c // main
2727
cosmossdk.io/x/consensus v0.0.0-00010101000000-000000000000
2828
github.com/cometbft/cometbft v1.0.0-rc1.0.20240908111210-ab0be101882f
@@ -44,7 +44,7 @@ require (
4444
cosmossdk.io/depinject v1.0.0 // indirect
4545
cosmossdk.io/errors/v2 v2.0.0-20240731132947-df72853b3ca5 // indirect
4646
cosmossdk.io/math v1.3.0 // indirect
47-
cosmossdk.io/schema v0.2.0 // indirect
47+
cosmossdk.io/schema v0.3.0 // indirect
4848
cosmossdk.io/store v1.1.1-0.20240909133312-50288938d1b6 // indirect
4949
cosmossdk.io/x/bank v0.0.0-20240226161501-23359a0b6d91 // indirect
5050
cosmossdk.io/x/staking v0.0.0-00010101000000-000000000000 // indirect
@@ -138,7 +138,7 @@ require (
138138
github.com/petermattis/goid v0.0.0-20240813172612-4fcff4a6cae7 // indirect
139139
github.com/pkg/errors v0.9.1 // indirect
140140
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
141-
github.com/prometheus/client_golang v1.20.3 // indirect
141+
github.com/prometheus/client_golang v1.20.4 // indirect
142142
github.com/prometheus/client_model v0.6.1 // indirect
143143
github.com/prometheus/common v0.59.1 // indirect
144144
github.com/prometheus/procfs v0.15.1 // indirect

server/v2/cometbft/go.sum

+12-12
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ cosmossdk.io/api v0.7.3-0.20240815194237-858ec2fcb897 h1:YV9M+9pClbzPncO5XMSc3kI
88
cosmossdk.io/api v0.7.3-0.20240815194237-858ec2fcb897/go.mod h1:oqpDMZQpEgSo0Cm4F+0yxoC9UQbo/SlodZR4zeOqBsE=
99
cosmossdk.io/collections v0.4.1-0.20240802064046-23fac2f1b8ab h1:E/IWad76v1Nc4Atswaccpt7twJ0VwHkbY94/PhmZfTo=
1010
cosmossdk.io/collections v0.4.1-0.20240802064046-23fac2f1b8ab/go.mod h1:Or+5eVAo1aiS1DnPK90eQykGc59LGBWtqwBoJcxXTmw=
11-
cosmossdk.io/core v1.0.0-alpha.2 h1:epU0Xwces4Rgl5bMhHHkXGaGDcyucNGlC/JDH+Suckg=
12-
cosmossdk.io/core v1.0.0-alpha.2/go.mod h1:abgLjeFLhtuKIYZWSPlVUgQBrKObO7ULV35KYfexE90=
11+
cosmossdk.io/core v1.0.0-alpha.3 h1:pnxaYAas7llXgVz1lM7X6De74nWrhNKnB3yMKe4OUUA=
12+
cosmossdk.io/core v1.0.0-alpha.3/go.mod h1:3u9cWq1FAVtiiCrDPpo4LhR+9V6k/ycSG4/Y/tREWCY=
1313
cosmossdk.io/core/testing v0.0.0-20240913164418-aaf72f20c10b h1:uEMbr7Hdpz0fU+GXU6mSN2vgoQnr66WYUpRuiba2aEk=
1414
cosmossdk.io/core/testing v0.0.0-20240913164418-aaf72f20c10b/go.mod h1:FllCSj/ZYskfb982HKqBSISO8DkBY4Euqq768HSFz68=
1515
cosmossdk.io/depinject v1.0.0 h1:dQaTu6+O6askNXO06+jyeUAnF2/ssKwrrszP9t5q050=
@@ -22,14 +22,14 @@ cosmossdk.io/log v1.4.1 h1:wKdjfDRbDyZRuWa8M+9nuvpVYxrEOwbD/CA8hvhU8QM=
2222
cosmossdk.io/log v1.4.1/go.mod h1:k08v0Pyq+gCP6phvdI6RCGhLf/r425UT6Rk/m+o74rU=
2323
cosmossdk.io/math v1.3.0 h1:RC+jryuKeytIiictDslBP9i1fhkVm6ZDmZEoNP316zE=
2424
cosmossdk.io/math v1.3.0/go.mod h1:vnRTxewy+M7BtXBNFybkuhSH4WfedVAAnERHgVFhp3k=
25-
cosmossdk.io/schema v0.2.0 h1:UH5CR1DqUq8yP+5Np8PbvG4YX0zAUsTN2Qk6yThmfMk=
26-
cosmossdk.io/schema v0.2.0/go.mod h1:RDAhxIeNB4bYqAlF4NBJwRrgtnciMcyyg0DOKnhNZQQ=
27-
cosmossdk.io/server/v2 v2.0.0-20240916221850-7856d226038c h1:c2o0xo9h6KPH7UW7wZkFe6QiUhQtdwx4144baCcldnk=
28-
cosmossdk.io/server/v2 v2.0.0-20240916221850-7856d226038c/go.mod h1:soFwwS7N21bYCgN2eNu8TzzxrswZErziVPhooljC8ss=
29-
cosmossdk.io/server/v2/appmanager v0.0.0-20240916221850-7856d226038c h1:M3oQtTg4tuCKPfN/Y5kahyf9q5VORdrup/kWJvaOghs=
30-
cosmossdk.io/server/v2/appmanager v0.0.0-20240916221850-7856d226038c/go.mod h1:qMT4t+uQP/gnfWtA3XTHsDCicXHRyYHxnLyEpRIHVxs=
31-
cosmossdk.io/server/v2/stf v0.0.0-20240916221850-7856d226038c h1:SewCB/kuygcCl9PN6nRSYB5+foshlQ0ycS+eulxFpfI=
32-
cosmossdk.io/server/v2/stf v0.0.0-20240916221850-7856d226038c/go.mod h1:SMSG34ve+IDONgjTXTHxYtx9UVeMdAk3alnxT8xU15I=
25+
cosmossdk.io/schema v0.3.0 h1:01lcaM4trhzZ1HQTfTV8z6Ma1GziOZ/YmdzBN3F720c=
26+
cosmossdk.io/schema v0.3.0/go.mod h1:RDAhxIeNB4bYqAlF4NBJwRrgtnciMcyyg0DOKnhNZQQ=
27+
cosmossdk.io/server/v2 v2.0.0-20240918153713-01212de2d9dc h1:6lX4zEWS3jApSahbytOB0YVgdV4DEPK0pt06227h9Ng=
28+
cosmossdk.io/server/v2 v2.0.0-20240918153713-01212de2d9dc/go.mod h1:OOnpz5j7kFoqr9gSJ4vdM4tq6FXXuJJm7KlikmyTYKk=
29+
cosmossdk.io/server/v2/appmanager v0.0.0-20240918153713-01212de2d9dc h1:eEAmv+489lbcPJ+xWlyRR4CPCSBEYY7jJ7ayHYJwAfM=
30+
cosmossdk.io/server/v2/appmanager v0.0.0-20240918153713-01212de2d9dc/go.mod h1:qMT4t+uQP/gnfWtA3XTHsDCicXHRyYHxnLyEpRIHVxs=
31+
cosmossdk.io/server/v2/stf v0.0.0-20240918153713-01212de2d9dc h1:K7VVR3N2slgDcl+QMZp9LUpsrT1huGIiWoYBndagW/A=
32+
cosmossdk.io/server/v2/stf v0.0.0-20240918153713-01212de2d9dc/go.mod h1:e/pdNHJIOxL1wFKGkERDxLY0chj0+ZIetIPTkRgjX2o=
3333
cosmossdk.io/store v1.0.0-rc.0.0.20240913190136-3bc707a5a214 h1:UUW0+2UgbDwQ452o2aw4DrVSWmowcad7DB7Vln+N94I=
3434
cosmossdk.io/store v1.0.0-rc.0.0.20240913190136-3bc707a5a214/go.mod h1:ct8HATr+s48YYTRXEyP3HF33v9qEVWHMxwOL8P/v4iQ=
3535
cosmossdk.io/store/v2 v2.0.0-20240916221850-7856d226038c h1:x0NX01A+QWckckb1hi9p8mYW4OXTYEzsohQK2qBtIHg=
@@ -423,8 +423,8 @@ github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH
423423
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
424424
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
425425
github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU=
426-
github.com/prometheus/client_golang v1.20.3 h1:oPksm4K8B+Vt35tUhw6GbSNSgVlVSBH0qELP/7u83l4=
427-
github.com/prometheus/client_golang v1.20.3/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
426+
github.com/prometheus/client_golang v1.20.4 h1:Tgh3Yr67PaOv/uTqloMsCEdeuFTatm5zIq5+qNN23vI=
427+
github.com/prometheus/client_golang v1.20.4/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
428428
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
429429
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
430430
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=

server/v2/cometbft/streaming.go

+10-2
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,28 @@ func (c *Consensus[T]) streamDeliverBlockChanges(
2121
// convert txresults to streaming txresults
2222
streamingTxResults := make([]*streaming.ExecTxResult, len(txResults))
2323
for i, txResult := range txResults {
24+
events, err := streaming.IntoStreamingEvents(txResult.Events)
25+
if err != nil {
26+
return err
27+
}
2428
streamingTxResults[i] = &streaming.ExecTxResult{
2529
Code: txResult.Code,
2630
GasWanted: uint64ToInt64(txResult.GasWanted),
2731
GasUsed: uint64ToInt64(txResult.GasUsed),
28-
Events: streaming.IntoStreamingEvents(txResult.Events),
32+
Events: events,
2933
}
3034
}
3135

3236
for _, streamingListener := range c.streaming.Listeners {
37+
events, err := streaming.IntoStreamingEvents(events)
38+
if err != nil {
39+
return err
40+
}
3341
if err := streamingListener.ListenDeliverBlock(ctx, streaming.ListenDeliverBlockRequest{
3442
BlockHeight: height,
3543
Txs: txs,
3644
TxResults: streamingTxResults,
37-
Events: streaming.IntoStreamingEvents(events),
45+
Events: events,
3846
}); err != nil {
3947
c.logger.Error("ListenDeliverBlock listening hook failed", "height", height, "err", err)
4048
}

server/v2/cometbft/utils.go

+33-12
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,19 @@ func finalizeBlockResponse(
7373
) (*abci.FinalizeBlockResponse, error) {
7474
allEvents := append(in.BeginBlockEvents, in.EndBlockEvents...)
7575

76+
events, err := intoABCIEvents(allEvents, indexSet)
77+
if err != nil {
78+
return nil, err
79+
}
80+
81+
txResults, err := intoABCITxResults(in.TxResults, indexSet)
82+
if err != nil {
83+
return nil, err
84+
}
85+
7686
resp := &abci.FinalizeBlockResponse{
77-
Events: intoABCIEvents(allEvents, indexSet),
78-
TxResults: intoABCITxResults(in.TxResults, indexSet),
87+
Events: events,
88+
TxResults: txResults,
7989
ValidatorUpdates: intoABCIValidatorUpdates(in.ValidatorUpdates),
8090
AppHash: appHash,
8191
ConsensusParamUpdates: cp,
@@ -97,7 +107,7 @@ func intoABCIValidatorUpdates(updates []appmodulev2.ValidatorUpdate) []abci.Vali
97107
return valsetUpdates
98108
}
99109

100-
func intoABCITxResults(results []server.TxResult, indexSet map[string]struct{}) []*abci.ExecTxResult {
110+
func intoABCITxResults(results []server.TxResult, indexSet map[string]struct{}) ([]*abci.ExecTxResult, error) {
101111
res := make([]*abci.ExecTxResult, len(results))
102112
for i := range results {
103113
if results[i].Error != nil {
@@ -110,29 +120,36 @@ func intoABCITxResults(results []server.TxResult, indexSet map[string]struct{})
110120

111121
continue
112122
}
113-
123+
events, err := intoABCIEvents(results[i].Events, indexSet)
124+
if err != nil {
125+
return nil, err
126+
}
114127
res[i] = responseExecTxResultWithEvents(
115128
results[i].Error,
116129
results[i].GasWanted,
117130
results[i].GasUsed,
118-
intoABCIEvents(results[i].Events, indexSet),
131+
events,
119132
false,
120133
)
121134
}
122135

123-
return res
136+
return res, nil
124137
}
125138

126-
func intoABCIEvents(events []event.Event, indexSet map[string]struct{}) []abci.Event {
139+
func intoABCIEvents(events []event.Event, indexSet map[string]struct{}) ([]abci.Event, error) {
127140
indexAll := len(indexSet) == 0
128141
abciEvents := make([]abci.Event, len(events))
129142
for i, e := range events {
143+
attributes, err := e.Attributes()
144+
if err != nil {
145+
return nil, err
146+
}
130147
abciEvents[i] = abci.Event{
131148
Type: e.Type,
132-
Attributes: make([]abci.EventAttribute, len(e.Attributes)),
149+
Attributes: make([]abci.EventAttribute, len(attributes)),
133150
}
134151

135-
for j, attr := range e.Attributes {
152+
for j, attr := range attributes {
136153
_, index := indexSet[fmt.Sprintf("%s.%s", e.Type, attr.Key)]
137154
abciEvents[i].Attributes[j] = abci.EventAttribute{
138155
Key: attr.Key,
@@ -141,19 +158,23 @@ func intoABCIEvents(events []event.Event, indexSet map[string]struct{}) []abci.E
141158
}
142159
}
143160
}
144-
return abciEvents
161+
return abciEvents, nil
145162
}
146163

147164
func intoABCISimulationResponse(txRes server.TxResult, indexSet map[string]struct{}) ([]byte, error) {
148165
indexAll := len(indexSet) == 0
149166
abciEvents := make([]abci.Event, len(txRes.Events))
150167
for i, e := range txRes.Events {
168+
attributes, err := e.Attributes()
169+
if err != nil {
170+
return nil, err
171+
}
151172
abciEvents[i] = abci.Event{
152173
Type: e.Type,
153-
Attributes: make([]abci.EventAttribute, len(e.Attributes)),
174+
Attributes: make([]abci.EventAttribute, len(attributes)),
154175
}
155176

156-
for j, attr := range e.Attributes {
177+
for j, attr := range attributes {
157178
_, index := indexSet[fmt.Sprintf("%s.%s", e.Type, attr.Key)]
158179
abciEvents[i].Attributes[j] = abci.EventAttribute{
159180
Key: attr.Key,

simapp/go.mod

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ require (
66
cosmossdk.io/api v0.8.0 // main
77
cosmossdk.io/client/v2 v2.0.0-20230630094428-02b760776860
88
cosmossdk.io/collections v0.4.1-0.20240802064046-23fac2f1b8ab // main
9-
cosmossdk.io/core v1.0.0-alpha.2 // main
9+
cosmossdk.io/core v1.0.0-alpha.3 // main
1010
cosmossdk.io/core/testing v0.0.0-20240913164418-aaf72f20c10b // main
1111
cosmossdk.io/depinject v1.0.0
1212
cosmossdk.io/log v1.4.1
@@ -59,7 +59,7 @@ require (
5959
cloud.google.com/go/iam v1.1.8 // indirect
6060
cloud.google.com/go/storage v1.42.0 // indirect
6161
cosmossdk.io/errors v1.0.1 // indirect
62-
cosmossdk.io/schema v0.2.0 // indirect
62+
cosmossdk.io/schema v0.3.0 // indirect
6363
cosmossdk.io/x/accounts/defaults/multisig v0.0.0-00010101000000-000000000000 // indirect
6464
filippo.io/edwards25519 v1.1.0 // indirect
6565
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect

simapp/go.sum

+4-4
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,8 @@ cosmossdk.io/api v0.7.3-0.20240815194237-858ec2fcb897 h1:YV9M+9pClbzPncO5XMSc3kI
196196
cosmossdk.io/api v0.7.3-0.20240815194237-858ec2fcb897/go.mod h1:oqpDMZQpEgSo0Cm4F+0yxoC9UQbo/SlodZR4zeOqBsE=
197197
cosmossdk.io/collections v0.4.1-0.20240802064046-23fac2f1b8ab h1:E/IWad76v1Nc4Atswaccpt7twJ0VwHkbY94/PhmZfTo=
198198
cosmossdk.io/collections v0.4.1-0.20240802064046-23fac2f1b8ab/go.mod h1:Or+5eVAo1aiS1DnPK90eQykGc59LGBWtqwBoJcxXTmw=
199-
cosmossdk.io/core v1.0.0-alpha.2 h1:epU0Xwces4Rgl5bMhHHkXGaGDcyucNGlC/JDH+Suckg=
200-
cosmossdk.io/core v1.0.0-alpha.2/go.mod h1:abgLjeFLhtuKIYZWSPlVUgQBrKObO7ULV35KYfexE90=
199+
cosmossdk.io/core v1.0.0-alpha.3 h1:pnxaYAas7llXgVz1lM7X6De74nWrhNKnB3yMKe4OUUA=
200+
cosmossdk.io/core v1.0.0-alpha.3/go.mod h1:3u9cWq1FAVtiiCrDPpo4LhR+9V6k/ycSG4/Y/tREWCY=
201201
cosmossdk.io/core/testing v0.0.0-20240913164418-aaf72f20c10b h1:uEMbr7Hdpz0fU+GXU6mSN2vgoQnr66WYUpRuiba2aEk=
202202
cosmossdk.io/core/testing v0.0.0-20240913164418-aaf72f20c10b/go.mod h1:FllCSj/ZYskfb982HKqBSISO8DkBY4Euqq768HSFz68=
203203
cosmossdk.io/depinject v1.0.0 h1:dQaTu6+O6askNXO06+jyeUAnF2/ssKwrrszP9t5q050=
@@ -208,8 +208,8 @@ cosmossdk.io/log v1.4.1 h1:wKdjfDRbDyZRuWa8M+9nuvpVYxrEOwbD/CA8hvhU8QM=
208208
cosmossdk.io/log v1.4.1/go.mod h1:k08v0Pyq+gCP6phvdI6RCGhLf/r425UT6Rk/m+o74rU=
209209
cosmossdk.io/math v1.3.0 h1:RC+jryuKeytIiictDslBP9i1fhkVm6ZDmZEoNP316zE=
210210
cosmossdk.io/math v1.3.0/go.mod h1:vnRTxewy+M7BtXBNFybkuhSH4WfedVAAnERHgVFhp3k=
211-
cosmossdk.io/schema v0.2.0 h1:UH5CR1DqUq8yP+5Np8PbvG4YX0zAUsTN2Qk6yThmfMk=
212-
cosmossdk.io/schema v0.2.0/go.mod h1:RDAhxIeNB4bYqAlF4NBJwRrgtnciMcyyg0DOKnhNZQQ=
211+
cosmossdk.io/schema v0.3.0 h1:01lcaM4trhzZ1HQTfTV8z6Ma1GziOZ/YmdzBN3F720c=
212+
cosmossdk.io/schema v0.3.0/go.mod h1:RDAhxIeNB4bYqAlF4NBJwRrgtnciMcyyg0DOKnhNZQQ=
213213
cosmossdk.io/store v1.0.0-rc.0.0.20240913190136-3bc707a5a214 h1:UUW0+2UgbDwQ452o2aw4DrVSWmowcad7DB7Vln+N94I=
214214
cosmossdk.io/store v1.0.0-rc.0.0.20240913190136-3bc707a5a214/go.mod h1:ct8HATr+s48YYTRXEyP3HF33v9qEVWHMxwOL8P/v4iQ=
215215
cosmossdk.io/x/tx v0.13.4-0.20240918094839-0c8ad9d2c64b h1:FyLcX6eZh9c4FqWla3pXubLIIVlndfQohvf+IcXg99M=

0 commit comments

Comments
 (0)