From ffff58c1c9c47bb45f4bde37464fea08a009cd6c Mon Sep 17 00:00:00 2001 From: muXxer Date: Thu, 23 Nov 2023 15:17:46 +0100 Subject: [PATCH 1/6] Fix calculation of preset values --- pkg/tests/accounts_test.go | 19 +- pkg/tests/upgrade_signaling_test.go | 12 +- pkg/testsuite/mock/utils.go | 67 +++- pkg/testsuite/mock/wallet.go | 2 + pkg/testsuite/mock/wallet_transactions.go | 12 +- pkg/testsuite/testsuite.go | 94 ++--- tools/genesis-snapshot/presets/presets.go | 446 +++++++++++----------- 7 files changed, 361 insertions(+), 291 deletions(-) diff --git a/pkg/tests/accounts_test.go b/pkg/tests/accounts_test.go index 2dac11fcc..15b7963fd 100644 --- a/pkg/tests/accounts_test.go +++ b/pkg/tests/accounts_test.go @@ -19,11 +19,14 @@ import ( func Test_TransitionAndDestroyAccount(t *testing.T) { oldGenesisOutputKey := utils.RandBlockIssuerKey() + // TODO: remove this ugly workaround + dummyParameters := iotago.NewV3ProtocolParameters(testsuite.DefaultProtocolParameterOptions("dummy")...) + ts := testsuite.NewTestSuite(t, testsuite.WithAccounts(snapshotcreator.AccountDetails{ // Nil address will be replaced with the address generated from genesis seed. Address: nil, // Set an amount enough to cover storage deposit and more issuer keys. - Amount: mock.MinIssuerAccountAmount * 10, + Amount: mock.MinIssuerAccountAmount(dummyParameters) * 10, Mana: 0, // AccountID is derived from this field, so this must be set uniquely for each account. IssuerKey: oldGenesisOutputKey, @@ -79,7 +82,7 @@ func Test_TransitionAndDestroyAccount(t *testing.T) { ExpirySlot: iotago.MaxSlotIndex, BlockIssuerKeys: node1.Validator.BlockIssuerKeys(), StakeEndEpoch: iotago.MaxEpochIndex, - ValidatorStake: mock.MinValidatorAccountAmount, + ValidatorStake: mock.MinValidatorAccountAmount(ts.API.ProtocolParameters()), }, ts.Nodes()...) // default wallet block issuer account. blockIssuerAccountOutput := ts.AccountOutput("Genesis:3") @@ -198,7 +201,7 @@ func Test_StakeDelegateAndDelayedClaim(t *testing.T) { ExpirySlot: iotago.MaxSlotIndex, BlockIssuerKeys: node1.Validator.BlockIssuerKeys(), StakeEndEpoch: iotago.MaxEpochIndex, - ValidatorStake: mock.MinValidatorAccountAmount, + ValidatorStake: mock.MinValidatorAccountAmount(ts.API.ProtocolParameters()), }, ts.Nodes()...) // Default wallet block issuer account. blockIssuerAccountOutput := ts.AccountOutput("Genesis:2") @@ -222,7 +225,7 @@ func Test_StakeDelegateAndDelayedClaim(t *testing.T) { ts.DefaultWallet(), mock.WithBlockIssuerFeature(iotago.BlockIssuerKeys{newAccountBlockIssuerKey}, newAccountExpirySlot), mock.WithStakingFeature(10000, 421, 0, 10), - mock.WithAccountAmount(mock.MinIssuerAccountAmount), + mock.WithAccountAmount(mock.MinIssuerAccountAmount(ts.API.ProtocolParameters())), ) genesisCommitment := iotago.NewEmptyCommitment(ts.API) @@ -373,7 +376,7 @@ func Test_ImplicitAccounts(t *testing.T) { ExpirySlot: iotago.MaxSlotIndex, BlockIssuerKeys: node1.Validator.BlockIssuerKeys(), StakeEndEpoch: iotago.MaxEpochIndex, - ValidatorStake: mock.MinValidatorAccountAmount, + ValidatorStake: mock.MinValidatorAccountAmount(ts.API.ProtocolParameters()), }, ts.Nodes()...) // default wallet block issuer account. blockIssuerAccountOutput := ts.AccountOutput("Genesis:2") @@ -424,7 +427,7 @@ func Test_ImplicitAccounts(t *testing.T) { iotago.BlockIssuerKeys{fullAccountBlockIssuerKey}, iotago.MaxSlotIndex, ), - mock.WithAccountAmount(mock.MinIssuerAccountAmount), + mock.WithAccountAmount(mock.MinIssuerAccountAmount(ts.API.ProtocolParameters())), ) block2Commitment := node1.Protocol.MainEngineInstance().Storage.Settings().LatestCommitment().Commitment() block2 := ts.IssueBasicBlockWithOptions("block2", newUserWallet, tx2, mock.WithStrongParents(latestParents...)) @@ -695,7 +698,7 @@ func Test_NegativeBIC_AccountOutput(t *testing.T) { ExpirySlot: iotago.MaxSlotIndex, BlockIssuerKeys: node1.Validator.BlockIssuerKeys(), StakeEndEpoch: iotago.MaxEpochIndex, - ValidatorStake: mock.MinValidatorAccountAmount, + ValidatorStake: mock.MinValidatorAccountAmount(ts.API.ProtocolParameters()), }, ts.Nodes()...) // default wallet block issuer account. wallet1AccountOutput := ts.AccountOutput("Genesis:2") @@ -909,7 +912,7 @@ func Test_NegativeBIC_AccountOwnedBasicOutputLocked(t *testing.T) { ExpirySlot: iotago.MaxSlotIndex, BlockIssuerKeys: node1.Validator.BlockIssuerKeys(), StakeEndEpoch: iotago.MaxEpochIndex, - ValidatorStake: mock.MinValidatorAccountAmount, + ValidatorStake: mock.MinValidatorAccountAmount(ts.API.ProtocolParameters()), }, ts.Nodes()...) // default wallet block issuer account. wallet1AccountOutput := ts.AccountOutput("Genesis:2") diff --git a/pkg/tests/upgrade_signaling_test.go b/pkg/tests/upgrade_signaling_test.go index 1cef7088b..7cc21ff8e 100644 --- a/pkg/tests/upgrade_signaling_test.go +++ b/pkg/tests/upgrade_signaling_test.go @@ -148,7 +148,7 @@ func Test_Upgrade_Signaling(t *testing.T) { ExpirySlot: iotago.MaxSlotIndex, OutputID: ts.AccountOutput("Genesis:1").OutputID(), BlockIssuerKeys: iotago.NewBlockIssuerKeys(iotago.Ed25519PublicKeyBlockIssuerKeyFromPublicKey(ed25519.PublicKey(ts.Node("nodeA").Validator.PublicKey))), - ValidatorStake: mock.MinValidatorAccountAmount, + ValidatorStake: mock.MinValidatorAccountAmount(ts.API.ProtocolParameters()), DelegationStake: 0, FixedCost: 0, StakeEndEpoch: iotago.MaxEpochIndex, @@ -182,7 +182,7 @@ func Test_Upgrade_Signaling(t *testing.T) { ExpirySlot: iotago.MaxSlotIndex, OutputID: ts.AccountOutput("Genesis:1").OutputID(), BlockIssuerKeys: iotago.NewBlockIssuerKeys(iotago.Ed25519PublicKeyBlockIssuerKeyFromPublicKey(ed25519.PublicKey(ts.Node("nodeA").Validator.PublicKey))), - ValidatorStake: mock.MinValidatorAccountAmount, + ValidatorStake: mock.MinValidatorAccountAmount(ts.API.ProtocolParameters()), DelegationStake: 0, FixedCost: 0, StakeEndEpoch: iotago.MaxEpochIndex, @@ -195,7 +195,7 @@ func Test_Upgrade_Signaling(t *testing.T) { ExpirySlot: iotago.MaxSlotIndex, OutputID: ts.AccountOutput("Genesis:4").OutputID(), BlockIssuerKeys: iotago.NewBlockIssuerKeys(iotago.Ed25519PublicKeyBlockIssuerKeyFromPublicKey(ed25519.PublicKey(ts.Node("nodeD").Validator.PublicKey))), - ValidatorStake: mock.MinValidatorAccountAmount, + ValidatorStake: mock.MinValidatorAccountAmount(ts.API.ProtocolParameters()), DelegationStake: 0, FixedCost: 0, StakeEndEpoch: iotago.MaxEpochIndex, @@ -216,7 +216,7 @@ func Test_Upgrade_Signaling(t *testing.T) { ExpirySlot: iotago.MaxSlotIndex, OutputID: ts.AccountOutput("Genesis:1").OutputID(), BlockIssuerKeys: iotago.NewBlockIssuerKeys(iotago.Ed25519PublicKeyBlockIssuerKeyFromPublicKey(ed25519.PublicKey(ts.Node("nodeA").Validator.PublicKey))), - ValidatorStake: mock.MinValidatorAccountAmount, + ValidatorStake: mock.MinValidatorAccountAmount(ts.API.ProtocolParameters()), DelegationStake: 0, FixedCost: 0, StakeEndEpoch: iotago.MaxEpochIndex, @@ -381,7 +381,7 @@ func Test_Upgrade_Signaling(t *testing.T) { ExpirySlot: iotago.MaxSlotIndex, OutputID: ts.AccountOutput("Genesis:1").OutputID(), BlockIssuerKeys: iotago.NewBlockIssuerKeys(iotago.Ed25519PublicKeyBlockIssuerKeyFromPublicKey(ed25519.PublicKey(ts.Node("nodeA").Validator.PublicKey))), - ValidatorStake: mock.MinValidatorAccountAmount, + ValidatorStake: mock.MinValidatorAccountAmount(ts.API.ProtocolParameters()), DelegationStake: 0, FixedCost: 0, StakeEndEpoch: iotago.MaxEpochIndex, @@ -394,7 +394,7 @@ func Test_Upgrade_Signaling(t *testing.T) { ExpirySlot: iotago.MaxSlotIndex, OutputID: ts.AccountOutput("Genesis:4").OutputID(), BlockIssuerKeys: iotago.NewBlockIssuerKeys(iotago.Ed25519PublicKeyBlockIssuerKeyFromPublicKey(ed25519.PublicKey(ts.Node("nodeD").Validator.PublicKey))), - ValidatorStake: mock.MinValidatorAccountAmount, + ValidatorStake: mock.MinValidatorAccountAmount(ts.API.ProtocolParameters()), DelegationStake: 0, FixedCost: 0, StakeEndEpoch: iotago.MaxEpochIndex, diff --git a/pkg/testsuite/mock/utils.go b/pkg/testsuite/mock/utils.go index 4314989c7..c083ae39d 100644 --- a/pkg/testsuite/mock/utils.go +++ b/pkg/testsuite/mock/utils.go @@ -1,16 +1,75 @@ package mock import ( + "github.com/iotaledger/hive.go/lo" "github.com/iotaledger/hive.go/runtime/options" "github.com/iotaledger/iota-core/pkg/protocol/engine/utxoledger" iotago "github.com/iotaledger/iota.go/v4" "github.com/iotaledger/iota.go/v4/builder" ) -const MinIssuerAccountAmount = iotago.BaseToken(372900) -const MinValidatorAccountAmount = iotago.BaseToken(722800) -const AccountConversionManaCost = iotago.Mana(1000000) -const MaxBlockManaCost = iotago.Mana(1000000) +func MinIssuerAccountAmount(protocolParameters iotago.ProtocolParameters) iotago.BaseToken { + // create a dummy account with a block issuer feature to calculate the storage score. + dummyAccountOutput := &iotago.AccountOutput{ + Amount: 0, + Mana: 0, + AccountID: iotago.EmptyAccountID, + FoundryCounter: 0, + UnlockConditions: iotago.AccountOutputUnlockConditions{ + &iotago.AddressUnlockCondition{ + Address: &iotago.Ed25519Address{}, + }, + }, + Features: iotago.AccountOutputFeatures{ + &iotago.BlockIssuerFeature{ + BlockIssuerKeys: iotago.BlockIssuerKeys{ + &iotago.Ed25519PublicKeyBlockIssuerKey{}, + }, + }, + }, + ImmutableFeatures: iotago.AccountOutputImmFeatures{}, + } + storageScoreStructure := iotago.NewStorageScoreStructure(protocolParameters.StorageScoreParameters()) + + return lo.PanicOnErr(storageScoreStructure.MinDeposit(dummyAccountOutput)) +} + +func MinValidatorAccountAmount(protocolParameters iotago.ProtocolParameters) iotago.BaseToken { + // create a dummy account with a staking and block issuer feature to calculate the storage score. + dummyAccountOutput := &iotago.AccountOutput{ + Amount: 0, + Mana: 0, + AccountID: iotago.EmptyAccountID, + FoundryCounter: 0, + UnlockConditions: iotago.AccountOutputUnlockConditions{ + &iotago.AddressUnlockCondition{ + Address: &iotago.Ed25519Address{}, + }, + }, + Features: iotago.AccountOutputFeatures{ + &iotago.BlockIssuerFeature{ + BlockIssuerKeys: iotago.BlockIssuerKeys{ + &iotago.Ed25519PublicKeyBlockIssuerKey{}, + }, + }, + &iotago.StakingFeature{}, + }, + ImmutableFeatures: iotago.AccountOutputImmFeatures{}, + } + storageScoreStructure := iotago.NewStorageScoreStructure(protocolParameters.StorageScoreParameters()) + + return lo.PanicOnErr(storageScoreStructure.MinDeposit(dummyAccountOutput)) +} + +// TODO: add the correct formula later +func AccountConversionManaCost(protocolParameters iotago.ProtocolParameters) iotago.Mana { + return iotago.Mana(1000000) +} + +// TODO: add the correct formula later +func MaxBlockManaCost(protocolParameters iotago.ProtocolParameters) iotago.Mana { + return iotago.Mana(1000000) +} // TransactionBuilder options diff --git a/pkg/testsuite/mock/wallet.go b/pkg/testsuite/mock/wallet.go index c7c1ec176..e0f59be89 100644 --- a/pkg/testsuite/mock/wallet.go +++ b/pkg/testsuite/mock/wallet.go @@ -26,6 +26,8 @@ type Wallet struct { keyManager *KeyManager + apiProvider iotago.APIProvider + BlockIssuer *BlockIssuer outputs map[string]*utxoledger.Output diff --git a/pkg/testsuite/mock/wallet_transactions.go b/pkg/testsuite/mock/wallet_transactions.go index c930e6c58..91430d682 100644 --- a/pkg/testsuite/mock/wallet_transactions.go +++ b/pkg/testsuite/mock/wallet_transactions.go @@ -21,7 +21,7 @@ func (w *Wallet) CreateAccountFromInput(transactionName string, inputName string input := w.Output(inputName) accountOutput := options.Apply(builder.NewAccountOutputBuilder(recipientWallet.Address(), input.BaseTokenAmount()). - Mana(MaxBlockManaCost), + Mana(MaxBlockManaCost(w.apiProvider.CommittedAPI().ProtocolParameters())), opts).MustBuild() outputStates := iotago.Outputs[iotago.Output]{accountOutput} @@ -197,8 +197,8 @@ func (w *Wallet) CreateImplicitAccountFromInput(transactionName string, inputNam input := w.Output(inputName) implicitAccountOutput := &iotago.BasicOutput{ - Amount: MinIssuerAccountAmount, - Mana: AccountConversionManaCost, + Amount: MinIssuerAccountAmount(w.apiProvider.CommittedAPI().ProtocolParameters()), + Mana: AccountConversionManaCost(w.apiProvider.CommittedAPI().ProtocolParameters()), UnlockConditions: iotago.BasicOutputUnlockConditions{ &iotago.AddressUnlockCondition{Address: recipientWallet.ImplicitAccountCreationAddress()}, }, @@ -206,8 +206,8 @@ func (w *Wallet) CreateImplicitAccountFromInput(transactionName string, inputNam } remainderBasicOutput := &iotago.BasicOutput{ - Amount: input.BaseTokenAmount() - MinIssuerAccountAmount, - Mana: input.StoredMana() - AccountConversionManaCost, + Amount: input.BaseTokenAmount() - MinIssuerAccountAmount(w.apiProvider.CommittedAPI().ProtocolParameters()), + Mana: input.StoredMana() - AccountConversionManaCost(w.apiProvider.CommittedAPI().ProtocolParameters()), UnlockConditions: iotago.BasicOutputUnlockConditions{ &iotago.AddressUnlockCondition{Address: input.Output().UnlockConditionSet().Address().Address}, }, @@ -242,7 +242,7 @@ func (w *Wallet) TransitionImplicitAccountToAccountOutput(transactionName string panic(fmt.Sprintf("output with alias %s is not an implicit account", inputName)) } - accountOutput := options.Apply(builder.NewAccountOutputBuilder(w.Address(), MinIssuerAccountAmount). + accountOutput := options.Apply(builder.NewAccountOutputBuilder(w.Address(), MinIssuerAccountAmount(w.apiProvider.CommittedAPI().ProtocolParameters())). AccountID(iotago.AccountIDFromOutputID(input.OutputID())), opts).MustBuild() diff --git a/pkg/testsuite/testsuite.go b/pkg/testsuite/testsuite.go index 911101fdf..bb8e97927 100644 --- a/pkg/testsuite/testsuite.go +++ b/pkg/testsuite/testsuite.go @@ -27,6 +27,50 @@ import ( "github.com/iotaledger/iota.go/v4/tpkg" ) +func DefaultProtocolParameterOptions(networkName string) []options.Option[iotago.V3ProtocolParameters] { + return []options.Option[iotago.V3ProtocolParameters]{ + iotago.WithNetworkOptions( + networkName, + "rms", + ), + iotago.WithSupplyOptions( + 1_000_0000, + 100, + 1, + 10, + 100, + 100, + 100, + ), + iotago.WithRewardsOptions(8, 8, 31, 1154, 2, 1), + iotago.WithStakingOptions(1, 100, 1), + + iotago.WithTimeProviderOptions( + 0, + GenesisTimeWithOffsetBySlots(0, DefaultSlotDurationInSeconds), + DefaultSlotDurationInSeconds, + DefaultSlotsPerEpochExponent, + ), + iotago.WithLivenessOptions( + DefaultLivenessThresholdLowerBoundInSeconds, + DefaultLivenessThresholdUpperBoundInSeconds, + DefaultMinCommittableAge, + DefaultMaxCommittableAge, + DefaultEpochNearingThreshold, + ), + iotago.WithCongestionControlOptions( + DefaultMinReferenceManaCost, + DefaultRMCIncrease, + DefaultRMCDecrease, + DefaultRMCIncreaseThreshold, + DefaultRMCDecreaseThreshold, + DefaultSchedulerRate, + DefaultMaxBufferSize, + DefaultMaxValBufferSize, + ), + } +} + type TestSuite struct { Testing *testing.T fakeTesting *testing.T @@ -74,49 +118,7 @@ func NewTestSuite(testingT *testing.T, opts ...options.Option[TestSuite]) *TestS }, opts, func(t *TestSuite) { fmt.Println("Setup TestSuite -", testingT.Name(), " @ ", time.Now()) - defaultProtocolParameters := []options.Option[iotago.V3ProtocolParameters]{ - iotago.WithNetworkOptions( - testingT.Name(), - "rms", - ), - iotago.WithSupplyOptions( - 1_000_0000, - 100, - 1, - 10, - 100, - 100, - 100, - ), - iotago.WithRewardsOptions(8, 8, 31, 1154, 2, 1), - iotago.WithStakingOptions(1, 100, 1), - - iotago.WithTimeProviderOptions( - 0, - GenesisTimeWithOffsetBySlots(0, DefaultSlotDurationInSeconds), - DefaultSlotDurationInSeconds, - DefaultSlotsPerEpochExponent, - ), - iotago.WithLivenessOptions( - DefaultLivenessThresholdLowerBoundInSeconds, - DefaultLivenessThresholdUpperBoundInSeconds, - DefaultMinCommittableAge, - DefaultMaxCommittableAge, - DefaultEpochNearingThreshold, - ), - iotago.WithCongestionControlOptions( - DefaultMinReferenceManaCost, - DefaultRMCIncrease, - DefaultRMCDecrease, - DefaultRMCIncreaseThreshold, - DefaultRMCDecreaseThreshold, - DefaultSchedulerRate, - DefaultMaxBufferSize, - DefaultMaxValBufferSize, - ), - } - - t.ProtocolParameterOptions = append(defaultProtocolParameters, t.ProtocolParameterOptions...) + t.ProtocolParameterOptions = append(DefaultProtocolParameterOptions(testingT.Name()), t.ProtocolParameterOptions...) t.API = iotago.V3API(iotago.NewV3ProtocolParameters(t.ProtocolParameterOptions...)) genesisBlock := blocks.NewRootBlock(t.API.ProtocolParameters().GenesisBlockID(), iotago.NewEmptyCommitment(t.API).MustID(), time.Unix(t.API.ProtocolParameters().GenesisUnixTimestamp(), 0)) @@ -332,7 +334,7 @@ func (t *TestSuite) addNodeToPartition(name string, partition string, validator t.nodes.Set(name, node) node.SetCurrentSlot(t.currentSlot) - amount := mock.MinValidatorAccountAmount + amount := mock.MinValidatorAccountAmount(t.API.ProtocolParameters()) if len(optAmount) > 0 { amount = optAmount[0] } @@ -395,8 +397,8 @@ func (t *TestSuite) AddGenesisWallet(name string, node *mock.Node, blockIssuance accountDetails := snapshotcreator.AccountDetails{ AccountID: accountID, Address: iotago.Ed25519AddressFromPubKey(newWallet.BlockIssuer.PublicKey), - Amount: mock.MinIssuerAccountAmount, - Mana: iotago.Mana(mock.MinIssuerAccountAmount), + Amount: mock.MinIssuerAccountAmount(t.API.ProtocolParameters()), + Mana: iotago.Mana(mock.MinIssuerAccountAmount(t.API.ProtocolParameters())), IssuerKey: iotago.Ed25519PublicKeyBlockIssuerKeyFromPublicKey(ed25519.PublicKey(newWallet.BlockIssuer.PublicKey)), ExpirySlot: iotago.MaxSlotIndex, BlockIssuanceCredits: bic, diff --git a/tools/genesis-snapshot/presets/presets.go b/tools/genesis-snapshot/presets/presets.go index eff0b3836..8f90767e6 100644 --- a/tools/genesis-snapshot/presets/presets.go +++ b/tools/genesis-snapshot/presets/presets.go @@ -15,238 +15,242 @@ import ( "github.com/iotaledger/iota.go/v4/hexutil" ) -var Base = []options.Option[snapshotcreator.Options]{ - snapshotcreator.WithDatabaseVersion(protocol.DatabaseVersion), - snapshotcreator.WithFilePath("snapshot.bin"), - snapshotcreator.WithProtocolParameters( - iotago.NewV3ProtocolParameters( - iotago.WithNetworkOptions("default", "rms"), - iotago.WithSupplyOptions(4_600_000_000_000_000, 250, 1, 1000, 100000, 500000, 100000), - iotago.WithTimeProviderOptions(0, 1696841745, 10, 13), - iotago.WithLivenessOptions(30, 30, 7, 14, 30), - // increase/decrease threshold = fraction * slotDurationInSeconds * schedulerRate - iotago.WithCongestionControlOptions(500, 500, 500, 800000, 500000, 100000, 1000, 100), - iotago.WithWorkScoreOptions(25, 1, 100, 50, 10, 10, 50, 1, 10, 250), - ), - ), - snapshotcreator.WithAddGenesisRootBlock(true), -} - -var Docker = []options.Option[snapshotcreator.Options]{ - snapshotcreator.WithFilePath("docker-network.snapshot"), - snapshotcreator.WithAccounts( - snapshotcreator.AccountDetails{ - /* - node-01-validator +var ( + protocolParamsBase = iotago.NewV3ProtocolParameters( + iotago.WithNetworkOptions("default", "rms"), + iotago.WithSupplyOptions(4_600_000_000_000_000, 250, 1, 1000, 100000, 500000, 100000), + iotago.WithTimeProviderOptions(0, 1696841745, 10, 13), + iotago.WithLivenessOptions(30, 30, 7, 14, 30), + // increase/decrease threshold = fraction * slotDurationInSeconds * schedulerRate + iotago.WithCongestionControlOptions(500, 500, 500, 800000, 500000, 100000, 1000, 100), + iotago.WithWorkScoreOptions(25, 1, 100, 50, 10, 10, 50, 1, 10, 250), + ) - Ed25519 Public Key: 293dc170d9a59474e6d81cfba7f7d924c09b25d7166bcfba606e53114d0a758b - Ed25519 Address: rms1qzg8cqhfxqhq7pt37y8cs4v5u4kcc48lquy2k73ehsdhf5ukhya3ytgk0ny - Account Address: rms1pzg8cqhfxqhq7pt37y8cs4v5u4kcc48lquy2k73ehsdhf5ukhya3y5rx2w6 - Restricted Address: rms1xqqfqlqzayczurc9w8cslzz4jnjkmrz5lurs32m68x7pkaxnj6unkyspqg8mulpm, Capabilities: mana - */ - AccountID: blake2b.Sum256(lo.PanicOnErr(hexutil.DecodeHex("0x293dc170d9a59474e6d81cfba7f7d924c09b25d7166bcfba606e53114d0a758b"))), - Address: iotago.Ed25519AddressFromPubKey(lo.PanicOnErr(hexutil.DecodeHex("0x293dc170d9a59474e6d81cfba7f7d924c09b25d7166bcfba606e53114d0a758b"))), - Amount: mock.MinValidatorAccountAmount, - IssuerKey: iotago.Ed25519PublicKeyBlockIssuerKeyFromPublicKey(ed25519.PublicKey(lo.PanicOnErr(hexutil.DecodeHex("0x293dc170d9a59474e6d81cfba7f7d924c09b25d7166bcfba606e53114d0a758b")))), - ExpirySlot: iotago.MaxSlotIndex, - BlockIssuanceCredits: iotago.MaxBlockIssuanceCredits / 4, - StakingEpochEnd: iotago.MaxEpochIndex, - FixedCost: 1, - StakedAmount: mock.MinValidatorAccountAmount, - Mana: iotago.Mana(mock.MinValidatorAccountAmount), - }, - snapshotcreator.AccountDetails{ - /* - node-02-validator + protocolParamsDocker = iotago.NewV3ProtocolParameters( + iotago.WithNetworkOptions("docker", "rms"), + iotago.WithSupplyOptions(4_600_000_000_000_000, 250, 1, 1000, 100000, 500000, 100000), + iotago.WithTimeProviderOptions(5, time.Now().Unix(), 10, 13), + iotago.WithLivenessOptions(30, 30, 7, 14, 30), + // increase/decrease threshold = fraction * slotDurationInSeconds * schedulerRate + iotago.WithCongestionControlOptions(500, 500, 500, 800000, 500000, 100000, 1000, 100), + iotago.WithWorkScoreOptions(25, 1, 100, 50, 10, 10, 50, 1, 10, 250), + ) - Ed25519 Public Key: 05c1de274451db8de8182d64c6ee0dca3ae0c9077e0b4330c976976171d79064 - Ed25519 Address: rms1qqm4xk8e9ny5w5rxjkvtp249tfhlwvcshyr3pc0665jvp7g3hc875flpz2p - Account Address: rms1pqm4xk8e9ny5w5rxjkvtp249tfhlwvcshyr3pc0665jvp7g3hc875k538hl - Restricted Address: rms1xqqrw56clykvj36sv62e3v9254dxlaenzzuswy8plt2jfs8ezxlql6spqgkulf7u, Capabilities: mana - */ - AccountID: blake2b.Sum256(lo.PanicOnErr(hexutil.DecodeHex("0x05c1de274451db8de8182d64c6ee0dca3ae0c9077e0b4330c976976171d79064"))), - Address: iotago.Ed25519AddressFromPubKey(lo.PanicOnErr(hexutil.DecodeHex("0x05c1de274451db8de8182d64c6ee0dca3ae0c9077e0b4330c976976171d79064"))), - Amount: mock.MinValidatorAccountAmount, - IssuerKey: iotago.Ed25519PublicKeyBlockIssuerKeyFromPublicKey(ed25519.PublicKey(lo.PanicOnErr(hexutil.DecodeHex("0x05c1de274451db8de8182d64c6ee0dca3ae0c9077e0b4330c976976171d79064")))), - ExpirySlot: iotago.MaxSlotIndex, - BlockIssuanceCredits: iotago.MaxBlockIssuanceCredits / 4, - StakingEpochEnd: iotago.MaxEpochIndex, - FixedCost: 1, - StakedAmount: mock.MinValidatorAccountAmount, - Mana: iotago.Mana(mock.MinValidatorAccountAmount), - }, - snapshotcreator.AccountDetails{ - /* - node-03-validator + protocolParamsFeature = iotago.NewV3ProtocolParameters( + iotago.WithNetworkOptions("feature", "rms"), + iotago.WithSupplyOptions(4_600_000_000_000_000, 250, 1, 1000, 100000, 500000, 100000), + iotago.WithTimeProviderOptions(666666, time.Now().Unix()-100_000, 10, 13), // Let's fix genesis at 10_000 slots back. + iotago.WithLivenessOptions(30, 30, 10, 20, 30), + // increase/decrease threshold = fraction * slotDurationInSeconds * schedulerRate + iotago.WithCongestionControlOptions(500, 500, 500, 800000, 500000, 100000, 1000, 100), + iotago.WithWorkScoreOptions(25, 1, 100, 50, 10, 10, 50, 1, 10, 250), + ) +) - Ed25519 Public Key: 1e4b21eb51dcddf65c20db1065e1f1514658b23a3ddbf48d30c0efc926a9a648 - Ed25519 Address: rms1qp4wuuz0y42caz48vv876qfpmffswsvg40zz8v79sy8cp0jfxm4kuvz0a44 - Account Address: rms1pp4wuuz0y42caz48vv876qfpmffswsvg40zz8v79sy8cp0jfxm4kunflcgt - Restricted Address: rms1xqqx4mnsfuj4tr525a3slmgpy8d9xp6p3z4ugganckqslq97fymwkmspqgnzrkjq, Capabilities: mana - */ - AccountID: blake2b.Sum256(lo.PanicOnErr(hexutil.DecodeHex("0x1e4b21eb51dcddf65c20db1065e1f1514658b23a3ddbf48d30c0efc926a9a648"))), - Address: iotago.Ed25519AddressFromPubKey(lo.PanicOnErr(hexutil.DecodeHex("0x1e4b21eb51dcddf65c20db1065e1f1514658b23a3ddbf48d30c0efc926a9a648"))), - Amount: mock.MinValidatorAccountAmount, - IssuerKey: iotago.Ed25519PublicKeyBlockIssuerKeyFromPublicKey(ed25519.PublicKey(lo.PanicOnErr(hexutil.DecodeHex("0x1e4b21eb51dcddf65c20db1065e1f1514658b23a3ddbf48d30c0efc926a9a648")))), - ExpirySlot: iotago.MaxSlotIndex, - BlockIssuanceCredits: iotago.MaxBlockIssuanceCredits / 4, - StakingEpochEnd: iotago.MaxEpochIndex, - FixedCost: 1, - StakedAmount: mock.MinValidatorAccountAmount, - Mana: iotago.Mana(mock.MinValidatorAccountAmount), - }, - snapshotcreator.AccountDetails{ - /* - inx-blockissuer +var ( + Base = []options.Option[snapshotcreator.Options]{ + snapshotcreator.WithDatabaseVersion(protocol.DatabaseVersion), + snapshotcreator.WithFilePath("snapshot.bin"), + snapshotcreator.WithProtocolParameters(protocolParamsBase), + snapshotcreator.WithAddGenesisRootBlock(true), + } - Ed25519 Private Key: 432c624ca3260f910df35008d5c740593b222f1e196e6cdb8cd1ad080f0d4e33997be92a22b1933f36e26fba5f721756f95811d6b4ae21564197c2bfa4f28270 - Ed25519 Public Key: 997be92a22b1933f36e26fba5f721756f95811d6b4ae21564197c2bfa4f28270 - Ed25519 Address: rms1qrkursay9fs2qjmfctamd6yxg9x8r3ry47786x0mvwek4qr9xd9d583cnpd - Account Address: rms1prkursay9fs2qjmfctamd6yxg9x8r3ry47786x0mvwek4qr9xd9d5c6gkun - Restricted Address: rms1xqqwmswr5s4xpgztd8p0hdhgseq5cuwyvjhmclgeld3mx65qv5e54kspqgda0nrn, Capabilities: mana - */ - AccountID: blake2b.Sum256(lo.PanicOnErr(hexutil.DecodeHex("0x997be92a22b1933f36e26fba5f721756f95811d6b4ae21564197c2bfa4f28270"))), - Address: iotago.Ed25519AddressFromPubKey(lo.PanicOnErr(hexutil.DecodeHex("0x997be92a22b1933f36e26fba5f721756f95811d6b4ae21564197c2bfa4f28270"))), - Amount: mock.MinIssuerAccountAmount, - IssuerKey: iotago.Ed25519PublicKeyBlockIssuerKeyFromPublicKey(ed25519.PublicKey(lo.PanicOnErr(hexutil.DecodeHex("0x997be92a22b1933f36e26fba5f721756f95811d6b4ae21564197c2bfa4f28270")))), - ExpirySlot: iotago.MaxSlotIndex, - BlockIssuanceCredits: iotago.MaxBlockIssuanceCredits / 4, - Mana: iotago.Mana(mock.MinIssuerAccountAmount), - }, - ), - snapshotcreator.WithBasicOutputs( - /* - inx-faucet - - Ed25519 Private Key: de52b9964dda96564e9fab362ab16c2669c715c6a2a853bece8a25fc58c599755b938327ea463e0c323c0fd44f6fc1843ed94daecc6909c6043d06b7152e4737 - Ed25519 Public Key: 5b938327ea463e0c323c0fd44f6fc1843ed94daecc6909c6043d06b7152e4737 - Ed25519 Address: rms1qqhkf7w30xv375z59vq7qd86qsa3j4qrsadcval04uvkkswg3qpaqf4hga2 - Restricted Address: rms1xqqz7e8e69uej86s2s4srcp5lgzrkx25qwr4hpnha7h3j66pezyq85qpqg55v3ur, Capabilities: mana - */ - snapshotcreator.BasicOutputDetails{ - Address: lo.Return2(iotago.ParseBech32("rms1xqqz7e8e69uej86s2s4srcp5lgzrkx25qwr4hpnha7h3j66pezyq85qpqg55v3ur")), - Amount: 1_000_000_000_000_000, - Mana: 10_000_000, - }, - ), - snapshotcreator.WithProtocolParameters( - iotago.NewV3ProtocolParameters( - iotago.WithNetworkOptions("docker", "rms"), - iotago.WithSupplyOptions(4_600_000_000_000_000, 250, 1, 1000, 100000, 500000, 100000), - iotago.WithTimeProviderOptions(5, time.Now().Unix(), 10, 13), - iotago.WithLivenessOptions(30, 30, 7, 14, 30), - // increase/decrease threshold = fraction * slotDurationInSeconds * schedulerRate - iotago.WithCongestionControlOptions(500, 500, 500, 800000, 500000, 100000, 1000, 100), - iotago.WithWorkScoreOptions(25, 1, 100, 50, 10, 10, 50, 1, 10, 250), + Docker = []options.Option[snapshotcreator.Options]{ + snapshotcreator.WithFilePath("docker-network.snapshot"), + snapshotcreator.WithProtocolParameters(protocolParamsDocker), + snapshotcreator.WithAccounts( + snapshotcreator.AccountDetails{ + /* + node-01-validator + + Ed25519 Public Key: 293dc170d9a59474e6d81cfba7f7d924c09b25d7166bcfba606e53114d0a758b + Ed25519 Address: rms1qzg8cqhfxqhq7pt37y8cs4v5u4kcc48lquy2k73ehsdhf5ukhya3ytgk0ny + Account Address: rms1pzg8cqhfxqhq7pt37y8cs4v5u4kcc48lquy2k73ehsdhf5ukhya3y5rx2w6 + Restricted Address: rms1xqqfqlqzayczurc9w8cslzz4jnjkmrz5lurs32m68x7pkaxnj6unkyspqg8mulpm, Capabilities: mana + */ + AccountID: blake2b.Sum256(lo.PanicOnErr(hexutil.DecodeHex("0x293dc170d9a59474e6d81cfba7f7d924c09b25d7166bcfba606e53114d0a758b"))), + Address: iotago.Ed25519AddressFromPubKey(lo.PanicOnErr(hexutil.DecodeHex("0x293dc170d9a59474e6d81cfba7f7d924c09b25d7166bcfba606e53114d0a758b"))), + Amount: mock.MinValidatorAccountAmount(protocolParamsDocker), + IssuerKey: iotago.Ed25519PublicKeyBlockIssuerKeyFromPublicKey(ed25519.PublicKey(lo.PanicOnErr(hexutil.DecodeHex("0x293dc170d9a59474e6d81cfba7f7d924c09b25d7166bcfba606e53114d0a758b")))), + ExpirySlot: iotago.MaxSlotIndex, + BlockIssuanceCredits: iotago.MaxBlockIssuanceCredits / 4, + StakingEpochEnd: iotago.MaxEpochIndex, + FixedCost: 1, + StakedAmount: mock.MinValidatorAccountAmount(protocolParamsDocker), + Mana: iotago.Mana(mock.MinValidatorAccountAmount(protocolParamsDocker)), + }, + snapshotcreator.AccountDetails{ + /* + node-02-validator + + Ed25519 Public Key: 05c1de274451db8de8182d64c6ee0dca3ae0c9077e0b4330c976976171d79064 + Ed25519 Address: rms1qqm4xk8e9ny5w5rxjkvtp249tfhlwvcshyr3pc0665jvp7g3hc875flpz2p + Account Address: rms1pqm4xk8e9ny5w5rxjkvtp249tfhlwvcshyr3pc0665jvp7g3hc875k538hl + Restricted Address: rms1xqqrw56clykvj36sv62e3v9254dxlaenzzuswy8plt2jfs8ezxlql6spqgkulf7u, Capabilities: mana + */ + AccountID: blake2b.Sum256(lo.PanicOnErr(hexutil.DecodeHex("0x05c1de274451db8de8182d64c6ee0dca3ae0c9077e0b4330c976976171d79064"))), + Address: iotago.Ed25519AddressFromPubKey(lo.PanicOnErr(hexutil.DecodeHex("0x05c1de274451db8de8182d64c6ee0dca3ae0c9077e0b4330c976976171d79064"))), + Amount: mock.MinValidatorAccountAmount(protocolParamsDocker), + IssuerKey: iotago.Ed25519PublicKeyBlockIssuerKeyFromPublicKey(ed25519.PublicKey(lo.PanicOnErr(hexutil.DecodeHex("0x05c1de274451db8de8182d64c6ee0dca3ae0c9077e0b4330c976976171d79064")))), + ExpirySlot: iotago.MaxSlotIndex, + BlockIssuanceCredits: iotago.MaxBlockIssuanceCredits / 4, + StakingEpochEnd: iotago.MaxEpochIndex, + FixedCost: 1, + StakedAmount: mock.MinValidatorAccountAmount(protocolParamsDocker), + Mana: iotago.Mana(mock.MinValidatorAccountAmount(protocolParamsDocker)), + }, + snapshotcreator.AccountDetails{ + /* + node-03-validator + + Ed25519 Public Key: 1e4b21eb51dcddf65c20db1065e1f1514658b23a3ddbf48d30c0efc926a9a648 + Ed25519 Address: rms1qp4wuuz0y42caz48vv876qfpmffswsvg40zz8v79sy8cp0jfxm4kuvz0a44 + Account Address: rms1pp4wuuz0y42caz48vv876qfpmffswsvg40zz8v79sy8cp0jfxm4kunflcgt + Restricted Address: rms1xqqx4mnsfuj4tr525a3slmgpy8d9xp6p3z4ugganckqslq97fymwkmspqgnzrkjq, Capabilities: mana + */ + AccountID: blake2b.Sum256(lo.PanicOnErr(hexutil.DecodeHex("0x1e4b21eb51dcddf65c20db1065e1f1514658b23a3ddbf48d30c0efc926a9a648"))), + Address: iotago.Ed25519AddressFromPubKey(lo.PanicOnErr(hexutil.DecodeHex("0x1e4b21eb51dcddf65c20db1065e1f1514658b23a3ddbf48d30c0efc926a9a648"))), + Amount: mock.MinValidatorAccountAmount(protocolParamsDocker), + IssuerKey: iotago.Ed25519PublicKeyBlockIssuerKeyFromPublicKey(ed25519.PublicKey(lo.PanicOnErr(hexutil.DecodeHex("0x1e4b21eb51dcddf65c20db1065e1f1514658b23a3ddbf48d30c0efc926a9a648")))), + ExpirySlot: iotago.MaxSlotIndex, + BlockIssuanceCredits: iotago.MaxBlockIssuanceCredits / 4, + StakingEpochEnd: iotago.MaxEpochIndex, + FixedCost: 1, + StakedAmount: mock.MinValidatorAccountAmount(protocolParamsDocker), + Mana: iotago.Mana(mock.MinValidatorAccountAmount(protocolParamsDocker)), + }, + snapshotcreator.AccountDetails{ + /* + inx-blockissuer + + Ed25519 Private Key: 432c624ca3260f910df35008d5c740593b222f1e196e6cdb8cd1ad080f0d4e33997be92a22b1933f36e26fba5f721756f95811d6b4ae21564197c2bfa4f28270 + Ed25519 Public Key: 997be92a22b1933f36e26fba5f721756f95811d6b4ae21564197c2bfa4f28270 + Ed25519 Address: rms1qrkursay9fs2qjmfctamd6yxg9x8r3ry47786x0mvwek4qr9xd9d583cnpd + Account Address: rms1prkursay9fs2qjmfctamd6yxg9x8r3ry47786x0mvwek4qr9xd9d5c6gkun + Restricted Address: rms1xqqwmswr5s4xpgztd8p0hdhgseq5cuwyvjhmclgeld3mx65qv5e54kspqgda0nrn, Capabilities: mana + */ + AccountID: blake2b.Sum256(lo.PanicOnErr(hexutil.DecodeHex("0x997be92a22b1933f36e26fba5f721756f95811d6b4ae21564197c2bfa4f28270"))), + Address: iotago.Ed25519AddressFromPubKey(lo.PanicOnErr(hexutil.DecodeHex("0x997be92a22b1933f36e26fba5f721756f95811d6b4ae21564197c2bfa4f28270"))), + Amount: mock.MinIssuerAccountAmount(protocolParamsDocker), + IssuerKey: iotago.Ed25519PublicKeyBlockIssuerKeyFromPublicKey(ed25519.PublicKey(lo.PanicOnErr(hexutil.DecodeHex("0x997be92a22b1933f36e26fba5f721756f95811d6b4ae21564197c2bfa4f28270")))), + ExpirySlot: iotago.MaxSlotIndex, + BlockIssuanceCredits: iotago.MaxBlockIssuanceCredits / 4, + Mana: iotago.Mana(mock.MinIssuerAccountAmount(protocolParamsDocker)), + }, ), - ), -} - -// Feature is a preset for the feature network, genesis time ~20th of July 2023. -var Feature = []options.Option[snapshotcreator.Options]{ - snapshotcreator.WithFilePath("docker-network.snapshot"), - snapshotcreator.WithAccounts( - snapshotcreator.AccountDetails{ + snapshotcreator.WithBasicOutputs( /* - node-01-validator + inx-faucet - Ed25519 Public Key: 01fb6b9db5d96240aef00bc950d1c67a6494513f6d7cf784e57b4972b96ab2fe - Ed25519 Address: rms1qqlhggrg2ml9p0q5c4593r2yd3jwgxn20d65ulyw6z9r7xmm78apq4y2mxh - Account Address: rms1pqlhggrg2ml9p0q5c4593r2yd3jwgxn20d65ulyw6z9r7xmm78apq2067mf - Restricted Address: rms1xqqr7apqdpt0u59uznzkskydg3kxfeq6dfah2nnu3mgg50cm00cl5yqpqgrpy62q, Capabilities: mana + Ed25519 Private Key: de52b9964dda96564e9fab362ab16c2669c715c6a2a853bece8a25fc58c599755b938327ea463e0c323c0fd44f6fc1843ed94daecc6909c6043d06b7152e4737 + Ed25519 Public Key: 5b938327ea463e0c323c0fd44f6fc1843ed94daecc6909c6043d06b7152e4737 + Ed25519 Address: rms1qqhkf7w30xv375z59vq7qd86qsa3j4qrsadcval04uvkkswg3qpaqf4hga2 + Restricted Address: rms1xqqz7e8e69uej86s2s4srcp5lgzrkx25qwr4hpnha7h3j66pezyq85qpqg55v3ur, Capabilities: mana */ - AccountID: blake2b.Sum256(lo.PanicOnErr(hexutil.DecodeHex("0x01fb6b9db5d96240aef00bc950d1c67a6494513f6d7cf784e57b4972b96ab2fe"))), - Address: iotago.Ed25519AddressFromPubKey(lo.PanicOnErr(hexutil.DecodeHex("0x01fb6b9db5d96240aef00bc950d1c67a6494513f6d7cf784e57b4972b96ab2fe"))), - Amount: mock.MinValidatorAccountAmount, - IssuerKey: iotago.Ed25519PublicKeyBlockIssuerKeyFromPublicKey(ed25519.PublicKey(lo.PanicOnErr(hexutil.DecodeHex("0x01fb6b9db5d96240aef00bc950d1c67a6494513f6d7cf784e57b4972b96ab2fe")))), - ExpirySlot: iotago.MaxSlotIndex, - BlockIssuanceCredits: iotago.MaxBlockIssuanceCredits / 4, - StakingEpochEnd: iotago.MaxEpochIndex, - FixedCost: 1, - StakedAmount: mock.MinValidatorAccountAmount, - Mana: iotago.Mana(mock.MinValidatorAccountAmount), - }, - snapshotcreator.AccountDetails{ - /* - node-02-validator + snapshotcreator.BasicOutputDetails{ + Address: lo.Return2(iotago.ParseBech32("rms1xqqz7e8e69uej86s2s4srcp5lgzrkx25qwr4hpnha7h3j66pezyq85qpqg55v3ur")), + Amount: 1_000_000_000_000_000, + Mana: 10_000_000, + }, + ), + } - Ed25519 Public Key: 83e7f71a440afd48981a8b4684ddae24434b7182ce5c47cfb56ac528525fd4b6 - Ed25519 Address: rms1qzjwamvhjuqtw3dkfwmmj2fgcetcdyt4uxrnjxel4caxfstzz903ypu8xvn - Account Address: rms1pzjwamvhjuqtw3dkfwmmj2fgcetcdyt4uxrnjxel4caxfstzz903y7hhr3d - Restricted Address: rms1xqq2fmhdj7tspd69ke9m0wff9rr90p53whscwwgm87hr5expvgg47yspqgm6whkx, Capabilities: mana - */ - AccountID: blake2b.Sum256(lo.PanicOnErr(hexutil.DecodeHex("0x83e7f71a440afd48981a8b4684ddae24434b7182ce5c47cfb56ac528525fd4b6"))), - Address: iotago.Ed25519AddressFromPubKey(lo.PanicOnErr(hexutil.DecodeHex("0x83e7f71a440afd48981a8b4684ddae24434b7182ce5c47cfb56ac528525fd4b6"))), - Amount: mock.MinValidatorAccountAmount, - IssuerKey: iotago.Ed25519PublicKeyBlockIssuerKeyFromPublicKey(ed25519.PublicKey(lo.PanicOnErr(hexutil.DecodeHex("0x83e7f71a440afd48981a8b4684ddae24434b7182ce5c47cfb56ac528525fd4b6")))), - ExpirySlot: iotago.MaxSlotIndex, - BlockIssuanceCredits: iotago.MaxBlockIssuanceCredits / 4, - StakingEpochEnd: iotago.MaxEpochIndex, - FixedCost: 1, - StakedAmount: mock.MinValidatorAccountAmount, - Mana: iotago.Mana(mock.MinValidatorAccountAmount), - }, - snapshotcreator.AccountDetails{ - /* - node-03-validator + // Feature is a preset for the feature network, genesis time ~20th of July 2023. + Feature = []options.Option[snapshotcreator.Options]{ + snapshotcreator.WithFilePath("docker-network.snapshot"), + snapshotcreator.WithProtocolParameters(protocolParamsFeature), + snapshotcreator.WithAccounts( + snapshotcreator.AccountDetails{ + /* + node-01-validator - Ed25519 Public Key: ac628986b2ef52a1679f2289fcd7b4198476976dea4c30ae34ff04ae52e14805 - Ed25519 Address: rms1qz6kedkxyw9md2cmp0wcdhvsxrn2e7gzuyly76ffymy4dhvtkm58qlkjupg - Account Address: rms1pz6kedkxyw9md2cmp0wcdhvsxrn2e7gzuyly76ffymy4dhvtkm58qqazeuk - Restricted Address: rms1xqqt2m9kcc3chd4trv9ampkajqcwdt8eqtsnunmf9ynvj4ka3wmwsuqpqgvp9zxl, Capabilities: mana - */ - AccountID: blake2b.Sum256(lo.PanicOnErr(hexutil.DecodeHex("0xac628986b2ef52a1679f2289fcd7b4198476976dea4c30ae34ff04ae52e14805"))), - Address: iotago.Ed25519AddressFromPubKey(lo.PanicOnErr(hexutil.DecodeHex("0xac628986b2ef52a1679f2289fcd7b4198476976dea4c30ae34ff04ae52e14805"))), - Amount: mock.MinValidatorAccountAmount, - IssuerKey: iotago.Ed25519PublicKeyBlockIssuerKeyFromPublicKey(ed25519.PublicKey(lo.PanicOnErr(hexutil.DecodeHex("0xac628986b2ef52a1679f2289fcd7b4198476976dea4c30ae34ff04ae52e14805")))), - ExpirySlot: iotago.MaxSlotIndex, - BlockIssuanceCredits: iotago.MaxBlockIssuanceCredits / 4, - StakingEpochEnd: iotago.MaxEpochIndex, - FixedCost: 1, - StakedAmount: mock.MinValidatorAccountAmount, - Mana: iotago.Mana(mock.MinValidatorAccountAmount), - }, - snapshotcreator.AccountDetails{ + Ed25519 Public Key: 01fb6b9db5d96240aef00bc950d1c67a6494513f6d7cf784e57b4972b96ab2fe + Ed25519 Address: rms1qqlhggrg2ml9p0q5c4593r2yd3jwgxn20d65ulyw6z9r7xmm78apq4y2mxh + Account Address: rms1pqlhggrg2ml9p0q5c4593r2yd3jwgxn20d65ulyw6z9r7xmm78apq2067mf + Restricted Address: rms1xqqr7apqdpt0u59uznzkskydg3kxfeq6dfah2nnu3mgg50cm00cl5yqpqgrpy62q, Capabilities: mana + */ + AccountID: blake2b.Sum256(lo.PanicOnErr(hexutil.DecodeHex("0x01fb6b9db5d96240aef00bc950d1c67a6494513f6d7cf784e57b4972b96ab2fe"))), + Address: iotago.Ed25519AddressFromPubKey(lo.PanicOnErr(hexutil.DecodeHex("0x01fb6b9db5d96240aef00bc950d1c67a6494513f6d7cf784e57b4972b96ab2fe"))), + Amount: mock.MinValidatorAccountAmount(protocolParamsFeature), + IssuerKey: iotago.Ed25519PublicKeyBlockIssuerKeyFromPublicKey(ed25519.PublicKey(lo.PanicOnErr(hexutil.DecodeHex("0x01fb6b9db5d96240aef00bc950d1c67a6494513f6d7cf784e57b4972b96ab2fe")))), + ExpirySlot: iotago.MaxSlotIndex, + BlockIssuanceCredits: iotago.MaxBlockIssuanceCredits / 4, + StakingEpochEnd: iotago.MaxEpochIndex, + FixedCost: 1, + StakedAmount: mock.MinValidatorAccountAmount(protocolParamsFeature), + Mana: iotago.Mana(mock.MinValidatorAccountAmount(protocolParamsFeature)), + }, + snapshotcreator.AccountDetails{ + /* + node-02-validator + + Ed25519 Public Key: 83e7f71a440afd48981a8b4684ddae24434b7182ce5c47cfb56ac528525fd4b6 + Ed25519 Address: rms1qzjwamvhjuqtw3dkfwmmj2fgcetcdyt4uxrnjxel4caxfstzz903ypu8xvn + Account Address: rms1pzjwamvhjuqtw3dkfwmmj2fgcetcdyt4uxrnjxel4caxfstzz903y7hhr3d + Restricted Address: rms1xqq2fmhdj7tspd69ke9m0wff9rr90p53whscwwgm87hr5expvgg47yspqgm6whkx, Capabilities: mana + */ + AccountID: blake2b.Sum256(lo.PanicOnErr(hexutil.DecodeHex("0x83e7f71a440afd48981a8b4684ddae24434b7182ce5c47cfb56ac528525fd4b6"))), + Address: iotago.Ed25519AddressFromPubKey(lo.PanicOnErr(hexutil.DecodeHex("0x83e7f71a440afd48981a8b4684ddae24434b7182ce5c47cfb56ac528525fd4b6"))), + Amount: mock.MinValidatorAccountAmount(protocolParamsFeature), + IssuerKey: iotago.Ed25519PublicKeyBlockIssuerKeyFromPublicKey(ed25519.PublicKey(lo.PanicOnErr(hexutil.DecodeHex("0x83e7f71a440afd48981a8b4684ddae24434b7182ce5c47cfb56ac528525fd4b6")))), + ExpirySlot: iotago.MaxSlotIndex, + BlockIssuanceCredits: iotago.MaxBlockIssuanceCredits / 4, + StakingEpochEnd: iotago.MaxEpochIndex, + FixedCost: 1, + StakedAmount: mock.MinValidatorAccountAmount(protocolParamsFeature), + Mana: iotago.Mana(mock.MinValidatorAccountAmount(protocolParamsFeature)), + }, + snapshotcreator.AccountDetails{ + /* + node-03-validator + + Ed25519 Public Key: ac628986b2ef52a1679f2289fcd7b4198476976dea4c30ae34ff04ae52e14805 + Ed25519 Address: rms1qz6kedkxyw9md2cmp0wcdhvsxrn2e7gzuyly76ffymy4dhvtkm58qlkjupg + Account Address: rms1pz6kedkxyw9md2cmp0wcdhvsxrn2e7gzuyly76ffymy4dhvtkm58qqazeuk + Restricted Address: rms1xqqt2m9kcc3chd4trv9ampkajqcwdt8eqtsnunmf9ynvj4ka3wmwsuqpqgvp9zxl, Capabilities: mana + */ + AccountID: blake2b.Sum256(lo.PanicOnErr(hexutil.DecodeHex("0xac628986b2ef52a1679f2289fcd7b4198476976dea4c30ae34ff04ae52e14805"))), + Address: iotago.Ed25519AddressFromPubKey(lo.PanicOnErr(hexutil.DecodeHex("0xac628986b2ef52a1679f2289fcd7b4198476976dea4c30ae34ff04ae52e14805"))), + Amount: mock.MinValidatorAccountAmount(protocolParamsFeature), + IssuerKey: iotago.Ed25519PublicKeyBlockIssuerKeyFromPublicKey(ed25519.PublicKey(lo.PanicOnErr(hexutil.DecodeHex("0xac628986b2ef52a1679f2289fcd7b4198476976dea4c30ae34ff04ae52e14805")))), + ExpirySlot: iotago.MaxSlotIndex, + BlockIssuanceCredits: iotago.MaxBlockIssuanceCredits / 4, + StakingEpochEnd: iotago.MaxEpochIndex, + FixedCost: 1, + StakedAmount: mock.MinValidatorAccountAmount(protocolParamsFeature), + Mana: iotago.Mana(mock.MinValidatorAccountAmount(protocolParamsFeature)), + }, + snapshotcreator.AccountDetails{ + /* + inx-blockissuer + + Ed25519 Public Key: 670a1a20ddb02a6cec53ec3196bc7d5bd26df2f5a6ca90b5fffd71364f104b25 + Ed25519 Address: rms1qqas0clgfsf8du9e6dw0yx9nwclqe0dd4f728pvgmcshpscm8r5mkjxnx5x + Account Address: rms1pqas0clgfsf8du9e6dw0yx9nwclqe0dd4f728pvgmcshpscm8r5mkddrrfc + Restricted Address: rms1xqqrkplrapxpyahsh8f4eusckdmrur9a4k48egu93r0zzuxrrvuwnwcpqgj0nu8t, Capabilities: mana + */ + AccountID: blake2b.Sum256(lo.PanicOnErr(hexutil.DecodeHex("0x670a1a20ddb02a6cec53ec3196bc7d5bd26df2f5a6ca90b5fffd71364f104b25"))), + Address: iotago.Ed25519AddressFromPubKey(lo.PanicOnErr(hexutil.DecodeHex("0x670a1a20ddb02a6cec53ec3196bc7d5bd26df2f5a6ca90b5fffd71364f104b25"))), + Amount: mock.MinIssuerAccountAmount(protocolParamsFeature), + IssuerKey: iotago.Ed25519PublicKeyBlockIssuerKeyFromPublicKey(ed25519.PublicKey(lo.PanicOnErr(hexutil.DecodeHex("0x670a1a20ddb02a6cec53ec3196bc7d5bd26df2f5a6ca90b5fffd71364f104b25")))), + ExpirySlot: iotago.MaxSlotIndex, + BlockIssuanceCredits: iotago.MaxBlockIssuanceCredits / 4, + Mana: iotago.Mana(mock.MinIssuerAccountAmount(protocolParamsFeature)), + }, + ), + snapshotcreator.WithBasicOutputs( /* - inx-blockissuer + inx-faucet - Ed25519 Public Key: 670a1a20ddb02a6cec53ec3196bc7d5bd26df2f5a6ca90b5fffd71364f104b25 - Ed25519 Address: rms1qqas0clgfsf8du9e6dw0yx9nwclqe0dd4f728pvgmcshpscm8r5mkjxnx5x - Account Address: rms1pqas0clgfsf8du9e6dw0yx9nwclqe0dd4f728pvgmcshpscm8r5mkddrrfc - Restricted Address: rms1xqqrkplrapxpyahsh8f4eusckdmrur9a4k48egu93r0zzuxrrvuwnwcpqgj0nu8t, Capabilities: mana + Ed25519 Public Key: dcd760a51cfafe901f4ca0745d399af7146028af643e8a339c7bb82fbb1be7f9 + Ed25519 Address: rms1qpy2e4my7cn9ydjx6hx0ytuq06tdxzm6kqry7dctvmagzxv9np0vg9c55n4 + Restricted Address: rms1xqqy3txhvnmzv53kgm2ueu30splfd5ct02cqvnehpdn04qgeskv9a3qpqgrhlhv3, Capabilities: mana */ - AccountID: blake2b.Sum256(lo.PanicOnErr(hexutil.DecodeHex("0x670a1a20ddb02a6cec53ec3196bc7d5bd26df2f5a6ca90b5fffd71364f104b25"))), - Address: iotago.Ed25519AddressFromPubKey(lo.PanicOnErr(hexutil.DecodeHex("0x670a1a20ddb02a6cec53ec3196bc7d5bd26df2f5a6ca90b5fffd71364f104b25"))), - Amount: mock.MinIssuerAccountAmount, - IssuerKey: iotago.Ed25519PublicKeyBlockIssuerKeyFromPublicKey(ed25519.PublicKey(lo.PanicOnErr(hexutil.DecodeHex("0x670a1a20ddb02a6cec53ec3196bc7d5bd26df2f5a6ca90b5fffd71364f104b25")))), - ExpirySlot: iotago.MaxSlotIndex, - BlockIssuanceCredits: iotago.MaxBlockIssuanceCredits / 4, - Mana: iotago.Mana(mock.MinIssuerAccountAmount), - }, - ), - snapshotcreator.WithBasicOutputs( - /* - inx-faucet - - Ed25519 Public Key: dcd760a51cfafe901f4ca0745d399af7146028af643e8a339c7bb82fbb1be7f9 - Ed25519 Address: rms1qpy2e4my7cn9ydjx6hx0ytuq06tdxzm6kqry7dctvmagzxv9np0vg9c55n4 - Restricted Address: rms1xqqy3txhvnmzv53kgm2ueu30splfd5ct02cqvnehpdn04qgeskv9a3qpqgrhlhv3, Capabilities: mana - */ - snapshotcreator.BasicOutputDetails{ - Address: lo.Return2(iotago.ParseBech32("rms1xqqy3txhvnmzv53kgm2ueu30splfd5ct02cqvnehpdn04qgeskv9a3qpqgrhlhv3")), - Amount: 1_000_000_000_000_000, - Mana: 10_000_000, - }, - ), - snapshotcreator.WithProtocolParameters( - iotago.NewV3ProtocolParameters( - iotago.WithNetworkOptions("feature", "rms"), - iotago.WithSupplyOptions(4_600_000_000_000_000, 250, 1, 1000, 100000, 500000, 100000), - iotago.WithTimeProviderOptions(666666, time.Now().Unix()-100_000, 10, 13), // Let's fix genesis at 10_000 slots back. - iotago.WithLivenessOptions(30, 30, 10, 20, 30), - // increase/decrease threshold = fraction * slotDurationInSeconds * schedulerRate - iotago.WithCongestionControlOptions(500, 500, 500, 800000, 500000, 100000, 1000, 100), - iotago.WithWorkScoreOptions(25, 1, 100, 50, 10, 10, 50, 1, 10, 250), + snapshotcreator.BasicOutputDetails{ + Address: lo.Return2(iotago.ParseBech32("rms1xqqy3txhvnmzv53kgm2ueu30splfd5ct02cqvnehpdn04qgeskv9a3qpqgrhlhv3")), + Amount: 1_000_000_000_000_000, + Mana: 10_000_000, + }, ), - ), -} + } +) From 0f5e58865e2cc5793ccdcd9fa658625a0a706c9c Mon Sep 17 00:00:00 2001 From: muXxer Date: Thu, 23 Nov 2023 15:24:19 +0100 Subject: [PATCH 2/6] Fix the github workflow --- .github/workflows/docker-network-health.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/docker-network-health.yml b/.github/workflows/docker-network-health.yml index b2ac8c32b..99d1fdd3d 100644 --- a/.github/workflows/docker-network-health.yml +++ b/.github/workflows/docker-network-health.yml @@ -3,10 +3,12 @@ name: Run Docker Network and Check Health on: workflow_dispatch: pull_request: - paths-ignore: - - 'documentation/**' - - 'scripts/**' - - 'tools/**' + paths: + - '*' + - '!documentation/**' + - '!scripts/**' + - '!tools/**' + - 'tools/genesis-snapshot/**' concurrency: group: run-and-check-group From 14a72ac0615aa89979321b626f0ecd197487a73f Mon Sep 17 00:00:00 2001 From: muXxer Date: Thu, 23 Nov 2023 15:29:04 +0100 Subject: [PATCH 3/6] Fix tests --- pkg/testsuite/mock/utils.go | 8 ++++++-- pkg/testsuite/mock/wallet.go | 2 -- pkg/testsuite/mock/wallet_transactions.go | 12 ++++++------ 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/pkg/testsuite/mock/utils.go b/pkg/testsuite/mock/utils.go index c083ae39d..8b59b713f 100644 --- a/pkg/testsuite/mock/utils.go +++ b/pkg/testsuite/mock/utils.go @@ -61,12 +61,16 @@ func MinValidatorAccountAmount(protocolParameters iotago.ProtocolParameters) iot return lo.PanicOnErr(storageScoreStructure.MinDeposit(dummyAccountOutput)) } -// TODO: add the correct formula later +// TODO: add the correct formula later. +// +//nolint:revive func AccountConversionManaCost(protocolParameters iotago.ProtocolParameters) iotago.Mana { return iotago.Mana(1000000) } -// TODO: add the correct formula later +// TODO: add the correct formula later. +// +//nolint:revive func MaxBlockManaCost(protocolParameters iotago.ProtocolParameters) iotago.Mana { return iotago.Mana(1000000) } diff --git a/pkg/testsuite/mock/wallet.go b/pkg/testsuite/mock/wallet.go index e0f59be89..c7c1ec176 100644 --- a/pkg/testsuite/mock/wallet.go +++ b/pkg/testsuite/mock/wallet.go @@ -26,8 +26,6 @@ type Wallet struct { keyManager *KeyManager - apiProvider iotago.APIProvider - BlockIssuer *BlockIssuer outputs map[string]*utxoledger.Output diff --git a/pkg/testsuite/mock/wallet_transactions.go b/pkg/testsuite/mock/wallet_transactions.go index 91430d682..c92069183 100644 --- a/pkg/testsuite/mock/wallet_transactions.go +++ b/pkg/testsuite/mock/wallet_transactions.go @@ -21,7 +21,7 @@ func (w *Wallet) CreateAccountFromInput(transactionName string, inputName string input := w.Output(inputName) accountOutput := options.Apply(builder.NewAccountOutputBuilder(recipientWallet.Address(), input.BaseTokenAmount()). - Mana(MaxBlockManaCost(w.apiProvider.CommittedAPI().ProtocolParameters())), + Mana(MaxBlockManaCost(w.Node.Protocol.CommittedAPI().ProtocolParameters())), opts).MustBuild() outputStates := iotago.Outputs[iotago.Output]{accountOutput} @@ -197,8 +197,8 @@ func (w *Wallet) CreateImplicitAccountFromInput(transactionName string, inputNam input := w.Output(inputName) implicitAccountOutput := &iotago.BasicOutput{ - Amount: MinIssuerAccountAmount(w.apiProvider.CommittedAPI().ProtocolParameters()), - Mana: AccountConversionManaCost(w.apiProvider.CommittedAPI().ProtocolParameters()), + Amount: MinIssuerAccountAmount(w.Node.Protocol.CommittedAPI().ProtocolParameters()), + Mana: AccountConversionManaCost(w.Node.Protocol.CommittedAPI().ProtocolParameters()), UnlockConditions: iotago.BasicOutputUnlockConditions{ &iotago.AddressUnlockCondition{Address: recipientWallet.ImplicitAccountCreationAddress()}, }, @@ -206,8 +206,8 @@ func (w *Wallet) CreateImplicitAccountFromInput(transactionName string, inputNam } remainderBasicOutput := &iotago.BasicOutput{ - Amount: input.BaseTokenAmount() - MinIssuerAccountAmount(w.apiProvider.CommittedAPI().ProtocolParameters()), - Mana: input.StoredMana() - AccountConversionManaCost(w.apiProvider.CommittedAPI().ProtocolParameters()), + Amount: input.BaseTokenAmount() - MinIssuerAccountAmount(w.Node.Protocol.CommittedAPI().ProtocolParameters()), + Mana: input.StoredMana() - AccountConversionManaCost(w.Node.Protocol.CommittedAPI().ProtocolParameters()), UnlockConditions: iotago.BasicOutputUnlockConditions{ &iotago.AddressUnlockCondition{Address: input.Output().UnlockConditionSet().Address().Address}, }, @@ -242,7 +242,7 @@ func (w *Wallet) TransitionImplicitAccountToAccountOutput(transactionName string panic(fmt.Sprintf("output with alias %s is not an implicit account", inputName)) } - accountOutput := options.Apply(builder.NewAccountOutputBuilder(w.Address(), MinIssuerAccountAmount(w.apiProvider.CommittedAPI().ProtocolParameters())). + accountOutput := options.Apply(builder.NewAccountOutputBuilder(w.Address(), MinIssuerAccountAmount(w.Node.Protocol.CommittedAPI().ProtocolParameters())). AccountID(iotago.AccountIDFromOutputID(input.OutputID())), opts).MustBuild() From 0a58f41011db399aff7f9ae0a8618558a8e685b7 Mon Sep 17 00:00:00 2001 From: muXxer Date: Thu, 23 Nov 2023 22:42:32 +0100 Subject: [PATCH 4/6] Add `AddDefaultWallet` to `TestSuite` to increase readability --- pkg/tests/accounts_test.go | 29 ++++++++++++++++++--- pkg/tests/booker_test.go | 12 ++++----- pkg/tests/committee_rotation_test.go | 2 +- pkg/tests/loss_of_acceptance_test.go | 6 ++--- pkg/tests/protocol_engine_switching_test.go | 2 +- pkg/tests/protocol_startup_test.go | 2 +- pkg/tests/upgrade_signaling_test.go | 2 +- pkg/testsuite/testsuite.go | 26 +++++++++++------- 8 files changed, 56 insertions(+), 25 deletions(-) diff --git a/pkg/tests/accounts_test.go b/pkg/tests/accounts_test.go index 15b7963fd..c0b263dec 100644 --- a/pkg/tests/accounts_test.go +++ b/pkg/tests/accounts_test.go @@ -58,7 +58,7 @@ func Test_TransitionAndDestroyAccount(t *testing.T) { // Add a non-validator node to the network. This will not add any accounts to the snapshot. _ = ts.AddNode("node2") // Add a default block issuer to the network. This will add another block issuer account to the snapshot. - wallet := ts.AddGenesisWallet("default", node1, iotago.MaxBlockIssuanceCredits/2) + wallet := ts.AddDefaultWallet(node1, iotago.MaxBlockIssuanceCredits/2) ts.Run(true) @@ -73,6 +73,7 @@ func Test_TransitionAndDestroyAccount(t *testing.T) { ExpirySlot: iotago.MaxSlotIndex, BlockIssuerKeys: iotago.NewBlockIssuerKeys(oldGenesisOutputKey), }, ts.Nodes()...) + // validator node account. validatorAccountOutput := ts.AccountOutput("Genesis:2") ts.AssertAccountData(&accounts.AccountData{ @@ -84,6 +85,7 @@ func Test_TransitionAndDestroyAccount(t *testing.T) { StakeEndEpoch: iotago.MaxEpochIndex, ValidatorStake: mock.MinValidatorAccountAmount(ts.API.ProtocolParameters()), }, ts.Nodes()...) + // default wallet block issuer account. blockIssuerAccountOutput := ts.AccountOutput("Genesis:3") ts.AssertAccountData(&accounts.AccountData{ @@ -187,7 +189,7 @@ func Test_StakeDelegateAndDelayedClaim(t *testing.T) { // Add a non-validator node to the network. This will not add any accounts to the snapshot. _ = ts.AddNode("node2") // Add a default block issuer to the network. This will add another block issuer account to the snapshot. - wallet := ts.AddGenesisWallet("default", node1, iotago.MaxBlockIssuanceCredits/2) + wallet := ts.AddDefaultWallet(node1, iotago.MaxBlockIssuanceCredits/2) ts.Run(true) @@ -203,6 +205,7 @@ func Test_StakeDelegateAndDelayedClaim(t *testing.T) { StakeEndEpoch: iotago.MaxEpochIndex, ValidatorStake: mock.MinValidatorAccountAmount(ts.API.ProtocolParameters()), }, ts.Nodes()...) + // Default wallet block issuer account. blockIssuerAccountOutput := ts.AccountOutput("Genesis:2") ts.AssertAccountData(&accounts.AccountData{ @@ -362,7 +365,7 @@ func Test_ImplicitAccounts(t *testing.T) { // Add a non-validator node to the network. This will not add any accounts to the snapshot. _ = ts.AddNode("node2") // Add a default block issuer to the network. This will add another block issuer account to the snapshot. - wallet := ts.AddGenesisWallet("default", node1, iotago.MaxBlockIssuanceCredits/2) + wallet := ts.AddDefaultWallet(node1, iotago.MaxBlockIssuanceCredits/2) ts.Run(true) @@ -378,6 +381,7 @@ func Test_ImplicitAccounts(t *testing.T) { StakeEndEpoch: iotago.MaxEpochIndex, ValidatorStake: mock.MinValidatorAccountAmount(ts.API.ProtocolParameters()), }, ts.Nodes()...) + // default wallet block issuer account. blockIssuerAccountOutput := ts.AccountOutput("Genesis:2") ts.AssertAccountData(&accounts.AccountData{ @@ -406,6 +410,7 @@ func Test_ImplicitAccounts(t *testing.T) { implicitAccountOutputID := implicitAccountOutput.OutputID() implicitAccountID := iotago.AccountIDFromOutputID(implicitAccountOutputID) var implicitBlockIssuerKey iotago.BlockIssuerKey = iotago.Ed25519PublicKeyHashBlockIssuerKeyFromImplicitAccountCreationAddress(newUserWallet.ImplicitAccountCreationAddress()) + // the new implicit account should now be registered in the accounts ledger. ts.AssertAccountData(&accounts.AccountData{ ID: implicitAccountID, @@ -451,6 +456,7 @@ func Test_ImplicitAccounts(t *testing.T) { FixedCostChange: 0, DelegationStakeChange: 0, }, false, ts.Nodes()...) + ts.AssertAccountData(&accounts.AccountData{ ID: implicitAccountID, Credits: accounts.NewBlockIssuanceCredits(allotted-burned, block2Slot), @@ -542,6 +548,7 @@ func Test_NegativeBIC_BlockIssuerLocked(t *testing.T) { ExpirySlot: iotago.MaxSlotIndex, BlockIssuerKeys: wallet1.BlockIssuer.BlockIssuerKeys(), }, ts.Nodes()...) + ts.AssertAccountData(&accounts.AccountData{ ID: wallet2.BlockIssuer.AccountID, Credits: accounts.NewBlockIssuanceCredits(wallet2BIC, block1Slot), @@ -577,6 +584,7 @@ func Test_NegativeBIC_BlockIssuerLocked(t *testing.T) { ExpirySlot: iotago.MaxSlotIndex, BlockIssuerKeys: wallet1.BlockIssuer.BlockIssuerKeys(), }, ts.Nodes()...) + ts.AssertAccountData(&accounts.AccountData{ ID: wallet2.BlockIssuer.AccountID, Credits: accounts.NewBlockIssuanceCredits(wallet2BIC, block1Slot), @@ -616,6 +624,7 @@ func Test_NegativeBIC_BlockIssuerLocked(t *testing.T) { ExpirySlot: iotago.MaxSlotIndex, BlockIssuerKeys: wallet1.BlockIssuer.BlockIssuerKeys(), }, ts.Nodes()...) + ts.AssertAccountData(&accounts.AccountData{ ID: wallet2.BlockIssuer.AccountID, Credits: accounts.NewBlockIssuanceCredits(wallet2BIC, block3Slot), @@ -646,6 +655,7 @@ func Test_NegativeBIC_BlockIssuerLocked(t *testing.T) { ExpirySlot: iotago.MaxSlotIndex, BlockIssuerKeys: wallet1.BlockIssuer.BlockIssuerKeys(), }, ts.Nodes()...) + ts.AssertAccountData(&accounts.AccountData{ ID: wallet2.BlockIssuer.AccountID, Credits: accounts.NewBlockIssuanceCredits(wallet2BIC, block4Slot), @@ -700,6 +710,7 @@ func Test_NegativeBIC_AccountOutput(t *testing.T) { StakeEndEpoch: iotago.MaxEpochIndex, ValidatorStake: mock.MinValidatorAccountAmount(ts.API.ProtocolParameters()), }, ts.Nodes()...) + // default wallet block issuer account. wallet1AccountOutput := ts.AccountOutput("Genesis:2") ts.AssertAccountData(&accounts.AccountData{ @@ -709,6 +720,7 @@ func Test_NegativeBIC_AccountOutput(t *testing.T) { ExpirySlot: iotago.MaxSlotIndex, BlockIssuerKeys: wallet1.BlockIssuer.BlockIssuerKeys(), }, ts.Nodes()...) + wallet2AccountOutput := ts.AccountOutput("Genesis:3") ts.AssertAccountData(&accounts.AccountData{ ID: wallet2.BlockIssuer.AccountID, @@ -723,10 +735,12 @@ func Test_NegativeBIC_AccountOutput(t *testing.T) { var block1Slot iotago.SlotIndex = 1 var latestParents []iotago.BlockID ts.SetCurrentSlot(block1Slot) + // set the expiry of the genesis account to be the block slot + max committable age. newExpirySlot := block1Slot + ts.API.ProtocolParameters().MaxCommittableAge() { // Prepare a transaction that will try to spend an AccountOutput of a locked account. + // BUG: How can we add a block issuer feature here with only minimum funds? tx1 := wallet1.TransitionAccount( "TX1", "Genesis:2", @@ -753,6 +767,7 @@ func Test_NegativeBIC_AccountOutput(t *testing.T) { ExpirySlot: iotago.MaxSlotIndex, BlockIssuerKeys: wallet1.BlockIssuer.BlockIssuerKeys(), }, ts.Nodes()...) + ts.AssertAccountData(&accounts.AccountData{ ID: wallet2.BlockIssuer.AccountID, Credits: accounts.NewBlockIssuanceCredits(wallet2BIC, 0), @@ -790,6 +805,7 @@ func Test_NegativeBIC_AccountOutput(t *testing.T) { ExpirySlot: iotago.MaxSlotIndex, BlockIssuerKeys: wallet1.BlockIssuer.BlockIssuerKeys(), }, ts.Nodes()...) + ts.AssertAccountData(&accounts.AccountData{ ID: wallet2.BlockIssuer.AccountID, Credits: accounts.NewBlockIssuanceCredits(wallet2BIC, block2Slot), @@ -828,6 +844,7 @@ func Test_NegativeBIC_AccountOutput(t *testing.T) { ExpirySlot: newExpirySlot, BlockIssuerKeys: iotago.NewBlockIssuerKeys(wallet1.BlockIssuer.BlockIssuerKeys()[0], newWallet1IssuerKey), }, ts.Nodes()...) + ts.AssertAccountData(&accounts.AccountData{ ID: wallet2.BlockIssuer.AccountID, Credits: accounts.NewBlockIssuanceCredits(wallet2BIC, block2Slot), @@ -914,6 +931,7 @@ func Test_NegativeBIC_AccountOwnedBasicOutputLocked(t *testing.T) { StakeEndEpoch: iotago.MaxEpochIndex, ValidatorStake: mock.MinValidatorAccountAmount(ts.API.ProtocolParameters()), }, ts.Nodes()...) + // default wallet block issuer account. wallet1AccountOutput := ts.AccountOutput("Genesis:2") ts.AssertAccountData(&accounts.AccountData{ @@ -923,6 +941,7 @@ func Test_NegativeBIC_AccountOwnedBasicOutputLocked(t *testing.T) { ExpirySlot: iotago.MaxSlotIndex, BlockIssuerKeys: wallet1.BlockIssuer.BlockIssuerKeys(), }, ts.Nodes()...) + wallet2AccountOutput := ts.AccountOutput("Genesis:3") ts.AssertAccountData(&accounts.AccountData{ ID: wallet2.BlockIssuer.AccountID, @@ -974,6 +993,7 @@ func Test_NegativeBIC_AccountOwnedBasicOutputLocked(t *testing.T) { ExpirySlot: iotago.MaxSlotIndex, BlockIssuerKeys: wallet1.BlockIssuer.BlockIssuerKeys(), }, ts.Nodes()...) + ts.AssertAccountData(&accounts.AccountData{ ID: wallet2.BlockIssuer.AccountID, Credits: accounts.NewBlockIssuanceCredits(wallet2BIC, block1Slot), @@ -1011,6 +1031,7 @@ func Test_NegativeBIC_AccountOwnedBasicOutputLocked(t *testing.T) { ExpirySlot: iotago.MaxSlotIndex, BlockIssuerKeys: wallet1.BlockIssuer.BlockIssuerKeys(), }, ts.Nodes()...) + ts.AssertAccountData(&accounts.AccountData{ ID: wallet2.BlockIssuer.AccountID, Credits: accounts.NewBlockIssuanceCredits(wallet2BIC, block1Slot), @@ -1054,6 +1075,7 @@ func Test_NegativeBIC_AccountOwnedBasicOutputLocked(t *testing.T) { ExpirySlot: iotago.MaxSlotIndex, BlockIssuerKeys: wallet1.BlockIssuer.BlockIssuerKeys(), }, ts.Nodes()...) + ts.AssertAccountData(&accounts.AccountData{ ID: wallet2.BlockIssuer.AccountID, Credits: accounts.NewBlockIssuanceCredits(wallet2BIC, block3Slot), @@ -1092,6 +1114,7 @@ func Test_NegativeBIC_AccountOwnedBasicOutputLocked(t *testing.T) { ExpirySlot: iotago.MaxSlotIndex, BlockIssuerKeys: wallet1.BlockIssuer.BlockIssuerKeys(), }, ts.Nodes()...) + ts.AssertAccountData(&accounts.AccountData{ ID: wallet2.BlockIssuer.AccountID, Credits: accounts.NewBlockIssuanceCredits(wallet2BIC, block3Slot), diff --git a/pkg/tests/booker_test.go b/pkg/tests/booker_test.go index 8164ec8dd..9caaa604e 100644 --- a/pkg/tests/booker_test.go +++ b/pkg/tests/booker_test.go @@ -18,7 +18,7 @@ func Test_IssuingTransactionsOutOfOrder(t *testing.T) { defer ts.Shutdown() node1 := ts.AddValidatorNode("node1") - wallet := ts.AddGenesisWallet("default", node1) + wallet := ts.AddDefaultWallet(node1) ts.Run(true, map[string][]options.Option[protocol.Protocol]{}) tx1 := wallet.CreateBasicOutputsEquallyFromInput("tx1", 1, "Genesis:0") @@ -55,7 +55,7 @@ func Test_WeightPropagation(t *testing.T) { node1 := ts.AddValidatorNode("node1") node2 := ts.AddValidatorNode("node2") - wallet := ts.AddGenesisWallet("default", node1) + wallet := ts.AddDefaultWallet(node1) ts.Run(true, map[string][]options.Option[protocol.Protocol]{}) @@ -145,7 +145,7 @@ func Test_DoubleSpend(t *testing.T) { node1 := ts.AddValidatorNode("node1") node2 := ts.AddValidatorNode("node2") - wallet := ts.AddGenesisWallet("default", node1) + wallet := ts.AddDefaultWallet(node1) ts.Run(true, map[string][]options.Option[protocol.Protocol]{}) @@ -215,7 +215,7 @@ func Test_MultipleAttachments(t *testing.T) { nodeA := ts.AddValidatorNode("nodeA") nodeB := ts.AddValidatorNode("nodeB") - wallet := ts.AddGenesisWallet("default", nodeA) + wallet := ts.AddDefaultWallet(nodeA) ts.Run(true, map[string][]options.Option[protocol.Protocol]{}) @@ -339,7 +339,7 @@ func Test_SpendRejectedCommittedRace(t *testing.T) { node1 := ts.AddValidatorNode("node1") node2 := ts.AddValidatorNode("node2") - wallet := ts.AddGenesisWallet("default", node1) + wallet := ts.AddDefaultWallet(node1) ts.Run(true, map[string][]options.Option[protocol.Protocol]{}) @@ -612,7 +612,7 @@ func Test_SpendPendingCommittedRace(t *testing.T) { node1 := ts.AddValidatorNode("node1") node2 := ts.AddValidatorNode("node2") - wallet := ts.AddGenesisWallet("default", node1) + wallet := ts.AddDefaultWallet(node1) ts.Run(true, map[string][]options.Option[protocol.Protocol]{}) diff --git a/pkg/tests/committee_rotation_test.go b/pkg/tests/committee_rotation_test.go index a7415bc24..50f3cbc34 100644 --- a/pkg/tests/committee_rotation_test.go +++ b/pkg/tests/committee_rotation_test.go @@ -40,7 +40,7 @@ func Test_TopStakersRotation(t *testing.T) { ts.AddValidatorNode("node4", 1_000_003) ts.AddValidatorNode("node5", 1_000_002) ts.AddValidatorNode("node6", 1_000_001) - ts.AddGenesisWallet("default", node1) + ts.AddDefaultWallet(node1) ts.AddNode("node7") diff --git a/pkg/tests/loss_of_acceptance_test.go b/pkg/tests/loss_of_acceptance_test.go index 89209a02f..919e12c51 100644 --- a/pkg/tests/loss_of_acceptance_test.go +++ b/pkg/tests/loss_of_acceptance_test.go @@ -36,7 +36,7 @@ func TestLossOfAcceptanceFromGenesis(t *testing.T) { defer ts.Shutdown() node0 := ts.AddValidatorNode("node0") - ts.AddGenesisWallet("default", node0) + ts.AddDefaultWallet(node0) ts.AddValidatorNode("node1") ts.AddNode("node2") @@ -121,7 +121,7 @@ func TestLossOfAcceptanceFromSnapshot(t *testing.T) { defer ts.Shutdown() node0 := ts.AddValidatorNode("node0") - ts.AddGenesisWallet("default", node0) + ts.AddDefaultWallet(node0) ts.AddValidatorNode("node1") node2 := ts.AddNode("node2") @@ -215,7 +215,7 @@ func TestLossOfAcceptanceWithRestartFromDisk(t *testing.T) { defer ts.Shutdown() node0 := ts.AddValidatorNode("node0") - ts.AddGenesisWallet("default", node0) + ts.AddDefaultWallet(node0) ts.AddValidatorNode("node1") node2 := ts.AddNode("node2") diff --git a/pkg/tests/protocol_engine_switching_test.go b/pkg/tests/protocol_engine_switching_test.go index 03b2cfc81..506dbcd93 100644 --- a/pkg/tests/protocol_engine_switching_test.go +++ b/pkg/tests/protocol_engine_switching_test.go @@ -57,7 +57,7 @@ func TestProtocol_EngineSwitching(t *testing.T) { node6 := ts.AddValidatorNode("node6") node7 := ts.AddValidatorNode("node7") node8 := ts.AddNode("node8") - ts.AddGenesisWallet("default", node0, iotago.MaxBlockIssuanceCredits/2) + ts.AddDefaultWallet(node0, iotago.MaxBlockIssuanceCredits/2) const expectedCommittedSlotAfterPartitionMerge = 19 nodesP1 := []*mock.Node{node0, node1, node2, node3, node4, node5} diff --git a/pkg/tests/protocol_startup_test.go b/pkg/tests/protocol_startup_test.go index 1c6a2210c..cc4e23a33 100644 --- a/pkg/tests/protocol_startup_test.go +++ b/pkg/tests/protocol_startup_test.go @@ -146,7 +146,7 @@ func Test_StartNodeFromSnapshotAndDisk(t *testing.T) { nodeA := ts.AddValidatorNode("nodeA") nodeB := ts.AddValidatorNode("nodeB") ts.AddNode("nodeC") - ts.AddGenesisWallet("default", nodeA, iotago.MaxBlockIssuanceCredits/2) + ts.AddDefaultWallet(nodeA, iotago.MaxBlockIssuanceCredits/2) nodeOptions := []options.Option[protocol.Protocol]{ protocol.WithStorageOptions( diff --git a/pkg/tests/upgrade_signaling_test.go b/pkg/tests/upgrade_signaling_test.go index 7cc21ff8e..9d009abef 100644 --- a/pkg/tests/upgrade_signaling_test.go +++ b/pkg/tests/upgrade_signaling_test.go @@ -126,7 +126,7 @@ func Test_Upgrade_Signaling(t *testing.T) { ts.AddValidatorNode("nodeD") ts.AddNode("nodeE") ts.AddNode("nodeF") - wallet := ts.AddGenesisWallet("default", nodeA, iotago.MaxBlockIssuanceCredits/2) + wallet := ts.AddDefaultWallet(nodeA, iotago.MaxBlockIssuanceCredits/2) ts.Run(true, map[string][]options.Option[protocol.Protocol]{ "nodeA": nodeOptionsWithoutV5, diff --git a/pkg/testsuite/testsuite.go b/pkg/testsuite/testsuite.go index bb8e97927..dcabdc303 100644 --- a/pkg/testsuite/testsuite.go +++ b/pkg/testsuite/testsuite.go @@ -409,17 +409,16 @@ func (t *TestSuite) AddGenesisWallet(name string, node *mock.Node, blockIssuance return newWallet } -func (t *TestSuite) AddWallet(name string, node *mock.Node, accountID iotago.AccountID, keyManager ...*mock.KeyManager) *mock.Wallet { - newWallet := mock.NewWallet(t.Testing, name, node, keyManager...) - newWallet.SetBlockIssuer(accountID) - t.wallets.Set(name, newWallet) - newWallet.SetCurrentSlot(t.currentSlot) +const ( + DefaultWallet = "defaultWallet" +) - return newWallet +func (t *TestSuite) AddDefaultWallet(node *mock.Node, blockIssuanceCredits ...iotago.BlockIssuanceCredits) *mock.Wallet { + return t.AddGenesisWallet(DefaultWallet, node, blockIssuanceCredits...) } func (t *TestSuite) DefaultWallet() *mock.Wallet { - defaultWallet, exists := t.wallets.Get("default") + defaultWallet, exists := t.wallets.Get(DefaultWallet) if !exists { return nil } @@ -427,6 +426,15 @@ func (t *TestSuite) DefaultWallet() *mock.Wallet { return defaultWallet } +func (t *TestSuite) AddWallet(name string, node *mock.Node, accountID iotago.AccountID, keyManager ...*mock.KeyManager) *mock.Wallet { + newWallet := mock.NewWallet(t.Testing, name, node, keyManager...) + newWallet.SetBlockIssuer(accountID) + t.wallets.Set(name, newWallet) + newWallet.SetCurrentSlot(t.currentSlot) + + return newWallet +} + // Update the global time of the test suite and all nodes and wallets. func (t *TestSuite) SetCurrentSlot(slot iotago.SlotIndex) { t.currentSlot = slot @@ -449,13 +457,13 @@ func (t *TestSuite) Run(failOnBlockFiltered bool, nodesOptions ...map[string][]o defer t.mutex.Unlock() // Add default wallet by default when creating the first node. - if !t.wallets.Has("default") { + if !t.wallets.Has(DefaultWallet) { _, node, exists := t.nodes.Head() if !exists { panic("at least one node is needed to create a default wallet") } - t.AddGenesisWallet("default", node) + t.AddDefaultWallet(node) } // Create accounts for any block issuer nodes added before starting the network. From ec1c279ae3191eb82f924554fa09fb2f86c44143 Mon Sep 17 00:00:00 2001 From: muXxer Date: Thu, 23 Nov 2023 23:05:01 +0100 Subject: [PATCH 5/6] Temporary fixes for the tests --- pkg/tests/accounts_test.go | 4 +++- pkg/testsuite/testsuite.go | 8 +++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/pkg/tests/accounts_test.go b/pkg/tests/accounts_test.go index c0b263dec..ca33f6ab1 100644 --- a/pkg/tests/accounts_test.go +++ b/pkg/tests/accounts_test.go @@ -228,7 +228,9 @@ func Test_StakeDelegateAndDelayedClaim(t *testing.T) { ts.DefaultWallet(), mock.WithBlockIssuerFeature(iotago.BlockIssuerKeys{newAccountBlockIssuerKey}, newAccountExpirySlot), mock.WithStakingFeature(10000, 421, 0, 10), - mock.WithAccountAmount(mock.MinIssuerAccountAmount(ts.API.ProtocolParameters())), + // TODO: Temporary "fix" for the tests, lets fix this in another PR, so we can at least use the docker network again + //mock.WithAccountAmount(mock.MinIssuerAccountAmount(ts.API.ProtocolParameters())), + mock.WithAccountAmount(mock.MinValidatorAccountAmount(ts.API.ProtocolParameters())), ) genesisCommitment := iotago.NewEmptyCommitment(ts.API) diff --git a/pkg/testsuite/testsuite.go b/pkg/testsuite/testsuite.go index dcabdc303..fdb5b62a5 100644 --- a/pkg/testsuite/testsuite.go +++ b/pkg/testsuite/testsuite.go @@ -395,9 +395,11 @@ func (t *TestSuite) AddGenesisWallet(name string, node *mock.Node, blockIssuance } accountDetails := snapshotcreator.AccountDetails{ - AccountID: accountID, - Address: iotago.Ed25519AddressFromPubKey(newWallet.BlockIssuer.PublicKey), - Amount: mock.MinIssuerAccountAmount(t.API.ProtocolParameters()), + AccountID: accountID, + Address: iotago.Ed25519AddressFromPubKey(newWallet.BlockIssuer.PublicKey), + // TODO: Temporary "fix" for the tests, lets fix this in another PR, so we can at least use the docker network again + //Amount: mock.MinIssuerAccountAmount(t.API.ProtocolParameters()), + Amount: mock.MinValidatorAccountAmount(t.API.ProtocolParameters()) + 800, Mana: iotago.Mana(mock.MinIssuerAccountAmount(t.API.ProtocolParameters())), IssuerKey: iotago.Ed25519PublicKeyBlockIssuerKeyFromPublicKey(ed25519.PublicKey(newWallet.BlockIssuer.PublicKey)), ExpirySlot: iotago.MaxSlotIndex, From 1793ca39fbf5d79fdd7bc4ff1ecf4654f2bc8658 Mon Sep 17 00:00:00 2001 From: muXxer Date: Fri, 24 Nov 2023 09:29:00 +0100 Subject: [PATCH 6/6] Fix comment --- tools/genesis-snapshot/presets/presets.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/genesis-snapshot/presets/presets.go b/tools/genesis-snapshot/presets/presets.go index 8f90767e6..707e7ff1b 100644 --- a/tools/genesis-snapshot/presets/presets.go +++ b/tools/genesis-snapshot/presets/presets.go @@ -155,7 +155,7 @@ var ( ), } - // Feature is a preset for the feature network, genesis time ~20th of July 2023. + // Feature is a preset for the feature network. Feature = []options.Option[snapshotcreator.Options]{ snapshotcreator.WithFilePath("docker-network.snapshot"), snapshotcreator.WithProtocolParameters(protocolParamsFeature),