Skip to content

Commit 01212de

Browse files
feat(server/v2): refactor the server/v2 events (#21785)
1 parent 71d4a08 commit 01212de

Some content is hidden

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

71 files changed

+297
-258
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.7.5
7-
cosmossdk.io/core v1.0.0-alpha.2
7+
cosmossdk.io/core v1.0.0-alpha.3
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
@@ -26,7 +26,7 @@ require (
2626
cosmossdk.io/errors v1.0.1 // indirect
2727
cosmossdk.io/log v1.4.1 // indirect
2828
cosmossdk.io/math v1.3.0
29-
cosmossdk.io/schema v0.2.0 // indirect
29+
cosmossdk.io/schema v0.3.0 // indirect
3030
cosmossdk.io/store v1.1.1-0.20240418092142-896cdf1971bc // indirect
3131
cosmossdk.io/x/staking v0.0.0-00010101000000-000000000000 // indirect
3232
filippo.io/edwards25519 v1.1.0 // indirect

client/v2/go.sum

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMT
66
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
77
cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s=
88
cosmossdk.io/collections v0.4.0/go.mod h1:oa5lUING2dP+gdDquow+QjlF45eL1t4TJDypgGd+tv0=
9-
cosmossdk.io/core v1.0.0-alpha.2 h1:epU0Xwces4Rgl5bMhHHkXGaGDcyucNGlC/JDH+Suckg=
10-
cosmossdk.io/core v1.0.0-alpha.2/go.mod h1:abgLjeFLhtuKIYZWSPlVUgQBrKObO7ULV35KYfexE90=
9+
cosmossdk.io/core v1.0.0-alpha.3 h1:pnxaYAas7llXgVz1lM7X6De74nWrhNKnB3yMKe4OUUA=
10+
cosmossdk.io/core v1.0.0-alpha.3/go.mod h1:3u9cWq1FAVtiiCrDPpo4LhR+9V6k/ycSG4/Y/tREWCY=
1111
cosmossdk.io/depinject v1.0.0 h1:dQaTu6+O6askNXO06+jyeUAnF2/ssKwrrszP9t5q050=
1212
cosmossdk.io/depinject v1.0.0/go.mod h1:zxK/h3HgHoA/eJVtiSsoaRaRA2D5U4cJ5thIG4ssbB8=
1313
cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0=
@@ -16,8 +16,8 @@ cosmossdk.io/log v1.4.1 h1:wKdjfDRbDyZRuWa8M+9nuvpVYxrEOwbD/CA8hvhU8QM=
1616
cosmossdk.io/log v1.4.1/go.mod h1:k08v0Pyq+gCP6phvdI6RCGhLf/r425UT6Rk/m+o74rU=
1717
cosmossdk.io/math v1.3.0 h1:RC+jryuKeytIiictDslBP9i1fhkVm6ZDmZEoNP316zE=
1818
cosmossdk.io/math v1.3.0/go.mod h1:vnRTxewy+M7BtXBNFybkuhSH4WfedVAAnERHgVFhp3k=
19-
cosmossdk.io/schema v0.2.0 h1:UH5CR1DqUq8yP+5Np8PbvG4YX0zAUsTN2Qk6yThmfMk=
20-
cosmossdk.io/schema v0.2.0/go.mod h1:RDAhxIeNB4bYqAlF4NBJwRrgtnciMcyyg0DOKnhNZQQ=
19+
cosmossdk.io/schema v0.3.0 h1:01lcaM4trhzZ1HQTfTV8z6Ma1GziOZ/YmdzBN3F720c=
20+
cosmossdk.io/schema v0.3.0/go.mod h1:RDAhxIeNB4bYqAlF4NBJwRrgtnciMcyyg0DOKnhNZQQ=
2121
cosmossdk.io/x/protocolpool v0.0.0-20230925135524-a1bc045b3190 h1:XQJj9Dv9Gtze0l2TF79BU5lkP6MkUveTUuKICmxoz+o=
2222
cosmossdk.io/x/protocolpool v0.0.0-20230925135524-a1bc045b3190/go.mod h1:7WUGupOvmlHJoIMBz1JbObQxeo6/TDiuDBxmtod8HRg=
2323
filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=

collections/collections.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ type Collection interface {
104104
// decoders and encoders to and from schema values and raw kv-store bytes.
105105
type collectionSchemaCodec struct {
106106
coll Collection
107-
objectType schema.ObjectType
107+
objectType schema.StateObjectType
108108
keyDecoder func([]byte) (any, error)
109109
valueDecoder func([]byte) (any, error)
110110
}

collections/go.mod

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ module cosmossdk.io/collections
33
go 1.23
44

55
require (
6-
cosmossdk.io/core v1.0.0-alpha.2
6+
cosmossdk.io/core v1.0.0-alpha.3
77
cosmossdk.io/core/testing v0.0.0-00010101000000-000000000000
8-
cosmossdk.io/schema v0.2.0
8+
cosmossdk.io/schema v0.3.0
99
github.com/stretchr/testify v1.9.0
1010
github.com/tidwall/btree v1.7.0
1111
pgregory.net/rapid v1.1.0

collections/go.sum

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
cosmossdk.io/core v1.0.0-alpha.2 h1:epU0Xwces4Rgl5bMhHHkXGaGDcyucNGlC/JDH+Suckg=
2-
cosmossdk.io/core v1.0.0-alpha.2/go.mod h1:abgLjeFLhtuKIYZWSPlVUgQBrKObO7ULV35KYfexE90=
3-
cosmossdk.io/schema v0.2.0 h1:UH5CR1DqUq8yP+5Np8PbvG4YX0zAUsTN2Qk6yThmfMk=
4-
cosmossdk.io/schema v0.2.0/go.mod h1:RDAhxIeNB4bYqAlF4NBJwRrgtnciMcyyg0DOKnhNZQQ=
1+
cosmossdk.io/core v1.0.0-alpha.3 h1:pnxaYAas7llXgVz1lM7X6De74nWrhNKnB3yMKe4OUUA=
2+
cosmossdk.io/core v1.0.0-alpha.3/go.mod h1:3u9cWq1FAVtiiCrDPpo4LhR+9V6k/ycSG4/Y/tREWCY=
3+
cosmossdk.io/schema v0.3.0 h1:01lcaM4trhzZ1HQTfTV8z6Ma1GziOZ/YmdzBN3F720c=
4+
cosmossdk.io/schema v0.3.0/go.mod h1:RDAhxIeNB4bYqAlF4NBJwRrgtnciMcyyg0DOKnhNZQQ=
55
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
66
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
77
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=

collections/indexing.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ type moduleDecoder struct {
6767
collectionLookup *btree.Map[string, *collectionSchemaCodec]
6868
}
6969

70-
func (m moduleDecoder) decodeKV(update schema.KVPairUpdate) ([]schema.ObjectUpdate, error) {
70+
func (m moduleDecoder) decodeKV(update schema.KVPairUpdate) ([]schema.StateObjectUpdate, error) {
7171
key := update.Key
7272
ks := string(key)
7373
var cd *collectionSchemaCodec
@@ -87,32 +87,32 @@ func (m moduleDecoder) decodeKV(update schema.KVPairUpdate) ([]schema.ObjectUpda
8787
return cd.decodeKVPair(update)
8888
}
8989

90-
func (c collectionSchemaCodec) decodeKVPair(update schema.KVPairUpdate) ([]schema.ObjectUpdate, error) {
90+
func (c collectionSchemaCodec) decodeKVPair(update schema.KVPairUpdate) ([]schema.StateObjectUpdate, error) {
9191
// strip prefix
9292
key := update.Key
9393
key = key[len(c.coll.GetPrefix()):]
9494

9595
k, err := c.keyDecoder(key)
9696
if err != nil {
97-
return []schema.ObjectUpdate{
97+
return []schema.StateObjectUpdate{
9898
{TypeName: c.coll.GetName()},
9999
}, err
100100
}
101101

102102
if update.Remove {
103-
return []schema.ObjectUpdate{
103+
return []schema.StateObjectUpdate{
104104
{TypeName: c.coll.GetName(), Key: k, Delete: true},
105105
}, nil
106106
}
107107

108108
v, err := c.valueDecoder(update.Value)
109109
if err != nil {
110-
return []schema.ObjectUpdate{
110+
return []schema.StateObjectUpdate{
111111
{TypeName: c.coll.GetName(), Key: k},
112112
}, err
113113
}
114114

115-
return []schema.ObjectUpdate{
115+
return []schema.StateObjectUpdate{
116116
{TypeName: c.coll.GetName(), Key: k, Value: v},
117117
}, nil
118118
}

go.mod

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ module github.com/cosmos/cosmos-sdk
55
require (
66
cosmossdk.io/api v0.7.5
77
cosmossdk.io/collections v0.4.0
8-
cosmossdk.io/core v1.0.0-alpha.2
8+
cosmossdk.io/core v1.0.0-alpha.3
99
cosmossdk.io/core/testing v0.0.0-00010101000000-000000000000
1010
cosmossdk.io/depinject v1.0.0
1111
cosmossdk.io/errors v1.0.1
1212
cosmossdk.io/log v1.4.1
1313
cosmossdk.io/math v1.3.0
14-
cosmossdk.io/schema v0.2.0
14+
cosmossdk.io/schema v0.3.0
1515
cosmossdk.io/store v1.1.1-0.20240418092142-896cdf1971bc
1616
cosmossdk.io/x/bank v0.0.0-20240226161501-23359a0b6d91
1717
cosmossdk.io/x/staking v0.0.0-00010101000000-000000000000

go.sum

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88e
44
buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2/go.mod h1:HqcXMSa5qnNuakaMUo+hWhF51mKbcrZxGl9Vp5EeJXc=
55
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
66
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
7-
cosmossdk.io/core v1.0.0-alpha.2 h1:epU0Xwces4Rgl5bMhHHkXGaGDcyucNGlC/JDH+Suckg=
8-
cosmossdk.io/core v1.0.0-alpha.2/go.mod h1:abgLjeFLhtuKIYZWSPlVUgQBrKObO7ULV35KYfexE90=
7+
cosmossdk.io/core v1.0.0-alpha.3 h1:pnxaYAas7llXgVz1lM7X6De74nWrhNKnB3yMKe4OUUA=
8+
cosmossdk.io/core v1.0.0-alpha.3/go.mod h1:3u9cWq1FAVtiiCrDPpo4LhR+9V6k/ycSG4/Y/tREWCY=
99
cosmossdk.io/depinject v1.0.0 h1:dQaTu6+O6askNXO06+jyeUAnF2/ssKwrrszP9t5q050=
1010
cosmossdk.io/depinject v1.0.0/go.mod h1:zxK/h3HgHoA/eJVtiSsoaRaRA2D5U4cJ5thIG4ssbB8=
1111
cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0=
@@ -14,8 +14,8 @@ cosmossdk.io/log v1.4.1 h1:wKdjfDRbDyZRuWa8M+9nuvpVYxrEOwbD/CA8hvhU8QM=
1414
cosmossdk.io/log v1.4.1/go.mod h1:k08v0Pyq+gCP6phvdI6RCGhLf/r425UT6Rk/m+o74rU=
1515
cosmossdk.io/math v1.3.0 h1:RC+jryuKeytIiictDslBP9i1fhkVm6ZDmZEoNP316zE=
1616
cosmossdk.io/math v1.3.0/go.mod h1:vnRTxewy+M7BtXBNFybkuhSH4WfedVAAnERHgVFhp3k=
17-
cosmossdk.io/schema v0.2.0 h1:UH5CR1DqUq8yP+5Np8PbvG4YX0zAUsTN2Qk6yThmfMk=
18-
cosmossdk.io/schema v0.2.0/go.mod h1:RDAhxIeNB4bYqAlF4NBJwRrgtnciMcyyg0DOKnhNZQQ=
17+
cosmossdk.io/schema v0.3.0 h1:01lcaM4trhzZ1HQTfTV8z6Ma1GziOZ/YmdzBN3F720c=
18+
cosmossdk.io/schema v0.3.0/go.mod h1:RDAhxIeNB4bYqAlF4NBJwRrgtnciMcyyg0DOKnhNZQQ=
1919
filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
2020
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
2121
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 h1:/vQbFIOMbk2FiG/kXiLl8BRyzTWDw7gX/Hz7Dd5eDMs=

runtime/v2/go.mod

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ replace (
1414

1515
require (
1616
cosmossdk.io/api v0.7.5
17-
cosmossdk.io/core v1.0.0-alpha.2
17+
cosmossdk.io/core v1.0.0-alpha.3
1818
cosmossdk.io/depinject v1.0.0
1919
cosmossdk.io/log v1.4.1
2020
cosmossdk.io/server/v2/appmanager v0.0.0-00010101000000-000000000000
@@ -31,6 +31,7 @@ require (
3131
buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 // indirect
3232
cosmossdk.io/core/testing v0.0.0-00010101000000-000000000000 // indirect
3333
cosmossdk.io/errors/v2 v2.0.0-20240731132947-df72853b3ca5 // indirect
34+
cosmossdk.io/schema v0.3.0 // indirect
3435
github.com/DataDog/zstd v1.5.5 // indirect
3536
github.com/beorn7/perks v1.0.1 // indirect
3637
github.com/cespare/xxhash/v2 v2.3.0 // indirect

runtime/v2/go.sum

+4-2
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@ buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fed
22
buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2/go.mod h1:1+3gJj2NvZ1mTLAtHu+lMhOjGgQPiCKCeo+9MBww0Eo=
33
buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 h1:b7EEYTUHmWSBEyISHlHvXbJPqtKiHRuUignL1tsHnNQ=
44
buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2/go.mod h1:HqcXMSa5qnNuakaMUo+hWhF51mKbcrZxGl9Vp5EeJXc=
5-
cosmossdk.io/core v1.0.0-alpha.2 h1:epU0Xwces4Rgl5bMhHHkXGaGDcyucNGlC/JDH+Suckg=
6-
cosmossdk.io/core v1.0.0-alpha.2/go.mod h1:abgLjeFLhtuKIYZWSPlVUgQBrKObO7ULV35KYfexE90=
5+
cosmossdk.io/core v1.0.0-alpha.3 h1:pnxaYAas7llXgVz1lM7X6De74nWrhNKnB3yMKe4OUUA=
6+
cosmossdk.io/core v1.0.0-alpha.3/go.mod h1:3u9cWq1FAVtiiCrDPpo4LhR+9V6k/ycSG4/Y/tREWCY=
77
cosmossdk.io/depinject v1.0.0 h1:dQaTu6+O6askNXO06+jyeUAnF2/ssKwrrszP9t5q050=
88
cosmossdk.io/depinject v1.0.0/go.mod h1:zxK/h3HgHoA/eJVtiSsoaRaRA2D5U4cJ5thIG4ssbB8=
99
cosmossdk.io/errors/v2 v2.0.0-20240731132947-df72853b3ca5 h1:IQNdY2kB+k+1OM2DvqFG1+UgeU1JzZrWtwuWzI3ZfwA=
1010
cosmossdk.io/errors/v2 v2.0.0-20240731132947-df72853b3ca5/go.mod h1:0CuYKkFHxc1vw2JC+t21THBCALJVROrWVR/3PQ1urpc=
1111
cosmossdk.io/log v1.4.1 h1:wKdjfDRbDyZRuWa8M+9nuvpVYxrEOwbD/CA8hvhU8QM=
1212
cosmossdk.io/log v1.4.1/go.mod h1:k08v0Pyq+gCP6phvdI6RCGhLf/r425UT6Rk/m+o74rU=
13+
cosmossdk.io/schema v0.3.0 h1:01lcaM4trhzZ1HQTfTV8z6Ma1GziOZ/YmdzBN3F720c=
14+
cosmossdk.io/schema v0.3.0/go.mod h1:RDAhxIeNB4bYqAlF4NBJwRrgtnciMcyyg0DOKnhNZQQ=
1315
github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ=
1416
github.com/DataDog/zstd v1.5.5 h1:oWf5W7GtOLgp6bciQYDmhHHjdhYkALu6S/5Ni9ZgSvQ=
1517
github.com/DataDog/zstd v1.5.5/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw=

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ replace (
1919

2020
require (
2121
cosmossdk.io/api v0.7.5
22-
cosmossdk.io/core v1.0.0-alpha.2
22+
cosmossdk.io/core v1.0.0-alpha.3
2323
cosmossdk.io/errors v1.0.1
2424
cosmossdk.io/log v1.4.1
2525
cosmossdk.io/server/v2 v2.0.0-00010101000000-000000000000
@@ -46,7 +46,7 @@ require (
4646
cosmossdk.io/depinject v1.0.0 // indirect
4747
cosmossdk.io/errors/v2 v2.0.0-20240731132947-df72853b3ca5 // indirect
4848
cosmossdk.io/math v1.3.0 // indirect
49-
cosmossdk.io/schema v0.2.0 // indirect
49+
cosmossdk.io/schema v0.3.0 // indirect
5050
cosmossdk.io/store v1.1.1-0.20240418092142-896cdf1971bc // indirect
5151
cosmossdk.io/x/bank v0.0.0-20240226161501-23359a0b6d91 // indirect
5252
cosmossdk.io/x/staking v0.0.0-00010101000000-000000000000 // indirect

server/v2/cometbft/go.sum

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMT
66
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
77
cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s=
88
cosmossdk.io/collections v0.4.0/go.mod h1:oa5lUING2dP+gdDquow+QjlF45eL1t4TJDypgGd+tv0=
9-
cosmossdk.io/core v1.0.0-alpha.2 h1:epU0Xwces4Rgl5bMhHHkXGaGDcyucNGlC/JDH+Suckg=
10-
cosmossdk.io/core v1.0.0-alpha.2/go.mod h1:abgLjeFLhtuKIYZWSPlVUgQBrKObO7ULV35KYfexE90=
9+
cosmossdk.io/core v1.0.0-alpha.3 h1:pnxaYAas7llXgVz1lM7X6De74nWrhNKnB3yMKe4OUUA=
10+
cosmossdk.io/core v1.0.0-alpha.3/go.mod h1:3u9cWq1FAVtiiCrDPpo4LhR+9V6k/ycSG4/Y/tREWCY=
1111
cosmossdk.io/depinject v1.0.0 h1:dQaTu6+O6askNXO06+jyeUAnF2/ssKwrrszP9t5q050=
1212
cosmossdk.io/depinject v1.0.0/go.mod h1:zxK/h3HgHoA/eJVtiSsoaRaRA2D5U4cJ5thIG4ssbB8=
1313
cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0=
@@ -18,8 +18,8 @@ cosmossdk.io/log v1.4.1 h1:wKdjfDRbDyZRuWa8M+9nuvpVYxrEOwbD/CA8hvhU8QM=
1818
cosmossdk.io/log v1.4.1/go.mod h1:k08v0Pyq+gCP6phvdI6RCGhLf/r425UT6Rk/m+o74rU=
1919
cosmossdk.io/math v1.3.0 h1:RC+jryuKeytIiictDslBP9i1fhkVm6ZDmZEoNP316zE=
2020
cosmossdk.io/math v1.3.0/go.mod h1:vnRTxewy+M7BtXBNFybkuhSH4WfedVAAnERHgVFhp3k=
21-
cosmossdk.io/schema v0.2.0 h1:UH5CR1DqUq8yP+5Np8PbvG4YX0zAUsTN2Qk6yThmfMk=
22-
cosmossdk.io/schema v0.2.0/go.mod h1:RDAhxIeNB4bYqAlF4NBJwRrgtnciMcyyg0DOKnhNZQQ=
21+
cosmossdk.io/schema v0.3.0 h1:01lcaM4trhzZ1HQTfTV8z6Ma1GziOZ/YmdzBN3F720c=
22+
cosmossdk.io/schema v0.3.0/go.mod h1:RDAhxIeNB4bYqAlF4NBJwRrgtnciMcyyg0DOKnhNZQQ=
2323
filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
2424
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
2525
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 h1:/vQbFIOMbk2FiG/kXiLl8BRyzTWDw7gX/Hz7Dd5eDMs=

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,

0 commit comments

Comments
 (0)