diff --git a/components/restapi/core/component.go b/components/restapi/core/component.go index 28d77494c..0c9aa06ed 100644 --- a/components/restapi/core/component.go +++ b/components/restapi/core/component.go @@ -48,6 +48,14 @@ func configure() error { return responseByHeader(c, resp) }) + routeGroup.GET(api.CoreEndpointNetworkHealth, func(c echo.Context) error { + if deps.RequestHandler.IsNetworkHealthy() { + return c.NoContent(http.StatusOK) + } + + return c.NoContent(http.StatusServiceUnavailable) + }) + routeGroup.GET(api.CoreEndpointNetworkMetrics, func(c echo.Context) error { resp := metrics() diff --git a/deploy/ansible/roles/metrics/files/grafana/provisioning/dashboards/node-exporter.json b/deploy/ansible/roles/metrics/files/grafana/provisioning/dashboards/node-exporter.json index 8b2bd8681..cff990c84 100644 --- a/deploy/ansible/roles/metrics/files/grafana/provisioning/dashboards/node-exporter.json +++ b/deploy/ansible/roles/metrics/files/grafana/provisioning/dashboards/node-exporter.json @@ -5289,7 +5289,7 @@ "step": 240 } ], - "title": "Memory Commited", + "title": "Memory Committed", "type": "timeseries" }, { @@ -10381,7 +10381,7 @@ "expr": "node_memory_NFS_Unstable_bytes{instance=\"$node\",job=\"$job\"}", "format": "time_series", "intervalFactor": 1, - "legendFormat": "NFS Unstable - Memory in NFS pages sent to the server, but not yet commited to the storage", + "legendFormat": "NFS Unstable - Memory in NFS pages sent to the server, but not yet committed to the storage", "refId": "A", "step": 240 } diff --git a/go.mod b/go.mod index 033381fd8..612bf772e 100644 --- a/go.mod +++ b/go.mod @@ -29,7 +29,7 @@ require ( github.com/iotaledger/hive.go/stringify v0.0.0-20240315104458-b689cbcfddbd github.com/iotaledger/inx-app v1.0.0-rc.3.0.20240307101848-db58eb9353ec github.com/iotaledger/inx/go v1.0.0-rc.2.0.20240307100839-48553e1d2022 - github.com/iotaledger/iota.go/v4 v4.0.0-20240313065735-74f8cf10c361 + github.com/iotaledger/iota.go/v4 v4.0.0-20240319114032-b6fcc3585c99 github.com/labstack/echo/v4 v4.11.4 github.com/labstack/gommon v0.4.2 github.com/libp2p/go-libp2p v0.33.0 diff --git a/go.sum b/go.sum index 1f9f831f2..386e32103 100644 --- a/go.sum +++ b/go.sum @@ -325,8 +325,8 @@ github.com/iotaledger/inx/go v1.0.0-rc.2.0.20240307100839-48553e1d2022 h1:I178Sa github.com/iotaledger/inx/go v1.0.0-rc.2.0.20240307100839-48553e1d2022/go.mod h1:jTFxIWiMUdAwO263jlJCSWcNLqEkgYEVOFXfjp5aNJM= github.com/iotaledger/iota-crypto-demo v0.0.0-20240216103559-27ca8dffd1e7 h1:t6k4MqiUov0FrBb2o2JhKlOVSdlPbIQWM8ivYHL0G0g= github.com/iotaledger/iota-crypto-demo v0.0.0-20240216103559-27ca8dffd1e7/go.mod h1:do+N3LpeDEi9qselEC4XcjqGoRc7cWGiqBtIeBOKEMs= -github.com/iotaledger/iota.go/v4 v4.0.0-20240313065735-74f8cf10c361 h1:fKvfJZ4byivRRKkqF6JPj8I4pDSN0y+bgF4I4HI11Lo= -github.com/iotaledger/iota.go/v4 v4.0.0-20240313065735-74f8cf10c361/go.mod h1:8UQOTI7CC5R/3TurawUFuBZbkb37RzW8m4q8Hp7ct30= +github.com/iotaledger/iota.go/v4 v4.0.0-20240319114032-b6fcc3585c99 h1:Fs4LqQ8VavnOkv4fRkEex8hVvnnqt1uVSY6R9hocPSU= +github.com/iotaledger/iota.go/v4 v4.0.0-20240319114032-b6fcc3585c99/go.mod h1:8UQOTI7CC5R/3TurawUFuBZbkb37RzW8m4q8Hp7ct30= github.com/ipfs/boxo v0.18.0 h1:MOL9/AgoV3e7jlVMInicaSdbgralfqSsbkc31dZ9tmw= github.com/ipfs/boxo v0.18.0/go.mod h1:pIZgTWdm3k3pLF9Uq6MB8JEcW07UDwNJjlXW1HELW80= github.com/ipfs/go-cid v0.4.1 h1:A/T3qGvxi4kpKWWcPC/PgbvDA2bjVLO7n4UeVwnbs/s= diff --git a/pkg/protocol/engine/syncmanager/syncmanager.go b/pkg/protocol/engine/syncmanager/syncmanager.go index 46143bbd2..5996d0ca3 100644 --- a/pkg/protocol/engine/syncmanager/syncmanager.go +++ b/pkg/protocol/engine/syncmanager/syncmanager.go @@ -16,6 +16,10 @@ type SyncManager interface { // IsNodeSynced returns bool indicating if a node is synced. IsNodeSynced() bool + // IsFinalizationDelayed returns bool indicating if the finalization is delayed + // (latest committed slot - latest finalized slot > max committable age). + IsFinalizationDelayed() bool + // LastAcceptedBlockSlot returns the slot of the latest accepted block. LastAcceptedBlockSlot() iotago.SlotIndex @@ -40,6 +44,7 @@ type SyncManager interface { type SyncStatus struct { NodeBootstrapped bool NodeSynced bool + FinalizationDelayed bool LastAcceptedBlockSlot iotago.SlotIndex LastConfirmedBlockSlot iotago.SlotIndex LatestCommitment *model.Commitment diff --git a/pkg/protocol/engine/syncmanager/trivialsyncmanager/syncmanager.go b/pkg/protocol/engine/syncmanager/trivialsyncmanager/syncmanager.go index 0da58dc75..fa862d499 100644 --- a/pkg/protocol/engine/syncmanager/trivialsyncmanager/syncmanager.go +++ b/pkg/protocol/engine/syncmanager/trivialsyncmanager/syncmanager.go @@ -19,35 +19,58 @@ type ( isBootstrappedFunc func(e *engine.Engine) bool ) +func WithSyncThreshold(threshold time.Duration) options.Option[SyncManager] { + return func(s *SyncManager) { + s.optsSyncThreshold = threshold + } +} + +func WithIsBootstrappedFunc(isBootstrapped isBootstrappedFunc) options.Option[SyncManager] { + return func(s *SyncManager) { + s.optsIsBootstrappedFunc = isBootstrapped + } +} + +func WithBootstrappedThreshold(threshold time.Duration) options.Option[SyncManager] { + return func(s *SyncManager) { + s.optsBootstrappedThreshold = threshold + } +} + type SyncManager struct { - events *syncmanager.Events - engine *engine.Engine - syncThreshold time.Duration + events *syncmanager.Events + engine *engine.Engine + + // options + optsSyncThreshold time.Duration + optsIsBootstrappedFunc isBootstrappedFunc + optsBootstrappedThreshold time.Duration + + // state + isBootstrappedLock syncutils.RWMutex + isBootstrapped bool + + isSyncedLock syncutils.RWMutex + isSynced bool + + isFinalizationDelayedLock syncutils.RWMutex + isFinalizationDelayed bool - lastAcceptedBlockSlot iotago.SlotIndex lastAcceptedBlockSlotLock syncutils.RWMutex + lastAcceptedBlockSlot iotago.SlotIndex - lastConfirmedBlockSlot iotago.SlotIndex lastConfirmedBlockSlotLock syncutils.RWMutex + lastConfirmedBlockSlot iotago.SlotIndex - latestCommitment *model.Commitment latestCommitmentLock syncutils.RWMutex + latestCommitment *model.Commitment - latestFinalizedSlot iotago.SlotIndex latestFinalizedSlotLock syncutils.RWMutex + latestFinalizedSlot iotago.SlotIndex + lastPrunedEpochLock syncutils.RWMutex lastPrunedEpoch iotago.EpochIndex hasPruned bool - lastPrunedEpochLock syncutils.RWMutex - - isSynced bool - isSyncedLock syncutils.RWMutex - - isBootstrapped bool - isBootstrappedLock syncutils.RWMutex - - optsIsBootstrappedFunc isBootstrappedFunc - optsBootstrappedThreshold time.Duration module.Module } @@ -71,14 +94,15 @@ func NewProvider(opts ...options.Option[SyncManager]) module.Provider[*engine.En }, asyncOpt) e.Events.Notarization.LatestCommitmentUpdated.Hook(func(commitment *model.Commitment) { + var bootstrapChanged bool if !s.IsBootstrapped() { - s.updateBootstrappedStatus() + bootstrapChanged = s.updateBootstrappedStatus() } syncChanged := s.updateSyncStatus() commitmentChanged := s.updateLatestCommitment(commitment) - if syncChanged || commitmentChanged { + if bootstrapChanged || syncChanged || commitmentChanged { s.triggerUpdate() } }, asyncOpt) @@ -103,16 +127,23 @@ func NewProvider(opts ...options.Option[SyncManager]) module.Provider[*engine.En func New(subModule module.Module, e *engine.Engine, latestCommitment *model.Commitment, finalizedSlot iotago.SlotIndex, opts ...options.Option[SyncManager]) *SyncManager { return module.InitSimpleLifecycle(options.Apply(&SyncManager{ - Module: subModule, - events: syncmanager.NewEvents(), - engine: e, - syncThreshold: 10 * time.Second, + Module: subModule, + events: syncmanager.NewEvents(), + engine: e, + + optsSyncThreshold: 10 * time.Second, + optsIsBootstrappedFunc: nil, + optsBootstrappedThreshold: 10 * time.Second, + + isBootstrapped: false, + isSynced: false, + isFinalizationDelayed: true, lastAcceptedBlockSlot: latestCommitment.Slot(), lastConfirmedBlockSlot: latestCommitment.Slot(), latestCommitment: latestCommitment, latestFinalizedSlot: finalizedSlot, - - optsBootstrappedThreshold: 10 * time.Second, + lastPrunedEpoch: 0, + hasPruned: false, }, opts, func(s *SyncManager) { s.updatePrunedEpoch(s.engine.Storage.LastPrunedEpoch()) @@ -126,20 +157,31 @@ func New(subModule module.Module, e *engine.Engine, latestCommitment *model.Comm } func (s *SyncManager) SyncStatus() *syncmanager.SyncStatus { + // get all the locks so we have an atomic view of the state + s.isBootstrappedLock.RLock() + s.isSyncedLock.RLock() + s.isFinalizationDelayedLock.RLock() s.lastAcceptedBlockSlotLock.RLock() s.lastConfirmedBlockSlotLock.RLock() s.latestCommitmentLock.RLock() s.latestFinalizedSlotLock.RLock() s.lastPrunedEpochLock.RLock() - defer s.lastAcceptedBlockSlotLock.RUnlock() - defer s.lastConfirmedBlockSlotLock.RUnlock() - defer s.latestCommitmentLock.RUnlock() - defer s.latestFinalizedSlotLock.RUnlock() - defer s.lastPrunedEpochLock.RUnlock() + + defer func() { + s.isBootstrappedLock.RUnlock() + s.isSyncedLock.RUnlock() + s.isFinalizationDelayedLock.RUnlock() + s.lastAcceptedBlockSlotLock.RUnlock() + s.lastConfirmedBlockSlotLock.RUnlock() + s.latestCommitmentLock.RUnlock() + s.latestFinalizedSlotLock.RUnlock() + s.lastPrunedEpochLock.RUnlock() + }() return &syncmanager.SyncStatus{ - NodeSynced: s.IsNodeSynced(), - NodeBootstrapped: s.IsBootstrapped(), + NodeBootstrapped: s.isBootstrapped, + NodeSynced: s.isSynced, + FinalizationDelayed: s.isFinalizationDelayed, LastAcceptedBlockSlot: s.lastAcceptedBlockSlot, LastConfirmedBlockSlot: s.lastConfirmedBlockSlot, LatestCommitment: s.latestCommitment, @@ -151,98 +193,85 @@ func (s *SyncManager) SyncStatus() *syncmanager.SyncStatus { // Reset resets the component to a clean state as if it was created at the last commitment. func (s *SyncManager) Reset() { + s.isSyncedLock.Lock() + s.isFinalizationDelayedLock.Lock() s.lastAcceptedBlockSlotLock.Lock() s.lastConfirmedBlockSlotLock.Lock() s.latestCommitmentLock.RLock() - s.isSyncedLock.Lock() - defer s.lastAcceptedBlockSlotLock.Unlock() - defer s.lastConfirmedBlockSlotLock.Unlock() - defer s.latestCommitmentLock.RUnlock() - defer s.isSyncedLock.Unlock() - s.lastAcceptedBlockSlot = s.latestCommitment.Slot() - s.lastConfirmedBlockSlot = s.latestCommitment.Slot() + defer func() { + s.isSyncedLock.Unlock() + s.isFinalizationDelayedLock.Unlock() + s.lastAcceptedBlockSlotLock.Unlock() + s.lastConfirmedBlockSlotLock.Unlock() + s.latestCommitmentLock.RUnlock() + }() + // Mark the synced flag as false, // because we clear the latest accepted blocks and return the whole state to the last committed slot. s.isSynced = false + s.isFinalizationDelayed = true + s.lastAcceptedBlockSlot = s.latestCommitment.Slot() + s.lastConfirmedBlockSlot = s.latestCommitment.Slot() } -func (s *SyncManager) updateLastAcceptedBlock(id iotago.BlockID) (changed bool) { - s.lastAcceptedBlockSlotLock.Lock() - defer s.lastAcceptedBlockSlotLock.Unlock() - - if id.Slot() > s.lastAcceptedBlockSlot { - s.lastAcceptedBlockSlot = id.Slot() - return true - } - - return false +func (s *SyncManager) triggerUpdate() { + s.events.UpdatedStatus.Trigger(s.SyncStatus()) } -func (s *SyncManager) updateLastConfirmedBlock(id iotago.BlockID) (changed bool) { - s.lastConfirmedBlockSlotLock.Lock() - defer s.lastConfirmedBlockSlotLock.Unlock() - - if id.Slot() > s.lastConfirmedBlockSlot { - s.lastConfirmedBlockSlot = id.Slot() - return true - } - - return false -} +func (s *SyncManager) updateBootstrappedStatus() (changed bool) { + s.isBootstrappedLock.Lock() + defer s.isBootstrappedLock.Unlock() -func (s *SyncManager) updateLatestCommitment(commitment *model.Commitment) (changed bool) { - s.latestCommitmentLock.Lock() - defer s.latestCommitmentLock.Unlock() + if !s.isBootstrapped && s.optsIsBootstrappedFunc(s.engine) { + s.isBootstrapped = true - if s.latestCommitment != commitment { - s.latestCommitment = commitment return true } return false } -func (s *SyncManager) updateBootstrappedStatus() { - s.isBootstrappedLock.Lock() - defer s.isBootstrappedLock.Unlock() +func (s *SyncManager) IsBootstrapped() bool { + s.isBootstrappedLock.RLock() + defer s.isBootstrappedLock.RUnlock() - if !s.isBootstrapped && s.optsIsBootstrappedFunc(s.engine) { - s.isBootstrapped = true - } + return s.isBootstrapped } func (s *SyncManager) updateSyncStatus() (changed bool) { s.isSyncedLock.Lock() defer s.isSyncedLock.Unlock() - if s.isSynced != (s.isBootstrapped && time.Since(s.engine.Clock.Accepted().RelativeTime()) < s.syncThreshold) { - s.isSynced = !s.isSynced + isSynced := s.isBootstrapped && time.Since(s.engine.Clock.Accepted().RelativeTime()) < s.optsSyncThreshold + if s.isSynced != isSynced { + s.isSynced = isSynced + return true } return false } -func (s *SyncManager) updateFinalizedSlot(index iotago.SlotIndex) (changed bool) { - s.latestFinalizedSlotLock.Lock() - defer s.latestFinalizedSlotLock.Unlock() - - if s.latestFinalizedSlot != index { - s.latestFinalizedSlot = index - return true - } +func (s *SyncManager) IsNodeSynced() bool { + s.isSyncedLock.RLock() + defer s.isSyncedLock.RUnlock() - return false + return s.isSynced } -func (s *SyncManager) updatePrunedEpoch(index iotago.EpochIndex, hasPruned bool) (changed bool) { - s.lastPrunedEpochLock.Lock() - defer s.lastPrunedEpochLock.Unlock() +func (s *SyncManager) updateIsFinalizationDelayed(latestFinalizedSlot iotago.SlotIndex, latestCommitmentSlot iotago.SlotIndex) (changed bool) { + s.isFinalizationDelayedLock.Lock() + defer s.isFinalizationDelayedLock.Unlock() - if s.lastPrunedEpoch != index { - s.lastPrunedEpoch = index - s.hasPruned = hasPruned + if latestCommitmentSlot < latestFinalizedSlot { + // This should never happen, but if it does, we don't want to panic. + return false + } + + isFinalizationDelayed := latestCommitmentSlot-latestFinalizedSlot > s.engine.CommittedAPI().ProtocolParameters().MaxCommittableAge() + if s.isFinalizationDelayed != isFinalizationDelayed { + s.isFinalizationDelayed = isFinalizationDelayed return true } @@ -250,18 +279,24 @@ func (s *SyncManager) updatePrunedEpoch(index iotago.EpochIndex, hasPruned bool) return false } -func (s *SyncManager) IsBootstrapped() bool { - s.isBootstrappedLock.RLock() - defer s.isBootstrappedLock.RUnlock() +func (s *SyncManager) IsFinalizationDelayed() bool { + s.isFinalizationDelayedLock.RLock() + defer s.isFinalizationDelayedLock.RUnlock() - return s.isBootstrapped + return s.isFinalizationDelayed } -func (s *SyncManager) IsNodeSynced() bool { - s.isSyncedLock.RLock() - defer s.isSyncedLock.RUnlock() +func (s *SyncManager) updateLastAcceptedBlock(lastAcceptedBlockID iotago.BlockID) (changed bool) { + s.lastAcceptedBlockSlotLock.Lock() + defer s.lastAcceptedBlockSlotLock.Unlock() - return s.isSynced + if lastAcceptedBlockID.Slot() > s.lastAcceptedBlockSlot { + s.lastAcceptedBlockSlot = lastAcceptedBlockID.Slot() + + return true + } + + return false } func (s *SyncManager) LastAcceptedBlockSlot() iotago.SlotIndex { @@ -271,6 +306,19 @@ func (s *SyncManager) LastAcceptedBlockSlot() iotago.SlotIndex { return s.lastAcceptedBlockSlot } +func (s *SyncManager) updateLastConfirmedBlock(lastConfirmedBlockID iotago.BlockID) (changed bool) { + s.lastConfirmedBlockSlotLock.Lock() + defer s.lastConfirmedBlockSlotLock.Unlock() + + if lastConfirmedBlockID.Slot() > s.lastConfirmedBlockSlot { + s.lastConfirmedBlockSlot = lastConfirmedBlockID.Slot() + + return true + } + + return false +} + func (s *SyncManager) LastConfirmedBlockSlot() iotago.SlotIndex { s.lastConfirmedBlockSlotLock.RLock() defer s.lastConfirmedBlockSlotLock.RUnlock() @@ -278,6 +326,25 @@ func (s *SyncManager) LastConfirmedBlockSlot() iotago.SlotIndex { return s.lastConfirmedBlockSlot } +func (s *SyncManager) updateLatestCommitment(commitment *model.Commitment) (changed bool) { + s.latestCommitmentLock.Lock() + + if s.latestCommitment != commitment { + s.latestCommitment = commitment + + // we need to unlock the lock before calling updateIsFinalizationDelayed, + // otherwise it might deadlock if isFinalizationDelayedLock is Rlocked in SyncStatus(). + s.latestCommitmentLock.Unlock() + + s.updateIsFinalizationDelayed(s.LatestFinalizedSlot(), commitment.Slot()) + + return true + } + s.latestCommitmentLock.Unlock() + + return false +} + func (s *SyncManager) LatestCommitment() *model.Commitment { s.latestCommitmentLock.RLock() defer s.latestCommitmentLock.RUnlock() @@ -285,6 +352,25 @@ func (s *SyncManager) LatestCommitment() *model.Commitment { return s.latestCommitment } +func (s *SyncManager) updateFinalizedSlot(slot iotago.SlotIndex) (changed bool) { + s.latestFinalizedSlotLock.Lock() + + if s.latestFinalizedSlot != slot { + s.latestFinalizedSlot = slot + + // we need to unlock the lock before calling updateIsFinalizationDelayed, + // otherwise it might deadlock if isFinalizationDelayedLock is Rlocked in SyncStatus(). + s.latestFinalizedSlotLock.Unlock() + + s.updateIsFinalizationDelayed(slot, s.LatestCommitment().Slot()) + + return true + } + s.latestFinalizedSlotLock.Unlock() + + return false +} + func (s *SyncManager) LatestFinalizedSlot() iotago.SlotIndex { s.latestFinalizedSlotLock.RLock() defer s.latestFinalizedSlotLock.RUnlock() @@ -292,25 +378,23 @@ func (s *SyncManager) LatestFinalizedSlot() iotago.SlotIndex { return s.latestFinalizedSlot } -func (s *SyncManager) LastPrunedEpoch() (iotago.EpochIndex, bool) { - s.lastPrunedEpochLock.RLock() - defer s.lastPrunedEpochLock.RUnlock() - - return s.lastPrunedEpoch, s.hasPruned -} +func (s *SyncManager) updatePrunedEpoch(epoch iotago.EpochIndex, hasPruned bool) (changed bool) { + s.lastPrunedEpochLock.Lock() + defer s.lastPrunedEpochLock.Unlock() -func (s *SyncManager) triggerUpdate() { - s.events.UpdatedStatus.Trigger(s.SyncStatus()) -} + if s.lastPrunedEpoch != epoch || s.hasPruned != hasPruned { + s.lastPrunedEpoch = epoch + s.hasPruned = hasPruned -func WithBootstrappedThreshold(threshold time.Duration) options.Option[SyncManager] { - return func(s *SyncManager) { - s.optsBootstrappedThreshold = threshold + return true } + + return false } -func WithBootstrappedFunc(isBootstrapped func(*engine.Engine) bool) options.Option[SyncManager] { - return func(s *SyncManager) { - s.optsIsBootstrappedFunc = isBootstrapped - } +func (s *SyncManager) LastPrunedEpoch() (iotago.EpochIndex, bool) { + s.lastPrunedEpochLock.RLock() + defer s.lastPrunedEpochLock.RUnlock() + + return s.lastPrunedEpoch, s.hasPruned } diff --git a/pkg/requesthandler/node.go b/pkg/requesthandler/node.go index f056e1f1d..a83b8aa36 100644 --- a/pkg/requesthandler/node.go +++ b/pkg/requesthandler/node.go @@ -13,6 +13,10 @@ func (r *RequestHandler) IsNodeSynced() bool { return r.protocol.Engines.Main.Get().SyncManager.IsNodeSynced() } +func (r *RequestHandler) IsNetworkHealthy() bool { + return r.protocol.Engines.Main.Get().SyncManager.IsNodeSynced() && !r.protocol.Engines.Main.Get().SyncManager.IsFinalizationDelayed() +} + func (r *RequestHandler) GetProtocolParameters() []*api.InfoResProtocolParameters { protoParams := make([]*api.InfoResProtocolParameters, 0) provider := r.protocol.Engines.Main.Get().Storage.Settings().APIProvider() @@ -37,6 +41,7 @@ func (r *RequestHandler) GetNodeStatus() *api.InfoResNodeStatus { return &api.InfoResNodeStatus{ IsHealthy: syncStatus.NodeSynced, + IsNetworkHealthy: syncStatus.NodeSynced && !syncStatus.FinalizationDelayed, AcceptedTangleTime: clSnapshot.AcceptedTime, RelativeAcceptedTangleTime: clSnapshot.RelativeAcceptedTime, ConfirmedTangleTime: clSnapshot.ConfirmedTime, diff --git a/pkg/retainer/txretainer/tx_retainer.go b/pkg/retainer/txretainer/tx_retainer.go index 016964c7d..6f37aa7db 100644 --- a/pkg/retainer/txretainer/tx_retainer.go +++ b/pkg/retainer/txretainer/tx_retainer.go @@ -278,12 +278,12 @@ func (r *TransactionRetainer) Prune(targetSlot iotago.SlotIndex) error { // CommitSlot applies all uncommitted changes of a slot from the cache to the database and deletes them from the cache. func (r *TransactionRetainer) CommitSlot(slot iotago.SlotIndex) error { - uncommitedChanges := r.txRetainerCache.DeleteAndReturnTxMetadataChangesBySlot(slot) - if len(uncommitedChanges) == 0 { + uncommittedChanges := r.txRetainerCache.DeleteAndReturnTxMetadataChangesBySlot(slot) + if len(uncommittedChanges) == 0 { return nil } - if err := r.txRetainerDatabase.ApplyTxMetadataChanges(uncommitedChanges); err != nil { + if err := r.txRetainerDatabase.ApplyTxMetadataChanges(uncommittedChanges); err != nil { return ierrors.Wrapf(err, "failed to commit slot: %d", slot) } diff --git a/pkg/retainer/txretainer/tx_retainer_database.go b/pkg/retainer/txretainer/tx_retainer_database.go index 5ff1203a5..b001aba25 100644 --- a/pkg/retainer/txretainer/tx_retainer_database.go +++ b/pkg/retainer/txretainer/tx_retainer_database.go @@ -58,11 +58,11 @@ func (r *transactionRetainerDatabase) InsertTxMetadata(newTxMeta *TransactionMet return nil } -// ApplyTxMetadataChanges applies the given uncommitedTxMetadataChanges to the database in a single atomic transaction. -func (r *transactionRetainerDatabase) ApplyTxMetadataChanges(uncommitedTxMetadataChanges map[iotago.TransactionID]*TransactionMetadata) error { +// ApplyTxMetadataChanges applies the given uncommittedTxMetadataChanges to the database in a single atomic transaction. +func (r *transactionRetainerDatabase) ApplyTxMetadataChanges(uncommittedTxMetadataChanges map[iotago.TransactionID]*TransactionMetadata) error { if err := r.dbExecFunc(func(db *gorm.DB) error { return db.Transaction(func(tx *gorm.DB) error { - for _, newTxMeta := range uncommitedTxMetadataChanges { + for _, newTxMeta := range uncommittedTxMetadataChanges { if err := r.insertTransactionMetadata(tx, newTxMeta); err != nil { return err } diff --git a/pkg/tests/protocol_engine_switching_test.go b/pkg/tests/protocol_engine_switching_test.go index c07aecb7c..7a6a3d01d 100644 --- a/pkg/tests/protocol_engine_switching_test.go +++ b/pkg/tests/protocol_engine_switching_test.go @@ -363,7 +363,7 @@ func TestProtocol_EngineSwitching(t *testing.T) { ), protocol.WithSyncManagerProvider( trivialsyncmanager.NewProvider( - trivialsyncmanager.WithBootstrappedFunc(func(e *engine.Engine) bool { + trivialsyncmanager.WithIsBootstrappedFunc(func(e *engine.Engine) bool { return e.SyncManager.LatestCommitment().Slot() >= expectedCommittedSlotAfterPartitionMerge && e.Notarization.IsBootstrapped() }), ), @@ -723,7 +723,7 @@ func TestProtocol_EngineSwitching_CommitteeRotation(t *testing.T) { ), protocol.WithSyncManagerProvider( trivialsyncmanager.NewProvider( - trivialsyncmanager.WithBootstrappedFunc(func(e *engine.Engine) bool { + trivialsyncmanager.WithIsBootstrappedFunc(func(e *engine.Engine) bool { return e.SyncManager.LatestCommitment().Slot() >= expectedCommittedSlotAfterPartitionMerge && e.Notarization.IsBootstrapped() }), ), @@ -1058,7 +1058,7 @@ func TestProtocol_EngineSwitching_Tie(t *testing.T) { protocol.WithSyncManagerProvider( trivialsyncmanager.NewProvider( - trivialsyncmanager.WithBootstrappedFunc(func(e *engine.Engine) bool { + trivialsyncmanager.WithIsBootstrappedFunc(func(e *engine.Engine) bool { return e.Storage.Settings().LatestCommitment().Slot() >= expectedCommittedSlotAfterPartitionMerge && e.Notarization.IsBootstrapped() }), ), diff --git a/pkg/tests/protocol_eviction_test.go b/pkg/tests/protocol_eviction_test.go index 298caa01f..ec2d0561f 100644 --- a/pkg/tests/protocol_eviction_test.go +++ b/pkg/tests/protocol_eviction_test.go @@ -93,7 +93,7 @@ func TestProtocol_Eviction(t *testing.T) { protocol.WithSyncManagerProvider( trivialsyncmanager.NewProvider( - trivialsyncmanager.WithBootstrappedFunc(func(e *engine.Engine) bool { + trivialsyncmanager.WithIsBootstrappedFunc(func(e *engine.Engine) bool { return e.Notarization.IsBootstrapped() }), ), diff --git a/tools/gendoc/go.mod b/tools/gendoc/go.mod index 80f65a73a..db326fd0a 100644 --- a/tools/gendoc/go.mod +++ b/tools/gendoc/go.mod @@ -75,7 +75,7 @@ require ( github.com/iotaledger/inx-app v1.0.0-rc.3.0.20240307101848-db58eb9353ec // indirect github.com/iotaledger/inx/go v1.0.0-rc.2.0.20240307100839-48553e1d2022 // indirect github.com/iotaledger/iota-crypto-demo v0.0.0-20240216103559-27ca8dffd1e7 // indirect - github.com/iotaledger/iota.go/v4 v4.0.0-20240313065735-74f8cf10c361 // indirect + github.com/iotaledger/iota.go/v4 v4.0.0-20240319114032-b6fcc3585c99 // indirect github.com/ipfs/boxo v0.18.0 // 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 b6a8df895..a27fd32d0 100644 --- a/tools/gendoc/go.sum +++ b/tools/gendoc/go.sum @@ -329,8 +329,8 @@ github.com/iotaledger/inx/go v1.0.0-rc.2.0.20240307100839-48553e1d2022 h1:I178Sa github.com/iotaledger/inx/go v1.0.0-rc.2.0.20240307100839-48553e1d2022/go.mod h1:jTFxIWiMUdAwO263jlJCSWcNLqEkgYEVOFXfjp5aNJM= github.com/iotaledger/iota-crypto-demo v0.0.0-20240216103559-27ca8dffd1e7 h1:t6k4MqiUov0FrBb2o2JhKlOVSdlPbIQWM8ivYHL0G0g= github.com/iotaledger/iota-crypto-demo v0.0.0-20240216103559-27ca8dffd1e7/go.mod h1:do+N3LpeDEi9qselEC4XcjqGoRc7cWGiqBtIeBOKEMs= -github.com/iotaledger/iota.go/v4 v4.0.0-20240313065735-74f8cf10c361 h1:fKvfJZ4byivRRKkqF6JPj8I4pDSN0y+bgF4I4HI11Lo= -github.com/iotaledger/iota.go/v4 v4.0.0-20240313065735-74f8cf10c361/go.mod h1:8UQOTI7CC5R/3TurawUFuBZbkb37RzW8m4q8Hp7ct30= +github.com/iotaledger/iota.go/v4 v4.0.0-20240319114032-b6fcc3585c99 h1:Fs4LqQ8VavnOkv4fRkEex8hVvnnqt1uVSY6R9hocPSU= +github.com/iotaledger/iota.go/v4 v4.0.0-20240319114032-b6fcc3585c99/go.mod h1:8UQOTI7CC5R/3TurawUFuBZbkb37RzW8m4q8Hp7ct30= github.com/ipfs/boxo v0.18.0 h1:MOL9/AgoV3e7jlVMInicaSdbgralfqSsbkc31dZ9tmw= github.com/ipfs/boxo v0.18.0/go.mod h1:pIZgTWdm3k3pLF9Uq6MB8JEcW07UDwNJjlXW1HELW80= github.com/ipfs/go-cid v0.4.1 h1:A/T3qGvxi4kpKWWcPC/PgbvDA2bjVLO7n4UeVwnbs/s=