From 7f87aeaa3749a1d24a9665866e9f8c76ef85071f Mon Sep 17 00:00:00 2001 From: Alexander Sporn Date: Tue, 31 Oct 2023 11:32:28 +0100 Subject: [PATCH 01/14] Adapting to latest iota.go with GenesisSlot support --- .../sybilprotectionv1/performance/testsuite_test.go | 2 +- pkg/tests/accounts_test.go | 3 +++ pkg/tests/booker_test.go | 2 ++ pkg/tests/committee_rotation_test.go | 1 + pkg/tests/confirmation_state_test.go | 1 + pkg/tests/loss_of_acceptance_test.go | 3 +++ pkg/tests/protocol_engine_rollback_test.go | 4 ++++ pkg/tests/protocol_engine_switching_test.go | 1 + pkg/tests/protocol_startup_test.go | 2 ++ pkg/tests/upgrade_signaling_test.go | 1 + pkg/testsuite/testsuite.go | 1 + 11 files changed, 20 insertions(+), 1 deletion(-) diff --git a/pkg/protocol/sybilprotection/sybilprotectionv1/performance/testsuite_test.go b/pkg/protocol/sybilprotection/sybilprotectionv1/performance/testsuite_test.go index 684e21916..dcea6c29f 100644 --- a/pkg/protocol/sybilprotection/sybilprotectionv1/performance/testsuite_test.go +++ b/pkg/protocol/sybilprotection/sybilprotectionv1/performance/testsuite_test.go @@ -41,7 +41,7 @@ func NewTestSuite(t *testing.T) *TestSuite { epochStats: make(map[iotago.EpochIndex]*model.PoolsStats), api: iotago.V3API( iotago.NewV3ProtocolParameters( - iotago.WithTimeProviderOptions(time.Now().Unix(), 10, 3), + iotago.WithTimeProviderOptions(0, time.Now().Unix(), 10, 3), iotago.WithRewardsOptions(8, 8, 11, 1154, 2, 1), ), ), diff --git a/pkg/tests/accounts_test.go b/pkg/tests/accounts_test.go index 99886583d..297f7d997 100644 --- a/pkg/tests/accounts_test.go +++ b/pkg/tests/accounts_test.go @@ -30,6 +30,7 @@ func Test_TransitionAndDestroyAccount(t *testing.T) { }), testsuite.WithProtocolParametersOptions( iotago.WithTimeProviderOptions( + 0, testsuite.GenesisTimeWithOffsetBySlots(200, testsuite.DefaultSlotDurationInSeconds), testsuite.DefaultSlotDurationInSeconds, 8, @@ -157,6 +158,7 @@ func Test_StakeDelegateAndDelayedClaim(t *testing.T) { ts := testsuite.NewTestSuite(t, testsuite.WithProtocolParametersOptions( iotago.WithTimeProviderOptions( + 0, testsuite.GenesisTimeWithOffsetBySlots(100, testsuite.DefaultSlotDurationInSeconds), testsuite.DefaultSlotDurationInSeconds, 8, @@ -332,6 +334,7 @@ func Test_ImplicitAccounts(t *testing.T) { ts := testsuite.NewTestSuite(t, testsuite.WithProtocolParametersOptions( iotago.WithTimeProviderOptions( + 0, testsuite.GenesisTimeWithOffsetBySlots(100, testsuite.DefaultSlotDurationInSeconds), testsuite.DefaultSlotDurationInSeconds, 8, diff --git a/pkg/tests/booker_test.go b/pkg/tests/booker_test.go index 8a9e2e576..9608d8f57 100644 --- a/pkg/tests/booker_test.go +++ b/pkg/tests/booker_test.go @@ -229,6 +229,7 @@ func Test_SpendRejectedCommittedRace(t *testing.T) { ts := testsuite.NewTestSuite(t, testsuite.WithProtocolParametersOptions( iotago.WithTimeProviderOptions( + 0, testsuite.GenesisTimeWithOffsetBySlots(20, testsuite.DefaultSlotDurationInSeconds), testsuite.DefaultSlotDurationInSeconds, testsuite.DefaultSlotsPerEpochExponent, @@ -498,6 +499,7 @@ func Test_SpendPendingCommittedRace(t *testing.T) { ts := testsuite.NewTestSuite(t, testsuite.WithProtocolParametersOptions( iotago.WithTimeProviderOptions( + 0, testsuite.GenesisTimeWithOffsetBySlots(20, testsuite.DefaultSlotDurationInSeconds), testsuite.DefaultSlotDurationInSeconds, testsuite.DefaultSlotsPerEpochExponent, diff --git a/pkg/tests/committee_rotation_test.go b/pkg/tests/committee_rotation_test.go index 375a3c98f..835df5931 100644 --- a/pkg/tests/committee_rotation_test.go +++ b/pkg/tests/committee_rotation_test.go @@ -16,6 +16,7 @@ func Test_TopStakersRotation(t *testing.T) { ts := testsuite.NewTestSuite(t, testsuite.WithProtocolParametersOptions( iotago.WithTimeProviderOptions( + 0, testsuite.GenesisTimeWithOffsetBySlots(1000, testsuite.DefaultSlotDurationInSeconds), testsuite.DefaultSlotDurationInSeconds, 4, diff --git a/pkg/tests/confirmation_state_test.go b/pkg/tests/confirmation_state_test.go index c874dd400..7c93b6540 100644 --- a/pkg/tests/confirmation_state_test.go +++ b/pkg/tests/confirmation_state_test.go @@ -20,6 +20,7 @@ func TestConfirmationFlags(t *testing.T) { // TODO: remove this opt and use a proper value when refactoring the test with scheduler testsuite.WithProtocolParametersOptions( iotago.WithTimeProviderOptions( + 0, testsuite.GenesisTimeWithOffsetBySlots(100, testsuite.DefaultSlotDurationInSeconds), testsuite.DefaultSlotDurationInSeconds, testsuite.DefaultSlotsPerEpochExponent, diff --git a/pkg/tests/loss_of_acceptance_test.go b/pkg/tests/loss_of_acceptance_test.go index a8bb02537..961adfbcd 100644 --- a/pkg/tests/loss_of_acceptance_test.go +++ b/pkg/tests/loss_of_acceptance_test.go @@ -17,6 +17,7 @@ func TestLossOfAcceptanceFromGenesis(t *testing.T) { ts := testsuite.NewTestSuite(t, testsuite.WithProtocolParametersOptions( iotago.WithTimeProviderOptions( + 0, testsuite.GenesisTimeWithOffsetBySlots(100, testsuite.DefaultSlotDurationInSeconds), testsuite.DefaultSlotDurationInSeconds, 3, @@ -102,6 +103,7 @@ func TestLossOfAcceptanceFromSnapshot(t *testing.T) { ts := testsuite.NewTestSuite(t, testsuite.WithProtocolParametersOptions( iotago.WithTimeProviderOptions( + 0, testsuite.GenesisTimeWithOffsetBySlots(100, testsuite.DefaultSlotDurationInSeconds), testsuite.DefaultSlotDurationInSeconds, 3, @@ -196,6 +198,7 @@ func TestLossOfAcceptanceWithRestartFromDisk(t *testing.T) { ts := testsuite.NewTestSuite(t, testsuite.WithProtocolParametersOptions( iotago.WithTimeProviderOptions( + 0, testsuite.GenesisTimeWithOffsetBySlots(100, testsuite.DefaultSlotDurationInSeconds), testsuite.DefaultSlotDurationInSeconds, 3, diff --git a/pkg/tests/protocol_engine_rollback_test.go b/pkg/tests/protocol_engine_rollback_test.go index e99339b19..cb72995b9 100644 --- a/pkg/tests/protocol_engine_rollback_test.go +++ b/pkg/tests/protocol_engine_rollback_test.go @@ -29,6 +29,7 @@ func TestProtocol_EngineRollbackFinalization(t *testing.T) { ts := testsuite.NewTestSuite(t, testsuite.WithProtocolParametersOptions( iotago.WithTimeProviderOptions( + 0, testsuite.GenesisTimeWithOffsetBySlots(1000, testsuite.DefaultSlotDurationInSeconds), testsuite.DefaultSlotDurationInSeconds, 3, @@ -215,6 +216,7 @@ func TestProtocol_EngineRollbackNoFinalization(t *testing.T) { ts := testsuite.NewTestSuite(t, testsuite.WithProtocolParametersOptions( iotago.WithTimeProviderOptions( + 0, testsuite.GenesisTimeWithOffsetBySlots(1000, testsuite.DefaultSlotDurationInSeconds), testsuite.DefaultSlotDurationInSeconds, 3, @@ -414,6 +416,7 @@ func TestProtocol_EngineRollbackNoFinalizationLastSlot(t *testing.T) { ts := testsuite.NewTestSuite(t, testsuite.WithProtocolParametersOptions( iotago.WithTimeProviderOptions( + 0, testsuite.GenesisTimeWithOffsetBySlots(1000, testsuite.DefaultSlotDurationInSeconds), testsuite.DefaultSlotDurationInSeconds, 3, @@ -613,6 +616,7 @@ func TestProtocol_EngineRollbackNoFinalizationBeforePointOfNoReturn(t *testing.T ts := testsuite.NewTestSuite(t, testsuite.WithProtocolParametersOptions( iotago.WithTimeProviderOptions( + 0, testsuite.GenesisTimeWithOffsetBySlots(1000, testsuite.DefaultSlotDurationInSeconds), testsuite.DefaultSlotDurationInSeconds, 3, diff --git a/pkg/tests/protocol_engine_switching_test.go b/pkg/tests/protocol_engine_switching_test.go index aa6bf7834..9923cf3e6 100644 --- a/pkg/tests/protocol_engine_switching_test.go +++ b/pkg/tests/protocol_engine_switching_test.go @@ -30,6 +30,7 @@ func TestProtocol_EngineSwitching(t *testing.T) { ts := testsuite.NewTestSuite(t, testsuite.WithProtocolParametersOptions( iotago.WithTimeProviderOptions( + 0, testsuite.GenesisTimeWithOffsetBySlots(1000, testsuite.DefaultSlotDurationInSeconds), testsuite.DefaultSlotDurationInSeconds, 3, diff --git a/pkg/tests/protocol_startup_test.go b/pkg/tests/protocol_startup_test.go index 11b6672d1..6a77e58eb 100644 --- a/pkg/tests/protocol_startup_test.go +++ b/pkg/tests/protocol_startup_test.go @@ -24,6 +24,7 @@ func Test_BookInCommittedSlot(t *testing.T) { ts := testsuite.NewTestSuite(t, testsuite.WithProtocolParametersOptions( iotago.WithTimeProviderOptions( + 0, testsuite.GenesisTimeWithOffsetBySlots(1000, testsuite.DefaultSlotDurationInSeconds), testsuite.DefaultSlotDurationInSeconds, 3, @@ -123,6 +124,7 @@ func Test_StartNodeFromSnapshotAndDisk(t *testing.T) { ts := testsuite.NewTestSuite(t, testsuite.WithProtocolParametersOptions( iotago.WithTimeProviderOptions( + 0, testsuite.GenesisTimeWithOffsetBySlots(1000, testsuite.DefaultSlotDurationInSeconds), testsuite.DefaultSlotDurationInSeconds, 3, diff --git a/pkg/tests/upgrade_signaling_test.go b/pkg/tests/upgrade_signaling_test.go index 8f5ed29f3..5dd73a40a 100644 --- a/pkg/tests/upgrade_signaling_test.go +++ b/pkg/tests/upgrade_signaling_test.go @@ -31,6 +31,7 @@ func Test_Upgrade_Signaling(t *testing.T) { ts := testsuite.NewTestSuite(t, testsuite.WithProtocolParametersOptions( iotago.WithTimeProviderOptions( + 0, testsuite.GenesisTimeWithOffsetBySlots(1000, testsuite.DefaultSlotDurationInSeconds), testsuite.DefaultSlotDurationInSeconds, 3, diff --git a/pkg/testsuite/testsuite.go b/pkg/testsuite/testsuite.go index 794702d79..9b9195f0f 100644 --- a/pkg/testsuite/testsuite.go +++ b/pkg/testsuite/testsuite.go @@ -90,6 +90,7 @@ func NewTestSuite(testingT *testing.T, opts ...options.Option[TestSuite]) *TestS iotago.WithStakingOptions(1, 100, 1), iotago.WithTimeProviderOptions( + 0, GenesisTimeWithOffsetBySlots(0, DefaultSlotDurationInSeconds), DefaultSlotDurationInSeconds, DefaultSlotsPerEpochExponent, From 2c4ca762a92a153fb69b420b117ea0d85d2b278e Mon Sep 17 00:00:00 2001 From: Alexander Sporn Date: Tue, 31 Oct 2023 15:24:33 +0100 Subject: [PATCH 02/14] Adapt checks to account for genesis != 0 --- components/validator/issuer.go | 4 +-- pkg/model/commitment.go | 2 +- .../blockgadget/testframework_test.go | 4 ++- pkg/protocol/engine/engine.go | 13 ++++++---- pkg/protocol/engine/eviction/state.go | 26 ++++++++++++------- pkg/protocol/engine/eviction/state_test.go | 20 +++++++------- pkg/protocol/engine/ledger/ledger/ledger.go | 2 +- pkg/protocol/engine/utxoledger/manager.go | 4 +-- pkg/protocol/enginemanager/enginemanager.go | 2 +- pkg/storage/permanent/commitments.go | 2 +- pkg/storage/permanent/settings.go | 2 +- pkg/storage/storage_prunable.go | 4 +++ pkg/tests/accounts_test.go | 4 +-- pkg/tests/confirmation_state_test.go | 2 +- pkg/tests/protocol_engine_rollback_test.go | 8 +++--- pkg/tests/protocol_engine_switching_test.go | 2 +- pkg/tests/protocol_startup_test.go | 4 +-- pkg/testsuite/snapshotcreator/options.go | 10 +++++++ .../snapshotcreator/snapshotcreator.go | 9 +++++-- pkg/testsuite/testsuite.go | 4 +-- tools/genesis-snapshot/presets/presets.go | 10 +++---- 21 files changed, 84 insertions(+), 54 deletions(-) diff --git a/components/validator/issuer.go b/components/validator/issuer.go index 038fb9e78..99911c4b6 100644 --- a/components/validator/issuer.go +++ b/components/validator/issuer.go @@ -109,7 +109,7 @@ func reviveChain(issuingTime time.Time) (*iotago.Commitment, iotago.BlockID, err apiForSlot := deps.Protocol.APIForSlot(lastCommittedSlot) // Get a rootblock as recent as possible for the parent. - parentBlockID := iotago.EmptyBlockID + parentBlockID := iotago.EmptyBlockID //TODO: use GenesisBlockID for rootBlock := range deps.Protocol.MainEngineInstance().EvictionState.ActiveRootBlocks() { if rootBlock.Slot() > parentBlockID.Slot() { parentBlockID = rootBlock @@ -151,7 +151,7 @@ func getAddressableCommitment(blockSlot iotago.SlotIndex) (*iotago.Commitment, e } if blockSlot < commitment.Slot+protoParams.MinCommittableAge() { - if blockSlot < protoParams.MinCommittableAge() || commitment.Slot < protoParams.MinCommittableAge() { + if blockSlot < protoParams.GenesisSlot()+protoParams.MinCommittableAge() || commitment.Slot < protoParams.GenesisSlot()+protoParams.MinCommittableAge() { return commitment, nil } diff --git a/pkg/model/commitment.go b/pkg/model/commitment.go index cf17c8c4f..5a3f03456 100644 --- a/pkg/model/commitment.go +++ b/pkg/model/commitment.go @@ -21,7 +21,7 @@ type Commitment struct { } func NewEmptyCommitment(api iotago.API) *Commitment { - emptyCommitment := iotago.NewEmptyCommitment(api.ProtocolParameters().Version()) + emptyCommitment := iotago.NewEmptyCommitment(api) emptyCommitment.ReferenceManaCost = api.ProtocolParameters().CongestionControlParameters().MinReferenceManaCost return lo.PanicOnErr(CommitmentFromCommitment(emptyCommitment, api)) diff --git a/pkg/protocol/engine/consensus/blockgadget/testframework_test.go b/pkg/protocol/engine/consensus/blockgadget/testframework_test.go index a2d7371bc..c8b17ebed 100644 --- a/pkg/protocol/engine/consensus/blockgadget/testframework_test.go +++ b/pkg/protocol/engine/consensus/blockgadget/testframework_test.go @@ -53,6 +53,8 @@ func NewTestFramework(test *testing.T) *TestFramework { iotago.CommitmentID.Bytes, iotago.CommitmentIDFromBytes, ), nil + }, func() iotago.BlockID { + return tpkg.TestAPI.ProtocolParameters().GenesisBlockID() }) t.blockCache = blocks.New(evictionState, api.SingleVersionProvider(tpkg.TestAPI)) @@ -63,7 +65,7 @@ func NewTestFramework(test *testing.T) *TestFramework { t.Events = instance.Events() t.Instance = instance - genesisBlock := blocks.NewRootBlock(iotago.EmptyBlockID, iotago.NewEmptyCommitment(tpkg.TestAPI.Version()).MustID(), time.Unix(tpkg.TestAPI.TimeProvider().GenesisUnixTime(), 0)) + genesisBlock := blocks.NewRootBlock(tpkg.TestAPI.ProtocolParameters().GenesisBlockID(), iotago.NewEmptyCommitment(tpkg.TestAPI).MustID(), time.Unix(tpkg.TestAPI.TimeProvider().GenesisUnixTime(), 0)) t.blocks.Set("Genesis", genesisBlock) genesisBlock.ID().RegisterAlias("Genesis") evictionState.AddRootBlock(genesisBlock.ID(), genesisBlock.SlotCommitmentID()) diff --git a/pkg/protocol/engine/engine.go b/pkg/protocol/engine/engine.go index 1cee3527b..de997f340 100644 --- a/pkg/protocol/engine/engine.go +++ b/pkg/protocol/engine/engine.go @@ -114,7 +114,7 @@ func New( &Engine{ Events: NewEvents(), Storage: storageInstance, - EvictionState: eviction.NewState(storageInstance.LatestNonEmptySlot(), storageInstance.RootBlocks), + EvictionState: eviction.NewState(storageInstance.LatestNonEmptySlot(), storageInstance.RootBlocks, storageInstance.GenesisRootBlockID), Workers: workers, errorHandler: errorHandler, @@ -183,7 +183,7 @@ func New( } // Only mark any pruning indexes if we loaded a non-genesis snapshot - if e.Storage.Settings().LatestFinalizedSlot() > 0 { + if e.Storage.Settings().LatestFinalizedSlot() > e.Storage.GenesisRootBlockID().Slot() { if _, _, err := e.Storage.PruneByDepth(1); err != nil { if !ierrors.Is(err, database.ErrNoPruningNeeded) && !ierrors.Is(err, database.ErrEpochPruned) { @@ -488,11 +488,14 @@ func (e *Engine) setupPruning() { // chain beyond a window based on eviction, which in turn is based on acceptance. In case of a partition, this behavior is // clearly not desired. func (e *Engine) EarliestRootCommitment(lastFinalizedSlot iotago.SlotIndex) (earliestCommitment *model.Commitment) { - maxCommittableAge := e.APIForSlot(lastFinalizedSlot).ProtocolParameters().MaxCommittableAge() + api := e.APIForSlot(lastFinalizedSlot) + + genesisSlot := api.ProtocolParameters().GenesisSlot() + maxCommittableAge := api.ProtocolParameters().MaxCommittableAge() var earliestRootCommitmentSlot iotago.SlotIndex - if lastFinalizedSlot <= maxCommittableAge { - earliestRootCommitmentSlot = 0 + if lastFinalizedSlot <= genesisSlot+maxCommittableAge { + earliestRootCommitmentSlot = genesisSlot } else { earliestRootCommitmentSlot = lastFinalizedSlot - maxCommittableAge } diff --git a/pkg/protocol/engine/eviction/state.go b/pkg/protocol/engine/eviction/state.go index 104af2c3e..b913653bb 100644 --- a/pkg/protocol/engine/eviction/state.go +++ b/pkg/protocol/engine/eviction/state.go @@ -28,17 +28,20 @@ type State struct { latestNonEmptyStore kvstore.KVStore evictionMutex syncutils.RWMutex + genesisRootBlockFunc func() iotago.BlockID + optsRootBlocksEvictionDelay iotago.SlotIndex } // NewState creates a new eviction State. -func NewState(latestNonEmptyStore kvstore.KVStore, rootBlockStorageFunc func(iotago.SlotIndex) (*slotstore.Store[iotago.BlockID, iotago.CommitmentID], error), opts ...options.Option[State]) (state *State) { +func NewState(latestNonEmptyStore kvstore.KVStore, rootBlockStorageFunc func(iotago.SlotIndex) (*slotstore.Store[iotago.BlockID, iotago.CommitmentID], error), genesisRootBlockFunc func() iotago.BlockID, opts ...options.Option[State]) (state *State) { return options.Apply(&State{ Events: NewEvents(), rootBlocks: memstorage.NewIndexedStorage[iotago.SlotIndex, iotago.BlockID, iotago.CommitmentID](), latestRootBlocks: ringbuffer.NewRingBuffer[iotago.BlockID](8), rootBlockStorageFunc: rootBlockStorageFunc, latestNonEmptyStore: latestNonEmptyStore, + genesisRootBlockFunc: genesisRootBlockFunc, optsRootBlocksEvictionDelay: 3, }, opts) } @@ -167,7 +170,7 @@ func (s *State) RootBlockCommitmentID(id iotago.BlockID) (commitmentID iotago.Co func (s *State) LatestRootBlocks() iotago.BlockIDs { rootBlocks := s.latestRootBlocks.ToSlice() if len(rootBlocks) == 0 { - return iotago.BlockIDs{iotago.EmptyBlockID} + return iotago.BlockIDs{s.genesisRootBlockFunc()} } return rootBlocks @@ -183,7 +186,8 @@ func (s *State) Export(writer io.WriteSeeker, lowerTarget iotago.SlotIndex, targ start, _ := s.delayedBlockEvictionThreshold(lowerTarget) - latestNonEmptySlot := iotago.SlotIndex(0) + genesisSlot := s.genesisRootBlockFunc().Slot() + latestNonEmptySlot := genesisSlot if err := stream.WriteCollection(writer, func() (elementsCount uint64, err error) { for currentSlot := start; currentSlot <= targetSlot; currentSlot++ { @@ -218,7 +222,7 @@ func (s *State) Export(writer io.WriteSeeker, lowerTarget iotago.SlotIndex, targ if latestNonEmptySlot > s.optsRootBlocksEvictionDelay { latestNonEmptySlot -= s.optsRootBlocksEvictionDelay } else { - latestNonEmptySlot = 0 + latestNonEmptySlot = genesisSlot } if err := stream.WriteSerializable(writer, latestNonEmptySlot, iotago.SlotIndexLength); err != nil { @@ -283,7 +287,8 @@ func (s *State) Rollback(lowerTarget, targetIndex iotago.SlotIndex) error { defer s.evictionMutex.RUnlock() start, _ := s.delayedBlockEvictionThreshold(lowerTarget) - latestNonEmptySlot := iotago.SlotIndex(0) + genesisSlot := s.genesisRootBlockFunc().Slot() + latestNonEmptySlot := genesisSlot for currentSlot := start; currentSlot <= targetIndex; currentSlot++ { _, err := s.rootBlockStorageFunc(currentSlot) @@ -297,7 +302,7 @@ func (s *State) Rollback(lowerTarget, targetIndex iotago.SlotIndex) error { if latestNonEmptySlot > s.optsRootBlocksEvictionDelay { latestNonEmptySlot -= s.optsRootBlocksEvictionDelay } else { - latestNonEmptySlot = 0 + latestNonEmptySlot = genesisSlot } if err := s.latestNonEmptyStore.Set([]byte{latestNonEmptySlotKey}, latestNonEmptySlot.MustBytes()); err != nil { @@ -371,8 +376,9 @@ func (s *State) withinActiveIndexRange(slot iotago.SlotIndex) bool { // delayedBlockEvictionThreshold returns the slot index that is the threshold for delayed rootblocks eviction. func (s *State) delayedBlockEvictionThreshold(slot iotago.SlotIndex) (thresholdSlot iotago.SlotIndex, shouldEvict bool) { - if slot < s.optsRootBlocksEvictionDelay { - return 0, false + genesisSlot := s.genesisRootBlockFunc().Slot() + if slot < genesisSlot+s.optsRootBlocksEvictionDelay { + return genesisSlot, false } // Check if we have root blocks up to the eviction point. @@ -383,7 +389,7 @@ func (s *State) delayedBlockEvictionThreshold(slot iotago.SlotIndex) (thresholdS return slot - s.optsRootBlocksEvictionDelay, true } - return 0, false + return genesisSlot, false } } } @@ -393,7 +399,7 @@ func (s *State) delayedBlockEvictionThreshold(slot iotago.SlotIndex) (thresholdS return latestNonEmptySlot - s.optsRootBlocksEvictionDelay, true } - return 0, false + return genesisSlot, false } // WithRootBlocksEvictionDelay sets the time since confirmation threshold. diff --git a/pkg/protocol/engine/eviction/state_test.go b/pkg/protocol/engine/eviction/state_test.go index 2787eb4b8..0bad76f27 100644 --- a/pkg/protocol/engine/eviction/state_test.go +++ b/pkg/protocol/engine/eviction/state_test.go @@ -22,20 +22,22 @@ func TestState_RootBlocks(t *testing.T) { Directory: t.TempDir(), }, api.SingleVersionProvider(tpkg.TestAPI), errorHandler) - ts := NewTestFramework(t, prunableStorage, eviction.NewState(mapdb.NewMapDB(), prunableStorage.RootBlocks, eviction.WithRootBlocksEvictionDelay(3))) - ts.CreateAndAddRootBlock("Genesis", 0, iotago.NewEmptyCommitment(tpkg.TestAPI.Version()).MustID()) + ts := NewTestFramework(t, prunableStorage, eviction.NewState(mapdb.NewMapDB(), prunableStorage.RootBlocks, func() iotago.BlockID { + return tpkg.TestAPI.ProtocolParameters().GenesisBlockID() + }, eviction.WithRootBlocksEvictionDelay(3))) + ts.CreateAndAddRootBlock("Genesis", 0, iotago.NewEmptyCommitment(tpkg.TestAPI).MustID()) ts.RequireActiveRootBlocks("Genesis") ts.RequireLastEvictedSlot(0) ts.Instance.Initialize(0) - ts.CreateAndAddRootBlock("Root1.0", 1, iotago.NewEmptyCommitment(tpkg.TestAPI.Version()).MustID()) - ts.CreateAndAddRootBlock("Root1.1", 1, iotago.NewEmptyCommitment(tpkg.TestAPI.Version()).MustID()) - ts.CreateAndAddRootBlock("Root2.0", 2, iotago.NewEmptyCommitment(tpkg.TestAPI.Version()).MustID()) - ts.CreateAndAddRootBlock("Root3.0", 3, iotago.NewEmptyCommitment(tpkg.TestAPI.Version()).MustID()) - ts.CreateAndAddRootBlock("Root4.0", 4, iotago.NewEmptyCommitment(tpkg.TestAPI.Version()).MustID()) - ts.CreateAndAddRootBlock("Root4.1", 4, iotago.NewEmptyCommitment(tpkg.TestAPI.Version()).MustID()) - ts.CreateAndAddRootBlock("Root5.0", 5, iotago.NewEmptyCommitment(tpkg.TestAPI.Version()).MustID()) + ts.CreateAndAddRootBlock("Root1.0", 1, iotago.NewEmptyCommitment(tpkg.TestAPI).MustID()) + ts.CreateAndAddRootBlock("Root1.1", 1, iotago.NewEmptyCommitment(tpkg.TestAPI).MustID()) + ts.CreateAndAddRootBlock("Root2.0", 2, iotago.NewEmptyCommitment(tpkg.TestAPI).MustID()) + ts.CreateAndAddRootBlock("Root3.0", 3, iotago.NewEmptyCommitment(tpkg.TestAPI).MustID()) + ts.CreateAndAddRootBlock("Root4.0", 4, iotago.NewEmptyCommitment(tpkg.TestAPI).MustID()) + ts.CreateAndAddRootBlock("Root4.1", 4, iotago.NewEmptyCommitment(tpkg.TestAPI).MustID()) + ts.CreateAndAddRootBlock("Root5.0", 5, iotago.NewEmptyCommitment(tpkg.TestAPI).MustID()) ts.RequireActiveRootBlocks("Genesis") ts.RequireLastEvictedSlot(0) diff --git a/pkg/protocol/engine/ledger/ledger/ledger.go b/pkg/protocol/engine/ledger/ledger/ledger.go index 31632f082..4728289e8 100644 --- a/pkg/protocol/engine/ledger/ledger/ledger.go +++ b/pkg/protocol/engine/ledger/ledger/ledger.go @@ -184,7 +184,7 @@ func (l *Ledger) CommitSlot(slot iotago.SlotIndex) (stateRoot iotago.Identifier, rmcIndex, _ := safemath.SafeSub(slot, maxCommittableAge) rmcForSlot, err := l.rmcManager.RMC(rmcIndex) if err != nil { - return iotago.Identifier{}, iotago.Identifier{}, iotago.Identifier{}, ierrors.Errorf("failed to get RMC for slot %d: %w", slot, err) + return iotago.Identifier{}, iotago.Identifier{}, iotago.Identifier{}, ierrors.Errorf("ledger failed to get RMC for slot %d: %w", slot, err) } if err = l.accountsLedger.ApplyDiff(slot, rmcForSlot, accountDiffs, destroyedAccounts); err != nil { return iotago.Identifier{}, iotago.Identifier{}, iotago.Identifier{}, ierrors.Errorf("failed to apply diff to Accounts ledger for slot %d: %w", slot, err) diff --git a/pkg/protocol/engine/utxoledger/manager.go b/pkg/protocol/engine/utxoledger/manager.go index 83fd376f5..09f97ac84 100644 --- a/pkg/protocol/engine/utxoledger/manager.go +++ b/pkg/protocol/engine/utxoledger/manager.go @@ -130,8 +130,8 @@ func (m *Manager) ReadLedgerIndexWithoutLocking() (iotago.SlotIndex, error) { value, err := m.store.Get([]byte{StoreKeyPrefixLedgerSlotIndex}) if err != nil { if ierrors.Is(err, kvstore.ErrKeyNotFound) { - // there is no ledger milestone yet => return 0 - return 0, nil + // there is no ledger milestone yet => return genesis slot + return m.apiProvider.CommittedAPI().ProtocolParameters().GenesisSlot(), nil } return 0, ierrors.Errorf("failed to load ledger milestone index: %w", err) diff --git a/pkg/protocol/enginemanager/enginemanager.go b/pkg/protocol/enginemanager/enginemanager.go index a36b01175..a1ade86d4 100644 --- a/pkg/protocol/enginemanager/enginemanager.go +++ b/pkg/protocol/enginemanager/enginemanager.go @@ -280,7 +280,7 @@ func (e *EngineManager) rollbackStorage(newStorage *storage.Storage, slot iotago return ierrors.Wrap(err, "failed to rollback commitments") } // Create temporary components and rollback their permanent state, which will be reflected on disk. - evictionState := eviction.NewState(newStorage.LatestNonEmptySlot(), newStorage.RootBlocks) + evictionState := eviction.NewState(newStorage.LatestNonEmptySlot(), newStorage.RootBlocks, newStorage.GenesisRootBlockID) evictionState.Initialize(latestCommitment.Slot()) blockCache := blocks.New(evictionState, newStorage.Settings().APIProvider()) diff --git a/pkg/storage/permanent/commitments.go b/pkg/storage/permanent/commitments.go index abc4b59c2..2dcf2ef09 100644 --- a/pkg/storage/permanent/commitments.go +++ b/pkg/storage/permanent/commitments.go @@ -44,7 +44,7 @@ func (c *Commitments) Load(slot iotago.SlotIndex) (commitment *model.Commitment, func (c *Commitments) Export(writer io.WriteSeeker, targetSlot iotago.SlotIndex) (err error) { if err := stream.WriteCollection(writer, func() (elementsCount uint64, err error) { var count uint64 - for slot := iotago.SlotIndex(0); slot <= targetSlot; slot++ { + for slot := c.apiProvider.CommittedAPI().ProtocolParameters().GenesisSlot(); slot <= targetSlot; slot++ { commitmentBytes, err := c.store.KVStore().Get(lo.PanicOnErr(slot.Bytes())) if err != nil { return 0, ierrors.Wrapf(err, "failed to load commitment for slot %d", slot) diff --git a/pkg/storage/permanent/settings.go b/pkg/storage/permanent/settings.go index d1ad5fe82..d68936c10 100644 --- a/pkg/storage/permanent/settings.go +++ b/pkg/storage/permanent/settings.go @@ -299,7 +299,7 @@ func (s *Settings) latestFinalizedSlot() iotago.SlotIndex { latestFinalizedSlot, err := s.storeLatestFinalizedSlot.Get() if err != nil { if ierrors.Is(err, kvstore.ErrKeyNotFound) { - return 0 + return s.apiProvider.CommittedAPI().ProtocolParameters().GenesisSlot() } panic(err) } diff --git a/pkg/storage/storage_prunable.go b/pkg/storage/storage_prunable.go index 5403484d9..657582904 100644 --- a/pkg/storage/storage_prunable.go +++ b/pkg/storage/storage_prunable.go @@ -41,6 +41,10 @@ func (s *Storage) RootBlocks(slot iotago.SlotIndex) (*slotstore.Store[iotago.Blo return s.prunable.RootBlocks(slot) } +func (s *Storage) GenesisRootBlockID() iotago.BlockID { + return s.Settings().APIProvider().CommittedAPI().ProtocolParameters().GenesisBlockID() +} + func (s *Storage) Mutations(slot iotago.SlotIndex) (kvstore.KVStore, error) { return s.prunable.Mutations(slot) } diff --git a/pkg/tests/accounts_test.go b/pkg/tests/accounts_test.go index 297f7d997..fba1e8b8e 100644 --- a/pkg/tests/accounts_test.go +++ b/pkg/tests/accounts_test.go @@ -101,7 +101,7 @@ func Test_TransitionAndDestroyAccount(t *testing.T) { ) // default block issuer issues a block containing the transaction in slot 1. - genesisCommitment := iotago.NewEmptyCommitment(ts.API.ProtocolParameters().Version()) + genesisCommitment := iotago.NewEmptyCommitment(ts.API) genesisCommitment.ReferenceManaCost = ts.API.ProtocolParameters().CongestionControlParameters().MinReferenceManaCost block1 := ts.IssueBasicBlockAtSlotWithOptions("block1", block1Slot, ts.DefaultWallet(), tx1, mock.WithSlotCommitment(genesisCommitment)) latestParent := ts.CommitUntilSlot(ts.BlockID("block1").Slot(), block1) @@ -221,7 +221,7 @@ func Test_StakeDelegateAndDelayedClaim(t *testing.T) { mock.WithAccountAmount(mock.MinIssuerAccountAmount), ) - genesisCommitment := iotago.NewEmptyCommitment(ts.API.ProtocolParameters().Version()) + genesisCommitment := iotago.NewEmptyCommitment(ts.API) genesisCommitment.ReferenceManaCost = ts.API.ProtocolParameters().CongestionControlParameters().MinReferenceManaCost block1 := ts.IssueBasicBlockAtSlotWithOptions("block1", block1Slot, ts.DefaultWallet(), tx1) latestParent := ts.CommitUntilSlot(block1Slot, block1) diff --git a/pkg/tests/confirmation_state_test.go b/pkg/tests/confirmation_state_test.go index 7c93b6540..63219ee69 100644 --- a/pkg/tests/confirmation_state_test.go +++ b/pkg/tests/confirmation_state_test.go @@ -99,7 +99,7 @@ func TestConfirmationFlags(t *testing.T) { }) // Verify that nodes have the expected states. - genesisCommitment := iotago.NewEmptyCommitment(ts.API.ProtocolParameters().Version()) + genesisCommitment := iotago.NewEmptyCommitment(ts.API) genesisCommitment.ReferenceManaCost = ts.API.ProtocolParameters().CongestionControlParameters().MinReferenceManaCost ts.AssertNodeState(ts.Nodes(), testsuite.WithSnapshotImported(true), diff --git a/pkg/tests/protocol_engine_rollback_test.go b/pkg/tests/protocol_engine_rollback_test.go index cb72995b9..0de8dc8f6 100644 --- a/pkg/tests/protocol_engine_rollback_test.go +++ b/pkg/tests/protocol_engine_rollback_test.go @@ -116,7 +116,7 @@ func TestProtocol_EngineRollbackFinalization(t *testing.T) { } { - genesisCommitment := iotago.NewEmptyCommitment(ts.API.ProtocolParameters().Version()) + genesisCommitment := iotago.NewEmptyCommitment(ts.API) genesisCommitment.ReferenceManaCost = ts.API.ProtocolParameters().CongestionControlParameters().MinReferenceManaCost ts.AssertNodeState(ts.Nodes(), testsuite.WithSnapshotImported(true), @@ -309,7 +309,7 @@ func TestProtocol_EngineRollbackNoFinalization(t *testing.T) { } { - genesisCommitment := iotago.NewEmptyCommitment(ts.API.ProtocolParameters().Version()) + genesisCommitment := iotago.NewEmptyCommitment(ts.API) genesisCommitment.ReferenceManaCost = ts.API.ProtocolParameters().CongestionControlParameters().MinReferenceManaCost ts.AssertNodeState(ts.Nodes(), testsuite.WithSnapshotImported(true), @@ -509,7 +509,7 @@ func TestProtocol_EngineRollbackNoFinalizationLastSlot(t *testing.T) { } { - genesisCommitment := iotago.NewEmptyCommitment(ts.API.ProtocolParameters().Version()) + genesisCommitment := iotago.NewEmptyCommitment(ts.API) genesisCommitment.ReferenceManaCost = ts.API.ProtocolParameters().CongestionControlParameters().MinReferenceManaCost ts.AssertNodeState(ts.Nodes(), testsuite.WithSnapshotImported(true), @@ -709,7 +709,7 @@ func TestProtocol_EngineRollbackNoFinalizationBeforePointOfNoReturn(t *testing.T } { - genesisCommitment := iotago.NewEmptyCommitment(ts.API.ProtocolParameters().Version()) + genesisCommitment := iotago.NewEmptyCommitment(ts.API) genesisCommitment.ReferenceManaCost = ts.API.ProtocolParameters().CongestionControlParameters().MinReferenceManaCost ts.AssertNodeState(ts.Nodes(), testsuite.WithSnapshotImported(true), diff --git a/pkg/tests/protocol_engine_switching_test.go b/pkg/tests/protocol_engine_switching_test.go index 9923cf3e6..b56f185ed 100644 --- a/pkg/tests/protocol_engine_switching_test.go +++ b/pkg/tests/protocol_engine_switching_test.go @@ -144,7 +144,7 @@ func TestProtocol_EngineSwitching(t *testing.T) { // Verify that nodes have the expected states. { - genesisCommitment := iotago.NewEmptyCommitment(ts.API.ProtocolParameters().Version()) + genesisCommitment := iotago.NewEmptyCommitment(ts.API) genesisCommitment.ReferenceManaCost = ts.API.ProtocolParameters().CongestionControlParameters().MinReferenceManaCost ts.AssertNodeState(ts.Nodes(), testsuite.WithSnapshotImported(true), diff --git a/pkg/tests/protocol_startup_test.go b/pkg/tests/protocol_startup_test.go index 6a77e58eb..8d1e502ed 100644 --- a/pkg/tests/protocol_startup_test.go +++ b/pkg/tests/protocol_startup_test.go @@ -63,7 +63,7 @@ func Test_BookInCommittedSlot(t *testing.T) { } // Verify that nodes have the expected states. - genesisCommitment := iotago.NewEmptyCommitment(ts.API.ProtocolParameters().Version()) + genesisCommitment := iotago.NewEmptyCommitment(ts.API) genesisCommitment.ReferenceManaCost = ts.API.ProtocolParameters().CongestionControlParameters().MinReferenceManaCost ts.AssertNodeState(ts.Nodes(), testsuite.WithSnapshotImported(true), @@ -175,7 +175,7 @@ func Test_StartNodeFromSnapshotAndDisk(t *testing.T) { } // Verify that nodes have the expected states. - genesisCommitment := iotago.NewEmptyCommitment(ts.API.ProtocolParameters().Version()) + genesisCommitment := iotago.NewEmptyCommitment(ts.API) genesisCommitment.ReferenceManaCost = ts.API.ProtocolParameters().CongestionControlParameters().MinReferenceManaCost ts.AssertNodeState(ts.Nodes(), testsuite.WithSnapshotImported(true), diff --git a/pkg/testsuite/snapshotcreator/options.go b/pkg/testsuite/snapshotcreator/options.go index 85aa1f439..20addc3f2 100644 --- a/pkg/testsuite/snapshotcreator/options.go +++ b/pkg/testsuite/snapshotcreator/options.go @@ -20,6 +20,9 @@ type Options struct { // ProtocolParameters provides the protocol parameters used for the network. ProtocolParameters iotago.ProtocolParameters + // AddGenesisRootBlock defines whether a Genesis root block should be added. + AddGenesisRootBlock bool + // RootBlocks define the initial blocks to which new blocks can attach to. RootBlocks map[iotago.BlockID]iotago.CommitmentID @@ -84,6 +87,13 @@ func WithRootBlocks(rootBlocks map[iotago.BlockID]iotago.CommitmentID) options.O } } +// WithAddGenesisRootBlock define whether a Genesis root block should be added. +func WithAddGenesisRootBlock(add bool) options.Option[Options] { + return func(m *Options) { + m.AddGenesisRootBlock = add + } +} + // WithGenesisKeyManager defines the seed used to generate keypair that can spend Genesis outputs. func WithGenesisKeyManager(keyManager *mock.KeyManager) options.Option[Options] { return func(m *Options) { diff --git a/pkg/testsuite/snapshotcreator/snapshotcreator.go b/pkg/testsuite/snapshotcreator/snapshotcreator.go index c09f9d622..0d0442bb0 100644 --- a/pkg/testsuite/snapshotcreator/snapshotcreator.go +++ b/pkg/testsuite/snapshotcreator/snapshotcreator.go @@ -66,7 +66,8 @@ func CreateSnapshot(opts ...options.Option[Options]) error { } api := s.Settings().APIProvider().CommittedAPI() - if err := s.Commitments().Store(model.NewEmptyCommitment(api)); err != nil { + genesisCommitment := model.NewEmptyCommitment(api) + if err := s.Commitments().Store(genesisCommitment); err != nil { return ierrors.Wrap(err, "failed to store empty commitment") } @@ -120,6 +121,10 @@ func CreateSnapshot(opts ...options.Option[Options]) error { ) defer engineInstance.Shutdown() + if opt.AddGenesisRootBlock { + engineInstance.EvictionState.AddRootBlock(api.ProtocolParameters().GenesisBlockID(), genesisCommitment.ID()) + } + for blockID, commitmentID := range opt.RootBlocks { engineInstance.EvictionState.AddRootBlock(blockID, commitmentID) } @@ -164,7 +169,7 @@ func CreateSnapshot(opts ...options.Option[Options]) error { return err } - utxoOutput := utxoledger.CreateOutput(engineInstance, outputID, iotago.EmptyBlockID, GenesisTransactionCreationSlot, output, proof) + utxoOutput := utxoledger.CreateOutput(engineInstance, outputID, api.ProtocolParameters().GenesisBlockID(), GenesisTransactionCreationSlot, output, proof) if err := engineInstance.Ledger.AddGenesisUnspentOutput(utxoOutput); err != nil { return err } diff --git a/pkg/testsuite/testsuite.go b/pkg/testsuite/testsuite.go index 9b9195f0f..f7c5f0b11 100644 --- a/pkg/testsuite/testsuite.go +++ b/pkg/testsuite/testsuite.go @@ -117,7 +117,7 @@ func NewTestSuite(testingT *testing.T, opts ...options.Option[TestSuite]) *TestS t.ProtocolParameterOptions = append(defaultProtocolParameters, t.ProtocolParameterOptions...) t.API = iotago.V3API(iotago.NewV3ProtocolParameters(t.ProtocolParameterOptions...)) - genesisBlock := blocks.NewRootBlock(iotago.EmptyBlockID, iotago.NewEmptyCommitment(t.API.ProtocolParameters().Version()).MustID(), time.Unix(t.API.ProtocolParameters().GenesisUnixTimestamp(), 0)) + genesisBlock := blocks.NewRootBlock(t.API.ProtocolParameters().GenesisBlockID(), iotago.NewEmptyCommitment(t.API).MustID(), time.Unix(t.API.ProtocolParameters().GenesisUnixTimestamp(), 0)) t.RegisterBlock("Genesis", genesisBlock) t.snapshotPath = t.Directory.Path("genesis_snapshot.bin") @@ -126,7 +126,7 @@ func NewTestSuite(testingT *testing.T, opts ...options.Option[TestSuite]) *TestS snapshotcreator.WithFilePath(t.snapshotPath), snapshotcreator.WithProtocolParameters(t.API.ProtocolParameters()), snapshotcreator.WithRootBlocks(map[iotago.BlockID]iotago.CommitmentID{ - iotago.EmptyBlockID: iotago.NewEmptyCommitment(t.API.ProtocolParameters().Version()).MustID(), + t.API.ProtocolParameters().GenesisBlockID(): iotago.NewEmptyCommitment(t.API).MustID(), }), } t.optsSnapshotOptions = append(defaultSnapshotOptions, t.optsSnapshotOptions...) diff --git a/tools/genesis-snapshot/presets/presets.go b/tools/genesis-snapshot/presets/presets.go index 8157c81e2..8e77c8437 100644 --- a/tools/genesis-snapshot/presets/presets.go +++ b/tools/genesis-snapshot/presets/presets.go @@ -22,16 +22,14 @@ var Base = []options.Option[snapshotcreator.Options]{ iotago.NewV3ProtocolParameters( iotago.WithNetworkOptions("default", "rms"), iotago.WithSupplyOptions(4_600_000_000_000_000, 100, 1, 10, 100, 100, 100), - iotago.WithTimeProviderOptions(1696841745, 10, 13), + iotago.WithTimeProviderOptions(0, 1696841745, 10, 13), iotago.WithLivenessOptions(30, 30, 7, 14, 30), // increase/decrease threshold = fraction * slotDurationInSeconds * schedulerRate iotago.WithCongestionControlOptions(500, 500, 500, 800000, 500000, 100000, 1000, 100), iotago.WithWorkScoreOptions(25, 1, 100, 50, 10, 10, 50, 1, 10, 250), ), ), - snapshotcreator.WithRootBlocks(map[iotago.BlockID]iotago.CommitmentID{ - iotago.EmptyBlockID: iotago.NewEmptyCommitment(3).MustID(), - }), + snapshotcreator.WithAddGenesisRootBlock(true), } var Docker = []options.Option[snapshotcreator.Options]{ @@ -112,7 +110,7 @@ var Docker = []options.Option[snapshotcreator.Options]{ iotago.NewV3ProtocolParameters( iotago.WithNetworkOptions("docker", "rms"), iotago.WithSupplyOptions(4_600_000_000_000_000, 1, 1, 10, 100, 100, 100), - iotago.WithTimeProviderOptions(time.Now().Unix(), 10, 13), + iotago.WithTimeProviderOptions(123456789, time.Now().Unix(), 10, 13), iotago.WithLivenessOptions(30, 30, 7, 14, 30), // increase/decrease threshold = fraction * slotDurationInSeconds * schedulerRate iotago.WithCongestionControlOptions(500, 500, 500, 800000, 500000, 100000, 1000, 100), @@ -198,7 +196,7 @@ var Feature = []options.Option[snapshotcreator.Options]{ iotago.NewV3ProtocolParameters( iotago.WithNetworkOptions("feature", "rms"), iotago.WithSupplyOptions(4_600_000_000_000_000, 100, 1, 10, 100, 100, 100), - iotago.WithTimeProviderOptions(1697631694, 10, 13), + iotago.WithTimeProviderOptions(666666, 1697631694, 10, 13), iotago.WithLivenessOptions(30, 30, 10, 20, 30), // increase/decrease threshold = fraction * slotDurationInSeconds * schedulerRate iotago.WithCongestionControlOptions(500, 500, 500, 800000, 500000, 100000, 1000, 100), From 8e1ad8f5ede1a7888d87fd6e18ec696789b04ca1 Mon Sep 17 00:00:00 2001 From: Alexander Sporn Date: Tue, 31 Oct 2023 15:26:53 +0100 Subject: [PATCH 03/14] Added error when loading a commitment older than genesis slot --- pkg/storage/permanent/commitments.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pkg/storage/permanent/commitments.go b/pkg/storage/permanent/commitments.go index 2dcf2ef09..c6246b0dd 100644 --- a/pkg/storage/permanent/commitments.go +++ b/pkg/storage/permanent/commitments.go @@ -11,6 +11,10 @@ import ( iotago "github.com/iotaledger/iota.go/v4" ) +var ( + ErrCommitmentBeforeGenesis = ierrors.New("commitment is before genesis") +) + type Commitments struct { apiProvider iotago.APIProvider store *kvstore.TypedStore[iotago.SlotIndex, *model.Commitment] @@ -38,6 +42,11 @@ func (c *Commitments) Store(commitment *model.Commitment) error { } func (c *Commitments) Load(slot iotago.SlotIndex) (commitment *model.Commitment, err error) { + genesisSlot := c.apiProvider.CommittedAPI().ProtocolParameters().GenesisSlot() + if slot < genesisSlot { + return nil, ierrors.Wrapf(ErrCommitmentBeforeGenesis, "slot %d is before genesis slot %d", slot, genesisSlot) + } + return c.store.Get(slot) } From 1b2a9950b46fbf7778bdaca10b2e3f169ca4e4c5 Mon Sep 17 00:00:00 2001 From: Alexander Sporn Date: Tue, 31 Oct 2023 15:36:25 +0100 Subject: [PATCH 04/14] Updated iota.go with required changes --- go.mod | 2 +- go.sum | 4 ++-- tools/gendoc/go.mod | 2 +- tools/gendoc/go.sum | 4 ++-- tools/genesis-snapshot/go.mod | 2 +- tools/genesis-snapshot/go.sum | 4 ++-- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/go.mod b/go.mod index 1784168e9..a034cd02d 100644 --- a/go.mod +++ b/go.mod @@ -25,7 +25,7 @@ require ( github.com/iotaledger/hive.go/stringify v0.0.0-20231027195901-620bd7470e42 github.com/iotaledger/inx-app v1.0.0-rc.3.0.20231031135002-4c79ea5193f5 github.com/iotaledger/inx/go v1.0.0-rc.2.0.20231031134131-b6ad918dc1ac - github.com/iotaledger/iota.go/v4 v4.0.0-20231031113109-5d7d59311967 + github.com/iotaledger/iota.go/v4 v4.0.0-20231031141917-e514cdca2d25 github.com/labstack/echo/v4 v4.11.2 github.com/labstack/gommon v0.4.0 github.com/libp2p/go-libp2p v0.32.0 diff --git a/go.sum b/go.sum index 2d6f0464b..adeae54ac 100644 --- a/go.sum +++ b/go.sum @@ -307,8 +307,8 @@ github.com/iotaledger/inx-app v1.0.0-rc.3.0.20231031135002-4c79ea5193f5 h1:17JDz github.com/iotaledger/inx-app v1.0.0-rc.3.0.20231031135002-4c79ea5193f5/go.mod h1:LsJvoBUVVnY7tkwwByCVtAwmp5bFXdyJNGU/+KVQJVM= github.com/iotaledger/inx/go v1.0.0-rc.2.0.20231031134131-b6ad918dc1ac h1:c7R33+TQGMYP6pvLUQQaqpdDFl+GZbhAcfGMI0285fo= github.com/iotaledger/inx/go v1.0.0-rc.2.0.20231031134131-b6ad918dc1ac/go.mod h1:qPuMUvCTaghsnYRDnRoRuztTyEKFlmi2S7gb44rH7WM= -github.com/iotaledger/iota.go/v4 v4.0.0-20231031113109-5d7d59311967 h1:qiBW4TiRdzVJshLu7RoWn9ur64SFLCOQ0oFtQWtz4bk= -github.com/iotaledger/iota.go/v4 v4.0.0-20231031113109-5d7d59311967/go.mod h1:jqbLYq4a/FwuiPBqFfkAwwxU8vs3+kReRq2/tyX5qRA= +github.com/iotaledger/iota.go/v4 v4.0.0-20231031141917-e514cdca2d25 h1:GXzRrRohi46SPhwcz+9455PaEh2j+wyc7r0sBFTX6PM= +github.com/iotaledger/iota.go/v4 v4.0.0-20231031141917-e514cdca2d25/go.mod h1:jqbLYq4a/FwuiPBqFfkAwwxU8vs3+kReRq2/tyX5qRA= github.com/ipfs/boxo v0.13.1 h1:nQ5oQzcMZR3oL41REJDcTbrvDvuZh3J9ckc9+ILeRQI= github.com/ipfs/boxo v0.13.1/go.mod h1:btrtHy0lmO1ODMECbbEY1pxNtrLilvKSYLoGQt1yYCk= github.com/ipfs/go-cid v0.4.1 h1:A/T3qGvxi4kpKWWcPC/PgbvDA2bjVLO7n4UeVwnbs/s= diff --git a/tools/gendoc/go.mod b/tools/gendoc/go.mod index 83ca86d17..1077b68d1 100644 --- a/tools/gendoc/go.mod +++ b/tools/gendoc/go.mod @@ -72,7 +72,7 @@ require ( github.com/iotaledger/hive.go/stringify v0.0.0-20231027195901-620bd7470e42 // indirect github.com/iotaledger/inx-app v1.0.0-rc.3.0.20231031135002-4c79ea5193f5 // indirect github.com/iotaledger/inx/go v1.0.0-rc.2.0.20231031134131-b6ad918dc1ac // indirect - github.com/iotaledger/iota.go/v4 v4.0.0-20231031113109-5d7d59311967 // indirect + github.com/iotaledger/iota.go/v4 v4.0.0-20231031141917-e514cdca2d25 // indirect github.com/ipfs/boxo v0.13.1 // indirect github.com/ipfs/go-cid v0.4.1 // indirect github.com/ipfs/go-datastore v0.6.0 // indirect diff --git a/tools/gendoc/go.sum b/tools/gendoc/go.sum index f3ed230d4..c27e6dd2e 100644 --- a/tools/gendoc/go.sum +++ b/tools/gendoc/go.sum @@ -311,8 +311,8 @@ github.com/iotaledger/inx-app v1.0.0-rc.3.0.20231031135002-4c79ea5193f5 h1:17JDz github.com/iotaledger/inx-app v1.0.0-rc.3.0.20231031135002-4c79ea5193f5/go.mod h1:LsJvoBUVVnY7tkwwByCVtAwmp5bFXdyJNGU/+KVQJVM= github.com/iotaledger/inx/go v1.0.0-rc.2.0.20231031134131-b6ad918dc1ac h1:c7R33+TQGMYP6pvLUQQaqpdDFl+GZbhAcfGMI0285fo= github.com/iotaledger/inx/go v1.0.0-rc.2.0.20231031134131-b6ad918dc1ac/go.mod h1:qPuMUvCTaghsnYRDnRoRuztTyEKFlmi2S7gb44rH7WM= -github.com/iotaledger/iota.go/v4 v4.0.0-20231031113109-5d7d59311967 h1:qiBW4TiRdzVJshLu7RoWn9ur64SFLCOQ0oFtQWtz4bk= -github.com/iotaledger/iota.go/v4 v4.0.0-20231031113109-5d7d59311967/go.mod h1:jqbLYq4a/FwuiPBqFfkAwwxU8vs3+kReRq2/tyX5qRA= +github.com/iotaledger/iota.go/v4 v4.0.0-20231031141917-e514cdca2d25 h1:GXzRrRohi46SPhwcz+9455PaEh2j+wyc7r0sBFTX6PM= +github.com/iotaledger/iota.go/v4 v4.0.0-20231031141917-e514cdca2d25/go.mod h1:jqbLYq4a/FwuiPBqFfkAwwxU8vs3+kReRq2/tyX5qRA= github.com/ipfs/boxo v0.13.1 h1:nQ5oQzcMZR3oL41REJDcTbrvDvuZh3J9ckc9+ILeRQI= github.com/ipfs/boxo v0.13.1/go.mod h1:btrtHy0lmO1ODMECbbEY1pxNtrLilvKSYLoGQt1yYCk= github.com/ipfs/go-cid v0.4.1 h1:A/T3qGvxi4kpKWWcPC/PgbvDA2bjVLO7n4UeVwnbs/s= diff --git a/tools/genesis-snapshot/go.mod b/tools/genesis-snapshot/go.mod index dbe403965..48f4003ba 100644 --- a/tools/genesis-snapshot/go.mod +++ b/tools/genesis-snapshot/go.mod @@ -10,7 +10,7 @@ require ( github.com/iotaledger/hive.go/lo v0.0.0-20231027195901-620bd7470e42 github.com/iotaledger/hive.go/runtime v0.0.0-20231027195901-620bd7470e42 github.com/iotaledger/iota-core v0.0.0-00010101000000-000000000000 - github.com/iotaledger/iota.go/v4 v4.0.0-20231031113109-5d7d59311967 + github.com/iotaledger/iota.go/v4 v4.0.0-20231031141917-e514cdca2d25 github.com/mr-tron/base58 v1.2.0 github.com/spf13/pflag v1.0.5 golang.org/x/crypto v0.14.0 diff --git a/tools/genesis-snapshot/go.sum b/tools/genesis-snapshot/go.sum index 4f07d0064..00d7bfa44 100644 --- a/tools/genesis-snapshot/go.sum +++ b/tools/genesis-snapshot/go.sum @@ -52,8 +52,8 @@ github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20231027195901-620bd74 github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20231027195901-620bd7470e42/go.mod h1:SdK26z8/VhWtxaqCuQrufm80SELgowQPmu9T/8eUQ8g= github.com/iotaledger/hive.go/stringify v0.0.0-20231027195901-620bd7470e42 h1:OlDhgvJ48bZxcvTeebJ1b96xtNnJAddejd2Q4rlH1mU= github.com/iotaledger/hive.go/stringify v0.0.0-20231027195901-620bd7470e42/go.mod h1:FTo/UWzNYgnQ082GI9QVM9HFDERqf9rw9RivNpqrnTs= -github.com/iotaledger/iota.go/v4 v4.0.0-20231031113109-5d7d59311967 h1:qiBW4TiRdzVJshLu7RoWn9ur64SFLCOQ0oFtQWtz4bk= -github.com/iotaledger/iota.go/v4 v4.0.0-20231031113109-5d7d59311967/go.mod h1:jqbLYq4a/FwuiPBqFfkAwwxU8vs3+kReRq2/tyX5qRA= +github.com/iotaledger/iota.go/v4 v4.0.0-20231031141917-e514cdca2d25 h1:GXzRrRohi46SPhwcz+9455PaEh2j+wyc7r0sBFTX6PM= +github.com/iotaledger/iota.go/v4 v4.0.0-20231031141917-e514cdca2d25/go.mod h1:jqbLYq4a/FwuiPBqFfkAwwxU8vs3+kReRq2/tyX5qRA= github.com/ipfs/go-cid v0.4.1 h1:A/T3qGvxi4kpKWWcPC/PgbvDA2bjVLO7n4UeVwnbs/s= github.com/ipfs/go-cid v0.4.1/go.mod h1:uQHwDeX4c6CtyrFwdqyhpNcxVewur1M7l7fNU7LKwZk= github.com/klauspost/cpuid/v2 v2.2.5 h1:0E5MSMDEoAulmXNFquVs//DdoomxaoTY1kUhbc/qbZg= From 8f22f6e5d45d817258187ddf7a35c1d7b26ce770 Mon Sep 17 00:00:00 2001 From: Alexander Sporn Date: Tue, 31 Oct 2023 15:51:13 +0100 Subject: [PATCH 05/14] Fixed RMC vector when committing a slot --- pkg/protocol/engine/ledger/ledger/ledger.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/pkg/protocol/engine/ledger/ledger/ledger.go b/pkg/protocol/engine/ledger/ledger/ledger.go index 4728289e8..1cf863a6f 100644 --- a/pkg/protocol/engine/ledger/ledger/ledger.go +++ b/pkg/protocol/engine/ledger/ledger/ledger.go @@ -180,11 +180,14 @@ func (l *Ledger) CommitSlot(slot iotago.SlotIndex) (stateRoot iotago.Identifier, // Update the Accounts ledger // first, get the RMC corresponding to this slot - maxCommittableAge := l.apiProvider.APIForSlot(slot).ProtocolParameters().MaxCommittableAge() - rmcIndex, _ := safemath.SafeSub(slot, maxCommittableAge) - rmcForSlot, err := l.rmcManager.RMC(rmcIndex) + protocolParams := l.apiProvider.APIForSlot(slot).ProtocolParameters() + rmcSlot, _ := safemath.SafeSub(slot, protocolParams.MaxCommittableAge()) + if rmcSlot < protocolParams.GenesisSlot() { + rmcSlot = protocolParams.GenesisSlot() + } + rmcForSlot, err := l.rmcManager.RMC(rmcSlot) if err != nil { - return iotago.Identifier{}, iotago.Identifier{}, iotago.Identifier{}, ierrors.Errorf("ledger failed to get RMC for slot %d: %w", slot, err) + return iotago.Identifier{}, iotago.Identifier{}, iotago.Identifier{}, ierrors.Errorf("ledger failed to get RMC for slot %d: %w", rmcSlot, err) } if err = l.accountsLedger.ApplyDiff(slot, rmcForSlot, accountDiffs, destroyedAccounts); err != nil { return iotago.Identifier{}, iotago.Identifier{}, iotago.Identifier{}, ierrors.Errorf("failed to apply diff to Accounts ledger for slot %d: %w", slot, err) From 885ff431d3896a3d5ac94cfef26ad5ff51130e64 Mon Sep 17 00:00:00 2001 From: Alexander Sporn Date: Mon, 6 Nov 2023 08:35:47 +0100 Subject: [PATCH 06/14] Updated iota.go to latest --- go.mod | 2 +- go.sum | 4 ++-- tools/gendoc/go.mod | 2 +- tools/gendoc/go.sum | 4 ++-- tools/genesis-snapshot/go.mod | 2 +- tools/genesis-snapshot/go.sum | 4 ++-- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/go.mod b/go.mod index 006f26e31..90dbdffc0 100644 --- a/go.mod +++ b/go.mod @@ -25,7 +25,7 @@ require ( github.com/iotaledger/hive.go/stringify v0.0.0-20231027195901-620bd7470e42 github.com/iotaledger/inx-app v1.0.0-rc.3.0.20231031135002-4c79ea5193f5 github.com/iotaledger/inx/go v1.0.0-rc.2.0.20231031134131-b6ad918dc1ac - github.com/iotaledger/iota.go/v4 v4.0.0-20231102113728-20b8d01e826e + github.com/iotaledger/iota.go/v4 v4.0.0-20231106073207-df0b9a448e96 github.com/labstack/echo/v4 v4.11.2 github.com/labstack/gommon v0.4.0 github.com/libp2p/go-libp2p v0.32.0 diff --git a/go.sum b/go.sum index 2af6a376f..4cac2ad11 100644 --- a/go.sum +++ b/go.sum @@ -307,8 +307,8 @@ github.com/iotaledger/inx-app v1.0.0-rc.3.0.20231031135002-4c79ea5193f5 h1:17JDz github.com/iotaledger/inx-app v1.0.0-rc.3.0.20231031135002-4c79ea5193f5/go.mod h1:LsJvoBUVVnY7tkwwByCVtAwmp5bFXdyJNGU/+KVQJVM= github.com/iotaledger/inx/go v1.0.0-rc.2.0.20231031134131-b6ad918dc1ac h1:c7R33+TQGMYP6pvLUQQaqpdDFl+GZbhAcfGMI0285fo= github.com/iotaledger/inx/go v1.0.0-rc.2.0.20231031134131-b6ad918dc1ac/go.mod h1:qPuMUvCTaghsnYRDnRoRuztTyEKFlmi2S7gb44rH7WM= -github.com/iotaledger/iota.go/v4 v4.0.0-20231102113728-20b8d01e826e h1:ZYRC1MHn/ghsqtjIpYGTxLQrh5n5eUmC0/YWnJiTRhk= -github.com/iotaledger/iota.go/v4 v4.0.0-20231102113728-20b8d01e826e/go.mod h1:jqbLYq4a/FwuiPBqFfkAwwxU8vs3+kReRq2/tyX5qRA= +github.com/iotaledger/iota.go/v4 v4.0.0-20231106073207-df0b9a448e96 h1:r1WyeLOAD//t9jG3sMYNEAy5SHQgVFi5VS0C88Aek6g= +github.com/iotaledger/iota.go/v4 v4.0.0-20231106073207-df0b9a448e96/go.mod h1:jqbLYq4a/FwuiPBqFfkAwwxU8vs3+kReRq2/tyX5qRA= github.com/ipfs/boxo v0.13.1 h1:nQ5oQzcMZR3oL41REJDcTbrvDvuZh3J9ckc9+ILeRQI= github.com/ipfs/boxo v0.13.1/go.mod h1:btrtHy0lmO1ODMECbbEY1pxNtrLilvKSYLoGQt1yYCk= github.com/ipfs/go-cid v0.4.1 h1:A/T3qGvxi4kpKWWcPC/PgbvDA2bjVLO7n4UeVwnbs/s= diff --git a/tools/gendoc/go.mod b/tools/gendoc/go.mod index 4fdc2c0b0..4633e32c4 100644 --- a/tools/gendoc/go.mod +++ b/tools/gendoc/go.mod @@ -72,7 +72,7 @@ require ( github.com/iotaledger/hive.go/stringify v0.0.0-20231027195901-620bd7470e42 // indirect github.com/iotaledger/inx-app v1.0.0-rc.3.0.20231031135002-4c79ea5193f5 // indirect github.com/iotaledger/inx/go v1.0.0-rc.2.0.20231031134131-b6ad918dc1ac // indirect - github.com/iotaledger/iota.go/v4 v4.0.0-20231102113728-20b8d01e826e // indirect + github.com/iotaledger/iota.go/v4 v4.0.0-20231106073207-df0b9a448e96 // indirect github.com/ipfs/boxo v0.13.1 // indirect github.com/ipfs/go-cid v0.4.1 // indirect github.com/ipfs/go-datastore v0.6.0 // indirect diff --git a/tools/gendoc/go.sum b/tools/gendoc/go.sum index b16ac173a..c80cc2de5 100644 --- a/tools/gendoc/go.sum +++ b/tools/gendoc/go.sum @@ -311,8 +311,8 @@ github.com/iotaledger/inx-app v1.0.0-rc.3.0.20231031135002-4c79ea5193f5 h1:17JDz github.com/iotaledger/inx-app v1.0.0-rc.3.0.20231031135002-4c79ea5193f5/go.mod h1:LsJvoBUVVnY7tkwwByCVtAwmp5bFXdyJNGU/+KVQJVM= github.com/iotaledger/inx/go v1.0.0-rc.2.0.20231031134131-b6ad918dc1ac h1:c7R33+TQGMYP6pvLUQQaqpdDFl+GZbhAcfGMI0285fo= github.com/iotaledger/inx/go v1.0.0-rc.2.0.20231031134131-b6ad918dc1ac/go.mod h1:qPuMUvCTaghsnYRDnRoRuztTyEKFlmi2S7gb44rH7WM= -github.com/iotaledger/iota.go/v4 v4.0.0-20231102113728-20b8d01e826e h1:ZYRC1MHn/ghsqtjIpYGTxLQrh5n5eUmC0/YWnJiTRhk= -github.com/iotaledger/iota.go/v4 v4.0.0-20231102113728-20b8d01e826e/go.mod h1:jqbLYq4a/FwuiPBqFfkAwwxU8vs3+kReRq2/tyX5qRA= +github.com/iotaledger/iota.go/v4 v4.0.0-20231106073207-df0b9a448e96 h1:r1WyeLOAD//t9jG3sMYNEAy5SHQgVFi5VS0C88Aek6g= +github.com/iotaledger/iota.go/v4 v4.0.0-20231106073207-df0b9a448e96/go.mod h1:jqbLYq4a/FwuiPBqFfkAwwxU8vs3+kReRq2/tyX5qRA= github.com/ipfs/boxo v0.13.1 h1:nQ5oQzcMZR3oL41REJDcTbrvDvuZh3J9ckc9+ILeRQI= github.com/ipfs/boxo v0.13.1/go.mod h1:btrtHy0lmO1ODMECbbEY1pxNtrLilvKSYLoGQt1yYCk= github.com/ipfs/go-cid v0.4.1 h1:A/T3qGvxi4kpKWWcPC/PgbvDA2bjVLO7n4UeVwnbs/s= diff --git a/tools/genesis-snapshot/go.mod b/tools/genesis-snapshot/go.mod index 1ec9104e2..c7b5ef6c2 100644 --- a/tools/genesis-snapshot/go.mod +++ b/tools/genesis-snapshot/go.mod @@ -10,7 +10,7 @@ require ( github.com/iotaledger/hive.go/lo v0.0.0-20231027195901-620bd7470e42 github.com/iotaledger/hive.go/runtime v0.0.0-20231027195901-620bd7470e42 github.com/iotaledger/iota-core v0.0.0-00010101000000-000000000000 - github.com/iotaledger/iota.go/v4 v4.0.0-20231102113728-20b8d01e826e + github.com/iotaledger/iota.go/v4 v4.0.0-20231106073207-df0b9a448e96 github.com/mr-tron/base58 v1.2.0 github.com/spf13/pflag v1.0.5 golang.org/x/crypto v0.14.0 diff --git a/tools/genesis-snapshot/go.sum b/tools/genesis-snapshot/go.sum index 00953620a..566f08dad 100644 --- a/tools/genesis-snapshot/go.sum +++ b/tools/genesis-snapshot/go.sum @@ -52,8 +52,8 @@ github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20231027195901-620bd74 github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20231027195901-620bd7470e42/go.mod h1:SdK26z8/VhWtxaqCuQrufm80SELgowQPmu9T/8eUQ8g= github.com/iotaledger/hive.go/stringify v0.0.0-20231027195901-620bd7470e42 h1:OlDhgvJ48bZxcvTeebJ1b96xtNnJAddejd2Q4rlH1mU= github.com/iotaledger/hive.go/stringify v0.0.0-20231027195901-620bd7470e42/go.mod h1:FTo/UWzNYgnQ082GI9QVM9HFDERqf9rw9RivNpqrnTs= -github.com/iotaledger/iota.go/v4 v4.0.0-20231102113728-20b8d01e826e h1:ZYRC1MHn/ghsqtjIpYGTxLQrh5n5eUmC0/YWnJiTRhk= -github.com/iotaledger/iota.go/v4 v4.0.0-20231102113728-20b8d01e826e/go.mod h1:jqbLYq4a/FwuiPBqFfkAwwxU8vs3+kReRq2/tyX5qRA= +github.com/iotaledger/iota.go/v4 v4.0.0-20231106073207-df0b9a448e96 h1:r1WyeLOAD//t9jG3sMYNEAy5SHQgVFi5VS0C88Aek6g= +github.com/iotaledger/iota.go/v4 v4.0.0-20231106073207-df0b9a448e96/go.mod h1:jqbLYq4a/FwuiPBqFfkAwwxU8vs3+kReRq2/tyX5qRA= github.com/ipfs/go-cid v0.4.1 h1:A/T3qGvxi4kpKWWcPC/PgbvDA2bjVLO7n4UeVwnbs/s= github.com/ipfs/go-cid v0.4.1/go.mod h1:uQHwDeX4c6CtyrFwdqyhpNcxVewur1M7l7fNU7LKwZk= github.com/klauspost/cpuid/v2 v2.2.5 h1:0E5MSMDEoAulmXNFquVs//DdoomxaoTY1kUhbc/qbZg= From 239496999cc29f3f184f8f419279a5fa924b493e Mon Sep 17 00:00:00 2001 From: Alexander Sporn Date: Mon, 6 Nov 2023 08:39:19 +0100 Subject: [PATCH 07/14] Add comment to safemath.SafeSub usage --- pkg/protocol/engine/ledger/ledger/ledger.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/protocol/engine/ledger/ledger/ledger.go b/pkg/protocol/engine/ledger/ledger/ledger.go index 1cf863a6f..47ccd7d68 100644 --- a/pkg/protocol/engine/ledger/ledger/ledger.go +++ b/pkg/protocol/engine/ledger/ledger/ledger.go @@ -181,7 +181,7 @@ func (l *Ledger) CommitSlot(slot iotago.SlotIndex) (stateRoot iotago.Identifier, // Update the Accounts ledger // first, get the RMC corresponding to this slot protocolParams := l.apiProvider.APIForSlot(slot).ProtocolParameters() - rmcSlot, _ := safemath.SafeSub(slot, protocolParams.MaxCommittableAge()) + rmcSlot, _ := safemath.SafeSub(slot, protocolParams.MaxCommittableAge()) // We can safely ignore the underflow error and use the default 0 return value if rmcSlot < protocolParams.GenesisSlot() { rmcSlot = protocolParams.GenesisSlot() } From eb75affaf61053443bae5d1a08b953ec7c22ff00 Mon Sep 17 00:00:00 2001 From: Andrea V <1577639+karimodm@users.noreply.github.com> Date: Mon, 6 Nov 2023 14:36:59 +0100 Subject: [PATCH 08/14] Remove intermediate eviction state cache --- go.mod | 2 +- pkg/protocol/engine/engine.go | 1 - pkg/protocol/engine/eviction/state.go | 114 ++++++++---------- .../engine/tipselection/v1/provider.go | 4 +- .../engine/tipselection/v1/tip_selection.go | 12 ++ 5 files changed, 64 insertions(+), 69 deletions(-) diff --git a/go.mod b/go.mod index 90dbdffc0..dda97aec0 100644 --- a/go.mod +++ b/go.mod @@ -43,6 +43,7 @@ require ( go.uber.org/atomic v1.11.0 go.uber.org/dig v1.17.1 golang.org/x/crypto v0.14.0 + golang.org/x/exp v0.0.0-20231006140011-7918f672742d google.golang.org/grpc v1.59.0 google.golang.org/protobuf v1.31.0 ) @@ -169,7 +170,6 @@ require ( go.uber.org/mock v0.3.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.26.0 // indirect - golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect golang.org/x/image v0.13.0 // indirect golang.org/x/mod v0.13.0 // indirect golang.org/x/net v0.17.0 // indirect diff --git a/pkg/protocol/engine/engine.go b/pkg/protocol/engine/engine.go index de997f340..089d8d5cc 100644 --- a/pkg/protocol/engine/engine.go +++ b/pkg/protocol/engine/engine.go @@ -199,7 +199,6 @@ func New( } else { // Restore from Disk e.Storage.RestoreFromDisk() - e.EvictionState.PopulateFromStorage(e.Storage.Settings().LatestCommitment().Slot()) if err := e.Attestations.RestoreFromDisk(); err != nil { panic(ierrors.Wrap(err, "failed to restore attestations from disk")) diff --git a/pkg/protocol/engine/eviction/state.go b/pkg/protocol/engine/eviction/state.go index b913653bb..e9867bfb2 100644 --- a/pkg/protocol/engine/eviction/state.go +++ b/pkg/protocol/engine/eviction/state.go @@ -3,8 +3,7 @@ package eviction import ( "io" - "github.com/iotaledger/hive.go/core/memstorage" - "github.com/iotaledger/hive.go/ds/ringbuffer" + "github.com/iotaledger/hive.go/core/safemath" "github.com/iotaledger/hive.go/ierrors" "github.com/iotaledger/hive.go/kvstore" "github.com/iotaledger/hive.go/lo" @@ -21,8 +20,6 @@ const latestNonEmptySlotKey = 1 type State struct { Events *Events - rootBlocks *memstorage.IndexedStorage[iotago.SlotIndex, iotago.BlockID, iotago.CommitmentID] - latestRootBlocks *ringbuffer.RingBuffer[iotago.BlockID] rootBlockStorageFunc func(iotago.SlotIndex) (*slotstore.Store[iotago.BlockID, iotago.CommitmentID], error) lastEvictedSlot iotago.SlotIndex latestNonEmptyStore kvstore.KVStore @@ -37,8 +34,6 @@ type State struct { func NewState(latestNonEmptyStore kvstore.KVStore, rootBlockStorageFunc func(iotago.SlotIndex) (*slotstore.Store[iotago.BlockID, iotago.CommitmentID], error), genesisRootBlockFunc func() iotago.BlockID, opts ...options.Option[State]) (state *State) { return options.Apply(&State{ Events: NewEvents(), - rootBlocks: memstorage.NewIndexedStorage[iotago.SlotIndex, iotago.BlockID, iotago.CommitmentID](), - latestRootBlocks: ringbuffer.NewRingBuffer[iotago.BlockID](8), rootBlockStorageFunc: rootBlockStorageFunc, latestNonEmptyStore: latestNonEmptyStore, genesisRootBlockFunc: genesisRootBlockFunc, @@ -57,8 +52,12 @@ func (s *State) AdvanceActiveWindowToIndex(slot iotago.SlotIndex) { if delayedIndex, shouldEvictRootBlocks := s.delayedBlockEvictionThreshold(slot); shouldEvictRootBlocks { // Remember the last slot outside our cache window that has root blocks. - if evictedSlot := s.rootBlocks.Evict(delayedIndex); evictedSlot != nil && evictedSlot.Size() > 0 { - s.setLatestNonEmptySlot(delayedIndex) + if storage, err := s.rootBlockStorageFunc(delayedIndex); err != nil { + storage.StreamKeys(func(_ iotago.BlockID) error { + s.setLatestNonEmptySlot(delayedIndex) + + return ierrors.New("stop iteration") + }) } } @@ -89,15 +88,17 @@ func (s *State) ActiveRootBlocks() map[iotago.BlockID]iotago.CommitmentID { activeRootBlocks := make(map[iotago.BlockID]iotago.CommitmentID) startSlot, endSlot := s.activeIndexRange() for slot := startSlot; slot <= endSlot; slot++ { - storage := s.rootBlocks.Get(slot) - if storage == nil { + // We assume the cache is always populated for the latest slots. + storage, err := s.rootBlockStorageFunc(slot) + // Slot too old, it was pruned. + if err != nil { continue } - storage.ForEach(func(id iotago.BlockID, commitmentID iotago.CommitmentID) bool { + storage.Stream(func(id iotago.BlockID, commitmentID iotago.CommitmentID) error { activeRootBlocks[id] = commitmentID - return true + return nil }) } @@ -114,13 +115,9 @@ func (s *State) AddRootBlock(id iotago.BlockID, commitmentID iotago.CommitmentID return } - if s.rootBlocks.Get(id.Slot(), true).Set(id, commitmentID) { - if err := lo.PanicOnErr(s.rootBlockStorageFunc(id.Slot())).Store(id, commitmentID); err != nil { - panic(ierrors.Wrapf(err, "failed to store root block %s", id)) - } + if err := lo.PanicOnErr(s.rootBlockStorageFunc(id.Slot())).Store(id, commitmentID); err != nil { + panic(ierrors.Wrapf(err, "failed to store root block %s", id)) } - - s.latestRootBlocks.Add(id) } // RemoveRootBlock removes a solid entry points from the map. @@ -128,10 +125,8 @@ func (s *State) RemoveRootBlock(id iotago.BlockID) { s.evictionMutex.RLock() defer s.evictionMutex.RUnlock() - if rootBlocks := s.rootBlocks.Get(id.Slot()); rootBlocks != nil && rootBlocks.Delete(id) { - if err := lo.PanicOnErr(s.rootBlockStorageFunc(id.Slot())).Delete(id); err != nil { - panic(err) - } + if err := lo.PanicOnErr(s.rootBlockStorageFunc(id.Slot())).Delete(id); err != nil { + panic(err) } } @@ -144,9 +139,12 @@ func (s *State) IsRootBlock(id iotago.BlockID) (has bool) { return false } - slotBlocks := s.rootBlocks.Get(id.Slot(), false) + storage, err := s.rootBlockStorageFunc(id.Slot()) + if err != nil { + return false + } - return slotBlocks != nil && slotBlocks.Has(id) + return lo.PanicOnErr(storage.Has(id)) } // RootBlockCommitmentID returns the commitmentID if it is a known root block. @@ -158,22 +156,15 @@ func (s *State) RootBlockCommitmentID(id iotago.BlockID) (commitmentID iotago.Co return iotago.CommitmentID{}, false } - slotBlocks := s.rootBlocks.Get(id.Slot(), false) - if slotBlocks == nil { - return iotago.CommitmentID{}, false + storage, err := s.rootBlockStorageFunc(id.Slot()) + if err != nil { + return iotago.EmptyCommitmentID, false } - return slotBlocks.Get(id) -} - -// LatestRootBlocks returns the latest root blocks. -func (s *State) LatestRootBlocks() iotago.BlockIDs { - rootBlocks := s.latestRootBlocks.ToSlice() - if len(rootBlocks) == 0 { - return iotago.BlockIDs{s.genesisRootBlockFunc()} - } + // This return empty value for commitmentID in the case the key is not found. + commitmentID = lo.PanicOnErr(storage.Load(id)) - return rootBlocks + return commitmentID, commitmentID != iotago.EmptyCommitmentID } // Export exports the root blocks to the given writer. @@ -235,7 +226,6 @@ func (s *State) Export(writer io.WriteSeeker, lowerTarget iotago.SlotIndex, targ // Import imports the root blocks from the given reader. func (s *State) Import(reader io.ReadSeeker) error { if err := stream.ReadCollection(reader, func(i int) error { - blockIDBytes, err := stream.ReadBlob(reader) if err != nil { return ierrors.Wrapf(err, "failed to read root block id %d", i) @@ -256,10 +246,8 @@ func (s *State) Import(reader io.ReadSeeker) error { return ierrors.Wrapf(err, "failed to parse root block's %s commitment id", rootBlockID) } - if s.rootBlocks.Get(rootBlockID.Slot(), true).Set(rootBlockID, commitmentID) { - if err := lo.PanicOnErr(s.rootBlockStorageFunc(rootBlockID.Slot())).Store(rootBlockID, commitmentID); err != nil { - panic(ierrors.Wrapf(err, "failed to store root block %s", rootBlockID)) - } + if err := lo.PanicOnErr(s.rootBlockStorageFunc(rootBlockID.Slot())).Store(rootBlockID, commitmentID); err != nil { + panic(ierrors.Wrapf(err, "failed to store root block %s", rootBlockID)) } return nil @@ -312,22 +300,6 @@ func (s *State) Rollback(lowerTarget, targetIndex iotago.SlotIndex) error { return nil } -// PopulateFromStorage populates the root blocks from the storage. -func (s *State) PopulateFromStorage(latestCommitmentSlot iotago.SlotIndex) { - for slot := lo.Return1(s.delayedBlockEvictionThreshold(latestCommitmentSlot)); slot <= latestCommitmentSlot; slot++ { - storedRootBlocks, err := s.rootBlockStorageFunc(slot) - if err != nil { - continue - } - - _ = storedRootBlocks.Stream(func(id iotago.BlockID, commitmentID iotago.CommitmentID) error { - s.AddRootBlock(id, commitmentID) - - return nil - }) - } -} - // latestNonEmptySlot returns the latest slot that contains a rootblock. func (s *State) latestNonEmptySlot() iotago.SlotIndex { latestNonEmptySlotBytes, err := s.latestNonEmptyStore.Get([]byte{latestNonEmptySlotKey}) @@ -381,17 +353,27 @@ func (s *State) delayedBlockEvictionThreshold(slot iotago.SlotIndex) (thresholdS return genesisSlot, false } + var rootBlockInWindow bool // Check if we have root blocks up to the eviction point. for ; slot >= s.lastEvictedSlot; slot-- { - if rb := s.rootBlocks.Get(slot); rb != nil { - if rb.Size() > 0 { - if slot >= s.optsRootBlocksEvictionDelay { - return slot - s.optsRootBlocksEvictionDelay, true - } - - return genesisSlot, false + storage := lo.PanicOnErr(s.rootBlockStorageFunc(slot)) + + storage.StreamKeys(func(_ iotago.BlockID) error { + if thresholdSlot, _ = safemath.SafeSub(slot, s.optsRootBlocksEvictionDelay); thresholdSlot <= genesisSlot { + thresholdSlot = genesisSlot + shouldEvict = false + } else { + shouldEvict = true } - } + + rootBlockInWindow = true + + return ierrors.New("stop iteration") + }) + } + + if rootBlockInWindow { + return thresholdSlot, shouldEvict } // If we didn't find any root blocks, we have to fallback to the latestNonEmptySlot before the eviction point. diff --git a/pkg/protocol/engine/tipselection/v1/provider.go b/pkg/protocol/engine/tipselection/v1/provider.go index ad9bb1d1b..f26180628 100644 --- a/pkg/protocol/engine/tipselection/v1/provider.go +++ b/pkg/protocol/engine/tipselection/v1/provider.go @@ -4,12 +4,14 @@ import ( "math" "time" + "github.com/iotaledger/hive.go/lo" "github.com/iotaledger/hive.go/runtime/module" "github.com/iotaledger/hive.go/runtime/options" "github.com/iotaledger/iota-core/pkg/protocol/engine" "github.com/iotaledger/iota-core/pkg/protocol/engine/blocks" "github.com/iotaledger/iota-core/pkg/protocol/engine/tipmanager" "github.com/iotaledger/iota-core/pkg/protocol/engine/tipselection" + iotago "github.com/iotaledger/iota.go/v4" ) // NewProvider creates a new TipSelection provider, that can be used to inject the component into an engine. @@ -20,7 +22,7 @@ func NewProvider(opts ...options.Option[TipSelection]) module.Provider[*engine.E e.HookConstructed(func() { // wait for submodules to be constructed (so all of their properties are available) module.OnAllConstructed(func() { - t.Construct(e.TipManager, e.Ledger.ConflictDAG(), e.Ledger.MemPool().TransactionMetadata, e.EvictionState.LatestRootBlocks, DynamicLivenessThreshold(e.SybilProtection.SeatManager().OnlineCommittee().Size)) + t.Construct(e.TipManager, e.Ledger.ConflictDAG(), e.Ledger.MemPool().TransactionMetadata, func() iotago.BlockIDs { return lo.Keys(e.EvictionState.ActiveRootBlocks()) }, DynamicLivenessThreshold(e.SybilProtection.SeatManager().OnlineCommittee().Size)) e.Events.AcceptedBlockProcessed.Hook(func(block *blocks.Block) { t.SetAcceptanceTime(block.IssuingTime()) diff --git a/pkg/protocol/engine/tipselection/v1/tip_selection.go b/pkg/protocol/engine/tipselection/v1/tip_selection.go index ee7b7fad4..f745dcc16 100644 --- a/pkg/protocol/engine/tipselection/v1/tip_selection.go +++ b/pkg/protocol/engine/tipselection/v1/tip_selection.go @@ -3,6 +3,8 @@ package tipselectionv1 import ( "time" + "golang.org/x/exp/slices" + "github.com/iotaledger/hive.go/ds" "github.com/iotaledger/hive.go/ds/reactive" "github.com/iotaledger/hive.go/ierrors" @@ -120,6 +122,16 @@ func (t *TipSelection) SelectTips(amount int) (references model.ParentReferences }, amount); len(references[iotago.StrongParentType]) == 0 { rootBlocks := t.rootBlocks() + // Sort the rootBlocks in descending order according to their slot. + slices.SortFunc(rootBlocks, func(i, j iotago.BlockID) int { + if i.Slot() == j.Slot() { + return 0 + } else if i.Slot() < j.Slot() { + return 1 + } + return -1 + }) + references[iotago.StrongParentType] = rootBlocks[:lo.Min(len(rootBlocks), t.optMaxStrongParents)] } From f73f56be79379240613ad3cea6fcf0f1e22f18ad Mon Sep 17 00:00:00 2001 From: Andrea V <1577639+karimodm@users.noreply.github.com> Date: Mon, 6 Nov 2023 15:15:59 +0100 Subject: [PATCH 09/14] Fix delayedBlockEvictionThreshold logic --- pkg/protocol/engine/eviction/state.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/protocol/engine/eviction/state.go b/pkg/protocol/engine/eviction/state.go index e9867bfb2..724ac48d9 100644 --- a/pkg/protocol/engine/eviction/state.go +++ b/pkg/protocol/engine/eviction/state.go @@ -3,7 +3,6 @@ package eviction import ( "io" - "github.com/iotaledger/hive.go/core/safemath" "github.com/iotaledger/hive.go/ierrors" "github.com/iotaledger/hive.go/kvstore" "github.com/iotaledger/hive.go/lo" @@ -359,11 +358,12 @@ func (s *State) delayedBlockEvictionThreshold(slot iotago.SlotIndex) (thresholdS storage := lo.PanicOnErr(s.rootBlockStorageFunc(slot)) storage.StreamKeys(func(_ iotago.BlockID) error { - if thresholdSlot, _ = safemath.SafeSub(slot, s.optsRootBlocksEvictionDelay); thresholdSlot <= genesisSlot { + if slot >= s.optsRootBlocksEvictionDelay { + thresholdSlot = slot - s.optsRootBlocksEvictionDelay + shouldEvict = true + } else { thresholdSlot = genesisSlot shouldEvict = false - } else { - shouldEvict = true } rootBlockInWindow = true From b6a100f1c8f579c85d92799723737fe06902e199 Mon Sep 17 00:00:00 2001 From: Alexander Sporn Date: Tue, 7 Nov 2023 14:45:03 +0100 Subject: [PATCH 10/14] Changed how the slotstore Load method returns a key not found --- pkg/protocol/engine/committed_slot_api.go | 2 +- pkg/protocol/engine/eviction/state.go | 7 +++++-- pkg/protocol/engine/eviction/testframework_test.go | 3 ++- pkg/protocol/protocol_fork.go | 2 +- .../sybilprotectionv1/performance/performance.go | 11 ++++++++--- pkg/storage/prunable/slotstore/store.go | 10 +++++----- pkg/testsuite/mock/node.go | 3 ++- pkg/testsuite/storage_rootblocks.go | 6 +++++- 8 files changed, 29 insertions(+), 15 deletions(-) diff --git a/pkg/protocol/engine/committed_slot_api.go b/pkg/protocol/engine/committed_slot_api.go index edb604814..6b9c22c2c 100644 --- a/pkg/protocol/engine/committed_slot_api.go +++ b/pkg/protocol/engine/committed_slot_api.go @@ -44,7 +44,7 @@ func (c *CommittedSlotAPI) Roots() (committedRoots *iotago.Roots, err error) { return nil, ierrors.Errorf("no roots storage for slot %d", c.CommitmentID) } - roots, err := rootsStorage.Load(c.CommitmentID) + roots, _, err := rootsStorage.Load(c.CommitmentID) if err != nil { return nil, ierrors.Wrapf(err, "failed to load roots for slot %d", c.CommitmentID) } diff --git a/pkg/protocol/engine/eviction/state.go b/pkg/protocol/engine/eviction/state.go index 724ac48d9..4ffb4c96e 100644 --- a/pkg/protocol/engine/eviction/state.go +++ b/pkg/protocol/engine/eviction/state.go @@ -161,9 +161,12 @@ func (s *State) RootBlockCommitmentID(id iotago.BlockID) (commitmentID iotago.Co } // This return empty value for commitmentID in the case the key is not found. - commitmentID = lo.PanicOnErr(storage.Load(id)) + commitmentID, exists, err = storage.Load(id) + if err != nil { + panic(ierrors.Wrapf(err, "failed to load root block %s", id)) + } - return commitmentID, commitmentID != iotago.EmptyCommitmentID + return commitmentID, exists } // Export exports the root blocks to the given writer. diff --git a/pkg/protocol/engine/eviction/testframework_test.go b/pkg/protocol/engine/eviction/testframework_test.go index 00b70e598..33d097036 100644 --- a/pkg/protocol/engine/eviction/testframework_test.go +++ b/pkg/protocol/engine/eviction/testframework_test.go @@ -97,8 +97,9 @@ func (t *TestFramework) RequireStorageRootBlocks(expected ...string) { rootBlockStorage, err := t.prunableStorage.RootBlocks(blockID.Slot()) require.NoError(t.Testing, err) - loadedCommitmentID, err := rootBlockStorage.Load(blockID) + loadedCommitmentID, exists, err := rootBlockStorage.Load(blockID) require.NoError(t.Testing, err) + require.True(t.Testing, exists) require.Equal(t.Testing, commitmentID, loadedCommitmentID) } } diff --git a/pkg/protocol/protocol_fork.go b/pkg/protocol/protocol_fork.go index 1425276cd..458ee4ccc 100644 --- a/pkg/protocol/protocol_fork.go +++ b/pkg/protocol/protocol_fork.go @@ -46,7 +46,7 @@ func (p *Protocol) processAttestationsRequest(commitmentID iotago.CommitmentID, p.HandleError(ierrors.Errorf("failed to get roots storage for commitment %s", commitmentID)) return } - roots, err := rootsStorage.Load(commitmentID) + roots, _, err := rootsStorage.Load(commitmentID) if err != nil { p.HandleError(ierrors.Wrapf(err, "failed to load roots for commitment %s", commitmentID)) return diff --git a/pkg/protocol/sybilprotection/sybilprotectionv1/performance/performance.go b/pkg/protocol/sybilprotection/sybilprotectionv1/performance/performance.go index f5f024a56..86cbe4d8b 100644 --- a/pkg/protocol/sybilprotection/sybilprotectionv1/performance/performance.go +++ b/pkg/protocol/sybilprotection/sybilprotectionv1/performance/performance.go @@ -232,11 +232,16 @@ func (t *Tracker) ApplyEpoch(epoch iotago.EpochIndex, committee *account.Account continue } - validatorPerformance, err := validatorSlotPerformances.Load(accountID) + validatorPerformance, exists, err := validatorSlotPerformances.Load(accountID) if err != nil { panic(ierrors.Wrapf(err, "failed to load performance factor for account %s", accountID)) } + // key not found + if !exists { + validatorPerformance = model.NewValidatorPerformance() + } + validatorPerformances = append(validatorPerformances, validatorPerformance) } pf := t.aggregatePerformanceFactors(validatorPerformances, epoch) @@ -326,7 +331,7 @@ func (t *Tracker) trackCommitteeMemberPerformance(validationBlock *iotago.Valida return } - validatorPerformance, err := validatorPerformances.Load(block.ProtocolBlock().Header.IssuerID) + validatorPerformance, exists, err := validatorPerformances.Load(block.ProtocolBlock().Header.IssuerID) if err != nil { t.errHandler(ierrors.Errorf("failed to load performance factor for account %s", block.ProtocolBlock().Header.IssuerID)) @@ -334,7 +339,7 @@ func (t *Tracker) trackCommitteeMemberPerformance(validationBlock *iotago.Valida } // key not found - if validatorPerformance == nil { + if !exists { validatorPerformance = model.NewValidatorPerformance() } diff --git a/pkg/storage/prunable/slotstore/store.go b/pkg/storage/prunable/slotstore/store.go index d6a571245..97a72e8b9 100644 --- a/pkg/storage/prunable/slotstore/store.go +++ b/pkg/storage/prunable/slotstore/store.go @@ -25,18 +25,18 @@ func NewStore[K, V any]( } } -func (s *Store[K, V]) Load(key K) (V, error) { - value, err := s.kv.Get(key) +func (s *Store[K, V]) Load(key K) (value V, exists bool, err error) { + value, err = s.kv.Get(key) if err != nil { var zeroValue V if ierrors.Is(err, kvstore.ErrKeyNotFound) { - return zeroValue, nil + return zeroValue, false, nil } - return zeroValue, ierrors.Wrapf(err, "failed to get value for key %v", key) + return zeroValue, false, ierrors.Wrapf(err, "failed to get value for key %v", key) } - return value, nil + return value, true, nil } func (s *Store[K, V]) Store(key K, value V) error { diff --git a/pkg/testsuite/mock/node.go b/pkg/testsuite/mock/node.go index b9bde387f..e2a8e2ed2 100644 --- a/pkg/testsuite/mock/node.go +++ b/pkg/testsuite/mock/node.go @@ -334,8 +334,9 @@ func (n *Node) attachEngineLogsWithName(failOnBlockFiltered bool, instance *engi rootsStorage, err := instance.Storage.Roots(details.Commitment.ID().Slot()) require.NoError(n.Testing, err, "roots storage for slot %d not found", details.Commitment.Slot()) - roots, err := rootsStorage.Load(details.Commitment.ID()) + roots, exists, err := rootsStorage.Load(details.Commitment.ID()) require.NoError(n.Testing, err) + require.True(n.Testing, exists) attestationBlockIDs := make([]iotago.BlockID, 0) tree, err := instance.Attestations.GetMap(details.Commitment.Slot()) diff --git a/pkg/testsuite/storage_rootblocks.go b/pkg/testsuite/storage_rootblocks.go index 8cb868bfd..60b721ddf 100644 --- a/pkg/testsuite/storage_rootblocks.go +++ b/pkg/testsuite/storage_rootblocks.go @@ -17,11 +17,15 @@ func (t *TestSuite) AssertStorageRootBlocks(blocks []*blocks.Block, nodes ...*mo return ierrors.Errorf("AssertStorageRootBlocks: %s: error loading root blocks for %s: %v", node.Name, block.ID().Slot(), err) } - loadedCommitmentID, err := storage.Load(block.ID()) + loadedCommitmentID, exists, err := storage.Load(block.ID()) if err != nil { return ierrors.Wrapf(err, "AssertStorageRootBlocks: %s: failed to load root block %s", node.Name, block.ID()) } + if !exists { + return ierrors.Errorf("AssertStorageRootBlocks: %s: root block %s does not exist", node.Name, block.ID()) + } + if block.SlotCommitmentID() != loadedCommitmentID { return ierrors.Errorf("AssertStorageRootBlocks: %s: expected slot commitment %s, got %s for block %s", node.Name, block.SlotCommitmentID(), loadedCommitmentID, block.ID()) } From cc14d947ad6b15321f637b0e4237e5c221a4c16d Mon Sep 17 00:00:00 2001 From: Alexander Sporn Date: Tue, 7 Nov 2023 14:53:43 +0100 Subject: [PATCH 11/14] Calm the doggo --- pkg/protocol/engine/eviction/state.go | 6 +++--- pkg/protocol/engine/tipselection/v1/tip_selection.go | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/pkg/protocol/engine/eviction/state.go b/pkg/protocol/engine/eviction/state.go index 4ffb4c96e..4e7ea8c26 100644 --- a/pkg/protocol/engine/eviction/state.go +++ b/pkg/protocol/engine/eviction/state.go @@ -52,7 +52,7 @@ func (s *State) AdvanceActiveWindowToIndex(slot iotago.SlotIndex) { if delayedIndex, shouldEvictRootBlocks := s.delayedBlockEvictionThreshold(slot); shouldEvictRootBlocks { // Remember the last slot outside our cache window that has root blocks. if storage, err := s.rootBlockStorageFunc(delayedIndex); err != nil { - storage.StreamKeys(func(_ iotago.BlockID) error { + _ = storage.StreamKeys(func(_ iotago.BlockID) error { s.setLatestNonEmptySlot(delayedIndex) return ierrors.New("stop iteration") @@ -94,7 +94,7 @@ func (s *State) ActiveRootBlocks() map[iotago.BlockID]iotago.CommitmentID { continue } - storage.Stream(func(id iotago.BlockID, commitmentID iotago.CommitmentID) error { + _ = storage.Stream(func(id iotago.BlockID, commitmentID iotago.CommitmentID) error { activeRootBlocks[id] = commitmentID return nil @@ -360,7 +360,7 @@ func (s *State) delayedBlockEvictionThreshold(slot iotago.SlotIndex) (thresholdS for ; slot >= s.lastEvictedSlot; slot-- { storage := lo.PanicOnErr(s.rootBlockStorageFunc(slot)) - storage.StreamKeys(func(_ iotago.BlockID) error { + _ = storage.StreamKeys(func(_ iotago.BlockID) error { if slot >= s.optsRootBlocksEvictionDelay { thresholdSlot = slot - s.optsRootBlocksEvictionDelay shouldEvict = true diff --git a/pkg/protocol/engine/tipselection/v1/tip_selection.go b/pkg/protocol/engine/tipselection/v1/tip_selection.go index f745dcc16..a4e180b86 100644 --- a/pkg/protocol/engine/tipselection/v1/tip_selection.go +++ b/pkg/protocol/engine/tipselection/v1/tip_selection.go @@ -129,6 +129,7 @@ func (t *TipSelection) SelectTips(amount int) (references model.ParentReferences } else if i.Slot() < j.Slot() { return 1 } + return -1 }) From 1a0dda0c8ac5114798bdad0716e47c3463f06ef7 Mon Sep 17 00:00:00 2001 From: Alexander Sporn Date: Wed, 8 Nov 2023 08:23:05 +0100 Subject: [PATCH 12/14] Updated iota.go --- go.mod | 4 ++-- go.sum | 4 ++-- tools/gendoc/go.mod | 2 +- tools/gendoc/go.sum | 4 ++-- tools/genesis-snapshot/go.mod | 2 +- tools/genesis-snapshot/go.sum | 4 ++-- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/go.mod b/go.mod index a9dd74376..340028286 100644 --- a/go.mod +++ b/go.mod @@ -25,7 +25,7 @@ require ( github.com/iotaledger/hive.go/stringify v0.0.0-20231108050255-98e0fa35e936 github.com/iotaledger/inx-app v1.0.0-rc.3.0.20231031135002-4c79ea5193f5 github.com/iotaledger/inx/go v1.0.0-rc.2.0.20231031134131-b6ad918dc1ac - github.com/iotaledger/iota.go/v4 v4.0.0-20231108050608-afce96cfe8a6 + github.com/iotaledger/iota.go/v4 v4.0.0-20231108071501-a74440c4ed89 github.com/labstack/echo/v4 v4.11.2 github.com/labstack/gommon v0.4.0 github.com/libp2p/go-libp2p v0.32.0 @@ -42,6 +42,7 @@ require ( go.uber.org/atomic v1.11.0 go.uber.org/dig v1.17.1 golang.org/x/crypto v0.14.0 + golang.org/x/exp v0.0.0-20231006140011-7918f672742d google.golang.org/grpc v1.59.0 google.golang.org/protobuf v1.31.0 ) @@ -168,7 +169,6 @@ require ( go.uber.org/mock v0.3.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.26.0 // indirect - golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect golang.org/x/image v0.13.0 // indirect golang.org/x/mod v0.13.0 // indirect golang.org/x/net v0.17.0 // indirect diff --git a/go.sum b/go.sum index 8ca757948..c11ebf989 100644 --- a/go.sum +++ b/go.sum @@ -307,8 +307,8 @@ github.com/iotaledger/inx-app v1.0.0-rc.3.0.20231031135002-4c79ea5193f5 h1:17JDz github.com/iotaledger/inx-app v1.0.0-rc.3.0.20231031135002-4c79ea5193f5/go.mod h1:LsJvoBUVVnY7tkwwByCVtAwmp5bFXdyJNGU/+KVQJVM= github.com/iotaledger/inx/go v1.0.0-rc.2.0.20231031134131-b6ad918dc1ac h1:c7R33+TQGMYP6pvLUQQaqpdDFl+GZbhAcfGMI0285fo= github.com/iotaledger/inx/go v1.0.0-rc.2.0.20231031134131-b6ad918dc1ac/go.mod h1:qPuMUvCTaghsnYRDnRoRuztTyEKFlmi2S7gb44rH7WM= -github.com/iotaledger/iota.go/v4 v4.0.0-20231108050608-afce96cfe8a6 h1:4kvG+BB4GOBsNYPY/enPo3xeC65A133L9cD73Kf1p9Q= -github.com/iotaledger/iota.go/v4 v4.0.0-20231108050608-afce96cfe8a6/go.mod h1:8iDORW4/e4NztyAGqjW07uSMjbhs7snbxw+81IWOczY= +github.com/iotaledger/iota.go/v4 v4.0.0-20231108071501-a74440c4ed89 h1:gZQw3iZL3ytmvYEfhJ8ip3P+HlUPHUqOeKH9d4Y3A+0= +github.com/iotaledger/iota.go/v4 v4.0.0-20231108071501-a74440c4ed89/go.mod h1:8iDORW4/e4NztyAGqjW07uSMjbhs7snbxw+81IWOczY= github.com/ipfs/boxo v0.13.1 h1:nQ5oQzcMZR3oL41REJDcTbrvDvuZh3J9ckc9+ILeRQI= github.com/ipfs/boxo v0.13.1/go.mod h1:btrtHy0lmO1ODMECbbEY1pxNtrLilvKSYLoGQt1yYCk= github.com/ipfs/go-cid v0.4.1 h1:A/T3qGvxi4kpKWWcPC/PgbvDA2bjVLO7n4UeVwnbs/s= diff --git a/tools/gendoc/go.mod b/tools/gendoc/go.mod index 7e15edb04..cb652fba1 100644 --- a/tools/gendoc/go.mod +++ b/tools/gendoc/go.mod @@ -72,7 +72,7 @@ require ( github.com/iotaledger/hive.go/stringify v0.0.0-20231108050255-98e0fa35e936 // indirect github.com/iotaledger/inx-app v1.0.0-rc.3.0.20231031135002-4c79ea5193f5 // indirect github.com/iotaledger/inx/go v1.0.0-rc.2.0.20231031134131-b6ad918dc1ac // indirect - github.com/iotaledger/iota.go/v4 v4.0.0-20231108050608-afce96cfe8a6 // indirect + github.com/iotaledger/iota.go/v4 v4.0.0-20231108071501-a74440c4ed89 // indirect github.com/ipfs/boxo v0.13.1 // indirect github.com/ipfs/go-cid v0.4.1 // indirect github.com/ipfs/go-datastore v0.6.0 // indirect diff --git a/tools/gendoc/go.sum b/tools/gendoc/go.sum index 17f6c8f9f..72cafa1d1 100644 --- a/tools/gendoc/go.sum +++ b/tools/gendoc/go.sum @@ -311,8 +311,8 @@ github.com/iotaledger/inx-app v1.0.0-rc.3.0.20231031135002-4c79ea5193f5 h1:17JDz github.com/iotaledger/inx-app v1.0.0-rc.3.0.20231031135002-4c79ea5193f5/go.mod h1:LsJvoBUVVnY7tkwwByCVtAwmp5bFXdyJNGU/+KVQJVM= github.com/iotaledger/inx/go v1.0.0-rc.2.0.20231031134131-b6ad918dc1ac h1:c7R33+TQGMYP6pvLUQQaqpdDFl+GZbhAcfGMI0285fo= github.com/iotaledger/inx/go v1.0.0-rc.2.0.20231031134131-b6ad918dc1ac/go.mod h1:qPuMUvCTaghsnYRDnRoRuztTyEKFlmi2S7gb44rH7WM= -github.com/iotaledger/iota.go/v4 v4.0.0-20231108050608-afce96cfe8a6 h1:4kvG+BB4GOBsNYPY/enPo3xeC65A133L9cD73Kf1p9Q= -github.com/iotaledger/iota.go/v4 v4.0.0-20231108050608-afce96cfe8a6/go.mod h1:8iDORW4/e4NztyAGqjW07uSMjbhs7snbxw+81IWOczY= +github.com/iotaledger/iota.go/v4 v4.0.0-20231108071501-a74440c4ed89 h1:gZQw3iZL3ytmvYEfhJ8ip3P+HlUPHUqOeKH9d4Y3A+0= +github.com/iotaledger/iota.go/v4 v4.0.0-20231108071501-a74440c4ed89/go.mod h1:8iDORW4/e4NztyAGqjW07uSMjbhs7snbxw+81IWOczY= github.com/ipfs/boxo v0.13.1 h1:nQ5oQzcMZR3oL41REJDcTbrvDvuZh3J9ckc9+ILeRQI= github.com/ipfs/boxo v0.13.1/go.mod h1:btrtHy0lmO1ODMECbbEY1pxNtrLilvKSYLoGQt1yYCk= github.com/ipfs/go-cid v0.4.1 h1:A/T3qGvxi4kpKWWcPC/PgbvDA2bjVLO7n4UeVwnbs/s= diff --git a/tools/genesis-snapshot/go.mod b/tools/genesis-snapshot/go.mod index edbf18aae..c30dd661a 100644 --- a/tools/genesis-snapshot/go.mod +++ b/tools/genesis-snapshot/go.mod @@ -10,7 +10,7 @@ require ( github.com/iotaledger/hive.go/lo v0.0.0-20231108050255-98e0fa35e936 github.com/iotaledger/hive.go/runtime v0.0.0-20231108050255-98e0fa35e936 github.com/iotaledger/iota-core v0.0.0-00010101000000-000000000000 - github.com/iotaledger/iota.go/v4 v4.0.0-20231108050608-afce96cfe8a6 + github.com/iotaledger/iota.go/v4 v4.0.0-20231108071501-a74440c4ed89 github.com/mr-tron/base58 v1.2.0 github.com/spf13/pflag v1.0.5 golang.org/x/crypto v0.14.0 diff --git a/tools/genesis-snapshot/go.sum b/tools/genesis-snapshot/go.sum index 0a0bf91ab..10ba38fff 100644 --- a/tools/genesis-snapshot/go.sum +++ b/tools/genesis-snapshot/go.sum @@ -52,8 +52,8 @@ github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20231108050255-98e0fa3 github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20231108050255-98e0fa35e936/go.mod h1:FoH3T6yKlZJp8xm8K+zsQiibSynp32v21CpWx8xkek8= github.com/iotaledger/hive.go/stringify v0.0.0-20231108050255-98e0fa35e936 h1:Y4HgL5gm9S27usg5M2t6wi1BSdCxVorM62lwnpKuMd4= github.com/iotaledger/hive.go/stringify v0.0.0-20231108050255-98e0fa35e936/go.mod h1:FTo/UWzNYgnQ082GI9QVM9HFDERqf9rw9RivNpqrnTs= -github.com/iotaledger/iota.go/v4 v4.0.0-20231108050608-afce96cfe8a6 h1:4kvG+BB4GOBsNYPY/enPo3xeC65A133L9cD73Kf1p9Q= -github.com/iotaledger/iota.go/v4 v4.0.0-20231108050608-afce96cfe8a6/go.mod h1:8iDORW4/e4NztyAGqjW07uSMjbhs7snbxw+81IWOczY= +github.com/iotaledger/iota.go/v4 v4.0.0-20231108071501-a74440c4ed89 h1:gZQw3iZL3ytmvYEfhJ8ip3P+HlUPHUqOeKH9d4Y3A+0= +github.com/iotaledger/iota.go/v4 v4.0.0-20231108071501-a74440c4ed89/go.mod h1:8iDORW4/e4NztyAGqjW07uSMjbhs7snbxw+81IWOczY= github.com/ipfs/go-cid v0.4.1 h1:A/T3qGvxi4kpKWWcPC/PgbvDA2bjVLO7n4UeVwnbs/s= github.com/ipfs/go-cid v0.4.1/go.mod h1:uQHwDeX4c6CtyrFwdqyhpNcxVewur1M7l7fNU7LKwZk= github.com/klauspost/cpuid/v2 v2.2.5 h1:0E5MSMDEoAulmXNFquVs//DdoomxaoTY1kUhbc/qbZg= From 9c86e82c8235fb68c81e4008238b25097a44d741 Mon Sep 17 00:00:00 2001 From: Alexander Sporn Date: Wed, 8 Nov 2023 12:03:36 +0100 Subject: [PATCH 13/14] Updated iota.go --- go.mod | 6 +++--- go.sum | 12 ++++++------ tools/gendoc/go.mod | 6 +++--- tools/gendoc/go.sum | 12 ++++++------ tools/genesis-snapshot/go.mod | 2 +- tools/genesis-snapshot/go.sum | 4 ++-- 6 files changed, 21 insertions(+), 21 deletions(-) diff --git a/go.mod b/go.mod index 340028286..821a76207 100644 --- a/go.mod +++ b/go.mod @@ -23,9 +23,9 @@ require ( github.com/iotaledger/hive.go/runtime v0.0.0-20231108050255-98e0fa35e936 github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20231108050255-98e0fa35e936 github.com/iotaledger/hive.go/stringify v0.0.0-20231108050255-98e0fa35e936 - github.com/iotaledger/inx-app v1.0.0-rc.3.0.20231031135002-4c79ea5193f5 - github.com/iotaledger/inx/go v1.0.0-rc.2.0.20231031134131-b6ad918dc1ac - github.com/iotaledger/iota.go/v4 v4.0.0-20231108071501-a74440c4ed89 + github.com/iotaledger/inx-app v1.0.0-rc.3.0.20231108104504-1445f545de82 + github.com/iotaledger/inx/go v1.0.0-rc.2.0.20231108104322-f301c3573998 + github.com/iotaledger/iota.go/v4 v4.0.0-20231108103955-bf75d703d8aa github.com/labstack/echo/v4 v4.11.2 github.com/labstack/gommon v0.4.0 github.com/libp2p/go-libp2p v0.32.0 diff --git a/go.sum b/go.sum index c11ebf989..a5a51a465 100644 --- a/go.sum +++ b/go.sum @@ -303,12 +303,12 @@ github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20231108050255-98e0fa3 github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20231108050255-98e0fa35e936/go.mod h1:FoH3T6yKlZJp8xm8K+zsQiibSynp32v21CpWx8xkek8= github.com/iotaledger/hive.go/stringify v0.0.0-20231108050255-98e0fa35e936 h1:Y4HgL5gm9S27usg5M2t6wi1BSdCxVorM62lwnpKuMd4= github.com/iotaledger/hive.go/stringify v0.0.0-20231108050255-98e0fa35e936/go.mod h1:FTo/UWzNYgnQ082GI9QVM9HFDERqf9rw9RivNpqrnTs= -github.com/iotaledger/inx-app v1.0.0-rc.3.0.20231031135002-4c79ea5193f5 h1:17JDzMKTMXKF3xys6gPURRddkZhg1LY+xwfhbr/sVqg= -github.com/iotaledger/inx-app v1.0.0-rc.3.0.20231031135002-4c79ea5193f5/go.mod h1:LsJvoBUVVnY7tkwwByCVtAwmp5bFXdyJNGU/+KVQJVM= -github.com/iotaledger/inx/go v1.0.0-rc.2.0.20231031134131-b6ad918dc1ac h1:c7R33+TQGMYP6pvLUQQaqpdDFl+GZbhAcfGMI0285fo= -github.com/iotaledger/inx/go v1.0.0-rc.2.0.20231031134131-b6ad918dc1ac/go.mod h1:qPuMUvCTaghsnYRDnRoRuztTyEKFlmi2S7gb44rH7WM= -github.com/iotaledger/iota.go/v4 v4.0.0-20231108071501-a74440c4ed89 h1:gZQw3iZL3ytmvYEfhJ8ip3P+HlUPHUqOeKH9d4Y3A+0= -github.com/iotaledger/iota.go/v4 v4.0.0-20231108071501-a74440c4ed89/go.mod h1:8iDORW4/e4NztyAGqjW07uSMjbhs7snbxw+81IWOczY= +github.com/iotaledger/inx-app v1.0.0-rc.3.0.20231108104504-1445f545de82 h1:FdM1lxUKgENO3oOlF5blVqmjER44mLIHGpavyUOY5JI= +github.com/iotaledger/inx-app v1.0.0-rc.3.0.20231108104504-1445f545de82/go.mod h1:HVxkGPraMDTRudfG9AFN7Ga9gijp6skXB9TKNBc4KgI= +github.com/iotaledger/inx/go v1.0.0-rc.2.0.20231108104322-f301c3573998 h1:KkC0SaWrjSMg897r2DDosJYALFfLadFST3Fvoaxg7hw= +github.com/iotaledger/inx/go v1.0.0-rc.2.0.20231108104322-f301c3573998/go.mod h1:c+lBG3vgt2rgXHeOncK8hMllMwihTAtVbu790NslW2w= +github.com/iotaledger/iota.go/v4 v4.0.0-20231108103955-bf75d703d8aa h1:A2nadmSbmn62f6wtrqvv/TCCF2sDiiwyDnl6brbRo1E= +github.com/iotaledger/iota.go/v4 v4.0.0-20231108103955-bf75d703d8aa/go.mod h1:8iDORW4/e4NztyAGqjW07uSMjbhs7snbxw+81IWOczY= github.com/ipfs/boxo v0.13.1 h1:nQ5oQzcMZR3oL41REJDcTbrvDvuZh3J9ckc9+ILeRQI= github.com/ipfs/boxo v0.13.1/go.mod h1:btrtHy0lmO1ODMECbbEY1pxNtrLilvKSYLoGQt1yYCk= github.com/ipfs/go-cid v0.4.1 h1:A/T3qGvxi4kpKWWcPC/PgbvDA2bjVLO7n4UeVwnbs/s= diff --git a/tools/gendoc/go.mod b/tools/gendoc/go.mod index cb652fba1..97dd12ea0 100644 --- a/tools/gendoc/go.mod +++ b/tools/gendoc/go.mod @@ -70,9 +70,9 @@ require ( github.com/iotaledger/hive.go/runtime v0.0.0-20231108050255-98e0fa35e936 // indirect github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20231108050255-98e0fa35e936 // indirect github.com/iotaledger/hive.go/stringify v0.0.0-20231108050255-98e0fa35e936 // indirect - github.com/iotaledger/inx-app v1.0.0-rc.3.0.20231031135002-4c79ea5193f5 // indirect - github.com/iotaledger/inx/go v1.0.0-rc.2.0.20231031134131-b6ad918dc1ac // indirect - github.com/iotaledger/iota.go/v4 v4.0.0-20231108071501-a74440c4ed89 // indirect + github.com/iotaledger/inx-app v1.0.0-rc.3.0.20231108104504-1445f545de82 // indirect + github.com/iotaledger/inx/go v1.0.0-rc.2.0.20231108104322-f301c3573998 // indirect + github.com/iotaledger/iota.go/v4 v4.0.0-20231108103955-bf75d703d8aa // indirect github.com/ipfs/boxo v0.13.1 // indirect github.com/ipfs/go-cid v0.4.1 // indirect github.com/ipfs/go-datastore v0.6.0 // indirect diff --git a/tools/gendoc/go.sum b/tools/gendoc/go.sum index 72cafa1d1..0eec52286 100644 --- a/tools/gendoc/go.sum +++ b/tools/gendoc/go.sum @@ -307,12 +307,12 @@ github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20231108050255-98e0fa3 github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20231108050255-98e0fa35e936/go.mod h1:FoH3T6yKlZJp8xm8K+zsQiibSynp32v21CpWx8xkek8= github.com/iotaledger/hive.go/stringify v0.0.0-20231108050255-98e0fa35e936 h1:Y4HgL5gm9S27usg5M2t6wi1BSdCxVorM62lwnpKuMd4= github.com/iotaledger/hive.go/stringify v0.0.0-20231108050255-98e0fa35e936/go.mod h1:FTo/UWzNYgnQ082GI9QVM9HFDERqf9rw9RivNpqrnTs= -github.com/iotaledger/inx-app v1.0.0-rc.3.0.20231031135002-4c79ea5193f5 h1:17JDzMKTMXKF3xys6gPURRddkZhg1LY+xwfhbr/sVqg= -github.com/iotaledger/inx-app v1.0.0-rc.3.0.20231031135002-4c79ea5193f5/go.mod h1:LsJvoBUVVnY7tkwwByCVtAwmp5bFXdyJNGU/+KVQJVM= -github.com/iotaledger/inx/go v1.0.0-rc.2.0.20231031134131-b6ad918dc1ac h1:c7R33+TQGMYP6pvLUQQaqpdDFl+GZbhAcfGMI0285fo= -github.com/iotaledger/inx/go v1.0.0-rc.2.0.20231031134131-b6ad918dc1ac/go.mod h1:qPuMUvCTaghsnYRDnRoRuztTyEKFlmi2S7gb44rH7WM= -github.com/iotaledger/iota.go/v4 v4.0.0-20231108071501-a74440c4ed89 h1:gZQw3iZL3ytmvYEfhJ8ip3P+HlUPHUqOeKH9d4Y3A+0= -github.com/iotaledger/iota.go/v4 v4.0.0-20231108071501-a74440c4ed89/go.mod h1:8iDORW4/e4NztyAGqjW07uSMjbhs7snbxw+81IWOczY= +github.com/iotaledger/inx-app v1.0.0-rc.3.0.20231108104504-1445f545de82 h1:FdM1lxUKgENO3oOlF5blVqmjER44mLIHGpavyUOY5JI= +github.com/iotaledger/inx-app v1.0.0-rc.3.0.20231108104504-1445f545de82/go.mod h1:HVxkGPraMDTRudfG9AFN7Ga9gijp6skXB9TKNBc4KgI= +github.com/iotaledger/inx/go v1.0.0-rc.2.0.20231108104322-f301c3573998 h1:KkC0SaWrjSMg897r2DDosJYALFfLadFST3Fvoaxg7hw= +github.com/iotaledger/inx/go v1.0.0-rc.2.0.20231108104322-f301c3573998/go.mod h1:c+lBG3vgt2rgXHeOncK8hMllMwihTAtVbu790NslW2w= +github.com/iotaledger/iota.go/v4 v4.0.0-20231108103955-bf75d703d8aa h1:A2nadmSbmn62f6wtrqvv/TCCF2sDiiwyDnl6brbRo1E= +github.com/iotaledger/iota.go/v4 v4.0.0-20231108103955-bf75d703d8aa/go.mod h1:8iDORW4/e4NztyAGqjW07uSMjbhs7snbxw+81IWOczY= github.com/ipfs/boxo v0.13.1 h1:nQ5oQzcMZR3oL41REJDcTbrvDvuZh3J9ckc9+ILeRQI= github.com/ipfs/boxo v0.13.1/go.mod h1:btrtHy0lmO1ODMECbbEY1pxNtrLilvKSYLoGQt1yYCk= github.com/ipfs/go-cid v0.4.1 h1:A/T3qGvxi4kpKWWcPC/PgbvDA2bjVLO7n4UeVwnbs/s= diff --git a/tools/genesis-snapshot/go.mod b/tools/genesis-snapshot/go.mod index c30dd661a..dbc3a759d 100644 --- a/tools/genesis-snapshot/go.mod +++ b/tools/genesis-snapshot/go.mod @@ -10,7 +10,7 @@ require ( github.com/iotaledger/hive.go/lo v0.0.0-20231108050255-98e0fa35e936 github.com/iotaledger/hive.go/runtime v0.0.0-20231108050255-98e0fa35e936 github.com/iotaledger/iota-core v0.0.0-00010101000000-000000000000 - github.com/iotaledger/iota.go/v4 v4.0.0-20231108071501-a74440c4ed89 + github.com/iotaledger/iota.go/v4 v4.0.0-20231108103955-bf75d703d8aa github.com/mr-tron/base58 v1.2.0 github.com/spf13/pflag v1.0.5 golang.org/x/crypto v0.14.0 diff --git a/tools/genesis-snapshot/go.sum b/tools/genesis-snapshot/go.sum index 10ba38fff..8f8630e48 100644 --- a/tools/genesis-snapshot/go.sum +++ b/tools/genesis-snapshot/go.sum @@ -52,8 +52,8 @@ github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20231108050255-98e0fa3 github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20231108050255-98e0fa35e936/go.mod h1:FoH3T6yKlZJp8xm8K+zsQiibSynp32v21CpWx8xkek8= github.com/iotaledger/hive.go/stringify v0.0.0-20231108050255-98e0fa35e936 h1:Y4HgL5gm9S27usg5M2t6wi1BSdCxVorM62lwnpKuMd4= github.com/iotaledger/hive.go/stringify v0.0.0-20231108050255-98e0fa35e936/go.mod h1:FTo/UWzNYgnQ082GI9QVM9HFDERqf9rw9RivNpqrnTs= -github.com/iotaledger/iota.go/v4 v4.0.0-20231108071501-a74440c4ed89 h1:gZQw3iZL3ytmvYEfhJ8ip3P+HlUPHUqOeKH9d4Y3A+0= -github.com/iotaledger/iota.go/v4 v4.0.0-20231108071501-a74440c4ed89/go.mod h1:8iDORW4/e4NztyAGqjW07uSMjbhs7snbxw+81IWOczY= +github.com/iotaledger/iota.go/v4 v4.0.0-20231108103955-bf75d703d8aa h1:A2nadmSbmn62f6wtrqvv/TCCF2sDiiwyDnl6brbRo1E= +github.com/iotaledger/iota.go/v4 v4.0.0-20231108103955-bf75d703d8aa/go.mod h1:8iDORW4/e4NztyAGqjW07uSMjbhs7snbxw+81IWOczY= github.com/ipfs/go-cid v0.4.1 h1:A/T3qGvxi4kpKWWcPC/PgbvDA2bjVLO7n4UeVwnbs/s= github.com/ipfs/go-cid v0.4.1/go.mod h1:uQHwDeX4c6CtyrFwdqyhpNcxVewur1M7l7fNU7LKwZk= github.com/klauspost/cpuid/v2 v2.2.5 h1:0E5MSMDEoAulmXNFquVs//DdoomxaoTY1kUhbc/qbZg= From b0272549e7f6395527565c0ad62f15d752ab57f4 Mon Sep 17 00:00:00 2001 From: Alexander Sporn Date: Wed, 8 Nov 2023 12:34:34 +0100 Subject: [PATCH 14/14] Use genesis slot 0 for the docker network --- tools/genesis-snapshot/presets/presets.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/genesis-snapshot/presets/presets.go b/tools/genesis-snapshot/presets/presets.go index 5f059249a..5c81cdaa7 100644 --- a/tools/genesis-snapshot/presets/presets.go +++ b/tools/genesis-snapshot/presets/presets.go @@ -133,7 +133,7 @@ var Docker = []options.Option[snapshotcreator.Options]{ iotago.NewV3ProtocolParameters( iotago.WithNetworkOptions("docker", "rms"), iotago.WithSupplyOptions(4_600_000_000_000_000, 1, 1, 10, 100, 100, 100), - iotago.WithTimeProviderOptions(123456789, time.Now().Unix(), 10, 13), + iotago.WithTimeProviderOptions(0, time.Now().Unix(), 10, 13), iotago.WithLivenessOptions(30, 30, 7, 14, 30), // increase/decrease threshold = fraction * slotDurationInSeconds * schedulerRate iotago.WithCongestionControlOptions(500, 500, 500, 800000, 500000, 100000, 1000, 100),