diff --git a/api/feemarket/feemarket/v1/params.pulsar.go b/api/feemarket/feemarket/v1/params.pulsar.go index 8aba756..f979ffe 100644 --- a/api/feemarket/feemarket/v1/params.pulsar.go +++ b/api/feemarket/feemarket/v1/params.pulsar.go @@ -24,8 +24,7 @@ var ( fd_Params_min_learning_rate protoreflect.FieldDescriptor fd_Params_max_learning_rate protoreflect.FieldDescriptor fd_Params_target_block_utilization protoreflect.FieldDescriptor - fd_Params_max_block_utilization protoreflect.FieldDescriptor - fd_Params_window protoreflect.FieldDescriptor + fd_Params_window_size protoreflect.FieldDescriptor fd_Params_fee_denom protoreflect.FieldDescriptor fd_Params_enabled protoreflect.FieldDescriptor ) @@ -41,8 +40,7 @@ func init() { fd_Params_min_learning_rate = md_Params.Fields().ByName("min_learning_rate") fd_Params_max_learning_rate = md_Params.Fields().ByName("max_learning_rate") fd_Params_target_block_utilization = md_Params.Fields().ByName("target_block_utilization") - fd_Params_max_block_utilization = md_Params.Fields().ByName("max_block_utilization") - fd_Params_window = md_Params.Fields().ByName("window") + fd_Params_window_size = md_Params.Fields().ByName("window_size") fd_Params_fee_denom = md_Params.Fields().ByName("fee_denom") fd_Params_enabled = md_Params.Fields().ByName("enabled") } @@ -160,15 +158,9 @@ func (x *fastReflection_Params) Range(f func(protoreflect.FieldDescriptor, proto return } } - if x.MaxBlockUtilization != uint64(0) { - value := protoreflect.ValueOfUint64(x.MaxBlockUtilization) - if !f(fd_Params_max_block_utilization, value) { - return - } - } - if x.Window != uint64(0) { - value := protoreflect.ValueOfUint64(x.Window) - if !f(fd_Params_window, value) { + if x.WindowSize != uint64(0) { + value := protoreflect.ValueOfUint64(x.WindowSize) + if !f(fd_Params_window_size, value) { return } } @@ -215,10 +207,8 @@ func (x *fastReflection_Params) Has(fd protoreflect.FieldDescriptor) bool { return x.MaxLearningRate != "" case "feemarket.feemarket.v1.Params.target_block_utilization": return x.TargetBlockUtilization != uint64(0) - case "feemarket.feemarket.v1.Params.max_block_utilization": - return x.MaxBlockUtilization != uint64(0) - case "feemarket.feemarket.v1.Params.window": - return x.Window != uint64(0) + case "feemarket.feemarket.v1.Params.window_size": + return x.WindowSize != uint64(0) case "feemarket.feemarket.v1.Params.fee_denom": return x.FeeDenom != "" case "feemarket.feemarket.v1.Params.enabled": @@ -255,10 +245,8 @@ func (x *fastReflection_Params) Clear(fd protoreflect.FieldDescriptor) { x.MaxLearningRate = "" case "feemarket.feemarket.v1.Params.target_block_utilization": x.TargetBlockUtilization = uint64(0) - case "feemarket.feemarket.v1.Params.max_block_utilization": - x.MaxBlockUtilization = uint64(0) - case "feemarket.feemarket.v1.Params.window": - x.Window = uint64(0) + case "feemarket.feemarket.v1.Params.window_size": + x.WindowSize = uint64(0) case "feemarket.feemarket.v1.Params.fee_denom": x.FeeDenom = "" case "feemarket.feemarket.v1.Params.enabled": @@ -303,11 +291,8 @@ func (x *fastReflection_Params) Get(descriptor protoreflect.FieldDescriptor) pro case "feemarket.feemarket.v1.Params.target_block_utilization": value := x.TargetBlockUtilization return protoreflect.ValueOfUint64(value) - case "feemarket.feemarket.v1.Params.max_block_utilization": - value := x.MaxBlockUtilization - return protoreflect.ValueOfUint64(value) - case "feemarket.feemarket.v1.Params.window": - value := x.Window + case "feemarket.feemarket.v1.Params.window_size": + value := x.WindowSize return protoreflect.ValueOfUint64(value) case "feemarket.feemarket.v1.Params.fee_denom": value := x.FeeDenom @@ -351,10 +336,8 @@ func (x *fastReflection_Params) Set(fd protoreflect.FieldDescriptor, value proto x.MaxLearningRate = value.Interface().(string) case "feemarket.feemarket.v1.Params.target_block_utilization": x.TargetBlockUtilization = value.Uint() - case "feemarket.feemarket.v1.Params.max_block_utilization": - x.MaxBlockUtilization = value.Uint() - case "feemarket.feemarket.v1.Params.window": - x.Window = value.Uint() + case "feemarket.feemarket.v1.Params.window_size": + x.WindowSize = value.Uint() case "feemarket.feemarket.v1.Params.fee_denom": x.FeeDenom = value.Interface().(string) case "feemarket.feemarket.v1.Params.enabled": @@ -395,10 +378,8 @@ func (x *fastReflection_Params) Mutable(fd protoreflect.FieldDescriptor) protore panic(fmt.Errorf("field max_learning_rate of message feemarket.feemarket.v1.Params is not mutable")) case "feemarket.feemarket.v1.Params.target_block_utilization": panic(fmt.Errorf("field target_block_utilization of message feemarket.feemarket.v1.Params is not mutable")) - case "feemarket.feemarket.v1.Params.max_block_utilization": - panic(fmt.Errorf("field max_block_utilization of message feemarket.feemarket.v1.Params is not mutable")) - case "feemarket.feemarket.v1.Params.window": - panic(fmt.Errorf("field window of message feemarket.feemarket.v1.Params is not mutable")) + case "feemarket.feemarket.v1.Params.window_size": + panic(fmt.Errorf("field window_size of message feemarket.feemarket.v1.Params is not mutable")) case "feemarket.feemarket.v1.Params.fee_denom": panic(fmt.Errorf("field fee_denom of message feemarket.feemarket.v1.Params is not mutable")) case "feemarket.feemarket.v1.Params.enabled": @@ -432,9 +413,7 @@ func (x *fastReflection_Params) NewField(fd protoreflect.FieldDescriptor) protor return protoreflect.ValueOfString("") case "feemarket.feemarket.v1.Params.target_block_utilization": return protoreflect.ValueOfUint64(uint64(0)) - case "feemarket.feemarket.v1.Params.max_block_utilization": - return protoreflect.ValueOfUint64(uint64(0)) - case "feemarket.feemarket.v1.Params.window": + case "feemarket.feemarket.v1.Params.window_size": return protoreflect.ValueOfUint64(uint64(0)) case "feemarket.feemarket.v1.Params.fee_denom": return protoreflect.ValueOfString("") @@ -540,11 +519,8 @@ func (x *fastReflection_Params) ProtoMethods() *protoiface.Methods { if x.TargetBlockUtilization != 0 { n += 1 + runtime.Sov(uint64(x.TargetBlockUtilization)) } - if x.MaxBlockUtilization != 0 { - n += 1 + runtime.Sov(uint64(x.MaxBlockUtilization)) - } - if x.Window != 0 { - n += 1 + runtime.Sov(uint64(x.Window)) + if x.WindowSize != 0 { + n += 1 + runtime.Sov(uint64(x.WindowSize)) } l = len(x.FeeDenom) if l > 0 { @@ -590,22 +566,17 @@ func (x *fastReflection_Params) ProtoMethods() *protoiface.Methods { dAtA[i] = 0 } i-- - dAtA[i] = 0x60 + dAtA[i] = 0x58 } if len(x.FeeDenom) > 0 { i -= len(x.FeeDenom) copy(dAtA[i:], x.FeeDenom) i = runtime.EncodeVarint(dAtA, i, uint64(len(x.FeeDenom))) i-- - dAtA[i] = 0x5a - } - if x.Window != 0 { - i = runtime.EncodeVarint(dAtA, i, uint64(x.Window)) - i-- - dAtA[i] = 0x50 + dAtA[i] = 0x52 } - if x.MaxBlockUtilization != 0 { - i = runtime.EncodeVarint(dAtA, i, uint64(x.MaxBlockUtilization)) + if x.WindowSize != 0 { + i = runtime.EncodeVarint(dAtA, i, uint64(x.WindowSize)) i-- dAtA[i] = 0x48 } @@ -957,9 +928,9 @@ func (x *fastReflection_Params) ProtoMethods() *protoiface.Methods { } case 9: if wireType != 0 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field MaxBlockUtilization", wireType) + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field WindowSize", wireType) } - x.MaxBlockUtilization = 0 + x.WindowSize = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow @@ -969,31 +940,12 @@ func (x *fastReflection_Params) ProtoMethods() *protoiface.Methods { } b := dAtA[iNdEx] iNdEx++ - x.MaxBlockUtilization |= uint64(b&0x7F) << shift + x.WindowSize |= uint64(b&0x7F) << shift if b < 0x80 { break } } case 10: - if wireType != 0 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Window", wireType) - } - x.Window = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow - } - if iNdEx >= l { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - x.Window |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 11: if wireType != 2 { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field FeeDenom", wireType) } @@ -1025,7 +977,7 @@ func (x *fastReflection_Params) ProtoMethods() *protoiface.Methods { } x.FeeDenom = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 12: + case 11: if wireType != 0 { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Enabled", wireType) } @@ -1100,7 +1052,7 @@ type Params struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - // Alpha is the amount we additively increase the learninig rate + // Alpha is the amount we additively increase the learning rate // when it is above or below the target +/- threshold. Alpha string `protobuf:"bytes,1,opt,name=alpha,proto3" json:"alpha,omitempty"` // Beta is the amount we multiplicatively decrease the learning rate @@ -1116,25 +1068,23 @@ type Params struct { // utilization. Delta string `protobuf:"bytes,4,opt,name=delta,proto3" json:"delta,omitempty"` // MinBaseFee determines the initial base fee of the module and the global - // minimum - // for the network. This is denominated in fee per gas unit. + // minimum for the network. This is denominated in fee per gas unit. MinBaseFee string `protobuf:"bytes,5,opt,name=min_base_fee,json=minBaseFee,proto3" json:"min_base_fee,omitempty"` // MinLearningRate is the lower bound for the learning rate. MinLearningRate string `protobuf:"bytes,6,opt,name=min_learning_rate,json=minLearningRate,proto3" json:"min_learning_rate,omitempty"` // MaxLearningRate is the upper bound for the learning rate. MaxLearningRate string `protobuf:"bytes,7,opt,name=max_learning_rate,json=maxLearningRate,proto3" json:"max_learning_rate,omitempty"` - // TargetBlockUtilization is the target block utilization. + // TargetBlockUtilization is the target block utilization (in units of gas). + // This value MUST be lower than the consensus max gas parameter. TargetBlockUtilization uint64 `protobuf:"varint,8,opt,name=target_block_utilization,json=targetBlockUtilization,proto3" json:"target_block_utilization,omitempty"` - // MaxBlockUtilization is the maximum block utilization. - MaxBlockUtilization uint64 `protobuf:"varint,9,opt,name=max_block_utilization,json=maxBlockUtilization,proto3" json:"max_block_utilization,omitempty"` - // Window defines the window size for calculating an adaptive learning rate - // over a moving window of blocks. - Window uint64 `protobuf:"varint,10,opt,name=window,proto3" json:"window,omitempty"` + // WindowSize defines the window size for calculating an adaptive learning + // rate over a moving window of blocks. + WindowSize uint64 `protobuf:"varint,9,opt,name=window_size,json=windowSize,proto3" json:"window_size,omitempty"` // FeeDenom is the denom that will be used for all fee payments. - FeeDenom string `protobuf:"bytes,11,opt,name=fee_denom,json=feeDenom,proto3" json:"fee_denom,omitempty"` + FeeDenom string `protobuf:"bytes,10,opt,name=fee_denom,json=feeDenom,proto3" json:"fee_denom,omitempty"` // Enabled is a boolean that determines whether the EIP1559 fee market is // enabled. - Enabled bool `protobuf:"varint,12,opt,name=enabled,proto3" json:"enabled,omitempty"` + Enabled bool `protobuf:"varint,11,opt,name=enabled,proto3" json:"enabled,omitempty"` } func (x *Params) Reset() { @@ -1213,16 +1163,9 @@ func (x *Params) GetTargetBlockUtilization() uint64 { return 0 } -func (x *Params) GetMaxBlockUtilization() uint64 { - if x != nil { - return x.MaxBlockUtilization - } - return 0 -} - -func (x *Params) GetWindow() uint64 { +func (x *Params) GetWindowSize() uint64 { if x != nil { - return x.Window + return x.WindowSize } return 0 } @@ -1250,7 +1193,7 @@ var file_feemarket_feemarket_v1_params_proto_rawDesc = []byte{ 0x2e, 0x66, 0x65, 0x65, 0x6d, 0x61, 0x72, 0x6b, 0x65, 0x74, 0x2e, 0x76, 0x31, 0x1a, 0x19, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x14, 0x67, 0x6f, 0x67, 0x6f, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x6f, 0x67, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xf4, + 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x6f, 0x67, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xc9, 0x05, 0x0a, 0x06, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12, 0x47, 0x0a, 0x05, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x31, 0xc8, 0xde, 0x1f, 0x00, 0xda, 0xde, 0x1f, 0x1b, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x6d, @@ -1290,29 +1233,26 @@ var file_feemarket_feemarket_v1_params_proto_rawDesc = []byte{ 0x65, 0x74, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x75, 0x74, 0x69, 0x6c, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x08, 0x20, 0x01, 0x28, 0x04, 0x52, 0x16, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x55, 0x74, 0x69, 0x6c, 0x69, 0x7a, 0x61, 0x74, 0x69, - 0x6f, 0x6e, 0x12, 0x32, 0x0a, 0x15, 0x6d, 0x61, 0x78, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, - 0x75, 0x74, 0x69, 0x6c, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x09, 0x20, 0x01, 0x28, - 0x04, 0x52, 0x13, 0x6d, 0x61, 0x78, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x55, 0x74, 0x69, 0x6c, 0x69, - 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x16, 0x0a, 0x06, 0x77, 0x69, 0x6e, 0x64, 0x6f, 0x77, - 0x18, 0x0a, 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x77, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x12, 0x1b, - 0x0a, 0x09, 0x66, 0x65, 0x65, 0x5f, 0x64, 0x65, 0x6e, 0x6f, 0x6d, 0x18, 0x0b, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x08, 0x66, 0x65, 0x65, 0x44, 0x65, 0x6e, 0x6f, 0x6d, 0x12, 0x18, 0x0a, 0x07, 0x65, - 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x65, 0x6e, - 0x61, 0x62, 0x6c, 0x65, 0x64, 0x42, 0xd8, 0x01, 0x0a, 0x1a, 0x63, 0x6f, 0x6d, 0x2e, 0x66, 0x65, - 0x65, 0x6d, 0x61, 0x72, 0x6b, 0x65, 0x74, 0x2e, 0x66, 0x65, 0x65, 0x6d, 0x61, 0x72, 0x6b, 0x65, - 0x74, 0x2e, 0x76, 0x31, 0x42, 0x0b, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x50, 0x72, 0x6f, 0x74, - 0x6f, 0x50, 0x01, 0x5a, 0x33, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, - 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x66, 0x65, 0x65, 0x6d, 0x61, 0x72, 0x6b, 0x65, 0x74, 0x2f, - 0x66, 0x65, 0x65, 0x6d, 0x61, 0x72, 0x6b, 0x65, 0x74, 0x2f, 0x76, 0x31, 0x3b, 0x66, 0x65, 0x65, - 0x6d, 0x61, 0x72, 0x6b, 0x65, 0x74, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x46, 0x46, 0x58, 0xaa, 0x02, - 0x16, 0x46, 0x65, 0x65, 0x6d, 0x61, 0x72, 0x6b, 0x65, 0x74, 0x2e, 0x46, 0x65, 0x65, 0x6d, 0x61, - 0x72, 0x6b, 0x65, 0x74, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x16, 0x46, 0x65, 0x65, 0x6d, 0x61, 0x72, - 0x6b, 0x65, 0x74, 0x5c, 0x46, 0x65, 0x65, 0x6d, 0x61, 0x72, 0x6b, 0x65, 0x74, 0x5c, 0x56, 0x31, - 0xe2, 0x02, 0x22, 0x46, 0x65, 0x65, 0x6d, 0x61, 0x72, 0x6b, 0x65, 0x74, 0x5c, 0x46, 0x65, 0x65, - 0x6d, 0x61, 0x72, 0x6b, 0x65, 0x74, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, - 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x18, 0x46, 0x65, 0x65, 0x6d, 0x61, 0x72, 0x6b, 0x65, - 0x74, 0x3a, 0x3a, 0x46, 0x65, 0x65, 0x6d, 0x61, 0x72, 0x6b, 0x65, 0x74, 0x3a, 0x3a, 0x56, 0x31, - 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6f, 0x6e, 0x12, 0x1f, 0x0a, 0x0b, 0x77, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x5f, 0x73, 0x69, 0x7a, + 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0a, 0x77, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x53, + 0x69, 0x7a, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x66, 0x65, 0x65, 0x5f, 0x64, 0x65, 0x6e, 0x6f, 0x6d, + 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x66, 0x65, 0x65, 0x44, 0x65, 0x6e, 0x6f, 0x6d, + 0x12, 0x18, 0x0a, 0x07, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x18, 0x0b, 0x20, 0x01, 0x28, + 0x08, 0x52, 0x07, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x42, 0xd8, 0x01, 0x0a, 0x1a, 0x63, + 0x6f, 0x6d, 0x2e, 0x66, 0x65, 0x65, 0x6d, 0x61, 0x72, 0x6b, 0x65, 0x74, 0x2e, 0x66, 0x65, 0x65, + 0x6d, 0x61, 0x72, 0x6b, 0x65, 0x74, 0x2e, 0x76, 0x31, 0x42, 0x0b, 0x50, 0x61, 0x72, 0x61, 0x6d, + 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x33, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, + 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x66, 0x65, 0x65, 0x6d, 0x61, + 0x72, 0x6b, 0x65, 0x74, 0x2f, 0x66, 0x65, 0x65, 0x6d, 0x61, 0x72, 0x6b, 0x65, 0x74, 0x2f, 0x76, + 0x31, 0x3b, 0x66, 0x65, 0x65, 0x6d, 0x61, 0x72, 0x6b, 0x65, 0x74, 0x76, 0x31, 0xa2, 0x02, 0x03, + 0x46, 0x46, 0x58, 0xaa, 0x02, 0x16, 0x46, 0x65, 0x65, 0x6d, 0x61, 0x72, 0x6b, 0x65, 0x74, 0x2e, + 0x46, 0x65, 0x65, 0x6d, 0x61, 0x72, 0x6b, 0x65, 0x74, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x16, 0x46, + 0x65, 0x65, 0x6d, 0x61, 0x72, 0x6b, 0x65, 0x74, 0x5c, 0x46, 0x65, 0x65, 0x6d, 0x61, 0x72, 0x6b, + 0x65, 0x74, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x22, 0x46, 0x65, 0x65, 0x6d, 0x61, 0x72, 0x6b, 0x65, + 0x74, 0x5c, 0x46, 0x65, 0x65, 0x6d, 0x61, 0x72, 0x6b, 0x65, 0x74, 0x5c, 0x56, 0x31, 0x5c, 0x47, + 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x18, 0x46, 0x65, 0x65, + 0x6d, 0x61, 0x72, 0x6b, 0x65, 0x74, 0x3a, 0x3a, 0x46, 0x65, 0x65, 0x6d, 0x61, 0x72, 0x6b, 0x65, + 0x74, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/api/feemarket/feemarket/v1/query.pulsar.go b/api/feemarket/feemarket/v1/query.pulsar.go index f7d1058..ca0d3eb 100644 --- a/api/feemarket/feemarket/v1/query.pulsar.go +++ b/api/feemarket/feemarket/v1/query.pulsar.go @@ -2006,14 +2006,14 @@ func (x *_BaseFeeResponse_1_list) IsValid() bool { } var ( - md_BaseFeeResponse protoreflect.MessageDescriptor - fd_BaseFeeResponse_fee protoreflect.FieldDescriptor + md_BaseFeeResponse protoreflect.MessageDescriptor + fd_BaseFeeResponse_fees protoreflect.FieldDescriptor ) func init() { file_feemarket_feemarket_v1_query_proto_init() md_BaseFeeResponse = File_feemarket_feemarket_v1_query_proto.Messages().ByName("BaseFeeResponse") - fd_BaseFeeResponse_fee = md_BaseFeeResponse.Fields().ByName("fee") + fd_BaseFeeResponse_fees = md_BaseFeeResponse.Fields().ByName("fees") } var _ protoreflect.Message = (*fastReflection_BaseFeeResponse)(nil) @@ -2081,9 +2081,9 @@ func (x *fastReflection_BaseFeeResponse) Interface() protoreflect.ProtoMessage { // While iterating, mutating operations may only be performed // on the current field descriptor. func (x *fastReflection_BaseFeeResponse) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { - if len(x.Fee) != 0 { - value := protoreflect.ValueOfList(&_BaseFeeResponse_1_list{list: &x.Fee}) - if !f(fd_BaseFeeResponse_fee, value) { + if len(x.Fees) != 0 { + value := protoreflect.ValueOfList(&_BaseFeeResponse_1_list{list: &x.Fees}) + if !f(fd_BaseFeeResponse_fees, value) { return } } @@ -2102,8 +2102,8 @@ func (x *fastReflection_BaseFeeResponse) Range(f func(protoreflect.FieldDescript // a repeated field is populated if it is non-empty. func (x *fastReflection_BaseFeeResponse) Has(fd protoreflect.FieldDescriptor) bool { switch fd.FullName() { - case "feemarket.feemarket.v1.BaseFeeResponse.fee": - return len(x.Fee) != 0 + case "feemarket.feemarket.v1.BaseFeeResponse.fees": + return len(x.Fees) != 0 default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: feemarket.feemarket.v1.BaseFeeResponse")) @@ -2120,8 +2120,8 @@ func (x *fastReflection_BaseFeeResponse) Has(fd protoreflect.FieldDescriptor) bo // Clear is a mutating operation and unsafe for concurrent use. func (x *fastReflection_BaseFeeResponse) Clear(fd protoreflect.FieldDescriptor) { switch fd.FullName() { - case "feemarket.feemarket.v1.BaseFeeResponse.fee": - x.Fee = nil + case "feemarket.feemarket.v1.BaseFeeResponse.fees": + x.Fees = nil default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: feemarket.feemarket.v1.BaseFeeResponse")) @@ -2138,11 +2138,11 @@ func (x *fastReflection_BaseFeeResponse) Clear(fd protoreflect.FieldDescriptor) // of the value; to obtain a mutable reference, use Mutable. func (x *fastReflection_BaseFeeResponse) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { switch descriptor.FullName() { - case "feemarket.feemarket.v1.BaseFeeResponse.fee": - if len(x.Fee) == 0 { + case "feemarket.feemarket.v1.BaseFeeResponse.fees": + if len(x.Fees) == 0 { return protoreflect.ValueOfList(&_BaseFeeResponse_1_list{}) } - listValue := &_BaseFeeResponse_1_list{list: &x.Fee} + listValue := &_BaseFeeResponse_1_list{list: &x.Fees} return protoreflect.ValueOfList(listValue) default: if descriptor.IsExtension() { @@ -2164,10 +2164,10 @@ func (x *fastReflection_BaseFeeResponse) Get(descriptor protoreflect.FieldDescri // Set is a mutating operation and unsafe for concurrent use. func (x *fastReflection_BaseFeeResponse) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { switch fd.FullName() { - case "feemarket.feemarket.v1.BaseFeeResponse.fee": + case "feemarket.feemarket.v1.BaseFeeResponse.fees": lv := value.List() clv := lv.(*_BaseFeeResponse_1_list) - x.Fee = *clv.list + x.Fees = *clv.list default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: feemarket.feemarket.v1.BaseFeeResponse")) @@ -2188,11 +2188,11 @@ func (x *fastReflection_BaseFeeResponse) Set(fd protoreflect.FieldDescriptor, va // Mutable is a mutating operation and unsafe for concurrent use. func (x *fastReflection_BaseFeeResponse) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { switch fd.FullName() { - case "feemarket.feemarket.v1.BaseFeeResponse.fee": - if x.Fee == nil { - x.Fee = []*v1beta1.Coin{} + case "feemarket.feemarket.v1.BaseFeeResponse.fees": + if x.Fees == nil { + x.Fees = []*v1beta1.Coin{} } - value := &_BaseFeeResponse_1_list{list: &x.Fee} + value := &_BaseFeeResponse_1_list{list: &x.Fees} return protoreflect.ValueOfList(value) default: if fd.IsExtension() { @@ -2207,7 +2207,7 @@ func (x *fastReflection_BaseFeeResponse) Mutable(fd protoreflect.FieldDescriptor // For lists, maps, and messages, this returns a new, empty, mutable value. func (x *fastReflection_BaseFeeResponse) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { switch fd.FullName() { - case "feemarket.feemarket.v1.BaseFeeResponse.fee": + case "feemarket.feemarket.v1.BaseFeeResponse.fees": list := []*v1beta1.Coin{} return protoreflect.ValueOfList(&_BaseFeeResponse_1_list{list: &list}) default: @@ -2279,8 +2279,8 @@ func (x *fastReflection_BaseFeeResponse) ProtoMethods() *protoiface.Methods { var n int var l int _ = l - if len(x.Fee) > 0 { - for _, e := range x.Fee { + if len(x.Fees) > 0 { + for _, e := range x.Fees { l = options.Size(e) n += 1 + l + runtime.Sov(uint64(l)) } @@ -2314,9 +2314,9 @@ func (x *fastReflection_BaseFeeResponse) ProtoMethods() *protoiface.Methods { i -= len(x.unknownFields) copy(dAtA[i:], x.unknownFields) } - if len(x.Fee) > 0 { - for iNdEx := len(x.Fee) - 1; iNdEx >= 0; iNdEx-- { - encoded, err := options.Marshal(x.Fee[iNdEx]) + if len(x.Fees) > 0 { + for iNdEx := len(x.Fees) - 1; iNdEx >= 0; iNdEx-- { + encoded, err := options.Marshal(x.Fees[iNdEx]) if err != nil { return protoiface.MarshalOutput{ NoUnkeyedLiterals: input.NoUnkeyedLiterals, @@ -2381,7 +2381,7 @@ func (x *fastReflection_BaseFeeResponse) ProtoMethods() *protoiface.Methods { switch fieldNum { case 1: if wireType != 2 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Fee", wireType) + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Fees", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -2408,8 +2408,8 @@ func (x *fastReflection_BaseFeeResponse) ProtoMethods() *protoiface.Methods { if postIndex > l { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF } - x.Fee = append(x.Fee, &v1beta1.Coin{}) - if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.Fee[len(x.Fee)-1]); err != nil { + x.Fees = append(x.Fees, &v1beta1.Coin{}) + if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.Fees[len(x.Fees)-1]); err != nil { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err } iNdEx = postIndex @@ -2620,7 +2620,7 @@ type BaseFeeResponse struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Fee []*v1beta1.Coin `protobuf:"bytes,1,rep,name=fee,proto3" json:"fee,omitempty"` + Fees []*v1beta1.Coin `protobuf:"bytes,1,rep,name=fees,proto3" json:"fees,omitempty"` } func (x *BaseFeeResponse) Reset() { @@ -2643,9 +2643,9 @@ func (*BaseFeeResponse) Descriptor() ([]byte, []int) { return file_feemarket_feemarket_v1_query_proto_rawDescGZIP(), []int{5} } -func (x *BaseFeeResponse) GetFee() []*v1beta1.Coin { +func (x *BaseFeeResponse) GetFees() []*v1beta1.Coin { if x != nil { - return x.Fee + return x.Fees } return nil } @@ -2680,53 +2680,53 @@ var file_feemarket_feemarket_v1_query_proto_rawDesc = []byte{ 0x1d, 0x2e, 0x66, 0x65, 0x65, 0x6d, 0x61, 0x72, 0x6b, 0x65, 0x74, 0x2e, 0x66, 0x65, 0x65, 0x6d, 0x61, 0x72, 0x6b, 0x65, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x42, 0x04, 0xc8, 0xde, 0x1f, 0x00, 0x52, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x22, 0x10, 0x0a, 0x0e, 0x42, - 0x61, 0x73, 0x65, 0x46, 0x65, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x86, 0x01, + 0x61, 0x73, 0x65, 0x46, 0x65, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x88, 0x01, 0x0a, 0x0f, 0x42, 0x61, 0x73, 0x65, 0x46, 0x65, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x12, 0x73, 0x0a, 0x03, 0x66, 0x65, 0x65, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x19, - 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x62, - 0x65, 0x74, 0x61, 0x31, 0x2e, 0x43, 0x6f, 0x69, 0x6e, 0x42, 0x46, 0xc8, 0xde, 0x1f, 0x00, 0xaa, - 0xdf, 0x1f, 0x28, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, - 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, - 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x43, 0x6f, 0x69, 0x6e, 0x73, 0x9a, 0xe7, 0xb0, 0x2a, 0x0c, - 0x6c, 0x65, 0x67, 0x61, 0x63, 0x79, 0x5f, 0x63, 0x6f, 0x69, 0x6e, 0x73, 0xa8, 0xe7, 0xb0, 0x2a, - 0x01, 0x52, 0x03, 0x66, 0x65, 0x65, 0x32, 0xed, 0x02, 0x0a, 0x05, 0x51, 0x75, 0x65, 0x72, 0x79, - 0x12, 0x75, 0x0a, 0x06, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12, 0x25, 0x2e, 0x66, 0x65, 0x65, - 0x6d, 0x61, 0x72, 0x6b, 0x65, 0x74, 0x2e, 0x66, 0x65, 0x65, 0x6d, 0x61, 0x72, 0x6b, 0x65, 0x74, - 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x1a, 0x26, 0x2e, 0x66, 0x65, 0x65, 0x6d, 0x61, 0x72, 0x6b, 0x65, 0x74, 0x2e, 0x66, 0x65, - 0x65, 0x6d, 0x61, 0x72, 0x6b, 0x65, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x61, 0x72, 0x61, 0x6d, - 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x1c, 0x82, 0xd3, 0xe4, 0x93, 0x02, - 0x16, 0x12, 0x14, 0x2f, 0x66, 0x65, 0x65, 0x6d, 0x61, 0x72, 0x6b, 0x65, 0x74, 0x2f, 0x76, 0x31, - 0x2f, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12, 0x71, 0x0a, 0x05, 0x53, 0x74, 0x61, 0x74, 0x65, - 0x12, 0x24, 0x2e, 0x66, 0x65, 0x65, 0x6d, 0x61, 0x72, 0x6b, 0x65, 0x74, 0x2e, 0x66, 0x65, 0x65, - 0x6d, 0x61, 0x72, 0x6b, 0x65, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x25, 0x2e, 0x66, 0x65, 0x65, 0x6d, 0x61, 0x72, 0x6b, - 0x65, 0x74, 0x2e, 0x66, 0x65, 0x65, 0x6d, 0x61, 0x72, 0x6b, 0x65, 0x74, 0x2e, 0x76, 0x31, 0x2e, - 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x1b, 0x82, - 0xd3, 0xe4, 0x93, 0x02, 0x15, 0x12, 0x13, 0x2f, 0x66, 0x65, 0x65, 0x6d, 0x61, 0x72, 0x6b, 0x65, - 0x74, 0x2f, 0x76, 0x31, 0x2f, 0x73, 0x74, 0x61, 0x74, 0x65, 0x12, 0x7a, 0x0a, 0x07, 0x42, 0x61, - 0x73, 0x65, 0x46, 0x65, 0x65, 0x12, 0x26, 0x2e, 0x66, 0x65, 0x65, 0x6d, 0x61, 0x72, 0x6b, 0x65, - 0x74, 0x2e, 0x66, 0x65, 0x65, 0x6d, 0x61, 0x72, 0x6b, 0x65, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x42, - 0x61, 0x73, 0x65, 0x46, 0x65, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x27, 0x2e, - 0x66, 0x65, 0x65, 0x6d, 0x61, 0x72, 0x6b, 0x65, 0x74, 0x2e, 0x66, 0x65, 0x65, 0x6d, 0x61, 0x72, - 0x6b, 0x65, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x42, 0x61, 0x73, 0x65, 0x46, 0x65, 0x65, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x1e, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x18, 0x12, 0x16, - 0x2f, 0x66, 0x65, 0x65, 0x6d, 0x61, 0x72, 0x6b, 0x65, 0x74, 0x2f, 0x76, 0x31, 0x2f, 0x62, 0x61, - 0x73, 0x65, 0x5f, 0x66, 0x65, 0x65, 0x42, 0xd7, 0x01, 0x0a, 0x1a, 0x63, 0x6f, 0x6d, 0x2e, 0x66, + 0x65, 0x12, 0x75, 0x0a, 0x04, 0x66, 0x65, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, + 0x19, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, + 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x43, 0x6f, 0x69, 0x6e, 0x42, 0x46, 0xc8, 0xde, 0x1f, 0x00, + 0xaa, 0xdf, 0x1f, 0x28, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, + 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, + 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x43, 0x6f, 0x69, 0x6e, 0x73, 0x9a, 0xe7, 0xb0, 0x2a, + 0x0c, 0x6c, 0x65, 0x67, 0x61, 0x63, 0x79, 0x5f, 0x63, 0x6f, 0x69, 0x6e, 0x73, 0xa8, 0xe7, 0xb0, + 0x2a, 0x01, 0x52, 0x04, 0x66, 0x65, 0x65, 0x73, 0x32, 0xed, 0x02, 0x0a, 0x05, 0x51, 0x75, 0x65, + 0x72, 0x79, 0x12, 0x75, 0x0a, 0x06, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12, 0x25, 0x2e, 0x66, 0x65, 0x65, 0x6d, 0x61, 0x72, 0x6b, 0x65, 0x74, 0x2e, 0x66, 0x65, 0x65, 0x6d, 0x61, 0x72, 0x6b, - 0x65, 0x74, 0x2e, 0x76, 0x31, 0x42, 0x0a, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x72, 0x6f, 0x74, - 0x6f, 0x50, 0x01, 0x5a, 0x33, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, - 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x66, 0x65, 0x65, 0x6d, 0x61, 0x72, 0x6b, 0x65, 0x74, 0x2f, - 0x66, 0x65, 0x65, 0x6d, 0x61, 0x72, 0x6b, 0x65, 0x74, 0x2f, 0x76, 0x31, 0x3b, 0x66, 0x65, 0x65, - 0x6d, 0x61, 0x72, 0x6b, 0x65, 0x74, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x46, 0x46, 0x58, 0xaa, 0x02, - 0x16, 0x46, 0x65, 0x65, 0x6d, 0x61, 0x72, 0x6b, 0x65, 0x74, 0x2e, 0x46, 0x65, 0x65, 0x6d, 0x61, - 0x72, 0x6b, 0x65, 0x74, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x16, 0x46, 0x65, 0x65, 0x6d, 0x61, 0x72, - 0x6b, 0x65, 0x74, 0x5c, 0x46, 0x65, 0x65, 0x6d, 0x61, 0x72, 0x6b, 0x65, 0x74, 0x5c, 0x56, 0x31, - 0xe2, 0x02, 0x22, 0x46, 0x65, 0x65, 0x6d, 0x61, 0x72, 0x6b, 0x65, 0x74, 0x5c, 0x46, 0x65, 0x65, - 0x6d, 0x61, 0x72, 0x6b, 0x65, 0x74, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, - 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x18, 0x46, 0x65, 0x65, 0x6d, 0x61, 0x72, 0x6b, 0x65, - 0x74, 0x3a, 0x3a, 0x46, 0x65, 0x65, 0x6d, 0x61, 0x72, 0x6b, 0x65, 0x74, 0x3a, 0x3a, 0x56, 0x31, - 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x65, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x26, 0x2e, 0x66, 0x65, 0x65, 0x6d, 0x61, 0x72, 0x6b, 0x65, 0x74, 0x2e, + 0x66, 0x65, 0x65, 0x6d, 0x61, 0x72, 0x6b, 0x65, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x61, 0x72, + 0x61, 0x6d, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x1c, 0x82, 0xd3, 0xe4, + 0x93, 0x02, 0x16, 0x12, 0x14, 0x2f, 0x66, 0x65, 0x65, 0x6d, 0x61, 0x72, 0x6b, 0x65, 0x74, 0x2f, + 0x76, 0x31, 0x2f, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12, 0x71, 0x0a, 0x05, 0x53, 0x74, 0x61, + 0x74, 0x65, 0x12, 0x24, 0x2e, 0x66, 0x65, 0x65, 0x6d, 0x61, 0x72, 0x6b, 0x65, 0x74, 0x2e, 0x66, + 0x65, 0x65, 0x6d, 0x61, 0x72, 0x6b, 0x65, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x74, 0x61, 0x74, + 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x25, 0x2e, 0x66, 0x65, 0x65, 0x6d, 0x61, + 0x72, 0x6b, 0x65, 0x74, 0x2e, 0x66, 0x65, 0x65, 0x6d, 0x61, 0x72, 0x6b, 0x65, 0x74, 0x2e, 0x76, + 0x31, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, + 0x1b, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x15, 0x12, 0x13, 0x2f, 0x66, 0x65, 0x65, 0x6d, 0x61, 0x72, + 0x6b, 0x65, 0x74, 0x2f, 0x76, 0x31, 0x2f, 0x73, 0x74, 0x61, 0x74, 0x65, 0x12, 0x7a, 0x0a, 0x07, + 0x42, 0x61, 0x73, 0x65, 0x46, 0x65, 0x65, 0x12, 0x26, 0x2e, 0x66, 0x65, 0x65, 0x6d, 0x61, 0x72, + 0x6b, 0x65, 0x74, 0x2e, 0x66, 0x65, 0x65, 0x6d, 0x61, 0x72, 0x6b, 0x65, 0x74, 0x2e, 0x76, 0x31, + 0x2e, 0x42, 0x61, 0x73, 0x65, 0x46, 0x65, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, + 0x27, 0x2e, 0x66, 0x65, 0x65, 0x6d, 0x61, 0x72, 0x6b, 0x65, 0x74, 0x2e, 0x66, 0x65, 0x65, 0x6d, + 0x61, 0x72, 0x6b, 0x65, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x42, 0x61, 0x73, 0x65, 0x46, 0x65, 0x65, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x1e, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x18, + 0x12, 0x16, 0x2f, 0x66, 0x65, 0x65, 0x6d, 0x61, 0x72, 0x6b, 0x65, 0x74, 0x2f, 0x76, 0x31, 0x2f, + 0x62, 0x61, 0x73, 0x65, 0x5f, 0x66, 0x65, 0x65, 0x42, 0xd7, 0x01, 0x0a, 0x1a, 0x63, 0x6f, 0x6d, + 0x2e, 0x66, 0x65, 0x65, 0x6d, 0x61, 0x72, 0x6b, 0x65, 0x74, 0x2e, 0x66, 0x65, 0x65, 0x6d, 0x61, + 0x72, 0x6b, 0x65, 0x74, 0x2e, 0x76, 0x31, 0x42, 0x0a, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x72, + 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x33, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, + 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x66, 0x65, 0x65, 0x6d, 0x61, 0x72, 0x6b, 0x65, + 0x74, 0x2f, 0x66, 0x65, 0x65, 0x6d, 0x61, 0x72, 0x6b, 0x65, 0x74, 0x2f, 0x76, 0x31, 0x3b, 0x66, + 0x65, 0x65, 0x6d, 0x61, 0x72, 0x6b, 0x65, 0x74, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x46, 0x46, 0x58, + 0xaa, 0x02, 0x16, 0x46, 0x65, 0x65, 0x6d, 0x61, 0x72, 0x6b, 0x65, 0x74, 0x2e, 0x46, 0x65, 0x65, + 0x6d, 0x61, 0x72, 0x6b, 0x65, 0x74, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x16, 0x46, 0x65, 0x65, 0x6d, + 0x61, 0x72, 0x6b, 0x65, 0x74, 0x5c, 0x46, 0x65, 0x65, 0x6d, 0x61, 0x72, 0x6b, 0x65, 0x74, 0x5c, + 0x56, 0x31, 0xe2, 0x02, 0x22, 0x46, 0x65, 0x65, 0x6d, 0x61, 0x72, 0x6b, 0x65, 0x74, 0x5c, 0x46, + 0x65, 0x65, 0x6d, 0x61, 0x72, 0x6b, 0x65, 0x74, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, + 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x18, 0x46, 0x65, 0x65, 0x6d, 0x61, 0x72, + 0x6b, 0x65, 0x74, 0x3a, 0x3a, 0x46, 0x65, 0x65, 0x6d, 0x61, 0x72, 0x6b, 0x65, 0x74, 0x3a, 0x3a, + 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -2756,7 +2756,7 @@ var file_feemarket_feemarket_v1_query_proto_goTypes = []interface{}{ var file_feemarket_feemarket_v1_query_proto_depIdxs = []int32{ 6, // 0: feemarket.feemarket.v1.ParamsResponse.params:type_name -> feemarket.feemarket.v1.Params 7, // 1: feemarket.feemarket.v1.StateResponse.state:type_name -> feemarket.feemarket.v1.State - 8, // 2: feemarket.feemarket.v1.BaseFeeResponse.fee:type_name -> cosmos.base.v1beta1.Coin + 8, // 2: feemarket.feemarket.v1.BaseFeeResponse.fees:type_name -> cosmos.base.v1beta1.Coin 0, // 3: feemarket.feemarket.v1.Query.Params:input_type -> feemarket.feemarket.v1.ParamsRequest 2, // 4: feemarket.feemarket.v1.Query.State:input_type -> feemarket.feemarket.v1.StateRequest 4, // 5: feemarket.feemarket.v1.Query.BaseFee:input_type -> feemarket.feemarket.v1.BaseFeeRequest diff --git a/go.mod b/go.mod index 749b552..a9f4035 100644 --- a/go.mod +++ b/go.mod @@ -24,8 +24,8 @@ require ( github.com/stretchr/testify v1.8.4 golang.org/x/tools v0.16.0 google.golang.org/genproto/googleapis/api v0.0.0-20231106174013-bbf56f31fb17 - google.golang.org/grpc v1.59.0 - google.golang.org/protobuf v1.31.0 + google.golang.org/grpc v1.60.1 + google.golang.org/protobuf v1.32.0 mvdan.cc/gofumpt v0.5.0 pgregory.net/rapid v1.1.0 ) @@ -299,14 +299,14 @@ require ( golang.org/x/exp/typeparams v0.0.0-20230307190834-24139beb5833 // indirect golang.org/x/mod v0.14.0 // indirect golang.org/x/net v0.19.0 // indirect - golang.org/x/oauth2 v0.12.0 // indirect + golang.org/x/oauth2 v0.13.0 // indirect golang.org/x/sync v0.5.0 // indirect golang.org/x/sys v0.15.0 // indirect golang.org/x/term v0.15.0 // indirect golang.org/x/text v0.14.0 // indirect golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect google.golang.org/api v0.143.0 // indirect - google.golang.org/appengine v1.6.7 // indirect + google.golang.org/appengine v1.6.8 // indirect google.golang.org/genproto v0.0.0-20231030173426-d783a09b4405 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20231030173426-d783a09b4405 // indirect gopkg.in/ini.v1 v1.67.0 // indirect diff --git a/go.sum b/go.sum index 63430d2..36f31c5 100644 --- a/go.sum +++ b/go.sum @@ -1716,8 +1716,8 @@ golang.org/x/oauth2 v0.0.0-20221006150949-b44042a4b9c1/go.mod h1:h4gKUeWbJ4rQPri golang.org/x/oauth2 v0.0.0-20221014153046-6fdb5e3db783/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg= golang.org/x/oauth2 v0.1.0/go.mod h1:G9FE4dLTsbXUu90h/Pf85g4w1D+SSAgR+q46nJZ8M4A= golang.org/x/oauth2 v0.4.0/go.mod h1:RznEsdpjGAINPTOF0UH/t+xJ75L18YO3Ho6Pyn+uRec= -golang.org/x/oauth2 v0.12.0 h1:smVPGxink+n1ZI5pkQa8y6fZT0RW0MgCO5bFpepy4B4= -golang.org/x/oauth2 v0.12.0/go.mod h1:A74bZ3aGXgCY0qaIC9Ahg6Lglin4AMAco8cIv9baba4= +golang.org/x/oauth2 v0.13.0 h1:jDDenyj+WgFtmV3zYVoi8aE2BwtXFLWOA67ZfNWftiY= +golang.org/x/oauth2 v0.13.0/go.mod h1:/JMhi4ZRXAf4HG9LiNmxvk+45+96RUlVThiH8FzNBn0= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -2026,8 +2026,9 @@ google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7 google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c= google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= +google.golang.org/appengine v1.6.8 h1:IhEN5q69dyKagZPYMSdIjS2HqprW324FRQZJcGqPAsM= +google.golang.org/appengine v1.6.8/go.mod h1:1jJ3jBArFh5pcgW8gCtRJnepW8FzD1V44FJffLiz/Ds= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20180831171423-11092d34479b/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= @@ -2195,8 +2196,8 @@ google.golang.org/grpc v1.50.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCD google.golang.org/grpc v1.50.1/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= google.golang.org/grpc v1.51.0/go.mod h1:wgNDFcnuBGmxLKI/qn4T+m5BtEBYXJPvibbUPsAIPww= google.golang.org/grpc v1.54.0/go.mod h1:PUSEXI6iWghWaB6lXM4knEgpJNu2qUcKfDtNci3EC2g= -google.golang.org/grpc v1.59.0 h1:Z5Iec2pjwb+LEOqzpB2MR12/eKFhDPhuqW91O+4bwUk= -google.golang.org/grpc v1.59.0/go.mod h1:aUPDwccQo6OTjy7Hct4AfBPD1GptF4fyUjIkQ9YtF98= +google.golang.org/grpc v1.60.1 h1:26+wFr+cNqSGFcOXcabYC0lUVJVRa2Sb2ortSK7VrEU= +google.golang.org/grpc v1.60.1/go.mod h1:OlCHIeLYqSSsLi6i49B5QGdzaMZK9+M7LXN2FKz4eGM= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= @@ -2214,8 +2215,8 @@ google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQ google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= -google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= -google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I= +google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= 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/proto/feemarket/feemarket/v1/params.proto b/proto/feemarket/feemarket/v1/params.proto index e805912..9ad090b 100644 --- a/proto/feemarket/feemarket/v1/params.proto +++ b/proto/feemarket/feemarket/v1/params.proto @@ -66,20 +66,18 @@ message Params { (gogoproto.nullable) = false ]; - // TargetBlockUtilization is the target block utilization. + // TargetBlockUtilization is the target block utilization (in units of gas). + // This value MUST be lower than the consensus max gas parameter. uint64 target_block_utilization = 8; - // MaxBlockUtilization is the maximum block utilization. - uint64 max_block_utilization = 9; - - // Window defines the window size for calculating an adaptive learning rate - // over a moving window of blocks. - uint64 window = 10; + // WindowSize defines the window size for calculating an adaptive learning + // rate over a moving window of blocks. + uint64 window_size = 9; // FeeDenom is the denom that will be used for all fee payments. - string fee_denom = 11; + string fee_denom = 10; // Enabled is a boolean that determines whether the EIP1559 fee market is // enabled. - bool enabled = 12; + bool enabled = 11; } diff --git a/tests/app/app.go b/tests/app/app.go index 29af144..2297dfc 100644 --- a/tests/app/app.go +++ b/tests/app/app.go @@ -34,8 +34,6 @@ import ( bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" "github.com/cosmos/cosmos-sdk/x/consensus" consensuskeeper "github.com/cosmos/cosmos-sdk/x/consensus/keeper" - "github.com/cosmos/cosmos-sdk/x/crisis" - crisiskeeper "github.com/cosmos/cosmos-sdk/x/crisis/keeper" distr "github.com/cosmos/cosmos-sdk/x/distribution" distrkeeper "github.com/cosmos/cosmos-sdk/x/distribution/keeper" "github.com/cosmos/cosmos-sdk/x/evidence" @@ -96,7 +94,6 @@ var ( }, ), params.AppModuleBasic{}, - crisis.AppModuleBasic{}, slashing.AppModuleBasic{}, feegrantmodule.AppModuleBasic{}, upgrade.AppModuleBasic{}, @@ -132,7 +129,6 @@ type TestApp struct { MintKeeper mintkeeper.Keeper DistrKeeper distrkeeper.Keeper GovKeeper *govkeeper.Keeper - CrisisKeeper *crisiskeeper.Keeper UpgradeKeeper *upgradekeeper.Keeper ParamsKeeper paramskeeper.Keeper AuthzKeeper authzkeeper.Keeper @@ -210,7 +206,6 @@ func New( &app.MintKeeper, &app.DistrKeeper, &app.GovKeeper, - &app.CrisisKeeper, &app.UpgradeKeeper, &app.ParamsKeeper, &app.AuthzKeeper, @@ -292,8 +287,6 @@ func New( /**** Module Options ****/ - app.ModuleManager.RegisterInvariants(app.CrisisKeeper) - // RegisterUpgradeHandlers is used for registering any on-chain upgrades. // app.RegisterUpgradeHandlers() diff --git a/tests/app/config.go b/tests/app/config.go index cb34e1a..f4a1249 100644 --- a/tests/app/config.go +++ b/tests/app/config.go @@ -9,7 +9,6 @@ import ( authzmodulev1 "cosmossdk.io/api/cosmos/authz/module/v1" bankmodulev1 "cosmossdk.io/api/cosmos/bank/module/v1" consensusmodulev1 "cosmossdk.io/api/cosmos/consensus/module/v1" - crisismodulev1 "cosmossdk.io/api/cosmos/crisis/module/v1" distrmodulev1 "cosmossdk.io/api/cosmos/distribution/module/v1" evidencemodulev1 "cosmossdk.io/api/cosmos/evidence/module/v1" feegrantmodulev1 "cosmossdk.io/api/cosmos/feegrant/module/v1" @@ -30,7 +29,6 @@ import ( banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" consensustypes "github.com/cosmos/cosmos-sdk/x/consensus/types" - crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types" distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types" "github.com/cosmos/cosmos-sdk/x/feegrant" @@ -57,11 +55,11 @@ var ( // so that other modules that want to create or claim capabilities afterwards in InitChain // can do so safely. genesisModuleOrder = []string{ - capabilitytypes.ModuleName, authtypes.ModuleName, banktypes.ModuleName, feemarkettypes.ModuleName, + capabilitytypes.ModuleName, authtypes.ModuleName, banktypes.ModuleName, distrtypes.ModuleName, stakingtypes.ModuleName, slashingtypes.ModuleName, govtypes.ModuleName, - minttypes.ModuleName, crisistypes.ModuleName, genutiltypes.ModuleName, evidencetypes.ModuleName, authz.ModuleName, + minttypes.ModuleName, genutiltypes.ModuleName, evidencetypes.ModuleName, authz.ModuleName, feegrant.ModuleName, group.ModuleName, paramstypes.ModuleName, upgradetypes.ModuleName, - vestingtypes.ModuleName, consensustypes.ModuleName, + vestingtypes.ModuleName, consensustypes.ModuleName, feemarkettypes.ModuleName, } // module account permissions @@ -112,7 +110,6 @@ var ( authtypes.ModuleName, banktypes.ModuleName, govtypes.ModuleName, - crisistypes.ModuleName, genutiltypes.ModuleName, authz.ModuleName, feegrant.ModuleName, @@ -122,7 +119,6 @@ var ( consensustypes.ModuleName, }, EndBlockers: []string{ - crisistypes.ModuleName, govtypes.ModuleName, feemarkettypes.ModuleName, stakingtypes.ModuleName, @@ -231,10 +227,6 @@ var ( Name: govtypes.ModuleName, Config: appconfig.WrapAny(&govmodulev1.Module{}), }, - { - Name: crisistypes.ModuleName, - Config: appconfig.WrapAny(&crisismodulev1.Module{}), - }, { Name: consensustypes.ModuleName, Config: appconfig.WrapAny(&consensusmodulev1.Module{}), diff --git a/tests/app/export.go b/tests/app/export.go index 7cb309f..2b754d7 100644 --- a/tests/app/export.go +++ b/tests/app/export.go @@ -65,9 +65,6 @@ func (app *TestApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs [ allowedAddrsMap[addr] = true } - /* Just to be safe, assert the invariants on current state. */ - app.CrisisKeeper.AssertInvariants(ctx) - /* Handle fee distribution state. */ // withdraw all validator commission diff --git a/tests/app/feemarketd/cmd/root.go b/tests/app/feemarketd/cmd/root.go index 2b836f8..80c0812 100644 --- a/tests/app/feemarketd/cmd/root.go +++ b/tests/app/feemarketd/cmd/root.go @@ -22,7 +22,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli" "github.com/cosmos/cosmos-sdk/x/auth/types" - "github.com/cosmos/cosmos-sdk/x/crisis" genutilcli "github.com/cosmos/cosmos-sdk/x/genutil/client/cli" "github.com/spf13/cobra" "github.com/spf13/viper" @@ -31,6 +30,8 @@ import ( "github.com/skip-mev/feemarket/tests/app/params" ) +var flagCrisisDummy = "x-crisis-skip-assert-invariants" // dummy flag so that the crisis module does not need to be imported for security reasons + func NewRootCmd() *cobra.Command { // we "pre"-instantiate the application for getting the injected/configured encoding configuration simApp := app.New(log.NewNopLogger(), dbm.NewMemDB(), nil, true, simtestutil.NewAppOptionsWithFlagHome(app.DefaultNodeHome)) @@ -177,8 +178,8 @@ func initRootCmd(rootCmd *cobra.Command, encodingConfig params.EncodingConfig) { ) } -func addModuleInitFlags(startCmd *cobra.Command) { - crisis.AddModuleInitFlags(startCmd) +func addModuleInitFlags(cmd *cobra.Command) { + cmd.Flags().Bool(flagCrisisDummy, true, "dummy flag for crisis module") } func genesisCommand(encodingConfig params.EncodingConfig, cmds ...*cobra.Command) *cobra.Command { diff --git a/tests/integration/integration_test.go b/tests/integration/integration_test.go index 9e33cf3..64260c0 100644 --- a/tests/integration/integration_test.go +++ b/tests/integration/integration_test.go @@ -28,7 +28,6 @@ func TestIntegrationTestSuite(t *testing.T) { func (s *IntegrationTestSuite) SetupTest() { s.encCfg = encoding.MakeTestEncodingConfig(app.ModuleBasics.RegisterInterfaces) - s.ctx, s.TestKeepers, s.TestMsgServers = testkeeper.NewTestSetup(s.T()) } @@ -81,8 +80,7 @@ func (s *IntegrationTestSuite) TestParams() { MinLearningRate: math.LegacyMustNewDecFromStr("0.1"), MaxLearningRate: math.LegacyMustNewDecFromStr("0.1"), TargetBlockUtilization: 5, - MaxBlockUtilization: 10, - Window: 1, + WindowSize: 1, Enabled: true, } diff --git a/testutils/keeper/keeper.go b/testutils/keeper/keeper.go index a8c069a..9bc24c5 100644 --- a/testutils/keeper/keeper.go +++ b/testutils/keeper/keeper.go @@ -4,12 +4,15 @@ package keeper import ( "testing" + consensustypes "github.com/cosmos/cosmos-sdk/x/consensus/types" + "github.com/cometbft/cometbft/libs/log" tmproto "github.com/cometbft/cometbft/proto/tendermint/types" storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + consensuskeeper "github.com/cosmos/cosmos-sdk/x/consensus/keeper" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" testkeeper "github.com/skip-mev/chaintestutil/keeper" "github.com/stretchr/testify/require" @@ -22,6 +25,7 @@ import ( type TestKeepers struct { testkeeper.TestKeepers FeeMarketKeeper *feemarketkeeper.Keeper + ConsensusKeeper *consensuskeeper.Keeper } // TestMsgServers holds all message servers used during keeper tests for all modules @@ -35,6 +39,16 @@ var additionalMaccPerms = map[string][]string{ feemarkettypes.FeeCollectorName: {authtypes.Burner}, } +var ConsensusParams = &tmproto.ConsensusParams{ + Block: &tmproto.BlockParams{ + MaxBytes: 1_000_000, + MaxGas: int64(feemarkettypes.DefaultMaxBlockUtilization), + }, + Evidence: nil, + Validator: nil, + Version: nil, +} + // NewTestSetup returns initialized instances of all the keepers and message servers of the modules func NewTestSetup(t testing.TB, options ...testkeeper.SetupOption) (sdk.Context, TestKeepers, TestMsgServers) { options = append(options, testkeeper.WithAdditionalModuleAccounts(additionalMaccPerms)) @@ -42,7 +56,8 @@ func NewTestSetup(t testing.TB, options ...testkeeper.SetupOption) (sdk.Context, _, tk, tms := testkeeper.NewTestSetup(t, options...) // initialize extra keeper - feeMarketKeeper := FeeMarket(tk.Initializer, tk.AccountKeeper) + consensusKeeper := Consensus(tk.Initializer) + feeMarketKeeper := FeeMarket(tk.Initializer, tk.AccountKeeper, consensusKeeper) require.NoError(t, tk.Initializer.LoadLatest()) // initialize msg servers @@ -58,9 +73,13 @@ func NewTestSetup(t testing.TB, options ...testkeeper.SetupOption) (sdk.Context, err = feeMarketKeeper.SetParams(ctx, feemarkettypes.DefaultParams()) require.NoError(t, err) + // init dummy consensus params + consensusKeeper.Set(ctx, ConsensusParams) + testKeepers := TestKeepers{ TestKeepers: tk, FeeMarketKeeper: feeMarketKeeper, + ConsensusKeeper: consensusKeeper, } testMsgServers := TestMsgServers{ @@ -71,10 +90,27 @@ func NewTestSetup(t testing.TB, options ...testkeeper.SetupOption) (sdk.Context, return ctx, testKeepers, testMsgServers } +// Consensus initializes the consensus params module using the testkeepers intializer. +func Consensus( + initializer *testkeeper.Initializer, +) *consensuskeeper.Keeper { + storeKey := sdk.NewKVStoreKey(consensustypes.StoreKey) + initializer.StateStore.MountStoreWithDB(storeKey, storetypes.StoreTypeIAVL, initializer.DB) + + k := consensuskeeper.NewKeeper( + initializer.Codec, + storeKey, + authtypes.NewModuleAddress(govtypes.ModuleName).String(), + ) + + return &k +} + // FeeMarket initializes the fee market module using the testkeepers intializer. func FeeMarket( initializer *testkeeper.Initializer, authKeeper authkeeper.AccountKeeper, + consensusKeeper feemarkettypes.ConsensusKeeper, ) *feemarketkeeper.Keeper { storeKey := sdk.NewKVStoreKey(feemarkettypes.StoreKey) initializer.StateStore.MountStoreWithDB(storeKey, storetypes.StoreTypeIAVL, initializer.DB) @@ -83,6 +119,7 @@ func FeeMarket( initializer.Codec, storeKey, authKeeper, + consensusKeeper, authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) } diff --git a/testutils/networksuite/networksuite.go b/testutils/networksuite/networksuite.go index 64b82bb..3d4dd19 100644 --- a/testutils/networksuite/networksuite.go +++ b/testutils/networksuite/networksuite.go @@ -4,6 +4,9 @@ package networksuite import ( "math/rand" + tmproto "github.com/cometbft/cometbft/proto/tendermint/types" + consensustypes "github.com/cosmos/cosmos-sdk/x/consensus/types" + tmdb "github.com/cometbft/cometbft-db" tmrand "github.com/cometbft/cometbft/libs/rand" "github.com/cosmos/cosmos-sdk/baseapp" @@ -44,6 +47,7 @@ type NetworkTestSuite struct { Network *network.Network FeeMarketState feemarkettypes.GenesisState + ConsensusState *tmproto.ConsensusParams } // SetupSuite setups the local network with a genesis state. @@ -64,6 +68,9 @@ func (nts *NetworkTestSuite) SetupSuite() { nts.FeeMarketState = populateFeeMarket(r, nts.FeeMarketState) updateGenesisConfigState(feemarkettypes.ModuleName, &nts.FeeMarketState) + nts.ConsensusState = populateConsensus(r) + updateGenesisConfigState(consensustypes.ModuleName, nts.ConsensusState) + nts.Network = network.New(nts.T(), cfg) } @@ -71,3 +78,14 @@ func populateFeeMarket(_ *rand.Rand, feeMarketState feemarkettypes.GenesisState) // TODO intercept and populate state randomly if desired return feeMarketState } + +func populateConsensus(_ *rand.Rand) *tmproto.ConsensusParams { + consensusParams := new(tmproto.ConsensusParams) + + consensusParams.Block = &tmproto.BlockParams{ + MaxBytes: 1_000_000_000, + MaxGas: int64(feemarkettypes.DefaultMaxBlockUtilization), + } + + return consensusParams +} diff --git a/x/feemarket/ante/suite/suite.go b/x/feemarket/ante/suite/suite.go index 5390748..9454529 100644 --- a/x/feemarket/ante/suite/suite.go +++ b/x/feemarket/ante/suite/suite.go @@ -3,6 +3,8 @@ package suite import ( "testing" + tmproto "github.com/cometbft/cometbft/proto/tendermint/types" + "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/tx" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" @@ -71,7 +73,15 @@ func SetupTestSuite(t *testing.T, mock bool) *TestSuite { s.EncCfg = encoding.MakeTestEncodingConfig(app.ModuleBasics.RegisterInterfaces) ctx, testKeepers, _ := testkeeper.NewTestSetup(t) - s.Ctx = ctx + s.Ctx = ctx.WithConsensusParams(&tmproto.ConsensusParams{ + Block: &tmproto.BlockParams{ + MaxBytes: 0, + MaxGas: 1_000_000_000, + }, + Evidence: nil, + Validator: nil, + Version: nil, + }) s.AccountKeeper = testKeepers.AccountKeeper s.FeeMarketKeeper = testKeepers.FeeMarketKeeper @@ -89,6 +99,7 @@ func SetupTestSuite(t *testing.T, mock bool) *TestSuite { func (s *TestSuite) SetupHandlers(mock bool) { bankKeeper := s.BankKeeper feeGrantKeeper := s.FeeGrantKeeper + if mock { bankKeeper = s.MockBankKeeper feeGrantKeeper = s.MockFeeGrantKeeper @@ -194,6 +205,17 @@ func (s *TestSuite) RunTestCase(t *testing.T, tc TestCase, args TestCaseArgs) { t.Fatal("expected one of txErr, handleErr to be an error") } } + + // reset consensus params + s.Ctx = s.Ctx.WithConsensusParams(&tmproto.ConsensusParams{ + Block: &tmproto.BlockParams{ + MaxBytes: 0, + MaxGas: 1_000_000_000, + }, + Evidence: nil, + Validator: nil, + Version: nil, + }) } // CreateTestTx is a helper function to create a tx given multiple inputs. diff --git a/x/feemarket/fuzz/aimd_eip1559_test.go b/x/feemarket/fuzz/aimd_eip1559_test.go index d72101f..eefe5e4 100644 --- a/x/feemarket/fuzz/aimd_eip1559_test.go +++ b/x/feemarket/fuzz/aimd_eip1559_test.go @@ -24,10 +24,11 @@ func TestAIMDLearningRate(t *testing.T) { state.Window = make([]uint64, window) params := CreateRandomAIMDParams(t) + maxBlockUtilization := rapid.Uint64Range(params.TargetBlockUtilization, params.TargetBlockUtilization*5).Draw(t, "max_block_utilization") // Randomly generate the block utilization. numBlocks := rapid.Uint64Range(0, 1000).Draw(t, "num_blocks") - gasGen := rapid.Uint64Range(0, params.MaxBlockUtilization) + gasGen := rapid.Uint64Range(0, maxBlockUtilization) // Update the fee market. for i := uint64(0); i < numBlocks; i++ { @@ -35,13 +36,13 @@ func TestAIMDLearningRate(t *testing.T) { prevLearningRate := state.LearningRate // Update the fee market. - if err := state.Update(blockUtilization, params); err != nil { + if err := state.Update(blockUtilization, maxBlockUtilization); err != nil { t.Fatalf("block update errors: %v", err) } // Update the learning rate. - lr := state.UpdateLearningRate(params) - utilization := state.GetAverageUtilization(params) + lr := state.UpdateLearningRate(params, maxBlockUtilization) + utilization := state.GetAverageUtilization(maxBlockUtilization) // Ensure that the learning rate is always bounded. require.True(t, lr.GTE(params.MinLearningRate)) @@ -70,22 +71,23 @@ func TestAIMDBaseFee(t *testing.T) { state.Window = make([]uint64, window) params := CreateRandomAIMDParams(t) + maxBlockUtilization := rapid.Uint64Range(params.TargetBlockUtilization, params.TargetBlockUtilization*5).Draw(t, "max_block_utilization") // Randomly generate the block utilization. numBlocks := rapid.Uint64Range(0, uint64(window)*10).Draw(t, "num_blocks") - gasGen := rapid.Uint64Range(0, params.MaxBlockUtilization) + gasGen := rapid.Uint64Range(0, maxBlockUtilization) // Update the fee market. for i := uint64(0); i < numBlocks; i++ { blockUtilization := gasGen.Draw(t, "gas") prevBaseFee := state.BaseFee - if err := state.Update(blockUtilization, params); err != nil { + if err := state.Update(blockUtilization, maxBlockUtilization); err != nil { t.Fatalf("block update errors: %v", err) } // Update the learning rate. - state.UpdateLearningRate(params) + state.UpdateLearningRate(params, maxBlockUtilization) // Update the base fee. state.UpdateBaseFee(params) @@ -133,14 +135,12 @@ func CreateRandomAIMDParams(t *rapid.T) types.Params { delta := math.LegacyNewDec(int64(d)).Quo(math.LegacyNewDec(1000)) targetBlockUtilization := rapid.Uint64Range(1, 30_000_000).Draw(t, "target_block_utilization") - maxBlockUtilization := rapid.Uint64Range(targetBlockUtilization, targetBlockUtilization*5).Draw(t, "max_block_utilization") params := types.DefaultAIMDParams() params.Alpha = alpha params.Beta = beta params.Theta = theta params.Delta = delta - params.MaxBlockUtilization = maxBlockUtilization params.TargetBlockUtilization = targetBlockUtilization return params diff --git a/x/feemarket/fuzz/eip1559_test.go b/x/feemarket/fuzz/eip1559_test.go index 58e8bb1..c4cf558 100644 --- a/x/feemarket/fuzz/eip1559_test.go +++ b/x/feemarket/fuzz/eip1559_test.go @@ -20,16 +20,17 @@ func TestLearningRate(t *testing.T) { // Randomly generate alpha and beta. prevLearningRate := state.LearningRate + maxBlockUtilization := rapid.Uint64Range(params.TargetBlockUtilization, params.TargetBlockUtilization*5).Draw(t, "max_block_utilization") + // Randomly generate the block utilization. - blockUtilization := rapid.Uint64Range(0, params.MaxBlockUtilization).Draw(t, "gas") + blockUtilization := rapid.Uint64Range(0, maxBlockUtilization).Draw(t, "gas") // Update the fee market. - if err := state.Update(blockUtilization, params); err != nil { + if err := state.Update(blockUtilization, maxBlockUtilization); err != nil { t.Fatalf("block update errors: %v", err) } - // Update the learning rate. - lr := state.UpdateLearningRate(params) + lr := state.UpdateLearningRate(params, maxBlockUtilization) require.Equal(t, types.DefaultMinLearningRate, lr) require.Equal(t, prevLearningRate, state.LearningRate) }) @@ -46,16 +47,18 @@ func TestBaseFee(t *testing.T) { prevBaseFee := state.BaseFee.Mul(math.NewInt(11)).Quo(math.NewInt(10)) state.BaseFee = prevBaseFee + maxBlockUtilization := rapid.Uint64Range(params.TargetBlockUtilization, params.TargetBlockUtilization*5).Draw(t, "max_block_utilization") + // Randomly generate the block utilization. - blockUtilization := rapid.Uint64Range(0, params.MaxBlockUtilization).Draw(t, "gas") + blockUtilization := rapid.Uint64Range(0, maxBlockUtilization).Draw(t, "gas") // Update the fee market. - if err := state.Update(blockUtilization, params); err != nil { + if err := state.Update(blockUtilization, maxBlockUtilization); err != nil { t.Fatalf("block update errors: %v", err) } // Update the learning rate. - state.UpdateLearningRate(params) + state.UpdateLearningRate(params, maxBlockUtilization) // Update the base fee. state.UpdateBaseFee(params) @@ -86,13 +89,11 @@ func CreateRandomParams(t *rapid.T) types.Params { theta := math.LegacyNewDec(int64(th)).Quo(math.LegacyNewDec(100)) targetBlockUtilization := rapid.Uint64Range(1, 30_000_000).Draw(t, "target_block_utilization") - maxBlockUtilization := rapid.Uint64Range(targetBlockUtilization, targetBlockUtilization*5).Draw(t, "max_block_utilization") params := types.DefaultParams() params.Alpha = alpha params.Beta = beta params.Theta = theta - params.MaxBlockUtilization = maxBlockUtilization params.TargetBlockUtilization = targetBlockUtilization return params diff --git a/x/feemarket/keeper/feemarket.go b/x/feemarket/keeper/feemarket.go index d95d725..3d16ba9 100644 --- a/x/feemarket/keeper/feemarket.go +++ b/x/feemarket/keeper/feemarket.go @@ -25,10 +25,17 @@ func (k *Keeper) UpdateFeeMarket(ctx sdk.Context) error { return err } + maxGas, err := k.GetMaxGasUtilization(ctx) + if err != nil { + k.Logger(ctx).Error("unable to get consensus params", "error", err) + return err + } + // Update the learning rate based on the block utilization seen in the // current block. This is the AIMD learning rate adjustment algorithm. newLR := state.UpdateLearningRate( params, + uint64(maxGas), ) // Update the base fee based with the new learning rate and delta adjustment. @@ -39,7 +46,7 @@ func (k *Keeper) UpdateFeeMarket(ctx sdk.Context) error { "height", ctx.BlockHeight(), "new_base_fee", newBaseFee, "new_learning_rate", newLR, - "average_block_utilization", state.GetAverageUtilization(params), + "average_block_utilization", state.GetAverageUtilization(uint64(maxGas)), "net_block_utilization", state.GetNetUtilization(params), ) diff --git a/x/feemarket/keeper/feemarket_test.go b/x/feemarket/keeper/feemarket_test.go index 2b94c69..2fdad9b 100644 --- a/x/feemarket/keeper/feemarket_test.go +++ b/x/feemarket/keeper/feemarket_test.go @@ -74,7 +74,7 @@ func (s *KeeperTestSuite) TestUpdateFeeMarket() { // Reaching the target block size means that we expect this to not // increase. - err := state.Update(params.TargetBlockUtilization, params) + err := state.Update(params.TargetBlockUtilization, types.DefaultMaxBlockUtilization) s.Require().NoError(err) s.setGenesisState(params, state) @@ -98,7 +98,7 @@ func (s *KeeperTestSuite) TestUpdateFeeMarket() { state.BaseFee = state.BaseFee.Mul(math.NewInt(2)) // Reaching the target block size means that we expect this to not // increase. - err := state.Update(params.TargetBlockUtilization, params) + err := state.Update(params.TargetBlockUtilization, types.DefaultMaxBlockUtilization) s.Require().NoError(err) s.setGenesisState(params, state) @@ -121,7 +121,7 @@ func (s *KeeperTestSuite) TestUpdateFeeMarket() { // Reaching the target block size means that we expect this to not // increase. - err := state.Update(params.MaxBlockUtilization, params) + err := state.Update(types.DefaultMaxBlockUtilization, types.DefaultMaxBlockUtilization) s.Require().NoError(err) s.setGenesisState(params, state) @@ -148,7 +148,7 @@ func (s *KeeperTestSuite) TestUpdateFeeMarket() { state.BaseFee = state.BaseFee.Mul(math.NewInt(2)) // Reaching the target block size means that we expect this to not // increase. - err := state.Update(params.MaxBlockUtilization, params) + err := state.Update(types.DefaultMaxBlockUtilization, types.DefaultMaxBlockUtilization) s.Require().NoError(err) s.setGenesisState(params, state) @@ -171,10 +171,13 @@ func (s *KeeperTestSuite) TestUpdateFeeMarket() { s.Run("in-between min and target block with default eip1559 at min base fee", func() { state := types.DefaultState() params := types.DefaultParams() - params.MaxBlockUtilization = 100 - params.TargetBlockUtilization = 50 + maxGas, err := s.feeMarketKeeper.GetMaxGasUtilization(s.ctx) + s.Require().NoError(err) + + maxUtilization := uint64(maxGas) + params.TargetBlockUtilization = maxUtilization / 2 - err := state.Update(25, params) + err = state.Update(maxUtilization/4, maxUtilization) s.Require().NoError(err) s.setGenesisState(params, state) @@ -194,12 +197,13 @@ func (s *KeeperTestSuite) TestUpdateFeeMarket() { s.Run("in-between min and target block with default eip1559 at preset base fee", func() { state := types.DefaultState() state.BaseFee = state.BaseFee.Mul(math.NewInt(2)) + maxGas, err := s.feeMarketKeeper.GetMaxGasUtilization(s.ctx) + s.Require().NoError(err) params := types.DefaultParams() - params.MaxBlockUtilization = 100 - params.TargetBlockUtilization = 50 - err := state.Update(25, params) - + maxUtilization := uint64(maxGas) + params.TargetBlockUtilization = maxUtilization / 2 + err = state.Update(maxUtilization/4, maxUtilization) s.Require().NoError(err) s.setGenesisState(params, state) @@ -222,10 +226,13 @@ func (s *KeeperTestSuite) TestUpdateFeeMarket() { s.Run("in-between target and max block with default eip1559 at min base fee", func() { state := types.DefaultState() params := types.DefaultParams() - params.MaxBlockUtilization = 100 - params.TargetBlockUtilization = 50 + maxGas, err := s.feeMarketKeeper.GetMaxGasUtilization(s.ctx) + s.Require().NoError(err) + maxUtilization := uint64(maxGas) + + params.TargetBlockUtilization = maxUtilization / 2 - err := state.Update(75, params) + err = state.Update((maxUtilization*3)/4, maxUtilization) s.Require().NoError(err) s.setGenesisState(params, state) @@ -249,10 +256,13 @@ func (s *KeeperTestSuite) TestUpdateFeeMarket() { state := types.DefaultState() state.BaseFee = state.BaseFee.Mul(math.NewInt(2)) params := types.DefaultParams() - params.MaxBlockUtilization = 100 - params.TargetBlockUtilization = 50 + maxGas, err := s.feeMarketKeeper.GetMaxGasUtilization(s.ctx) + s.Require().NoError(err) + maxUtilization := uint64(maxGas) + + params.TargetBlockUtilization = maxUtilization / 2 - err := state.Update(75, params) + err = state.Update((maxUtilization*3)/4, maxUtilization) s.Require().NoError(err) s.setGenesisState(params, state) diff --git a/x/feemarket/keeper/genesis.go b/x/feemarket/keeper/genesis.go index 5226c82..0fa3f9b 100644 --- a/x/feemarket/keeper/genesis.go +++ b/x/feemarket/keeper/genesis.go @@ -1,6 +1,8 @@ package keeper import ( + "fmt" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/skip-mev/feemarket/x/feemarket/types" @@ -12,10 +14,27 @@ func (k *Keeper) InitGenesis(ctx sdk.Context, gs types.GenesisState) { panic(err) } - if gs.Params.Window != uint64(len(gs.State.Window)) { + if gs.Params.WindowSize != uint64(len(gs.State.Window)) { panic("genesis state and parameters do not match for window") } + maxGas, err := k.GetMaxGasUtilization(ctx) + if err != nil { + panic("unable to get consensus params. ensure that the feemarket module is initialized after the consensus params module") + } + + maxUtilization := uint64(maxGas) + if gs.Params.TargetBlockUtilization > maxUtilization { + panic(fmt.Sprintf("target block size of %d cannot be greater than max block size of %d", gs.Params.TargetBlockUtilization, maxUtilization)) + } + + if maxUtilization/gs.Params.TargetBlockUtilization > types.MaxBlockUtilizationRatio { + panic(fmt.Sprintf("max block size of %d cannot be greater than target block of %d size times %d", + maxUtilization, + gs.Params.TargetBlockUtilization, + types.MaxBlockUtilizationRatio, + )) + } // Initialize the fee market state and parameters. if err := k.SetParams(ctx, gs.Params); err != nil { panic(err) diff --git a/x/feemarket/keeper/genesis_test.go b/x/feemarket/keeper/genesis_test.go index ef5976b..8774d6c 100644 --- a/x/feemarket/keeper/genesis_test.go +++ b/x/feemarket/keeper/genesis_test.go @@ -19,7 +19,7 @@ func (s *KeeperTestSuite) TestInitGenesis() { s.Run("bad genesis state should panic", func() { gs := types.DefaultGenesisState() - gs.Params.Window = 0 + gs.Params.WindowSize = 0 s.Require().Panics(func() { s.feeMarketKeeper.InitGenesis(s.ctx, *gs) }) @@ -27,7 +27,7 @@ func (s *KeeperTestSuite) TestInitGenesis() { s.Run("mismatch in params and state for window should panic", func() { gs := types.DefaultAIMDGenesisState() - gs.Params.Window = 1 + gs.Params.WindowSize = 1 s.Require().Panics(func() { s.feeMarketKeeper.InitGenesis(s.ctx, *gs) diff --git a/x/feemarket/keeper/keeper.go b/x/feemarket/keeper/keeper.go index 8522d66..1585daf 100644 --- a/x/feemarket/keeper/keeper.go +++ b/x/feemarket/keeper/keeper.go @@ -15,6 +15,7 @@ type Keeper struct { cdc codec.BinaryCodec storeKey storetypes.StoreKey ak types.AccountKeeper + cpk types.ConsensusKeeper // The address that is capable of executing a MsgParams message. // Typically, this will be the governance module's address. @@ -26,16 +27,26 @@ func NewKeeper( cdc codec.BinaryCodec, storeKey storetypes.StoreKey, authKeeper types.AccountKeeper, + consensusKeeper types.ConsensusKeeper, authority string, ) *Keeper { if _, err := sdk.AccAddressFromBech32(authority); err != nil { panic(fmt.Sprintf("invalid authority address: %s", authority)) } + if authKeeper == nil { + panic("authkeeper cannot be nil") + } + + if consensusKeeper == nil { + panic("consensuskeeper cannot be nil") + } + k := &Keeper{ cdc, storeKey, authKeeper, + consensusKeeper, authority, } @@ -47,6 +58,20 @@ func (k *Keeper) Logger(ctx sdk.Context) log.Logger { return ctx.Logger().With("module", "x/"+types.ModuleName) } +// GetMaxGasUtilization returns the MaxGas parameter from the consensus params keeper. +func (k *Keeper) GetMaxGasUtilization(ctx sdk.Context) (int64, error) { + consensusParams, err := k.cpk.Get(ctx) + if err != nil { + return -1, fmt.Errorf("unable to get consensus params. ensure that the feemarket module is initialized after the consensus params module: %w", err) + } + + if consensusParams == nil { + return -1, fmt.Errorf("got nil consensus params") + } + + return consensusParams.Block.MaxGas, nil +} + // GetAuthority returns the address that is capable of executing a MsgUpdateParams message. func (k *Keeper) GetAuthority() string { return k.authority diff --git a/x/feemarket/keeper/keeper_test.go b/x/feemarket/keeper/keeper_test.go index e7c64d4..347b622 100644 --- a/x/feemarket/keeper/keeper_test.go +++ b/x/feemarket/keeper/keeper_test.go @@ -3,6 +3,8 @@ package keeper_test import ( "testing" + tmproto "github.com/cometbft/cometbft/proto/tendermint/types" + "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" @@ -43,7 +45,15 @@ func (s *KeeperTestSuite) SetupTest() { s.accountKeeper = mocks.NewAccountKeeper(s.T()) ctx, tk, tm := testkeeper.NewTestSetup(s.T()) - s.ctx = ctx + s.ctx = ctx.WithConsensusParams(&tmproto.ConsensusParams{ + Block: &tmproto.BlockParams{ + MaxBytes: 0, + MaxGas: int64(types.DefaultMaxBlockUtilization), + }, + Evidence: nil, + Validator: nil, + Version: nil, + }) s.feeMarketKeeper = tk.FeeMarketKeeper s.msgServer = tm.FeeMarketMsgServer s.queryServer = keeper.NewQueryServer(*s.feeMarketKeeper) @@ -98,8 +108,7 @@ func (s *KeeperTestSuite) TestParams() { MinLearningRate: math.LegacyMustNewDecFromStr("0.1"), MaxLearningRate: math.LegacyMustNewDecFromStr("0.1"), TargetBlockUtilization: 5, - MaxBlockUtilization: 10, - Window: 1, + WindowSize: 1, Enabled: true, } diff --git a/x/feemarket/keeper/msg_server.go b/x/feemarket/keeper/msg_server.go index 4403249..d8dd883 100644 --- a/x/feemarket/keeper/msg_server.go +++ b/x/feemarket/keeper/msg_server.go @@ -30,12 +30,26 @@ func (ms MsgServer) Params(goCtx context.Context, msg *types.MsgParams) (*types. return nil, fmt.Errorf("invalid authority to execute message") } + maxGas, err := ms.k.GetMaxGasUtilization(ctx) + if err != nil { + return nil, fmt.Errorf("unable to get consensus params: %w", err) + } + + maxUtilization := uint64(maxGas) + if msg.Params.TargetBlockUtilization > maxUtilization { + return nil, fmt.Errorf("target block size of %d cannot be greater than max block size of %d", msg.Params.TargetBlockUtilization, maxUtilization) + } + + if maxUtilization/msg.Params.TargetBlockUtilization > types.MaxBlockUtilizationRatio { + return nil, fmt.Errorf(fmt.Sprintf("max block size cannot be greater than target block size times %d", types.MaxBlockUtilizationRatio)) + } + params := msg.Params if err := ms.k.SetParams(ctx, params); err != nil { return nil, fmt.Errorf("error setting params: %w", err) } - newState := types.NewState(params.Window, params.MinBaseFee, params.MinLearningRate) + newState := types.NewState(params.WindowSize, params.MinBaseFee, params.MinLearningRate) if err := ms.k.SetState(ctx, newState); err != nil { return nil, fmt.Errorf("error setting state: %w", err) } diff --git a/x/feemarket/keeper/msg_server_test.go b/x/feemarket/keeper/msg_server_test.go index 57cbd1e..a363cce 100644 --- a/x/feemarket/keeper/msg_server_test.go +++ b/x/feemarket/keeper/msg_server_test.go @@ -5,19 +5,6 @@ import ( ) func (s *KeeperTestSuite) TestMsgParams() { - s.Run("accepts a req with no params", func() { - req := &types.MsgParams{ - Authority: s.authorityAccount.String(), - } - resp, err := s.msgServer.Params(s.ctx, req) - s.Require().NoError(err) - s.Require().NotNil(resp) - - params, err := s.feeMarketKeeper.GetParams(s.ctx) - s.Require().NoError(err) - s.Require().False(params.Enabled) - }) - s.Run("accepts a req with params", func() { req := &types.MsgParams{ Authority: s.authorityAccount.String(), @@ -47,13 +34,13 @@ func (s *KeeperTestSuite) TestMsgParams() { state, err := s.feeMarketKeeper.GetState(s.ctx) s.Require().NoError(err) - err = state.Update(params.MaxBlockUtilization, params) + err = state.Update(types.DefaultMaxBlockUtilization, types.DefaultMaxBlockUtilization) s.Require().NoError(err) err = s.feeMarketKeeper.SetState(s.ctx, state) s.Require().NoError(err) - params.Window = 100 + params.WindowSize = 100 req := &types.MsgParams{ Authority: s.authorityAccount.String(), Params: params, @@ -63,7 +50,7 @@ func (s *KeeperTestSuite) TestMsgParams() { state, err = s.feeMarketKeeper.GetState(s.ctx) s.Require().NoError(err) - s.Require().Equal(params.Window, uint64(len(state.Window))) + s.Require().Equal(params.WindowSize, uint64(len(state.Window))) s.Require().Equal(state.Window[0], uint64(0)) }) } diff --git a/x/feemarket/keeper/query_server_test.go b/x/feemarket/keeper/query_server_test.go index 23aac7c..4ce45c6 100644 --- a/x/feemarket/keeper/query_server_test.go +++ b/x/feemarket/keeper/query_server_test.go @@ -31,8 +31,7 @@ func (s *KeeperTestSuite) TestParamsRequest() { MinLearningRate: math.LegacyMustNewDecFromStr("0.1"), MaxLearningRate: math.LegacyMustNewDecFromStr("0.1"), TargetBlockUtilization: 5, - MaxBlockUtilization: 10, - Window: 1, + WindowSize: 1, Enabled: true, } err := s.feeMarketKeeper.SetParams(s.ctx, params) diff --git a/x/feemarket/module.go b/x/feemarket/module.go index d531d9a..dda37fe 100644 --- a/x/feemarket/module.go +++ b/x/feemarket/module.go @@ -3,7 +3,6 @@ package feemarket import ( "context" "encoding/json" - abci "github.com/cometbft/cometbft/abci/types" "cosmossdk.io/core/appmodule" @@ -81,16 +80,25 @@ func (amb AppModuleBasic) GetQueryCmd() *cobra.Command { type AppModule struct { AppModuleBasic - k keeper.Keeper + k keeper.Keeper + accountKeeper types.AccountKeeper + consensusParamsKeeper types.ConsensusKeeper } // NewAppModule returns an application module for the x/feemarket module. -func NewAppModule(cdc codec.Codec, k keeper.Keeper) AppModule { +func NewAppModule( + cdc codec.Codec, + k keeper.Keeper, + accountKeeper types.AccountKeeper, + consensusParamsKeeper types.ConsensusKeeper, +) AppModule { return AppModule{ AppModuleBasic: AppModuleBasic{ cdc: cdc, }, - k: k, + k: k, + accountKeeper: accountKeeper, + consensusParamsKeeper: consensusParamsKeeper, } } @@ -158,10 +166,11 @@ func init() { type Inputs struct { depinject.In - Config *modulev1.Module - Cdc codec.Codec - Key *store.KVStoreKey - AccountKeeper types.AccountKeeper + Config *modulev1.Module + Cdc codec.Codec + Key *store.KVStoreKey + AccountKeeper types.AccountKeeper + ConsensusKeeper types.ConsensusKeeper } type Outputs struct { @@ -189,10 +198,11 @@ func ProvideModule(in Inputs) Outputs { in.Cdc, in.Key, in.AccountKeeper, + in.ConsensusKeeper, authority.String(), ) - m := NewAppModule(in.Cdc, *Keeper) + m := NewAppModule(in.Cdc, *Keeper, in.AccountKeeper, in.ConsensusKeeper) return Outputs{Keeper: *Keeper, Module: m} } diff --git a/x/feemarket/post/expected_keeper.go b/x/feemarket/post/expected_keeper.go index dfa94ff..b73534f 100644 --- a/x/feemarket/post/expected_keeper.go +++ b/x/feemarket/post/expected_keeper.go @@ -45,4 +45,5 @@ type FeeMarketKeeper interface { SetParams(ctx sdk.Context, params feemarkettypes.Params) error SetState(ctx sdk.Context, state feemarkettypes.State) error GetMinGasPrices(ctx sdk.Context) (sdk.Coins, error) + GetMaxGasUtilization(ctx sdk.Context) (int64, error) } diff --git a/x/feemarket/post/fee.go b/x/feemarket/post/fee.go index 1e308f0..3e0e795 100644 --- a/x/feemarket/post/fee.go +++ b/x/feemarket/post/fee.go @@ -99,9 +99,14 @@ func (dfd FeeMarketDeductDecorator) PostHandle(ctx sdk.Context, tx sdk.Tx, simul return ctx, err } - err = state.Update(gas, params) + maxGas, err := dfd.feemarketKeeper.GetMaxGasUtilization(ctx) if err != nil { - return ctx, errorsmod.Wrapf(err, "unable to update fee market state") + return ctx, errorsmod.Wrapf(err, "unable to get max gas parameter") + } + + err = state.Update(gas, uint64(maxGas)) + if err != nil { + return ctx, errorsmod.Wrapf(sdkerrors.ErrTxTooLarge, err.Error()) } err = dfd.feemarketKeeper.SetState(ctx, state) diff --git a/x/feemarket/post/fee_test.go b/x/feemarket/post/fee_test.go index 79334b8..8d4113c 100644 --- a/x/feemarket/post/fee_test.go +++ b/x/feemarket/post/fee_test.go @@ -4,6 +4,8 @@ import ( "fmt" "testing" + testkeeper "github.com/skip-mev/feemarket/testutils/keeper" + "github.com/cosmos/cosmos-sdk/testutil/testdata" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/stretchr/testify/mock" @@ -143,6 +145,26 @@ func TestPostHandle(t *testing.T) { ExpPass: false, ExpErr: sdkerrors.ErrInvalidGasLimit, }, + { + Name: "using consensus params for max gas override - valid)", + Malleate: func(s *antesuite.TestSuite) antesuite.TestCaseArgs { + accs := s.CreateTestAccounts(1) + s.MockBankKeeper.On("SendCoinsFromAccountToModule", mock.Anything, accs[0].Account.GetAddress(), types.FeeCollectorName, mock.Anything).Return(nil) + params := testkeeper.ConsensusParams + params.Block.MaxGas = int64(gasLimit - 1) + + return antesuite.TestCaseArgs{ + Msgs: []sdk.Msg{testdata.NewTestMsg(accs[0].Account.GetAddress())}, + GasLimit: gasLimit, + FeeAmount: validFee, + } + }, + RunAnte: true, + RunPost: true, + Simulate: false, + ExpPass: true, + ExpErr: nil, + }, { Name: "signer has enough funds, should pass, no tip", Malleate: func(s *antesuite.TestSuite) antesuite.TestCaseArgs { diff --git a/x/feemarket/post/mocks/mock_feemarket_keeper.go b/x/feemarket/post/mocks/mock_feemarket_keeper.go index ccdd104..4e0c6f3 100644 --- a/x/feemarket/post/mocks/mock_feemarket_keeper.go +++ b/x/feemarket/post/mocks/mock_feemarket_keeper.go @@ -41,6 +41,30 @@ func (_m *FeeMarketKeeper) GetMinGasPrices(ctx types.Context) (types.Coins, erro return r0, r1 } +// GetParams provides a mock function with given fields: ctx +func (_m *FeeMarketKeeper) GetParams(ctx types.Context) (feemarkettypes.Params, error) { + ret := _m.Called(ctx) + + var r0 feemarkettypes.Params + var r1 error + if rf, ok := ret.Get(0).(func(types.Context) (feemarkettypes.Params, error)); ok { + return rf(ctx) + } + if rf, ok := ret.Get(0).(func(types.Context) feemarkettypes.Params); ok { + r0 = rf(ctx) + } else { + r0 = ret.Get(0).(feemarkettypes.Params) + } + + if rf, ok := ret.Get(1).(func(types.Context) error); ok { + r1 = rf(ctx) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + // GetState provides a mock function with given fields: ctx func (_m *FeeMarketKeeper) GetState(ctx types.Context) (feemarkettypes.State, error) { ret := _m.Called(ctx) @@ -65,6 +89,20 @@ func (_m *FeeMarketKeeper) GetState(ctx types.Context) (feemarkettypes.State, er return r0, r1 } +// SetParams provides a mock function with given fields: ctx, params +func (_m *FeeMarketKeeper) SetParams(ctx types.Context, params feemarkettypes.Params) error { + ret := _m.Called(ctx, params) + + var r0 error + if rf, ok := ret.Get(0).(func(types.Context, feemarkettypes.Params) error); ok { + r0 = rf(ctx, params) + } else { + r0 = ret.Error(0) + } + + return r0 +} + // SetState provides a mock function with given fields: ctx, state func (_m *FeeMarketKeeper) SetState(ctx types.Context, state feemarkettypes.State) error { ret := _m.Called(ctx, state) diff --git a/x/feemarket/types/eip1559.go b/x/feemarket/types/eip1559.go index 0dae6e1..a5030bd 100644 --- a/x/feemarket/types/eip1559.go +++ b/x/feemarket/types/eip1559.go @@ -61,7 +61,6 @@ func DefaultParams() Params { DefaultTheta, DefaultDelta, DefaultTargetBlockUtilization, - DefaultMaxBlockUtilization, DefaultMinBaseFee, DefaultMinLearningRate, DefaultMaxLearningRate, diff --git a/x/feemarket/types/eip1559_aimd.go b/x/feemarket/types/eip1559_aimd.go index 39c62c8..b1f892a 100644 --- a/x/feemarket/types/eip1559_aimd.go +++ b/x/feemarket/types/eip1559_aimd.go @@ -70,7 +70,6 @@ func DefaultAIMDParams() Params { DefaultAIMDTheta, DefaultAIMDDelta, DefaultAIMDTargetBlockSize, - DefaultAIMDMaxBlockSize, DefaultAIMDMinBaseFee, DefaultAIMDMinLearningRate, DefaultAIMDMaxLearningRate, diff --git a/x/feemarket/types/expected_keepers.go b/x/feemarket/types/expected_keepers.go index b455992..35358f5 100644 --- a/x/feemarket/types/expected_keepers.go +++ b/x/feemarket/types/expected_keepers.go @@ -1,6 +1,7 @@ package types import ( + tmproto "github.com/cometbft/cometbft/proto/tendermint/types" sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" ) @@ -13,3 +14,10 @@ type AccountKeeper interface { GetModuleAddress(name string) sdk.AccAddress GetModuleAccount(ctx sdk.Context, name string) authtypes.ModuleAccountI } + +// ConsensusKeeper defines the expected consensus keeper (noalias) +// +//go:generate mockery --name ConsensusKeeper --filename mock_consensus_keeper.go +type ConsensusKeeper interface { + Get(ctx sdk.Context) (*tmproto.ConsensusParams, error) +} diff --git a/x/feemarket/types/mocks/mock_account_keeper.go b/x/feemarket/types/mocks/mock_account_keeper.go index a4f040a..45470f3 100644 --- a/x/feemarket/types/mocks/mock_account_keeper.go +++ b/x/feemarket/types/mocks/mock_account_keeper.go @@ -68,8 +68,7 @@ func (_m *AccountKeeper) GetModuleAddress(name string) types.AccAddress { func NewAccountKeeper(t interface { mock.TestingT Cleanup(func()) -}, -) *AccountKeeper { +}) *AccountKeeper { mock := &AccountKeeper{} mock.Mock.Test(t) diff --git a/x/feemarket/types/mocks/mock_consensus_keeper.go b/x/feemarket/types/mocks/mock_consensus_keeper.go new file mode 100644 index 0000000..0be3217 --- /dev/null +++ b/x/feemarket/types/mocks/mock_consensus_keeper.go @@ -0,0 +1,54 @@ +// Code generated by mockery v0.0.0-dev. DO NOT EDIT. + +package mocks + +import ( + tenderminttypes "github.com/cometbft/cometbft/proto/tendermint/types" + types "github.com/cosmos/cosmos-sdk/types" + mock "github.com/stretchr/testify/mock" +) + +// ConsensusKeeper is an autogenerated mock type for the ConsensusKeeper type +type ConsensusKeeper struct { + mock.Mock +} + +// Get provides a mock function with given fields: ctx +func (_m *ConsensusKeeper) Get(ctx types.Context) (*tenderminttypes.ConsensusParams, error) { + ret := _m.Called(ctx) + + var r0 *tenderminttypes.ConsensusParams + var r1 error + if rf, ok := ret.Get(0).(func(types.Context) (*tenderminttypes.ConsensusParams, error)); ok { + return rf(ctx) + } + if rf, ok := ret.Get(0).(func(types.Context) *tenderminttypes.ConsensusParams); ok { + r0 = rf(ctx) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*tenderminttypes.ConsensusParams) + } + } + + if rf, ok := ret.Get(1).(func(types.Context) error); ok { + r1 = rf(ctx) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// NewConsensusKeeper creates a new instance of ConsensusKeeper. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewConsensusKeeper(t interface { + mock.TestingT + Cleanup(func()) +}) *ConsensusKeeper { + mock := &ConsensusKeeper{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/x/feemarket/types/params.go b/x/feemarket/types/params.go index a268b6d..ceb22be 100644 --- a/x/feemarket/types/params.go +++ b/x/feemarket/types/params.go @@ -14,13 +14,12 @@ const MaxBlockUtilizationRatio = 10 // NewParams instantiates a new EIP-1559 Params object. This params object is utilized // to implement both the base EIP-1559 fee and AIMD EIP-1559 fee market implementations. func NewParams( - window uint64, + windowSize uint64, alpha math.LegacyDec, beta math.LegacyDec, theta math.LegacyDec, delta math.LegacyDec, targetBlockSize uint64, - maxBlockSize uint64, minBaseFee math.Int, minLearingRate math.LegacyDec, maxLearningRate math.LegacyDec, @@ -36,8 +35,7 @@ func NewParams( MinLearningRate: minLearingRate, MaxLearningRate: maxLearningRate, TargetBlockUtilization: targetBlockSize, - MaxBlockUtilization: maxBlockSize, - Window: window, + WindowSize: windowSize, FeeDenom: feeDenom, Enabled: enabled, } @@ -45,7 +43,7 @@ func NewParams( // ValidateBasic performs basic validation on the parameters. func (p *Params) ValidateBasic() error { - if p.Window == 0 { + if p.WindowSize == 0 { return fmt.Errorf("window cannot be zero") } @@ -69,14 +67,6 @@ func (p *Params) ValidateBasic() error { return fmt.Errorf("target block size cannot be zero") } - if p.TargetBlockUtilization > p.MaxBlockUtilization { - return fmt.Errorf("target block size cannot be greater than max block size") - } - - if p.MaxBlockUtilization/p.TargetBlockUtilization > MaxBlockUtilizationRatio { - return fmt.Errorf("max block size cannot be greater than target block size times %d", MaxBlockUtilizationRatio) - } - if p.MinBaseFee.IsNil() || !p.MinBaseFee.GTE(math.ZeroInt()) { return fmt.Errorf("min base fee cannot be nil and must be greater than or equal to zero") } diff --git a/x/feemarket/types/params.pb.go b/x/feemarket/types/params.pb.go index 90fa054..18fa852 100644 --- a/x/feemarket/types/params.pb.go +++ b/x/feemarket/types/params.pb.go @@ -50,18 +50,17 @@ type Params struct { MinLearningRate cosmossdk_io_math.LegacyDec `protobuf:"bytes,6,opt,name=min_learning_rate,json=minLearningRate,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"min_learning_rate"` // MaxLearningRate is the upper bound for the learning rate. MaxLearningRate cosmossdk_io_math.LegacyDec `protobuf:"bytes,7,opt,name=max_learning_rate,json=maxLearningRate,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"max_learning_rate"` - // TargetBlockUtilization is the target block utilization. + // TargetBlockUtilization is the target block utilization (in units of gas). This value MUST + // be lower than the consensus max gas parameter. TargetBlockUtilization uint64 `protobuf:"varint,8,opt,name=target_block_utilization,json=targetBlockUtilization,proto3" json:"target_block_utilization,omitempty"` - // MaxBlockUtilization is the maximum block utilization. - MaxBlockUtilization uint64 `protobuf:"varint,9,opt,name=max_block_utilization,json=maxBlockUtilization,proto3" json:"max_block_utilization,omitempty"` - // Window defines the window size for calculating an adaptive learning rate + // WindowSize defines the window size for calculating an adaptive learning rate // over a moving window of blocks. - Window uint64 `protobuf:"varint,10,opt,name=window,proto3" json:"window,omitempty"` + WindowSize uint64 `protobuf:"varint,9,opt,name=window_size,json=windowSize,proto3" json:"window_size,omitempty"` // FeeDenom is the denom that will be used for all fee payments. - FeeDenom string `protobuf:"bytes,11,opt,name=fee_denom,json=feeDenom,proto3" json:"fee_denom,omitempty"` + FeeDenom string `protobuf:"bytes,10,opt,name=fee_denom,json=feeDenom,proto3" json:"fee_denom,omitempty"` // Enabled is a boolean that determines whether the EIP1559 fee market is // enabled. - Enabled bool `protobuf:"varint,12,opt,name=enabled,proto3" json:"enabled,omitempty"` + Enabled bool `protobuf:"varint,11,opt,name=enabled,proto3" json:"enabled,omitempty"` } func (m *Params) Reset() { *m = Params{} } @@ -104,16 +103,9 @@ func (m *Params) GetTargetBlockUtilization() uint64 { return 0 } -func (m *Params) GetMaxBlockUtilization() uint64 { +func (m *Params) GetWindowSize() uint64 { if m != nil { - return m.MaxBlockUtilization - } - return 0 -} - -func (m *Params) GetWindow() uint64 { - if m != nil { - return m.Window + return m.WindowSize } return 0 } @@ -141,36 +133,35 @@ func init() { } var fileDescriptor_3907de4df2e1c66e = []byte{ - // 451 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0xd3, 0x41, 0x8b, 0xd3, 0x40, - 0x14, 0x07, 0xf0, 0x46, 0xdb, 0x6e, 0x3b, 0x2e, 0x88, 0xd1, 0x2d, 0xe3, 0x2e, 0x64, 0x8b, 0x5e, - 0x0a, 0xb2, 0x09, 0xd5, 0x8b, 0xe7, 0x52, 0x95, 0xc2, 0x0a, 0x12, 0xf0, 0x22, 0x48, 0x78, 0x49, - 0x5e, 0xd3, 0xa1, 0x99, 0x99, 0x90, 0xcc, 0x76, 0xbb, 0x7e, 0x0a, 0x3f, 0x8c, 0x1f, 0x62, 0x8f, - 0x8b, 0x27, 0xf1, 0xb0, 0x48, 0xfb, 0x15, 0xfc, 0x00, 0x32, 0x33, 0xd5, 0xd6, 0xed, 0x2d, 0xb7, - 0xf7, 0xe6, 0xcd, 0xff, 0x97, 0x97, 0xc3, 0x90, 0xe7, 0x53, 0x44, 0x0e, 0xe5, 0x1c, 0x55, 0xb0, - 0xad, 0x16, 0xc3, 0xa0, 0x80, 0x12, 0x78, 0xe5, 0x17, 0xa5, 0x54, 0xd2, 0xed, 0xfd, 0x1b, 0xf9, - 0xdb, 0x6a, 0x31, 0x3c, 0x7e, 0x9a, 0xc8, 0x8a, 0xcb, 0x2a, 0x32, 0xb7, 0x02, 0xdb, 0xd8, 0xc8, - 0xf1, 0x93, 0x4c, 0x66, 0xd2, 0x9e, 0xeb, 0xca, 0x9e, 0x3e, 0xfb, 0xdd, 0x22, 0xed, 0x0f, 0x46, - 0x76, 0xdf, 0x91, 0x16, 0xe4, 0xc5, 0x0c, 0xa8, 0xd3, 0x77, 0x06, 0xdd, 0xd1, 0xf0, 0xfa, 0xf6, - 0xb4, 0xf1, 0xf3, 0xf6, 0xf4, 0xc4, 0x2a, 0x55, 0x3a, 0xf7, 0x99, 0x0c, 0x38, 0xa8, 0x99, 0x7f, - 0x8e, 0x19, 0x24, 0x57, 0x63, 0x4c, 0xbe, 0x7f, 0x3b, 0x23, 0x9b, 0x8f, 0x8c, 0x31, 0x09, 0x6d, - 0xde, 0x7d, 0x43, 0x9a, 0x31, 0x2a, 0xa0, 0xf7, 0xea, 0x3a, 0x26, 0xae, 0xf7, 0x51, 0x33, 0xed, - 0xdc, 0xaf, 0xbd, 0x8f, 0xc9, 0x6b, 0x28, 0xc5, 0x5c, 0x01, 0x6d, 0xd6, 0x86, 0x4c, 0xde, 0x7d, - 0x4f, 0x0e, 0x39, 0x13, 0x51, 0x0c, 0x15, 0x46, 0x53, 0x44, 0xda, 0x32, 0xde, 0x8b, 0x8d, 0x77, - 0xb4, 0xef, 0x4d, 0x84, 0xda, 0x91, 0x26, 0x42, 0x85, 0x84, 0x33, 0x31, 0x82, 0x0a, 0xdf, 0x22, - 0xba, 0x9f, 0xc9, 0x23, 0xcd, 0xe5, 0x08, 0xa5, 0x60, 0x22, 0x8b, 0x4a, 0x50, 0x48, 0xdb, 0x75, - 0x77, 0x7c, 0xc8, 0x99, 0x38, 0xdf, 0x50, 0x21, 0x28, 0xcb, 0xc3, 0xf2, 0x0e, 0x7f, 0x50, 0x9f, - 0x87, 0xe5, 0x7f, 0xfc, 0x6b, 0x42, 0x15, 0x94, 0x19, 0xaa, 0x28, 0xce, 0x65, 0x32, 0x8f, 0x2e, - 0x14, 0xcb, 0xd9, 0x17, 0x50, 0x4c, 0x0a, 0xda, 0xe9, 0x3b, 0x83, 0x66, 0xd8, 0xb3, 0xf3, 0x91, - 0x1e, 0x7f, 0xdc, 0x4e, 0xdd, 0x97, 0xe4, 0x48, 0x2f, 0xb6, 0x1f, 0xeb, 0x9a, 0xd8, 0x63, 0x0e, - 0xcb, 0xbd, 0x4c, 0x8f, 0xb4, 0x2f, 0x99, 0x48, 0xe5, 0x25, 0x25, 0xe6, 0xd2, 0xa6, 0x73, 0x4f, - 0x48, 0x77, 0x8a, 0x18, 0xa5, 0x28, 0x24, 0xa7, 0x0f, 0xf4, 0xcf, 0x85, 0x9d, 0x29, 0xe2, 0x58, - 0xf7, 0x2e, 0x25, 0x07, 0x28, 0x20, 0xce, 0x31, 0xa5, 0x87, 0x7d, 0x67, 0xd0, 0x09, 0xff, 0xb6, - 0xa3, 0xc9, 0xf5, 0xca, 0x73, 0x6e, 0x56, 0x9e, 0xf3, 0x6b, 0xe5, 0x39, 0x5f, 0xd7, 0x5e, 0xe3, - 0x66, 0xed, 0x35, 0x7e, 0xac, 0xbd, 0xc6, 0xa7, 0x20, 0x63, 0x6a, 0x76, 0x11, 0xfb, 0x89, 0xe4, - 0x41, 0x35, 0x67, 0xc5, 0x19, 0xc7, 0xc5, 0xce, 0x43, 0x5c, 0xee, 0xd4, 0xea, 0xaa, 0xc0, 0x2a, - 0x6e, 0x9b, 0x87, 0xf4, 0xea, 0x4f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x7e, 0xef, 0x08, 0x09, 0xb8, - 0x03, 0x00, 0x00, + // 441 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x93, 0x41, 0x8b, 0xd3, 0x40, + 0x14, 0xc7, 0x1b, 0x6d, 0xbb, 0xed, 0xac, 0x20, 0x06, 0x5d, 0xc6, 0x5d, 0x48, 0x8b, 0x5e, 0x0a, + 0xb2, 0x09, 0xc5, 0x8b, 0xe7, 0x52, 0x95, 0xc2, 0x0a, 0x12, 0xf1, 0x22, 0x48, 0x78, 0x49, 0x5e, + 0xd3, 0xa1, 0x99, 0x99, 0x90, 0x99, 0xed, 0x76, 0xfb, 0x29, 0xfc, 0x30, 0x7e, 0x88, 0xf5, 0xb6, + 0x78, 0x12, 0x0f, 0x45, 0xda, 0x2f, 0x22, 0x99, 0xa9, 0xb6, 0xba, 0xb7, 0xdc, 0xfe, 0xef, 0xfd, + 0xe7, 0xff, 0x9b, 0xff, 0xe5, 0x91, 0xe7, 0x53, 0x44, 0x0e, 0xe5, 0x1c, 0x75, 0xb0, 0x57, 0x8b, + 0x61, 0x50, 0x40, 0x09, 0x5c, 0xf9, 0x45, 0x29, 0xb5, 0x74, 0x4f, 0xfe, 0x5a, 0xfe, 0x5e, 0x2d, + 0x86, 0xa7, 0x4f, 0x13, 0xa9, 0xb8, 0x54, 0x91, 0x79, 0x15, 0xd8, 0xc1, 0x46, 0x4e, 0x1f, 0x67, + 0x32, 0x93, 0x76, 0x5f, 0x29, 0xbb, 0x7d, 0xf6, 0xad, 0x45, 0xda, 0xef, 0x0d, 0xd9, 0x7d, 0x4b, + 0x5a, 0x90, 0x17, 0x33, 0xa0, 0x4e, 0xdf, 0x19, 0x74, 0x47, 0xc3, 0x9b, 0x75, 0xaf, 0xf1, 0x73, + 0xdd, 0x3b, 0xb3, 0x14, 0x95, 0xce, 0x7d, 0x26, 0x03, 0x0e, 0x7a, 0xe6, 0x5f, 0x60, 0x06, 0xc9, + 0xf5, 0x18, 0x93, 0xef, 0x5f, 0xcf, 0xc9, 0xee, 0x93, 0x31, 0x26, 0xa1, 0xcd, 0xbb, 0xaf, 0x49, + 0x33, 0x46, 0x0d, 0xf4, 0x5e, 0x5d, 0x8e, 0x89, 0x57, 0x7d, 0xf4, 0xac, 0xe2, 0xdc, 0xaf, 0xdd, + 0xc7, 0xe4, 0x2b, 0x50, 0x8a, 0xb9, 0x06, 0xda, 0xac, 0x0d, 0x32, 0x79, 0xf7, 0x1d, 0x79, 0xc0, + 0x99, 0x88, 0x62, 0x50, 0x18, 0x4d, 0x11, 0x69, 0xcb, 0xf0, 0x5e, 0xec, 0x78, 0x4f, 0xee, 0xf2, + 0x26, 0x42, 0x1f, 0x90, 0x26, 0x42, 0x87, 0x84, 0x33, 0x31, 0x02, 0x85, 0x6f, 0x10, 0xdd, 0xcf, + 0xe4, 0x51, 0x85, 0xcb, 0x11, 0x4a, 0xc1, 0x44, 0x16, 0x95, 0xa0, 0x91, 0xb6, 0xeb, 0x76, 0x7c, + 0xc8, 0x99, 0xb8, 0xd8, 0xa1, 0x42, 0xd0, 0x16, 0x0f, 0xcb, 0xff, 0xf0, 0x47, 0xf5, 0xf1, 0xb0, + 0xfc, 0x07, 0xff, 0x8a, 0x50, 0x0d, 0x65, 0x86, 0x3a, 0x8a, 0x73, 0x99, 0xcc, 0xa3, 0x4b, 0xcd, + 0x72, 0xb6, 0x02, 0xcd, 0xa4, 0xa0, 0x9d, 0xbe, 0x33, 0x68, 0x86, 0x27, 0xd6, 0x1f, 0x55, 0xf6, + 0xc7, 0xbd, 0xeb, 0xf6, 0xc8, 0xf1, 0x15, 0x13, 0xa9, 0xbc, 0x8a, 0x14, 0x5b, 0x21, 0xed, 0x9a, + 0xc7, 0xc4, 0xae, 0x3e, 0xb0, 0x15, 0xba, 0x67, 0xa4, 0x3b, 0x45, 0x8c, 0x52, 0x14, 0x92, 0x53, + 0x52, 0x35, 0x0e, 0x3b, 0x53, 0xc4, 0x71, 0x35, 0xbb, 0x94, 0x1c, 0xa1, 0x80, 0x38, 0xc7, 0x94, + 0x1e, 0xf7, 0x9d, 0x41, 0x27, 0xfc, 0x33, 0x8e, 0x26, 0x37, 0x1b, 0xcf, 0xb9, 0xdd, 0x78, 0xce, + 0xaf, 0x8d, 0xe7, 0x7c, 0xd9, 0x7a, 0x8d, 0xdb, 0xad, 0xd7, 0xf8, 0xb1, 0xf5, 0x1a, 0x9f, 0x82, + 0x8c, 0xe9, 0xd9, 0x65, 0xec, 0x27, 0x92, 0x07, 0x6a, 0xce, 0x8a, 0x73, 0x8e, 0x8b, 0x83, 0xeb, + 0x5a, 0x1e, 0x68, 0x7d, 0x5d, 0xa0, 0x8a, 0xdb, 0xe6, 0x3a, 0x5e, 0xfe, 0x0e, 0x00, 0x00, 0xff, + 0xff, 0xbb, 0x63, 0x36, 0x76, 0x8d, 0x03, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -201,22 +192,17 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { dAtA[i] = 0 } i-- - dAtA[i] = 0x60 + dAtA[i] = 0x58 } if len(m.FeeDenom) > 0 { i -= len(m.FeeDenom) copy(dAtA[i:], m.FeeDenom) i = encodeVarintParams(dAtA, i, uint64(len(m.FeeDenom))) i-- - dAtA[i] = 0x5a - } - if m.Window != 0 { - i = encodeVarintParams(dAtA, i, uint64(m.Window)) - i-- - dAtA[i] = 0x50 + dAtA[i] = 0x52 } - if m.MaxBlockUtilization != 0 { - i = encodeVarintParams(dAtA, i, uint64(m.MaxBlockUtilization)) + if m.WindowSize != 0 { + i = encodeVarintParams(dAtA, i, uint64(m.WindowSize)) i-- dAtA[i] = 0x48 } @@ -332,11 +318,8 @@ func (m *Params) Size() (n int) { if m.TargetBlockUtilization != 0 { n += 1 + sovParams(uint64(m.TargetBlockUtilization)) } - if m.MaxBlockUtilization != 0 { - n += 1 + sovParams(uint64(m.MaxBlockUtilization)) - } - if m.Window != 0 { - n += 1 + sovParams(uint64(m.Window)) + if m.WindowSize != 0 { + n += 1 + sovParams(uint64(m.WindowSize)) } l = len(m.FeeDenom) if l > 0 { @@ -642,9 +625,9 @@ func (m *Params) Unmarshal(dAtA []byte) error { } case 9: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MaxBlockUtilization", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field WindowSize", wireType) } - m.MaxBlockUtilization = 0 + m.WindowSize = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowParams @@ -654,31 +637,12 @@ func (m *Params) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.MaxBlockUtilization |= uint64(b&0x7F) << shift + m.WindowSize |= uint64(b&0x7F) << shift if b < 0x80 { break } } case 10: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Window", wireType) - } - m.Window = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Window |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 11: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field FeeDenom", wireType) } @@ -710,7 +674,7 @@ func (m *Params) Unmarshal(dAtA []byte) error { } m.FeeDenom = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 12: + case 11: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field Enabled", wireType) } diff --git a/x/feemarket/types/params_test.go b/x/feemarket/types/params_test.go index c69dac9..4a9980f 100644 --- a/x/feemarket/types/params_test.go +++ b/x/feemarket/types/params_test.go @@ -33,120 +33,120 @@ func TestParams(t *testing.T) { { name: "nil alpha", p: types.Params{ - Window: 1, - FeeDenom: types.DefaultFeeDenom, + WindowSize: 1, + FeeDenom: types.DefaultFeeDenom, }, expectedErr: true, }, { name: "negative alpha", p: types.Params{ - Window: 1, - Alpha: math.LegacyMustNewDecFromStr("-0.1"), - FeeDenom: types.DefaultFeeDenom, + WindowSize: 1, + Alpha: math.LegacyMustNewDecFromStr("-0.1"), + FeeDenom: types.DefaultFeeDenom, }, expectedErr: true, }, { name: "beta is nil", p: types.Params{ - Window: 1, - Alpha: math.LegacyMustNewDecFromStr("0.1"), - FeeDenom: types.DefaultFeeDenom, + WindowSize: 1, + Alpha: math.LegacyMustNewDecFromStr("0.1"), + FeeDenom: types.DefaultFeeDenom, }, expectedErr: true, }, { name: "beta is negative", p: types.Params{ - Window: 1, - Alpha: math.LegacyMustNewDecFromStr("0.1"), - Beta: math.LegacyMustNewDecFromStr("-0.1"), - FeeDenom: types.DefaultFeeDenom, + WindowSize: 1, + Alpha: math.LegacyMustNewDecFromStr("0.1"), + Beta: math.LegacyMustNewDecFromStr("-0.1"), + FeeDenom: types.DefaultFeeDenom, }, expectedErr: true, }, { name: "beta is greater than 1", p: types.Params{ - Window: 1, - Alpha: math.LegacyMustNewDecFromStr("0.1"), - Beta: math.LegacyMustNewDecFromStr("1.1"), - FeeDenom: types.DefaultFeeDenom, + WindowSize: 1, + Alpha: math.LegacyMustNewDecFromStr("0.1"), + Beta: math.LegacyMustNewDecFromStr("1.1"), + FeeDenom: types.DefaultFeeDenom, }, expectedErr: true, }, { name: "theta is nil", p: types.Params{ - Window: 1, - Alpha: math.LegacyMustNewDecFromStr("0.1"), - Beta: math.LegacyMustNewDecFromStr("0.1"), - FeeDenom: types.DefaultFeeDenom, + WindowSize: 1, + Alpha: math.LegacyMustNewDecFromStr("0.1"), + Beta: math.LegacyMustNewDecFromStr("0.1"), + FeeDenom: types.DefaultFeeDenom, }, expectedErr: true, }, { name: "theta is negative", p: types.Params{ - Window: 1, - Alpha: math.LegacyMustNewDecFromStr("0.1"), - Beta: math.LegacyMustNewDecFromStr("0.1"), - Theta: math.LegacyMustNewDecFromStr("-0.1"), - FeeDenom: types.DefaultFeeDenom, + WindowSize: 1, + Alpha: math.LegacyMustNewDecFromStr("0.1"), + Beta: math.LegacyMustNewDecFromStr("0.1"), + Theta: math.LegacyMustNewDecFromStr("-0.1"), + FeeDenom: types.DefaultFeeDenom, }, expectedErr: true, }, { name: "theta is greater than 1", p: types.Params{ - Window: 1, - Alpha: math.LegacyMustNewDecFromStr("0.1"), - Beta: math.LegacyMustNewDecFromStr("0.1"), - Theta: math.LegacyMustNewDecFromStr("1.1"), - FeeDenom: types.DefaultFeeDenom, + WindowSize: 1, + Alpha: math.LegacyMustNewDecFromStr("0.1"), + Beta: math.LegacyMustNewDecFromStr("0.1"), + Theta: math.LegacyMustNewDecFromStr("1.1"), + FeeDenom: types.DefaultFeeDenom, }, expectedErr: true, }, { name: "delta is nil", p: types.Params{ - Window: 1, - Alpha: math.LegacyMustNewDecFromStr("0.1"), - Beta: math.LegacyMustNewDecFromStr("0.1"), - Theta: math.LegacyMustNewDecFromStr("0.1"), - FeeDenom: types.DefaultFeeDenom, + WindowSize: 1, + Alpha: math.LegacyMustNewDecFromStr("0.1"), + Beta: math.LegacyMustNewDecFromStr("0.1"), + Theta: math.LegacyMustNewDecFromStr("0.1"), + FeeDenom: types.DefaultFeeDenom, }, expectedErr: true, }, { name: "delta is negative", p: types.Params{ - Window: 1, - Alpha: math.LegacyMustNewDecFromStr("0.1"), - Beta: math.LegacyMustNewDecFromStr("0.1"), - Theta: math.LegacyMustNewDecFromStr("0.1"), - Delta: math.LegacyMustNewDecFromStr("-0.1"), - FeeDenom: types.DefaultFeeDenom, + WindowSize: 1, + Alpha: math.LegacyMustNewDecFromStr("0.1"), + Beta: math.LegacyMustNewDecFromStr("0.1"), + Theta: math.LegacyMustNewDecFromStr("0.1"), + Delta: math.LegacyMustNewDecFromStr("-0.1"), + FeeDenom: types.DefaultFeeDenom, }, expectedErr: true, }, { name: "target block size is zero", p: types.Params{ - Window: 1, - Alpha: math.LegacyMustNewDecFromStr("0.1"), - Beta: math.LegacyMustNewDecFromStr("0.1"), - Theta: math.LegacyMustNewDecFromStr("0.1"), - Delta: math.LegacyMustNewDecFromStr("0.1"), - FeeDenom: types.DefaultFeeDenom, + WindowSize: 1, + Alpha: math.LegacyMustNewDecFromStr("0.1"), + Beta: math.LegacyMustNewDecFromStr("0.1"), + Theta: math.LegacyMustNewDecFromStr("0.1"), + Delta: math.LegacyMustNewDecFromStr("0.1"), + FeeDenom: types.DefaultFeeDenom, }, expectedErr: true, }, { name: "max block size is zero", p: types.Params{ - Window: 1, + WindowSize: 1, Alpha: math.LegacyMustNewDecFromStr("0.1"), Beta: math.LegacyMustNewDecFromStr("0.1"), Theta: math.LegacyMustNewDecFromStr("0.1"), @@ -159,27 +159,12 @@ func TestParams(t *testing.T) { { name: "target block size is greater than max block size", p: types.Params{ - Window: 1, + WindowSize: 1, Alpha: math.LegacyMustNewDecFromStr("0.1"), Beta: math.LegacyMustNewDecFromStr("0.1"), Theta: math.LegacyMustNewDecFromStr("0.1"), Delta: math.LegacyMustNewDecFromStr("0.1"), TargetBlockUtilization: 2, - MaxBlockUtilization: 1, - FeeDenom: types.DefaultFeeDenom, - }, - expectedErr: true, - }, - { - name: "max to target block size ratio is too large", - p: types.Params{ - Window: 1, - Alpha: math.LegacyMustNewDecFromStr("0.1"), - Beta: math.LegacyMustNewDecFromStr("0.1"), - Theta: math.LegacyMustNewDecFromStr("0.1"), - Delta: math.LegacyMustNewDecFromStr("0.1"), - TargetBlockUtilization: 2, - MaxBlockUtilization: 200, FeeDenom: types.DefaultFeeDenom, }, expectedErr: true, @@ -187,13 +172,12 @@ func TestParams(t *testing.T) { { name: "min base fee is nil", p: types.Params{ - Window: 1, + WindowSize: 1, Alpha: math.LegacyMustNewDecFromStr("0.1"), Beta: math.LegacyMustNewDecFromStr("0.1"), Theta: math.LegacyMustNewDecFromStr("0.1"), Delta: math.LegacyMustNewDecFromStr("0.1"), TargetBlockUtilization: 2, - MaxBlockUtilization: 3, FeeDenom: types.DefaultFeeDenom, }, expectedErr: true, @@ -201,13 +185,12 @@ func TestParams(t *testing.T) { { name: "min base fee is negative", p: types.Params{ - Window: 1, + WindowSize: 1, Alpha: math.LegacyMustNewDecFromStr("0.1"), Beta: math.LegacyMustNewDecFromStr("0.1"), Theta: math.LegacyMustNewDecFromStr("0.1"), Delta: math.LegacyMustNewDecFromStr("0.1"), TargetBlockUtilization: 2, - MaxBlockUtilization: 3, MinBaseFee: math.NewInt(-1), FeeDenom: types.DefaultFeeDenom, }, @@ -216,13 +199,12 @@ func TestParams(t *testing.T) { { name: "min learning rate is nil", p: types.Params{ - Window: 1, + WindowSize: 1, Alpha: math.LegacyMustNewDecFromStr("0.1"), Beta: math.LegacyMustNewDecFromStr("0.1"), Theta: math.LegacyMustNewDecFromStr("0.1"), Delta: math.LegacyMustNewDecFromStr("0.1"), TargetBlockUtilization: 2, - MaxBlockUtilization: 3, MinBaseFee: math.NewInt(1), FeeDenom: types.DefaultFeeDenom, }, @@ -231,13 +213,12 @@ func TestParams(t *testing.T) { { name: "min learning rate is negative", p: types.Params{ - Window: 1, + WindowSize: 1, Alpha: math.LegacyMustNewDecFromStr("0.1"), Beta: math.LegacyMustNewDecFromStr("0.1"), Theta: math.LegacyMustNewDecFromStr("0.1"), Delta: math.LegacyMustNewDecFromStr("0.1"), TargetBlockUtilization: 2, - MaxBlockUtilization: 3, MinBaseFee: math.NewInt(1), MinLearningRate: math.LegacyMustNewDecFromStr("-0.1"), FeeDenom: types.DefaultFeeDenom, @@ -247,13 +228,12 @@ func TestParams(t *testing.T) { { name: "max learning rate is nil", p: types.Params{ - Window: 1, + WindowSize: 1, Alpha: math.LegacyMustNewDecFromStr("0.1"), Beta: math.LegacyMustNewDecFromStr("0.1"), Theta: math.LegacyMustNewDecFromStr("0.1"), Delta: math.LegacyMustNewDecFromStr("0.1"), TargetBlockUtilization: 2, - MaxBlockUtilization: 3, MinBaseFee: math.NewInt(1), MinLearningRate: math.LegacyMustNewDecFromStr("0.1"), FeeDenom: types.DefaultFeeDenom, @@ -263,13 +243,12 @@ func TestParams(t *testing.T) { { name: "max learning rate is negative", p: types.Params{ - Window: 1, + WindowSize: 1, Alpha: math.LegacyMustNewDecFromStr("0.1"), Beta: math.LegacyMustNewDecFromStr("0.1"), Theta: math.LegacyMustNewDecFromStr("0.1"), Delta: math.LegacyMustNewDecFromStr("0.1"), TargetBlockUtilization: 2, - MaxBlockUtilization: 3, MinBaseFee: math.NewInt(1), MinLearningRate: math.LegacyMustNewDecFromStr("0.1"), MaxLearningRate: math.LegacyMustNewDecFromStr("-0.1"), @@ -280,13 +259,12 @@ func TestParams(t *testing.T) { { name: "min learning rate is greater than max learning rate", p: types.Params{ - Window: 1, + WindowSize: 1, Alpha: math.LegacyMustNewDecFromStr("0.1"), Beta: math.LegacyMustNewDecFromStr("0.1"), Theta: math.LegacyMustNewDecFromStr("0.1"), Delta: math.LegacyMustNewDecFromStr("0.1"), TargetBlockUtilization: 2, - MaxBlockUtilization: 3, MinBaseFee: math.NewInt(1), MinLearningRate: math.LegacyMustNewDecFromStr("0.1"), MaxLearningRate: math.LegacyMustNewDecFromStr("0.05"), @@ -297,13 +275,12 @@ func TestParams(t *testing.T) { { name: "fee denom is empty", p: types.Params{ - Window: 1, + WindowSize: 1, Alpha: math.LegacyMustNewDecFromStr("0.1"), Beta: math.LegacyMustNewDecFromStr("0.1"), Theta: math.LegacyMustNewDecFromStr("0.1"), Delta: math.LegacyMustNewDecFromStr("0.1"), TargetBlockUtilization: 2, - MaxBlockUtilization: 3, MinBaseFee: math.NewInt(1), MinLearningRate: math.LegacyMustNewDecFromStr("0.01"), MaxLearningRate: math.LegacyMustNewDecFromStr("0.05"), diff --git a/x/feemarket/types/state.go b/x/feemarket/types/state.go index 3ff2985..8daff62 100644 --- a/x/feemarket/types/state.go +++ b/x/feemarket/types/state.go @@ -25,10 +25,10 @@ func NewState( // Update updates the block utilization for the current height with the given // transaction utilization i.e. gas limit. -func (s *State) Update(gas uint64, params Params) error { +func (s *State) Update(gas, maxGas uint64) error { update := s.Window[s.Index] + gas - if update > params.MaxBlockUtilization { - return fmt.Errorf("block utilization cannot exceed max block utilization") + if update > maxGas { + return fmt.Errorf("block utilization of %d cannot exceed max block utilization of %d", update, maxGas) } s.Window[s.Index] = update @@ -94,7 +94,7 @@ func (s *State) UpdateBaseFee(params Params) (fee math.Int) { // when blocks are relatively close to the target block utilization. // // For more details, please see the EIP-1559 specification. -func (s *State) UpdateLearningRate(params Params) (lr math.LegacyDec) { +func (s *State) UpdateLearningRate(params Params, consensusMaxGas uint64) (lr math.LegacyDec) { // Panic catch in case there is an overflow defer func() { if rec := recover(); rec != nil { @@ -104,7 +104,7 @@ func (s *State) UpdateLearningRate(params Params) (lr math.LegacyDec) { }() // Calculate the average utilization of the block window. - avg := s.GetAverageUtilization(params) + avg := s.GetAverageUtilization(consensusMaxGas) // Determine if the average utilization is above or below the target // threshold and adjust the learning rate accordingly. @@ -140,7 +140,7 @@ func (s *State) GetNetUtilization(params Params) math.Int { // GetAverageUtilization returns the average utilization of the block // window. -func (s *State) GetAverageUtilization(params Params) math.LegacyDec { +func (s *State) GetAverageUtilization(consensusMaxGas uint64) math.LegacyDec { var total uint64 for _, utilization := range s.Window { total += utilization @@ -149,7 +149,7 @@ func (s *State) GetAverageUtilization(params Params) math.LegacyDec { sum := math.LegacyNewDecFromInt(math.NewIntFromUint64(total)) multiple := math.LegacyNewDecFromInt(math.NewIntFromUint64(uint64(len(s.Window)))) - divisor := math.LegacyNewDecFromInt(math.NewIntFromUint64(params.MaxBlockUtilization)).Mul(multiple) + divisor := math.LegacyNewDecFromInt(math.NewIntFromUint64(consensusMaxGas)).Mul(multiple) return sum.Quo(divisor) } diff --git a/x/feemarket/types/state_fuzz_test.go b/x/feemarket/types/state_fuzz_test.go index ec3c22a..9a631b7 100644 --- a/x/feemarket/types/state_fuzz_test.go +++ b/x/feemarket/types/state_fuzz_test.go @@ -33,9 +33,9 @@ func FuzzDefaultFeeMarket(f *testing.F) { params.MinBaseFee = math.NewIntFromUint64(100) state.BaseFee = math.NewIntFromUint64(200) - err := state.Update(blockGasUsed, params) + err := state.Update(blockGasUsed, types.DefaultMaxBlockUtilization) - if blockGasUsed > params.MaxBlockUtilization { + if blockGasUsed > types.DefaultMaxBlockUtilization { require.Error(t, err) return } @@ -46,6 +46,7 @@ func FuzzDefaultFeeMarket(f *testing.F) { // Ensure the learning rate is always the default learning rate. lr := state.UpdateLearningRate( params, + types.DefaultMaxBlockUtilization, ) require.Equal(t, defaultLR, lr) @@ -82,9 +83,9 @@ func FuzzAIMDFeeMarket(f *testing.F) { params.MinBaseFee = math.NewIntFromUint64(100) state.BaseFee = math.NewIntFromUint64(200) state.Window = make([]uint64, 1) - err := state.Update(blockGasUsed, params) + err := state.Update(blockGasUsed, types.DefaultAIMDMaxBlockSize) - if blockGasUsed > params.MaxBlockUtilization { + if blockGasUsed > types.DefaultAIMDMaxBlockSize { require.Error(t, err) return } diff --git a/x/feemarket/types/state_test.go b/x/feemarket/types/state_test.go index 1c6bdb1..1b27041 100644 --- a/x/feemarket/types/state_test.go +++ b/x/feemarket/types/state_test.go @@ -15,105 +15,99 @@ var OneHundred = math.LegacyNewDecFromInt(math.NewInt(100)) func TestState_Update(t *testing.T) { t.Run("can add to window", func(t *testing.T) { state := types.DefaultState() - params := types.DefaultParams() - err := state.Update(100, params) + err := state.Update(100, types.DefaultMaxBlockUtilization) require.NoError(t, err) require.Equal(t, uint64(100), state.Window[0]) }) t.Run("can add several txs to window", func(t *testing.T) { state := types.DefaultState() - params := types.DefaultParams() - err := state.Update(100, params) + err := state.Update(100, types.DefaultMaxBlockUtilization) require.NoError(t, err) require.Equal(t, uint64(100), state.Window[0]) - err = state.Update(200, params) + err = state.Update(200, types.DefaultMaxBlockUtilization) require.NoError(t, err) require.Equal(t, uint64(300), state.Window[0]) }) t.Run("errors when it exceeds max block utilization", func(t *testing.T) { state := types.DefaultState() - params := types.DefaultParams() - err := state.Update(params.MaxBlockUtilization+1, params) + err := state.Update(types.DefaultMaxBlockUtilization+1, types.DefaultMaxBlockUtilization) require.Error(t, err) }) t.Run("can update with several blocks in default eip-1559", func(t *testing.T) { state := types.DefaultState() - params := types.DefaultParams() - err := state.Update(100, params) + err := state.Update(100, types.DefaultMaxBlockUtilization) require.NoError(t, err) require.Equal(t, uint64(100), state.Window[0]) state.IncrementHeight() - err = state.Update(200, params) + err = state.Update(200, types.DefaultMaxBlockUtilization) require.NoError(t, err) require.Equal(t, uint64(200), state.Window[0]) - err = state.Update(300, params) + err = state.Update(300, types.DefaultMaxBlockUtilization) require.NoError(t, err) require.Equal(t, uint64(500), state.Window[0]) }) t.Run("can update with several blocks in default aimd eip-1559", func(t *testing.T) { state := types.DefaultAIMDState() - params := types.DefaultAIMDParams() - err := state.Update(100, params) + err := state.Update(100, types.DefaultAIMDMaxBlockSize) require.NoError(t, err) require.Equal(t, uint64(100), state.Window[0]) state.IncrementHeight() - err = state.Update(200, params) + err = state.Update(200, types.DefaultAIMDMaxBlockSize) require.NoError(t, err) require.Equal(t, uint64(200), state.Window[1]) state.IncrementHeight() - err = state.Update(300, params) + err = state.Update(300, types.DefaultAIMDMaxBlockSize) require.NoError(t, err) require.Equal(t, uint64(300), state.Window[2]) state.IncrementHeight() - err = state.Update(400, params) + err = state.Update(400, types.DefaultAIMDMaxBlockSize) require.NoError(t, err) require.Equal(t, uint64(400), state.Window[3]) }) t.Run("correctly wraps around with aimd eip-1559", func(t *testing.T) { state := types.DefaultAIMDState() - params := types.DefaultAIMDParams() state.Window = make([]uint64, 3) - err := state.Update(100, params) + err := state.Update(100, types.DefaultAIMDMaxBlockSize) require.NoError(t, err) require.Equal(t, uint64(100), state.Window[0]) state.IncrementHeight() - err = state.Update(200, params) + err = state.Update(200, types.DefaultAIMDMaxBlockSize) require.NoError(t, err) require.Equal(t, uint64(200), state.Window[1]) state.IncrementHeight() - err = state.Update(300, params) + err = state.Update(300, types.DefaultAIMDMaxBlockSize) require.NoError(t, err) require.Equal(t, uint64(300), state.Window[2]) state.IncrementHeight() require.Equal(t, uint64(0), state.Window[0]) - err = state.Update(400, params) + err = state.Update(400, types.DefaultAIMDMaxBlockSize) require.NoError(t, err) require.Equal(t, uint64(400), state.Window[0]) require.Equal(t, uint64(200), state.Window[1]) @@ -155,7 +149,7 @@ func TestState_UpdateBaseFee(t *testing.T) { state.BaseFee = math.NewInt(1000) params.MinBaseFee = math.NewInt(125) - state.Window[0] = params.MaxBlockUtilization + state.Window[0] = types.DefaultMaxBlockUtilization newBaseFee := state.UpdateBaseFee(params) expectedBaseFee := math.NewInt(1125) @@ -170,7 +164,7 @@ func TestState_UpdateBaseFee(t *testing.T) { params.MinBaseFee = math.NewInt(125) state.LearningRate = math.LegacyMustNewDecFromStr("0.125") - state.UpdateLearningRate(params) + state.UpdateLearningRate(params, types.DefaultMaxBlockUtilization) newBaseFee := state.UpdateBaseFee(params) expectedBaseFee := math.NewInt(850) @@ -189,7 +183,7 @@ func TestState_UpdateBaseFee(t *testing.T) { state.Window[i] = params.TargetBlockUtilization } - state.UpdateLearningRate(params) + state.UpdateLearningRate(params, types.DefaultAIMDMaxBlockSize) newBaseFee := state.UpdateBaseFee(params) expectedBaseFee := math.NewInt(1000) @@ -205,10 +199,10 @@ func TestState_UpdateBaseFee(t *testing.T) { state.LearningRate = math.LegacyMustNewDecFromStr("0.125") for i := 0; i < len(state.Window); i++ { - state.Window[i] = params.MaxBlockUtilization + state.Window[i] = types.DefaultAIMDMaxBlockSize } - state.UpdateLearningRate(params) + state.UpdateLearningRate(params, types.DefaultAIMDMaxBlockSize) newBaseFee := state.UpdateBaseFee(params) expectedBaseFee := math.NewInt(1150) @@ -246,12 +240,12 @@ func TestState_UpdateBaseFee(t *testing.T) { // Empty blocks state := types.DefaultAIMDState() state.BaseFee = state.BaseFee.Mul(math.NewInt(10)) - lr := state.UpdateLearningRate(params) + lr := state.UpdateLearningRate(params, types.DefaultAIMDMaxBlockSize) bf := state.UpdateBaseFee(params) state = types.DefaultAIMDState() state.BaseFee = state.BaseFee.Mul(math.NewInt(10)) - lrWithDelta := state.UpdateLearningRate(paramsWithDelta) + lrWithDelta := state.UpdateLearningRate(paramsWithDelta, types.DefaultAIMDMaxBlockSize) bfWithDelta := state.UpdateBaseFee(paramsWithDelta) // Ensure that the learning rate is the same. @@ -273,19 +267,19 @@ func TestState_UpdateBaseFee(t *testing.T) { state := types.DefaultAIMDState() state.BaseFee = state.BaseFee.Mul(math.NewInt(10)) for i := 0; i < len(state.Window); i++ { - state.Window[i] = params.MaxBlockUtilization + state.Window[i] = types.DefaultAIMDMaxBlockSize } - lr := state.UpdateLearningRate(params) + lr := state.UpdateLearningRate(params, types.DefaultAIMDMaxBlockSize) bf := state.UpdateBaseFee(params) state = types.DefaultAIMDState() state.BaseFee = state.BaseFee.Mul(math.NewInt(10)) for i := 0; i < len(state.Window); i++ { - state.Window[i] = params.MaxBlockUtilization + state.Window[i] = types.DefaultAIMDMaxBlockSize } - lrWithDelta := state.UpdateLearningRate(paramsWithDelta) + lrWithDelta := state.UpdateLearningRate(paramsWithDelta, types.DefaultAIMDMaxBlockSize) bfWithDelta := state.UpdateBaseFee(paramsWithDelta) // Ensure that the learning rate is the same. @@ -310,7 +304,7 @@ func TestState_UpdateBaseFee(t *testing.T) { state.Window[i] = params.TargetBlockUtilization } - lr := state.UpdateLearningRate(params) + lr := state.UpdateLearningRate(params, types.DefaultAIMDMaxBlockSize) bf := state.UpdateBaseFee(params) state = types.DefaultAIMDState() @@ -319,13 +313,13 @@ func TestState_UpdateBaseFee(t *testing.T) { state.Window[i] = params.TargetBlockUtilization } - lrWithDelta := state.UpdateLearningRate(paramsWithDelta) + lrWithDelta := state.UpdateLearningRate(paramsWithDelta, types.DefaultAIMDMaxBlockSize) bfWithDelta := state.UpdateBaseFee(paramsWithDelta) // Ensure that the learning rate is the same. require.Equal(t, lr, lrWithDelta) - // Ensure that the base fee's are equal. + // Ensure that the base fees are equal. require.Equal(t, bf, bfWithDelta) }) @@ -337,14 +331,14 @@ func TestState_UpdateBaseFee(t *testing.T) { // Instantiate the params with a delta. params := types.DefaultAIMDParams() - params.Window = 1 + params.WindowSize = 1 params.Delta = math.LegacyNewDec(10) // 1/4th of the window is full. state.Window[0] = params.TargetBlockUtilization / 2 prevLR := state.LearningRate - lr := state.UpdateLearningRate(params) + lr := state.UpdateLearningRate(params, types.DefaultAIMDMaxBlockSize) bf := state.UpdateBaseFee(params) expectedUtilization := math.LegacyMustNewDecFromStr("-0.5") @@ -367,21 +361,21 @@ func TestState_UpdateBaseFee(t *testing.T) { // Instantiate the params with a delta. params := types.DefaultAIMDParams() - params.Window = 1 + params.WindowSize = 1 params.Delta = math.LegacyNewDec(10) // 1/4th of the window is full. - state.Window[0] = params.MaxBlockUtilization / 4 * 3 + state.Window[0] = types.DefaultAIMDMaxBlockSize / 4 * 3 prevLR := state.LearningRate - lr := state.UpdateLearningRate(params) + lr := state.UpdateLearningRate(params, types.DefaultAIMDMaxBlockSize) bf := state.UpdateBaseFee(params) expectedUtilization := math.LegacyMustNewDecFromStr("0.5") expectedLR := prevLR.Add(params.Alpha) expectedLRAdjustment := (expectedLR.Mul(expectedUtilization)).Add(math.LegacyOneDec()) - expectedNetUtilization := math.LegacyNewDec(int64(params.MaxBlockUtilization) / 4) + expectedNetUtilization := math.LegacyNewDec(int64(types.DefaultAIMDMaxBlockSize) / 4) deltaDiff := expectedNetUtilization.Mul(params.Delta) expectedFee := (math.LegacyNewDecFromInt(prevBF).Mul(expectedLRAdjustment)).Add(deltaDiff).TruncateInt() @@ -395,16 +389,16 @@ func TestState_UpdateBaseFee(t *testing.T) { state.BaseFee = state.BaseFee.Mul(math.NewInt(10)) params := types.DefaultAIMDParams() - params.Window = 50 + params.WindowSize = 50 // This should overflow the base fee after a few iterations. params.TargetBlockUtilization = 1 - params.MaxBlockUtilization = 9_999_999_999_999_999_999 + maxUtilization := uint64(9_999_999_999_999_999_999) for { var baseFee math.Int require.NotPanics(t, func() { - state.Update(params.MaxBlockUtilization, params) - state.UpdateLearningRate(params) + state.Update(maxUtilization, maxUtilization) + state.UpdateLearningRate(params, maxUtilization) baseFee = state.UpdateBaseFee(params) }) @@ -424,7 +418,7 @@ func TestState_UpdateLearningRate(t *testing.T) { state := types.DefaultState() params := types.DefaultParams() - state.UpdateLearningRate(params) + state.UpdateLearningRate(params, types.DefaultMaxBlockUtilization) expectedLearningRate := math.LegacyMustNewDecFromStr("0.125") require.True(t, expectedLearningRate.Equal(state.LearningRate)) }) @@ -435,7 +429,7 @@ func TestState_UpdateLearningRate(t *testing.T) { state.Window[0] = params.TargetBlockUtilization - state.UpdateLearningRate(params) + state.UpdateLearningRate(params, types.DefaultMaxBlockUtilization) expectedLearningRate := math.LegacyMustNewDecFromStr("0.125") require.True(t, expectedLearningRate.Equal(state.LearningRate)) }) @@ -444,9 +438,9 @@ func TestState_UpdateLearningRate(t *testing.T) { state := types.DefaultState() params := types.DefaultParams() - state.Window[0] = params.MaxBlockUtilization + state.Window[0] = types.DefaultMaxBlockUtilization - state.UpdateLearningRate(params) + state.UpdateLearningRate(params, types.DefaultMaxBlockUtilization) expectedLearningRate := math.LegacyMustNewDecFromStr("0.125") require.True(t, expectedLearningRate.Equal(state.LearningRate)) }) @@ -457,7 +451,7 @@ func TestState_UpdateLearningRate(t *testing.T) { state.Window[0] = 50000 - state.UpdateLearningRate(params) + state.UpdateLearningRate(params, types.DefaultMaxBlockUtilization) expectedLearningRate := math.LegacyMustNewDecFromStr("0.125") require.True(t, expectedLearningRate.Equal(state.LearningRate)) }) @@ -468,7 +462,7 @@ func TestState_UpdateLearningRate(t *testing.T) { state.Window[0] = params.TargetBlockUtilization + 50000 - state.UpdateLearningRate(params) + state.UpdateLearningRate(params, types.DefaultMaxBlockUtilization) expectedLearningRate := math.LegacyMustNewDecFromStr("0.125") require.True(t, expectedLearningRate.Equal(state.LearningRate)) }) @@ -480,7 +474,7 @@ func TestState_UpdateLearningRate(t *testing.T) { randomValue := rand.Int63n(1000000000) state.Window[0] = uint64(randomValue) - state.UpdateLearningRate(params) + state.UpdateLearningRate(params, types.DefaultMaxBlockUtilization) expectedLearningRate := math.LegacyMustNewDecFromStr("0.125") require.True(t, expectedLearningRate.Equal(state.LearningRate)) }) @@ -489,7 +483,7 @@ func TestState_UpdateLearningRate(t *testing.T) { state := types.DefaultAIMDState() params := types.DefaultAIMDParams() - state.UpdateLearningRate(params) + state.UpdateLearningRate(params, types.DefaultAIMDMaxBlockSize) expectedLearningRate := params.MinLearningRate.Add(params.Alpha) require.True(t, expectedLearningRate.Equal(state.LearningRate)) }) @@ -505,7 +499,7 @@ func TestState_UpdateLearningRate(t *testing.T) { state.Window[i] = params.TargetBlockUtilization } - state.UpdateLearningRate(params) + state.UpdateLearningRate(params, types.DefaultAIMDMaxBlockSize) expectedLearningRate := defaultLR.Mul(params.Beta) require.True(t, expectedLearningRate.Equal(state.LearningRate)) }) @@ -518,10 +512,10 @@ func TestState_UpdateLearningRate(t *testing.T) { params := types.DefaultAIMDParams() for i := 0; i < len(state.Window); i++ { - state.Window[i] = params.MaxBlockUtilization + state.Window[i] = types.DefaultAIMDMaxBlockSize } - state.UpdateLearningRate(params) + state.UpdateLearningRate(params, types.DefaultAIMDMaxBlockSize) expectedLearningRate := defaultLR.Add(params.Alpha) require.True(t, expectedLearningRate.Equal(state.LearningRate)) }) @@ -535,13 +529,13 @@ func TestState_UpdateLearningRate(t *testing.T) { for i := 0; i < len(state.Window); i++ { if i%2 == 0 { - state.Window[i] = params.MaxBlockUtilization + state.Window[i] = types.DefaultAIMDMaxBlockSize } else { state.Window[i] = 0 } } - state.UpdateLearningRate(params) + state.UpdateLearningRate(params, types.DefaultAIMDMaxBlockSize) expectedLearningRate := defaultLR.Mul(params.Beta) require.True(t, expectedLearningRate.Equal(state.LearningRate)) }) @@ -555,13 +549,13 @@ func TestState_UpdateLearningRate(t *testing.T) { for i := 0; i < len(state.Window); i++ { if i%2 == 0 { - state.Window[i] = params.MaxBlockUtilization + state.Window[i] = types.DefaultAIMDMaxBlockSize } else { state.Window[i] = params.TargetBlockUtilization + 1 } } - state.UpdateLearningRate(params) + state.UpdateLearningRate(params, types.DefaultAIMDMaxBlockSize) expectedLearningRate := defaultLR.Add(params.Alpha) require.True(t, expectedLearningRate.Equal(state.LearningRate)) }) @@ -592,10 +586,10 @@ func TestState_GetNetUtilization(t *testing.T) { state := types.DefaultState() params := types.DefaultParams() - state.Window[0] = params.MaxBlockUtilization + state.Window[0] = types.DefaultMaxBlockUtilization netUtilization := state.GetNetUtilization(params) - expectedUtilization := math.NewIntFromUint64(params.MaxBlockUtilization - params.TargetBlockUtilization) + expectedUtilization := math.NewIntFromUint64(types.DefaultMaxBlockUtilization - params.TargetBlockUtilization) require.True(t, expectedUtilization.Equal(netUtilization)) }) @@ -615,13 +609,13 @@ func TestState_GetNetUtilization(t *testing.T) { params := types.DefaultAIMDParams() for i := 0; i < len(state.Window); i++ { - state.Window[i] = params.MaxBlockUtilization + state.Window[i] = types.DefaultAIMDMaxBlockSize } netUtilization := state.GetNetUtilization(params) multiple := math.NewIntFromUint64(uint64(len(state.Window))) - expectedUtilization := math.NewIntFromUint64(params.MaxBlockUtilization).Sub(math.NewIntFromUint64(params.TargetBlockUtilization)).Mul(multiple) + expectedUtilization := math.NewIntFromUint64(types.DefaultAIMDMaxBlockSize).Sub(math.NewIntFromUint64(params.TargetBlockUtilization)).Mul(multiple) require.True(t, expectedUtilization.Equal(netUtilization)) }) @@ -631,7 +625,7 @@ func TestState_GetNetUtilization(t *testing.T) { for i := 0; i < len(state.Window); i++ { if i%2 == 0 { - state.Window[i] = params.MaxBlockUtilization + state.Window[i] = types.DefaultAIMDMaxBlockSize } else { state.Window[i] = 0 } @@ -648,16 +642,16 @@ func TestState_GetNetUtilization(t *testing.T) { for i := 0; i < len(state.Window); i++ { if i%2 == 0 { - state.Window[i] = params.MaxBlockUtilization + state.Window[i] = types.DefaultAIMDMaxBlockSize } else { state.Window[i] = params.TargetBlockUtilization } } netUtilization := state.GetNetUtilization(params) - first := math.NewIntFromUint64(params.MaxBlockUtilization).Mul(math.NewIntFromUint64(params.Window / 2)) - second := math.NewIntFromUint64(params.TargetBlockUtilization).Mul(math.NewIntFromUint64(params.Window / 2)) - expectedUtilization := first.Add(second).Sub(math.NewIntFromUint64(params.TargetBlockUtilization).Mul(math.NewIntFromUint64(params.Window))) + first := math.NewIntFromUint64(types.DefaultAIMDMaxBlockSize).Mul(math.NewIntFromUint64(params.WindowSize / 2)) + second := math.NewIntFromUint64(params.TargetBlockUtilization).Mul(math.NewIntFromUint64(params.WindowSize / 2)) + expectedUtilization := first.Add(second).Sub(math.NewIntFromUint64(params.TargetBlockUtilization).Mul(math.NewIntFromUint64(params.WindowSize))) require.True(t, expectedUtilization.Equal(netUtilization)) }) @@ -667,7 +661,6 @@ func TestState_GetNetUtilization(t *testing.T) { params := types.DefaultAIMDParams() params.TargetBlockUtilization = 100 - params.MaxBlockUtilization = 200 state.Window[0] = 100 state.Window[1] = 200 @@ -685,7 +678,6 @@ func TestState_GetNetUtilization(t *testing.T) { params := types.DefaultAIMDParams() params.TargetBlockUtilization = 100 - params.MaxBlockUtilization = 200 state.Window[0] = 0 state.Window[1] = 25 @@ -701,9 +693,8 @@ func TestState_GetNetUtilization(t *testing.T) { func TestState_GetAverageUtilization(t *testing.T) { t.Run("empty block with default eip-1559", func(t *testing.T) { state := types.DefaultState() - params := types.DefaultParams() - avgUtilization := state.GetAverageUtilization(params) + avgUtilization := state.GetAverageUtilization(types.DefaultMaxBlockUtilization) expectedUtilization := math.LegacyZeroDec() require.True(t, expectedUtilization.Equal(avgUtilization)) }) @@ -714,27 +705,25 @@ func TestState_GetAverageUtilization(t *testing.T) { state.Window[0] = params.TargetBlockUtilization - avgUtilization := state.GetAverageUtilization(params) + avgUtilization := state.GetAverageUtilization(types.DefaultMaxBlockUtilization) expectedUtilization := math.LegacyMustNewDecFromStr("0.5") require.True(t, expectedUtilization.Equal(avgUtilization)) }) t.Run("full block with default eip-1559", func(t *testing.T) { state := types.DefaultState() - params := types.DefaultParams() - state.Window[0] = params.MaxBlockUtilization + state.Window[0] = types.DefaultMaxBlockUtilization - avgUtilization := state.GetAverageUtilization(params) + avgUtilization := state.GetAverageUtilization(types.DefaultMaxBlockUtilization) expectedUtilization := math.LegacyMustNewDecFromStr("1.0") require.True(t, expectedUtilization.Equal(avgUtilization)) }) t.Run("empty block with default aimd eip-1559", func(t *testing.T) { state := types.DefaultAIMDState() - params := types.DefaultAIMDParams() - avgUtilization := state.GetAverageUtilization(params) + avgUtilization := state.GetAverageUtilization(types.DefaultAIMDMaxBlockSize) expectedUtilization := math.LegacyZeroDec() require.True(t, expectedUtilization.Equal(avgUtilization)) }) @@ -747,37 +736,35 @@ func TestState_GetAverageUtilization(t *testing.T) { state.Window[i] = params.TargetBlockUtilization } - avgUtilization := state.GetAverageUtilization(params) + avgUtilization := state.GetAverageUtilization(types.DefaultAIMDMaxBlockSize) expectedUtilization := math.LegacyMustNewDecFromStr("0.5") require.True(t, expectedUtilization.Equal(avgUtilization)) }) t.Run("full blocks with default aimd eip-1559", func(t *testing.T) { state := types.DefaultAIMDState() - params := types.DefaultAIMDParams() for i := 0; i < len(state.Window); i++ { - state.Window[i] = params.MaxBlockUtilization + state.Window[i] = types.DefaultAIMDMaxBlockSize } - avgUtilization := state.GetAverageUtilization(params) + avgUtilization := state.GetAverageUtilization(types.DefaultAIMDMaxBlockSize) expectedUtilization := math.LegacyMustNewDecFromStr("1.0") require.True(t, expectedUtilization.Equal(avgUtilization)) }) t.Run("varying blocks with default aimd eip-1559", func(t *testing.T) { state := types.DefaultAIMDState() - params := types.DefaultAIMDParams() for i := 0; i < len(state.Window); i++ { if i%2 == 0 { - state.Window[i] = params.MaxBlockUtilization + state.Window[i] = types.DefaultAIMDMaxBlockSize } else { state.Window[i] = 0 } } - avgUtilization := state.GetAverageUtilization(params) + avgUtilization := state.GetAverageUtilization(types.DefaultAIMDMaxBlockSize) expectedUtilization := math.LegacyMustNewDecFromStr("0.5") require.True(t, expectedUtilization.Equal(avgUtilization)) }) @@ -788,13 +775,13 @@ func TestState_GetAverageUtilization(t *testing.T) { for i := 0; i < len(state.Window); i++ { if i%2 == 0 { - state.Window[i] = params.MaxBlockUtilization + state.Window[i] = types.DefaultAIMDMaxBlockSize } else { state.Window[i] = params.TargetBlockUtilization } } - avgUtilization := state.GetAverageUtilization(params) + avgUtilization := state.GetAverageUtilization(types.DefaultAIMDMaxBlockSize) expectedUtilization := math.LegacyMustNewDecFromStr("0.75") require.True(t, expectedUtilization.Equal(avgUtilization)) }) @@ -805,14 +792,14 @@ func TestState_GetAverageUtilization(t *testing.T) { params := types.DefaultAIMDParams() params.TargetBlockUtilization = 100 - params.MaxBlockUtilization = 200 + maxUtilization := uint64(200) state.Window[0] = 100 state.Window[1] = 200 state.Window[2] = 0 state.Window[3] = 50 - avgUtilization := state.GetAverageUtilization(params) + avgUtilization := state.GetAverageUtilization(maxUtilization) expectedUtilization := math.LegacyMustNewDecFromStr("0.4375") require.True(t, expectedUtilization.Equal(avgUtilization)) }) @@ -822,16 +809,16 @@ func TestState_GetAverageUtilization(t *testing.T) { state.Window = make([]uint64, 4) params := types.DefaultAIMDParams() - params.Window = 4 + params.WindowSize = 4 params.TargetBlockUtilization = 100 - params.MaxBlockUtilization = 200 + maxUtilization := uint64(200) state.Window[0] = 0 state.Window[1] = 25 state.Window[2] = 50 state.Window[3] = 75 - avgUtilization := state.GetAverageUtilization(params) + avgUtilization := state.GetAverageUtilization(maxUtilization) expectedUtilization := math.LegacyMustNewDecFromStr("0.1875") require.True(t, expectedUtilization.Equal(avgUtilization)) })