From 90d02f8455c1ba5658456929a6f0b59839d39953 Mon Sep 17 00:00:00 2001 From: Philipp Gackstatter Date: Mon, 4 Dec 2023 15:46:20 +0100 Subject: [PATCH 1/5] Bump iota.go version --- 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 f24b5f54c..26bcb4b67 100644 --- a/go.mod +++ b/go.mod @@ -25,7 +25,7 @@ require ( github.com/iotaledger/hive.go/stringify v0.0.0-20231128121006-331a9e522dfe github.com/iotaledger/inx-app v1.0.0-rc.3.0.20231201123347-1c44b3f24221 github.com/iotaledger/inx/go v1.0.0-rc.2.0.20231201114846-3bb5c3fd5665 - github.com/iotaledger/iota.go/v4 v4.0.0-20231201114738-56b50084ab22 + github.com/iotaledger/iota.go/v4 v4.0.0-20231204142547-416c9a87403d github.com/labstack/echo/v4 v4.11.3 github.com/labstack/gommon v0.4.1 github.com/libp2p/go-libp2p v0.32.0 diff --git a/go.sum b/go.sum index d65c68ff1..2a1ecbf91 100644 --- a/go.sum +++ b/go.sum @@ -307,8 +307,8 @@ github.com/iotaledger/inx-app v1.0.0-rc.3.0.20231201123347-1c44b3f24221 h1:+ozra github.com/iotaledger/inx-app v1.0.0-rc.3.0.20231201123347-1c44b3f24221/go.mod h1:6cLX3gnhP0WL+Q+mf3/rIqfACe5fWKVR8luPXWh2xiY= github.com/iotaledger/inx/go v1.0.0-rc.2.0.20231201114846-3bb5c3fd5665 h1:XdhojOpZ0t0pJFyNO0zlBogSAUrhEI67eCpTC9H6sGM= github.com/iotaledger/inx/go v1.0.0-rc.2.0.20231201114846-3bb5c3fd5665/go.mod h1:obK1N42oafGA7EH6zC4VX2fKh7jTa3WnIa9h1azfxq0= -github.com/iotaledger/iota.go/v4 v4.0.0-20231201114738-56b50084ab22 h1:awGSiqmM1pYF+e+uILNQAiiNXrirU/mTYmUf4f/wVac= -github.com/iotaledger/iota.go/v4 v4.0.0-20231201114738-56b50084ab22/go.mod h1:aO+5iL0vTNwNfE4QMGHVIufGziSI1wTvwJY1ipSMgCk= +github.com/iotaledger/iota.go/v4 v4.0.0-20231204142547-416c9a87403d h1:MPklxa8jW4/EgDm/LEzf6orxjik7U+vMUW/ToGT1Zqg= +github.com/iotaledger/iota.go/v4 v4.0.0-20231204142547-416c9a87403d/go.mod h1:lCk9rhP3B5pX9BKhzR+Jobq4xPd+GHlqgF4Ga+eQfWA= 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 d93bf4c5e..0cd85a09e 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-20231128121006-331a9e522dfe // indirect github.com/iotaledger/inx-app v1.0.0-rc.3.0.20231201123347-1c44b3f24221 // indirect github.com/iotaledger/inx/go v1.0.0-rc.2.0.20231201114846-3bb5c3fd5665 // indirect - github.com/iotaledger/iota.go/v4 v4.0.0-20231201114738-56b50084ab22 // indirect + github.com/iotaledger/iota.go/v4 v4.0.0-20231204142547-416c9a87403d // 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 1208a30b0..547b95422 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.20231201123347-1c44b3f24221 h1:+ozra github.com/iotaledger/inx-app v1.0.0-rc.3.0.20231201123347-1c44b3f24221/go.mod h1:6cLX3gnhP0WL+Q+mf3/rIqfACe5fWKVR8luPXWh2xiY= github.com/iotaledger/inx/go v1.0.0-rc.2.0.20231201114846-3bb5c3fd5665 h1:XdhojOpZ0t0pJFyNO0zlBogSAUrhEI67eCpTC9H6sGM= github.com/iotaledger/inx/go v1.0.0-rc.2.0.20231201114846-3bb5c3fd5665/go.mod h1:obK1N42oafGA7EH6zC4VX2fKh7jTa3WnIa9h1azfxq0= -github.com/iotaledger/iota.go/v4 v4.0.0-20231201114738-56b50084ab22 h1:awGSiqmM1pYF+e+uILNQAiiNXrirU/mTYmUf4f/wVac= -github.com/iotaledger/iota.go/v4 v4.0.0-20231201114738-56b50084ab22/go.mod h1:aO+5iL0vTNwNfE4QMGHVIufGziSI1wTvwJY1ipSMgCk= +github.com/iotaledger/iota.go/v4 v4.0.0-20231204142547-416c9a87403d h1:MPklxa8jW4/EgDm/LEzf6orxjik7U+vMUW/ToGT1Zqg= +github.com/iotaledger/iota.go/v4 v4.0.0-20231204142547-416c9a87403d/go.mod h1:lCk9rhP3B5pX9BKhzR+Jobq4xPd+GHlqgF4Ga+eQfWA= 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 aa2165797..cf0ca6379 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-20231128121006-331a9e522dfe github.com/iotaledger/hive.go/runtime v0.0.0-20231128121006-331a9e522dfe github.com/iotaledger/iota-core v0.0.0-00010101000000-000000000000 - github.com/iotaledger/iota.go/v4 v4.0.0-20231201114738-56b50084ab22 + github.com/iotaledger/iota.go/v4 v4.0.0-20231204142547-416c9a87403d github.com/mr-tron/base58 v1.2.0 github.com/spf13/pflag v1.0.5 golang.org/x/crypto v0.16.0 diff --git a/tools/genesis-snapshot/go.sum b/tools/genesis-snapshot/go.sum index 138a2d62f..a98c8bbec 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.20231127134220-90b88e3 github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20231127134220-90b88e35bdb2/go.mod h1:FoH3T6yKlZJp8xm8K+zsQiibSynp32v21CpWx8xkek8= github.com/iotaledger/hive.go/stringify v0.0.0-20231128121006-331a9e522dfe h1:RcFUqhnJ+86+sA0XMrZ0q+086ULrdWQkWrjUt2OnJK4= github.com/iotaledger/hive.go/stringify v0.0.0-20231128121006-331a9e522dfe/go.mod h1:FTo/UWzNYgnQ082GI9QVM9HFDERqf9rw9RivNpqrnTs= -github.com/iotaledger/iota.go/v4 v4.0.0-20231201114738-56b50084ab22 h1:awGSiqmM1pYF+e+uILNQAiiNXrirU/mTYmUf4f/wVac= -github.com/iotaledger/iota.go/v4 v4.0.0-20231201114738-56b50084ab22/go.mod h1:aO+5iL0vTNwNfE4QMGHVIufGziSI1wTvwJY1ipSMgCk= +github.com/iotaledger/iota.go/v4 v4.0.0-20231204142547-416c9a87403d h1:MPklxa8jW4/EgDm/LEzf6orxjik7U+vMUW/ToGT1Zqg= +github.com/iotaledger/iota.go/v4 v4.0.0-20231204142547-416c9a87403d/go.mod h1:lCk9rhP3B5pX9BKhzR+Jobq4xPd+GHlqgF4Ga+eQfWA= 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 bbbe901f1d172bdbd6557dd058cbe388d1a0a93a Mon Sep 17 00:00:00 2001 From: Philipp Gackstatter Date: Mon, 4 Dec 2023 15:46:27 +0100 Subject: [PATCH 2/5] Adapt to renamed mana decay provider functions --- .../engine/accounts/accountsledger/manager.go | 4 ++-- pkg/protocol/engine/accounts/mana/manager.go | 14 ++++++------- .../engine/accounts/mana/manager_test.go | 20 +++++++++---------- .../sybilprotectionv1/performance/rewards.go | 4 ++-- .../performance/testsuite_test.go | 4 ++-- pkg/testsuite/mock/wallet_transactions.go | 4 ++-- 6 files changed, 25 insertions(+), 25 deletions(-) diff --git a/pkg/protocol/engine/accounts/accountsledger/manager.go b/pkg/protocol/engine/accounts/accountsledger/manager.go index dbdb75e1f..2b63a92e5 100644 --- a/pkg/protocol/engine/accounts/accountsledger/manager.go +++ b/pkg/protocol/engine/accounts/accountsledger/manager.go @@ -490,7 +490,7 @@ func (m *Manager) computeBlockBurnsForSlot(slot iotago.SlotIndex, rmc iotago.Man return nil, ierrors.Wrapf(err, "cannot compute penalty for over-issuing validator, account %s could not be retrieved", accountID) } punishmentEpochs := apiForSlot.ProtocolParameters().PunishmentEpochs() - manaPunishment, err := apiForSlot.ManaDecayProvider().ManaGenerationWithDecay(accountData.ValidatorStake, slot, slot+apiForSlot.TimeProvider().EpochDurationSlots()*iotago.SlotIndex(punishmentEpochs)) + manaPunishment, err := apiForSlot.ManaDecayProvider().GenerateManaAndDecayBySlots(accountData.ValidatorStake, slot, slot+apiForSlot.TimeProvider().EpochDurationSlots()*iotago.SlotIndex(punishmentEpochs)) if err != nil { return nil, ierrors.Wrapf(err, "cannot compute penalty for over-issuing validator with account ID %s due to problem with mana generation", accountID) } @@ -526,7 +526,7 @@ func (m *Manager) commitAccountTree(slot iotago.SlotIndex, accountDiffChanges ma if diffChange.BICChange != 0 || !exists { // decay the credits to the current slot if the account exists if exists { - decayedPreviousCredits, err := m.apiProvider.APIForSlot(slot).ManaDecayProvider().ManaWithDecay(iotago.Mana(accountData.Credits.Value), accountData.Credits.UpdateSlot, slot) + decayedPreviousCredits, err := m.apiProvider.APIForSlot(slot).ManaDecayProvider().DecayManaBySlots(iotago.Mana(accountData.Credits.Value), accountData.Credits.UpdateSlot, slot) if err != nil { return ierrors.Wrapf(err, "can't retrieve account, could not decay credits for account (%s) in slot (%d)", accountData.ID, slot) } diff --git a/pkg/protocol/engine/accounts/mana/manager.go b/pkg/protocol/engine/accounts/mana/manager.go index d9c6ae32f..d140dddbc 100644 --- a/pkg/protocol/engine/accounts/mana/manager.go +++ b/pkg/protocol/engine/accounts/mana/manager.go @@ -79,24 +79,24 @@ func (m *Manager) GetManaOnAccount(accountID iotago.AccountID, slot iotago.SlotI // Apply decay to stored, potential and BIC mana that was calculated when adding the entry to cache // so that it's correct for the requested slot. - manaWithDecay, err := manaDecayProvider.ManaWithDecay(mana.Value(), mana.UpdateTime(), slot) + DecayManaBySlots, err := manaDecayProvider.DecayManaBySlots(mana.Value(), mana.UpdateTime(), slot) if err != nil { return 0, err } // Calculate newly generated potential mana since last update time. - manaPotential, err := manaDecayProvider.ManaGenerationWithDecay(mana.ExcessBaseTokens(), mana.UpdateTime(), slot) + manaPotential, err := manaDecayProvider.GenerateManaAndDecayBySlots(mana.ExcessBaseTokens(), mana.UpdateTime(), slot) if err != nil { return 0, err } // Add potential mana to the decayed mana. - manaWithDecayAndGeneration, err := safemath.SafeAdd(manaWithDecay, manaPotential) + DecayManaBySlotsAndGeneration, err := safemath.SafeAdd(DecayManaBySlots, manaPotential) if err != nil { return 0, ierrors.Wrapf(err, "overflow when adding stored and potential mana for account %s", accountID) } - return manaWithDecayAndGeneration, nil + return DecayManaBySlotsAndGeneration, nil } func (m *Manager) getMana(accountID iotago.AccountID, output *utxoledger.Output, slot iotago.SlotIndex) (*accounts.Mana, error) { @@ -124,12 +124,12 @@ func (m *Manager) getMana(accountID iotago.AccountID, output *utxoledger.Output, var manaUpdateTime iotago.SlotIndex var totalMana iotago.Mana if bicUpdateTime > output.SlotCreated() { - manaPotential, err := manaDecayProvider.ManaGenerationWithDecay(excessBaseTokens, output.SlotCreated(), bicUpdateTime) + manaPotential, err := manaDecayProvider.GenerateManaAndDecayBySlots(excessBaseTokens, output.SlotCreated(), bicUpdateTime) if err != nil { return nil, ierrors.Wrapf(err, "failed to calculate mana generation with decay (excessBaseTokens: %d; outputSlotCreated: %d; targetSlot: %d)", excessBaseTokens, output.SlotCreated(), bicUpdateTime) } - manaStored, err := manaDecayProvider.ManaWithDecay(output.StoredMana(), output.SlotCreated(), bicUpdateTime) + manaStored, err := manaDecayProvider.DecayManaBySlots(output.StoredMana(), output.SlotCreated(), bicUpdateTime) if err != nil { return nil, ierrors.Wrapf(err, "failed to calculate mana with decay (storedMana: %d; outputSlotCreated: %d; targetSlot: %d)", output.StoredMana(), output.SlotCreated(), bicUpdateTime) } @@ -147,7 +147,7 @@ func (m *Manager) getMana(accountID iotago.AccountID, output *utxoledger.Output, manaUpdateTime = bicUpdateTime } else if output.SlotCreated() > bicUpdateTime { // Decay BIC to match the Output creation time. - bicWithDecay, err := manaDecayProvider.ManaWithDecay(bic, bicUpdateTime, output.SlotCreated()) + bicWithDecay, err := manaDecayProvider.DecayManaBySlots(bic, bicUpdateTime, output.SlotCreated()) if err != nil { return nil, err } diff --git a/pkg/protocol/engine/accounts/mana/manager_test.go b/pkg/protocol/engine/accounts/mana/manager_test.go index 62301750c..1951737f7 100644 --- a/pkg/protocol/engine/accounts/mana/manager_test.go +++ b/pkg/protocol/engine/accounts/mana/manager_test.go @@ -133,10 +133,10 @@ func TestManager_GetManaOnAccountOverflow(t *testing.T) { mana, err := manager.GetManaOnAccount(accountIDValid, 1) require.NoError(t, err) - decayedMana, err := manaDecayProvider.ManaWithDecay(iotago.MaxMana/2+iotago.Mana(iotago.MaxBlockIssuanceCredits/2+iotago.MaxBlockIssuanceCredits/4), 0, 1) + decayedMana, err := manaDecayProvider.DecayManaBySlots(iotago.MaxMana/2+iotago.Mana(iotago.MaxBlockIssuanceCredits/2+iotago.MaxBlockIssuanceCredits/4), 0, 1) require.NoError(t, err) - generatedMana, err := manaDecayProvider.ManaGenerationWithDecay(iotago.MaxBaseToken/2, 0, 1) + generatedMana, err := manaDecayProvider.GenerateManaAndDecayBySlots(iotago.MaxBaseToken/2, 0, 1) require.NoError(t, err) require.EqualValues(t, decayedMana+generatedMana, mana) @@ -153,17 +153,17 @@ func TestManager_GetManaOnAccountOverflow(t *testing.T) { mana, err := manager.GetManaOnAccount(accountIDRecentOutput, 2) require.NoError(t, err) - decayedStoredMana, err := manaDecayProvider.ManaWithDecay(iotago.MaxMana/2, 1, 2) + decayedStoredMana, err := manaDecayProvider.DecayManaBySlots(iotago.MaxMana/2, 1, 2) require.NoError(t, err) - decayedBIC2Slots, err := manaDecayProvider.ManaWithDecay(iotago.Mana(iotago.MaxBlockIssuanceCredits/2+iotago.MaxBlockIssuanceCredits/4), 0, 2) + decayedBIC2Slots, err := manaDecayProvider.DecayManaBySlots(iotago.Mana(iotago.MaxBlockIssuanceCredits/2+iotago.MaxBlockIssuanceCredits/4), 0, 2) require.NoError(t, err) - generatedMana, err := manaDecayProvider.ManaGenerationWithDecay(iotago.MaxBaseToken/2, 1, 2) + generatedMana, err := manaDecayProvider.GenerateManaAndDecayBySlots(iotago.MaxBaseToken/2, 1, 2) require.NoError(t, err) require.EqualValues(t, decayedBIC2Slots+decayedStoredMana+generatedMana, mana) - decayedBIC1Slot, err := manaDecayProvider.ManaWithDecay(iotago.Mana(iotago.MaxBlockIssuanceCredits/2+iotago.MaxBlockIssuanceCredits/4), 0, 2) + decayedBIC1Slot, err := manaDecayProvider.DecayManaBySlots(iotago.Mana(iotago.MaxBlockIssuanceCredits/2+iotago.MaxBlockIssuanceCredits/4), 0, 2) require.NoError(t, err) // Make sure that cache entry is for slot 1. @@ -178,20 +178,20 @@ func TestManager_GetManaOnAccountOverflow(t *testing.T) { mana, err := manager.GetManaOnAccount(accountIDRecentBIC, 2) require.NoError(t, err) - decayedStoredMana2Slots, err := manaDecayProvider.ManaWithDecay(iotago.MaxMana/2, 0, 0) + decayedStoredMana2Slots, err := manaDecayProvider.DecayManaBySlots(iotago.MaxMana/2, 0, 0) require.NoError(t, err) - generatedMana1Slot, err := manaDecayProvider.ManaGenerationWithDecay(iotago.MaxBaseToken/2, 0, 1) + generatedMana1Slot, err := manaDecayProvider.GenerateManaAndDecayBySlots(iotago.MaxBaseToken/2, 0, 1) require.NoError(t, err) - decayedBIC, err := manaDecayProvider.ManaWithDecay(iotago.Mana(iotago.MaxBlockIssuanceCredits/2+iotago.MaxBlockIssuanceCredits/4), 1, 1) + decayedBIC, err := manaDecayProvider.DecayManaBySlots(iotago.Mana(iotago.MaxBlockIssuanceCredits/2+iotago.MaxBlockIssuanceCredits/4), 1, 1) require.NoError(t, err) // generatedMana1Slot is multiplied to calculate generation for two slots. It cannot be done in a single step // because the value does not match due to approximation errors inherent to the underlying calculation method. require.EqualValues(t, decayedStoredMana2Slots+generatedMana1Slot*2+decayedBIC, mana) - decayedStoredMana1Slot, err := manaDecayProvider.ManaWithDecay(iotago.MaxMana/2, 0, 1) + decayedStoredMana1Slot, err := manaDecayProvider.DecayManaBySlots(iotago.MaxMana/2, 0, 1) require.NoError(t, err) // Make sure that cache entry is for slot 1. diff --git a/pkg/protocol/sybilprotection/sybilprotectionv1/performance/rewards.go b/pkg/protocol/sybilprotection/sybilprotectionv1/performance/rewards.go index 73df3dab9..31d13e58d 100644 --- a/pkg/protocol/sybilprotection/sybilprotectionv1/performance/rewards.go +++ b/pkg/protocol/sybilprotection/sybilprotectionv1/performance/rewards.go @@ -95,7 +95,7 @@ func (t *Tracker) ValidatorReward(validatorID iotago.AccountID, stakeAmount iota } decayProvider := t.apiProvider.APIForEpoch(epoch).ManaDecayProvider() - decayedEpochRewards, err := decayProvider.RewardsWithDecay(iotago.Mana(unDecayedEpochRewards), epoch, epochEnd) + decayedEpochRewards, err := decayProvider.DecayManaByEpochs(iotago.Mana(unDecayedEpochRewards), epoch, epochEnd) if err != nil { return 0, 0, 0, ierrors.Wrapf(err, "failed to calculate rewards with decay for epoch %d and validator accountID %s", epoch, validatorID) } @@ -172,7 +172,7 @@ func (t *Tracker) DelegatorReward(validatorID iotago.AccountID, delegatedAmount } decayProvider := t.apiProvider.APIForEpoch(epoch).ManaDecayProvider() - decayedEpochRewards, err := decayProvider.RewardsWithDecay(iotago.Mana(unDecayedEpochRewards), epoch, epochEnd) + decayedEpochRewards, err := decayProvider.DecayManaByEpochs(iotago.Mana(unDecayedEpochRewards), epoch, epochEnd) if err != nil { return 0, 0, 0, ierrors.Wrapf(err, "failed to calculate rewards with decay for epoch %d and validator accountID %s", epoch, validatorID) } diff --git a/pkg/protocol/sybilprotection/sybilprotectionv1/performance/testsuite_test.go b/pkg/protocol/sybilprotection/sybilprotectionv1/performance/testsuite_test.go index c79086778..d27730805 100644 --- a/pkg/protocol/sybilprotection/sybilprotectionv1/performance/testsuite_test.go +++ b/pkg/protocol/sybilprotection/sybilprotectionv1/performance/testsuite_test.go @@ -229,7 +229,7 @@ func (t *TestSuite) validatorReward(alias string, epoch iotago.EpochIndex, profi residualValidatorFactor := ((profitMarginComplement * poolRewardsNoFixedCost) >> profitMarginExponent) * stakeAmount / poolStake unDecayedEpochRewards := fixedCost + profitMarginFactor + residualValidatorFactor decayProvider := t.api.ManaDecayProvider() - decayedEpochRewards, err := decayProvider.RewardsWithDecay(iotago.Mana(unDecayedEpochRewards), epoch, epoch) + decayedEpochRewards, err := decayProvider.DecayManaByEpochs(iotago.Mana(unDecayedEpochRewards), epoch, epoch) require.NoError(t.T, err) return decayedEpochRewards @@ -250,7 +250,7 @@ func (t *TestSuite) delegatorReward(epoch iotago.EpochIndex, profitMargin, poolR unDecayedEpochRewards := (((profitMarginComplement * poolRewards) >> profitMarginExponent) * delegatedAmount) / poolStake decayProvider := t.api.ManaDecayProvider() - decayedEpochRewards, err := decayProvider.RewardsWithDecay(iotago.Mana(unDecayedEpochRewards), epoch, epoch) + decayedEpochRewards, err := decayProvider.DecayManaByEpochs(iotago.Mana(unDecayedEpochRewards), epoch, epoch) require.NoError(t.T, err) return decayedEpochRewards diff --git a/pkg/testsuite/mock/wallet_transactions.go b/pkg/testsuite/mock/wallet_transactions.go index 36b70e4bd..f15219ffc 100644 --- a/pkg/testsuite/mock/wallet_transactions.go +++ b/pkg/testsuite/mock/wallet_transactions.go @@ -557,12 +557,12 @@ func (w *Wallet) PotentialMana(api iotago.API, input *utxoledger.Output) iotago. excessBaseTokens := input.BaseTokenAmount() - minDeposit - return lo.PanicOnErr(api.ManaDecayProvider().ManaGenerationWithDecay(excessBaseTokens, input.SlotCreated(), w.currentSlot)) + return lo.PanicOnErr(api.ManaDecayProvider().GenerateManaAndDecayBySlots(excessBaseTokens, input.SlotCreated(), w.currentSlot)) } // Computes the decay on stored mana that the output holds until the current slot. func (w *Wallet) StoredMana(api iotago.API, input *utxoledger.Output) iotago.Mana { - return lo.PanicOnErr(api.ManaDecayProvider().ManaWithDecay(input.StoredMana(), input.SlotCreated(), w.currentSlot)) + return lo.PanicOnErr(api.ManaDecayProvider().DecayManaBySlots(input.StoredMana(), input.SlotCreated(), w.currentSlot)) } func (w *Wallet) AllotManaToWallet(transactionName string, inputName string, recipientWallet *Wallet) *iotago.SignedTransaction { From 88e08a6d532c45592eee987a39291506b90664c2 Mon Sep 17 00:00:00 2001 From: Philipp Gackstatter Date: Mon, 4 Dec 2023 16:04:55 +0100 Subject: [PATCH 3/5] Use Potential Mana func from iotago --- pkg/testsuite/mock/wallet_transactions.go | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/pkg/testsuite/mock/wallet_transactions.go b/pkg/testsuite/mock/wallet_transactions.go index f15219ffc..f39e400ff 100644 --- a/pkg/testsuite/mock/wallet_transactions.go +++ b/pkg/testsuite/mock/wallet_transactions.go @@ -549,15 +549,7 @@ func (w *Wallet) ClaimDelegatorRewards(transactionName string, inputName string) // Computes the Potential Mana that the output generates until the current slot. func (w *Wallet) PotentialMana(api iotago.API, input *utxoledger.Output) iotago.Mana { - minDeposit := lo.PanicOnErr(api.StorageScoreStructure().MinDeposit(input.Output())) - - if minDeposit > input.BaseTokenAmount() { - return 0 - } - - excessBaseTokens := input.BaseTokenAmount() - minDeposit - - return lo.PanicOnErr(api.ManaDecayProvider().GenerateManaAndDecayBySlots(excessBaseTokens, input.SlotCreated(), w.currentSlot)) + return lo.PanicOnErr(iotago.PotentialMana(api.ManaDecayProvider(), api.StorageScoreStructure(), input.Output(), input.SlotCreated(), w.currentSlot)) } // Computes the decay on stored mana that the output holds until the current slot. From 32e701c34ba077f47352e1adcdeefe16b1ca4494 Mon Sep 17 00:00:00 2001 From: Philipp Gackstatter Date: Tue, 5 Dec 2023 09:01:48 +0100 Subject: [PATCH 4/5] Revert unintended variable name changes --- pkg/protocol/engine/accounts/mana/manager.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/protocol/engine/accounts/mana/manager.go b/pkg/protocol/engine/accounts/mana/manager.go index d140dddbc..8716d1d2b 100644 --- a/pkg/protocol/engine/accounts/mana/manager.go +++ b/pkg/protocol/engine/accounts/mana/manager.go @@ -79,7 +79,7 @@ func (m *Manager) GetManaOnAccount(accountID iotago.AccountID, slot iotago.SlotI // Apply decay to stored, potential and BIC mana that was calculated when adding the entry to cache // so that it's correct for the requested slot. - DecayManaBySlots, err := manaDecayProvider.DecayManaBySlots(mana.Value(), mana.UpdateTime(), slot) + manaWithDecay, err := manaDecayProvider.DecayManaBySlots(mana.Value(), mana.UpdateTime(), slot) if err != nil { return 0, err } @@ -91,12 +91,12 @@ func (m *Manager) GetManaOnAccount(accountID iotago.AccountID, slot iotago.SlotI } // Add potential mana to the decayed mana. - DecayManaBySlotsAndGeneration, err := safemath.SafeAdd(DecayManaBySlots, manaPotential) + manaWithDecayAndGeneration, err := safemath.SafeAdd(manaWithDecay, manaPotential) if err != nil { return 0, ierrors.Wrapf(err, "overflow when adding stored and potential mana for account %s", accountID) } - return DecayManaBySlotsAndGeneration, nil + return manaWithDecayAndGeneration, nil } func (m *Manager) getMana(accountID iotago.AccountID, output *utxoledger.Output, slot iotago.SlotIndex) (*accounts.Mana, error) { From 3c9b3e60cbbd0c30bed885749f2be4c946ed7730 Mon Sep 17 00:00:00 2001 From: Philipp Gackstatter Date: Tue, 5 Dec 2023 09:04:35 +0100 Subject: [PATCH 5/5] Bump iota.go version --- 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 256f3d414..89c8f04ec 100644 --- a/go.mod +++ b/go.mod @@ -25,7 +25,7 @@ require ( github.com/iotaledger/hive.go/stringify v0.0.0-20231128121006-331a9e522dfe github.com/iotaledger/inx-app v1.0.0-rc.3.0.20231201123347-1c44b3f24221 github.com/iotaledger/inx/go v1.0.0-rc.2.0.20231201114846-3bb5c3fd5665 - github.com/iotaledger/iota.go/v4 v4.0.0-20231204084048-9c12053adaf6 + github.com/iotaledger/iota.go/v4 v4.0.0-20231204142547-416c9a87403d github.com/labstack/echo/v4 v4.11.3 github.com/labstack/gommon v0.4.1 github.com/libp2p/go-libp2p v0.32.0 diff --git a/go.sum b/go.sum index 947972092..2a1ecbf91 100644 --- a/go.sum +++ b/go.sum @@ -307,8 +307,8 @@ github.com/iotaledger/inx-app v1.0.0-rc.3.0.20231201123347-1c44b3f24221 h1:+ozra github.com/iotaledger/inx-app v1.0.0-rc.3.0.20231201123347-1c44b3f24221/go.mod h1:6cLX3gnhP0WL+Q+mf3/rIqfACe5fWKVR8luPXWh2xiY= github.com/iotaledger/inx/go v1.0.0-rc.2.0.20231201114846-3bb5c3fd5665 h1:XdhojOpZ0t0pJFyNO0zlBogSAUrhEI67eCpTC9H6sGM= github.com/iotaledger/inx/go v1.0.0-rc.2.0.20231201114846-3bb5c3fd5665/go.mod h1:obK1N42oafGA7EH6zC4VX2fKh7jTa3WnIa9h1azfxq0= -github.com/iotaledger/iota.go/v4 v4.0.0-20231204084048-9c12053adaf6 h1:Wuf8Ps3tzuZ5CCbl7LA5O2qwhfuXWo30RCOT0yhm4pg= -github.com/iotaledger/iota.go/v4 v4.0.0-20231204084048-9c12053adaf6/go.mod h1:lCk9rhP3B5pX9BKhzR+Jobq4xPd+GHlqgF4Ga+eQfWA= +github.com/iotaledger/iota.go/v4 v4.0.0-20231204142547-416c9a87403d h1:MPklxa8jW4/EgDm/LEzf6orxjik7U+vMUW/ToGT1Zqg= +github.com/iotaledger/iota.go/v4 v4.0.0-20231204142547-416c9a87403d/go.mod h1:lCk9rhP3B5pX9BKhzR+Jobq4xPd+GHlqgF4Ga+eQfWA= 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 ee1992d2c..0cd85a09e 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-20231128121006-331a9e522dfe // indirect github.com/iotaledger/inx-app v1.0.0-rc.3.0.20231201123347-1c44b3f24221 // indirect github.com/iotaledger/inx/go v1.0.0-rc.2.0.20231201114846-3bb5c3fd5665 // indirect - github.com/iotaledger/iota.go/v4 v4.0.0-20231204084048-9c12053adaf6 // indirect + github.com/iotaledger/iota.go/v4 v4.0.0-20231204142547-416c9a87403d // 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 734814b2e..547b95422 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.20231201123347-1c44b3f24221 h1:+ozra github.com/iotaledger/inx-app v1.0.0-rc.3.0.20231201123347-1c44b3f24221/go.mod h1:6cLX3gnhP0WL+Q+mf3/rIqfACe5fWKVR8luPXWh2xiY= github.com/iotaledger/inx/go v1.0.0-rc.2.0.20231201114846-3bb5c3fd5665 h1:XdhojOpZ0t0pJFyNO0zlBogSAUrhEI67eCpTC9H6sGM= github.com/iotaledger/inx/go v1.0.0-rc.2.0.20231201114846-3bb5c3fd5665/go.mod h1:obK1N42oafGA7EH6zC4VX2fKh7jTa3WnIa9h1azfxq0= -github.com/iotaledger/iota.go/v4 v4.0.0-20231204084048-9c12053adaf6 h1:Wuf8Ps3tzuZ5CCbl7LA5O2qwhfuXWo30RCOT0yhm4pg= -github.com/iotaledger/iota.go/v4 v4.0.0-20231204084048-9c12053adaf6/go.mod h1:lCk9rhP3B5pX9BKhzR+Jobq4xPd+GHlqgF4Ga+eQfWA= +github.com/iotaledger/iota.go/v4 v4.0.0-20231204142547-416c9a87403d h1:MPklxa8jW4/EgDm/LEzf6orxjik7U+vMUW/ToGT1Zqg= +github.com/iotaledger/iota.go/v4 v4.0.0-20231204142547-416c9a87403d/go.mod h1:lCk9rhP3B5pX9BKhzR+Jobq4xPd+GHlqgF4Ga+eQfWA= 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 416b59558..3514c522b 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-20231128121006-331a9e522dfe github.com/iotaledger/hive.go/runtime v0.0.0-20231128121006-331a9e522dfe github.com/iotaledger/iota-core v0.0.0-00010101000000-000000000000 - github.com/iotaledger/iota.go/v4 v4.0.0-20231204084048-9c12053adaf6 + github.com/iotaledger/iota.go/v4 v4.0.0-20231204142547-416c9a87403d github.com/mr-tron/base58 v1.2.0 github.com/spf13/pflag v1.0.5 golang.org/x/crypto v0.16.0 diff --git a/tools/genesis-snapshot/go.sum b/tools/genesis-snapshot/go.sum index 30c064306..9374066ac 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.20231127134220-90b88e3 github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20231127134220-90b88e35bdb2/go.mod h1:FoH3T6yKlZJp8xm8K+zsQiibSynp32v21CpWx8xkek8= github.com/iotaledger/hive.go/stringify v0.0.0-20231128121006-331a9e522dfe h1:RcFUqhnJ+86+sA0XMrZ0q+086ULrdWQkWrjUt2OnJK4= github.com/iotaledger/hive.go/stringify v0.0.0-20231128121006-331a9e522dfe/go.mod h1:FTo/UWzNYgnQ082GI9QVM9HFDERqf9rw9RivNpqrnTs= -github.com/iotaledger/iota.go/v4 v4.0.0-20231204084048-9c12053adaf6 h1:Wuf8Ps3tzuZ5CCbl7LA5O2qwhfuXWo30RCOT0yhm4pg= -github.com/iotaledger/iota.go/v4 v4.0.0-20231204084048-9c12053adaf6/go.mod h1:lCk9rhP3B5pX9BKhzR+Jobq4xPd+GHlqgF4Ga+eQfWA= +github.com/iotaledger/iota.go/v4 v4.0.0-20231204142547-416c9a87403d h1:MPklxa8jW4/EgDm/LEzf6orxjik7U+vMUW/ToGT1Zqg= +github.com/iotaledger/iota.go/v4 v4.0.0-20231204142547-416c9a87403d/go.mod h1:lCk9rhP3B5pX9BKhzR+Jobq4xPd+GHlqgF4Ga+eQfWA= 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=