From 6ac122dec703f8696f273c898dde3ad34d85fe7e Mon Sep 17 00:00:00 2001 From: mbreithecker Date: Tue, 11 Jul 2023 15:46:51 +0200 Subject: [PATCH 1/2] feat: store stake security for finalized bundles --- app/app.go | 1 + app/upgrades/v1_3/upgrade.go | 16 ++ proto/kyve/bundles/v1beta1/bundles.proto | 8 +- testutil/integration/checks.go | 2 + x/bundles/keeper/getters_bundles.go | 7 +- .../keeper/keeper_suite_valid_bundles_test.go | 16 +- x/bundles/keeper/logic_bundles.go | 4 + x/bundles/spec/02_state.md | 20 +- x/bundles/types/bundles.pb.go | 183 ++++++++++++------ 9 files changed, 189 insertions(+), 68 deletions(-) diff --git a/app/app.go b/app/app.go index 1335c020..5a7b9adc 100644 --- a/app/app.go +++ b/app/app.go @@ -810,6 +810,7 @@ func NewKYVEApp( app.AccountKeeper, app.BankKeeper, app.StakingKeeper, + app.BundlesKeeper, ), ) diff --git a/app/upgrades/v1_3/upgrade.go b/app/upgrades/v1_3/upgrade.go index b8664693..22c7051e 100644 --- a/app/upgrades/v1_3/upgrade.go +++ b/app/upgrades/v1_3/upgrade.go @@ -3,6 +3,9 @@ package v1_3 import ( "fmt" + bundlesKeeper "github.com/KYVENetwork/chain/x/bundles/keeper" + bundlesTypes "github.com/KYVENetwork/chain/x/bundles/types" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" "github.com/tendermint/tendermint/libs/log" @@ -29,11 +32,13 @@ func CreateUpgradeHandler( accountKeeper authKeeper.AccountKeeper, bankKeeper bankKeeper.Keeper, stakingKeeper stakingKeeper.Keeper, + bundlesKeeper bundlesKeeper.Keeper, ) upgradeTypes.UpgradeHandler { return func(ctx sdk.Context, _ upgradeTypes.Plan, vm module.VersionMap) (module.VersionMap, error) { logger := ctx.Logger().With("upgrade", UpgradeName) CheckPoolAccounts(ctx, logger, poolKeeper) + UpdateBundlesVersionMap(bundlesKeeper, ctx) if ctx.ChainID() == MainnetChainID { for _, address := range InvestorAccounts { @@ -92,3 +97,14 @@ func CheckPoolAccounts(ctx sdk.Context, logger log.Logger, keeper poolKeeper.Kee logger.Info("successfully initialised pool account", "name", name) } } + +func UpdateBundlesVersionMap(keeper bundlesKeeper.Keeper, ctx sdk.Context) { + keeper.SetBundleVersionMap(ctx, bundlesTypes.BundleVersionMap{ + Versions: []*bundlesTypes.BundleVersionEntry{ + { + Height: uint64(ctx.BlockHeight()), + Version: 2, + }, + }, + }) +} diff --git a/proto/kyve/bundles/v1beta1/bundles.proto b/proto/kyve/bundles/v1beta1/bundles.proto index 8ae2ee6d..8c50f54a 100644 --- a/proto/kyve/bundles/v1beta1/bundles.proto +++ b/proto/kyve/bundles/v1beta1/bundles.proto @@ -91,6 +91,8 @@ message FinalizedBundle { uint32 storage_provider_id = 12; // compression_id the id of the compression type with which the data was compressed uint32 compression_id = 13; + // stake_security + StakeSecurity stake_security = 14; } // FinalizedAt ... @@ -101,11 +103,11 @@ message FinalizedAt { uint64 timestamp = 2; } -// FinalizedAt ... +// StakeSecurity stores information about total stake and valid votes with which the bundle got finalized. message StakeSecurity { - // valid_vote_power ... + // valid_vote_power is the total amount of stake of all pool stakers which voted valid for the given bundle. uint64 valid_vote_power = 1; - // total_vote_power ... + // total_vote_power is the total amount of stake that was present during the finalization of the bundle uint64 total_vote_power = 2; } diff --git a/testutil/integration/checks.go b/testutil/integration/checks.go index 0dc7771a..971a28e9 100644 --- a/testutil/integration/checks.go +++ b/testutil/integration/checks.go @@ -278,6 +278,8 @@ func checkFinalizedBundle(queryBundle querytypes.FinalizedBundle, rawBundle bund Expect(queryBundle.FromKey).To(Equal(rawBundle.FromKey)) Expect(queryBundle.StorageProviderId).To(Equal(uint64(rawBundle.StorageProviderId))) Expect(queryBundle.CompressionId).To(Equal(uint64(rawBundle.CompressionId))) + Expect(queryBundle.StakeSecurity.ValidVotePower.Uint64()).To(Equal(rawBundle.StakeSecurity.ValidVotePower)) + Expect(queryBundle.StakeSecurity.TotalVotePower.Uint64()).To(Equal(rawBundle.StakeSecurity.TotalVotePower)) } func (suite *KeeperTestSuite) VerifyBundlesQueries() { diff --git a/x/bundles/keeper/getters_bundles.go b/x/bundles/keeper/getters_bundles.go index 5b82d54b..b4e13f15 100644 --- a/x/bundles/keeper/getters_bundles.go +++ b/x/bundles/keeper/getters_bundles.go @@ -146,7 +146,12 @@ func RawBundleToQueryBundle(rawFinalizedBundle types.FinalizedBundle, versionMap } // Check for version 2 - // TODO will be done by separate PR + if rawFinalizedBundle.FinalizedAt.Height >= versionMap[2] { + validPower := cosmossdk_io_math.NewInt(int64(rawFinalizedBundle.StakeSecurity.ValidVotePower)) + totalPower := cosmossdk_io_math.NewInt(int64(rawFinalizedBundle.StakeSecurity.TotalVotePower)) + finalizedBundle.StakeSecurity.ValidVotePower = &validPower + finalizedBundle.StakeSecurity.TotalVotePower = &totalPower + } return finalizedBundle } diff --git a/x/bundles/keeper/keeper_suite_valid_bundles_test.go b/x/bundles/keeper/keeper_suite_valid_bundles_test.go index 32cd8d4e..007f40ca 100644 --- a/x/bundles/keeper/keeper_suite_valid_bundles_test.go +++ b/x/bundles/keeper/keeper_suite_valid_bundles_test.go @@ -147,6 +147,8 @@ var _ = Describe("valid bundles", Ordered, func() { Expect(finalizedBundle.BundleSummary).To(Equal("test_value")) Expect(finalizedBundle.DataHash).To(Equal("test_hash")) Expect(finalizedBundle.FinalizedAt).NotTo(BeZero()) + Expect(finalizedBundle.StakeSecurity.ValidVotePower).To(Equal(100 * i.KYVE)) + Expect(finalizedBundle.StakeSecurity.TotalVotePower).To(Equal(100 * i.KYVE)) // check if next bundle proposal got registered bundleProposal, bundleProposalFound := s.App().BundlesKeeper.GetBundleProposal(s.Ctx(), 0) @@ -263,6 +265,8 @@ var _ = Describe("valid bundles", Ordered, func() { Expect(finalizedBundle.BundleSummary).To(Equal("test_value")) Expect(finalizedBundle.DataHash).To(Equal("test_hash")) Expect(finalizedBundle.FinalizedAt).NotTo(BeZero()) + Expect(finalizedBundle.StakeSecurity.ValidVotePower).To(Equal(400 * i.KYVE)) + Expect(finalizedBundle.StakeSecurity.TotalVotePower).To(Equal(400 * i.KYVE)) // check if next bundle proposal got registered bundleProposal, bundleProposalFound := s.App().BundlesKeeper.GetBundleProposal(s.Ctx(), 0) @@ -401,6 +405,8 @@ var _ = Describe("valid bundles", Ordered, func() { Expect(finalizedBundle.BundleSummary).To(Equal("test_value")) Expect(finalizedBundle.DataHash).To(Equal("test_hash")) Expect(finalizedBundle.FinalizedAt).NotTo(BeZero()) + Expect(finalizedBundle.StakeSecurity.ValidVotePower).To(Equal(200 * i.KYVE)) + Expect(finalizedBundle.StakeSecurity.TotalVotePower).To(Equal(200 * i.KYVE)) // check if next bundle proposal got registered bundleProposal, bundleProposalFound := s.App().BundlesKeeper.GetBundleProposal(s.Ctx(), 0) @@ -409,7 +415,6 @@ var _ = Describe("valid bundles", Ordered, func() { Expect(bundleProposal.PoolId).To(Equal(uint64(0))) Expect(bundleProposal.StorageId).To(Equal("P9edn0bjEfMU_lecFDIPLvGO2v2ltpFNUMWp5kgPddg")) Expect(bundleProposal.Uploader).To(Equal(i.STAKER_0)) - // TODO(postAudit,@troy): how to get next uploader deterministically? Expect(bundleProposal.NextUploader).NotTo(BeEmpty()) Expect(bundleProposal.DataSize).To(Equal(uint64(100))) Expect(bundleProposal.DataHash).To(Equal("test_hash2")) @@ -557,6 +562,8 @@ var _ = Describe("valid bundles", Ordered, func() { Expect(finalizedBundle.BundleSummary).To(Equal("test_value")) Expect(finalizedBundle.DataHash).To(Equal("test_hash")) Expect(finalizedBundle.FinalizedAt).NotTo(BeZero()) + Expect(finalizedBundle.StakeSecurity.ValidVotePower).To(Equal(700 * i.KYVE)) + Expect(finalizedBundle.StakeSecurity.TotalVotePower).To(Equal(700 * i.KYVE)) // check if next bundle proposal got registered bundleProposal, bundleProposalFound := s.App().BundlesKeeper.GetBundleProposal(s.Ctx(), 0) @@ -565,7 +572,6 @@ var _ = Describe("valid bundles", Ordered, func() { Expect(bundleProposal.PoolId).To(Equal(uint64(0))) Expect(bundleProposal.StorageId).To(Equal("P9edn0bjEfMU_lecFDIPLvGO2v2ltpFNUMWp5kgPddg")) Expect(bundleProposal.Uploader).To(Equal(i.STAKER_0)) - // TODO(postAudit,@troy): how to get next uploader deterministically? Expect(bundleProposal.NextUploader).NotTo(BeEmpty()) Expect(bundleProposal.DataSize).To(Equal(uint64(100))) Expect(bundleProposal.DataHash).To(Equal("test_hash2")) @@ -720,6 +726,8 @@ var _ = Describe("valid bundles", Ordered, func() { Expect(finalizedBundle.BundleSummary).To(Equal("test_value")) Expect(finalizedBundle.DataHash).To(Equal("test_hash")) Expect(finalizedBundle.FinalizedAt).NotTo(BeZero()) + Expect(finalizedBundle.StakeSecurity.ValidVotePower).To(Equal(400 * i.KYVE)) + Expect(finalizedBundle.StakeSecurity.TotalVotePower).To(Equal(700 * i.KYVE)) // check if next bundle proposal got registered bundleProposal, bundleProposalFound := s.App().BundlesKeeper.GetBundleProposal(s.Ctx(), 0) @@ -884,6 +892,8 @@ var _ = Describe("valid bundles", Ordered, func() { Expect(finalizedBundle.BundleSummary).To(Equal("test_value")) Expect(finalizedBundle.DataHash).To(Equal("test_hash")) Expect(finalizedBundle.FinalizedAt).NotTo(BeZero()) + Expect(finalizedBundle.StakeSecurity.ValidVotePower).To(Equal(400 * i.KYVE)) + Expect(finalizedBundle.StakeSecurity.TotalVotePower).To(Equal(700 * i.KYVE)) // check if next bundle proposal got registered bundleProposal, bundleProposalFound := s.App().BundlesKeeper.GetBundleProposal(s.Ctx(), 0) @@ -1048,6 +1058,8 @@ var _ = Describe("valid bundles", Ordered, func() { Expect(finalizedBundle.BundleSummary).To(Equal("test_value")) Expect(finalizedBundle.DataHash).To(Equal("test_hash")) Expect(finalizedBundle.FinalizedAt).NotTo(BeZero()) + Expect(finalizedBundle.StakeSecurity.ValidVotePower).To(Equal(400 * i.KYVE)) + Expect(finalizedBundle.StakeSecurity.TotalVotePower).To(Equal(700 * i.KYVE)) // check if next bundle proposal got registered bundleProposal, bundleProposalFound := s.App().BundlesKeeper.GetBundleProposal(s.Ctx(), 0) diff --git a/x/bundles/keeper/logic_bundles.go b/x/bundles/keeper/logic_bundles.go index 4b3925d1..f29812c4 100644 --- a/x/bundles/keeper/logic_bundles.go +++ b/x/bundles/keeper/logic_bundles.go @@ -340,6 +340,10 @@ func (k Keeper) finalizeCurrentBundleProposal(ctx sdk.Context, poolId uint64, vo DataHash: bundleProposal.DataHash, StorageProviderId: bundleProposal.StorageProviderId, CompressionId: bundleProposal.CompressionId, + StakeSecurity: &types.StakeSecurity{ + ValidVotePower: voteDistribution.Valid, + TotalVotePower: voteDistribution.Total, + }, } k.SetFinalizedBundle(ctx, finalizedBundle) diff --git a/x/bundles/spec/02_state.md b/x/bundles/spec/02_state.md index 8e876188..ed36278a 100644 --- a/x/bundles/spec/02_state.md +++ b/x/bundles/spec/02_state.md @@ -59,13 +59,29 @@ type FinalizedBundle struct { ToKey string BundleSummary string DataHash string - FinalizedAt uint64 + FinalizedAt { + Height uint64 + Timestamp uint64 + } FromKey string StorageProviderId uint32 CompressionId uint32 + StakeSecurity { + ValidVotePower uint64 + TotalVotePower uint64 + } } ``` +### BundleVersionMap + +The version map keeps track of which protocol version was present at given +block heights. It is only updated during chain upgrades. It helps the query +handler to probably decode a finalized bundle. Later it might also be important +for on chain computations. + +- BundleVersionMap `0x03 -> ProtocolBuffer(BundleVersionMap)` + ## Round-Robin For correctly determining the next uploader the current round-robin @@ -89,7 +105,7 @@ type RoundRobinSingleValidatorProgress struct { RoundRobinProgress stores the current state of the round-robin selection for a given pool. -- RoundRobinProgress `0x03 | PoolId -> ProtocolBuffer(roundRobinProgress)` +- RoundRobinProgress `0x04 | PoolId -> ProtocolBuffer(roundRobinProgress)` ```go message RoundRobinProgress { diff --git a/x/bundles/types/bundles.pb.go b/x/bundles/types/bundles.pb.go index 94d4437a..ef21ee89 100644 --- a/x/bundles/types/bundles.pb.go +++ b/x/bundles/types/bundles.pb.go @@ -279,6 +279,8 @@ type FinalizedBundle struct { StorageProviderId uint32 `protobuf:"varint,12,opt,name=storage_provider_id,json=storageProviderId,proto3" json:"storage_provider_id,omitempty"` // compression_id the id of the compression type with which the data was compressed CompressionId uint32 `protobuf:"varint,13,opt,name=compression_id,json=compressionId,proto3" json:"compression_id,omitempty"` + // stake_security + StakeSecurity *StakeSecurity `protobuf:"bytes,14,opt,name=stake_security,json=stakeSecurity,proto3" json:"stake_security,omitempty"` } func (m *FinalizedBundle) Reset() { *m = FinalizedBundle{} } @@ -405,6 +407,13 @@ func (m *FinalizedBundle) GetCompressionId() uint32 { return 0 } +func (m *FinalizedBundle) GetStakeSecurity() *StakeSecurity { + if m != nil { + return m.StakeSecurity + } + return nil +} + // FinalizedAt ... type FinalizedAt struct { // height ... @@ -460,11 +469,11 @@ func (m *FinalizedAt) GetTimestamp() uint64 { return 0 } -// FinalizedAt ... +// StakeSecurity stores information about total stake and valid votes with which the bundle got finalized. type StakeSecurity struct { - // valid_vote_power ... + // valid_vote_power is the total amount of stake of all pool stakers which voted valid for the given bundle. ValidVotePower uint64 `protobuf:"varint,1,opt,name=valid_vote_power,json=validVotePower,proto3" json:"valid_vote_power,omitempty"` - // total_vote_power ... + // total_vote_power is the total amount of stake that was present during the finalization of the bundle TotalVotePower uint64 `protobuf:"varint,2,opt,name=total_vote_power,json=totalVotePower,proto3" json:"total_vote_power,omitempty"` } @@ -743,63 +752,65 @@ func init() { } var fileDescriptor_889cf76d77a4de2b = []byte{ - // 895 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x55, 0x4d, 0x6f, 0xe2, 0x46, - 0x18, 0xc6, 0x40, 0xf8, 0x78, 0xf9, 0x58, 0x3a, 0xfb, 0x11, 0x27, 0xdb, 0x50, 0x42, 0x55, 0x09, - 0x55, 0x15, 0x68, 0xb7, 0x87, 0x9e, 0xc9, 0x02, 0xaa, 0xb5, 0x59, 0x96, 0xda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e, 0xec, 0x52, 0xc3, 0xd7, 0xf6, 0x60, 0x3c, 0xec, - 0x59, 0xb5, 0x0c, 0x7a, 0x0a, 0xfb, 0xb7, 0xb8, 0xef, 0xc6, 0xaf, 0xcd, 0xf1, 0xab, 0x5a, 0xf6, - 0xf6, 0xc1, 0x9e, 0x61, 0x75, 0x4f, 0x4e, 0xfb, 0xbd, 0xda, 0xde, 0x61, 0xf6, 0xa7, 0x5f, 0xeb, - 0xa9, 0x93, 0xc1, 0x9f, 0x57, 0x75, 0xed, 0xfd, 0x55, 0x5d, 0xfb, 0xfb, 0xaa, 0xae, 0xfd, 0x72, - 0x5d, 0x4f, 0xbd, 0xbf, 0xae, 0xa7, 0xfe, 0xba, 0xae, 0xa7, 0x7e, 0xf8, 0x6a, 0x4e, 0xf9, 0x62, - 0x35, 0x6d, 0xcf, 0xd8, 0xb2, 0xf3, 0xf2, 0xed, 0xa4, 0x3f, 0x24, 0xfc, 0x1d, 0x0b, 0xce, 0x3b, - 0xb3, 0x05, 0xa6, 0x5e, 0xe7, 0x22, 0xf9, 0xc7, 0xf2, 0x8d, 0x4f, 0xc2, 0x69, 0x4e, 0xfe, 0x2e, - 0xbf, 0xfe, 0x27, 0x00, 0x00, 0xff, 0xff, 0x4b, 0x5b, 0xbb, 0x33, 0x80, 0x07, 0x00, 0x00, + // 918 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x55, 0xdd, 0x6e, 0x1a, 0x47, + 0x14, 0x66, 0x01, 0xf3, 0x73, 0x60, 0x09, 0x9d, 0xfc, 0x78, 0xed, 0xd4, 0x14, 0x13, 0x55, 0x42, + 0x55, 0x05, 0x8a, 0x7b, 0xd1, 0x6b, 0x1c, 0x40, 0xdd, 0xc6, 0x21, 0x74, 0x37, 0xa0, 0xa6, 0xaa, + 0xb4, 0x1a, 0xd8, 0x31, 0x8c, 0x0c, 0x3b, 0xab, 0xdd, 0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 0x14, 0x24, 0x05, 0x8f, 0x21, 0xc3, 0x99, 0x73, 0x41, 0x56, 0x46, 0x56, 0xe6, 0xde, 0xe3, 0xec, + 0x25, 0x59, 0xa1, 0xcf, 0xa1, 0x14, 0x9f, 0x5b, 0xcc, 0xe7, 0x38, 0x58, 0x19, 0x39, 0x49, 0xeb, + 0xd1, 0x51, 0x05, 0xae, 0xef, 0x9e, 0xe2, 0x70, 0x6a, 0xe4, 0x55, 0xf5, 0x02, 0xf8, 0x06, 0x87, + 0x53, 0xd1, 0xf8, 0xc2, 0x77, 0x31, 0x27, 0xae, 0x83, 0xb9, 0x01, 0xf2, 0xea, 0x7c, 0x84, 0xb4, + 0x38, 0x3a, 0x86, 0xe2, 0x92, 0x71, 0x12, 0x84, 0xce, 0x12, 0xcf, 0xa8, 0x6b, 0x14, 0xaa, 0xa9, + 0x7a, 0xde, 0x2a, 0x28, 0x6c, 0x28, 0x20, 0x51, 0x45, 0x24, 0xa1, 0x9e, 0x12, 0x15, 0xa5, 0x48, + 0x57, 0xa8, 0xa9, 0xc0, 0x0d, 0x19, 0x1e, 0x85, 0x1c, 0x53, 0xcf, 0xd0, 0x37, 0x65, 0x2d, 0x05, + 0xa2, 0x03, 0xc8, 0x9d, 0x07, 0x6c, 0x2e, 0x9b, 0x2d, 0xc9, 0x5a, 0xb3, 0x22, 0x16, 0xed, 0x36, + 0xe0, 0x61, 0xbc, 0x23, 0x3f, 0x60, 0x4b, 0xea, 0x92, 0x40, 0x2c, 0xeb, 0x41, 0x55, 0xab, 0xeb, + 0xd6, 0x27, 0x11, 0xd5, 0x8f, 0x18, 0x53, 0xde, 0x38, 0x66, 0x73, 0x3f, 0x20, 0x61, 0x48, 0x99, + 0x27, 0xa4, 0x65, 0x29, 0xd5, 0x37, 0x50, 0xd3, 0xad, 0xfd, 0x92, 0x86, 0x07, 0x5d, 0xea, 0xe1, + 0x19, 0xbd, 0x22, 0xae, 0xf2, 0xcb, 0xfd, 0x3e, 0x29, 0x41, 0x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xb7, 0x09, 0xb3, 0xa7, 0xa8, 0x24, 0x3a, 0x84, 0x27, 0xdb, + 0x54, 0xef, 0xb5, 0xd3, 0x1d, 0xf4, 0xda, 0x76, 0x39, 0x85, 0x9e, 0xc2, 0xfe, 0x1d, 0xee, 0xbb, + 0xc1, 0x6b, 0x6b, 0xf0, 0xaa, 0x9c, 0xbe, 0x7b, 0xb0, 0x6d, 0xda, 0xad, 0xd3, 0xb3, 0x4e, 0xbb, + 0xbc, 0x77, 0x98, 0xfe, 0xe9, 0xb7, 0x4a, 0xe2, 0xb4, 0xfb, 0xe7, 0x75, 0x45, 0x7b, 0x7f, 0x5d, + 0xd1, 0xfe, 0xbe, 0xae, 0x68, 0xbf, 0xde, 0x54, 0x12, 0xef, 0x6f, 0x2a, 0x89, 0xbf, 0x6e, 0x2a, + 0x89, 0x1f, 0xbe, 0x9c, 0x50, 0x3e, 0x5d, 0x8c, 0x1a, 0x63, 0x36, 0x6f, 0xbe, 0x7c, 0x3b, 0xec, + 0xf4, 0x08, 0x7f, 0xc7, 0x82, 0x8b, 0xe6, 0x78, 0x8a, 0xa9, 0xd7, 0xbc, 0x5c, 0x7f, 0xaf, 0xf9, + 0xca, 0x27, 0xe1, 0x28, 0x23, 0x3f, 0xbd, 0x5f, 0xfd, 0x13, 0x00, 0x00, 0xff, 0xff, 0x45, 0x66, + 0x7a, 0xef, 0xcc, 0x07, 0x00, 0x00, } func (m *BundleProposal) Marshal() (dAtA []byte, err error) { @@ -953,6 +964,18 @@ func (m *FinalizedBundle) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.StakeSecurity != nil { + { + size, err := m.StakeSecurity.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintBundles(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x72 + } if m.CompressionId != 0 { i = encodeVarintBundles(dAtA, i, uint64(m.CompressionId)) i-- @@ -1389,6 +1412,10 @@ func (m *FinalizedBundle) Size() (n int) { if m.CompressionId != 0 { n += 1 + sovBundles(uint64(m.CompressionId)) } + if m.StakeSecurity != nil { + l = m.StakeSecurity.Size() + n += 1 + l + sovBundles(uint64(l)) + } return n } @@ -2347,6 +2374,42 @@ func (m *FinalizedBundle) Unmarshal(dAtA []byte) error { break } } + case 14: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field StakeSecurity", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBundles + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthBundles + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthBundles + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.StakeSecurity == nil { + m.StakeSecurity = &StakeSecurity{} + } + if err := m.StakeSecurity.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipBundles(dAtA[iNdEx:]) From f41670a330b6629248876f18f230577015af298b Mon Sep 17 00:00:00 2001 From: mbreithecker Date: Tue, 11 Jul 2023 16:06:40 +0200 Subject: [PATCH 2/2] chore: update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 868cfdf8..5eb26ae3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ - (ibc) [#30](https://github.com/KYVENetwork/chain/pull/30) Integrate [Packet Forward Middleware](https://github.com/strangelove-ventures/packet-forward-middleware). - (`x/bundles`) [#99](https://github.com/KYVENetwork/chain/pull/99) Use weighted round-robin approach for uploader selection. +- (`x/bundles`) [#108](https://github.com/KYVENetwork/chain/pull/108) Store stake security for finalized bundles. ### Improvements