Skip to content

Commit

Permalink
Fixed RMC vector when committing a slot
Browse files Browse the repository at this point in the history
  • Loading branch information
alexsporn committed Oct 31, 2023
1 parent 1b2a995 commit 8f22f6e
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions pkg/protocol/engine/ledger/ledger/ledger.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 8f22f6e

Please sign in to comment.