diff --git a/api/layer/oracle/aggregate.pulsar.go b/api/layer/oracle/aggregate.pulsar.go index 684f52d19..7e84d0230 100644 --- a/api/layer/oracle/aggregate.pulsar.go +++ b/api/layer/oracle/aggregate.pulsar.go @@ -79,6 +79,7 @@ var ( fd_Aggregate_nonce protoreflect.FieldDescriptor fd_Aggregate_aggregateReportIndex protoreflect.FieldDescriptor fd_Aggregate_height protoreflect.FieldDescriptor + fd_Aggregate_micro_height protoreflect.FieldDescriptor ) func init() { @@ -94,6 +95,7 @@ func init() { fd_Aggregate_nonce = md_Aggregate.Fields().ByName("nonce") fd_Aggregate_aggregateReportIndex = md_Aggregate.Fields().ByName("aggregateReportIndex") fd_Aggregate_height = md_Aggregate.Fields().ByName("height") + fd_Aggregate_micro_height = md_Aggregate.Fields().ByName("micro_height") } var _ protoreflect.Message = (*fastReflection_Aggregate)(nil) @@ -221,6 +223,12 @@ func (x *fastReflection_Aggregate) Range(f func(protoreflect.FieldDescriptor, pr return } } + if x.MicroHeight != int64(0) { + value := protoreflect.ValueOfInt64(x.MicroHeight) + if !f(fd_Aggregate_micro_height, value) { + return + } + } } // Has reports whether a field is populated. @@ -256,6 +264,8 @@ func (x *fastReflection_Aggregate) Has(fd protoreflect.FieldDescriptor) bool { return x.AggregateReportIndex != int64(0) case "layer.oracle.Aggregate.height": return x.Height != int64(0) + case "layer.oracle.Aggregate.micro_height": + return x.MicroHeight != int64(0) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: layer.oracle.Aggregate")) @@ -292,6 +302,8 @@ func (x *fastReflection_Aggregate) Clear(fd protoreflect.FieldDescriptor) { x.AggregateReportIndex = int64(0) case "layer.oracle.Aggregate.height": x.Height = int64(0) + case "layer.oracle.Aggregate.micro_height": + x.MicroHeight = int64(0) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: layer.oracle.Aggregate")) @@ -341,6 +353,9 @@ func (x *fastReflection_Aggregate) Get(descriptor protoreflect.FieldDescriptor) case "layer.oracle.Aggregate.height": value := x.Height return protoreflect.ValueOfInt64(value) + case "layer.oracle.Aggregate.micro_height": + value := x.MicroHeight + return protoreflect.ValueOfInt64(value) default: if descriptor.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: layer.oracle.Aggregate")) @@ -383,6 +398,8 @@ func (x *fastReflection_Aggregate) Set(fd protoreflect.FieldDescriptor, value pr x.AggregateReportIndex = value.Int() case "layer.oracle.Aggregate.height": x.Height = value.Int() + case "layer.oracle.Aggregate.micro_height": + x.MicroHeight = value.Int() default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: layer.oracle.Aggregate")) @@ -427,6 +444,8 @@ func (x *fastReflection_Aggregate) Mutable(fd protoreflect.FieldDescriptor) prot panic(fmt.Errorf("field aggregateReportIndex of message layer.oracle.Aggregate is not mutable")) case "layer.oracle.Aggregate.height": panic(fmt.Errorf("field height of message layer.oracle.Aggregate is not mutable")) + case "layer.oracle.Aggregate.micro_height": + panic(fmt.Errorf("field micro_height of message layer.oracle.Aggregate is not mutable")) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: layer.oracle.Aggregate")) @@ -461,6 +480,8 @@ func (x *fastReflection_Aggregate) NewField(fd protoreflect.FieldDescriptor) pro return protoreflect.ValueOfInt64(int64(0)) case "layer.oracle.Aggregate.height": return protoreflect.ValueOfInt64(int64(0)) + case "layer.oracle.Aggregate.micro_height": + return protoreflect.ValueOfInt64(int64(0)) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: layer.oracle.Aggregate")) @@ -566,6 +587,9 @@ func (x *fastReflection_Aggregate) ProtoMethods() *protoiface.Methods { if x.Height != 0 { n += 1 + runtime.Sov(uint64(x.Height)) } + if x.MicroHeight != 0 { + n += 1 + runtime.Sov(uint64(x.MicroHeight)) + } if x.unknownFields != nil { n += len(x.unknownFields) } @@ -595,6 +619,11 @@ func (x *fastReflection_Aggregate) ProtoMethods() *protoiface.Methods { i -= len(x.unknownFields) copy(dAtA[i:], x.unknownFields) } + if x.MicroHeight != 0 { + i = runtime.EncodeVarint(dAtA, i, uint64(x.MicroHeight)) + i-- + dAtA[i] = 0x58 + } if x.Height != 0 { i = runtime.EncodeVarint(dAtA, i, uint64(x.Height)) i-- @@ -956,6 +985,25 @@ func (x *fastReflection_Aggregate) ProtoMethods() *protoiface.Methods { break } } + case 11: + if wireType != 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field MicroHeight", wireType) + } + x.MicroHeight = 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.MicroHeight |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := runtime.Skip(dAtA[iNdEx:]) @@ -1513,6 +1561,8 @@ type Aggregate struct { Nonce uint64 `protobuf:"varint,8,opt,name=nonce,proto3" json:"nonce,omitempty"` AggregateReportIndex int64 `protobuf:"varint,9,opt,name=aggregateReportIndex,proto3" json:"aggregateReportIndex,omitempty"` Height int64 `protobuf:"varint,10,opt,name=height,proto3" json:"height,omitempty"` + // height of the micro report + MicroHeight int64 `protobuf:"varint,11,opt,name=micro_height,json=microHeight,proto3" json:"micro_height,omitempty"` } func (x *Aggregate) Reset() { @@ -1605,6 +1655,13 @@ func (x *Aggregate) GetHeight() int64 { return 0 } +func (x *Aggregate) GetMicroHeight() int64 { + if x != nil { + return x.MicroHeight + } + return 0 +} + type AvailableTimestamps struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -1651,7 +1708,7 @@ var file_layer_oracle_aggregate_proto_rawDesc = []byte{ 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x25, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x2f, 0x6f, 0x72, 0x61, 0x63, 0x6c, 0x65, 0x2f, 0x61, 0x67, 0x67, 0x72, 0x65, 0x67, 0x61, 0x74, 0x65, 0x5f, 0x72, 0x65, 0x70, 0x6f, - 0x72, 0x74, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x8b, 0x03, 0x0a, 0x09, 0x41, + 0x72, 0x74, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xae, 0x03, 0x0a, 0x09, 0x41, 0x67, 0x67, 0x72, 0x65, 0x67, 0x61, 0x74, 0x65, 0x12, 0x19, 0x0a, 0x08, 0x71, 0x75, 0x65, 0x72, 0x79, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x71, 0x75, 0x65, 0x72, 0x79, 0x49, 0x64, 0x12, 0x26, 0x0a, 0x0e, 0x61, 0x67, 0x67, 0x72, 0x65, 0x67, 0x61, 0x74, 0x65, @@ -1676,23 +1733,26 @@ var file_layer_oracle_aggregate_proto_rawDesc = []byte{ 0x6e, 0x64, 0x65, 0x78, 0x18, 0x09, 0x20, 0x01, 0x28, 0x03, 0x52, 0x14, 0x61, 0x67, 0x67, 0x72, 0x65, 0x67, 0x61, 0x74, 0x65, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x12, 0x16, 0x0a, 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x03, - 0x52, 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x22, 0x5b, 0x0a, 0x13, 0x41, 0x76, 0x61, 0x69, - 0x6c, 0x61, 0x62, 0x6c, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x73, 0x12, - 0x44, 0x0a, 0x0a, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x73, 0x18, 0x01, 0x20, - 0x03, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x42, - 0x08, 0xc8, 0xde, 0x1f, 0x00, 0x90, 0xdf, 0x1f, 0x01, 0x52, 0x0a, 0x74, 0x69, 0x6d, 0x65, 0x73, - 0x74, 0x61, 0x6d, 0x70, 0x73, 0x42, 0xa0, 0x01, 0x0a, 0x10, 0x63, 0x6f, 0x6d, 0x2e, 0x6c, 0x61, - 0x79, 0x65, 0x72, 0x2e, 0x6f, 0x72, 0x61, 0x63, 0x6c, 0x65, 0x42, 0x0e, 0x41, 0x67, 0x67, 0x72, - 0x65, 0x67, 0x61, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x2b, 0x67, 0x69, - 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x74, 0x65, 0x6c, 0x6c, 0x6f, 0x72, 0x2d, - 0x69, 0x6f, 0x2f, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x6c, 0x61, 0x79, - 0x65, 0x72, 0x2f, 0x6f, 0x72, 0x61, 0x63, 0x6c, 0x65, 0xa2, 0x02, 0x03, 0x4c, 0x4f, 0x58, 0xaa, - 0x02, 0x0c, 0x4c, 0x61, 0x79, 0x65, 0x72, 0x2e, 0x4f, 0x72, 0x61, 0x63, 0x6c, 0x65, 0xca, 0x02, - 0x0c, 0x4c, 0x61, 0x79, 0x65, 0x72, 0x5c, 0x4f, 0x72, 0x61, 0x63, 0x6c, 0x65, 0xe2, 0x02, 0x18, - 0x4c, 0x61, 0x79, 0x65, 0x72, 0x5c, 0x4f, 0x72, 0x61, 0x63, 0x6c, 0x65, 0x5c, 0x47, 0x50, 0x42, - 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x0d, 0x4c, 0x61, 0x79, 0x65, 0x72, - 0x3a, 0x3a, 0x4f, 0x72, 0x61, 0x63, 0x6c, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x52, 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x12, 0x21, 0x0a, 0x0c, 0x6d, 0x69, 0x63, 0x72, + 0x6f, 0x5f, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0b, + 0x6d, 0x69, 0x63, 0x72, 0x6f, 0x48, 0x65, 0x69, 0x67, 0x68, 0x74, 0x22, 0x5b, 0x0a, 0x13, 0x41, + 0x76, 0x61, 0x69, 0x6c, 0x61, 0x62, 0x6c, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, + 0x70, 0x73, 0x12, 0x44, 0x0a, 0x0a, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x73, + 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, + 0x6d, 0x70, 0x42, 0x08, 0xc8, 0xde, 0x1f, 0x00, 0x90, 0xdf, 0x1f, 0x01, 0x52, 0x0a, 0x74, 0x69, + 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x73, 0x42, 0xa0, 0x01, 0x0a, 0x10, 0x63, 0x6f, 0x6d, + 0x2e, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x2e, 0x6f, 0x72, 0x61, 0x63, 0x6c, 0x65, 0x42, 0x0e, 0x41, + 0x67, 0x67, 0x72, 0x65, 0x67, 0x61, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, + 0x2b, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x74, 0x65, 0x6c, 0x6c, + 0x6f, 0x72, 0x2d, 0x69, 0x6f, 0x2f, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x2f, 0x61, 0x70, 0x69, 0x2f, + 0x6c, 0x61, 0x79, 0x65, 0x72, 0x2f, 0x6f, 0x72, 0x61, 0x63, 0x6c, 0x65, 0xa2, 0x02, 0x03, 0x4c, + 0x4f, 0x58, 0xaa, 0x02, 0x0c, 0x4c, 0x61, 0x79, 0x65, 0x72, 0x2e, 0x4f, 0x72, 0x61, 0x63, 0x6c, + 0x65, 0xca, 0x02, 0x0c, 0x4c, 0x61, 0x79, 0x65, 0x72, 0x5c, 0x4f, 0x72, 0x61, 0x63, 0x6c, 0x65, + 0xe2, 0x02, 0x18, 0x4c, 0x61, 0x79, 0x65, 0x72, 0x5c, 0x4f, 0x72, 0x61, 0x63, 0x6c, 0x65, 0x5c, + 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x0d, 0x4c, 0x61, + 0x79, 0x65, 0x72, 0x3a, 0x3a, 0x4f, 0x72, 0x61, 0x63, 0x6c, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x33, } var ( diff --git a/proto/layer/oracle/aggregate.proto b/proto/layer/oracle/aggregate.proto index 90ae94881..5fb7c47be 100644 --- a/proto/layer/oracle/aggregate.proto +++ b/proto/layer/oracle/aggregate.proto @@ -18,6 +18,8 @@ message Aggregate { uint64 nonce = 8; int64 aggregateReportIndex = 9; int64 height = 10; + // height of the micro report + int64 micro_height = 11; } message AvailableTimestamps { diff --git a/tests/integration/reporter_keeper_test.go b/tests/integration/reporter_keeper_test.go index e82a71af4..a0466ae2c 100644 --- a/tests/integration/reporter_keeper_test.go +++ b/tests/integration/reporter_keeper_test.go @@ -222,3 +222,69 @@ func (s *IntegrationTestSuite) TestDelegatorCount() { s.NoError(err) s.Equal(uint64(5), del.DelegationCount) } + +// add 100 delegators to a reporter and check if the delegator count is 100 +// and what happens when the 101st delegator tries to delegate +func (s *IntegrationTestSuite) TestMaxDelegatorCount() { + valAccs, valAddrs, _ := s.Setup.CreateValidator(1) + stakingmsgServer := stakingkeeper.NewMsgServerImpl(s.Setup.Stakingkeeper) + valAcc := valAccs[0] + valAdd := valAddrs[0] + k1 := valAcc + var k2 sdk.AccAddress + // delegate a 100 delegators + for i := 0; i < 100; i++ { + delegatorAddr := sample.AccAddressBytes() + s.Setup.MintTokens(delegatorAddr, math.NewInt(1000*1e6)) + msgDelegate := stakingtypes.NewMsgDelegate( + delegatorAddr.String(), + valAdd.String(), + sdk.NewInt64Coin(s.Setup.Denom, 1000*1e6), + ) + if i == 99 { + k2 = delegatorAddr + } + _, err := stakingmsgServer.Delegate(s.Setup.Ctx, msgDelegate) + s.NoError(err) + } + + // check delegator count + rep, err := s.Setup.Reporterkeeper.Reporters.Get(s.Setup.Ctx, valAcc) + s.NoError(err) + s.Equal(uint64(100), rep.DelegatorsCount) + // check how many reporters are there + iter, err := s.Setup.Reporterkeeper.Reporters.Iterate(s.Setup.Ctx, nil) + s.NoError(err) + list, err := iter.Keys() + s.NoError(err) + s.Equal(2, len(list)) + + rep1, err := s.Setup.Reporterkeeper.Reporters.Get(s.Setup.Ctx, k1) + s.NoError(err) + s.Equal(uint64(100), rep1.DelegatorsCount) + rep2, err := s.Setup.Reporterkeeper.Reporters.Get(s.Setup.Ctx, k2) + s.NoError(err) + s.Equal(uint64(1), rep2.DelegatorsCount) + + // delegate 102nd delegator + delegatorAddr := sample.AccAddressBytes() + s.Setup.MintTokens(delegatorAddr, math.NewInt(1000*1e6)) + msgDelegate := stakingtypes.NewMsgDelegate( + delegatorAddr.String(), + valAdd.String(), + sdk.NewInt64Coin(s.Setup.Denom, 1000*1e6), + ) + _, err = stakingmsgServer.Delegate(s.Setup.Ctx, msgDelegate) + s.NoError(err) + + // check delegator count + iter, err = s.Setup.Reporterkeeper.Reporters.Iterate(s.Setup.Ctx, nil) + s.NoError(err) + list, err = iter.Keys() + s.NoError(err) + s.Equal(3, len(list)) + // delegator should be come a third reporter + rep3, err := s.Setup.Reporterkeeper.Reporters.Get(s.Setup.Ctx, delegatorAddr) + s.NoError(err) + s.Equal(uint64(1), rep3.DelegatorsCount) +} diff --git a/tests/setup.go b/tests/setup.go index d3167ad4b..1084331c6 100644 --- a/tests/setup.go +++ b/tests/setup.go @@ -395,3 +395,48 @@ func (s *SharedSetup) ConvertToAccAddress(priv []ed25519.PrivKey) []sdk.AccAddre } return testAddrs } + +func (s *SharedSetup) CreateValidator(numValidators int) ([]sdk.AccAddress, []sdk.ValAddress, []stakingtypes.Validator) { + require := s.require + + // create account that will become a validator + accountsAddrs := simtestutil.CreateIncrementalAccounts(numValidators) + // mint numTrb for each validator + initCoins := sdk.NewCoin(s.Denom, math.NewInt(5000*1e6)) + for _, acc := range accountsAddrs { + // mint to module + require.NoError(s.Bankkeeper.MintCoins(s.Ctx, authtypes.Minter, sdk.NewCoins(initCoins))) + // send from module to account + require.NoError(s.Bankkeeper.SendCoinsFromModuleToAccount(s.Ctx, authtypes.Minter, acc, sdk.NewCoins(initCoins))) + require.Equal(initCoins, s.Bankkeeper.GetBalance(s.Ctx, acc, s.Denom)) + } + + // get val address for each account + validatorsAddrs := simtestutil.ConvertAddrsToValAddrs(accountsAddrs) + // create pub keys for validators + pubKeys := simtestutil.CreateTestPubKeys(numValidators) + validators := make([]stakingtypes.Validator, numValidators) + stakingServer := stakingkeeper.NewMsgServerImpl(s.Stakingkeeper) + // set each account with proper keepers + for i, pubKey := range pubKeys { + s.Accountkeeper.NewAccountWithAddress(s.Ctx, accountsAddrs[i]) + valMsg, err := stakingtypes.NewMsgCreateValidator( + validatorsAddrs[i].String(), + pubKey, + sdk.NewInt64Coin(s.Denom, 100), + stakingtypes.Description{Moniker: strconv.Itoa(i)}, + stakingtypes.CommissionRates{ + Rate: math.LegacyNewDecWithPrec(5, 1), + MaxRate: math.LegacyNewDecWithPrec(5, 1), + MaxChangeRate: math.LegacyNewDec(0), + }, + math.OneInt()) + require.NoError(err) + + _, err = stakingServer.CreateValidator(s.Ctx, valMsg) + require.NoError(err) + } + _, err := s.Stakingkeeper.EndBlocker(s.Ctx) + require.NoError(err) + return accountsAddrs, validatorsAddrs, validators +} diff --git a/x/bridge/keeper/withdraw_tokens.go b/x/bridge/keeper/withdraw_tokens.go index ca4b4d152..3fb4379be 100644 --- a/x/bridge/keeper/withdraw_tokens.go +++ b/x/bridge/keeper/withdraw_tokens.go @@ -82,6 +82,7 @@ func (k Keeper) createWithdrawalAggregate(goCtx context.Context, amount sdk.Coin Nonce: 0, AggregateReportIndex: 0, Height: ctx.BlockHeight(), + MicroHeight: ctx.BlockHeight(), } return aggregate, nil } diff --git a/x/dispute/keeper/dispute.go b/x/dispute/keeper/dispute.go index 84e60f880..1d5670895 100644 --- a/x/dispute/keeper/dispute.go +++ b/x/dispute/keeper/dispute.go @@ -130,6 +130,11 @@ func (k Keeper) SetNewDispute(ctx sdk.Context, sender sdk.AccAddress, msg types. // Slash and jail reporter func (k Keeper) SlashAndJailReporter(ctx sdk.Context, report oracletypes.MicroReport, category types.DisputeCategory, hashId []byte) error { + // flag aggregate report if necessary + err := k.oracleKeeper.FlagAggregateReport(ctx, report) + if err != nil { + return err + } reporterAddr := sdk.MustAccAddressFromBech32(report.Reporter) slashFactor, jailDuration, err := GetSlashPercentageAndJailDuration(category) diff --git a/x/dispute/keeper/dispute_test.go b/x/dispute/keeper/dispute_test.go index 3ea0f0386..dfa8725d7 100644 --- a/x/dispute/keeper/dispute_test.go +++ b/x/dispute/keeper/dispute_test.go @@ -154,6 +154,7 @@ func (s *KeeperTestSuite) TestSlashAndJailReporter() { reporterAcc := sdk.MustAccAddressFromBech32(report.Reporter) s.reporterKeeper.On("EscrowReporterStake", s.ctx, reporterAcc, report.Power, int64(1), math.NewInt(10000), dispute.HashId).Return(nil) s.reporterKeeper.On("JailReporter", s.ctx, reporterAcc, int64(0)).Return(nil) + s.oracleKeeper.On("FlagAggregateReport", s.ctx, report).Return(nil) s.NoError(s.disputeKeeper.SlashAndJailReporter(s.ctx, report, dispute.DisputeCategory, dispute.HashId)) } @@ -193,6 +194,7 @@ func (s *KeeperTestSuite) TestGetSlashPercentageAndJailDuration() { cat: 4, }, } + s.oracleKeeper.On("FlagAggregateReport", s.ctx, report()).Return(nil) for _, tc := range testCases { tc := tc @@ -254,6 +256,7 @@ func (s *KeeperTestSuite) TestAddDisputeRound() { fee := sdk.NewCoin("loya", math.NewInt(10)) s.bankKeeper.On("HasBalance", s.ctx, sender, fee).Return(true) s.bankKeeper.On("SendCoinsFromAccountToModule", s.ctx, sender, types.ModuleName, sdk.NewCoins(fee)).Return(nil) + s.oracleKeeper.On("FlagAggregateReport", s.ctx, report()).Return(nil) s.NoError(s.disputeKeeper.AddDisputeRound(s.ctx, sender, dispute, msg)) dispute1, err := s.disputeKeeper.Disputes.Get(s.ctx, 1) diff --git a/x/dispute/keeper/msg_server_add_fee_to_dispute_test.go b/x/dispute/keeper/msg_server_add_fee_to_dispute_test.go index acd2b4459..ef77a08eb 100644 --- a/x/dispute/keeper/msg_server_add_fee_to_dispute_test.go +++ b/x/dispute/keeper/msg_server_add_fee_to_dispute_test.go @@ -3,6 +3,7 @@ package keeper_test import ( "time" + "github.com/stretchr/testify/mock" "github.com/tellor-io/layer/testutil/sample" layer "github.com/tellor-io/layer/types" "github.com/tellor-io/layer/x/dispute/types" @@ -46,6 +47,7 @@ func (k *KeeperTestSuite) TestMsgServerAddFeeToDispute() { dispute.FeeTotal = math.ZeroInt() k.NoError(k.disputeKeeper.Disputes.Set(k.ctx, dispute.DisputeId, dispute)) fee := sdk.NewCoin(layer.BondDenom, math.NewInt(10000)) + k.oracleKeeper.On("FlagAggregateReport", k.ctx, mock.Anything).Return(nil) k.bankKeeper.On("HasBalance", k.ctx, creator, fee).Return(true) k.bankKeeper.On("SendCoinsFromAccountToModule", k.ctx, creator, types.ModuleName, sdk.NewCoins(fee)).Return(nil) k.reporterKeeper.On("EscrowReporterStake", k.ctx, sdk.MustAccAddressFromBech32(dispute.ReportEvidence.Reporter), dispute.ReportEvidence.Power, int64(1), dispute.SlashAmount, dispute.HashId).Return(nil) diff --git a/x/dispute/keeper/msg_server_propose_dispute_test.go b/x/dispute/keeper/msg_server_propose_dispute_test.go index e64014724..f7d666688 100644 --- a/x/dispute/keeper/msg_server_propose_dispute_test.go +++ b/x/dispute/keeper/msg_server_propose_dispute_test.go @@ -44,6 +44,7 @@ func (s *KeeperTestSuite) TestMsgProposeDisputeFromAccount() sdk.AccAddress { s.bankKeeper.On("HasBalance", s.ctx, addr, fee).Return(true) s.bankKeeper.On("SendCoinsFromAccountToModule", s.ctx, addr, mock.Anything, sdk.NewCoins(fee)).Return(nil) + s.oracleKeeper.On("FlagAggregateReport", s.ctx, report).Return(nil) msgRes, err := s.msgServer.ProposeDispute(s.ctx, &msg) s.NoError(err) diff --git a/x/dispute/mocks/OracleKeeper.go b/x/dispute/mocks/OracleKeeper.go index b6bf71e2e..8c9aa2b64 100644 --- a/x/dispute/mocks/OracleKeeper.go +++ b/x/dispute/mocks/OracleKeeper.go @@ -5,11 +5,13 @@ package mocks import ( context "context" + cosmos_sdktypes "github.com/cosmos/cosmos-sdk/types" + math "cosmossdk.io/math" mock "github.com/stretchr/testify/mock" - types "github.com/cosmos/cosmos-sdk/types" + types "github.com/tellor-io/layer/x/oracle/types" ) // OracleKeeper is an autogenerated mock type for the OracleKeeper type @@ -17,22 +19,36 @@ type OracleKeeper struct { mock.Mock } +// FlagAggregateReport provides a mock function with given fields: ctx, report +func (_m *OracleKeeper) FlagAggregateReport(ctx context.Context, report types.MicroReport) error { + ret := _m.Called(ctx, report) + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, types.MicroReport) error); ok { + r0 = rf(ctx, report) + } else { + r0 = ret.Error(0) + } + + return r0 +} + // GetTipsAtBlockForTipper provides a mock function with given fields: ctx, blockNumber, tipper -func (_m *OracleKeeper) GetTipsAtBlockForTipper(ctx context.Context, blockNumber int64, tipper types.AccAddress) (math.Int, error) { +func (_m *OracleKeeper) GetTipsAtBlockForTipper(ctx context.Context, blockNumber int64, tipper cosmos_sdktypes.AccAddress) (math.Int, error) { ret := _m.Called(ctx, blockNumber, tipper) var r0 math.Int var r1 error - if rf, ok := ret.Get(0).(func(context.Context, int64, types.AccAddress) (math.Int, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, int64, cosmos_sdktypes.AccAddress) (math.Int, error)); ok { return rf(ctx, blockNumber, tipper) } - if rf, ok := ret.Get(0).(func(context.Context, int64, types.AccAddress) math.Int); ok { + if rf, ok := ret.Get(0).(func(context.Context, int64, cosmos_sdktypes.AccAddress) math.Int); ok { r0 = rf(ctx, blockNumber, tipper) } else { r0 = ret.Get(0).(math.Int) } - if rf, ok := ret.Get(1).(func(context.Context, int64, types.AccAddress) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, int64, cosmos_sdktypes.AccAddress) error); ok { r1 = rf(ctx, blockNumber, tipper) } else { r1 = ret.Error(1) @@ -90,21 +106,21 @@ func (_m *OracleKeeper) GetTotalTipsAtBlock(ctx context.Context, blockNumber int } // GetUserTips provides a mock function with given fields: ctx, tipper -func (_m *OracleKeeper) GetUserTips(ctx context.Context, tipper types.AccAddress) (math.Int, error) { +func (_m *OracleKeeper) GetUserTips(ctx context.Context, tipper cosmos_sdktypes.AccAddress) (math.Int, error) { ret := _m.Called(ctx, tipper) var r0 math.Int var r1 error - if rf, ok := ret.Get(0).(func(context.Context, types.AccAddress) (math.Int, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, cosmos_sdktypes.AccAddress) (math.Int, error)); ok { return rf(ctx, tipper) } - if rf, ok := ret.Get(0).(func(context.Context, types.AccAddress) math.Int); ok { + if rf, ok := ret.Get(0).(func(context.Context, cosmos_sdktypes.AccAddress) math.Int); ok { r0 = rf(ctx, tipper) } else { r0 = ret.Get(0).(math.Int) } - if rf, ok := ret.Get(1).(func(context.Context, types.AccAddress) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, cosmos_sdktypes.AccAddress) error); ok { r1 = rf(ctx, tipper) } else { r1 = ret.Error(1) diff --git a/x/dispute/types/expected_keepers.go b/x/dispute/types/expected_keepers.go index 488c4a3c1..38527e174 100644 --- a/x/dispute/types/expected_keepers.go +++ b/x/dispute/types/expected_keepers.go @@ -3,6 +3,7 @@ package types import ( context "context" + oracletypes "github.com/tellor-io/layer/x/oracle/types" reportertypes "github.com/tellor-io/layer/x/reporter/types" "cosmossdk.io/math" @@ -36,6 +37,7 @@ type OracleKeeper interface { GetUserTips(ctx context.Context, tipper sdk.AccAddress) (math.Int, error) GetTotalTipsAtBlock(ctx context.Context, blockNumber int64) (math.Int, error) GetTipsAtBlockForTipper(ctx context.Context, blockNumber int64, tipper sdk.AccAddress) (math.Int, error) + FlagAggregateReport(ctx context.Context, report oracletypes.MicroReport) error } type ReporterKeeper interface { diff --git a/x/oracle/keeper/indexes.go b/x/oracle/keeper/indexes.go index c406f78e2..4eed818cc 100644 --- a/x/oracle/keeper/indexes.go +++ b/x/oracle/keeper/indexes.go @@ -30,11 +30,12 @@ func NewTipsIndex(sb *collections.SchemaBuilder) tipsIndex { type aggregatesIndex struct { BlockHeight *indexes.Multi[int64, collections.Pair[[]byte, int64], types.Aggregate] + MicroHeight *indexes.Multi[int64, collections.Pair[[]byte, int64], types.Aggregate] } func (a aggregatesIndex) IndexesList() []collections.Index[collections.Pair[[]byte, int64], types.Aggregate] { return []collections.Index[collections.Pair[[]byte, int64], types.Aggregate]{ - a.BlockHeight, + a.BlockHeight, a.MicroHeight, } } @@ -47,6 +48,13 @@ func NewAggregatesIndex(sb *collections.SchemaBuilder) aggregatesIndex { return v.Height, nil }, ), + MicroHeight: indexes.NewMulti( + sb, types.AggregatesMicroHeightIndexPrefix, "aggregates_by_micro_height", + collections.Int64Key, collections.PairKeyCodec[[]byte, int64](collections.BytesKey, collections.Int64Key), + func(_ collections.Pair[[]byte, int64], v types.Aggregate) (int64, error) { + return v.MicroHeight, nil + }, + ), } } diff --git a/x/oracle/keeper/keeper.go b/x/oracle/keeper/keeper.go index a44b3d714..101a66549 100644 --- a/x/oracle/keeper/keeper.go +++ b/x/oracle/keeper/keeper.go @@ -1,6 +1,7 @@ package keeper import ( + "bytes" "context" "fmt" "time" @@ -176,3 +177,30 @@ func (k Keeper) UpdateQuery(ctx context.Context, queryType string, newTimeframe } return nil } + +func (k Keeper) FlagAggregateReport(ctx context.Context, report types.MicroReport) error { + iter, err := k.Aggregates.Indexes.MicroHeight.MatchExact(ctx, report.BlockNumber) + if err != nil { + return err + } + defer iter.Close() + for ; iter.Valid(); iter.Next() { + aggregatekey, err := iter.PrimaryKey() + if err != nil { + return err + } + if bytes.Equal(aggregatekey.K1(), report.QueryId) { + aggregate, err := k.Aggregates.Get(ctx, aggregatekey) + if err != nil { + return err + } + reporter := aggregate.Reporters[aggregate.AggregateReportIndex].Reporter + if sdk.MustAccAddressFromBech32(reporter).Equals(sdk.MustAccAddressFromBech32(report.Reporter)) { + aggregate.Flagged = true + return k.Aggregates.Set(ctx, aggregatekey, aggregate) + } + } + } + + return nil +} diff --git a/x/oracle/keeper/weighted_median.go b/x/oracle/keeper/weighted_median.go index 949dbe39f..fde2dd636 100644 --- a/x/oracle/keeper/weighted_median.go +++ b/x/oracle/keeper/weighted_median.go @@ -46,6 +46,7 @@ func (k Keeper) WeightedMedian(ctx context.Context, reports []types.MicroReport) medianReport.AggregateValue = s.Value medianReport.QueryId = s.QueryId medianReport.AggregateReportIndex = int64(i) + medianReport.MicroHeight = s.BlockNumber break } } diff --git a/x/oracle/keeper/weighted_mode.go b/x/oracle/keeper/weighted_mode.go index be1639e84..d0b02e2de 100644 --- a/x/oracle/keeper/weighted_mode.go +++ b/x/oracle/keeper/weighted_mode.go @@ -56,6 +56,7 @@ func (k Keeper) WeightedMode(ctx context.Context, reports []types.MicroReport) ( ReporterPower: totalReporterPower, Reporters: modeReporters, AggregateReportIndex: modeReportIndex, + MicroHeight: modeReport.BlockNumber, } err := k.SetAggregate(ctx, &aggregateReport) diff --git a/x/oracle/types/aggregate.pb.go b/x/oracle/types/aggregate.pb.go index 37aa4cf58..257bc80e8 100644 --- a/x/oracle/types/aggregate.pb.go +++ b/x/oracle/types/aggregate.pb.go @@ -39,6 +39,8 @@ type Aggregate struct { Nonce uint64 `protobuf:"varint,8,opt,name=nonce,proto3" json:"nonce,omitempty"` AggregateReportIndex int64 `protobuf:"varint,9,opt,name=aggregateReportIndex,proto3" json:"aggregateReportIndex,omitempty"` Height int64 `protobuf:"varint,10,opt,name=height,proto3" json:"height,omitempty"` + // height of the micro report + MicroHeight int64 `protobuf:"varint,11,opt,name=micro_height,json=microHeight,proto3" json:"micro_height,omitempty"` } func (m *Aggregate) Reset() { *m = Aggregate{} } @@ -144,6 +146,13 @@ func (m *Aggregate) GetHeight() int64 { return 0 } +func (m *Aggregate) GetMicroHeight() int64 { + if m != nil { + return m.MicroHeight + } + return 0 +} + type AvailableTimestamps struct { Timestamps []time.Time `protobuf:"bytes,1,rep,name=timestamps,proto3,stdtime" json:"timestamps"` } @@ -196,34 +205,35 @@ func init() { func init() { proto.RegisterFile("layer/oracle/aggregate.proto", fileDescriptor_788ad347f505f8a6) } var fileDescriptor_788ad347f505f8a6 = []byte{ - // 422 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x52, 0x41, 0x6f, 0xd3, 0x30, - 0x14, 0xae, 0xe9, 0xd6, 0x36, 0x66, 0x20, 0x61, 0x2a, 0x64, 0x2a, 0x94, 0x44, 0x13, 0xa0, 0x20, - 0x81, 0x23, 0x8d, 0x33, 0x87, 0x8e, 0x5d, 0x76, 0x43, 0x16, 0xe2, 0x00, 0x87, 0xc9, 0x69, 0xde, - 0x5c, 0x4b, 0x6e, 0x1c, 0x1c, 0x67, 0xac, 0xbf, 0x81, 0xcb, 0x7e, 0xd6, 0x8e, 0x3b, 0x72, 0x02, - 0xd4, 0xfe, 0x11, 0x34, 0xa7, 0x09, 0x5b, 0xb7, 0x5b, 0xbe, 0xf7, 0x7d, 0x9f, 0xdf, 0x7b, 0x79, - 0x1f, 0x7e, 0xa1, 0xc5, 0x12, 0x6c, 0x6a, 0xac, 0x98, 0x69, 0x48, 0x85, 0x94, 0x16, 0xa4, 0x70, - 0xc0, 0x4a, 0x6b, 0x9c, 0x21, 0x7b, 0x9e, 0x65, 0x0d, 0x3b, 0x19, 0x4b, 0x23, 0x8d, 0x27, 0xd2, - 0xeb, 0xaf, 0x46, 0x33, 0x89, 0xa4, 0x31, 0x52, 0x43, 0xea, 0x51, 0x56, 0x9f, 0xa6, 0x4e, 0x2d, - 0xa0, 0x72, 0x62, 0x51, 0x6e, 0x04, 0xaf, 0xee, 0x6f, 0x71, 0x62, 0xa1, 0x34, 0xd6, 0x81, 0x6d, - 0x64, 0xfb, 0x3f, 0xfb, 0x38, 0x98, 0xb6, 0x24, 0x79, 0x8e, 0x47, 0xdf, 0x6b, 0xb0, 0xcb, 0x13, - 0x95, 0x53, 0x14, 0xa3, 0x64, 0x8f, 0x0f, 0x3d, 0x3e, 0xce, 0xc9, 0x6b, 0xfc, 0xb8, 0x7b, 0xe4, - 0x8b, 0xd0, 0x35, 0xd0, 0x07, 0x31, 0x4a, 0x02, 0xbe, 0x55, 0x25, 0x6f, 0xf1, 0x93, 0xae, 0xc2, - 0x37, 0xbd, 0x68, 0xdf, 0x4b, 0xef, 0x12, 0xe4, 0x25, 0x7e, 0xd4, 0x0e, 0xf4, 0xc9, 0xfc, 0x00, - 0x4b, 0x77, 0x62, 0x94, 0xf4, 0xf9, 0xed, 0xe2, 0xf5, 0x9b, 0x95, 0x13, 0x45, 0x2e, 0x6c, 0x7e, - 0x04, 0x67, 0x4a, 0x38, 0x65, 0x0a, 0xba, 0x1b, 0xa3, 0x04, 0xf1, 0xbb, 0x04, 0xf9, 0x80, 0x83, - 0xd6, 0x5e, 0xd1, 0x41, 0xdc, 0x4f, 0x1e, 0x1e, 0x44, 0xec, 0xe6, 0x2f, 0x65, 0xd3, 0xed, 0x39, - 0xf8, 0x7f, 0x07, 0xa1, 0x78, 0x78, 0xaa, 0x85, 0x94, 0x90, 0xd3, 0x61, 0x8c, 0x92, 0x11, 0x6f, - 0x21, 0x19, 0xe3, 0xdd, 0xc2, 0x14, 0x33, 0xa0, 0xa3, 0x18, 0x25, 0x3b, 0xbc, 0x01, 0xe4, 0x00, - 0x8f, 0xb7, 0xf6, 0x3a, 0x2e, 0x72, 0x38, 0xa7, 0x81, 0xdf, 0xe4, 0x5e, 0x8e, 0x3c, 0xc3, 0x83, - 0x39, 0x28, 0x39, 0x77, 0x14, 0x7b, 0xd5, 0x06, 0xed, 0x7f, 0xc3, 0x4f, 0xa7, 0x67, 0x42, 0x69, - 0x91, 0x69, 0xf8, 0xdc, 0x1e, 0xb4, 0x22, 0x47, 0x18, 0x77, 0xe7, 0xad, 0x28, 0xf2, 0x2b, 0x4d, - 0x58, 0x93, 0x00, 0xd6, 0x26, 0x80, 0x75, 0x86, 0xc3, 0xd1, 0xe5, 0xef, 0xa8, 0x77, 0xf1, 0x27, - 0x42, 0xfc, 0x86, 0xef, 0xf0, 0xe3, 0xe5, 0x2a, 0x44, 0x57, 0xab, 0x10, 0xfd, 0x5d, 0x85, 0xe8, - 0x62, 0x1d, 0xf6, 0xae, 0xd6, 0x61, 0xef, 0xd7, 0x3a, 0xec, 0x7d, 0x7d, 0x23, 0x95, 0x9b, 0xd7, - 0x19, 0x9b, 0x99, 0x45, 0xea, 0x40, 0x6b, 0x63, 0xdf, 0x29, 0x93, 0x36, 0x01, 0x3a, 0x6f, 0x23, - 0xe4, 0x96, 0x25, 0x54, 0xd9, 0xc0, 0xb7, 0x7b, 0xff, 0x2f, 0x00, 0x00, 0xff, 0xff, 0xf0, 0xf9, - 0xe2, 0x3e, 0xc2, 0x02, 0x00, 0x00, + // 441 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x92, 0xcf, 0x6e, 0x13, 0x31, + 0x10, 0xc6, 0x63, 0xd2, 0xe6, 0xcf, 0x24, 0x20, 0x61, 0x22, 0x64, 0x22, 0xb4, 0x59, 0x2a, 0x40, + 0x8b, 0x04, 0x5e, 0xa9, 0x9c, 0x39, 0xa4, 0xf4, 0x40, 0x6f, 0xc8, 0x42, 0x1c, 0xe0, 0x10, 0x39, + 0xd9, 0xa9, 0x63, 0xc9, 0x59, 0x07, 0xaf, 0x53, 0x9a, 0xb7, 0xe8, 0x93, 0xf0, 0x1c, 0x3d, 0xf6, + 0xc8, 0x09, 0x50, 0xf2, 0x22, 0xa8, 0xde, 0x6c, 0x28, 0x69, 0x6f, 0x3b, 0xdf, 0xef, 0x1b, 0x8f, + 0x67, 0xfd, 0xc1, 0x53, 0x23, 0x97, 0xe8, 0x52, 0xeb, 0xe4, 0xc4, 0x60, 0x2a, 0x95, 0x72, 0xa8, + 0xa4, 0x47, 0x3e, 0x77, 0xd6, 0x5b, 0xda, 0x0d, 0x94, 0x97, 0xb4, 0xdf, 0x53, 0x56, 0xd9, 0x00, + 0xd2, 0xeb, 0xaf, 0xd2, 0xd3, 0x1f, 0x28, 0x6b, 0x95, 0xc1, 0x34, 0x54, 0xe3, 0xc5, 0x69, 0xea, + 0xf5, 0x0c, 0x0b, 0x2f, 0x67, 0xf3, 0x8d, 0xe1, 0xc5, 0xdd, 0x23, 0x46, 0x0e, 0xe7, 0xd6, 0x79, + 0x74, 0xa5, 0xed, 0xe0, 0x47, 0x1d, 0xda, 0xc3, 0x0a, 0xd2, 0x27, 0xd0, 0xfa, 0xb6, 0x40, 0xb7, + 0x1c, 0xe9, 0x8c, 0x91, 0x98, 0x24, 0x5d, 0xd1, 0x0c, 0xf5, 0x49, 0x46, 0x5f, 0xc2, 0x83, 0xed, + 0x21, 0x9f, 0xa5, 0x59, 0x20, 0xbb, 0x17, 0x93, 0xa4, 0x2d, 0x76, 0x54, 0xfa, 0x1a, 0x1e, 0x6e, + 0x15, 0xb1, 0x99, 0xc5, 0xea, 0xc1, 0x7a, 0x1b, 0xd0, 0xe7, 0x70, 0xbf, 0xba, 0xd0, 0x47, 0xfb, + 0x1d, 0x1d, 0xdb, 0x8b, 0x49, 0x52, 0x17, 0xff, 0x8b, 0xd7, 0x67, 0x16, 0x5e, 0xe6, 0x99, 0x74, + 0xd9, 0x31, 0x9e, 0x69, 0xe9, 0xb5, 0xcd, 0xd9, 0x7e, 0x4c, 0x12, 0x22, 0x6e, 0x03, 0xfa, 0x0e, + 0xda, 0x55, 0x7b, 0xc1, 0x1a, 0x71, 0x3d, 0xe9, 0x1c, 0x0e, 0xf8, 0xcd, 0x5f, 0xca, 0x87, 0xbb, + 0xf7, 0x10, 0xff, 0x3a, 0x28, 0x83, 0xe6, 0xa9, 0x91, 0x4a, 0x61, 0xc6, 0x9a, 0x31, 0x49, 0x5a, + 0xa2, 0x2a, 0x69, 0x0f, 0xf6, 0x73, 0x9b, 0x4f, 0x90, 0xb5, 0x62, 0x92, 0xec, 0x89, 0xb2, 0xa0, + 0x87, 0xd0, 0xdb, 0xd9, 0xeb, 0x24, 0xcf, 0xf0, 0x9c, 0xb5, 0xc3, 0x26, 0x77, 0x32, 0xfa, 0x18, + 0x1a, 0x53, 0xd4, 0x6a, 0xea, 0x19, 0x04, 0xd7, 0xa6, 0xa2, 0xcf, 0xa0, 0x3b, 0xd3, 0x13, 0x67, + 0x47, 0x1b, 0xda, 0x09, 0xb4, 0x13, 0xb4, 0x0f, 0x41, 0x3a, 0xf8, 0x0a, 0x8f, 0x86, 0x67, 0x52, + 0x1b, 0x39, 0x36, 0xf8, 0xa9, 0x7a, 0xf3, 0x82, 0x1e, 0x03, 0x6c, 0x13, 0x50, 0x30, 0x12, 0xb6, + 0xee, 0xf3, 0x32, 0x24, 0xbc, 0x0a, 0x09, 0xdf, 0x36, 0x1c, 0xb5, 0x2e, 0x7f, 0x0d, 0x6a, 0x17, + 0xbf, 0x07, 0x44, 0xdc, 0xe8, 0x3b, 0x7a, 0x7f, 0xb9, 0x8a, 0xc8, 0xd5, 0x2a, 0x22, 0x7f, 0x56, + 0x11, 0xb9, 0x58, 0x47, 0xb5, 0xab, 0x75, 0x54, 0xfb, 0xb9, 0x8e, 0x6a, 0x5f, 0x5e, 0x29, 0xed, + 0xa7, 0x8b, 0x31, 0x9f, 0xd8, 0x59, 0xea, 0xd1, 0x18, 0xeb, 0xde, 0x68, 0x9b, 0x96, 0x19, 0x3b, + 0xaf, 0x52, 0xe6, 0x97, 0x73, 0x2c, 0xc6, 0x8d, 0x30, 0xee, 0xed, 0xdf, 0x00, 0x00, 0x00, 0xff, + 0xff, 0x0c, 0x16, 0x92, 0x3e, 0xe5, 0x02, 0x00, 0x00, } func (m *Aggregate) Marshal() (dAtA []byte, err error) { @@ -246,6 +256,11 @@ func (m *Aggregate) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.MicroHeight != 0 { + i = encodeVarintAggregate(dAtA, i, uint64(m.MicroHeight)) + i-- + dAtA[i] = 0x58 + } if m.Height != 0 { i = encodeVarintAggregate(dAtA, i, uint64(m.Height)) i-- @@ -408,6 +423,9 @@ func (m *Aggregate) Size() (n int) { if m.Height != 0 { n += 1 + sovAggregate(uint64(m.Height)) } + if m.MicroHeight != 0 { + n += 1 + sovAggregate(uint64(m.MicroHeight)) + } return n } @@ -700,6 +718,25 @@ func (m *Aggregate) Unmarshal(dAtA []byte) error { break } } + case 11: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MicroHeight", wireType) + } + m.MicroHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAggregate + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MicroHeight |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipAggregate(dAtA[iNdEx:]) diff --git a/x/oracle/types/keys.go b/x/oracle/types/keys.go index 872bcc3d5..b83b15251 100644 --- a/x/oracle/types/keys.go +++ b/x/oracle/types/keys.go @@ -34,19 +34,20 @@ var ( NoncesPrefix = collections.NewPrefix(7) TotalTipsPrefix = collections.NewPrefix(8) - QuerySeqPrefix = collections.NewPrefix(9) - QueryTipPrefix = collections.NewPrefix(10) - ReportsIdIndexPrefix = collections.NewPrefix(11) - QueryCyclePrefix = collections.NewPrefix(12) - CycleSeqPrefix = collections.NewPrefix(13) - QueryTipPrefix2 = collections.NewPrefix(14) - NextInListPrefix = collections.NewPrefix(15) - QueryRevealedIdsIndexPrefix = collections.NewPrefix(16) - CyclelistPrefix = collections.NewPrefix(17) - QueryTypeIndexPrefix = collections.NewPrefix(18) - AggregatesHeightIndexPrefix = collections.NewPrefix(19) - TipsBlockIndexPrefix = collections.NewPrefix(20) - TipperTotalPrefix = collections.NewPrefix(21) + QuerySeqPrefix = collections.NewPrefix(9) + QueryTipPrefix = collections.NewPrefix(10) + ReportsIdIndexPrefix = collections.NewPrefix(11) + QueryCyclePrefix = collections.NewPrefix(12) + CycleSeqPrefix = collections.NewPrefix(13) + QueryTipPrefix2 = collections.NewPrefix(14) + NextInListPrefix = collections.NewPrefix(15) + QueryRevealedIdsIndexPrefix = collections.NewPrefix(16) + CyclelistPrefix = collections.NewPrefix(17) + QueryTypeIndexPrefix = collections.NewPrefix(18) + AggregatesHeightIndexPrefix = collections.NewPrefix(19) + TipsBlockIndexPrefix = collections.NewPrefix(20) + TipperTotalPrefix = collections.NewPrefix(21) + AggregatesMicroHeightIndexPrefix = collections.NewPrefix(22) ) func KeyPrefix(p string) []byte {