Skip to content
This repository was archived by the owner on Jan 24, 2025. It is now read-only.

Commit 85d47f0

Browse files
authored
Merge pull request #680 from iotaledger/feat/cleanup-syncmanager-settings-usage
Cleanup usage of SyncManager and Settings across codebase.
2 parents 5951157 + fa3faa7 commit 85d47f0

File tree

20 files changed

+90
-62
lines changed

20 files changed

+90
-62
lines changed

components/debugapi/node.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
//nolint:unparam // we have no error case right now
1111
func validatorsSummary() (*ValidatorsSummaryResponse, error) {
1212
seatManager := deps.Protocol.Engines.Main.Get().SybilProtection.SeatManager()
13-
latestSlotIndex := deps.Protocol.Engines.Main.Get().Storage.Settings().LatestCommitment().Slot()
13+
latestSlotIndex := deps.Protocol.Engines.Main.Get().SyncManager.LatestCommitment().Slot()
1414
latestCommittee, exists := seatManager.CommitteeInSlot(latestSlotIndex)
1515
if !exists {
1616
return nil, ierrors.Errorf("committee for slot %d was not selected", latestSlotIndex)

components/inx/server_utxo.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ func NewLedgerUpdateBatchOperationConsumed(spent *utxoledger.Spent) (*inx.Ledger
134134
func (s *Server) ReadOutput(_ context.Context, id *inx.OutputId) (*inx.OutputResponse, error) {
135135
engine := deps.Protocol.Engines.Main.Get()
136136

137-
latestCommitment := engine.Storage.Settings().LatestCommitment()
137+
latestCommitment := engine.SyncManager.LatestCommitment()
138138

139139
outputID := id.Unwrap()
140140

@@ -172,7 +172,7 @@ func (s *Server) ReadOutput(_ context.Context, id *inx.OutputId) (*inx.OutputRes
172172

173173
func (s *Server) ReadUnspentOutputs(_ *inx.NoParams, srv inx.INX_ReadUnspentOutputsServer) error {
174174
engine := deps.Protocol.Engines.Main.Get()
175-
latestCommitment := engine.Storage.Settings().LatestCommitment()
175+
latestCommitment := engine.SyncManager.LatestCommitment()
176176

177177
var innerErr error
178178
err := engine.Ledger.ForEachUnspentOutput(func(output *utxoledger.Output) bool {

pkg/protocol/engine/blockdag/inmemoryblockdag/blockdag.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ func NewProvider(opts ...options.Option[BlockDAG]) module.Provider[*engine.Engin
5959
}, event.WithWorkerPool(wp))
6060

6161
b.setRetainBlockFailureFunc(e.Retainer.RetainBlockFailure)
62-
b.latestCommitmentFunc = e.Storage.Settings().LatestCommitment
62+
b.latestCommitmentFunc = e.SyncManager.LatestCommitment
6363

6464
e.Events.BlockDAG.LinkTo(b.events)
6565

pkg/protocol/engine/commitment_api.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ func (c *CommitmentAPI) Mutations() (acceptedBlocksBySlotCommitment map[iotago.C
8686

8787
// Roots returns the roots of the slot.
8888
func (c *CommitmentAPI) Roots() (committedRoots *iotago.Roots, err error) {
89-
if c.engine.Storage.Settings().LatestCommitment().Slot() < c.CommitmentID.Slot() {
89+
if c.engine.SyncManager.LatestCommitment().Slot() < c.CommitmentID.Slot() {
9090
return nil, ierrors.Errorf("slot %d is not committed yet", c.CommitmentID)
9191
}
9292

@@ -107,7 +107,7 @@ func (c *CommitmentAPI) Roots() (committedRoots *iotago.Roots, err error) {
107107

108108
// BlocksIDsBySlotCommitmentID returns the accepted block IDs of the slot grouped by their SlotCommitmentID.
109109
func (c *CommitmentAPI) BlocksIDsBySlotCommitmentID() (map[iotago.CommitmentID]iotago.BlockIDs, error) {
110-
if c.engine.Storage.Settings().LatestCommitment().Slot() < c.CommitmentID.Slot() {
110+
if c.engine.SyncManager.LatestCommitment().Slot() < c.CommitmentID.Slot() {
111111
return nil, ierrors.Errorf("slot %d is not committed yet", c.CommitmentID)
112112
}
113113

@@ -128,7 +128,7 @@ func (c *CommitmentAPI) BlocksIDsBySlotCommitmentID() (map[iotago.CommitmentID]i
128128
}
129129

130130
func (c *CommitmentAPI) TransactionIDs() (iotago.TransactionIDs, error) {
131-
if c.engine.Storage.Settings().LatestCommitment().Slot() < c.CommitmentID.Slot() {
131+
if c.engine.SyncManager.LatestCommitment().Slot() < c.CommitmentID.Slot() {
132132
return nil, ierrors.Errorf("slot %d is not committed yet", c.CommitmentID)
133133
}
134134

pkg/protocol/engine/congestioncontrol/scheduler/drr/scheduler.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ func NewProvider(opts ...options.Option[Scheduler]) module.Provider[*engine.Engi
5959

6060
e.Constructed.OnTrigger(func() {
6161
s.latestCommittedSlot = func() iotago.SlotIndex {
62-
return e.Storage.Settings().LatestCommitment().Slot()
62+
return e.SyncManager.LatestCommitment().Slot()
6363
}
6464
s.blockCache = e.BlockCache
6565
e.Events.Scheduler.LinkTo(s.events)

pkg/protocol/engine/consensus/slotgadget/totalweightslotgadget/gadget.go

+1
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ func NewProvider(opts ...options.Option[Gadget]) module.Provider[*engine.Engine,
6565
func() {
6666
g.mutex.Lock()
6767
defer g.mutex.Unlock()
68+
6869
g.lastFinalizedSlot = e.Storage.Settings().LatestFinalizedSlot()
6970
}()
7071

pkg/protocol/engine/engine.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ func (e *Engine) CommitmentAPI(commitmentID iotago.CommitmentID) (*CommitmentAPI
331331
return nil, ierrors.New("engine is nil")
332332
}
333333

334-
if e.Storage.Settings().LatestCommitment().Slot() < commitmentID.Slot() {
334+
if e.SyncManager.LatestCommitment().Slot() < commitmentID.Slot() {
335335
return nil, ierrors.Errorf("slot %d is not committed yet", commitmentID.Slot())
336336
}
337337

pkg/retainer/retainer/retainer.go

+16-2
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,22 @@ func NewProvider() module.Provider[*engine.Engine, retainer.Retainer] {
5555
return module.Provide(func(e *engine.Engine) retainer.Retainer {
5656
r := New(e.Workers.CreateGroup("Retainer"),
5757
e.Storage.Retainer,
58-
e.Storage.Settings().LatestCommitment().Slot,
59-
e.Storage.Settings().LatestFinalizedSlot,
58+
func() iotago.SlotIndex {
59+
// use settings in case SyncManager is not constructed yet.
60+
if e.SyncManager == nil {
61+
return e.Storage.Settings().LatestCommitment().Slot()
62+
}
63+
64+
return e.SyncManager.LatestCommitment().Slot()
65+
},
66+
func() iotago.SlotIndex {
67+
// use settings in case SyncManager is not constructed yet.
68+
if e.SyncManager == nil {
69+
return e.Storage.Settings().LatestFinalizedSlot()
70+
}
71+
72+
return e.SyncManager.LatestFinalizedSlot()
73+
},
6074
e.ErrorHandler("retainer"))
6175

6276
asyncOpt := event.WithWorkerPool(r.workerPool)

pkg/storage/permanent/settings.go

+4
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,8 @@ func (s *Settings) SetSnapshotImported() (err error) {
251251
return s.storeSnapshotImported.Set(true)
252252
}
253253

254+
// LatestCommitment returns the last created commitment.
255+
// This method should not be called often as it reads data from the underlying KVStore. For frequent access, use SyncManager.
254256
func (s *Settings) LatestCommitment() *model.Commitment {
255257
return s.latestCommitment()
256258
}
@@ -283,6 +285,8 @@ func (s *Settings) SetLatestFinalizedSlot(slot iotago.SlotIndex) (err error) {
283285
return s.storeLatestFinalizedSlot.Set(slot)
284286
}
285287

288+
// LatestFinalizedSlot returns the last finalized slot.
289+
// This method should not be called often as it reads data from the underlying KVStore. For frequent access, use SyncManager.
286290
func (s *Settings) LatestFinalizedSlot() iotago.SlotIndex {
287291
latestFinalizedSlot, err := s.storeLatestFinalizedSlot.Get()
288292
if err != nil {

pkg/tests/accounts_test.go

+11-11
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ func Test_StakeDelegateAndDelayedClaim(t *testing.T) {
205205
// CREATE NEW ACCOUNT WITH BLOCK ISSUER AND STAKING FEATURES FROM BASIC UTXO
206206
newAccountBlockIssuerKey := tpkg.RandBlockIssuerKey()
207207
// set the expiry slot of the transitioned genesis account to the latest committed + MaxCommittableAge
208-
newAccountExpirySlot := node1.Protocol.Engines.Main.Get().Storage.Settings().LatestCommitment().Slot() + ts.API.ProtocolParameters().MaxCommittableAge()
208+
newAccountExpirySlot := node1.Protocol.Engines.Main.Get().SyncManager.LatestCommitment().Slot() + ts.API.ProtocolParameters().MaxCommittableAge()
209209

210210
stakedAmount := iotago.BaseToken(10000)
211211

@@ -421,7 +421,7 @@ func Test_ImplicitAccounts(t *testing.T) {
421421
),
422422
mock.WithAccountAmount(mock.MinIssuerAccountAmount(ts.API.ProtocolParameters())),
423423
)
424-
block2Commitment := node1.Protocol.Engines.Main.Get().Storage.Settings().LatestCommitment().Commitment()
424+
block2Commitment := node1.Protocol.Engines.Main.Get().SyncManager.LatestCommitment().Commitment()
425425
block2 := ts.IssueBasicBlockWithOptions("block2", newUserWallet, tx2, mock.WithStrongParents(latestParents...))
426426
latestParents = ts.CommitUntilSlot(block2Slot, block2.ID())
427427

@@ -543,7 +543,7 @@ func Test_NegativeBIC_BlockIssuerLocked(t *testing.T) {
543543
// Try to issue more blocks from each of the issuers - one succeeds in issuing a block,
544544
// the other has the block rejected in the PostSolidFilter as his account has negative BIC value.
545545
{
546-
block2Commitment := node1.Protocol.Engines.Main.Get().Storage.Settings().LatestCommitment().Commitment()
546+
block2Commitment := node1.Protocol.Engines.Main.Get().SyncManager.LatestCommitment().Commitment()
547547

548548
block21 := ts.IssueBasicBlockWithOptions("block2.1", wallet1, &iotago.TaggedData{}, mock.WithSlotCommitment(block2Commitment))
549549

@@ -586,7 +586,7 @@ func Test_NegativeBIC_BlockIssuerLocked(t *testing.T) {
586586
Mana: iotago.Mana(allottedBIC),
587587
}}, "Genesis:0")
588588

589-
block3Commitment := node1.Protocol.Engines.Main.Get().Storage.Settings().LatestCommitment().Commitment()
589+
block3Commitment := node1.Protocol.Engines.Main.Get().SyncManager.LatestCommitment().Commitment()
590590
// Wallet 1 whose account is not locked is issuing the block to unlock the account of wallet 2.
591591
block31 := ts.IssueBasicBlockWithOptions("block3.1", wallet1, tx1, mock.WithStrongParents(latestParents...), mock.WithSlotCommitment(block3Commitment))
592592

@@ -618,7 +618,7 @@ func Test_NegativeBIC_BlockIssuerLocked(t *testing.T) {
618618

619619
// Issue block from the unlocked account of wallet 2 to make sure that it's actually unlocked.
620620
{
621-
block4Commitment := node1.Protocol.Engines.Main.Get().Storage.Settings().LatestCommitment().Commitment()
621+
block4Commitment := node1.Protocol.Engines.Main.Get().SyncManager.LatestCommitment().Commitment()
622622

623623
block4 := ts.IssueBasicBlockWithOptions("block4", wallet2, &iotago.TaggedData{}, mock.WithStrongParents(latestParents...), mock.WithSlotCommitment(block4Commitment))
624624

@@ -768,7 +768,7 @@ func Test_NegativeBIC_AccountOutput(t *testing.T) {
768768
Mana: iotago.Mana(allottedBIC),
769769
}}, "Genesis:0")
770770

771-
block2Commitment := node1.Protocol.Engines.Main.Get().Storage.Settings().LatestCommitment().Commitment()
771+
block2Commitment := node1.Protocol.Engines.Main.Get().SyncManager.LatestCommitment().Commitment()
772772
// Wallet 2 whose account is not locked is issuing the block to unlock the account of wallet 1.
773773
block2 := ts.IssueBasicBlockWithOptions("block2", wallet2, tx2, mock.WithStrongParents(latestParents...), mock.WithSlotCommitment(block2Commitment))
774774

@@ -805,7 +805,7 @@ func Test_NegativeBIC_AccountOutput(t *testing.T) {
805805
mock.WithBlockIssuerExpirySlot(newExpirySlot),
806806
)
807807

808-
block3Commitment := node1.Protocol.Engines.Main.Get().Storage.Settings().LatestCommitment().Commitment()
808+
block3Commitment := node1.Protocol.Engines.Main.Get().SyncManager.LatestCommitment().Commitment()
809809

810810
// Wallet 1, which already has non-negative BIC issues the block.
811811
block3 := ts.IssueBasicBlockWithOptions("block3", wallet1, tx3, mock.WithStrongParents(latestParents...), mock.WithSlotCommitment(block3Commitment))
@@ -843,7 +843,7 @@ func Test_NegativeBIC_AccountOutput(t *testing.T) {
843843
// create a transaction which destroys the genesis account.
844844

845845
tx4 := wallet1.DestroyAccount("TX4", "TX3:0")
846-
block4Commitment := node1.Protocol.Engines.Main.Get().Storage.Settings().LatestCommitment().Commitment()
846+
block4Commitment := node1.Protocol.Engines.Main.Get().SyncManager.LatestCommitment().Commitment()
847847

848848
block4 := ts.IssueBasicBlockWithOptions("block4", wallet2, tx4, mock.WithStrongParents(latestParents...), mock.WithSlotCommitment(block4Commitment))
849849
latestParents = ts.CommitUntilSlot(block4Slot, block4.ID())
@@ -979,7 +979,7 @@ func Test_NegativeBIC_AccountOwnedBasicOutputLocked(t *testing.T) {
979979

980980
// TRY TO SPEND THE BASIC OUTPUT FROM AN ACCOUNT ADDRESS
981981
{
982-
block2Commitment := node1.Protocol.Engines.Main.Get().Storage.Settings().LatestCommitment().Commitment()
982+
block2Commitment := node1.Protocol.Engines.Main.Get().SyncManager.LatestCommitment().Commitment()
983983

984984
tx2 := wallet1.SendFundsFromAccount(
985985
"TX2",
@@ -1026,7 +1026,7 @@ func Test_NegativeBIC_AccountOwnedBasicOutputLocked(t *testing.T) {
10261026
Mana: iotago.Mana(allottedBIC),
10271027
}}, "TX0:1")
10281028

1029-
block3Commitment := node1.Protocol.Engines.Main.Get().Storage.Settings().LatestCommitment().Commitment()
1029+
block3Commitment := node1.Protocol.Engines.Main.Get().SyncManager.LatestCommitment().Commitment()
10301030

10311031
// Wallet 2 whose account is not locked is issuing the block to unlock the account of wallet 1.
10321032
block3 := ts.IssueBasicBlockWithOptions("block3", wallet2, tx3, mock.WithStrongParents(latestParents...), mock.WithSlotCommitment(block3Commitment))
@@ -1060,7 +1060,7 @@ func Test_NegativeBIC_AccountOwnedBasicOutputLocked(t *testing.T) {
10601060
block4Slot := ts.CurrentSlot()
10611061
// SPEND THE BASIC OUTPUT FROM AN ACCOUNT ADDRESS
10621062
{
1063-
block4Commitment := node1.Protocol.Engines.Main.Get().Storage.Settings().LatestCommitment().Commitment()
1063+
block4Commitment := node1.Protocol.Engines.Main.Get().SyncManager.LatestCommitment().Commitment()
10641064

10651065
tx4 := wallet1.SendFundsFromAccount(
10661066
"TX4",

pkg/tests/protocol_engine_rollback_test.go

+8-8
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,8 @@ func TestProtocol_EngineRollbackFinalization(t *testing.T) {
176176

177177
// Assert state of the forked engine after rollback.
178178
{
179-
require.EqualValues(t, 13, newEngine.Storage.Settings().LatestCommitment().Slot())
180-
require.EqualValues(t, 13, newEngine.Storage.Settings().LatestFinalizedSlot())
179+
require.EqualValues(t, 13, newEngine.SyncManager.LatestCommitment().Slot())
180+
require.EqualValues(t, 13, newEngine.SyncManager.LatestFinalizedSlot())
181181
require.EqualValues(t, 13, newEngine.EvictionState.LastEvictedSlot())
182182

183183
for epoch := 0; epoch <= 2; epoch++ {
@@ -370,8 +370,8 @@ func TestProtocol_EngineRollbackNoFinalization(t *testing.T) {
370370

371371
// Assert state of the forked engine after rollback.
372372
{
373-
require.EqualValues(t, 13, newEngine.Storage.Settings().LatestCommitment().Slot())
374-
require.EqualValues(t, 8, newEngine.Storage.Settings().LatestFinalizedSlot())
373+
require.EqualValues(t, 13, newEngine.SyncManager.LatestCommitment().Slot())
374+
require.EqualValues(t, 8, newEngine.SyncManager.LatestFinalizedSlot())
375375
require.EqualValues(t, 13, newEngine.EvictionState.LastEvictedSlot())
376376

377377
for epoch := 0; epoch <= 2; epoch++ {
@@ -564,8 +564,8 @@ func TestProtocol_EngineRollbackNoFinalizationLastSlot(t *testing.T) {
564564

565565
// Assert state of the forked engine after rollback.
566566
{
567-
require.EqualValues(t, 15, newEngine.Storage.Settings().LatestCommitment().Slot())
568-
require.EqualValues(t, 8, newEngine.Storage.Settings().LatestFinalizedSlot())
567+
require.EqualValues(t, 15, newEngine.SyncManager.LatestCommitment().Slot())
568+
require.EqualValues(t, 8, newEngine.SyncManager.LatestFinalizedSlot())
569569
require.EqualValues(t, 15, newEngine.EvictionState.LastEvictedSlot())
570570

571571
for epoch := 0; epoch <= 2; epoch++ {
@@ -758,8 +758,8 @@ func TestProtocol_EngineRollbackNoFinalizationBeforePointOfNoReturn(t *testing.T
758758

759759
// Assert state of the forked engine after rollback.
760760
{
761-
require.EqualValues(t, 9, newEngine.Storage.Settings().LatestCommitment().Slot())
762-
require.EqualValues(t, 8, newEngine.Storage.Settings().LatestFinalizedSlot())
761+
require.EqualValues(t, 9, newEngine.SyncManager.LatestCommitment().Slot())
762+
require.EqualValues(t, 8, newEngine.SyncManager.LatestFinalizedSlot())
763763
require.EqualValues(t, 9, newEngine.EvictionState.LastEvictedSlot())
764764

765765
for epoch := 0; epoch <= 1; epoch++ {

pkg/tests/protocol_engine_switching_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ func TestProtocol_EngineSwitching(t *testing.T) {
9898
protocol.WithSyncManagerProvider(
9999
trivialsyncmanager.NewProvider(
100100
trivialsyncmanager.WithBootstrappedFunc(func(e *engine.Engine) bool {
101-
return e.Storage.Settings().LatestCommitment().Slot() >= expectedCommittedSlotAfterPartitionMerge && e.Notarization.IsBootstrapped()
101+
return e.SyncManager.LatestCommitment().Slot() >= expectedCommittedSlotAfterPartitionMerge && e.Notarization.IsBootstrapped()
102102
}),
103103
),
104104
),
@@ -420,7 +420,7 @@ func TestProtocol_EngineSwitching_CommitteeRotation(t *testing.T) {
420420
protocol.WithSyncManagerProvider(
421421
trivialsyncmanager.NewProvider(
422422
trivialsyncmanager.WithBootstrappedFunc(func(e *engine.Engine) bool {
423-
return e.Storage.Settings().LatestCommitment().Slot() >= expectedCommittedSlotAfterPartitionMerge && e.Notarization.IsBootstrapped()
423+
return e.SyncManager.LatestCommitment().Slot() >= expectedCommittedSlotAfterPartitionMerge && e.Notarization.IsBootstrapped()
424424
}),
425425
),
426426
),

pkg/tests/reward_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ func Test_Delegation_DelayedClaimingDestroyOutputWithoutRewards(t *testing.T) {
107107
block1 := ts.IssueBasicBlockWithOptions("block1", ts.DefaultWallet(), tx1)
108108

109109
// TRANSITION TO DELAYED CLAIMING (IN THE SAME SLOT)
110-
latestCommitment := ts.DefaultWallet().Node.Protocol.Engines.Main.Get().Storage.Settings().LatestCommitment()
110+
latestCommitment := ts.DefaultWallet().Node.Protocol.Engines.Main.Get().SyncManager.LatestCommitment()
111111
apiForSlot := ts.DefaultWallet().Node.Protocol.APIForSlot(block1_2Slot)
112112

113113
futureBoundedSlotIndex := latestCommitment.Slot() + apiForSlot.ProtocolParameters().MinCommittableAge()
@@ -237,7 +237,7 @@ func Test_RewardInputCannotPointToNFTOutput(t *testing.T) {
237237
0,
238238
),
239239
mock.WithCommitmentInput(&iotago.CommitmentInput{
240-
CommitmentID: ts.DefaultWallet().Node.Protocol.Engines.Main.Get().Storage.Settings().LatestCommitment().Commitment().MustID(),
240+
CommitmentID: ts.DefaultWallet().Node.Protocol.Engines.Main.Get().SyncManager.LatestCommitment().Commitment().MustID(),
241241
}))
242242

243243
ts.IssueBasicBlockWithOptions("block2", ts.DefaultWallet(), tx2, mock.WithStrongParents(latestParents...))

pkg/tests/validator_test.go

+6-5
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@ import (
55
"testing"
66
"time"
77

8+
"github.com/stretchr/testify/require"
9+
810
"github.com/iotaledger/hive.go/core/safemath"
911
"github.com/iotaledger/hive.go/lo"
1012
"github.com/iotaledger/hive.go/log"
1113
"github.com/iotaledger/hive.go/runtime/options"
1214
"github.com/iotaledger/iota-core/pkg/testsuite"
1315
"github.com/iotaledger/iota-core/pkg/testsuite/mock"
14-
"github.com/stretchr/testify/require"
1516

1617
iotago "github.com/iotaledger/iota.go/v4"
1718
)
@@ -267,7 +268,7 @@ func validatorTest(t *testing.T, test ValidatorTest) {
267268
for subslotIdx := uint8(0); subslotIdx < test.issuancePerSlot; subslotIdx++ {
268269
for _, node := range ts.Validators() {
269270
blockName := fmt.Sprintf("block-%s-%d/%d", node.Name, ts.CurrentSlot(), subslotIdx)
270-
latestCommitment := node.Protocol.Engines.Main.Get().Storage.Settings().LatestCommitment().Commitment()
271+
latestCommitment := node.Protocol.Engines.Main.Get().SyncManager.LatestCommitment().Commitment()
271272

272273
issuingTime := slotStartTime.
273274
Add(issuancePeriod * time.Duration(subslotIdx)).
@@ -291,7 +292,7 @@ func validatorTest(t *testing.T, test ValidatorTest) {
291292
var totalStake iotago.BaseToken = 0
292293
var totalValidatorStake iotago.BaseToken = 0
293294
lo.ForEach(ts.Validators(), func(n *mock.Node) {
294-
latestCommittedSlot := ts.DefaultWallet().Node.Protocol.Engines.Main.Get().Storage.Settings().LatestCommitment().Slot()
295+
latestCommittedSlot := ts.DefaultWallet().Node.Protocol.Engines.Main.Get().SyncManager.LatestCommitment().Slot()
295296
accountData, exists, err := ts.DefaultWallet().Node.Protocol.Engines.Main.Get().Ledger.Account(n.Validator.AccountID, latestCommittedSlot)
296297
if err != nil || !exists {
297298
t.Fatal(exists, err)
@@ -357,7 +358,7 @@ type epochReward struct {
357358
// as in the epoch for which to calculate rewards.
358359
func calculateEpochReward(t *testing.T, ts *testsuite.TestSuite, accountID iotago.AccountID, epoch iotago.EpochIndex, epochPerformanceFactor uint64, totalStake iotago.BaseToken, totalValidatorStake iotago.BaseToken) epochReward {
359360

360-
latestCommittedSlot := ts.DefaultWallet().Node.Protocol.Engines.Main.Get().Storage.Settings().LatestCommitment().Slot()
361+
latestCommittedSlot := ts.DefaultWallet().Node.Protocol.Engines.Main.Get().SyncManager.LatestCommitment().Slot()
361362
targetReward := lo.PanicOnErr(ts.API.ProtocolParameters().RewardsParameters().TargetReward(epoch, ts.API))
362363
accountData, exists, err := ts.DefaultWallet().Node.Protocol.Engines.Main.Get().Ledger.Account(accountID, latestCommittedSlot)
363364
if err != nil || !exists {
@@ -384,7 +385,7 @@ func calculateEpochReward(t *testing.T, ts *testsuite.TestSuite, accountID iotag
384385
// For testing purposes, assumes that the account's staking data is the same in the latest committed slot
385386
// as in the epoch for which to calculate rewards.
386387
func calculateValidatorReward(t *testing.T, ts *testsuite.TestSuite, accountID iotago.AccountID, epochRewards []epochReward, startEpoch iotago.EpochIndex, claimingEpoch iotago.EpochIndex) iotago.Mana {
387-
latestCommittedSlot := ts.DefaultWallet().Node.Protocol.Engines.Main.Get().Storage.Settings().LatestCommitment().Slot()
388+
latestCommittedSlot := ts.DefaultWallet().Node.Protocol.Engines.Main.Get().SyncManager.LatestCommitment().Slot()
388389
accountData, exists, err := ts.DefaultWallet().Node.Protocol.Engines.Main.Get().Ledger.Account(accountID, latestCommittedSlot)
389390
if err != nil || !exists {
390391
t.Fatal(exists, err)

0 commit comments

Comments
 (0)