diff --git a/go.mod b/go.mod index 03ff851845..e2e05f8440 100644 --- a/go.mod +++ b/go.mod @@ -94,7 +94,6 @@ require ( github.com/firefart/nonamedreturns v1.0.1 // indirect github.com/fsnotify/fsnotify v1.5.4 // indirect github.com/fzipp/gocyclo v0.5.1 // indirect - github.com/ghodss/yaml v1.0.0 // indirect github.com/gin-gonic/gin v1.7.7 // indirect github.com/go-critic/go-critic v0.6.3 // indirect github.com/go-kit/kit v0.12.0 // indirect @@ -142,7 +141,6 @@ require ( github.com/gostaticanalysis/nilerr v0.1.1 // indirect github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 // indirect github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect - github.com/grpc-ecosystem/grpc-gateway/v2 v2.14.0 // indirect github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c // indirect github.com/hashicorp/errwrap v1.0.0 // indirect github.com/hashicorp/go-immutable-radix v1.3.1 // indirect @@ -209,7 +207,6 @@ require ( github.com/quasilyte/stdinfo v0.0.0-20220114132959-f7386bf02567 // indirect github.com/rakyll/statik v0.1.7 // indirect github.com/regen-network/cosmos-proto v0.3.1 // indirect - github.com/rogpeppe/go-internal v1.8.1 // indirect github.com/rs/xid v1.3.0 // indirect github.com/ryancurrah/gomodguard v1.2.3 // indirect github.com/ryanrolds/sqlclosecheck v0.3.0 // indirect diff --git a/go.sum b/go.sum index 93c94015e0..711969871d 100644 --- a/go.sum +++ b/go.sum @@ -406,8 +406,6 @@ github.com/fullstorydev/grpcurl v1.6.0/go.mod h1:ZQ+ayqbKMJNhzLmbpCiurTVlaK2M/3n github.com/fzipp/gocyclo v0.5.1 h1:L66amyuYogbxl0j2U+vGqJXusPF2IkduvXLnYD5TFgw= github.com/fzipp/gocyclo v0.5.1/go.mod h1:rXPyn8fnlpa0R2csP/31uerbiVBugk5whMdlyaLkLoA= github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff/go.mod h1:x7DCsMOv1taUwEWCzT4cmDeAkigA5/QCwUodaVOe8Ww= -github.com/ghemawat/stream v0.0.0-20171120220530-696b145b53b9/go.mod h1:106OIgooyS7OzLDOpUGgm9fA3bQENb/cFSyyBmMoJDs= -github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= @@ -681,8 +679,6 @@ github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t github.com/grpc-ecosystem/grpc-gateway v1.12.1/go.mod h1:8XEsbTttt/W+VvjtQhLACqCisSPWTxCZ7sBRjU6iH9c= github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo= github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.14.0 h1:t7uX3JBHdVwAi3G7sSSdbsk8NfgA+LnUS88V/2EKaA0= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.14.0/go.mod h1:4OGVnY4qf2+gw+ssiHbW+pq4mo2yko94YxxMmXZ7jCA= github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c h1:6rhixN/i8ZofjG1Y75iExal34USq5p+wiN1tpie8IrU= github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c/go.mod h1:NMPJylDgVpX0MLRlPy15sqSwOFv/U1GZ2m21JhFfek0= github.com/hashicorp/consul/api v1.3.0/go.mod h1:MmDNSzIMUjNpY/mQ398R4bk2FnqQLoPndWW5VkKPlCE= diff --git a/proto/dex/params.proto b/proto/dex/params.proto index ff44257e54..16702db522 100644 --- a/proto/dex/params.proto +++ b/proto/dex/params.proto @@ -19,4 +19,12 @@ message Params { (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false ]; + uint64 begin_block_gas_limit = 3 [ + (gogoproto.jsontag) = "begin_block_gas_limit", + (gogoproto.moretags) = "yaml:\"begin_block_gas_limit\"" + ]; + uint64 end_block_gas_limit = 4 [ + (gogoproto.jsontag) = "end_block_gas_limit", + (gogoproto.moretags) = "yaml:\"end_block_gas_limit\"" + ]; } diff --git a/x/dex/contract/abci.go b/x/dex/contract/abci.go index 5b06fdf917..700d7ec2ef 100644 --- a/x/dex/contract/abci.go +++ b/x/dex/contract/abci.go @@ -42,7 +42,7 @@ func EndBlockerAtomic(ctx sdk.Context, keeper *keeper.Keeper, validContractsInfo spanCtx, span := (*tracer).Start(tracingInfo.TracerContext, "DexEndBlockerAtomic") defer span.End() env := newEnv(ctx, validContractsInfo, keeper) - cachedCtx, msCached := cacheAndDecorateContext(ctx, env) + cachedCtx, msCached := cacheAndDecorateContext(ctx, env, keeper.GetParams(ctx).EndBlockGasLimit) memStateCopy := dexutils.GetMemState(cachedCtx.Context()).DeepCopy() handleDeposits(cachedCtx, env, keeper, tracer) @@ -99,11 +99,11 @@ func newEnv(ctx sdk.Context, validContractsInfo []types.ContractInfoV2, keeper * } } -func cacheAndDecorateContext(ctx sdk.Context, env *environment) (sdk.Context, sdk.CacheMultiStore) { +func cacheAndDecorateContext(ctx sdk.Context, env *environment, gasLimit uint64) (sdk.Context, sdk.CacheMultiStore) { cachedCtx, msCached := store.GetCachedContext(ctx) goCtx := context.WithValue(cachedCtx.Context(), dexcache.CtxKeyExecTermSignal, env.executionTerminationSignals) cachedCtx = cachedCtx.WithContext(goCtx) - decoratedCtx := cachedCtx.WithGasMeter(seisync.NewGasWrapper(sdk.NewInfiniteGasMeter())).WithBlockGasMeter( + decoratedCtx := cachedCtx.WithGasMeter(seisync.NewGasWrapper(dexutils.GetGasMeterForLimit(gasLimit))).WithBlockGasMeter( seisync.NewGasWrapper(cachedCtx.BlockGasMeter()), ) return decoratedCtx, msCached diff --git a/x/dex/module.go b/x/dex/module.go index 4c1208d96f..fcee854a9b 100644 --- a/x/dex/module.go +++ b/x/dex/module.go @@ -30,6 +30,7 @@ import ( "github.com/sei-protocol/sei-chain/x/dex/migrations" "github.com/sei-protocol/sei-chain/x/dex/types" dexutils "github.com/sei-protocol/sei-chain/x/dex/utils" + "github.com/sei-protocol/sei-chain/x/store" ) var ( @@ -229,9 +230,13 @@ func (am AppModule) BeginBlock(ctx sdk.Context, _ abci.RequestBeginBlock) { if isNewEpoch { am.keeper.SetEpoch(ctx, currentEpoch) } + cachedCtx, cachedStore := store.GetCachedContext(ctx) + cachedCtx = cachedCtx.WithGasMeter(dexutils.GetGasMeterForLimit(am.keeper.GetParams(ctx).BeginBlockGasLimit)) for _, contract := range am.getAllContractInfo(ctx) { - am.beginBlockForContract(ctx, contract, int64(currentEpoch)) + am.beginBlockForContract(cachedCtx, contract, int64(currentEpoch)) } + // only write if all contracts have been processed + cachedStore.Write() } func (am AppModule) beginBlockForContract(ctx sdk.Context, contract types.ContractInfoV2, epoch int64) { diff --git a/x/dex/types/params.go b/x/dex/types/params.go index 8120682e8f..ebebcf0525 100644 --- a/x/dex/types/params.go +++ b/x/dex/types/params.go @@ -11,10 +11,14 @@ import ( var ( KeyPriceSnapshotRetention = []byte("PriceSnapshotRetention") // number of epochs to retain price snapshots for KeySudoCallGasPrice = []byte("KeySudoCallGasPrice") // gas price for sudo calls from endblock + KeyBeginBlockGasLimit = []byte("KeyBeginBlockGasLimit") + KeyEndBlockGasLimit = []byte("KeyEndBlockGasLimit") ) const ( - DefaultPriceSnapshotRetention = 24 * 3600 // default to one day + DefaultPriceSnapshotRetention = 24 * 3600 // default to one day + DefaultBeginBlockGasLimit = 200000000 // 200M + DefaultEndBlockGasLimit = 1000000000 // 1B ) var DefaultSudoCallGasPrice = sdk.ZeroDec() // 0 @@ -36,6 +40,8 @@ func DefaultParams() Params { return Params{ PriceSnapshotRetention: DefaultPriceSnapshotRetention, SudoCallGasPrice: DefaultSudoCallGasPrice, + BeginBlockGasLimit: DefaultBeginBlockGasLimit, + EndBlockGasLimit: DefaultEndBlockGasLimit, } } @@ -44,6 +50,8 @@ func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { return paramtypes.ParamSetPairs{ paramtypes.NewParamSetPair(KeyPriceSnapshotRetention, &p.PriceSnapshotRetention, validatePriceSnapshotRetention), paramtypes.NewParamSetPair(KeySudoCallGasPrice, &p.SudoCallGasPrice, validateSudoCallGasPrice), + paramtypes.NewParamSetPair(KeyBeginBlockGasLimit, &p.BeginBlockGasLimit, validateBeginBlockGasLimit), + paramtypes.NewParamSetPair(KeyEndBlockGasLimit, &p.EndBlockGasLimit, validateEndBlockGasLimit), } } @@ -74,3 +82,21 @@ func validatePriceSnapshotRetention(i interface{}) error { func validateSudoCallGasPrice(i interface{}) error { return nil } + +func validateBeginBlockGasLimit(i interface{}) error { + _, ok := i.(uint64) + if !ok { + return fmt.Errorf("invalid parameter type: %T", i) + } + + return nil +} + +func validateEndBlockGasLimit(i interface{}) error { + _, ok := i.(uint64) + if !ok { + return fmt.Errorf("invalid parameter type: %T", i) + } + + return nil +} diff --git a/x/dex/types/params.pb.go b/x/dex/types/params.pb.go index 35befdc34a..cdc006aca4 100644 --- a/x/dex/types/params.pb.go +++ b/x/dex/types/params.pb.go @@ -28,6 +28,8 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type Params struct { PriceSnapshotRetention uint64 `protobuf:"varint,1,opt,name=price_snapshot_retention,json=priceSnapshotRetention,proto3" json:"price_snapshot_retention" yaml:"price_snapshot_retention"` SudoCallGasPrice github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=sudo_call_gas_price,json=sudoCallGasPrice,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"sudo_call_gas_price"` + BeginBlockGasLimit uint64 `protobuf:"varint,3,opt,name=begin_block_gas_limit,json=beginBlockGasLimit,proto3" json:"begin_block_gas_limit" yaml:"begin_block_gas_limit"` + EndBlockGasLimit uint64 `protobuf:"varint,4,opt,name=end_block_gas_limit,json=endBlockGasLimit,proto3" json:"end_block_gas_limit" yaml:"end_block_gas_limit"` } func (m *Params) Reset() { *m = Params{} } @@ -69,6 +71,20 @@ func (m *Params) GetPriceSnapshotRetention() uint64 { return 0 } +func (m *Params) GetBeginBlockGasLimit() uint64 { + if m != nil { + return m.BeginBlockGasLimit + } + return 0 +} + +func (m *Params) GetEndBlockGasLimit() uint64 { + if m != nil { + return m.EndBlockGasLimit + } + return 0 +} + func init() { proto.RegisterType((*Params)(nil), "seiprotocol.seichain.dex.Params") } @@ -76,26 +92,31 @@ func init() { func init() { proto.RegisterFile("dex/params.proto", fileDescriptor_e49286500ccff43e) } var fileDescriptor_e49286500ccff43e = []byte{ - // 303 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x91, 0x31, 0x4b, 0xc3, 0x40, - 0x14, 0xc7, 0x73, 0x45, 0x8a, 0x66, 0x2a, 0x55, 0x24, 0x38, 0xdc, 0x95, 0x0e, 0xd2, 0xa5, 0xb9, - 0xc1, 0xad, 0x8b, 0x50, 0x95, 0xae, 0xa5, 0x6e, 0x2e, 0xe1, 0x7a, 0x39, 0x92, 0xc3, 0x4b, 0x2e, - 0xe4, 0x5d, 0x21, 0x99, 0xfd, 0x02, 0x8e, 0x8e, 0xfd, 0x38, 0x1d, 0x3b, 0x8a, 0x43, 0x90, 0x64, - 0x91, 0x8e, 0x7e, 0x02, 0xc9, 0xd9, 0x82, 0x83, 0x9d, 0xee, 0xdd, 0xfb, 0xfd, 0x78, 0x0f, 0xf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x76, 0xde, 0x1b, 0xec, 0x3c, 0x8d, 0xff, 0x2c, 0x05, - 0x21, 0xc7, 0x87, 0x6c, 0xed, 0xc7, 0x86, 0x4b, 0x0b, 0xda, 0x5e, 0xc1, 0xee, 0x5f, 0x76, 0x2d, - 0xbf, 0xf9, 0x09, 0x00, 0x00, 0xff, 0xff, 0x19, 0xbd, 0xa8, 0x1c, 0x99, 0x01, 0x00, 0x00, + // 381 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x92, 0x31, 0x6b, 0xfa, 0x40, + 0x18, 0xc6, 0x93, 0xbf, 0x22, 0xff, 0x66, 0x92, 0xd8, 0x96, 0x20, 0x25, 0x27, 0x19, 0x8a, 0x8b, + 0xc9, 0x50, 0x3a, 0xd4, 0xa5, 0x90, 0xb6, 0xb8, 0x74, 0x90, 0x74, 0xeb, 0x12, 0x2e, 0x97, 0x23, + 0x1e, 0x5e, 0x72, 0x21, 0x77, 0x82, 0x7e, 0x8b, 0x8e, 0x1d, 0xfd, 0x38, 0x8e, 0x6e, 0x2d, 0x1d, + 0x8e, 0xa2, 0x4b, 0x71, 0xf4, 0x13, 0x94, 0x9c, 0x0a, 0x2d, 0x8d, 0x53, 0xde, 0x3c, 0xbf, 0x87, + 0xf7, 0xb9, 0xf7, 0xe5, 0x35, 0x9a, 0x31, 0x9e, 0x7a, 0x39, 0x2c, 0x60, 0xca, 0xdd, 0xbc, 0x60, + 0x82, 0x99, 0x16, 0xc7, 0x44, 0x55, 0x88, 0x51, 0x97, 0x63, 0x82, 0x46, 0x90, 0x64, 0x6e, 0x8c, + 0xa7, 0xed, 0xd3, 0x84, 0x25, 0x4c, 0x21, 0xaf, 0xac, 0x76, 0x7e, 0xe7, 0xad, 0x66, 0x34, 0x86, + 0xaa, 0x81, 0x39, 0x33, 0xac, 0xbc, 0x20, 0x08, 0x87, 0x3c, 0x83, 0x39, 0x1f, 0x31, 0x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xb6, 0xbe, 0x5c, 0xd9, 0xfa, 0xe7, 0xca, 0xd6, 0x5f, 0xd6, 0xb6, + 0xb6, 0x5c, 0xdb, 0xda, 0xfb, 0xda, 0xd6, 0x9e, 0x7b, 0x3f, 0x16, 0xc9, 0x31, 0xe9, 0x1d, 0xee, + 0x45, 0xfd, 0xa8, 0x83, 0xf1, 0xa6, 0x5e, 0x79, 0x59, 0x6a, 0xa7, 0x51, 0x43, 0xf1, 0xab, 0xef, + 0x00, 0x00, 0x00, 0xff, 0xff, 0xda, 0xfb, 0x04, 0x6b, 0x6d, 0x02, 0x00, 0x00, } func (this *Params) Equal(that interface{}) bool { @@ -123,6 +144,12 @@ func (this *Params) Equal(that interface{}) bool { if !this.SudoCallGasPrice.Equal(that1.SudoCallGasPrice) { return false } + if this.BeginBlockGasLimit != that1.BeginBlockGasLimit { + return false + } + if this.EndBlockGasLimit != that1.EndBlockGasLimit { + return false + } return true } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -145,6 +172,16 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.EndBlockGasLimit != 0 { + i = encodeVarintParams(dAtA, i, uint64(m.EndBlockGasLimit)) + i-- + dAtA[i] = 0x20 + } + if m.BeginBlockGasLimit != 0 { + i = encodeVarintParams(dAtA, i, uint64(m.BeginBlockGasLimit)) + i-- + dAtA[i] = 0x18 + } { size := m.SudoCallGasPrice.Size() i -= size @@ -185,6 +222,12 @@ func (m *Params) Size() (n int) { } l = m.SudoCallGasPrice.Size() n += 1 + l + sovParams(uint64(l)) + if m.BeginBlockGasLimit != 0 { + n += 1 + sovParams(uint64(m.BeginBlockGasLimit)) + } + if m.EndBlockGasLimit != 0 { + n += 1 + sovParams(uint64(m.EndBlockGasLimit)) + } return n } @@ -276,6 +319,44 @@ func (m *Params) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field BeginBlockGasLimit", wireType) + } + m.BeginBlockGasLimit = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.BeginBlockGasLimit |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field EndBlockGasLimit", wireType) + } + m.EndBlockGasLimit = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.EndBlockGasLimit |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipParams(dAtA[iNdEx:]) diff --git a/x/dex/utils/gas.go b/x/dex/utils/gas.go new file mode 100644 index 0000000000..3e420dc990 --- /dev/null +++ b/x/dex/utils/gas.go @@ -0,0 +1,12 @@ +package utils + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" +) + +func GetGasMeterForLimit(limit uint64) sdk.GasMeter { + if limit == 0 { + return sdk.NewInfiniteGasMeter() + } + return sdk.NewGasMeter(limit) +}