Skip to content

Commit

Permalink
Merge pull request #680 from iotaledger/feat/cleanup-syncmanager-sett…
Browse files Browse the repository at this point in the history
…ings-usage

Cleanup usage of SyncManager and Settings across codebase.
  • Loading branch information
piotrm50 authored Jan 23, 2024
2 parents 5951157 + fa3faa7 commit 85d47f0
Show file tree
Hide file tree
Showing 20 changed files with 90 additions and 62 deletions.
2 changes: 1 addition & 1 deletion components/debugapi/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
//nolint:unparam // we have no error case right now
func validatorsSummary() (*ValidatorsSummaryResponse, error) {
seatManager := deps.Protocol.Engines.Main.Get().SybilProtection.SeatManager()
latestSlotIndex := deps.Protocol.Engines.Main.Get().Storage.Settings().LatestCommitment().Slot()
latestSlotIndex := deps.Protocol.Engines.Main.Get().SyncManager.LatestCommitment().Slot()
latestCommittee, exists := seatManager.CommitteeInSlot(latestSlotIndex)
if !exists {
return nil, ierrors.Errorf("committee for slot %d was not selected", latestSlotIndex)
Expand Down
4 changes: 2 additions & 2 deletions components/inx/server_utxo.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ func NewLedgerUpdateBatchOperationConsumed(spent *utxoledger.Spent) (*inx.Ledger
func (s *Server) ReadOutput(_ context.Context, id *inx.OutputId) (*inx.OutputResponse, error) {
engine := deps.Protocol.Engines.Main.Get()

latestCommitment := engine.Storage.Settings().LatestCommitment()
latestCommitment := engine.SyncManager.LatestCommitment()

outputID := id.Unwrap()

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

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

var innerErr error
err := engine.Ledger.ForEachUnspentOutput(func(output *utxoledger.Output) bool {
Expand Down
2 changes: 1 addition & 1 deletion pkg/protocol/engine/blockdag/inmemoryblockdag/blockdag.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func NewProvider(opts ...options.Option[BlockDAG]) module.Provider[*engine.Engin
}, event.WithWorkerPool(wp))

b.setRetainBlockFailureFunc(e.Retainer.RetainBlockFailure)
b.latestCommitmentFunc = e.Storage.Settings().LatestCommitment
b.latestCommitmentFunc = e.SyncManager.LatestCommitment

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

Expand Down
6 changes: 3 additions & 3 deletions pkg/protocol/engine/commitment_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func (c *CommitmentAPI) Mutations() (acceptedBlocksBySlotCommitment map[iotago.C

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

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

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

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

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func NewProvider(opts ...options.Option[Scheduler]) module.Provider[*engine.Engi

e.Constructed.OnTrigger(func() {
s.latestCommittedSlot = func() iotago.SlotIndex {
return e.Storage.Settings().LatestCommitment().Slot()
return e.SyncManager.LatestCommitment().Slot()
}
s.blockCache = e.BlockCache
e.Events.Scheduler.LinkTo(s.events)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ func NewProvider(opts ...options.Option[Gadget]) module.Provider[*engine.Engine,
func() {
g.mutex.Lock()
defer g.mutex.Unlock()

g.lastFinalizedSlot = e.Storage.Settings().LatestFinalizedSlot()
}()

Expand Down
2 changes: 1 addition & 1 deletion pkg/protocol/engine/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ func (e *Engine) CommitmentAPI(commitmentID iotago.CommitmentID) (*CommitmentAPI
return nil, ierrors.New("engine is nil")
}

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

Expand Down
18 changes: 16 additions & 2 deletions pkg/retainer/retainer/retainer.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,22 @@ func NewProvider() module.Provider[*engine.Engine, retainer.Retainer] {
return module.Provide(func(e *engine.Engine) retainer.Retainer {
r := New(e.Workers.CreateGroup("Retainer"),
e.Storage.Retainer,
e.Storage.Settings().LatestCommitment().Slot,
e.Storage.Settings().LatestFinalizedSlot,
func() iotago.SlotIndex {
// use settings in case SyncManager is not constructed yet.
if e.SyncManager == nil {
return e.Storage.Settings().LatestCommitment().Slot()
}

return e.SyncManager.LatestCommitment().Slot()
},
func() iotago.SlotIndex {
// use settings in case SyncManager is not constructed yet.
if e.SyncManager == nil {
return e.Storage.Settings().LatestFinalizedSlot()
}

return e.SyncManager.LatestFinalizedSlot()
},
e.ErrorHandler("retainer"))

asyncOpt := event.WithWorkerPool(r.workerPool)
Expand Down
4 changes: 4 additions & 0 deletions pkg/storage/permanent/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,8 @@ func (s *Settings) SetSnapshotImported() (err error) {
return s.storeSnapshotImported.Set(true)
}

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

// LatestFinalizedSlot returns the last finalized slot.
// This method should not be called often as it reads data from the underlying KVStore. For frequent access, use SyncManager.
func (s *Settings) LatestFinalizedSlot() iotago.SlotIndex {
latestFinalizedSlot, err := s.storeLatestFinalizedSlot.Get()
if err != nil {
Expand Down
22 changes: 11 additions & 11 deletions pkg/tests/accounts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ func Test_StakeDelegateAndDelayedClaim(t *testing.T) {
// CREATE NEW ACCOUNT WITH BLOCK ISSUER AND STAKING FEATURES FROM BASIC UTXO
newAccountBlockIssuerKey := tpkg.RandBlockIssuerKey()
// set the expiry slot of the transitioned genesis account to the latest committed + MaxCommittableAge
newAccountExpirySlot := node1.Protocol.Engines.Main.Get().Storage.Settings().LatestCommitment().Slot() + ts.API.ProtocolParameters().MaxCommittableAge()
newAccountExpirySlot := node1.Protocol.Engines.Main.Get().SyncManager.LatestCommitment().Slot() + ts.API.ProtocolParameters().MaxCommittableAge()

stakedAmount := iotago.BaseToken(10000)

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

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

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

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

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

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

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

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

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

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

Expand Down Expand Up @@ -805,7 +805,7 @@ func Test_NegativeBIC_AccountOutput(t *testing.T) {
mock.WithBlockIssuerExpirySlot(newExpirySlot),
)

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

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

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

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

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

tx2 := wallet1.SendFundsFromAccount(
"TX2",
Expand Down Expand Up @@ -1026,7 +1026,7 @@ func Test_NegativeBIC_AccountOwnedBasicOutputLocked(t *testing.T) {
Mana: iotago.Mana(allottedBIC),
}}, "TX0:1")

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

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

tx4 := wallet1.SendFundsFromAccount(
"TX4",
Expand Down
16 changes: 8 additions & 8 deletions pkg/tests/protocol_engine_rollback_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,8 @@ func TestProtocol_EngineRollbackFinalization(t *testing.T) {

// Assert state of the forked engine after rollback.
{
require.EqualValues(t, 13, newEngine.Storage.Settings().LatestCommitment().Slot())
require.EqualValues(t, 13, newEngine.Storage.Settings().LatestFinalizedSlot())
require.EqualValues(t, 13, newEngine.SyncManager.LatestCommitment().Slot())
require.EqualValues(t, 13, newEngine.SyncManager.LatestFinalizedSlot())
require.EqualValues(t, 13, newEngine.EvictionState.LastEvictedSlot())

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

// Assert state of the forked engine after rollback.
{
require.EqualValues(t, 13, newEngine.Storage.Settings().LatestCommitment().Slot())
require.EqualValues(t, 8, newEngine.Storage.Settings().LatestFinalizedSlot())
require.EqualValues(t, 13, newEngine.SyncManager.LatestCommitment().Slot())
require.EqualValues(t, 8, newEngine.SyncManager.LatestFinalizedSlot())
require.EqualValues(t, 13, newEngine.EvictionState.LastEvictedSlot())

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

// Assert state of the forked engine after rollback.
{
require.EqualValues(t, 15, newEngine.Storage.Settings().LatestCommitment().Slot())
require.EqualValues(t, 8, newEngine.Storage.Settings().LatestFinalizedSlot())
require.EqualValues(t, 15, newEngine.SyncManager.LatestCommitment().Slot())
require.EqualValues(t, 8, newEngine.SyncManager.LatestFinalizedSlot())
require.EqualValues(t, 15, newEngine.EvictionState.LastEvictedSlot())

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

// Assert state of the forked engine after rollback.
{
require.EqualValues(t, 9, newEngine.Storage.Settings().LatestCommitment().Slot())
require.EqualValues(t, 8, newEngine.Storage.Settings().LatestFinalizedSlot())
require.EqualValues(t, 9, newEngine.SyncManager.LatestCommitment().Slot())
require.EqualValues(t, 8, newEngine.SyncManager.LatestFinalizedSlot())
require.EqualValues(t, 9, newEngine.EvictionState.LastEvictedSlot())

for epoch := 0; epoch <= 1; epoch++ {
Expand Down
4 changes: 2 additions & 2 deletions pkg/tests/protocol_engine_switching_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func TestProtocol_EngineSwitching(t *testing.T) {
protocol.WithSyncManagerProvider(
trivialsyncmanager.NewProvider(
trivialsyncmanager.WithBootstrappedFunc(func(e *engine.Engine) bool {
return e.Storage.Settings().LatestCommitment().Slot() >= expectedCommittedSlotAfterPartitionMerge && e.Notarization.IsBootstrapped()
return e.SyncManager.LatestCommitment().Slot() >= expectedCommittedSlotAfterPartitionMerge && e.Notarization.IsBootstrapped()
}),
),
),
Expand Down Expand Up @@ -420,7 +420,7 @@ func TestProtocol_EngineSwitching_CommitteeRotation(t *testing.T) {
protocol.WithSyncManagerProvider(
trivialsyncmanager.NewProvider(
trivialsyncmanager.WithBootstrappedFunc(func(e *engine.Engine) bool {
return e.Storage.Settings().LatestCommitment().Slot() >= expectedCommittedSlotAfterPartitionMerge && e.Notarization.IsBootstrapped()
return e.SyncManager.LatestCommitment().Slot() >= expectedCommittedSlotAfterPartitionMerge && e.Notarization.IsBootstrapped()
}),
),
),
Expand Down
4 changes: 2 additions & 2 deletions pkg/tests/reward_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func Test_Delegation_DelayedClaimingDestroyOutputWithoutRewards(t *testing.T) {
block1 := ts.IssueBasicBlockWithOptions("block1", ts.DefaultWallet(), tx1)

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

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

ts.IssueBasicBlockWithOptions("block2", ts.DefaultWallet(), tx2, mock.WithStrongParents(latestParents...))
Expand Down
11 changes: 6 additions & 5 deletions pkg/tests/validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ import (
"testing"
"time"

"github.com/stretchr/testify/require"

"github.com/iotaledger/hive.go/core/safemath"
"github.com/iotaledger/hive.go/lo"
"github.com/iotaledger/hive.go/log"
"github.com/iotaledger/hive.go/runtime/options"
"github.com/iotaledger/iota-core/pkg/testsuite"
"github.com/iotaledger/iota-core/pkg/testsuite/mock"
"github.com/stretchr/testify/require"

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

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

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

0 comments on commit 85d47f0

Please sign in to comment.