Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: max-event-size config to limit size of events stored #614

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
clean up
  • Loading branch information
czarcas7ic committed Jun 17, 2024
commit 57a2d27d695b6944b893c4c1986d0dde355d46a4
3 changes: 0 additions & 3 deletions baseapp/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -412,12 +412,9 @@ func (app *BaseApp) DeliverTx(req abci.RequestDeliverTx) (res abci.ResponseDeliv
return sdkerrors.ResponseDeliverTxWithEvents(err, gInfo.GasWanted, gInfo.GasUsed, sdk.MarkEventsToIndex(anteEvents, app.indexEvents), app.trace)
}

fmt.Println("DeliverTx")
if sdk.MaxEventSize > 0 {
fmt.Println("sdk.MaxEventSize > 0", sdk.MaxEventSize)
for i, event := range result.Events {
for j, attr := range event.Attributes {
fmt.Println("lengths", len([]byte(attr.Key)), len([]byte(attr.Value)))
if len([]byte(attr.Key))+len([]byte(attr.Value)) > sdk.MaxEventSize {
result.Events[i].Attributes[j].Value = "evt val too large, inc max-event-size in config.toml"
}
Expand Down
4 changes: 3 additions & 1 deletion server/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ type BaseConfig struct {
// An empty string indicates that the Tendermint config's DBBackend value should be used.
AppDBBackend string `mapstructure:"app-db-backend"`

// MaxEventSize defines the maximum size of an attribute (key + value) of an event that will be stored in the block results.
// If an attribute is larger than this size, it will be replaced with a placeholder in the block results.
MaxEventSize int `mapstructure:"max-event-size" json:"max-event-size"`
}

Expand Down Expand Up @@ -318,7 +320,7 @@ func DefaultConfig() *Config {
IAVLFastNodeModuleWhitelist: []string{"lockup"},
IAVLLazyLoading: false,
AppDBBackend: "",
MaxEventSize: 0,
MaxEventSize: 1000000, // 1MB
},
Telemetry: telemetry.Config{
Enabled: false,
Expand Down
3 changes: 2 additions & 1 deletion server/config/toml.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ iavl-lazy-loading = {{ .BaseConfig.IAVLLazyLoading }}
# The fallback is the db_backend value set in Tendermint's config.toml.
app-db-backend = "{{ .BaseConfig.AppDBBackend }}"

# Maximum event size in bytes. 0 means no limit
# Maximum event size in bytes that is stored in the block results. 0 means no limit
# If an attribute of an event is larger than the max size, the attribute will be replaced with a placeholder.
max-event-size = {{ .BaseConfig.MaxEventSize }}

###############################################################################
Expand Down
Loading