From 0ebeaebd05cf5818f2fc73ec66706354d4949621 Mon Sep 17 00:00:00 2001 From: yirenz Date: Wed, 28 Aug 2024 10:13:39 -0400 Subject: [PATCH] feat: add wasm contract query gas limit (#1830) * feat: add wasm contract query gas limit add a wasm contract query gas limit to prevent infinite gas attacks * test: update unit tests - add and update unit tests * fix: assign new queryCtx instead of overwriting current tx --------- Co-authored-by: blindchaser --- app/receipt.go | 19 +++- go.mod | 22 ++-- go.sum | 40 +++---- precompiles/distribution/distribution_test.go | 8 +- precompiles/ibc/ibc_test.go | 6 +- proto/evm/params.proto | 1 + x/evm/keeper/params.go | 4 + x/evm/keeper/params_test.go | 1 + x/evm/module_test.go | 2 +- x/evm/types/params.go | 24 ++++- x/evm/types/params.pb.go | 100 ++++++++++++------ x/evm/types/params_test.go | 21 ++++ 12 files changed, 171 insertions(+), 77 deletions(-) diff --git a/app/receipt.go b/app/receipt.go index b9ddef9fc..41c8e4ec9 100644 --- a/app/receipt.go +++ b/app/receipt.go @@ -37,16 +37,21 @@ func (app *App) AddCosmosEventsToEVMReceiptIfApplicable(ctx sdk.Context, tx sdk. return } wasmEvents := GetEventsOfType(response, wasmtypes.WasmModuleEventType) + if len(wasmEvents) == 0 { + return + } logs := []*ethtypes.Log{} + wasmGasLimit := app.EvmKeeper.GetDeliverTxHookWasmGasLimit(ctx) + queryCtx := ctx.WithGasMeter(sdk.NewGasMeterWithMultiplier(ctx, wasmGasLimit)) for _, wasmEvent := range wasmEvents { contractAddr, found := GetAttributeValue(wasmEvent, wasmtypes.AttributeKeyContractAddr) if !found { continue } // check if there is a ERC20 pointer to contractAddr - pointerAddr, _, exists := app.EvmKeeper.GetERC20CW20Pointer(ctx, contractAddr) + pointerAddr, _, exists := app.EvmKeeper.GetERC20CW20Pointer(queryCtx, contractAddr) if exists { - log, eligible := app.translateCW20Event(ctx, wasmEvent, pointerAddr, contractAddr) + log, eligible := app.translateCW20Event(queryCtx, wasmEvent, pointerAddr, contractAddr) if eligible { log.Index = uint(len(logs)) logs = append(logs, log) @@ -54,9 +59,9 @@ func (app *App) AddCosmosEventsToEVMReceiptIfApplicable(ctx sdk.Context, tx sdk. continue } // check if there is a ERC721 pointer to contract Addr - pointerAddr, _, exists = app.EvmKeeper.GetERC721CW721Pointer(ctx, contractAddr) + pointerAddr, _, exists = app.EvmKeeper.GetERC721CW721Pointer(queryCtx, contractAddr) if exists { - log, eligible := app.translateCW721Event(ctx, wasmEvent, pointerAddr, contractAddr) + log, eligible := app.translateCW721Event(queryCtx, wasmEvent, pointerAddr, contractAddr) if eligible { log.Index = uint(len(logs)) logs = append(logs, log) @@ -107,6 +112,12 @@ func (app *App) AddCosmosEventsToEVMReceiptIfApplicable(ctx sdk.Context, tx sdk. } func (app *App) translateCW20Event(ctx sdk.Context, wasmEvent abci.Event, pointerAddr common.Address, contractAddr string) (*ethtypes.Log, bool) { + defer func() { + if r := recover(); r != nil { + fmt.Printf("[Error] Panic caught during translateCW20Event: type=%T, value=%+v\n", r, r) + } + }() + action, found := GetAttributeValue(wasmEvent, "action") if !found { return nil, false diff --git a/go.mod b/go.mod index 4e763cb6c..014d9679d 100644 --- a/go.mod +++ b/go.mod @@ -41,11 +41,11 @@ require ( go.opentelemetry.io/otel v1.9.0 go.opentelemetry.io/otel/trace v1.9.0 golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa - golang.org/x/sync v0.7.0 + golang.org/x/sync v0.8.0 golang.org/x/time v0.3.0 - google.golang.org/genproto/googleapis/api v0.0.0-20240513163218-0867130af1f8 - google.golang.org/grpc v1.64.0 - google.golang.org/protobuf v1.34.1 + google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142 + google.golang.org/grpc v1.64.1 + google.golang.org/protobuf v1.34.2 gopkg.in/yaml.v2 v2.4.0 gopkg.in/yaml.v3 v3.0.1 ) @@ -312,16 +312,16 @@ require ( go.opencensus.io v0.23.0 // indirect go.opentelemetry.io/otel/exporters/jaeger v1.9.0 // indirect go.opentelemetry.io/otel/sdk v1.9.0 // indirect - golang.org/x/crypto v0.23.0 // indirect + golang.org/x/crypto v0.24.0 // indirect golang.org/x/exp/typeparams v0.0.0-20220218215828-6cf2b201936e // indirect golang.org/x/mod v0.17.0 // indirect - golang.org/x/net v0.25.0 // indirect - golang.org/x/sys v0.20.0 // indirect - golang.org/x/term v0.20.0 // indirect - golang.org/x/text v0.15.0 // indirect - golang.org/x/tools v0.21.0 // indirect + golang.org/x/net v0.26.0 // indirect + golang.org/x/sys v0.21.0 // indirect + golang.org/x/term v0.21.0 // indirect + golang.org/x/text v0.17.0 // indirect + golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect google.golang.org/genproto v0.0.0-20240116215550-a9fa1716bcac // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240513163218-0867130af1f8 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect honnef.co/go/tools v0.3.1 // indirect diff --git a/go.sum b/go.sum index 8bdefbce3..1413d1f77 100644 --- a/go.sum +++ b/go.sum @@ -1647,8 +1647,8 @@ golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98y golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc= golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= golang.org/x/crypto v0.15.0/go.mod h1:4ChreQoLWfG3xLDer1WdlH5NdlQ3+mwnQq1YTKY+72g= -golang.org/x/crypto v0.23.0 h1:dIJU/v2J8Mdglj/8rJ6UUOM3Zc9zLZxVZwwxMooUSAI= -golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8= +golang.org/x/crypto v0.24.0 h1:mnl8DM0o513X8fdIkmyFE/5hTYxbwYOjDS/+rK6qpRI= +golang.org/x/crypto v0.24.0/go.mod h1:Z1PMYSOR5nyMcyAVAIQSKCDwalqy85Aqn1x3Ws4L5DM= golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -1788,8 +1788,8 @@ golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk= golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= golang.org/x/net v0.18.0/go.mod h1:/czyP5RqHAH4odGYxBJ1qz0+CE5WZ+2j1YgoEo8F2jQ= -golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac= -golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM= +golang.org/x/net v0.26.0 h1:soB7SVo0PWrY4vPW/+ay0jKDNScG2X9wFeYlXIvJsOQ= +golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE= golang.org/x/oauth2 v0.0.0-20170207211851-4464e7848382/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -1828,8 +1828,8 @@ golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= golang.org/x/sync v0.5.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= -golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= -golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= +golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -1956,8 +1956,8 @@ golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y= -golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws= +golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= @@ -1970,8 +1970,8 @@ golang.org/x/term v0.11.0/go.mod h1:zC9APTIj3jG3FdV/Ons+XE1riIZXG4aZ4GTHiPZJPIU= golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU= golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U= golang.org/x/term v0.14.0/go.mod h1:TySc+nGkYR6qt8km8wUhuFRTVSMIX3XPR58y2lC8vww= -golang.org/x/term v0.20.0 h1:VnkxpohqXaOBYJtBmEppKUG6mXpi+4O6purfc2+sMhw= -golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY= +golang.org/x/term v0.21.0 h1:WVXCp+/EBEHOj53Rvu+7KiT/iElMrO8ACK16SMZ3jaA= +golang.org/x/term v0.21.0/go.mod h1:ooXLefLobQVslOqselCNF4SxFAaoS6KujMbsGzSDmX0= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -1990,8 +1990,8 @@ golang.org/x/text v0.10.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= -golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk= -golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc= +golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -2109,8 +2109,8 @@ golang.org/x/tools v0.2.0/go.mod h1:y4OqIKeOV/fWJetJ8bXPU1sEVniLMIyDAZWeHdV+NTA= golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58= golang.org/x/tools v0.15.0/go.mod h1:hpksKq4dtpQWS1uQ61JkdqWM3LscIS6Slf+VVkm+wQk= -golang.org/x/tools v0.21.0 h1:qc0xYgIbsSDt9EyWz05J5wfa7LOVW0YTLOXrqdLAWIw= -golang.org/x/tools v0.21.0/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk= +golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d h1:vU5i/LfpvrRCpgM/VPfJLg5KjxD3E+hfT1SH+d9zLwg= +golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -2255,10 +2255,10 @@ google.golang.org/genproto v0.0.0-20220324131243-acbaeb5b85eb/go.mod h1:hAL49I2I google.golang.org/genproto v0.0.0-20220407144326-9054f6ed7bac/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= google.golang.org/genproto v0.0.0-20240116215550-a9fa1716bcac h1:ZL/Teoy/ZGnzyrqK/Optxxp2pmVh+fmJ97slxSRyzUg= google.golang.org/genproto v0.0.0-20240116215550-a9fa1716bcac/go.mod h1:+Rvu7ElI+aLzyDQhpHMFMMltsD6m7nqpuWDd2CwJw3k= -google.golang.org/genproto/googleapis/api v0.0.0-20240513163218-0867130af1f8 h1:W5Xj/70xIA4x60O/IFyXivR5MGqblAb8R3w26pnD6No= -google.golang.org/genproto/googleapis/api v0.0.0-20240513163218-0867130af1f8/go.mod h1:vPrPUTsDCYxXWjP7clS81mZ6/803D8K4iM9Ma27VKas= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240513163218-0867130af1f8 h1:mxSlqyb8ZAHsYDCfiXN1EDdNTdvjUJSLY+OnAUtYNYA= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240513163218-0867130af1f8/go.mod h1:I7Y+G38R2bu5j1aLzfFmQfTcU/WnFuqDwLZAbvKTKpM= +google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142 h1:wKguEg1hsxI2/L3hUYrpo1RVi48K+uTyzKqprwLXsb8= +google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142/go.mod h1:d6be+8HhtEtucleCbxpPW9PA9XwISACu8nvpPqF0BVo= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 h1:e7S5W7MGGLaSu8j3YjdezkZ+m1/Nm0uRVRMEMGk26Xs= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU= google.golang.org/grpc v1.33.2 h1:EQyQC3sa8M+p6Ulc8yy9SWSS2GVwyRc83gAbG8lrl4o= google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= @@ -2276,8 +2276,8 @@ google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp0 google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= -google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg= -google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= +google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= +google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/precompiles/distribution/distribution_test.go b/precompiles/distribution/distribution_test.go index 1a7e071d3..19bab661c 100644 --- a/precompiles/distribution/distribution_test.go +++ b/precompiles/distribution/distribution_test.go @@ -148,7 +148,7 @@ func TestWithdraw(t *testing.T) { res, err = msgServer.EVMTransaction(sdk.WrapSDKContext(ctx), req) require.Nil(t, err) require.Empty(t, res.VmError) - require.Equal(t, uint64(68688), res.GasUsed) + require.Equal(t, uint64(69808), res.GasUsed) // reinitialized d, found = testApp.StakingKeeper.GetDelegation(ctx, seiAddr, val) @@ -301,7 +301,7 @@ func setWithdrawAddressAndWithdraw( res, err = msgServer.EVMTransaction(sdk.WrapSDKContext(ctx), r) require.Nil(t, err) require.Empty(t, res.VmError) - require.Equal(t, uint64(152854), res.GasUsed) + require.Equal(t, uint64(153974), res.GasUsed) // reinitialized for _, val := range vals { @@ -1051,7 +1051,7 @@ func TestPrecompile_RunAndCalculateGas_Rewards(t *testing.T) { suppliedGas: uint64(1000000), }, wantRet: emptyCasePackedOutput, - wantRemainingGas: 994313, + wantRemainingGas: 993193, wantErr: false, }, { @@ -1067,7 +1067,7 @@ func TestPrecompile_RunAndCalculateGas_Rewards(t *testing.T) { suppliedGas: uint64(1000000), }, wantRet: happyPathPackedOutput, - wantRemainingGas: 994313, + wantRemainingGas: 993193, wantErr: false, }, } diff --git a/precompiles/ibc/ibc_test.go b/precompiles/ibc/ibc_test.go index feccfb150..b651af746 100644 --- a/precompiles/ibc/ibc_test.go +++ b/precompiles/ibc/ibc_test.go @@ -106,7 +106,7 @@ func TestPrecompile_Run(t *testing.T) { fields: fields{transferKeeper: &MockTransferKeeper{}}, args: commonArgs, wantBz: packedTrue, - wantRemainingGas: 994313, + wantRemainingGas: 993193, wantErr: false, }, { @@ -235,7 +235,7 @@ func TestPrecompile_Run(t *testing.T) { value: nil, }, wantBz: packedTrue, - wantRemainingGas: 994313, + wantRemainingGas: 993193, wantErr: false, }, { @@ -255,7 +255,7 @@ func TestPrecompile_Run(t *testing.T) { value: nil, }, wantBz: packedTrue, - wantRemainingGas: 994313, + wantRemainingGas: 993193, wantErr: false, }, } diff --git a/proto/evm/params.proto b/proto/evm/params.proto index 3f07c1a07..d2497e4b3 100644 --- a/proto/evm/params.proto +++ b/proto/evm/params.proto @@ -32,6 +32,7 @@ string minimum_fee_per_gas = 4 [ (gogoproto.nullable) = false, (gogoproto.jsontag) = "minimum_fee_per_gas" ]; +uint64 deliver_tx_hook_wasm_gas_limit = 5; // ChainConfig chain_config = 5 [(gogoproto.moretags) = "yaml:\"chain_config\"", (gogoproto.nullable) = false]; // string chain_id = 6 [ // (gogoproto.moretags) = "yaml:\"chain_id\"", diff --git a/x/evm/keeper/params.go b/x/evm/keeper/params.go index a70a52d86..951f82d20 100644 --- a/x/evm/keeper/params.go +++ b/x/evm/keeper/params.go @@ -37,6 +37,10 @@ func (k *Keeper) GetMinimumFeePerGas(ctx sdk.Context) sdk.Dec { return k.GetParams(ctx).MinimumFeePerGas } +func (k *Keeper) GetDeliverTxHookWasmGasLimit(ctx sdk.Context) uint64 { + return k.GetParams(ctx).DeliverTxHookWasmGasLimit +} + func (k *Keeper) ChainID(ctx sdk.Context) *big.Int { if k.EthReplayConfig.Enabled || k.EthBlockTestConfig.Enabled { // replay is for eth mainnet so always return 1 diff --git a/x/evm/keeper/params_test.go b/x/evm/keeper/params_test.go index 9a25e26d7..e508d99b0 100644 --- a/x/evm/keeper/params_test.go +++ b/x/evm/keeper/params_test.go @@ -16,6 +16,7 @@ func TestParams(t *testing.T) { require.Equal(t, types.DefaultPriorityNormalizer, k.GetPriorityNormalizer(ctx)) require.Equal(t, types.DefaultBaseFeePerGas, k.GetBaseFeePerGas(ctx)) require.Equal(t, types.DefaultMinFeePerGas, k.GetMinimumFeePerGas(ctx)) + require.Equal(t, types.DefaultDeliverTxHookWasmGasLimit, k.GetDeliverTxHookWasmGasLimit(ctx)) require.Nil(t, k.GetParams(ctx).Validate()) } diff --git a/x/evm/module_test.go b/x/evm/module_test.go index b5bda72dd..181cd0377 100644 --- a/x/evm/module_test.go +++ b/x/evm/module_test.go @@ -53,7 +53,7 @@ func TestModuleExportGenesis(t *testing.T) { module := evm.NewAppModule(nil, k) jsonMsg := module.ExportGenesis(ctx, types.ModuleCdc) jsonStr := string(jsonMsg) - assert.Equal(t, "{\"params\":{\"priority_normalizer\":\"1.000000000000000000\",\"base_fee_per_gas\":\"0.000000000000000000\",\"minimum_fee_per_gas\":\"100000000000.000000000000000000\",\"whitelisted_cw_code_hashes_for_delegate_call\":[]},\"address_associations\":[{\"sei_address\":\"sei17xpfvakm2amg962yls6f84z3kell8c5la4jkdu\",\"eth_address\":\"0x27F7B8B8B5A4e71E8E9aA671f4e4031E3773303F\"}],\"codes\":[],\"states\":[],\"nonces\":[],\"serialized\":[{\"prefix\":\"Fg==\",\"key\":\"AwAC\",\"value\":\"AAAAAAAAAAM=\"},{\"prefix\":\"Fg==\",\"key\":\"BAAG\",\"value\":\"AAAAAAAAAAQ=\"}]}", jsonStr) + assert.Equal(t, "{\"params\":{\"priority_normalizer\":\"1.000000000000000000\",\"base_fee_per_gas\":\"0.000000000000000000\",\"minimum_fee_per_gas\":\"100000000000.000000000000000000\",\"deliver_tx_hook_wasm_gas_limit\":\"300000\",\"whitelisted_cw_code_hashes_for_delegate_call\":[]},\"address_associations\":[{\"sei_address\":\"sei17xpfvakm2amg962yls6f84z3kell8c5la4jkdu\",\"eth_address\":\"0x27F7B8B8B5A4e71E8E9aA671f4e4031E3773303F\"}],\"codes\":[],\"states\":[],\"nonces\":[],\"serialized\":[{\"prefix\":\"Fg==\",\"key\":\"AwAC\",\"value\":\"AAAAAAAAAAM=\"},{\"prefix\":\"Fg==\",\"key\":\"BAAG\",\"value\":\"AAAAAAAAAAQ=\"}]}", jsonStr) } func TestConsensusVersion(t *testing.T) { diff --git a/x/evm/types/params.go b/x/evm/types/params.go index 6e98e3ead..ffb78606d 100644 --- a/x/evm/types/params.go +++ b/x/evm/types/params.go @@ -10,9 +10,10 @@ import ( ) var ( - KeyPriorityNormalizer = []byte("KeyPriorityNormalizer") - KeyBaseFeePerGas = []byte("KeyBaseFeePerGas") - KeyMinFeePerGas = []byte("KeyMinFeePerGas") + KeyPriorityNormalizer = []byte("KeyPriorityNormalizer") + KeyBaseFeePerGas = []byte("KeyBaseFeePerGas") + KeyMinFeePerGas = []byte("KeyMinFeePerGas") + KeyDeliverTxHookWasmGasLimit = []byte("KeyDeliverTxHookWasmGasLimit") // deprecated KeyWhitelistedCwCodeHashesForDelegateCall = []byte("KeyWhitelistedCwCodeHashesForDelegateCall") ) @@ -24,6 +25,7 @@ var DefaultPriorityNormalizer = sdk.NewDec(1) // Ethereum). var DefaultBaseFeePerGas = sdk.NewDec(0) var DefaultMinFeePerGas = sdk.NewDec(100000000000) +var DefaultDeliverTxHookWasmGasLimit = uint64(300000) var DefaultWhitelistedCwCodeHashesForDelegateCall = generateDefaultWhitelistedCwCodeHashesForDelegateCall() @@ -38,6 +40,7 @@ func DefaultParams() Params { PriorityNormalizer: DefaultPriorityNormalizer, BaseFeePerGas: DefaultBaseFeePerGas, MinimumFeePerGas: DefaultMinFeePerGas, + DeliverTxHookWasmGasLimit: DefaultDeliverTxHookWasmGasLimit, WhitelistedCwCodeHashesForDelegateCall: DefaultWhitelistedCwCodeHashesForDelegateCall, } } @@ -47,6 +50,7 @@ func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { paramtypes.NewParamSetPair(KeyPriorityNormalizer, &p.PriorityNormalizer, validatePriorityNormalizer), paramtypes.NewParamSetPair(KeyBaseFeePerGas, &p.BaseFeePerGas, validateBaseFeePerGas), paramtypes.NewParamSetPair(KeyMinFeePerGas, &p.MinimumFeePerGas, validateMinFeePerGas), + paramtypes.NewParamSetPair(KeyDeliverTxHookWasmGasLimit, &p.DeliverTxHookWasmGasLimit, validateDeliverTxHookWasmGasLimit), paramtypes.NewParamSetPair(KeyWhitelistedCwCodeHashesForDelegateCall, &p.WhitelistedCwCodeHashesForDelegateCall, validateWhitelistedCwHashesForDelegateCall), } } @@ -61,6 +65,9 @@ func (p Params) Validate() error { if err := validateMinFeePerGas(p.MinimumFeePerGas); err != nil { return err } + if err := validateDeliverTxHookWasmGasLimit(p.DeliverTxHookWasmGasLimit); err != nil { + return err + } if p.MinimumFeePerGas.LT(p.BaseFeePerGas) { return errors.New("minimum fee cannot be lower than base fee") } @@ -111,6 +118,17 @@ func validateMinFeePerGas(i interface{}) error { return nil } +func validateDeliverTxHookWasmGasLimit(i interface{}) error { + v, ok := i.(uint64) + if !ok { + return fmt.Errorf("invalid parameter type: %T", i) + } + if v == 0 { + return fmt.Errorf("invalid deliver_tx_hook_wasm_gas_limit: must be greater than 0, got %d", v) + } + return nil +} + func validateWhitelistedCwHashesForDelegateCall(i interface{}) error { _, ok := i.([][]byte) if !ok { diff --git a/x/evm/types/params.pb.go b/x/evm/types/params.pb.go index 3f16118ba..8303ff5af 100644 --- a/x/evm/types/params.pb.go +++ b/x/evm/types/params.pb.go @@ -30,9 +30,10 @@ type Params struct { // (gogoproto.moretags) = "yaml:\"base_denom\"", // (gogoproto.jsontag) = "base_denom" // ]; - PriorityNormalizer github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=priority_normalizer,json=priorityNormalizer,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"priority_normalizer" yaml:"priority_normalizer"` - BaseFeePerGas github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=base_fee_per_gas,json=baseFeePerGas,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"base_fee_per_gas" yaml:"base_fee_per_gas"` - MinimumFeePerGas github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,4,opt,name=minimum_fee_per_gas,json=minimumFeePerGas,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"minimum_fee_per_gas" yaml:"minimum_fee_per_gas"` + PriorityNormalizer github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=priority_normalizer,json=priorityNormalizer,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"priority_normalizer" yaml:"priority_normalizer"` + BaseFeePerGas github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=base_fee_per_gas,json=baseFeePerGas,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"base_fee_per_gas" yaml:"base_fee_per_gas"` + MinimumFeePerGas github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,4,opt,name=minimum_fee_per_gas,json=minimumFeePerGas,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"minimum_fee_per_gas" yaml:"minimum_fee_per_gas"` + DeliverTxHookWasmGasLimit uint64 `protobuf:"varint,5,opt,name=deliver_tx_hook_wasm_gas_limit,json=deliverTxHookWasmGasLimit,proto3" json:"deliver_tx_hook_wasm_gas_limit,omitempty"` // ChainConfig chain_config = 5 [(gogoproto.moretags) = "yaml:\"chain_config\"", (gogoproto.nullable) = false]; // string chain_id = 6 [ // (gogoproto.moretags) = "yaml:\"chain_id\"", @@ -79,6 +80,13 @@ func (m *Params) XXX_DiscardUnknown() { var xxx_messageInfo_Params proto.InternalMessageInfo +func (m *Params) GetDeliverTxHookWasmGasLimit() uint64 { + if m != nil { + return m.DeliverTxHookWasmGasLimit + } + return 0 +} + func (m *Params) GetWhitelistedCwCodeHashesForDelegateCall() [][]byte { if m != nil { return m.WhitelistedCwCodeHashesForDelegateCall @@ -93,34 +101,37 @@ func init() { func init() { proto.RegisterFile("evm/params.proto", fileDescriptor_9272f3679901ea94) } var fileDescriptor_9272f3679901ea94 = []byte{ - // 423 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x52, 0x31, 0x6f, 0xd3, 0x40, - 0x18, 0xf5, 0xd1, 0x52, 0x81, 0x05, 0x52, 0xe4, 0x22, 0x61, 0x65, 0xf0, 0x55, 0x1e, 0xaa, 0x0e, - 0xc4, 0x1e, 0xba, 0x75, 0x4c, 0xaa, 0x96, 0x09, 0x55, 0x1e, 0x91, 0xd0, 0xe9, 0x72, 0xfe, 0x62, - 0x9f, 0xb8, 0xf3, 0x59, 0x77, 0x6e, 0x43, 0xf8, 0x01, 0x2c, 0x2c, 0x08, 0x31, 0x30, 0xf2, 0x67, - 0x90, 0x3a, 0x76, 0x44, 0x0c, 0x16, 0x4a, 0xb6, 0x8e, 0xf9, 0x05, 0xc8, 0xe7, 0x94, 0x04, 0xf0, - 0x92, 0x4e, 0xf7, 0xdd, 0x7b, 0xef, 0x7b, 0x7a, 0x7a, 0xfa, 0xdc, 0x1e, 0x5c, 0xc9, 0xb8, 0xa4, - 0x9a, 0x4a, 0x13, 0x95, 0x5a, 0x55, 0xca, 0xf3, 0x0d, 0x70, 0x3b, 0x31, 0x25, 0x22, 0x03, 0x9c, - 0xe5, 0x94, 0x17, 0x11, 0x5c, 0xc9, 0xfe, 0xb3, 0x4c, 0x65, 0xca, 0x52, 0x71, 0x33, 0xb5, 0xfa, - 0xbe, 0x75, 0x60, 0xaa, 0x98, 0xf0, 0xac, 0x45, 0xc2, 0x8f, 0x0f, 0xdd, 0xbd, 0x0b, 0x6b, 0xe9, - 0x7d, 0x41, 0xee, 0x7e, 0xa9, 0xb9, 0xd2, 0xbc, 0x9a, 0x91, 0x42, 0x69, 0x49, 0x05, 0x7f, 0x0f, - 0xda, 0x7f, 0x70, 0x80, 0x8e, 0x1e, 0x0f, 0xd9, 0x75, 0x8d, 0x9d, 0x9f, 0x35, 0x3e, 0xcc, 0x78, - 0x95, 0x5f, 0x8e, 0x23, 0xa6, 0x1a, 0x27, 0x23, 0x95, 0x59, 0x3d, 0x03, 0x93, 0xbe, 0x8d, 0xab, - 0x59, 0x09, 0x26, 0x3a, 0x05, 0x76, 0x5b, 0xe3, 0x2e, 0xb3, 0x65, 0x8d, 0xfb, 0x33, 0x2a, 0xc5, - 0x49, 0xd8, 0x41, 0x86, 0x89, 0x77, 0x87, 0xbe, 0xfa, 0x03, 0x7a, 0x1f, 0x90, 0xdb, 0x1b, 0x53, - 0x03, 0x64, 0x02, 0x40, 0x4a, 0xd0, 0x24, 0xa3, 0xc6, 0xdf, 0xb1, 0x99, 0xde, 0x6c, 0x9d, 0xe9, - 0x3f, 0xa7, 0x65, 0x8d, 0x9f, 0xb7, 0x81, 0xfe, 0x65, 0xc2, 0xe4, 0x69, 0x03, 0x9d, 0x01, 0x5c, - 0x80, 0x3e, 0xa7, 0xc6, 0xfb, 0x8c, 0xdc, 0x7d, 0xc9, 0x0b, 0x2e, 0x2f, 0xe5, 0x5f, 0x59, 0x76, - 0xef, 0xdb, 0x4f, 0x87, 0xd9, 0xba, 0x9f, 0x0e, 0x32, 0x4c, 0x7a, 0x2b, 0x74, 0x1d, 0xea, 0x3b, - 0x72, 0x5f, 0x4c, 0x73, 0x5e, 0x81, 0xe0, 0xa6, 0x82, 0x94, 0xb0, 0x29, 0x61, 0x2a, 0x05, 0x92, - 0x53, 0x93, 0x83, 0x21, 0x13, 0xa5, 0x49, 0x0a, 0x02, 0x32, 0x5a, 0x01, 0x61, 0x54, 0x08, 0xff, - 0xd1, 0xc1, 0xce, 0xd1, 0x93, 0x61, 0x76, 0x5b, 0xe3, 0xad, 0xf6, 0x96, 0x35, 0x3e, 0x6e, 0x83, - 0x6d, 0xb3, 0x15, 0x26, 0x87, 0x1b, 0xf2, 0xd1, 0x74, 0xa4, 0x52, 0x78, 0x69, 0xb5, 0x67, 0x4a, - 0x9f, 0xae, 0x94, 0x23, 0x2a, 0xc4, 0xc9, 0xee, 0xd7, 0x6f, 0xd8, 0x19, 0x9e, 0x5f, 0xcf, 0x03, - 0x74, 0x33, 0x0f, 0xd0, 0xaf, 0x79, 0x80, 0x3e, 0x2d, 0x02, 0xe7, 0x66, 0x11, 0x38, 0x3f, 0x16, - 0x81, 0xf3, 0x7a, 0xb0, 0x51, 0xab, 0x01, 0x3e, 0xb8, 0xbb, 0x7a, 0xfb, 0xb1, 0x67, 0x1f, 0xbf, - 0x8b, 0x9b, 0xeb, 0xb6, 0x0d, 0x8f, 0xf7, 0x2c, 0x7f, 0xfc, 0x3b, 0x00, 0x00, 0xff, 0xff, 0x53, - 0xce, 0xd1, 0xa6, 0x33, 0x03, 0x00, 0x00, + // 472 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x53, 0xcf, 0x8b, 0xd3, 0x40, + 0x14, 0x4e, 0xdc, 0xee, 0xa2, 0x41, 0xa1, 0x64, 0x05, 0x63, 0x0f, 0x49, 0xc9, 0x61, 0xe9, 0xc1, + 0x26, 0x87, 0xbd, 0xed, 0xcd, 0x76, 0xd9, 0xee, 0x41, 0x64, 0x09, 0x82, 0x20, 0xc8, 0x30, 0x4d, + 0x5e, 0x93, 0xa1, 0x33, 0x7d, 0x61, 0x26, 0xdb, 0x1f, 0xfe, 0x01, 0x9e, 0x45, 0x3c, 0x78, 0xf4, + 0x9f, 0x11, 0xf6, 0x24, 0x7b, 0x14, 0x0f, 0x41, 0xda, 0xdb, 0x1e, 0xfb, 0x17, 0x48, 0xa6, 0x5d, + 0xb7, 0x6a, 0x2f, 0xf5, 0x94, 0x97, 0xef, 0xfb, 0xde, 0xc7, 0x37, 0xef, 0xf1, 0xac, 0x3a, 0x8c, + 0x45, 0x98, 0x53, 0x49, 0x85, 0x0a, 0x72, 0x89, 0x05, 0xda, 0x8e, 0x02, 0xa6, 0xab, 0x18, 0x79, + 0xa0, 0x80, 0xc5, 0x19, 0x65, 0xa3, 0x00, 0xc6, 0xa2, 0xf1, 0x38, 0xc5, 0x14, 0x35, 0x15, 0x56, + 0xd5, 0x4a, 0xdf, 0xd0, 0x0e, 0x31, 0x8e, 0x06, 0x2c, 0x5d, 0x21, 0xfe, 0xb7, 0x7d, 0xeb, 0xe0, + 0x42, 0x5b, 0xda, 0x9f, 0x4c, 0xeb, 0x30, 0x97, 0x0c, 0x25, 0x2b, 0x66, 0x64, 0x84, 0x52, 0x50, + 0xce, 0xde, 0x81, 0x74, 0xee, 0x35, 0xcd, 0xd6, 0x83, 0x4e, 0x7c, 0x55, 0x7a, 0xc6, 0x8f, 0xd2, + 0x3b, 0x4a, 0x59, 0x91, 0x5d, 0xf6, 0x83, 0x18, 0x2b, 0x27, 0x25, 0x50, 0xad, 0x3f, 0x6d, 0x95, + 0x0c, 0xc3, 0x62, 0x96, 0x83, 0x0a, 0x4e, 0x21, 0xbe, 0x29, 0xbd, 0x6d, 0x66, 0xcb, 0xd2, 0x6b, + 0xcc, 0xa8, 0xe0, 0x27, 0xfe, 0x16, 0xd2, 0x8f, 0xec, 0x5b, 0xf4, 0xe5, 0x6f, 0xd0, 0x7e, 0x6f, + 0x5a, 0xf5, 0x3e, 0x55, 0x40, 0x06, 0x00, 0x24, 0x07, 0x49, 0x52, 0xaa, 0x9c, 0x3d, 0x9d, 0xe9, + 0xed, 0xce, 0x99, 0xfe, 0x71, 0x5a, 0x96, 0xde, 0x93, 0x55, 0xa0, 0xbf, 0x19, 0x3f, 0x7a, 0x54, + 0x41, 0x67, 0x00, 0x17, 0x20, 0x7b, 0x54, 0xd9, 0x1f, 0x4d, 0xeb, 0x50, 0xb0, 0x11, 0x13, 0x97, + 0xe2, 0x8f, 0x2c, 0xb5, 0xff, 0x9d, 0xcf, 0x16, 0xb3, 0xbb, 0xf9, 0x6c, 0x21, 0xfd, 0xa8, 0xbe, + 0x46, 0xef, 0x42, 0x3d, 0xb7, 0xdc, 0x04, 0x38, 0x1b, 0x83, 0x24, 0xc5, 0x94, 0x64, 0x88, 0x43, + 0x32, 0xa1, 0x4a, 0x54, 0x72, 0xc2, 0x99, 0x60, 0x85, 0xb3, 0xdf, 0x34, 0x5b, 0xb5, 0xe8, 0xe9, + 0x5a, 0xf5, 0x6a, 0x7a, 0x8e, 0x38, 0x7c, 0x4d, 0x95, 0xe8, 0x51, 0xf5, 0xa2, 0x12, 0xd8, 0x5f, + 0x4d, 0xeb, 0xd9, 0x24, 0x63, 0x05, 0x70, 0xa6, 0x0a, 0x48, 0x48, 0x3c, 0x21, 0x31, 0x26, 0x40, + 0x32, 0xaa, 0x32, 0x50, 0x64, 0x80, 0x92, 0x24, 0xc0, 0x21, 0xa5, 0x05, 0x90, 0x98, 0x72, 0xee, + 0xdc, 0x6f, 0xee, 0xb5, 0x1e, 0x76, 0xd2, 0x9b, 0xd2, 0xdb, 0xa9, 0x6f, 0x59, 0x7a, 0xc7, 0xab, + 0xb7, 0xed, 0xd2, 0xe5, 0x47, 0x47, 0x1b, 0xf2, 0xee, 0xa4, 0x8b, 0x09, 0x9c, 0x6b, 0xed, 0x19, + 0xca, 0xd3, 0xb5, 0xb2, 0x4b, 0x39, 0x3f, 0xa9, 0x7d, 0xfe, 0xe2, 0x19, 0x9d, 0xde, 0xd5, 0xdc, + 0x35, 0xaf, 0xe7, 0xae, 0xf9, 0x73, 0xee, 0x9a, 0x1f, 0x16, 0xae, 0x71, 0xbd, 0x70, 0x8d, 0xef, + 0x0b, 0xd7, 0x78, 0xd3, 0xde, 0xd8, 0x8c, 0x02, 0xd6, 0xbe, 0x3d, 0x1c, 0xfd, 0xa3, 0x2f, 0x27, + 0x9c, 0x86, 0xd5, 0x81, 0xe8, 0x25, 0xf5, 0x0f, 0x34, 0x7f, 0xfc, 0x2b, 0x00, 0x00, 0xff, 0xff, + 0x70, 0xe7, 0xb6, 0xa2, 0x76, 0x03, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -152,6 +163,11 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { dAtA[i] = 0x42 } } + if m.DeliverTxHookWasmGasLimit != 0 { + i = encodeVarintParams(dAtA, i, uint64(m.DeliverTxHookWasmGasLimit)) + i-- + dAtA[i] = 0x28 + } { size := m.MinimumFeePerGas.Size() i -= size @@ -208,6 +224,9 @@ func (m *Params) Size() (n int) { n += 1 + l + sovParams(uint64(l)) l = m.MinimumFeePerGas.Size() n += 1 + l + sovParams(uint64(l)) + if m.DeliverTxHookWasmGasLimit != 0 { + n += 1 + sovParams(uint64(m.DeliverTxHookWasmGasLimit)) + } if len(m.WhitelistedCwCodeHashesForDelegateCall) > 0 { for _, b := range m.WhitelistedCwCodeHashesForDelegateCall { l = len(b) @@ -354,6 +373,25 @@ func (m *Params) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field DeliverTxHookWasmGasLimit", wireType) + } + m.DeliverTxHookWasmGasLimit = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.DeliverTxHookWasmGasLimit |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } case 8: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field WhitelistedCwCodeHashesForDelegateCall", wireType) diff --git a/x/evm/types/params_test.go b/x/evm/types/params_test.go index 342e2a2e8..40b7dc911 100644 --- a/x/evm/types/params_test.go +++ b/x/evm/types/params_test.go @@ -14,6 +14,7 @@ func TestDefaultParams(t *testing.T) { PriorityNormalizer: types.DefaultPriorityNormalizer, BaseFeePerGas: types.DefaultBaseFeePerGas, MinimumFeePerGas: types.DefaultMinFeePerGas, + DeliverTxHookWasmGasLimit: types.DefaultDeliverTxHookWasmGasLimit, WhitelistedCwCodeHashesForDelegateCall: types.DefaultWhitelistedCwCodeHashesForDelegateCall, }, types.DefaultParams()) @@ -46,3 +47,23 @@ func TestBaseFeeMinimumFee(t *testing.T) { require.Error(t, err) require.Contains(t, err.Error(), "minimum fee cannot be lower than base fee") } + +func TestValidateParamsInvalidDeliverTxHookWasmGasLimit(t *testing.T) { + params := types.DefaultParams() + params.DeliverTxHookWasmGasLimit = 0 // Set to invalid value (0) + + err := params.Validate() + require.Error(t, err) + require.Contains(t, err.Error(), "invalid deliver_tx_hook_wasm_gas_limit: must be greater than 0") +} + +func TestValidateParamsValidDeliverTxHookWasmGasLimit(t *testing.T) { + params := types.DefaultParams() + + require.Equal(t, params.DeliverTxHookWasmGasLimit, types.DefaultDeliverTxHookWasmGasLimit) + + params.DeliverTxHookWasmGasLimit = 100000 // Set to valid value + + err := params.Validate() + require.NoError(t, err) +}