From 64f5d337021bbc45a7293286b8b520b7760b9649 Mon Sep 17 00:00:00 2001 From: Andrew Date: Fri, 15 Sep 2023 13:03:49 +0100 Subject: [PATCH 01/24] add implicit account to accounts manager and check for their signatures in commitment filter --- go.mod | 2 +- go.sum | 4 ++-- .../accountsfilter/commitmentfilter.go | 17 +++++++++++------ pkg/protocol/engine/ledger/ledger/ledger.go | 16 +++++++++++++++- tools/evil-spammer/go.mod | 2 +- tools/evil-spammer/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 ++-- 10 files changed, 38 insertions(+), 19 deletions(-) diff --git a/go.mod b/go.mod index 7b6135a3d..ca0f238d8 100644 --- a/go.mod +++ b/go.mod @@ -24,7 +24,7 @@ require ( github.com/iotaledger/hive.go/stringify v0.0.0-20230906114834-b50190b9f9c2 github.com/iotaledger/inx-app v1.0.0-rc.3.0.20230829161228-3f4eb50a4d14 github.com/iotaledger/inx/go v1.0.0-rc.2.0.20230829160617-69b96c7c9f9b - github.com/iotaledger/iota.go/v4 v4.0.0-20230913143616-917572c7752d + github.com/iotaledger/iota.go/v4 v4.0.0-20230915114908-97b965f76784 github.com/labstack/echo/v4 v4.11.1 github.com/labstack/gommon v0.4.0 github.com/libp2p/go-libp2p v0.30.0 diff --git a/go.sum b/go.sum index d2bb86a59..eea0de2a2 100644 --- a/go.sum +++ b/go.sum @@ -307,8 +307,8 @@ github.com/iotaledger/inx-app v1.0.0-rc.3.0.20230829161228-3f4eb50a4d14 h1:BkDuQ github.com/iotaledger/inx-app v1.0.0-rc.3.0.20230829161228-3f4eb50a4d14/go.mod h1:ADBXzdHXTldP0NB2Vf+KbhDxkYciGRjzQVXT6Rdne1g= github.com/iotaledger/inx/go v1.0.0-rc.2.0.20230829160617-69b96c7c9f9b h1:EPB/+iWeSx/WgJlzaXl8yjinxuD8CCOdi2ZPMLeeMVY= github.com/iotaledger/inx/go v1.0.0-rc.2.0.20230829160617-69b96c7c9f9b/go.mod h1:B7gyJP6GshCSlEmY3CxEk5TZdsMs3UNz5U92hkFDdMs= -github.com/iotaledger/iota.go/v4 v4.0.0-20230913143616-917572c7752d h1:p9IchKq6kft758XDlnN/tAEXJMXGlmQPmbdxolba1gs= -github.com/iotaledger/iota.go/v4 v4.0.0-20230913143616-917572c7752d/go.mod h1:DWCa+mXRTGWBV0EHVuvToUxAEcICe2Pab9hBlxBamKo= +github.com/iotaledger/iota.go/v4 v4.0.0-20230915114908-97b965f76784 h1:lb/8KbtTOqwIqGb84F70dbmqENRDHZZul4AaPNapfAU= +github.com/iotaledger/iota.go/v4 v4.0.0-20230915114908-97b965f76784/go.mod h1:DWCa+mXRTGWBV0EHVuvToUxAEcICe2Pab9hBlxBamKo= github.com/ipfs/boxo v0.10.0 h1:tdDAxq8jrsbRkYoF+5Rcqyeb91hgWe2hp7iLu7ORZLY= github.com/ipfs/boxo v0.10.0/go.mod h1:Fg+BnfxZ0RPzR0nOodzdIq3A7KgoWAOWsEIImrIQdBM= github.com/ipfs/go-cid v0.4.1 h1:A/T3qGvxi4kpKWWcPC/PgbvDA2bjVLO7n4UeVwnbs/s= diff --git a/pkg/protocol/engine/commitmentfilter/accountsfilter/commitmentfilter.go b/pkg/protocol/engine/commitmentfilter/accountsfilter/commitmentfilter.go index 8c00824e6..7f0bf2cd0 100644 --- a/pkg/protocol/engine/commitmentfilter/accountsfilter/commitmentfilter.go +++ b/pkg/protocol/engine/commitmentfilter/accountsfilter/commitmentfilter.go @@ -1,6 +1,8 @@ package accountsfilter import ( + "crypto/ed25519" + "github.com/iotaledger/hive.go/core/safemath" hiveEd25519 "github.com/iotaledger/hive.go/crypto/ed25519" "github.com/iotaledger/hive.go/ierrors" @@ -155,12 +157,15 @@ func (c *CommitmentFilter) evaluateBlock(block *blocks.Block) { switch signature := block.ProtocolBlock().Signature.(type) { case *iotago.Ed25519Signature: if !accountData.BlockIssuerKeys.Has(iotago.BlockIssuerKeyEd25519FromPublicKey(signature.PublicKey)) { - c.events.BlockFiltered.Trigger(&commitmentfilter.BlockFilteredEvent{ - Block: block, - Reason: ierrors.Wrapf(ErrInvalidSignature, "block issuer account %s does not have public key %s in slot %d", block.ProtocolBlock().IssuerID, signature.PublicKey, block.ProtocolBlock().SlotCommitmentID.Index()), - }) - - return + // if the block issuer does not have the public key in the slot commitment, check if it has an implicit account with the corresponding address + if !accountData.BlockIssuerKeys.Has(iotago.BlockIssuerKeyEd25519AddressFromAddress(iotago.Ed25519AddressFromPubKey(ed25519.PublicKey(signature.PublicKey[:])))) { + c.events.BlockFiltered.Trigger(&commitmentfilter.BlockFilteredEvent{ + Block: block, + Reason: ierrors.Wrapf(ErrInvalidSignature, "block issuer account %s does not have block issuer key corresponding to public key %s in slot %d", block.ProtocolBlock().IssuerID, signature.PublicKey, block.ProtocolBlock().SlotCommitmentID.Index()), + }) + + return + } } signingMessage, err := block.ProtocolBlock().SigningMessage(blockAPI) if err != nil { diff --git a/pkg/protocol/engine/ledger/ledger/ledger.go b/pkg/protocol/engine/ledger/ledger/ledger.go index 46b80fe49..75b4a3709 100644 --- a/pkg/protocol/engine/ledger/ledger/ledger.go +++ b/pkg/protocol/engine/ledger/ledger/ledger.go @@ -439,7 +439,13 @@ func (l *Ledger) prepareAccountDiffs(accountDiffs map[iotago.AccountID]*model.Ac accountDiff.PreviousOutputID = iotago.EmptyOutputID accountDiff.NewExpirySlot = createdOutput.Output().FeatureSet().BlockIssuer().ExpirySlot accountDiff.PreviousExpirySlot = 0 - accountDiff.BlockIssuerKeysAdded = createdOutput.Output().FeatureSet().BlockIssuer().BlockIssuerKeys + // if the account is an implicit account, we need to set block issuer keys differently + if createdOutput.Output().Type() == iotago.OutputAccount { + accountDiff.BlockIssuerKeysAdded = createdOutput.Output().FeatureSet().BlockIssuer().BlockIssuerKeys + } else { + ed25519Address, _ := createdOutput.Output().UnlockConditionSet().Address().Address.(*iotago.Ed25519Address) + accountDiff.BlockIssuerKeysAdded = iotago.BlockIssuerKeys{iotago.BlockIssuerKeyEd25519AddressFromAddress(ed25519Address)} + } if stakingFeature := createdOutput.Output().FeatureSet().Staking(); stakingFeature != nil { accountDiff.ValidatorStakeChange = int64(stakingFeature.StakedAmount) @@ -485,6 +491,14 @@ func (l *Ledger) processCreatedAndConsumedAccountOutputs(stateDiff mempool.State // the delegation output was created => determine later if we need to add the stake to the validator delegation, _ := createdOutput.Output().(*iotago.DelegationOutput) createdAccountDelegation[delegation.DelegationID] = delegation + + case iotago.OutputBasic: + // if a basic output is sent to an implicit account creation address, we need to create the account + if createdOutput.Output().UnlockConditionSet().Address().Address.Type() == iotago.AddressImplicitAccountCreation { + accountID := iotago.AccountIDFromOutputID(outputID) + l.events.AccountCreated.Trigger(accountID) + createdAccounts[accountID] = createdOutput + } } return true diff --git a/tools/evil-spammer/go.mod b/tools/evil-spammer/go.mod index 43f8810ea..b88cbd2ae 100644 --- a/tools/evil-spammer/go.mod +++ b/tools/evil-spammer/go.mod @@ -17,7 +17,7 @@ require ( github.com/iotaledger/hive.go/runtime v0.0.0-20230906114834-b50190b9f9c2 github.com/iotaledger/iota-core v0.0.0-00010101000000-000000000000 github.com/iotaledger/iota-core/tools/genesis-snapshot v0.0.0-00010101000000-000000000000 - github.com/iotaledger/iota.go/v4 v4.0.0-20230913143616-917572c7752d + github.com/iotaledger/iota.go/v4 v4.0.0-20230915114908-97b965f76784 github.com/mr-tron/base58 v1.2.0 go.uber.org/atomic v1.11.0 ) diff --git a/tools/evil-spammer/go.sum b/tools/evil-spammer/go.sum index 08959c5c6..2baee6d10 100644 --- a/tools/evil-spammer/go.sum +++ b/tools/evil-spammer/go.sum @@ -197,8 +197,8 @@ github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20230912111751-d84fba0 github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20230912111751-d84fba02bb7c/go.mod h1:IJgaaxbgKCsNat18jlJJEAxCY2oVYR3F30B+M4vJ89I= github.com/iotaledger/hive.go/stringify v0.0.0-20230906114834-b50190b9f9c2 h1:exATYMLT/d8fgMuVNO6kMDsFn9DUJEcyCuoBv9sP13g= github.com/iotaledger/hive.go/stringify v0.0.0-20230906114834-b50190b9f9c2/go.mod h1:FTo/UWzNYgnQ082GI9QVM9HFDERqf9rw9RivNpqrnTs= -github.com/iotaledger/iota.go/v4 v4.0.0-20230913143616-917572c7752d h1:p9IchKq6kft758XDlnN/tAEXJMXGlmQPmbdxolba1gs= -github.com/iotaledger/iota.go/v4 v4.0.0-20230913143616-917572c7752d/go.mod h1:DWCa+mXRTGWBV0EHVuvToUxAEcICe2Pab9hBlxBamKo= +github.com/iotaledger/iota.go/v4 v4.0.0-20230915114908-97b965f76784 h1:lb/8KbtTOqwIqGb84F70dbmqENRDHZZul4AaPNapfAU= +github.com/iotaledger/iota.go/v4 v4.0.0-20230915114908-97b965f76784/go.mod h1:DWCa+mXRTGWBV0EHVuvToUxAEcICe2Pab9hBlxBamKo= 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/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= diff --git a/tools/gendoc/go.mod b/tools/gendoc/go.mod index bf2f8d4ba..228144b5c 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-20230906114834-b50190b9f9c2 // indirect github.com/iotaledger/inx-app v1.0.0-rc.3.0.20230829161228-3f4eb50a4d14 // indirect github.com/iotaledger/inx/go v1.0.0-rc.2.0.20230829160617-69b96c7c9f9b // indirect - github.com/iotaledger/iota.go/v4 v4.0.0-20230913143616-917572c7752d // indirect + github.com/iotaledger/iota.go/v4 v4.0.0-20230915114908-97b965f76784 // indirect github.com/ipfs/boxo v0.10.0 // 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 3a508dff0..f35b37a1d 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.20230829161228-3f4eb50a4d14 h1:BkDuQ github.com/iotaledger/inx-app v1.0.0-rc.3.0.20230829161228-3f4eb50a4d14/go.mod h1:ADBXzdHXTldP0NB2Vf+KbhDxkYciGRjzQVXT6Rdne1g= github.com/iotaledger/inx/go v1.0.0-rc.2.0.20230829160617-69b96c7c9f9b h1:EPB/+iWeSx/WgJlzaXl8yjinxuD8CCOdi2ZPMLeeMVY= github.com/iotaledger/inx/go v1.0.0-rc.2.0.20230829160617-69b96c7c9f9b/go.mod h1:B7gyJP6GshCSlEmY3CxEk5TZdsMs3UNz5U92hkFDdMs= -github.com/iotaledger/iota.go/v4 v4.0.0-20230913143616-917572c7752d h1:p9IchKq6kft758XDlnN/tAEXJMXGlmQPmbdxolba1gs= -github.com/iotaledger/iota.go/v4 v4.0.0-20230913143616-917572c7752d/go.mod h1:DWCa+mXRTGWBV0EHVuvToUxAEcICe2Pab9hBlxBamKo= +github.com/iotaledger/iota.go/v4 v4.0.0-20230915114908-97b965f76784 h1:lb/8KbtTOqwIqGb84F70dbmqENRDHZZul4AaPNapfAU= +github.com/iotaledger/iota.go/v4 v4.0.0-20230915114908-97b965f76784/go.mod h1:DWCa+mXRTGWBV0EHVuvToUxAEcICe2Pab9hBlxBamKo= github.com/ipfs/boxo v0.10.0 h1:tdDAxq8jrsbRkYoF+5Rcqyeb91hgWe2hp7iLu7ORZLY= github.com/ipfs/boxo v0.10.0/go.mod h1:Fg+BnfxZ0RPzR0nOodzdIq3A7KgoWAOWsEIImrIQdBM= 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 8927fb9b5..569aa43e7 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-20230906114834-b50190b9f9c2 github.com/iotaledger/hive.go/runtime v0.0.0-20230906114834-b50190b9f9c2 github.com/iotaledger/iota-core v0.0.0-00010101000000-000000000000 - github.com/iotaledger/iota.go/v4 v4.0.0-20230913143616-917572c7752d + github.com/iotaledger/iota.go/v4 v4.0.0-20230915114908-97b965f76784 github.com/mr-tron/base58 v1.2.0 github.com/spf13/pflag v1.0.5 golang.org/x/crypto v0.13.0 diff --git a/tools/genesis-snapshot/go.sum b/tools/genesis-snapshot/go.sum index eab46e060..9965c8d49 100644 --- a/tools/genesis-snapshot/go.sum +++ b/tools/genesis-snapshot/go.sum @@ -50,8 +50,8 @@ github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20230912111751-d84fba0 github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20230912111751-d84fba02bb7c/go.mod h1:IJgaaxbgKCsNat18jlJJEAxCY2oVYR3F30B+M4vJ89I= github.com/iotaledger/hive.go/stringify v0.0.0-20230906114834-b50190b9f9c2 h1:exATYMLT/d8fgMuVNO6kMDsFn9DUJEcyCuoBv9sP13g= github.com/iotaledger/hive.go/stringify v0.0.0-20230906114834-b50190b9f9c2/go.mod h1:FTo/UWzNYgnQ082GI9QVM9HFDERqf9rw9RivNpqrnTs= -github.com/iotaledger/iota.go/v4 v4.0.0-20230913143616-917572c7752d h1:p9IchKq6kft758XDlnN/tAEXJMXGlmQPmbdxolba1gs= -github.com/iotaledger/iota.go/v4 v4.0.0-20230913143616-917572c7752d/go.mod h1:DWCa+mXRTGWBV0EHVuvToUxAEcICe2Pab9hBlxBamKo= +github.com/iotaledger/iota.go/v4 v4.0.0-20230915114908-97b965f76784 h1:lb/8KbtTOqwIqGb84F70dbmqENRDHZZul4AaPNapfAU= +github.com/iotaledger/iota.go/v4 v4.0.0-20230915114908-97b965f76784/go.mod h1:DWCa+mXRTGWBV0EHVuvToUxAEcICe2Pab9hBlxBamKo= 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 b612ea067688412a75a61e4fe49c74ba68e62863 Mon Sep 17 00:00:00 2001 From: Andrew Date: Fri, 15 Sep 2023 14:03:50 +0100 Subject: [PATCH 02/24] fix commitment filter bug --- .../accountsfilter/commitmentfilter.go | 12 ++++++++--- .../accountsfilter/commitmentfilter_test.go | 20 ++++++++++++++++--- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/pkg/protocol/engine/commitmentfilter/accountsfilter/commitmentfilter.go b/pkg/protocol/engine/commitmentfilter/accountsfilter/commitmentfilter.go index 7f0bf2cd0..2c0d0a216 100644 --- a/pkg/protocol/engine/commitmentfilter/accountsfilter/commitmentfilter.go +++ b/pkg/protocol/engine/commitmentfilter/accountsfilter/commitmentfilter.go @@ -1,8 +1,6 @@ package accountsfilter import ( - "crypto/ed25519" - "github.com/iotaledger/hive.go/core/safemath" hiveEd25519 "github.com/iotaledger/hive.go/crypto/ed25519" "github.com/iotaledger/hive.go/ierrors" @@ -158,7 +156,15 @@ func (c *CommitmentFilter) evaluateBlock(block *blocks.Block) { case *iotago.Ed25519Signature: if !accountData.BlockIssuerKeys.Has(iotago.BlockIssuerKeyEd25519FromPublicKey(signature.PublicKey)) { // if the block issuer does not have the public key in the slot commitment, check if it has an implicit account with the corresponding address - if !accountData.BlockIssuerKeys.Has(iotago.BlockIssuerKeyEd25519AddressFromAddress(iotago.Ed25519AddressFromPubKey(ed25519.PublicKey(signature.PublicKey[:])))) { + var hasAddress = false + accountData.BlockIssuerKeys.Range(func(element iotago.BlockIssuerKey) { + if keyAddress, isAddress := element.(iotago.BlockIssuerKeyEd25519Address); isAddress { + if keyAddress.Address.Equal(iotago.Ed25519AddressFromPubKey(signature.PublicKey[:])) { + hasAddress = true + } + } + }) + if !hasAddress { c.events.BlockFiltered.Trigger(&commitmentfilter.BlockFilteredEvent{ Block: block, Reason: ierrors.Wrapf(ErrInvalidSignature, "block issuer account %s does not have block issuer key corresponding to public key %s in slot %d", block.ProtocolBlock().IssuerID, signature.PublicKey, block.ProtocolBlock().SlotCommitmentID.Index()), diff --git a/pkg/protocol/engine/commitmentfilter/accountsfilter/commitmentfilter_test.go b/pkg/protocol/engine/commitmentfilter/accountsfilter/commitmentfilter_test.go index 6f2df5ec7..19207185d 100644 --- a/pkg/protocol/engine/commitmentfilter/accountsfilter/commitmentfilter_test.go +++ b/pkg/protocol/engine/commitmentfilter/accountsfilter/commitmentfilter_test.go @@ -149,6 +149,7 @@ func TestCommitmentFilter_NoAccount(t *testing.T) { tf.CommitmentFilter.events.BlockFiltered.Hook(func(event *commitmentfilter.BlockFilteredEvent) { require.NotEqual(t, "withAccount", event.Block.ID().Alias()) + require.NotEqual(t, "withImplicitAccount", event.Block.ID().Alias()) }) keyPair := ed25519.GenerateKeyPair() @@ -165,7 +166,7 @@ func TestCommitmentFilter_NoAccount(t *testing.T) { addr := iotago.Ed25519AddressFromPubKey(keyPair.PublicKey[:]) accountID := iotago.AccountID(addr[:]) - // register the account in the proxy account manager + // register the accounts in the proxy account manager tf.AddAccountData( accountID, accounts.NewAccountData( @@ -174,13 +175,26 @@ func TestCommitmentFilter_NoAccount(t *testing.T) { accounts.WithBlockIssuerKeys(iotago.BlockIssuerKeyEd25519FromPublicKey(keyPair.PublicKey)), ), ) + keyPairImplicitAccount := ed25519.GenerateKeyPair() + implicitAddress := iotago.Ed25519AddressFromPubKey(keyPairImplicitAccount.PublicKey[:]) + implicitAccountID := iotago.AccountID(implicitAddress[:]) + tf.AddAccountData( + implicitAccountID, + accounts.NewAccountData( + implicitAccountID, + accounts.WithExpirySlot(math.MaxUint64), + accounts.WithBlockIssuerKeys(iotago.BlockIssuerKeyEd25519AddressFromAddress(implicitAddress)), + ), + ) tf.AddRMCData(currentSlot-currentAPI.ProtocolParameters().MaxCommittableAge(), iotago.Mana(0)) tf.IssueSignedBlockAtSlot("withAccount", currentSlot, commitmentID, keyPair) - otherKeyPair := ed25519.GenerateKeyPair() - tf.IssueSignedBlockAtSlot("noAccount", currentSlot, commitmentID, otherKeyPair) + keyPairNoAccount := ed25519.GenerateKeyPair() + tf.IssueSignedBlockAtSlot("noAccount", currentSlot, commitmentID, keyPairNoAccount) + + tf.IssueSignedBlockAtSlot("withImplicitAccount", currentSlot, commitmentID, keyPairImplicitAccount) } func TestCommitmentFilter_BurnedMana(t *testing.T) { From 1a176a5623e3d9567a0339e8ac9f7251e166d404 Mon Sep 17 00:00:00 2001 From: Andrew Date: Mon, 18 Sep 2023 15:28:01 +0100 Subject: [PATCH 03/24] track consumed implicit accounts --- pkg/protocol/engine/ledger/ledger/ledger.go | 28 ++++++++++++++------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/pkg/protocol/engine/ledger/ledger/ledger.go b/pkg/protocol/engine/ledger/ledger/ledger.go index 75b4a3709..9f05ca5c2 100644 --- a/pkg/protocol/engine/ledger/ledger/ledger.go +++ b/pkg/protocol/engine/ledger/ledger/ledger.go @@ -439,19 +439,22 @@ func (l *Ledger) prepareAccountDiffs(accountDiffs map[iotago.AccountID]*model.Ac accountDiff.PreviousOutputID = iotago.EmptyOutputID accountDiff.NewExpirySlot = createdOutput.Output().FeatureSet().BlockIssuer().ExpirySlot accountDiff.PreviousExpirySlot = 0 - // if the account is an implicit account, we need to set block issuer keys differently - if createdOutput.Output().Type() == iotago.OutputAccount { + + switch createdOutput.Output().Type() { + // for account outputs, get block issuer keys from the block issuer feature, and check for staking info. + case iotago.OutputAccount: accountDiff.BlockIssuerKeysAdded = createdOutput.Output().FeatureSet().BlockIssuer().BlockIssuerKeys - } else { + if stakingFeature := createdOutput.Output().FeatureSet().Staking(); stakingFeature != nil { + accountDiff.ValidatorStakeChange = int64(stakingFeature.StakedAmount) + accountDiff.StakeEndEpochChange = int64(stakingFeature.EndEpoch) + accountDiff.FixedCostChange = int64(stakingFeature.FixedCost) + } + // for basic outputs (implicit accounts), get block issuer keys from the address in the unlock conditions. + case iotago.OutputBasic: ed25519Address, _ := createdOutput.Output().UnlockConditionSet().Address().Address.(*iotago.Ed25519Address) accountDiff.BlockIssuerKeysAdded = iotago.BlockIssuerKeys{iotago.BlockIssuerKeyEd25519AddressFromAddress(ed25519Address)} } - if stakingFeature := createdOutput.Output().FeatureSet().Staking(); stakingFeature != nil { - accountDiff.ValidatorStakeChange = int64(stakingFeature.StakedAmount) - accountDiff.StakeEndEpochChange = int64(stakingFeature.EndEpoch) - accountDiff.FixedCostChange = int64(stakingFeature.FixedCost) - } } } @@ -519,7 +522,7 @@ func (l *Ledger) processCreatedAndConsumedAccountOutputs(stateDiff mempool.State switch spentOutput.OutputType() { case iotago.OutputAccount: consumedAccount, _ := spentOutput.Output().(*iotago.AccountOutput) - // if we transition / destroy an account that doesn't have a block issuer feature or staking, we don't need to track the changes. + // if we transition / destroy an account output that doesn't have a block issuer feature or staking, we don't need to track the changes. if consumedAccount.FeatureSet().BlockIssuer() == nil && consumedAccount.FeatureSet().Staking() == nil { return true } @@ -542,6 +545,13 @@ func (l *Ledger) processCreatedAndConsumedAccountOutputs(stateDiff mempool.State accountDiff := getAccountDiff(accountDiffs, delegationOutput.ValidatorID) accountDiff.DelegationStakeChange -= int64(delegationOutput.DelegatedAmount) } + + case iotago.OutputBasic: + // if a basic output (implicit account) is consumed, get the accountID as hash of the output ID. + if spentOutput.Output().UnlockConditionSet().Address().Address.Type() == iotago.AddressImplicitAccountCreation { + accountID := iotago.AccountIDFromOutputID(outputID) + consumedAccounts[accountID] = spentOutput + } } return true From d564fbda18d3d51e9f6b7acdc81a184ded6d4d86 Mon Sep 17 00:00:00 2001 From: Andrew Date: Tue, 19 Sep 2023 10:11:22 +0100 Subject: [PATCH 04/24] test implicit account creation --- go.mod | 2 +- go.sum | 4 +- pkg/protocol/engine/accounts/accounts.go | 8 ++++ .../accountsfilter/commitmentfilter_test.go | 2 +- pkg/protocol/engine/ledger/ledger/ledger.go | 22 ++++++++--- pkg/tests/accounts_test.go | 37 ++++++++++++++++++- pkg/testsuite/accounts.go | 2 +- pkg/testsuite/transactions_framework.go | 17 +++++++++ tools/evil-spammer/go.mod | 2 +- tools/evil-spammer/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 +- 14 files changed, 91 insertions(+), 21 deletions(-) diff --git a/go.mod b/go.mod index ca0f238d8..7d0e83c63 100644 --- a/go.mod +++ b/go.mod @@ -24,7 +24,7 @@ require ( github.com/iotaledger/hive.go/stringify v0.0.0-20230906114834-b50190b9f9c2 github.com/iotaledger/inx-app v1.0.0-rc.3.0.20230829161228-3f4eb50a4d14 github.com/iotaledger/inx/go v1.0.0-rc.2.0.20230829160617-69b96c7c9f9b - github.com/iotaledger/iota.go/v4 v4.0.0-20230915114908-97b965f76784 + github.com/iotaledger/iota.go/v4 v4.0.0-20230919084223-31baf7634420 github.com/labstack/echo/v4 v4.11.1 github.com/labstack/gommon v0.4.0 github.com/libp2p/go-libp2p v0.30.0 diff --git a/go.sum b/go.sum index eea0de2a2..f5823318d 100644 --- a/go.sum +++ b/go.sum @@ -307,8 +307,8 @@ github.com/iotaledger/inx-app v1.0.0-rc.3.0.20230829161228-3f4eb50a4d14 h1:BkDuQ github.com/iotaledger/inx-app v1.0.0-rc.3.0.20230829161228-3f4eb50a4d14/go.mod h1:ADBXzdHXTldP0NB2Vf+KbhDxkYciGRjzQVXT6Rdne1g= github.com/iotaledger/inx/go v1.0.0-rc.2.0.20230829160617-69b96c7c9f9b h1:EPB/+iWeSx/WgJlzaXl8yjinxuD8CCOdi2ZPMLeeMVY= github.com/iotaledger/inx/go v1.0.0-rc.2.0.20230829160617-69b96c7c9f9b/go.mod h1:B7gyJP6GshCSlEmY3CxEk5TZdsMs3UNz5U92hkFDdMs= -github.com/iotaledger/iota.go/v4 v4.0.0-20230915114908-97b965f76784 h1:lb/8KbtTOqwIqGb84F70dbmqENRDHZZul4AaPNapfAU= -github.com/iotaledger/iota.go/v4 v4.0.0-20230915114908-97b965f76784/go.mod h1:DWCa+mXRTGWBV0EHVuvToUxAEcICe2Pab9hBlxBamKo= +github.com/iotaledger/iota.go/v4 v4.0.0-20230919084223-31baf7634420 h1:WVaB6hOwT6UhnDtM+uQlL0OBw91OdUONiaFgOvAud1g= +github.com/iotaledger/iota.go/v4 v4.0.0-20230919084223-31baf7634420/go.mod h1:DWCa+mXRTGWBV0EHVuvToUxAEcICe2Pab9hBlxBamKo= github.com/ipfs/boxo v0.10.0 h1:tdDAxq8jrsbRkYoF+5Rcqyeb91hgWe2hp7iLu7ORZLY= github.com/ipfs/boxo v0.10.0/go.mod h1:Fg+BnfxZ0RPzR0nOodzdIq3A7KgoWAOWsEIImrIQdBM= github.com/ipfs/go-cid v0.4.1 h1:A/T3qGvxi4kpKWWcPC/PgbvDA2bjVLO7n4UeVwnbs/s= diff --git a/pkg/protocol/engine/accounts/accounts.go b/pkg/protocol/engine/accounts/accounts.go index 420112e9e..8ac5149c0 100644 --- a/pkg/protocol/engine/accounts/accounts.go +++ b/pkg/protocol/engine/accounts/accounts.go @@ -146,6 +146,14 @@ func (a *AccountData) readFromReadSeeker(reader io.ReadSeeker) (int, error) { } bytesConsumed += bytesRead blockIssuerKeys[i] = iotago.BlockIssuerKeyEd25519FromPublicKey(ed25519PublicKey) + case iotago.Ed25519BlockIssuerKeyAddress: + var implicitAccountCreationAddress iotago.ImplicitAccountCreationAddress + bytesRead, err = io.ReadFull(reader, implicitAccountCreationAddress[:]) + if err != nil { + return bytesConsumed, ierrors.Wrapf(err, "unable to read address %d for accountID %s", i, a.ID) + } + bytesConsumed += bytesRead + blockIssuerKeys[i] = iotago.BlockIssuerKeyEd25519AddressFromAddress(&implicitAccountCreationAddress) default: return bytesConsumed, ierrors.Wrapf(err, "unsupported block issuer key type %d for accountID %s at offset %d", blockIssuerKeyType, a.ID, i) } diff --git a/pkg/protocol/engine/commitmentfilter/accountsfilter/commitmentfilter_test.go b/pkg/protocol/engine/commitmentfilter/accountsfilter/commitmentfilter_test.go index 19207185d..3d81fe997 100644 --- a/pkg/protocol/engine/commitmentfilter/accountsfilter/commitmentfilter_test.go +++ b/pkg/protocol/engine/commitmentfilter/accountsfilter/commitmentfilter_test.go @@ -176,7 +176,7 @@ func TestCommitmentFilter_NoAccount(t *testing.T) { ), ) keyPairImplicitAccount := ed25519.GenerateKeyPair() - implicitAddress := iotago.Ed25519AddressFromPubKey(keyPairImplicitAccount.PublicKey[:]) + implicitAddress := iotago.ImplicitAccountCreationAddressFromPubKey(keyPairImplicitAccount.PublicKey[:]) implicitAccountID := iotago.AccountID(implicitAddress[:]) tf.AddAccountData( implicitAccountID, diff --git a/pkg/protocol/engine/ledger/ledger/ledger.go b/pkg/protocol/engine/ledger/ledger/ledger.go index 9f05ca5c2..c05053896 100644 --- a/pkg/protocol/engine/ledger/ledger/ledger.go +++ b/pkg/protocol/engine/ledger/ledger/ledger.go @@ -2,6 +2,7 @@ package ledger import ( "io" + "math" "github.com/iotaledger/hive.go/core/safemath" "github.com/iotaledger/hive.go/ds" @@ -388,11 +389,19 @@ func (l *Ledger) prepareAccountDiffs(accountDiffs map[iotago.AccountID]*model.Ac // case 1. continue } - accountDiff.NewOutputID = createdOutput.OutputID() - accountDiff.PreviousOutputID = consumedOutput.OutputID() + // case 2. + // created output can never be an implicit account as these can not be transitioned, but consumed output can be. + switch consumedOutput.Output().Type() { + case iotago.OutputAccount: + accountDiff.PreviousExpirySlot = consumedOutput.Output().FeatureSet().BlockIssuer().ExpirySlot + case iotago.OutputBasic: + accountDiff.PreviousExpirySlot = iotago.SlotIndex(math.MaxUint64) + } + + accountDiff.PreviousOutputID = consumedOutput.OutputID() + accountDiff.NewOutputID = createdOutput.OutputID() accountDiff.NewExpirySlot = createdOutput.Output().FeatureSet().BlockIssuer().ExpirySlot - accountDiff.PreviousExpirySlot = consumedOutput.Output().FeatureSet().BlockIssuer().ExpirySlot oldPubKeysSet := accountData.BlockIssuerKeys newPubKeysSet := ds.NewSet[iotago.BlockIssuerKey]() @@ -437,13 +446,13 @@ func (l *Ledger) prepareAccountDiffs(accountDiffs map[iotago.AccountID]*model.Ac // have some values from the allotment, so no need to set them explicitly. accountDiff.NewOutputID = createdOutput.OutputID() accountDiff.PreviousOutputID = iotago.EmptyOutputID - accountDiff.NewExpirySlot = createdOutput.Output().FeatureSet().BlockIssuer().ExpirySlot accountDiff.PreviousExpirySlot = 0 switch createdOutput.Output().Type() { // for account outputs, get block issuer keys from the block issuer feature, and check for staking info. case iotago.OutputAccount: accountDiff.BlockIssuerKeysAdded = createdOutput.Output().FeatureSet().BlockIssuer().BlockIssuerKeys + accountDiff.NewExpirySlot = createdOutput.Output().FeatureSet().BlockIssuer().ExpirySlot if stakingFeature := createdOutput.Output().FeatureSet().Staking(); stakingFeature != nil { accountDiff.ValidatorStakeChange = int64(stakingFeature.StakedAmount) accountDiff.StakeEndEpochChange = int64(stakingFeature.EndEpoch) @@ -451,8 +460,9 @@ func (l *Ledger) prepareAccountDiffs(accountDiffs map[iotago.AccountID]*model.Ac } // for basic outputs (implicit accounts), get block issuer keys from the address in the unlock conditions. case iotago.OutputBasic: - ed25519Address, _ := createdOutput.Output().UnlockConditionSet().Address().Address.(*iotago.Ed25519Address) - accountDiff.BlockIssuerKeysAdded = iotago.BlockIssuerKeys{iotago.BlockIssuerKeyEd25519AddressFromAddress(ed25519Address)} + address, _ := createdOutput.Output().UnlockConditionSet().Address().Address.(*iotago.ImplicitAccountCreationAddress) + accountDiff.BlockIssuerKeysAdded = iotago.BlockIssuerKeys{iotago.BlockIssuerKeyEd25519AddressFromAddress(address)} + accountDiff.NewExpirySlot = iotago.SlotIndex(math.MaxUint64) } } diff --git a/pkg/tests/accounts_test.go b/pkg/tests/accounts_test.go index a3e69243d..e7b065cbf 100644 --- a/pkg/tests/accounts_test.go +++ b/pkg/tests/accounts_test.go @@ -1,8 +1,10 @@ package tests import ( + "math" "testing" + "github.com/iotaledger/hive.go/crypto/ed25519" "github.com/iotaledger/hive.go/ds" "github.com/iotaledger/hive.go/lo" "github.com/iotaledger/hive.go/runtime/options" @@ -276,7 +278,7 @@ func Test_TransitionAccount(t *testing.T) { block4 := ts.IssueBlockAtSlotWithOptions("block4", slotIndexBlock4, node1.Protocol.MainEngineInstance().Storage.Settings().LatestCommitment().Commitment(), node1, tx4, blockfactory.WithStrongParents(latestParent.ID())) - _ = ts.CommitUntilSlot(slotIndexBlock4, activeNodes, block4) + latestParent = ts.CommitUntilSlot(slotIndexBlock4, activeNodes, block4) ts.AssertAccountDiff(newAccountOutput.AccountID, slotIndexBlock4, &model.AccountDiff{ BICChange: 0, @@ -303,6 +305,39 @@ func Test_TransitionAccount(t *testing.T) { ValidatorStake: 10000, }, ts.Nodes()...) + // CREATE IMPLICIT ACCOUNT FROM BASIC UTXO + + keyPair := ed25519.GenerateKeyPair() + implicitAccountAddress := iotago.ImplicitAccountCreationAddressFromPubKey(keyPair.PublicKey[:]) + inputForImplicitAccount, outputsForImplicitAccount, implicitWallet := ts.TransactionFramework.CreateImplicitAccountFromInput("TX1:3", implicitAccountAddress) + + tx5 := lo.PanicOnErr(ts.TransactionFramework.CreateTransactionWithOptions("TX5", implicitWallet, + testsuite.WithInputs(inputForImplicitAccount), + testsuite.WithOutputs(outputsForImplicitAccount), + )) + + implicitAccountOutput := ts.TransactionFramework.Output("TX5:0") + implicitAccountOutputID := implicitAccountOutput.OutputID() + implicitAccountID := iotago.AccountIDFromOutputID(implicitAccountOutputID) + + slotIndexBlock5 := latestParent.ID().Index() + + block5 := ts.IssueBlockAtSlotWithOptions("block5", slotIndexBlock5, node1.Protocol.MainEngineInstance().Storage.Settings().LatestCommitment().Commitment(), node1, tx5, blockfactory.WithStrongParents(latestParent.ID())) + + latestParent = ts.CommitUntilSlot(slotIndexBlock5, activeNodes, block5) + + var implicitBlockIssuerKey iotago.BlockIssuerKey = iotago.BlockIssuerKeyEd25519AddressFromAddress(implicitAccountAddress) + + ts.AssertAccountData(&accounts.AccountData{ + ID: implicitAccountID, + Credits: accounts.NewBlockIssuanceCredits(0, slotIndexBlock5), + ExpirySlot: iotago.SlotIndex(math.MaxUint64), + OutputID: implicitAccountOutputID, + BlockIssuerKeys: ds.NewSet(implicitBlockIssuerKey), + }, ts.Nodes()...) + + // TRANSITION IMPLICIT ACCOUNT TO ACCOUNT OUTPUT + ts.Wait(ts.Nodes()...) } diff --git a/pkg/testsuite/accounts.go b/pkg/testsuite/accounts.go index 50503f33a..447d0e9e8 100644 --- a/pkg/testsuite/accounts.go +++ b/pkg/testsuite/accounts.go @@ -42,7 +42,7 @@ func (t *TestSuite) AssertAccountData(accountData *accounts.AccountData, nodes . } if !cmp.Equal(accountData.BlockIssuerKeys.ToSlice(), actualAccountData.BlockIssuerKeys.ToSlice()) { - return ierrors.Errorf("AssertAccountData: %s: accountID %s expected pub keys %s, got %s", node.Name, accountData.ID, accountData.BlockIssuerKeys, actualAccountData.BlockIssuerKeys) + return ierrors.Errorf("AssertAccountData: %s: accountID %s expected pub keys %s, got %s", node.Name, accountData.ID, accountData.BlockIssuerKeys.ToSlice(), actualAccountData.BlockIssuerKeys.ToSlice()) } if accountData.StakeEndEpoch != actualAccountData.StakeEndEpoch { diff --git a/pkg/testsuite/transactions_framework.go b/pkg/testsuite/transactions_framework.go index a306231e7..a790d42a1 100644 --- a/pkg/testsuite/transactions_framework.go +++ b/pkg/testsuite/transactions_framework.go @@ -209,6 +209,23 @@ func (t *TransactionFramework) CreateAccountFromInput(inputAlias string, opts .. return utxoledger.Outputs{input}, outputStates, []*mock.HDWallet{t.wallet} } +// CreateImplicitAccountFromInput +func (t *TransactionFramework) CreateImplicitAccountFromInput(inputAlias string, address *iotago.ImplicitAccountCreationAddress) (utxoledger.Outputs, iotago.Outputs[iotago.Output], []*mock.HDWallet) { + input := t.Output(inputAlias) + + basicOutput := &iotago.BasicOutput{ + Amount: input.BaseTokenAmount(), + Mana: input.StoredMana(), + NativeTokens: iotago.NativeTokens{}, + Conditions: iotago.BasicOutputUnlockConditions{ + &iotago.AddressUnlockCondition{Address: address}, + }, + Features: iotago.BasicOutputFeatures{}, + } + + return utxoledger.Outputs{input}, iotago.Outputs[iotago.Output]{basicOutput}, []*mock.HDWallet{t.wallet} +} + // CreateDelegationFromInput creates a new DelegationOutput with given options from an input. If the remainder Output // is not created, then StoredMana from the input is not passed and can potentially be burned. // In order not to burn it, it needs to be assigned manually in another output in the transaction. diff --git a/tools/evil-spammer/go.mod b/tools/evil-spammer/go.mod index b88cbd2ae..83be809b6 100644 --- a/tools/evil-spammer/go.mod +++ b/tools/evil-spammer/go.mod @@ -17,7 +17,7 @@ require ( github.com/iotaledger/hive.go/runtime v0.0.0-20230906114834-b50190b9f9c2 github.com/iotaledger/iota-core v0.0.0-00010101000000-000000000000 github.com/iotaledger/iota-core/tools/genesis-snapshot v0.0.0-00010101000000-000000000000 - github.com/iotaledger/iota.go/v4 v4.0.0-20230915114908-97b965f76784 + github.com/iotaledger/iota.go/v4 v4.0.0-20230919084223-31baf7634420 github.com/mr-tron/base58 v1.2.0 go.uber.org/atomic v1.11.0 ) diff --git a/tools/evil-spammer/go.sum b/tools/evil-spammer/go.sum index 2baee6d10..2cc2b7496 100644 --- a/tools/evil-spammer/go.sum +++ b/tools/evil-spammer/go.sum @@ -197,8 +197,8 @@ github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20230912111751-d84fba0 github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20230912111751-d84fba02bb7c/go.mod h1:IJgaaxbgKCsNat18jlJJEAxCY2oVYR3F30B+M4vJ89I= github.com/iotaledger/hive.go/stringify v0.0.0-20230906114834-b50190b9f9c2 h1:exATYMLT/d8fgMuVNO6kMDsFn9DUJEcyCuoBv9sP13g= github.com/iotaledger/hive.go/stringify v0.0.0-20230906114834-b50190b9f9c2/go.mod h1:FTo/UWzNYgnQ082GI9QVM9HFDERqf9rw9RivNpqrnTs= -github.com/iotaledger/iota.go/v4 v4.0.0-20230915114908-97b965f76784 h1:lb/8KbtTOqwIqGb84F70dbmqENRDHZZul4AaPNapfAU= -github.com/iotaledger/iota.go/v4 v4.0.0-20230915114908-97b965f76784/go.mod h1:DWCa+mXRTGWBV0EHVuvToUxAEcICe2Pab9hBlxBamKo= +github.com/iotaledger/iota.go/v4 v4.0.0-20230919084223-31baf7634420 h1:WVaB6hOwT6UhnDtM+uQlL0OBw91OdUONiaFgOvAud1g= +github.com/iotaledger/iota.go/v4 v4.0.0-20230919084223-31baf7634420/go.mod h1:DWCa+mXRTGWBV0EHVuvToUxAEcICe2Pab9hBlxBamKo= 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/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= diff --git a/tools/gendoc/go.mod b/tools/gendoc/go.mod index 228144b5c..d97280d73 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-20230906114834-b50190b9f9c2 // indirect github.com/iotaledger/inx-app v1.0.0-rc.3.0.20230829161228-3f4eb50a4d14 // indirect github.com/iotaledger/inx/go v1.0.0-rc.2.0.20230829160617-69b96c7c9f9b // indirect - github.com/iotaledger/iota.go/v4 v4.0.0-20230915114908-97b965f76784 // indirect + github.com/iotaledger/iota.go/v4 v4.0.0-20230919084223-31baf7634420 // indirect github.com/ipfs/boxo v0.10.0 // 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 f35b37a1d..0dace4ec7 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.20230829161228-3f4eb50a4d14 h1:BkDuQ github.com/iotaledger/inx-app v1.0.0-rc.3.0.20230829161228-3f4eb50a4d14/go.mod h1:ADBXzdHXTldP0NB2Vf+KbhDxkYciGRjzQVXT6Rdne1g= github.com/iotaledger/inx/go v1.0.0-rc.2.0.20230829160617-69b96c7c9f9b h1:EPB/+iWeSx/WgJlzaXl8yjinxuD8CCOdi2ZPMLeeMVY= github.com/iotaledger/inx/go v1.0.0-rc.2.0.20230829160617-69b96c7c9f9b/go.mod h1:B7gyJP6GshCSlEmY3CxEk5TZdsMs3UNz5U92hkFDdMs= -github.com/iotaledger/iota.go/v4 v4.0.0-20230915114908-97b965f76784 h1:lb/8KbtTOqwIqGb84F70dbmqENRDHZZul4AaPNapfAU= -github.com/iotaledger/iota.go/v4 v4.0.0-20230915114908-97b965f76784/go.mod h1:DWCa+mXRTGWBV0EHVuvToUxAEcICe2Pab9hBlxBamKo= +github.com/iotaledger/iota.go/v4 v4.0.0-20230919084223-31baf7634420 h1:WVaB6hOwT6UhnDtM+uQlL0OBw91OdUONiaFgOvAud1g= +github.com/iotaledger/iota.go/v4 v4.0.0-20230919084223-31baf7634420/go.mod h1:DWCa+mXRTGWBV0EHVuvToUxAEcICe2Pab9hBlxBamKo= github.com/ipfs/boxo v0.10.0 h1:tdDAxq8jrsbRkYoF+5Rcqyeb91hgWe2hp7iLu7ORZLY= github.com/ipfs/boxo v0.10.0/go.mod h1:Fg+BnfxZ0RPzR0nOodzdIq3A7KgoWAOWsEIImrIQdBM= 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 569aa43e7..2c76bb37f 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-20230906114834-b50190b9f9c2 github.com/iotaledger/hive.go/runtime v0.0.0-20230906114834-b50190b9f9c2 github.com/iotaledger/iota-core v0.0.0-00010101000000-000000000000 - github.com/iotaledger/iota.go/v4 v4.0.0-20230915114908-97b965f76784 + github.com/iotaledger/iota.go/v4 v4.0.0-20230919084223-31baf7634420 github.com/mr-tron/base58 v1.2.0 github.com/spf13/pflag v1.0.5 golang.org/x/crypto v0.13.0 diff --git a/tools/genesis-snapshot/go.sum b/tools/genesis-snapshot/go.sum index 9965c8d49..a16a1fb67 100644 --- a/tools/genesis-snapshot/go.sum +++ b/tools/genesis-snapshot/go.sum @@ -50,8 +50,8 @@ github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20230912111751-d84fba0 github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20230912111751-d84fba02bb7c/go.mod h1:IJgaaxbgKCsNat18jlJJEAxCY2oVYR3F30B+M4vJ89I= github.com/iotaledger/hive.go/stringify v0.0.0-20230906114834-b50190b9f9c2 h1:exATYMLT/d8fgMuVNO6kMDsFn9DUJEcyCuoBv9sP13g= github.com/iotaledger/hive.go/stringify v0.0.0-20230906114834-b50190b9f9c2/go.mod h1:FTo/UWzNYgnQ082GI9QVM9HFDERqf9rw9RivNpqrnTs= -github.com/iotaledger/iota.go/v4 v4.0.0-20230915114908-97b965f76784 h1:lb/8KbtTOqwIqGb84F70dbmqENRDHZZul4AaPNapfAU= -github.com/iotaledger/iota.go/v4 v4.0.0-20230915114908-97b965f76784/go.mod h1:DWCa+mXRTGWBV0EHVuvToUxAEcICe2Pab9hBlxBamKo= +github.com/iotaledger/iota.go/v4 v4.0.0-20230919084223-31baf7634420 h1:WVaB6hOwT6UhnDtM+uQlL0OBw91OdUONiaFgOvAud1g= +github.com/iotaledger/iota.go/v4 v4.0.0-20230919084223-31baf7634420/go.mod h1:DWCa+mXRTGWBV0EHVuvToUxAEcICe2Pab9hBlxBamKo= 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 f64fb8bd1a33b67cf3468686ac0049fc244b840a Mon Sep 17 00:00:00 2001 From: Andrew Date: Tue, 19 Sep 2023 10:22:31 +0100 Subject: [PATCH 05/24] fix commitment filter --- .../engine/commitmentfilter/accountsfilter/commitmentfilter.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/protocol/engine/commitmentfilter/accountsfilter/commitmentfilter.go b/pkg/protocol/engine/commitmentfilter/accountsfilter/commitmentfilter.go index 2c0d0a216..dc7a23637 100644 --- a/pkg/protocol/engine/commitmentfilter/accountsfilter/commitmentfilter.go +++ b/pkg/protocol/engine/commitmentfilter/accountsfilter/commitmentfilter.go @@ -159,7 +159,7 @@ func (c *CommitmentFilter) evaluateBlock(block *blocks.Block) { var hasAddress = false accountData.BlockIssuerKeys.Range(func(element iotago.BlockIssuerKey) { if keyAddress, isAddress := element.(iotago.BlockIssuerKeyEd25519Address); isAddress { - if keyAddress.Address.Equal(iotago.Ed25519AddressFromPubKey(signature.PublicKey[:])) { + if keyAddress.Address.Equal(iotago.ImplicitAccountCreationAddressFromPubKey(signature.PublicKey[:])) { hasAddress = true } } From 03ecb8bb5b3eeebd72d97cfe034b05296093e627 Mon Sep 17 00:00:00 2001 From: Andrew Date: Wed, 20 Sep 2023 15:40:55 +0100 Subject: [PATCH 06/24] start accounts test additions --- pkg/tests/accounts_test.go | 44 +++++++++++++++++++++++++ pkg/testsuite/transactions_framework.go | 29 ++++++++++++++++ 2 files changed, 73 insertions(+) diff --git a/pkg/tests/accounts_test.go b/pkg/tests/accounts_test.go index e7b065cbf..b59279bae 100644 --- a/pkg/tests/accounts_test.go +++ b/pkg/tests/accounts_test.go @@ -338,6 +338,50 @@ func Test_TransitionAccount(t *testing.T) { // TRANSITION IMPLICIT ACCOUNT TO ACCOUNT OUTPUT + fullAccountBlockIssuerKey := utils.RandBlockIssuerKey() + + inputForImplicitAccountTransition, outputsForImplicitAccountTransition, fullAccountWallet := ts.TransactionFramework.TransitionImplicitAccountToAccountOutput( + "TX5:0", + testsuite.WithBlockIssuerFeature(&iotago.BlockIssuerFeature{ + BlockIssuerKeys: iotago.BlockIssuerKeys{fullAccountBlockIssuerKey}, + ExpirySlot: math.MaxUint64, + }), + ) + + tx6 := lo.PanicOnErr(ts.TransactionFramework.CreateTransactionWithOptions("TX6", fullAccountWallet, + testsuite.WithInputs(inputForImplicitAccountTransition), + testsuite.WithOutputs(outputsForImplicitAccountTransition), + )) + + slotIndexBlock6 := latestParent.ID().Index() + + block6 := ts.IssueBlockAtSlotWithOptions("block6", slotIndexBlock6, node1.Protocol.MainEngineInstance().Storage.Settings().LatestCommitment().Commitment(), node1, tx6, blockfactory.WithStrongParents(latestParent.ID())) + + latestParent = ts.CommitUntilSlot(slotIndexBlock6, activeNodes, block6) + + fullAccountOutputID := ts.TransactionFramework.Output("TX6:0").OutputID() + + ts.AssertAccountDiff(implicitAccountID, slotIndexBlock6, &model.AccountDiff{ + BICChange: 0, + PreviousUpdatedTime: 0, + NewOutputID: fullAccountOutputID, + PreviousOutputID: implicitAccountOutputID, + BlockIssuerKeysAdded: iotago.BlockIssuerKeys{fullAccountBlockIssuerKey}, + BlockIssuerKeysRemoved: iotago.BlockIssuerKeys{implicitBlockIssuerKey}, + ValidatorStakeChange: 0, + StakeEndEpochChange: 0, + FixedCostChange: 0, + DelegationStakeChange: 0, + }, false, ts.Nodes()...) + + ts.AssertAccountData(&accounts.AccountData{ + ID: implicitAccountID, + Credits: accounts.NewBlockIssuanceCredits(0, slotIndexBlock6), + ExpirySlot: iotago.SlotIndex(math.MaxUint64), + OutputID: implicitAccountOutputID, + BlockIssuerKeys: ds.NewSet(fullAccountBlockIssuerKey), + }, ts.Nodes()...) + ts.Wait(ts.Nodes()...) } diff --git a/pkg/testsuite/transactions_framework.go b/pkg/testsuite/transactions_framework.go index a790d42a1..2c9f38ff6 100644 --- a/pkg/testsuite/transactions_framework.go +++ b/pkg/testsuite/transactions_framework.go @@ -320,6 +320,35 @@ func (t *TransactionFramework) TransitionAccount(alias string, opts ...options.O return output, iotago.Outputs[iotago.Output]{accountOutput}, []*mock.HDWallet{t.wallet} } +func (t *TransactionFramework) TransitionImplicitAccountToAccountOutput(alias string, opts ...options.Option[iotago.AccountOutput]) (consumedInput utxoledger.Outputs, outputs iotago.Outputs[iotago.Output], signingWallets []*mock.HDWallet) { + input, exists := t.states[alias] + if !exists { + panic(fmt.Sprintf("account with alias %s does not exist", alias)) + } + + basicOutput, isBasic := input.Output().(*iotago.BasicOutput) + if !isBasic { + panic(fmt.Sprintf("output with alias %s is not *iotago.BasicOutput", alias)) + } + if basicOutput.UnlockConditionSet().Address().Address.Type() != iotago.AddressImplicitAccountCreation { + panic(fmt.Sprintf("output with alias %s is not an implicit account", alias)) + } + + accountOutput := options.Apply(&iotago.AccountOutput{ + Amount: input.BaseTokenAmount(), + Mana: input.StoredMana(), + NativeTokens: iotago.NativeTokens{}, + Conditions: iotago.AccountOutputUnlockConditions{ + &iotago.StateControllerAddressUnlockCondition{Address: t.DefaultAddress()}, + &iotago.GovernorAddressUnlockCondition{Address: t.DefaultAddress()}, + }, + Features: iotago.AccountOutputFeatures{}, + ImmutableFeatures: iotago.AccountOutputImmFeatures{}, + }, opts) + + return utxoledger.Outputs{input}, iotago.Outputs[iotago.Output]{accountOutput}, []*mock.HDWallet{t.wallet} +} + func (t *TransactionFramework) Output(alias string) *utxoledger.Output { output, exists := t.states[alias] if !exists { From 27ea6be613d1184719fdcef6f78a74027b5054ad Mon Sep 17 00:00:00 2001 From: muXxer Date: Wed, 20 Sep 2023 17:51:57 +0200 Subject: [PATCH 07/24] Fix transaction framework for implicit accounts --- pkg/tests/accounts_test.go | 6 +----- pkg/testsuite/mock/hdwallet.go | 18 ++++++++++++++--- pkg/testsuite/transactions_framework.go | 27 ++++++++++++++++--------- tools/evil-spammer/wallet/wallet.go | 6 ++++-- 4 files changed, 37 insertions(+), 20 deletions(-) diff --git a/pkg/tests/accounts_test.go b/pkg/tests/accounts_test.go index b59279bae..6c3ae427b 100644 --- a/pkg/tests/accounts_test.go +++ b/pkg/tests/accounts_test.go @@ -4,7 +4,6 @@ import ( "math" "testing" - "github.com/iotaledger/hive.go/crypto/ed25519" "github.com/iotaledger/hive.go/ds" "github.com/iotaledger/hive.go/lo" "github.com/iotaledger/hive.go/runtime/options" @@ -306,10 +305,7 @@ func Test_TransitionAccount(t *testing.T) { }, ts.Nodes()...) // CREATE IMPLICIT ACCOUNT FROM BASIC UTXO - - keyPair := ed25519.GenerateKeyPair() - implicitAccountAddress := iotago.ImplicitAccountCreationAddressFromPubKey(keyPair.PublicKey[:]) - inputForImplicitAccount, outputsForImplicitAccount, implicitWallet := ts.TransactionFramework.CreateImplicitAccountFromInput("TX1:3", implicitAccountAddress) + inputForImplicitAccount, outputsForImplicitAccount, implicitAccountAddress, implicitWallet := ts.TransactionFramework.CreateImplicitAccountFromInput("TX1:3") tx5 := lo.PanicOnErr(ts.TransactionFramework.CreateTransactionWithOptions("TX5", implicitWallet, testsuite.WithInputs(inputForImplicitAccount), diff --git a/pkg/testsuite/mock/hdwallet.go b/pkg/testsuite/mock/hdwallet.go index 9f033627d..a4f6eb4c2 100644 --- a/pkg/testsuite/mock/hdwallet.go +++ b/pkg/testsuite/mock/hdwallet.go @@ -8,6 +8,7 @@ import ( "github.com/wollac/iota-crypto-demo/pkg/slip10" "github.com/wollac/iota-crypto-demo/pkg/slip10/eddsa" + "github.com/iotaledger/hive.go/ierrors" "github.com/iotaledger/iota-core/pkg/protocol/engine/utxoledger" iotago "github.com/iotaledger/iota.go/v4" ) @@ -101,11 +102,22 @@ func (hd *HDWallet) Outputs() []*utxoledger.Output { } // Address calculates an ed25519 address by using slip10. -func (hd *HDWallet) Address() *iotago.Ed25519Address { +func (hd *HDWallet) Address(addressType ...iotago.AddressType) iotago.DirectUnlockableAddress { _, pubKey := hd.KeyPair() - addr := iotago.Ed25519AddressFromPubKey(pubKey) - return addr + addrType := iotago.AddressEd25519 + if len(addressType) > 0 { + addrType = addressType[0] + } + + switch addrType { + case iotago.AddressEd25519: + return iotago.Ed25519AddressFromPubKey(pubKey) + case iotago.AddressImplicitAccountCreation: + return iotago.ImplicitAccountCreationAddressFromPubKey(pubKey) + default: + panic(ierrors.Wrapf(iotago.ErrUnknownAddrType, "type %d", addressType)) + } } func (hd *HDWallet) PrintStatus() { diff --git a/pkg/testsuite/transactions_framework.go b/pkg/testsuite/transactions_framework.go index 2c9f38ff6..bf8c14848 100644 --- a/pkg/testsuite/transactions_framework.go +++ b/pkg/testsuite/transactions_framework.go @@ -73,10 +73,14 @@ func (t *TransactionFramework) RegisterTransaction(alias string, transaction *io func (t *TransactionFramework) CreateTransactionWithOptions(alias string, signingWallets []*mock.HDWallet, opts ...options.Option[builder.TransactionBuilder]) (*iotago.Transaction, error) { currentAPI := t.apiProvider.CurrentAPI() - walletKeys := make([]iotago.AddressKeys, len(signingWallets)) - for i, wallet := range signingWallets { + walletKeys := make([]iotago.AddressKeys, 0, len(signingWallets)*2) + for _, wallet := range signingWallets { inputPrivateKey, _ := wallet.KeyPair() - walletKeys[i] = iotago.AddressKeys{Address: wallet.Address(), Keys: inputPrivateKey} + // add address keys for both types of directly unlockable addresses to simplify the TransactionFramework + //nolint:forcetypeassert + walletKeys = append(walletKeys, iotago.NewAddressKeysForEd25519Address(wallet.Address(iotago.AddressEd25519).(*iotago.Ed25519Address), inputPrivateKey)) + //nolint:forcetypeassert + walletKeys = append(walletKeys, iotago.NewAddressKeysForImplicitAccountCreationAddress(wallet.Address(iotago.AddressImplicitAccountCreation).(*iotago.ImplicitAccountCreationAddress), inputPrivateKey)) } txBuilder := builder.NewTransactionBuilder(currentAPI) @@ -209,21 +213,24 @@ func (t *TransactionFramework) CreateAccountFromInput(inputAlias string, opts .. return utxoledger.Outputs{input}, outputStates, []*mock.HDWallet{t.wallet} } -// CreateImplicitAccountFromInput -func (t *TransactionFramework) CreateImplicitAccountFromInput(inputAlias string, address *iotago.ImplicitAccountCreationAddress) (utxoledger.Outputs, iotago.Outputs[iotago.Output], []*mock.HDWallet) { +// CreateImplicitAccountFromInput creates an implicit account output. +func (t *TransactionFramework) CreateImplicitAccountFromInput(inputAlias string) (utxoledger.Outputs, iotago.Outputs[iotago.Output], *iotago.ImplicitAccountCreationAddress, []*mock.HDWallet) { input := t.Output(inputAlias) + //nolint:forcetypeassert + implicitAccountAddress := t.DefaultAddress(iotago.AddressImplicitAccountCreation).(*iotago.ImplicitAccountCreationAddress) + basicOutput := &iotago.BasicOutput{ Amount: input.BaseTokenAmount(), Mana: input.StoredMana(), NativeTokens: iotago.NativeTokens{}, Conditions: iotago.BasicOutputUnlockConditions{ - &iotago.AddressUnlockCondition{Address: address}, + &iotago.AddressUnlockCondition{Address: implicitAccountAddress}, }, Features: iotago.BasicOutputFeatures{}, } - return utxoledger.Outputs{input}, iotago.Outputs[iotago.Output]{basicOutput}, []*mock.HDWallet{t.wallet} + return utxoledger.Outputs{input}, iotago.Outputs[iotago.Output]{basicOutput}, implicitAccountAddress, []*mock.HDWallet{t.wallet} } // CreateDelegationFromInput creates a new DelegationOutput with given options from an input. If the remainder Output @@ -323,7 +330,7 @@ func (t *TransactionFramework) TransitionAccount(alias string, opts ...options.O func (t *TransactionFramework) TransitionImplicitAccountToAccountOutput(alias string, opts ...options.Option[iotago.AccountOutput]) (consumedInput utxoledger.Outputs, outputs iotago.Outputs[iotago.Output], signingWallets []*mock.HDWallet) { input, exists := t.states[alias] if !exists { - panic(fmt.Sprintf("account with alias %s does not exist", alias)) + panic(fmt.Sprintf("output with alias %s does not exist", alias)) } basicOutput, isBasic := input.Output().(*iotago.BasicOutput) @@ -383,8 +390,8 @@ func (t *TransactionFramework) TransactionIDs(aliases ...string) []iotago.Transa return lo.Map(aliases, t.TransactionID) } -func (t *TransactionFramework) DefaultAddress() iotago.Address { - return t.wallet.Address() +func (t *TransactionFramework) DefaultAddress(addressType ...iotago.AddressType) iotago.Address { + return t.wallet.Address(addressType...) } // DelegationOutput options diff --git a/tools/evil-spammer/wallet/wallet.go b/tools/evil-spammer/wallet/wallet.go index f31fa9a9e..c1c024a81 100644 --- a/tools/evil-spammer/wallet/wallet.go +++ b/tools/evil-spammer/wallet/wallet.go @@ -72,7 +72,8 @@ func (w *Wallet) Address() *iotago.Ed25519Address { index := uint64(w.lastAddrIdxUsed.Add(1)) hdWallet := mock.NewHDWallet("", w.seed[:], index) - addr := hdWallet.Address() + //nolint:forcetypeassert + addr := hdWallet.Address(iotago.AddressEd25519).(*iotago.Ed25519Address) w.indexAddrMap[index] = addr.String() w.addrIndexMap[addr.String()] = index @@ -85,7 +86,8 @@ func (w *Wallet) AddressOnIndex(index uint64) *iotago.Ed25519Address { defer w.Unlock() hdWallet := mock.NewHDWallet("", w.seed[:], index) - addr := hdWallet.Address() + //nolint:forcetypeassert + addr := hdWallet.Address(iotago.AddressEd25519).(*iotago.Ed25519Address) return addr } From 74473aaa683a84b0ac1f0fc4373e70f4decf990b Mon Sep 17 00:00:00 2001 From: Andrew Date: Wed, 20 Sep 2023 17:14:50 +0100 Subject: [PATCH 08/24] fixes for account test --- pkg/tests/accounts_test.go | 7 ++++++- pkg/testsuite/transactions_framework.go | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/pkg/tests/accounts_test.go b/pkg/tests/accounts_test.go index 6c3ae427b..8ee6a5f39 100644 --- a/pkg/tests/accounts_test.go +++ b/pkg/tests/accounts_test.go @@ -347,6 +347,11 @@ func Test_TransitionAccount(t *testing.T) { tx6 := lo.PanicOnErr(ts.TransactionFramework.CreateTransactionWithOptions("TX6", fullAccountWallet, testsuite.WithInputs(inputForImplicitAccountTransition), testsuite.WithOutputs(outputsForImplicitAccountTransition), + testsuite.WithContextInputs(iotago.TxEssenceContextInputs{ + &iotago.CommitmentInput{ + CommitmentID: node1.Protocol.MainEngineInstance().Storage.Settings().LatestCommitment().Commitment().MustID(), + }, + }), )) slotIndexBlock6 := latestParent.ID().Index() @@ -374,7 +379,7 @@ func Test_TransitionAccount(t *testing.T) { ID: implicitAccountID, Credits: accounts.NewBlockIssuanceCredits(0, slotIndexBlock6), ExpirySlot: iotago.SlotIndex(math.MaxUint64), - OutputID: implicitAccountOutputID, + OutputID: fullAccountOutputID, BlockIssuerKeys: ds.NewSet(fullAccountBlockIssuerKey), }, ts.Nodes()...) diff --git a/pkg/testsuite/transactions_framework.go b/pkg/testsuite/transactions_framework.go index bf8c14848..e4b49de6c 100644 --- a/pkg/testsuite/transactions_framework.go +++ b/pkg/testsuite/transactions_framework.go @@ -344,6 +344,7 @@ func (t *TransactionFramework) TransitionImplicitAccountToAccountOutput(alias st accountOutput := options.Apply(&iotago.AccountOutput{ Amount: input.BaseTokenAmount(), Mana: input.StoredMana(), + AccountID: iotago.AccountIDFromOutputID(input.OutputID()), NativeTokens: iotago.NativeTokens{}, Conditions: iotago.AccountOutputUnlockConditions{ &iotago.StateControllerAddressUnlockCondition{Address: t.DefaultAddress()}, From ec314bf67d19fed9d67e0e990de562d8fa406719 Mon Sep 17 00:00:00 2001 From: Andrew Date: Tue, 26 Sep 2023 11:14:37 +0200 Subject: [PATCH 09/24] align with iota.go --- pkg/model/account_diff.go | 4 ++-- pkg/protocol/engine/accounts/accounts.go | 8 ++++---- pkg/protocol/engine/accounts/mana/manager.go | 4 ++-- .../commitmentfilter/accountsfilter/commitmentfilter.go | 4 ++-- pkg/protocol/engine/ledger/ledger/ledger.go | 2 +- .../mempool/conflictdag/conflictdagv1/conflictdag_test.go | 2 +- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/pkg/model/account_diff.go b/pkg/model/account_diff.go index 21a09a223..2e9f5a8d1 100644 --- a/pkg/model/account_diff.go +++ b/pkg/model/account_diff.go @@ -233,7 +233,7 @@ func readBlockIssuerKey(reader io.ReadSeeker) (iotago.BlockIssuerKey, int, error bytesConsumed++ switch blockIssuerKeyType { - case iotago.Ed25519BlockIssuerKey: + case iotago.BlockIssuerKeyEd25519PublicKey: var ed25519PublicKey ed25519.PublicKey var bytesRead, err = io.ReadFull(reader, ed25519PublicKey[:]) bytesConsumed += bytesRead @@ -241,7 +241,7 @@ func readBlockIssuerKey(reader io.ReadSeeker) (iotago.BlockIssuerKey, int, error return nil, bytesConsumed, ierrors.Errorf("unable to read ed25519 public key in account diff: %w", err) } - return iotago.BlockIssuerKeyEd25519FromPublicKey(ed25519PublicKey), bytesConsumed, nil + return iotago.Ed25519PublicKeyBlockIssuerKeyFromPublicKey(ed25519PublicKey), bytesConsumed, nil default: return nil, bytesConsumed, ierrors.Errorf("unsupported block issuer key type %d in account diff", blockIssuerKeyType) } diff --git a/pkg/protocol/engine/accounts/accounts.go b/pkg/protocol/engine/accounts/accounts.go index 8ac5149c0..ae1503463 100644 --- a/pkg/protocol/engine/accounts/accounts.go +++ b/pkg/protocol/engine/accounts/accounts.go @@ -138,22 +138,22 @@ func (a *AccountData) readFromReadSeeker(reader io.ReadSeeker) (int, error) { bytesConsumed++ switch blockIssuerKeyType { - case iotago.Ed25519BlockIssuerKey: + case iotago.BlockIssuerKeyEd25519PublicKey: var ed25519PublicKey ed25519.PublicKey bytesRead, err = io.ReadFull(reader, ed25519PublicKey[:]) if err != nil { return bytesConsumed, ierrors.Wrapf(err, "unable to read public key index %d for accountID %s", i, a.ID) } bytesConsumed += bytesRead - blockIssuerKeys[i] = iotago.BlockIssuerKeyEd25519FromPublicKey(ed25519PublicKey) - case iotago.Ed25519BlockIssuerKeyAddress: + blockIssuerKeys[i] = iotago.Ed25519PublicKeyBlockIssuerKeyFromPublicKey(ed25519PublicKey) + case iotago.BlockIssuerKeyEd25519Address: var implicitAccountCreationAddress iotago.ImplicitAccountCreationAddress bytesRead, err = io.ReadFull(reader, implicitAccountCreationAddress[:]) if err != nil { return bytesConsumed, ierrors.Wrapf(err, "unable to read address %d for accountID %s", i, a.ID) } bytesConsumed += bytesRead - blockIssuerKeys[i] = iotago.BlockIssuerKeyEd25519AddressFromAddress(&implicitAccountCreationAddress) + blockIssuerKeys[i] = iotago.Ed25519AddressBlockIssuerKeyFromAddress(&implicitAccountCreationAddress) default: return bytesConsumed, ierrors.Wrapf(err, "unsupported block issuer key type %d for accountID %s at offset %d", blockIssuerKeyType, a.ID, i) } diff --git a/pkg/protocol/engine/accounts/mana/manager.go b/pkg/protocol/engine/accounts/mana/manager.go index 51e9d6066..4afbe0313 100644 --- a/pkg/protocol/engine/accounts/mana/manager.go +++ b/pkg/protocol/engine/accounts/mana/manager.go @@ -45,7 +45,7 @@ func (m *Manager) GetManaOnAccount(accountID iotago.AccountID, currentSlot iotag if err != nil { return 0, ierrors.Errorf("failed to resolve AccountOutput for %s in slot %s: %w", accountID, currentSlot, err) } - minDeposit := m.apiProvider.CurrentAPI().ProtocolParameters().RentStructure().MinDeposit(output.Output()) + minDeposit := m.apiProvider.CurrentAPI().RentStructure().MinDeposit(output.Output()) if output.BaseTokenAmount() <= minDeposit { mana = accounts.NewMana(output.StoredMana(), 0, output.CreationSlot()) } else { @@ -92,7 +92,7 @@ func (m *Manager) ApplyDiff(slotIndex iotago.SlotIndex, destroyedAccounts ds.Set for accountID, output := range accountOutputs { mana, exists := m.manaVectorCache.Get(accountID) if exists { - minDeposit := m.apiProvider.CurrentAPI().ProtocolParameters().RentStructure().MinDeposit(output.Output()) + minDeposit := m.apiProvider.CurrentAPI().RentStructure().MinDeposit(output.Output()) if output.BaseTokenAmount() <= minDeposit { mana.Update(output.StoredMana(), 0, slotIndex) } else { diff --git a/pkg/protocol/engine/commitmentfilter/accountsfilter/commitmentfilter.go b/pkg/protocol/engine/commitmentfilter/accountsfilter/commitmentfilter.go index eee187cc8..d176e668b 100644 --- a/pkg/protocol/engine/commitmentfilter/accountsfilter/commitmentfilter.go +++ b/pkg/protocol/engine/commitmentfilter/accountsfilter/commitmentfilter.go @@ -153,11 +153,11 @@ func (c *CommitmentFilter) evaluateBlock(block *blocks.Block) { switch signature := block.ProtocolBlock().Signature.(type) { case *iotago.Ed25519Signature: - if !accountData.BlockIssuerKeys.Has(iotago.BlockIssuerKeyEd25519FromPublicKey(signature.PublicKey)) { + if !accountData.BlockIssuerKeys.Has(iotago.Ed25519PublicKeyBlockIssuerKeyFromPublicKey(signature.PublicKey)) { // if the block issuer does not have the public key in the slot commitment, check if it has an implicit account with the corresponding address var hasAddress = false accountData.BlockIssuerKeys.Range(func(element iotago.BlockIssuerKey) { - if keyAddress, isAddress := element.(iotago.BlockIssuerKeyEd25519Address); isAddress { + if keyAddress, isAddress := element.(iotago.Ed25519AddressBlockIssuerKey); isAddress { if keyAddress.Address.Equal(iotago.ImplicitAccountCreationAddressFromPubKey(signature.PublicKey[:])) { hasAddress = true } diff --git a/pkg/protocol/engine/ledger/ledger/ledger.go b/pkg/protocol/engine/ledger/ledger/ledger.go index d1d4a504b..ab24369b1 100644 --- a/pkg/protocol/engine/ledger/ledger/ledger.go +++ b/pkg/protocol/engine/ledger/ledger/ledger.go @@ -461,7 +461,7 @@ func (l *Ledger) prepareAccountDiffs(accountDiffs map[iotago.AccountID]*model.Ac case iotago.OutputBasic: address, _ := createdOutput.Output().UnlockConditionSet().Address().Address.(*iotago.ImplicitAccountCreationAddress) accountDiff.BlockIssuerKeysAdded = iotago.BlockIssuerKeys{iotago.BlockIssuerKeyEd25519AddressFromAddress(address)} - accountDiff.NewExpirySlot = iotago.SlotIndex(math.MaxUint64) + accountDiff.NewExpirySlot = iotago.MaxSlotIndex } } diff --git a/pkg/protocol/engine/mempool/conflictdag/conflictdagv1/conflictdag_test.go b/pkg/protocol/engine/mempool/conflictdag/conflictdagv1/conflictdag_test.go index 1682921bf..577033350 100644 --- a/pkg/protocol/engine/mempool/conflictdag/conflictdagv1/conflictdag_test.go +++ b/pkg/protocol/engine/mempool/conflictdag/conflictdagv1/conflictdag_test.go @@ -40,7 +40,7 @@ func transactionID(alias string) iotago.TransactionID { hashedAlias := blake2b.Sum256([]byte(alias)) var result iotago.TransactionID - result, _, err := iotago.IdentifierFromBytes(hashedAlias[:]) + result, _, err := iotago.SlotIdentifierFromBytes(hashedAlias[:]) if err != nil { panic(err) } From 192c41547988a6fa08c7d4e8fed9954424c73a54 Mon Sep 17 00:00:00 2001 From: Andrew Date: Wed, 27 Sep 2023 09:42:47 +0200 Subject: [PATCH 10/24] fix merge errors --- .../accountsfilter/commitmentfilter.go | 23 ++++++++----------- .../accountsfilter/commitmentfilter_test.go | 4 ++-- pkg/protocol/engine/ledger/ledger/ledger.go | 8 +++---- .../snapshotcreator/snapshotcreator.go | 4 ++-- pkg/tests/accounts_test.go | 15 ++++++------ 5 files changed, 24 insertions(+), 30 deletions(-) diff --git a/pkg/protocol/engine/commitmentfilter/accountsfilter/commitmentfilter.go b/pkg/protocol/engine/commitmentfilter/accountsfilter/commitmentfilter.go index d176e668b..0bf073a05 100644 --- a/pkg/protocol/engine/commitmentfilter/accountsfilter/commitmentfilter.go +++ b/pkg/protocol/engine/commitmentfilter/accountsfilter/commitmentfilter.go @@ -155,22 +155,17 @@ func (c *CommitmentFilter) evaluateBlock(block *blocks.Block) { case *iotago.Ed25519Signature: if !accountData.BlockIssuerKeys.Has(iotago.Ed25519PublicKeyBlockIssuerKeyFromPublicKey(signature.PublicKey)) { // if the block issuer does not have the public key in the slot commitment, check if it has an implicit account with the corresponding address - var hasAddress = false - accountData.BlockIssuerKeys.Range(func(element iotago.BlockIssuerKey) { - if keyAddress, isAddress := element.(iotago.Ed25519AddressBlockIssuerKey); isAddress { - if keyAddress.Address.Equal(iotago.ImplicitAccountCreationAddressFromPubKey(signature.PublicKey[:])) { - hasAddress = true - } + if keyAddress, isAddress := accountData.BlockIssuerKeys[0].(*iotago.Ed25519AddressBlockIssuerKey); isAddress { + if !keyAddress.Address.Equal(iotago.ImplicitAccountCreationAddressFromPubKey(signature.PublicKey[:])) { + c.events.BlockFiltered.Trigger(&commitmentfilter.BlockFilteredEvent{ + Block: block, + Reason: ierrors.Wrapf(ErrInvalidSignature, "block issuer account %s does not have block issuer key corresponding to public key %s in slot %d", block.ProtocolBlock().IssuerID, signature.PublicKey, block.ProtocolBlock().SlotCommitmentID.Index()), + }) + + return } - }) - if !hasAddress { - c.events.BlockFiltered.Trigger(&commitmentfilter.BlockFilteredEvent{ - Block: block, - Reason: ierrors.Wrapf(ErrInvalidSignature, "block issuer account %s does not have block issuer key corresponding to public key %s in slot %d", block.ProtocolBlock().IssuerID, signature.PublicKey, block.ProtocolBlock().SlotCommitmentID.Index()), - }) - - return } + } signingMessage, err := block.ProtocolBlock().SigningMessage(blockAPI) if err != nil { diff --git a/pkg/protocol/engine/commitmentfilter/accountsfilter/commitmentfilter_test.go b/pkg/protocol/engine/commitmentfilter/accountsfilter/commitmentfilter_test.go index a0f6b3865..909e95ec5 100644 --- a/pkg/protocol/engine/commitmentfilter/accountsfilter/commitmentfilter_test.go +++ b/pkg/protocol/engine/commitmentfilter/accountsfilter/commitmentfilter_test.go @@ -181,8 +181,8 @@ func TestCommitmentFilter_NoAccount(t *testing.T) { implicitAccountID, accounts.NewAccountData( implicitAccountID, - accounts.WithExpirySlot(math.MaxUint64), - accounts.WithBlockIssuerKeys(iotago.BlockIssuerKeyEd25519AddressFromAddress(implicitAddress)), + accounts.WithExpirySlot(iotago.MaxSlotIndex), + accounts.WithBlockIssuerKeys(iotago.Ed25519AddressBlockIssuerKeyFromAddress(implicitAddress)), ), ) diff --git a/pkg/protocol/engine/ledger/ledger/ledger.go b/pkg/protocol/engine/ledger/ledger/ledger.go index 5cdc40de2..48bc39f64 100644 --- a/pkg/protocol/engine/ledger/ledger/ledger.go +++ b/pkg/protocol/engine/ledger/ledger/ledger.go @@ -1,8 +1,8 @@ package ledger import ( + "fmt" "io" - "math" "github.com/iotaledger/hive.go/core/safemath" "github.com/iotaledger/hive.go/ds" @@ -390,7 +390,7 @@ func (l *Ledger) prepareAccountDiffs(accountDiffs map[iotago.AccountID]*model.Ac case iotago.OutputAccount: accountDiff.PreviousExpirySlot = consumedOutput.Output().FeatureSet().BlockIssuer().ExpirySlot case iotago.OutputBasic: - accountDiff.PreviousExpirySlot = iotago.SlotIndex(math.MaxUint64) + accountDiff.PreviousExpirySlot = iotago.MaxSlotIndex } accountDiff.PreviousOutputID = consumedOutput.OutputID() @@ -462,10 +462,10 @@ func (l *Ledger) prepareAccountDiffs(accountDiffs map[iotago.AccountID]*model.Ac // for basic outputs (implicit accounts), get block issuer keys from the address in the unlock conditions. case iotago.OutputBasic: address, _ := createdOutput.Output().UnlockConditionSet().Address().Address.(*iotago.ImplicitAccountCreationAddress) - accountDiff.BlockIssuerKeysAdded = iotago.BlockIssuerKeys{iotago.BlockIssuerKeyEd25519AddressFromAddress(address)} + accountDiff.BlockIssuerKeysAdded = iotago.BlockIssuerKeys{iotago.Ed25519AddressBlockIssuerKeyFromAddress(address)} accountDiff.NewExpirySlot = iotago.MaxSlotIndex } - + fmt.Printf("account diff for %s: %+v\n", createdAccountID, accountDiff) } } diff --git a/pkg/protocol/snapshotcreator/snapshotcreator.go b/pkg/protocol/snapshotcreator/snapshotcreator.go index 9bab2a3ce..a23983d2a 100644 --- a/pkg/protocol/snapshotcreator/snapshotcreator.go +++ b/pkg/protocol/snapshotcreator/snapshotcreator.go @@ -135,7 +135,7 @@ func createGenesisOutput(genesisTokenAmount iotago.BaseToken, genesisSeed []byte genesisWallet := mock.NewHDWallet("genesis", genesisSeed, 0) output := createOutput(genesisWallet.Address(), genesisTokenAmount) - if _, err := engineInstance.CurrentAPI().ProtocolParameters().RentStructure().CoversMinDeposit(output, genesisTokenAmount); err != nil { + if _, err := engineInstance.CurrentAPI().RentStructure().CoversMinDeposit(output, genesisTokenAmount); err != nil { return ierrors.Wrap(err, "min rent not covered by Genesis output with index 0") } @@ -153,7 +153,7 @@ func createGenesisAccounts(accounts []AccountDetails, engineInstance *engine.Eng for idx, genesisAccount := range accounts { output := createAccount(genesisAccount.AccountID, genesisAccount.Address, genesisAccount.Amount, genesisAccount.Mana, genesisAccount.IssuerKey, genesisAccount.ExpirySlot, genesisAccount.StakedAmount, genesisAccount.StakingEpochEnd, genesisAccount.FixedCost) - if _, err := engineInstance.CurrentAPI().ProtocolParameters().RentStructure().CoversMinDeposit(output, genesisAccount.Amount); err != nil { + if _, err := engineInstance.CurrentAPI().RentStructure().CoversMinDeposit(output, genesisAccount.Amount); err != nil { return ierrors.Wrapf(err, "min rent not covered by account output with index %d", idx+1) } diff --git a/pkg/tests/accounts_test.go b/pkg/tests/accounts_test.go index 6d005f9dc..4d7ee11a1 100644 --- a/pkg/tests/accounts_test.go +++ b/pkg/tests/accounts_test.go @@ -1,7 +1,6 @@ package tests import ( - "math" "testing" "github.com/iotaledger/hive.go/lo" @@ -69,7 +68,7 @@ func Test_TransitionAccount(t *testing.T) { testsuite.AddBlockIssuerKey(newGenesisOutputKey), testsuite.WithBlockIssuerExpirySlot(1), ) - consumedInputs, equalOutputs, equalWallets := ts.TransactionFramework.CreateBasicOutputsEqually(2, "Genesis:0") + consumedInputs, equalOutputs, equalWallets := ts.TransactionFramework.CreateBasicOutputsEqually(4, "Genesis:0") tx1 := lo.PanicOnErr(ts.TransactionFramework.CreateTransactionWithOptions("TX1", append(accountWallets, equalWallets...), testsuite.WithAccountInput(accountInput, true), @@ -322,14 +321,14 @@ func Test_TransitionAccount(t *testing.T) { latestParent = ts.CommitUntilSlot(slotIndexBlock5, activeNodes, block5) - var implicitBlockIssuerKey iotago.BlockIssuerKey = iotago.BlockIssuerKeyEd25519AddressFromAddress(implicitAccountAddress) + var implicitBlockIssuerKey iotago.BlockIssuerKey = iotago.Ed25519AddressBlockIssuerKeyFromAddress(implicitAccountAddress) ts.AssertAccountData(&accounts.AccountData{ ID: implicitAccountID, Credits: accounts.NewBlockIssuanceCredits(0, slotIndexBlock5), - ExpirySlot: iotago.SlotIndex(math.MaxUint64), + ExpirySlot: iotago.MaxSlotIndex, OutputID: implicitAccountOutputID, - BlockIssuerKeys: ds.NewSet(implicitBlockIssuerKey), + BlockIssuerKeys: iotago.NewBlockIssuerKeys(implicitBlockIssuerKey), }, ts.Nodes()...) // TRANSITION IMPLICIT ACCOUNT TO ACCOUNT OUTPUT @@ -340,7 +339,7 @@ func Test_TransitionAccount(t *testing.T) { "TX5:0", testsuite.WithBlockIssuerFeature(&iotago.BlockIssuerFeature{ BlockIssuerKeys: iotago.BlockIssuerKeys{fullAccountBlockIssuerKey}, - ExpirySlot: math.MaxUint64, + ExpirySlot: iotago.MaxSlotIndex, }), ) @@ -378,9 +377,9 @@ func Test_TransitionAccount(t *testing.T) { ts.AssertAccountData(&accounts.AccountData{ ID: implicitAccountID, Credits: accounts.NewBlockIssuanceCredits(0, slotIndexBlock6), - ExpirySlot: iotago.SlotIndex(math.MaxUint64), + ExpirySlot: iotago.MaxSlotIndex, OutputID: fullAccountOutputID, - BlockIssuerKeys: ds.NewSet(fullAccountBlockIssuerKey), + BlockIssuerKeys: iotago.NewBlockIssuerKeys(fullAccountBlockIssuerKey), }, ts.Nodes()...) ts.Wait(ts.Nodes()...) From b15799e79acaf2ca261f163f4aa8b33314eec3db Mon Sep 17 00:00:00 2001 From: Andrew Date: Wed, 27 Sep 2023 10:07:24 +0200 Subject: [PATCH 11/24] use block issuer key constructor --- pkg/protocol/engine/ledger/ledger/ledger.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/protocol/engine/ledger/ledger/ledger.go b/pkg/protocol/engine/ledger/ledger/ledger.go index 48bc39f64..553f79607 100644 --- a/pkg/protocol/engine/ledger/ledger/ledger.go +++ b/pkg/protocol/engine/ledger/ledger/ledger.go @@ -462,7 +462,7 @@ func (l *Ledger) prepareAccountDiffs(accountDiffs map[iotago.AccountID]*model.Ac // for basic outputs (implicit accounts), get block issuer keys from the address in the unlock conditions. case iotago.OutputBasic: address, _ := createdOutput.Output().UnlockConditionSet().Address().Address.(*iotago.ImplicitAccountCreationAddress) - accountDiff.BlockIssuerKeysAdded = iotago.BlockIssuerKeys{iotago.Ed25519AddressBlockIssuerKeyFromAddress(address)} + accountDiff.BlockIssuerKeysAdded = iotago.NewBlockIssuerKeys(iotago.Ed25519AddressBlockIssuerKeyFromAddress(address)) accountDiff.NewExpirySlot = iotago.MaxSlotIndex } fmt.Printf("account diff for %s: %+v\n", createdAccountID, accountDiff) From 08d48e27f62305fb89f65b81bf675f7481a9ed7a Mon Sep 17 00:00:00 2001 From: Andrew Date: Wed, 27 Sep 2023 12:58:08 +0200 Subject: [PATCH 12/24] update to implicit account block issuer key type to pubkeyhash in iotago --- go.mod | 2 +- go.sum | 4 ++-- pkg/model/account_diff.go | 2 +- pkg/protocol/engine/accounts/accounts.go | 2 +- .../commitmentfilter/accountsfilter/commitmentfilter.go | 5 +++-- .../commitmentfilter/accountsfilter/commitmentfilter_test.go | 2 +- pkg/protocol/engine/ledger/ledger/ledger.go | 2 +- pkg/tests/accounts_test.go | 2 +- tools/evil-spammer/go.mod | 2 +- tools/evil-spammer/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 ++-- 14 files changed, 20 insertions(+), 19 deletions(-) diff --git a/go.mod b/go.mod index d0a2cb1cc..57ac35d63 100644 --- a/go.mod +++ b/go.mod @@ -26,7 +26,7 @@ require ( github.com/iotaledger/hive.go/stringify v0.0.0-20230926122307-d671b36a4a65 github.com/iotaledger/inx-app v1.0.0-rc.3.0.20230925153303-c7fbe63a0ab4 github.com/iotaledger/inx/go v1.0.0-rc.2.0.20230925152824-4bfa09b8c132 - github.com/iotaledger/iota.go/v4 v4.0.0-20230926171759-340cfc7c2478 + github.com/iotaledger/iota.go/v4 v4.0.0-20230927105604-ea84bcb2c9d4 github.com/labstack/echo/v4 v4.11.1 github.com/labstack/gommon v0.4.0 github.com/libp2p/go-libp2p v0.30.0 diff --git a/go.sum b/go.sum index 9415582e0..e667df197 100644 --- a/go.sum +++ b/go.sum @@ -305,8 +305,8 @@ github.com/iotaledger/inx-app v1.0.0-rc.3.0.20230925153303-c7fbe63a0ab4 h1:pbw/e github.com/iotaledger/inx-app v1.0.0-rc.3.0.20230925153303-c7fbe63a0ab4/go.mod h1:KbmEuxbhax3fyVrxF4RjBD1/MWLFxHLNDFBnDYUzok4= github.com/iotaledger/inx/go v1.0.0-rc.2.0.20230925152824-4bfa09b8c132 h1:YHvgNY3/TRx84UxqizkFe7vVUxAMQB2DOuEL8wjHxpg= github.com/iotaledger/inx/go v1.0.0-rc.2.0.20230925152824-4bfa09b8c132/go.mod h1:DIFr5lt73HLIyn/Lg2jtzfakwhIT0mMZjMFFji3GXeI= -github.com/iotaledger/iota.go/v4 v4.0.0-20230926171759-340cfc7c2478 h1:sAjTMFvLwABCiYSh4JJehpwY5Tz20BgzGtgVbkwpyf4= -github.com/iotaledger/iota.go/v4 v4.0.0-20230926171759-340cfc7c2478/go.mod h1:wR9xBbsofns9hFyRHFZ2bDYIb861qsfmQPVMBKcPvDo= +github.com/iotaledger/iota.go/v4 v4.0.0-20230927105604-ea84bcb2c9d4 h1:ZKaBVOWDzsM+Iq46l73VYp+wfhp/BytplvCsDQbkgTA= +github.com/iotaledger/iota.go/v4 v4.0.0-20230927105604-ea84bcb2c9d4/go.mod h1:wR9xBbsofns9hFyRHFZ2bDYIb861qsfmQPVMBKcPvDo= github.com/ipfs/boxo v0.10.0 h1:tdDAxq8jrsbRkYoF+5Rcqyeb91hgWe2hp7iLu7ORZLY= github.com/ipfs/boxo v0.10.0/go.mod h1:Fg+BnfxZ0RPzR0nOodzdIq3A7KgoWAOWsEIImrIQdBM= github.com/ipfs/go-cid v0.4.1 h1:A/T3qGvxi4kpKWWcPC/PgbvDA2bjVLO7n4UeVwnbs/s= diff --git a/pkg/model/account_diff.go b/pkg/model/account_diff.go index 0846247fe..12199c371 100644 --- a/pkg/model/account_diff.go +++ b/pkg/model/account_diff.go @@ -254,7 +254,7 @@ func readBlockIssuerKey(reader io.ReadSeeker) (iotago.BlockIssuerKey, int, error // return nil, bytesConsumed, ierrors.Errorf("unable to read ed25519 address key in account diff: %w", err) // } // - // return iotago.Ed25519AddressBlockIssuerKeyFromAddress(ed25519Address), bytesConsumed, nil + // return iotago.Ed25519PublicKeyHashBlockIssuerKeyFromAddress(ed25519Address), bytesConsumed, nil default: return nil, bytesConsumed, ierrors.Errorf("unsupported block issuer key type %d in account diff", blockIssuerKeyType) diff --git a/pkg/protocol/engine/accounts/accounts.go b/pkg/protocol/engine/accounts/accounts.go index 4984ecac3..b9eca4ed6 100644 --- a/pkg/protocol/engine/accounts/accounts.go +++ b/pkg/protocol/engine/accounts/accounts.go @@ -148,7 +148,7 @@ func (a *AccountData) readFromReadSeeker(reader io.ReadSeeker) (int, error) { return bytesConsumed, ierrors.Wrapf(err, "unable to read address %d for accountID %s", i, a.ID) } bytesConsumed += bytesRead - a.BlockIssuerKeys.Add(iotago.Ed25519AddressBlockIssuerKeyFromAddress(&implicitAccountCreationAddress)) + a.BlockIssuerKeys.Add(iotago.Ed25519PublicKeyHashBlockIssuerKeyFromImplicitAccountCreationAddress(&implicitAccountCreationAddress)) default: return bytesConsumed, ierrors.Wrapf(err, "unsupported block issuer key type %d for accountID %s at offset %d", blockIssuerKeyType, a.ID, i) } diff --git a/pkg/protocol/engine/commitmentfilter/accountsfilter/commitmentfilter.go b/pkg/protocol/engine/commitmentfilter/accountsfilter/commitmentfilter.go index e6fcd04f1..27f5fda5e 100644 --- a/pkg/protocol/engine/commitmentfilter/accountsfilter/commitmentfilter.go +++ b/pkg/protocol/engine/commitmentfilter/accountsfilter/commitmentfilter.go @@ -155,8 +155,9 @@ func (c *CommitmentFilter) evaluateBlock(block *blocks.Block) { case *iotago.Ed25519Signature: if !accountData.BlockIssuerKeys.Has(iotago.Ed25519PublicKeyBlockIssuerKeyFromPublicKey(signature.PublicKey)) { // if the block issuer does not have the public key in the slot commitment, check if it has an implicit account with the corresponding address - if keyAddress, isAddress := accountData.BlockIssuerKeys[0].(*iotago.Ed25519AddressBlockIssuerKey); isAddress { - if !keyAddress.Address.Equal(iotago.ImplicitAccountCreationAddressFromPubKey(signature.PublicKey[:])) { + if keyAddress, isAddress := accountData.BlockIssuerKeys[0].(*iotago.Ed25519PublicKeyHashBlockIssuerKey); isAddress { + + if keyAddress.PublicKeyHash != iotago.Ed25519PublicKeyHashBlockIssuerKeyFromPublicKey(signature.PublicKey[:]).PublicKeyHash { c.events.BlockFiltered.Trigger(&commitmentfilter.BlockFilteredEvent{ Block: block, Reason: ierrors.Wrapf(ErrInvalidSignature, "block issuer account %s does not have block issuer key corresponding to public key %s in slot %d", block.ProtocolBlock().IssuerID, signature.PublicKey, block.ProtocolBlock().SlotCommitmentID.Index()), diff --git a/pkg/protocol/engine/commitmentfilter/accountsfilter/commitmentfilter_test.go b/pkg/protocol/engine/commitmentfilter/accountsfilter/commitmentfilter_test.go index 3b6089cba..579a493ab 100644 --- a/pkg/protocol/engine/commitmentfilter/accountsfilter/commitmentfilter_test.go +++ b/pkg/protocol/engine/commitmentfilter/accountsfilter/commitmentfilter_test.go @@ -171,7 +171,7 @@ func TestCommitmentFilter_NoAccount(t *testing.T) { accounts.NewAccountData( implicitAccountID, accounts.WithExpirySlot(iotago.MaxSlotIndex), - accounts.WithBlockIssuerKeys(iotago.Ed25519AddressBlockIssuerKeyFromAddress(implicitAddress)), + accounts.WithBlockIssuerKeys(iotago.Ed25519PublicKeyHashBlockIssuerKeyFromImplicitAccountCreationAddress(implicitAddress)), ), ) diff --git a/pkg/protocol/engine/ledger/ledger/ledger.go b/pkg/protocol/engine/ledger/ledger/ledger.go index 553f79607..e9c8c5010 100644 --- a/pkg/protocol/engine/ledger/ledger/ledger.go +++ b/pkg/protocol/engine/ledger/ledger/ledger.go @@ -462,7 +462,7 @@ func (l *Ledger) prepareAccountDiffs(accountDiffs map[iotago.AccountID]*model.Ac // for basic outputs (implicit accounts), get block issuer keys from the address in the unlock conditions. case iotago.OutputBasic: address, _ := createdOutput.Output().UnlockConditionSet().Address().Address.(*iotago.ImplicitAccountCreationAddress) - accountDiff.BlockIssuerKeysAdded = iotago.NewBlockIssuerKeys(iotago.Ed25519AddressBlockIssuerKeyFromAddress(address)) + accountDiff.BlockIssuerKeysAdded = iotago.NewBlockIssuerKeys(iotago.Ed25519PublicKeyHashBlockIssuerKeyFromImplicitAccountCreationAddress(address)) accountDiff.NewExpirySlot = iotago.MaxSlotIndex } fmt.Printf("account diff for %s: %+v\n", createdAccountID, accountDiff) diff --git a/pkg/tests/accounts_test.go b/pkg/tests/accounts_test.go index bb286480c..4c5444114 100644 --- a/pkg/tests/accounts_test.go +++ b/pkg/tests/accounts_test.go @@ -321,7 +321,7 @@ func Test_TransitionAccount(t *testing.T) { latestParent = ts.CommitUntilSlot(slotIndexBlock5, activeNodes, block5) - var implicitBlockIssuerKey iotago.BlockIssuerKey = iotago.Ed25519AddressBlockIssuerKeyFromAddress(implicitAccountAddress) + var implicitBlockIssuerKey iotago.BlockIssuerKey = iotago.Ed25519PublicKeyHashBlockIssuerKeyFromImplicitAccountCreationAddress(implicitAccountAddress) ts.AssertAccountData(&accounts.AccountData{ ID: implicitAccountID, diff --git a/tools/evil-spammer/go.mod b/tools/evil-spammer/go.mod index bab246f37..2cb632e8a 100644 --- a/tools/evil-spammer/go.mod +++ b/tools/evil-spammer/go.mod @@ -17,7 +17,7 @@ require ( github.com/iotaledger/hive.go/runtime v0.0.0-20230926122307-d671b36a4a65 github.com/iotaledger/iota-core v0.0.0-00010101000000-000000000000 github.com/iotaledger/iota-core/tools/genesis-snapshot v0.0.0-00010101000000-000000000000 - github.com/iotaledger/iota.go/v4 v4.0.0-20230926171759-340cfc7c2478 + github.com/iotaledger/iota.go/v4 v4.0.0-20230927105604-ea84bcb2c9d4 github.com/mr-tron/base58 v1.2.0 go.uber.org/atomic v1.11.0 ) diff --git a/tools/evil-spammer/go.sum b/tools/evil-spammer/go.sum index b4710506f..308046bd3 100644 --- a/tools/evil-spammer/go.sum +++ b/tools/evil-spammer/go.sum @@ -195,8 +195,8 @@ github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20230926122307-d671b36 github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20230926122307-d671b36a4a65/go.mod h1:IJgaaxbgKCsNat18jlJJEAxCY2oVYR3F30B+M4vJ89I= github.com/iotaledger/hive.go/stringify v0.0.0-20230926122307-d671b36a4a65 h1:3OmUR8yYlCENhbosY99eM3bIJQJCiLijtebt+Q6sQEs= github.com/iotaledger/hive.go/stringify v0.0.0-20230926122307-d671b36a4a65/go.mod h1:FTo/UWzNYgnQ082GI9QVM9HFDERqf9rw9RivNpqrnTs= -github.com/iotaledger/iota.go/v4 v4.0.0-20230926171759-340cfc7c2478 h1:sAjTMFvLwABCiYSh4JJehpwY5Tz20BgzGtgVbkwpyf4= -github.com/iotaledger/iota.go/v4 v4.0.0-20230926171759-340cfc7c2478/go.mod h1:wR9xBbsofns9hFyRHFZ2bDYIb861qsfmQPVMBKcPvDo= +github.com/iotaledger/iota.go/v4 v4.0.0-20230927105604-ea84bcb2c9d4 h1:ZKaBVOWDzsM+Iq46l73VYp+wfhp/BytplvCsDQbkgTA= +github.com/iotaledger/iota.go/v4 v4.0.0-20230927105604-ea84bcb2c9d4/go.mod h1:wR9xBbsofns9hFyRHFZ2bDYIb861qsfmQPVMBKcPvDo= 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/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= diff --git a/tools/gendoc/go.mod b/tools/gendoc/go.mod index 59620c7df..0e79936c7 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-20230926122307-d671b36a4a65 // indirect github.com/iotaledger/inx-app v1.0.0-rc.3.0.20230925153303-c7fbe63a0ab4 // indirect github.com/iotaledger/inx/go v1.0.0-rc.2.0.20230925152824-4bfa09b8c132 // indirect - github.com/iotaledger/iota.go/v4 v4.0.0-20230926171759-340cfc7c2478 // indirect + github.com/iotaledger/iota.go/v4 v4.0.0-20230927105604-ea84bcb2c9d4 // indirect github.com/ipfs/boxo v0.10.0 // 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 00dac6753..d93255583 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.20230925153303-c7fbe63a0ab4 h1:pbw/e github.com/iotaledger/inx-app v1.0.0-rc.3.0.20230925153303-c7fbe63a0ab4/go.mod h1:KbmEuxbhax3fyVrxF4RjBD1/MWLFxHLNDFBnDYUzok4= github.com/iotaledger/inx/go v1.0.0-rc.2.0.20230925152824-4bfa09b8c132 h1:YHvgNY3/TRx84UxqizkFe7vVUxAMQB2DOuEL8wjHxpg= github.com/iotaledger/inx/go v1.0.0-rc.2.0.20230925152824-4bfa09b8c132/go.mod h1:DIFr5lt73HLIyn/Lg2jtzfakwhIT0mMZjMFFji3GXeI= -github.com/iotaledger/iota.go/v4 v4.0.0-20230926171759-340cfc7c2478 h1:sAjTMFvLwABCiYSh4JJehpwY5Tz20BgzGtgVbkwpyf4= -github.com/iotaledger/iota.go/v4 v4.0.0-20230926171759-340cfc7c2478/go.mod h1:wR9xBbsofns9hFyRHFZ2bDYIb861qsfmQPVMBKcPvDo= +github.com/iotaledger/iota.go/v4 v4.0.0-20230927105604-ea84bcb2c9d4 h1:ZKaBVOWDzsM+Iq46l73VYp+wfhp/BytplvCsDQbkgTA= +github.com/iotaledger/iota.go/v4 v4.0.0-20230927105604-ea84bcb2c9d4/go.mod h1:wR9xBbsofns9hFyRHFZ2bDYIb861qsfmQPVMBKcPvDo= github.com/ipfs/boxo v0.10.0 h1:tdDAxq8jrsbRkYoF+5Rcqyeb91hgWe2hp7iLu7ORZLY= github.com/ipfs/boxo v0.10.0/go.mod h1:Fg+BnfxZ0RPzR0nOodzdIq3A7KgoWAOWsEIImrIQdBM= 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 eea632b7c..754555de6 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-20230926122307-d671b36a4a65 github.com/iotaledger/hive.go/runtime v0.0.0-20230926122307-d671b36a4a65 github.com/iotaledger/iota-core v0.0.0-00010101000000-000000000000 - github.com/iotaledger/iota.go/v4 v4.0.0-20230926171759-340cfc7c2478 + github.com/iotaledger/iota.go/v4 v4.0.0-20230927105604-ea84bcb2c9d4 github.com/mr-tron/base58 v1.2.0 github.com/spf13/pflag v1.0.5 golang.org/x/crypto v0.13.0 diff --git a/tools/genesis-snapshot/go.sum b/tools/genesis-snapshot/go.sum index 4fe32e3fb..6594b2d2d 100644 --- a/tools/genesis-snapshot/go.sum +++ b/tools/genesis-snapshot/go.sum @@ -50,8 +50,8 @@ github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20230926122307-d671b36 github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20230926122307-d671b36a4a65/go.mod h1:IJgaaxbgKCsNat18jlJJEAxCY2oVYR3F30B+M4vJ89I= github.com/iotaledger/hive.go/stringify v0.0.0-20230926122307-d671b36a4a65 h1:3OmUR8yYlCENhbosY99eM3bIJQJCiLijtebt+Q6sQEs= github.com/iotaledger/hive.go/stringify v0.0.0-20230926122307-d671b36a4a65/go.mod h1:FTo/UWzNYgnQ082GI9QVM9HFDERqf9rw9RivNpqrnTs= -github.com/iotaledger/iota.go/v4 v4.0.0-20230926171759-340cfc7c2478 h1:sAjTMFvLwABCiYSh4JJehpwY5Tz20BgzGtgVbkwpyf4= -github.com/iotaledger/iota.go/v4 v4.0.0-20230926171759-340cfc7c2478/go.mod h1:wR9xBbsofns9hFyRHFZ2bDYIb861qsfmQPVMBKcPvDo= +github.com/iotaledger/iota.go/v4 v4.0.0-20230927105604-ea84bcb2c9d4 h1:ZKaBVOWDzsM+Iq46l73VYp+wfhp/BytplvCsDQbkgTA= +github.com/iotaledger/iota.go/v4 v4.0.0-20230927105604-ea84bcb2c9d4/go.mod h1:wR9xBbsofns9hFyRHFZ2bDYIb861qsfmQPVMBKcPvDo= 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 9f2a0d489695a7f87779046edd00b76a338e4b74 Mon Sep 17 00:00:00 2001 From: Philipp Gackstatter Date: Wed, 27 Sep 2023 14:58:15 +0200 Subject: [PATCH 13/24] Document filter rules and increase resiliency --- .../accountsfilter/commitmentfilter.go | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/pkg/protocol/engine/commitmentfilter/accountsfilter/commitmentfilter.go b/pkg/protocol/engine/commitmentfilter/accountsfilter/commitmentfilter.go index 27f5fda5e..1f3b924ef 100644 --- a/pkg/protocol/engine/commitmentfilter/accountsfilter/commitmentfilter.go +++ b/pkg/protocol/engine/commitmentfilter/accountsfilter/commitmentfilter.go @@ -154,19 +154,22 @@ func (c *CommitmentFilter) evaluateBlock(block *blocks.Block) { switch signature := block.ProtocolBlock().Signature.(type) { case *iotago.Ed25519Signature: if !accountData.BlockIssuerKeys.Has(iotago.Ed25519PublicKeyBlockIssuerKeyFromPublicKey(signature.PublicKey)) { - // if the block issuer does not have the public key in the slot commitment, check if it has an implicit account with the corresponding address - if keyAddress, isAddress := accountData.BlockIssuerKeys[0].(*iotago.Ed25519PublicKeyHashBlockIssuerKey); isAddress { - - if keyAddress.PublicKeyHash != iotago.Ed25519PublicKeyHashBlockIssuerKeyFromPublicKey(signature.PublicKey[:]).PublicKeyHash { - c.events.BlockFiltered.Trigger(&commitmentfilter.BlockFilteredEvent{ - Block: block, - Reason: ierrors.Wrapf(ErrInvalidSignature, "block issuer account %s does not have block issuer key corresponding to public key %s in slot %d", block.ProtocolBlock().IssuerID, signature.PublicKey, block.ProtocolBlock().SlotCommitmentID.Index()), - }) - - return - } + // If the block issuer does not have the public key in the slot commitment, check if it is an implicit account with the corresponding address. + // There must be at least one block issuer key on any account, so extracting index 0 is fine. + // For implicit accounts there is exactly one key, so we do not have to check any other indices. + blockIssuerKey := accountData.BlockIssuerKeys[0] + // Implicit Accounts can only have Block Issuer Keys of type Ed25519PublicKeyHashBlockIssuerKey. + bikPubKeyHash, isBikPubKeyHash := blockIssuerKey.(*iotago.Ed25519PublicKeyHashBlockIssuerKey) + + // Filter the block if it's not a Block Issuer Key from an Implicit Account or if the Pub Key Hashes do not match. + if !isBikPubKeyHash || bikPubKeyHash.PublicKeyHash != iotago.Ed25519PublicKeyHashBlockIssuerKeyFromPublicKey(signature.PublicKey[:]).PublicKeyHash { + c.events.BlockFiltered.Trigger(&commitmentfilter.BlockFilteredEvent{ + Block: block, + Reason: ierrors.Wrapf(ErrInvalidSignature, "block issuer account %s does not have block issuer key corresponding to public key %s in slot %d", block.ProtocolBlock().IssuerID, signature.PublicKey, block.ProtocolBlock().SlotCommitmentID.Index()), + }) + + return } - } signingMessage, err := block.ProtocolBlock().SigningMessage() if err != nil { From c886ac1a22369159690827dc3e1404147e4a8ad9 Mon Sep 17 00:00:00 2001 From: Philipp Gackstatter Date: Wed, 27 Sep 2023 15:20:01 +0200 Subject: [PATCH 14/24] Add comment on type assertion --- pkg/protocol/engine/ledger/ledger/ledger.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/protocol/engine/ledger/ledger/ledger.go b/pkg/protocol/engine/ledger/ledger/ledger.go index e9c8c5010..8d51736cc 100644 --- a/pkg/protocol/engine/ledger/ledger/ledger.go +++ b/pkg/protocol/engine/ledger/ledger/ledger.go @@ -461,6 +461,7 @@ func (l *Ledger) prepareAccountDiffs(accountDiffs map[iotago.AccountID]*model.Ac } // for basic outputs (implicit accounts), get block issuer keys from the address in the unlock conditions. case iotago.OutputBasic: + // If the Output is a Basic Output it can only be here if the address is an ImplicitAccountCreationAddress. address, _ := createdOutput.Output().UnlockConditionSet().Address().Address.(*iotago.ImplicitAccountCreationAddress) accountDiff.BlockIssuerKeysAdded = iotago.NewBlockIssuerKeys(iotago.Ed25519PublicKeyHashBlockIssuerKeyFromImplicitAccountCreationAddress(address)) accountDiff.NewExpirySlot = iotago.MaxSlotIndex From d22c94c0e12056d772ac46681a130b6aaac82362 Mon Sep 17 00:00:00 2001 From: Andrew Date: Wed, 27 Sep 2023 16:34:33 +0200 Subject: [PATCH 15/24] go mod tidy --- go.mod | 2 +- go.sum | 4 ++-- pkg/tests/accounts_test.go | 1 + tools/evil-spammer/go.mod | 2 +- tools/evil-spammer/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 ++-- 9 files changed, 13 insertions(+), 12 deletions(-) diff --git a/go.mod b/go.mod index aa98955c2..2b6d0d72e 100644 --- a/go.mod +++ b/go.mod @@ -26,7 +26,7 @@ require ( github.com/iotaledger/hive.go/stringify v0.0.0-20230926122307-d671b36a4a65 github.com/iotaledger/inx-app v1.0.0-rc.3.0.20230927112840-e982cb6707c9 github.com/iotaledger/inx/go v1.0.0-rc.2.0.20230925152824-4bfa09b8c132 - github.com/iotaledger/iota.go/v4 v4.0.0-20230927105604-ea84bcb2c9d4 + github.com/iotaledger/iota.go/v4 v4.0.0-20230927142038-c44427859ad2 github.com/labstack/echo/v4 v4.11.1 github.com/labstack/gommon v0.4.0 github.com/libp2p/go-libp2p v0.30.0 diff --git a/go.sum b/go.sum index 7b117b923..841a6e701 100644 --- a/go.sum +++ b/go.sum @@ -305,8 +305,8 @@ github.com/iotaledger/inx-app v1.0.0-rc.3.0.20230927112840-e982cb6707c9 h1:vRGNf github.com/iotaledger/inx-app v1.0.0-rc.3.0.20230927112840-e982cb6707c9/go.mod h1:KbmEuxbhax3fyVrxF4RjBD1/MWLFxHLNDFBnDYUzok4= github.com/iotaledger/inx/go v1.0.0-rc.2.0.20230925152824-4bfa09b8c132 h1:YHvgNY3/TRx84UxqizkFe7vVUxAMQB2DOuEL8wjHxpg= github.com/iotaledger/inx/go v1.0.0-rc.2.0.20230925152824-4bfa09b8c132/go.mod h1:DIFr5lt73HLIyn/Lg2jtzfakwhIT0mMZjMFFji3GXeI= -github.com/iotaledger/iota.go/v4 v4.0.0-20230927105604-ea84bcb2c9d4 h1:ZKaBVOWDzsM+Iq46l73VYp+wfhp/BytplvCsDQbkgTA= -github.com/iotaledger/iota.go/v4 v4.0.0-20230927105604-ea84bcb2c9d4/go.mod h1:wR9xBbsofns9hFyRHFZ2bDYIb861qsfmQPVMBKcPvDo= +github.com/iotaledger/iota.go/v4 v4.0.0-20230927142038-c44427859ad2 h1:cJbjZis2WD9Iy86rrRkRG4a3RoCaEsJol4Rmv6PpwKA= +github.com/iotaledger/iota.go/v4 v4.0.0-20230927142038-c44427859ad2/go.mod h1:wR9xBbsofns9hFyRHFZ2bDYIb861qsfmQPVMBKcPvDo= github.com/ipfs/boxo v0.10.0 h1:tdDAxq8jrsbRkYoF+5Rcqyeb91hgWe2hp7iLu7ORZLY= github.com/ipfs/boxo v0.10.0/go.mod h1:Fg+BnfxZ0RPzR0nOodzdIq3A7KgoWAOWsEIImrIQdBM= github.com/ipfs/go-cid v0.4.1 h1:A/T3qGvxi4kpKWWcPC/PgbvDA2bjVLO7n4UeVwnbs/s= diff --git a/pkg/tests/accounts_test.go b/pkg/tests/accounts_test.go index eb9697716..5043daf2b 100644 --- a/pkg/tests/accounts_test.go +++ b/pkg/tests/accounts_test.go @@ -351,6 +351,7 @@ func Test_TransitionAccount(t *testing.T) { CommitmentID: node1.Protocol.MainEngineInstance().Storage.Settings().LatestCommitment().Commitment().MustID(), }, }), + testsuite.WithSlotCreated(slotIndexBlock5), )) slotIndexBlock6 := latestParent.ID().Index() diff --git a/tools/evil-spammer/go.mod b/tools/evil-spammer/go.mod index 2cb632e8a..b73672a5c 100644 --- a/tools/evil-spammer/go.mod +++ b/tools/evil-spammer/go.mod @@ -17,7 +17,7 @@ require ( github.com/iotaledger/hive.go/runtime v0.0.0-20230926122307-d671b36a4a65 github.com/iotaledger/iota-core v0.0.0-00010101000000-000000000000 github.com/iotaledger/iota-core/tools/genesis-snapshot v0.0.0-00010101000000-000000000000 - github.com/iotaledger/iota.go/v4 v4.0.0-20230927105604-ea84bcb2c9d4 + github.com/iotaledger/iota.go/v4 v4.0.0-20230927142038-c44427859ad2 github.com/mr-tron/base58 v1.2.0 go.uber.org/atomic v1.11.0 ) diff --git a/tools/evil-spammer/go.sum b/tools/evil-spammer/go.sum index 308046bd3..523f2b796 100644 --- a/tools/evil-spammer/go.sum +++ b/tools/evil-spammer/go.sum @@ -195,8 +195,8 @@ github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20230926122307-d671b36 github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20230926122307-d671b36a4a65/go.mod h1:IJgaaxbgKCsNat18jlJJEAxCY2oVYR3F30B+M4vJ89I= github.com/iotaledger/hive.go/stringify v0.0.0-20230926122307-d671b36a4a65 h1:3OmUR8yYlCENhbosY99eM3bIJQJCiLijtebt+Q6sQEs= github.com/iotaledger/hive.go/stringify v0.0.0-20230926122307-d671b36a4a65/go.mod h1:FTo/UWzNYgnQ082GI9QVM9HFDERqf9rw9RivNpqrnTs= -github.com/iotaledger/iota.go/v4 v4.0.0-20230927105604-ea84bcb2c9d4 h1:ZKaBVOWDzsM+Iq46l73VYp+wfhp/BytplvCsDQbkgTA= -github.com/iotaledger/iota.go/v4 v4.0.0-20230927105604-ea84bcb2c9d4/go.mod h1:wR9xBbsofns9hFyRHFZ2bDYIb861qsfmQPVMBKcPvDo= +github.com/iotaledger/iota.go/v4 v4.0.0-20230927142038-c44427859ad2 h1:cJbjZis2WD9Iy86rrRkRG4a3RoCaEsJol4Rmv6PpwKA= +github.com/iotaledger/iota.go/v4 v4.0.0-20230927142038-c44427859ad2/go.mod h1:wR9xBbsofns9hFyRHFZ2bDYIb861qsfmQPVMBKcPvDo= 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/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= diff --git a/tools/gendoc/go.mod b/tools/gendoc/go.mod index 3576a12cc..15f731a5d 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-20230926122307-d671b36a4a65 // indirect github.com/iotaledger/inx-app v1.0.0-rc.3.0.20230927112840-e982cb6707c9 // indirect github.com/iotaledger/inx/go v1.0.0-rc.2.0.20230925152824-4bfa09b8c132 // indirect - github.com/iotaledger/iota.go/v4 v4.0.0-20230927105604-ea84bcb2c9d4 // indirect + github.com/iotaledger/iota.go/v4 v4.0.0-20230927142038-c44427859ad2 // indirect github.com/ipfs/boxo v0.10.0 // 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 85fff9722..21257cbb8 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.20230927112840-e982cb6707c9 h1:vRGNf github.com/iotaledger/inx-app v1.0.0-rc.3.0.20230927112840-e982cb6707c9/go.mod h1:KbmEuxbhax3fyVrxF4RjBD1/MWLFxHLNDFBnDYUzok4= github.com/iotaledger/inx/go v1.0.0-rc.2.0.20230925152824-4bfa09b8c132 h1:YHvgNY3/TRx84UxqizkFe7vVUxAMQB2DOuEL8wjHxpg= github.com/iotaledger/inx/go v1.0.0-rc.2.0.20230925152824-4bfa09b8c132/go.mod h1:DIFr5lt73HLIyn/Lg2jtzfakwhIT0mMZjMFFji3GXeI= -github.com/iotaledger/iota.go/v4 v4.0.0-20230927105604-ea84bcb2c9d4 h1:ZKaBVOWDzsM+Iq46l73VYp+wfhp/BytplvCsDQbkgTA= -github.com/iotaledger/iota.go/v4 v4.0.0-20230927105604-ea84bcb2c9d4/go.mod h1:wR9xBbsofns9hFyRHFZ2bDYIb861qsfmQPVMBKcPvDo= +github.com/iotaledger/iota.go/v4 v4.0.0-20230927142038-c44427859ad2 h1:cJbjZis2WD9Iy86rrRkRG4a3RoCaEsJol4Rmv6PpwKA= +github.com/iotaledger/iota.go/v4 v4.0.0-20230927142038-c44427859ad2/go.mod h1:wR9xBbsofns9hFyRHFZ2bDYIb861qsfmQPVMBKcPvDo= github.com/ipfs/boxo v0.10.0 h1:tdDAxq8jrsbRkYoF+5Rcqyeb91hgWe2hp7iLu7ORZLY= github.com/ipfs/boxo v0.10.0/go.mod h1:Fg+BnfxZ0RPzR0nOodzdIq3A7KgoWAOWsEIImrIQdBM= 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 754555de6..6dd1734b0 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-20230926122307-d671b36a4a65 github.com/iotaledger/hive.go/runtime v0.0.0-20230926122307-d671b36a4a65 github.com/iotaledger/iota-core v0.0.0-00010101000000-000000000000 - github.com/iotaledger/iota.go/v4 v4.0.0-20230927105604-ea84bcb2c9d4 + github.com/iotaledger/iota.go/v4 v4.0.0-20230927142038-c44427859ad2 github.com/mr-tron/base58 v1.2.0 github.com/spf13/pflag v1.0.5 golang.org/x/crypto v0.13.0 diff --git a/tools/genesis-snapshot/go.sum b/tools/genesis-snapshot/go.sum index 6594b2d2d..a42c93523 100644 --- a/tools/genesis-snapshot/go.sum +++ b/tools/genesis-snapshot/go.sum @@ -50,8 +50,8 @@ github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20230926122307-d671b36 github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20230926122307-d671b36a4a65/go.mod h1:IJgaaxbgKCsNat18jlJJEAxCY2oVYR3F30B+M4vJ89I= github.com/iotaledger/hive.go/stringify v0.0.0-20230926122307-d671b36a4a65 h1:3OmUR8yYlCENhbosY99eM3bIJQJCiLijtebt+Q6sQEs= github.com/iotaledger/hive.go/stringify v0.0.0-20230926122307-d671b36a4a65/go.mod h1:FTo/UWzNYgnQ082GI9QVM9HFDERqf9rw9RivNpqrnTs= -github.com/iotaledger/iota.go/v4 v4.0.0-20230927105604-ea84bcb2c9d4 h1:ZKaBVOWDzsM+Iq46l73VYp+wfhp/BytplvCsDQbkgTA= -github.com/iotaledger/iota.go/v4 v4.0.0-20230927105604-ea84bcb2c9d4/go.mod h1:wR9xBbsofns9hFyRHFZ2bDYIb861qsfmQPVMBKcPvDo= +github.com/iotaledger/iota.go/v4 v4.0.0-20230927142038-c44427859ad2 h1:cJbjZis2WD9Iy86rrRkRG4a3RoCaEsJol4Rmv6PpwKA= +github.com/iotaledger/iota.go/v4 v4.0.0-20230927142038-c44427859ad2/go.mod h1:wR9xBbsofns9hFyRHFZ2bDYIb861qsfmQPVMBKcPvDo= 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 524a367f95ebef474d845c70bb66535fb0819ac5 Mon Sep 17 00:00:00 2001 From: Andrew Date: Wed, 27 Sep 2023 18:27:27 +0200 Subject: [PATCH 16/24] fix accounts test --- pkg/tests/accounts_test.go | 13 ++++++++++--- pkg/testsuite/transactions_framework.go | 1 + 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/pkg/tests/accounts_test.go b/pkg/tests/accounts_test.go index 5043daf2b..d769b7877 100644 --- a/pkg/tests/accounts_test.go +++ b/pkg/tests/accounts_test.go @@ -1,6 +1,7 @@ package tests import ( + "fmt" "testing" "github.com/iotaledger/hive.go/lo" @@ -343,14 +344,18 @@ func Test_TransitionAccount(t *testing.T) { }), ) + fmt.Printf("inputForImplicitAccountTransition: %+v\n", inputForImplicitAccountTransition.ToOutputSet()) tx6 := lo.PanicOnErr(ts.TransactionFramework.CreateTransactionWithOptions("TX6", fullAccountWallet, - testsuite.WithInputs(inputForImplicitAccountTransition), - testsuite.WithOutputs(outputsForImplicitAccountTransition), testsuite.WithContextInputs(iotago.TxEssenceContextInputs{ + &iotago.BlockIssuanceCreditInput{ + AccountID: implicitAccountID, + }, &iotago.CommitmentInput{ CommitmentID: node1.Protocol.MainEngineInstance().Storage.Settings().LatestCommitment().Commitment().MustID(), }, }), + testsuite.WithInputs(inputForImplicitAccountTransition), + testsuite.WithOutputs(outputsForImplicitAccountTransition), testsuite.WithSlotCreated(slotIndexBlock5), )) @@ -367,6 +372,8 @@ func Test_TransitionAccount(t *testing.T) { PreviousUpdatedTime: 0, NewOutputID: fullAccountOutputID, PreviousOutputID: implicitAccountOutputID, + PreviousExpirySlot: iotago.MaxSlotIndex, + NewExpirySlot: iotago.MaxSlotIndex, BlockIssuerKeysAdded: iotago.BlockIssuerKeys{fullAccountBlockIssuerKey}, BlockIssuerKeysRemoved: iotago.BlockIssuerKeys{implicitBlockIssuerKey}, ValidatorStakeChange: 0, @@ -377,7 +384,7 @@ func Test_TransitionAccount(t *testing.T) { ts.AssertAccountData(&accounts.AccountData{ ID: implicitAccountID, - Credits: accounts.NewBlockIssuanceCredits(0, slotIndexBlock6), + Credits: accounts.NewBlockIssuanceCredits(0, slotIndexBlock5), ExpirySlot: iotago.MaxSlotIndex, OutputID: fullAccountOutputID, BlockIssuerKeys: iotago.NewBlockIssuerKeys(fullAccountBlockIssuerKey), diff --git a/pkg/testsuite/transactions_framework.go b/pkg/testsuite/transactions_framework.go index 5a5fd7102..e5d928435 100644 --- a/pkg/testsuite/transactions_framework.go +++ b/pkg/testsuite/transactions_framework.go @@ -344,6 +344,7 @@ func (t *TransactionFramework) TransitionImplicitAccountToAccountOutput(alias st Amount: input.BaseTokenAmount(), Mana: input.StoredMana(), AccountID: iotago.AccountIDFromOutputID(input.OutputID()), + StateIndex: 1, NativeTokens: iotago.NativeTokens{}, Conditions: iotago.AccountOutputUnlockConditions{ &iotago.StateControllerAddressUnlockCondition{Address: t.DefaultAddress()}, From fb6af98582aeed417e224a962a7d0a3ce929dd6f Mon Sep 17 00:00:00 2001 From: Andrew Date: Wed, 27 Sep 2023 18:28:36 +0200 Subject: [PATCH 17/24] remove print from accounts test --- pkg/tests/accounts_test.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/pkg/tests/accounts_test.go b/pkg/tests/accounts_test.go index d769b7877..b2d8ae87f 100644 --- a/pkg/tests/accounts_test.go +++ b/pkg/tests/accounts_test.go @@ -1,7 +1,6 @@ package tests import ( - "fmt" "testing" "github.com/iotaledger/hive.go/lo" @@ -344,7 +343,6 @@ func Test_TransitionAccount(t *testing.T) { }), ) - fmt.Printf("inputForImplicitAccountTransition: %+v\n", inputForImplicitAccountTransition.ToOutputSet()) tx6 := lo.PanicOnErr(ts.TransactionFramework.CreateTransactionWithOptions("TX6", fullAccountWallet, testsuite.WithContextInputs(iotago.TxEssenceContextInputs{ &iotago.BlockIssuanceCreditInput{ From 0242a840077eea5e164cfaaa686e03ab7698c164 Mon Sep 17 00:00:00 2001 From: Andrew Date: Wed, 27 Sep 2023 18:31:00 +0200 Subject: [PATCH 18/24] go mod tidy --- go.mod | 2 +- go.sum | 4 ++-- tools/evil-spammer/go.mod | 2 +- tools/evil-spammer/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 ++-- 8 files changed, 12 insertions(+), 12 deletions(-) diff --git a/go.mod b/go.mod index 2b6d0d72e..60bd1bca5 100644 --- a/go.mod +++ b/go.mod @@ -26,7 +26,7 @@ require ( github.com/iotaledger/hive.go/stringify v0.0.0-20230926122307-d671b36a4a65 github.com/iotaledger/inx-app v1.0.0-rc.3.0.20230927112840-e982cb6707c9 github.com/iotaledger/inx/go v1.0.0-rc.2.0.20230925152824-4bfa09b8c132 - github.com/iotaledger/iota.go/v4 v4.0.0-20230927142038-c44427859ad2 + github.com/iotaledger/iota.go/v4 v4.0.0-20230927162933-5be644777e14 github.com/labstack/echo/v4 v4.11.1 github.com/labstack/gommon v0.4.0 github.com/libp2p/go-libp2p v0.30.0 diff --git a/go.sum b/go.sum index 841a6e701..56c0f1fed 100644 --- a/go.sum +++ b/go.sum @@ -305,8 +305,8 @@ github.com/iotaledger/inx-app v1.0.0-rc.3.0.20230927112840-e982cb6707c9 h1:vRGNf github.com/iotaledger/inx-app v1.0.0-rc.3.0.20230927112840-e982cb6707c9/go.mod h1:KbmEuxbhax3fyVrxF4RjBD1/MWLFxHLNDFBnDYUzok4= github.com/iotaledger/inx/go v1.0.0-rc.2.0.20230925152824-4bfa09b8c132 h1:YHvgNY3/TRx84UxqizkFe7vVUxAMQB2DOuEL8wjHxpg= github.com/iotaledger/inx/go v1.0.0-rc.2.0.20230925152824-4bfa09b8c132/go.mod h1:DIFr5lt73HLIyn/Lg2jtzfakwhIT0mMZjMFFji3GXeI= -github.com/iotaledger/iota.go/v4 v4.0.0-20230927142038-c44427859ad2 h1:cJbjZis2WD9Iy86rrRkRG4a3RoCaEsJol4Rmv6PpwKA= -github.com/iotaledger/iota.go/v4 v4.0.0-20230927142038-c44427859ad2/go.mod h1:wR9xBbsofns9hFyRHFZ2bDYIb861qsfmQPVMBKcPvDo= +github.com/iotaledger/iota.go/v4 v4.0.0-20230927162933-5be644777e14 h1:lswEq/4v+zkd/fITPiqrQ1vVpgaq2dRpUABAcZhft14= +github.com/iotaledger/iota.go/v4 v4.0.0-20230927162933-5be644777e14/go.mod h1:wR9xBbsofns9hFyRHFZ2bDYIb861qsfmQPVMBKcPvDo= github.com/ipfs/boxo v0.10.0 h1:tdDAxq8jrsbRkYoF+5Rcqyeb91hgWe2hp7iLu7ORZLY= github.com/ipfs/boxo v0.10.0/go.mod h1:Fg+BnfxZ0RPzR0nOodzdIq3A7KgoWAOWsEIImrIQdBM= github.com/ipfs/go-cid v0.4.1 h1:A/T3qGvxi4kpKWWcPC/PgbvDA2bjVLO7n4UeVwnbs/s= diff --git a/tools/evil-spammer/go.mod b/tools/evil-spammer/go.mod index b73672a5c..93f7c5f02 100644 --- a/tools/evil-spammer/go.mod +++ b/tools/evil-spammer/go.mod @@ -17,7 +17,7 @@ require ( github.com/iotaledger/hive.go/runtime v0.0.0-20230926122307-d671b36a4a65 github.com/iotaledger/iota-core v0.0.0-00010101000000-000000000000 github.com/iotaledger/iota-core/tools/genesis-snapshot v0.0.0-00010101000000-000000000000 - github.com/iotaledger/iota.go/v4 v4.0.0-20230927142038-c44427859ad2 + github.com/iotaledger/iota.go/v4 v4.0.0-20230927162933-5be644777e14 github.com/mr-tron/base58 v1.2.0 go.uber.org/atomic v1.11.0 ) diff --git a/tools/evil-spammer/go.sum b/tools/evil-spammer/go.sum index 523f2b796..5b278eaf9 100644 --- a/tools/evil-spammer/go.sum +++ b/tools/evil-spammer/go.sum @@ -195,8 +195,8 @@ github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20230926122307-d671b36 github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20230926122307-d671b36a4a65/go.mod h1:IJgaaxbgKCsNat18jlJJEAxCY2oVYR3F30B+M4vJ89I= github.com/iotaledger/hive.go/stringify v0.0.0-20230926122307-d671b36a4a65 h1:3OmUR8yYlCENhbosY99eM3bIJQJCiLijtebt+Q6sQEs= github.com/iotaledger/hive.go/stringify v0.0.0-20230926122307-d671b36a4a65/go.mod h1:FTo/UWzNYgnQ082GI9QVM9HFDERqf9rw9RivNpqrnTs= -github.com/iotaledger/iota.go/v4 v4.0.0-20230927142038-c44427859ad2 h1:cJbjZis2WD9Iy86rrRkRG4a3RoCaEsJol4Rmv6PpwKA= -github.com/iotaledger/iota.go/v4 v4.0.0-20230927142038-c44427859ad2/go.mod h1:wR9xBbsofns9hFyRHFZ2bDYIb861qsfmQPVMBKcPvDo= +github.com/iotaledger/iota.go/v4 v4.0.0-20230927162933-5be644777e14 h1:lswEq/4v+zkd/fITPiqrQ1vVpgaq2dRpUABAcZhft14= +github.com/iotaledger/iota.go/v4 v4.0.0-20230927162933-5be644777e14/go.mod h1:wR9xBbsofns9hFyRHFZ2bDYIb861qsfmQPVMBKcPvDo= 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/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= diff --git a/tools/gendoc/go.mod b/tools/gendoc/go.mod index 15f731a5d..986884cbc 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-20230926122307-d671b36a4a65 // indirect github.com/iotaledger/inx-app v1.0.0-rc.3.0.20230927112840-e982cb6707c9 // indirect github.com/iotaledger/inx/go v1.0.0-rc.2.0.20230925152824-4bfa09b8c132 // indirect - github.com/iotaledger/iota.go/v4 v4.0.0-20230927142038-c44427859ad2 // indirect + github.com/iotaledger/iota.go/v4 v4.0.0-20230927162933-5be644777e14 // indirect github.com/ipfs/boxo v0.10.0 // 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 21257cbb8..021535ebf 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.20230927112840-e982cb6707c9 h1:vRGNf github.com/iotaledger/inx-app v1.0.0-rc.3.0.20230927112840-e982cb6707c9/go.mod h1:KbmEuxbhax3fyVrxF4RjBD1/MWLFxHLNDFBnDYUzok4= github.com/iotaledger/inx/go v1.0.0-rc.2.0.20230925152824-4bfa09b8c132 h1:YHvgNY3/TRx84UxqizkFe7vVUxAMQB2DOuEL8wjHxpg= github.com/iotaledger/inx/go v1.0.0-rc.2.0.20230925152824-4bfa09b8c132/go.mod h1:DIFr5lt73HLIyn/Lg2jtzfakwhIT0mMZjMFFji3GXeI= -github.com/iotaledger/iota.go/v4 v4.0.0-20230927142038-c44427859ad2 h1:cJbjZis2WD9Iy86rrRkRG4a3RoCaEsJol4Rmv6PpwKA= -github.com/iotaledger/iota.go/v4 v4.0.0-20230927142038-c44427859ad2/go.mod h1:wR9xBbsofns9hFyRHFZ2bDYIb861qsfmQPVMBKcPvDo= +github.com/iotaledger/iota.go/v4 v4.0.0-20230927162933-5be644777e14 h1:lswEq/4v+zkd/fITPiqrQ1vVpgaq2dRpUABAcZhft14= +github.com/iotaledger/iota.go/v4 v4.0.0-20230927162933-5be644777e14/go.mod h1:wR9xBbsofns9hFyRHFZ2bDYIb861qsfmQPVMBKcPvDo= github.com/ipfs/boxo v0.10.0 h1:tdDAxq8jrsbRkYoF+5Rcqyeb91hgWe2hp7iLu7ORZLY= github.com/ipfs/boxo v0.10.0/go.mod h1:Fg+BnfxZ0RPzR0nOodzdIq3A7KgoWAOWsEIImrIQdBM= 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 6dd1734b0..6b6786695 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-20230926122307-d671b36a4a65 github.com/iotaledger/hive.go/runtime v0.0.0-20230926122307-d671b36a4a65 github.com/iotaledger/iota-core v0.0.0-00010101000000-000000000000 - github.com/iotaledger/iota.go/v4 v4.0.0-20230927142038-c44427859ad2 + github.com/iotaledger/iota.go/v4 v4.0.0-20230927162933-5be644777e14 github.com/mr-tron/base58 v1.2.0 github.com/spf13/pflag v1.0.5 golang.org/x/crypto v0.13.0 diff --git a/tools/genesis-snapshot/go.sum b/tools/genesis-snapshot/go.sum index a42c93523..8787e4055 100644 --- a/tools/genesis-snapshot/go.sum +++ b/tools/genesis-snapshot/go.sum @@ -50,8 +50,8 @@ github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20230926122307-d671b36 github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20230926122307-d671b36a4a65/go.mod h1:IJgaaxbgKCsNat18jlJJEAxCY2oVYR3F30B+M4vJ89I= github.com/iotaledger/hive.go/stringify v0.0.0-20230926122307-d671b36a4a65 h1:3OmUR8yYlCENhbosY99eM3bIJQJCiLijtebt+Q6sQEs= github.com/iotaledger/hive.go/stringify v0.0.0-20230926122307-d671b36a4a65/go.mod h1:FTo/UWzNYgnQ082GI9QVM9HFDERqf9rw9RivNpqrnTs= -github.com/iotaledger/iota.go/v4 v4.0.0-20230927142038-c44427859ad2 h1:cJbjZis2WD9Iy86rrRkRG4a3RoCaEsJol4Rmv6PpwKA= -github.com/iotaledger/iota.go/v4 v4.0.0-20230927142038-c44427859ad2/go.mod h1:wR9xBbsofns9hFyRHFZ2bDYIb861qsfmQPVMBKcPvDo= +github.com/iotaledger/iota.go/v4 v4.0.0-20230927162933-5be644777e14 h1:lswEq/4v+zkd/fITPiqrQ1vVpgaq2dRpUABAcZhft14= +github.com/iotaledger/iota.go/v4 v4.0.0-20230927162933-5be644777e14/go.mod h1:wR9xBbsofns9hFyRHFZ2bDYIb861qsfmQPVMBKcPvDo= 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 a27c9bc58cdf30d41c051b247e2f80abd99cbaa7 Mon Sep 17 00:00:00 2001 From: Andrew Date: Thu, 28 Sep 2023 12:06:38 +0200 Subject: [PATCH 19/24] state index implicit account = 0 --- pkg/testsuite/transactions_framework.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/testsuite/transactions_framework.go b/pkg/testsuite/transactions_framework.go index e5d928435..bc681b93a 100644 --- a/pkg/testsuite/transactions_framework.go +++ b/pkg/testsuite/transactions_framework.go @@ -344,7 +344,7 @@ func (t *TransactionFramework) TransitionImplicitAccountToAccountOutput(alias st Amount: input.BaseTokenAmount(), Mana: input.StoredMana(), AccountID: iotago.AccountIDFromOutputID(input.OutputID()), - StateIndex: 1, + StateIndex: 0, NativeTokens: iotago.NativeTokens{}, Conditions: iotago.AccountOutputUnlockConditions{ &iotago.StateControllerAddressUnlockCondition{Address: t.DefaultAddress()}, From a94acccf5b551268f386c64504a9a95a1fa9895a Mon Sep 17 00:00:00 2001 From: Andrew Date: Thu, 28 Sep 2023 12:09:02 +0200 Subject: [PATCH 20/24] go mod tidy --- go.mod | 2 +- go.sum | 4 ++-- tools/evil-spammer/go.mod | 2 +- tools/evil-spammer/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 ++-- 8 files changed, 12 insertions(+), 12 deletions(-) diff --git a/go.mod b/go.mod index 54d8af2af..0e5e4137f 100644 --- a/go.mod +++ b/go.mod @@ -26,7 +26,7 @@ require ( github.com/iotaledger/hive.go/stringify v0.0.0-20230926122307-d671b36a4a65 github.com/iotaledger/inx-app v1.0.0-rc.3.0.20230927140518-622f63be6182 github.com/iotaledger/inx/go v1.0.0-rc.2.0.20230927140257-bfa0bb0af2bd - github.com/iotaledger/iota.go/v4 v4.0.0-20230927125610-ddf51789ec4d + github.com/iotaledger/iota.go/v4 v4.0.0-20230928100216-5ab7cddca52a github.com/labstack/echo/v4 v4.11.1 github.com/labstack/gommon v0.4.0 github.com/libp2p/go-libp2p v0.30.0 diff --git a/go.sum b/go.sum index 53a194994..cb6195efc 100644 --- a/go.sum +++ b/go.sum @@ -305,8 +305,8 @@ github.com/iotaledger/inx-app v1.0.0-rc.3.0.20230927140518-622f63be6182 h1:lQikt github.com/iotaledger/inx-app v1.0.0-rc.3.0.20230927140518-622f63be6182/go.mod h1:q24QEsS887ZWJVX76w2kwSgC84KS7wIKOy1otuqZ2ZM= github.com/iotaledger/inx/go v1.0.0-rc.2.0.20230927140257-bfa0bb0af2bd h1:nFG3Zq/zFA4KhBYFX2IezX1C74zfE0DqCt0LrgTa9Ig= github.com/iotaledger/inx/go v1.0.0-rc.2.0.20230927140257-bfa0bb0af2bd/go.mod h1:c5778OnWpLq108YE+Eb2m8Ri/t/4ydV0TvI/Sy5YivQ= -github.com/iotaledger/iota.go/v4 v4.0.0-20230927125610-ddf51789ec4d h1:lhYbBhVORcS2LLNviaO/yTmom1suDskJLA1wSvvsLiU= -github.com/iotaledger/iota.go/v4 v4.0.0-20230927125610-ddf51789ec4d/go.mod h1:wR9xBbsofns9hFyRHFZ2bDYIb861qsfmQPVMBKcPvDo= +github.com/iotaledger/iota.go/v4 v4.0.0-20230928100216-5ab7cddca52a h1:UN62GL5huiGdOzXhjXIStehwEP7qg4C1Ye4daGx3nPE= +github.com/iotaledger/iota.go/v4 v4.0.0-20230928100216-5ab7cddca52a/go.mod h1:wR9xBbsofns9hFyRHFZ2bDYIb861qsfmQPVMBKcPvDo= github.com/ipfs/boxo v0.10.0 h1:tdDAxq8jrsbRkYoF+5Rcqyeb91hgWe2hp7iLu7ORZLY= github.com/ipfs/boxo v0.10.0/go.mod h1:Fg+BnfxZ0RPzR0nOodzdIq3A7KgoWAOWsEIImrIQdBM= github.com/ipfs/go-cid v0.4.1 h1:A/T3qGvxi4kpKWWcPC/PgbvDA2bjVLO7n4UeVwnbs/s= diff --git a/tools/evil-spammer/go.mod b/tools/evil-spammer/go.mod index 861cfb4a5..4d9e7e585 100644 --- a/tools/evil-spammer/go.mod +++ b/tools/evil-spammer/go.mod @@ -17,7 +17,7 @@ require ( github.com/iotaledger/hive.go/runtime v0.0.0-20230926122307-d671b36a4a65 github.com/iotaledger/iota-core v0.0.0-00010101000000-000000000000 github.com/iotaledger/iota-core/tools/genesis-snapshot v0.0.0-00010101000000-000000000000 - github.com/iotaledger/iota.go/v4 v4.0.0-20230927125610-ddf51789ec4d + github.com/iotaledger/iota.go/v4 v4.0.0-20230928100216-5ab7cddca52a github.com/mr-tron/base58 v1.2.0 go.uber.org/atomic v1.11.0 ) diff --git a/tools/evil-spammer/go.sum b/tools/evil-spammer/go.sum index 9138a9753..b0b1a87af 100644 --- a/tools/evil-spammer/go.sum +++ b/tools/evil-spammer/go.sum @@ -195,8 +195,8 @@ github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20230926122307-d671b36 github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20230926122307-d671b36a4a65/go.mod h1:IJgaaxbgKCsNat18jlJJEAxCY2oVYR3F30B+M4vJ89I= github.com/iotaledger/hive.go/stringify v0.0.0-20230926122307-d671b36a4a65 h1:3OmUR8yYlCENhbosY99eM3bIJQJCiLijtebt+Q6sQEs= github.com/iotaledger/hive.go/stringify v0.0.0-20230926122307-d671b36a4a65/go.mod h1:FTo/UWzNYgnQ082GI9QVM9HFDERqf9rw9RivNpqrnTs= -github.com/iotaledger/iota.go/v4 v4.0.0-20230927125610-ddf51789ec4d h1:lhYbBhVORcS2LLNviaO/yTmom1suDskJLA1wSvvsLiU= -github.com/iotaledger/iota.go/v4 v4.0.0-20230927125610-ddf51789ec4d/go.mod h1:wR9xBbsofns9hFyRHFZ2bDYIb861qsfmQPVMBKcPvDo= +github.com/iotaledger/iota.go/v4 v4.0.0-20230928100216-5ab7cddca52a h1:UN62GL5huiGdOzXhjXIStehwEP7qg4C1Ye4daGx3nPE= +github.com/iotaledger/iota.go/v4 v4.0.0-20230928100216-5ab7cddca52a/go.mod h1:wR9xBbsofns9hFyRHFZ2bDYIb861qsfmQPVMBKcPvDo= 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/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= diff --git a/tools/gendoc/go.mod b/tools/gendoc/go.mod index e67b05610..253ff6715 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-20230926122307-d671b36a4a65 // indirect github.com/iotaledger/inx-app v1.0.0-rc.3.0.20230927140518-622f63be6182 // indirect github.com/iotaledger/inx/go v1.0.0-rc.2.0.20230927140257-bfa0bb0af2bd // indirect - github.com/iotaledger/iota.go/v4 v4.0.0-20230927125610-ddf51789ec4d // indirect + github.com/iotaledger/iota.go/v4 v4.0.0-20230928100216-5ab7cddca52a // indirect github.com/ipfs/boxo v0.10.0 // 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 5edeea70e..44ed566ac 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.20230927140518-622f63be6182 h1:lQikt github.com/iotaledger/inx-app v1.0.0-rc.3.0.20230927140518-622f63be6182/go.mod h1:q24QEsS887ZWJVX76w2kwSgC84KS7wIKOy1otuqZ2ZM= github.com/iotaledger/inx/go v1.0.0-rc.2.0.20230927140257-bfa0bb0af2bd h1:nFG3Zq/zFA4KhBYFX2IezX1C74zfE0DqCt0LrgTa9Ig= github.com/iotaledger/inx/go v1.0.0-rc.2.0.20230927140257-bfa0bb0af2bd/go.mod h1:c5778OnWpLq108YE+Eb2m8Ri/t/4ydV0TvI/Sy5YivQ= -github.com/iotaledger/iota.go/v4 v4.0.0-20230927125610-ddf51789ec4d h1:lhYbBhVORcS2LLNviaO/yTmom1suDskJLA1wSvvsLiU= -github.com/iotaledger/iota.go/v4 v4.0.0-20230927125610-ddf51789ec4d/go.mod h1:wR9xBbsofns9hFyRHFZ2bDYIb861qsfmQPVMBKcPvDo= +github.com/iotaledger/iota.go/v4 v4.0.0-20230928100216-5ab7cddca52a h1:UN62GL5huiGdOzXhjXIStehwEP7qg4C1Ye4daGx3nPE= +github.com/iotaledger/iota.go/v4 v4.0.0-20230928100216-5ab7cddca52a/go.mod h1:wR9xBbsofns9hFyRHFZ2bDYIb861qsfmQPVMBKcPvDo= github.com/ipfs/boxo v0.10.0 h1:tdDAxq8jrsbRkYoF+5Rcqyeb91hgWe2hp7iLu7ORZLY= github.com/ipfs/boxo v0.10.0/go.mod h1:Fg+BnfxZ0RPzR0nOodzdIq3A7KgoWAOWsEIImrIQdBM= 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 b75541880..a991abd59 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-20230926122307-d671b36a4a65 github.com/iotaledger/hive.go/runtime v0.0.0-20230926122307-d671b36a4a65 github.com/iotaledger/iota-core v0.0.0-00010101000000-000000000000 - github.com/iotaledger/iota.go/v4 v4.0.0-20230927125610-ddf51789ec4d + github.com/iotaledger/iota.go/v4 v4.0.0-20230928100216-5ab7cddca52a github.com/mr-tron/base58 v1.2.0 github.com/spf13/pflag v1.0.5 golang.org/x/crypto v0.13.0 diff --git a/tools/genesis-snapshot/go.sum b/tools/genesis-snapshot/go.sum index 1b24bf02e..e0d81d325 100644 --- a/tools/genesis-snapshot/go.sum +++ b/tools/genesis-snapshot/go.sum @@ -50,8 +50,8 @@ github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20230926122307-d671b36 github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20230926122307-d671b36a4a65/go.mod h1:IJgaaxbgKCsNat18jlJJEAxCY2oVYR3F30B+M4vJ89I= github.com/iotaledger/hive.go/stringify v0.0.0-20230926122307-d671b36a4a65 h1:3OmUR8yYlCENhbosY99eM3bIJQJCiLijtebt+Q6sQEs= github.com/iotaledger/hive.go/stringify v0.0.0-20230926122307-d671b36a4a65/go.mod h1:FTo/UWzNYgnQ082GI9QVM9HFDERqf9rw9RivNpqrnTs= -github.com/iotaledger/iota.go/v4 v4.0.0-20230927125610-ddf51789ec4d h1:lhYbBhVORcS2LLNviaO/yTmom1suDskJLA1wSvvsLiU= -github.com/iotaledger/iota.go/v4 v4.0.0-20230927125610-ddf51789ec4d/go.mod h1:wR9xBbsofns9hFyRHFZ2bDYIb861qsfmQPVMBKcPvDo= +github.com/iotaledger/iota.go/v4 v4.0.0-20230928100216-5ab7cddca52a h1:UN62GL5huiGdOzXhjXIStehwEP7qg4C1Ye4daGx3nPE= +github.com/iotaledger/iota.go/v4 v4.0.0-20230928100216-5ab7cddca52a/go.mod h1:wR9xBbsofns9hFyRHFZ2bDYIb861qsfmQPVMBKcPvDo= 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 88eca770555dc7ed62392764205d27ebe561e3ce Mon Sep 17 00:00:00 2001 From: Andrew Date: Thu, 28 Sep 2023 12:15:28 +0200 Subject: [PATCH 21/24] merge errors --- pkg/protocol/engine/accounts/accounts.go | 2 +- pkg/tests/accounts_test.go | 8 ++++---- pkg/testsuite/transactions_framework.go | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pkg/protocol/engine/accounts/accounts.go b/pkg/protocol/engine/accounts/accounts.go index b9eca4ed6..403f569c0 100644 --- a/pkg/protocol/engine/accounts/accounts.go +++ b/pkg/protocol/engine/accounts/accounts.go @@ -141,7 +141,7 @@ func (a *AccountData) readFromReadSeeker(reader io.ReadSeeker) (int, error) { } bytesConsumed += bytesRead a.BlockIssuerKeys.Add(iotago.Ed25519PublicKeyBlockIssuerKeyFromPublicKey(ed25519PublicKey)) - case iotago.BlockIssuerKeyEd25519Address: + case iotago.BlockIssuerKeyPublicKeyHash: var implicitAccountCreationAddress iotago.ImplicitAccountCreationAddress bytesRead, err = io.ReadFull(reader, implicitAccountCreationAddress[:]) if err != nil { diff --git a/pkg/tests/accounts_test.go b/pkg/tests/accounts_test.go index 68cb43155..1a9d326db 100644 --- a/pkg/tests/accounts_test.go +++ b/pkg/tests/accounts_test.go @@ -329,10 +329,10 @@ func Test_TransitionAccount(t *testing.T) { inputForImplicitAccountTransition, outputsForImplicitAccountTransition, fullAccountWallet := ts.TransactionFramework.TransitionImplicitAccountToAccountOutput( "TX5:0", - testsuite.WithBlockIssuerFeature(&iotago.BlockIssuerFeature{ - BlockIssuerKeys: iotago.BlockIssuerKeys{fullAccountBlockIssuerKey}, - ExpirySlot: iotago.MaxSlotIndex, - }), + testsuite.WithBlockIssuerFeature( + iotago.BlockIssuerKeys{fullAccountBlockIssuerKey}, + iotago.MaxSlotIndex, + ), ) tx6 := lo.PanicOnErr(ts.TransactionFramework.CreateTransactionWithOptions("TX6", fullAccountWallet, diff --git a/pkg/testsuite/transactions_framework.go b/pkg/testsuite/transactions_framework.go index 37dcaaf01..9bbbbb053 100644 --- a/pkg/testsuite/transactions_framework.go +++ b/pkg/testsuite/transactions_framework.go @@ -313,7 +313,7 @@ func (t *TransactionFramework) TransitionAccount(alias string, opts ...options.O return output, iotago.Outputs[iotago.Output]{accountOutput}, []*mock.HDWallet{t.wallet} } -func (t *TransactionFramework) TransitionImplicitAccountToAccountOutput(alias string, opts ...options.Option[iotago.AccountOutput]) (consumedInput utxoledger.Outputs, outputs iotago.Outputs[iotago.Output], signingWallets []*mock.HDWallet) { +func (t *TransactionFramework) TransitionImplicitAccountToAccountOutput(alias string, opts ...options.Option[builder.AccountOutputBuilder]) (consumedInput utxoledger.Outputs, outputs iotago.Outputs[iotago.Output], signingWallets []*mock.HDWallet) { input, exists := t.states[alias] if !exists { panic(fmt.Sprintf("output with alias %s does not exist", alias)) From 51eccbc6009819db09e35bc5397787bc09f20628 Mon Sep 17 00:00:00 2001 From: Andrew Date: Thu, 28 Sep 2023 12:36:11 +0200 Subject: [PATCH 22/24] use new account builder --- go.mod | 2 +- go.sum | 4 ++-- pkg/testsuite/transactions_framework.go | 17 ++++------------- tools/evil-spammer/go.mod | 2 +- tools/evil-spammer/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 ++-- 9 files changed, 16 insertions(+), 25 deletions(-) diff --git a/go.mod b/go.mod index 0e5e4137f..472f2bdd9 100644 --- a/go.mod +++ b/go.mod @@ -26,7 +26,7 @@ require ( github.com/iotaledger/hive.go/stringify v0.0.0-20230926122307-d671b36a4a65 github.com/iotaledger/inx-app v1.0.0-rc.3.0.20230927140518-622f63be6182 github.com/iotaledger/inx/go v1.0.0-rc.2.0.20230927140257-bfa0bb0af2bd - github.com/iotaledger/iota.go/v4 v4.0.0-20230928100216-5ab7cddca52a + github.com/iotaledger/iota.go/v4 v4.0.0-20230928103002-093e56bf1b19 github.com/labstack/echo/v4 v4.11.1 github.com/labstack/gommon v0.4.0 github.com/libp2p/go-libp2p v0.30.0 diff --git a/go.sum b/go.sum index cb6195efc..e64c0fb9a 100644 --- a/go.sum +++ b/go.sum @@ -305,8 +305,8 @@ github.com/iotaledger/inx-app v1.0.0-rc.3.0.20230927140518-622f63be6182 h1:lQikt github.com/iotaledger/inx-app v1.0.0-rc.3.0.20230927140518-622f63be6182/go.mod h1:q24QEsS887ZWJVX76w2kwSgC84KS7wIKOy1otuqZ2ZM= github.com/iotaledger/inx/go v1.0.0-rc.2.0.20230927140257-bfa0bb0af2bd h1:nFG3Zq/zFA4KhBYFX2IezX1C74zfE0DqCt0LrgTa9Ig= github.com/iotaledger/inx/go v1.0.0-rc.2.0.20230927140257-bfa0bb0af2bd/go.mod h1:c5778OnWpLq108YE+Eb2m8Ri/t/4ydV0TvI/Sy5YivQ= -github.com/iotaledger/iota.go/v4 v4.0.0-20230928100216-5ab7cddca52a h1:UN62GL5huiGdOzXhjXIStehwEP7qg4C1Ye4daGx3nPE= -github.com/iotaledger/iota.go/v4 v4.0.0-20230928100216-5ab7cddca52a/go.mod h1:wR9xBbsofns9hFyRHFZ2bDYIb861qsfmQPVMBKcPvDo= +github.com/iotaledger/iota.go/v4 v4.0.0-20230928103002-093e56bf1b19 h1:4vN+jZJECvlfP0Bam8tonH9ndFBJoi8G0nMb4m1kpKk= +github.com/iotaledger/iota.go/v4 v4.0.0-20230928103002-093e56bf1b19/go.mod h1:wR9xBbsofns9hFyRHFZ2bDYIb861qsfmQPVMBKcPvDo= github.com/ipfs/boxo v0.10.0 h1:tdDAxq8jrsbRkYoF+5Rcqyeb91hgWe2hp7iLu7ORZLY= github.com/ipfs/boxo v0.10.0/go.mod h1:Fg+BnfxZ0RPzR0nOodzdIq3A7KgoWAOWsEIImrIQdBM= github.com/ipfs/go-cid v0.4.1 h1:A/T3qGvxi4kpKWWcPC/PgbvDA2bjVLO7n4UeVwnbs/s= diff --git a/pkg/testsuite/transactions_framework.go b/pkg/testsuite/transactions_framework.go index 9bbbbb053..00d4c66ac 100644 --- a/pkg/testsuite/transactions_framework.go +++ b/pkg/testsuite/transactions_framework.go @@ -327,19 +327,10 @@ func (t *TransactionFramework) TransitionImplicitAccountToAccountOutput(alias st panic(fmt.Sprintf("output with alias %s is not an implicit account", alias)) } - accountOutput := options.Apply(&iotago.AccountOutput{ - Amount: input.BaseTokenAmount(), - Mana: input.StoredMana(), - AccountID: iotago.AccountIDFromOutputID(input.OutputID()), - StateIndex: 0, - NativeTokens: iotago.NativeTokens{}, - Conditions: iotago.AccountOutputUnlockConditions{ - &iotago.StateControllerAddressUnlockCondition{Address: t.DefaultAddress()}, - &iotago.GovernorAddressUnlockCondition{Address: t.DefaultAddress()}, - }, - Features: iotago.AccountOutputFeatures{}, - ImmutableFeatures: iotago.AccountOutputImmFeatures{}, - }, opts) + accountOutput := options.Apply(builder.NewAccountOutputBuilder(t.DefaultAddress(), t.DefaultAddress(), input.BaseTokenAmount()). + Mana(input.StoredMana()). + AccountID(iotago.AccountIDFromOutputID(input.OutputID())), + opts).MustBuild() return utxoledger.Outputs{input}, iotago.Outputs[iotago.Output]{accountOutput}, []*mock.HDWallet{t.wallet} } diff --git a/tools/evil-spammer/go.mod b/tools/evil-spammer/go.mod index 4d9e7e585..b9e5473d1 100644 --- a/tools/evil-spammer/go.mod +++ b/tools/evil-spammer/go.mod @@ -17,7 +17,7 @@ require ( github.com/iotaledger/hive.go/runtime v0.0.0-20230926122307-d671b36a4a65 github.com/iotaledger/iota-core v0.0.0-00010101000000-000000000000 github.com/iotaledger/iota-core/tools/genesis-snapshot v0.0.0-00010101000000-000000000000 - github.com/iotaledger/iota.go/v4 v4.0.0-20230928100216-5ab7cddca52a + github.com/iotaledger/iota.go/v4 v4.0.0-20230928103002-093e56bf1b19 github.com/mr-tron/base58 v1.2.0 go.uber.org/atomic v1.11.0 ) diff --git a/tools/evil-spammer/go.sum b/tools/evil-spammer/go.sum index b0b1a87af..c21f83a62 100644 --- a/tools/evil-spammer/go.sum +++ b/tools/evil-spammer/go.sum @@ -195,8 +195,8 @@ github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20230926122307-d671b36 github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20230926122307-d671b36a4a65/go.mod h1:IJgaaxbgKCsNat18jlJJEAxCY2oVYR3F30B+M4vJ89I= github.com/iotaledger/hive.go/stringify v0.0.0-20230926122307-d671b36a4a65 h1:3OmUR8yYlCENhbosY99eM3bIJQJCiLijtebt+Q6sQEs= github.com/iotaledger/hive.go/stringify v0.0.0-20230926122307-d671b36a4a65/go.mod h1:FTo/UWzNYgnQ082GI9QVM9HFDERqf9rw9RivNpqrnTs= -github.com/iotaledger/iota.go/v4 v4.0.0-20230928100216-5ab7cddca52a h1:UN62GL5huiGdOzXhjXIStehwEP7qg4C1Ye4daGx3nPE= -github.com/iotaledger/iota.go/v4 v4.0.0-20230928100216-5ab7cddca52a/go.mod h1:wR9xBbsofns9hFyRHFZ2bDYIb861qsfmQPVMBKcPvDo= +github.com/iotaledger/iota.go/v4 v4.0.0-20230928103002-093e56bf1b19 h1:4vN+jZJECvlfP0Bam8tonH9ndFBJoi8G0nMb4m1kpKk= +github.com/iotaledger/iota.go/v4 v4.0.0-20230928103002-093e56bf1b19/go.mod h1:wR9xBbsofns9hFyRHFZ2bDYIb861qsfmQPVMBKcPvDo= 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/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= diff --git a/tools/gendoc/go.mod b/tools/gendoc/go.mod index 253ff6715..ae1c79100 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-20230926122307-d671b36a4a65 // indirect github.com/iotaledger/inx-app v1.0.0-rc.3.0.20230927140518-622f63be6182 // indirect github.com/iotaledger/inx/go v1.0.0-rc.2.0.20230927140257-bfa0bb0af2bd // indirect - github.com/iotaledger/iota.go/v4 v4.0.0-20230928100216-5ab7cddca52a // indirect + github.com/iotaledger/iota.go/v4 v4.0.0-20230928103002-093e56bf1b19 // indirect github.com/ipfs/boxo v0.10.0 // 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 44ed566ac..9c689ecab 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.20230927140518-622f63be6182 h1:lQikt github.com/iotaledger/inx-app v1.0.0-rc.3.0.20230927140518-622f63be6182/go.mod h1:q24QEsS887ZWJVX76w2kwSgC84KS7wIKOy1otuqZ2ZM= github.com/iotaledger/inx/go v1.0.0-rc.2.0.20230927140257-bfa0bb0af2bd h1:nFG3Zq/zFA4KhBYFX2IezX1C74zfE0DqCt0LrgTa9Ig= github.com/iotaledger/inx/go v1.0.0-rc.2.0.20230927140257-bfa0bb0af2bd/go.mod h1:c5778OnWpLq108YE+Eb2m8Ri/t/4ydV0TvI/Sy5YivQ= -github.com/iotaledger/iota.go/v4 v4.0.0-20230928100216-5ab7cddca52a h1:UN62GL5huiGdOzXhjXIStehwEP7qg4C1Ye4daGx3nPE= -github.com/iotaledger/iota.go/v4 v4.0.0-20230928100216-5ab7cddca52a/go.mod h1:wR9xBbsofns9hFyRHFZ2bDYIb861qsfmQPVMBKcPvDo= +github.com/iotaledger/iota.go/v4 v4.0.0-20230928103002-093e56bf1b19 h1:4vN+jZJECvlfP0Bam8tonH9ndFBJoi8G0nMb4m1kpKk= +github.com/iotaledger/iota.go/v4 v4.0.0-20230928103002-093e56bf1b19/go.mod h1:wR9xBbsofns9hFyRHFZ2bDYIb861qsfmQPVMBKcPvDo= github.com/ipfs/boxo v0.10.0 h1:tdDAxq8jrsbRkYoF+5Rcqyeb91hgWe2hp7iLu7ORZLY= github.com/ipfs/boxo v0.10.0/go.mod h1:Fg+BnfxZ0RPzR0nOodzdIq3A7KgoWAOWsEIImrIQdBM= 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 a991abd59..efd34f5ac 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-20230926122307-d671b36a4a65 github.com/iotaledger/hive.go/runtime v0.0.0-20230926122307-d671b36a4a65 github.com/iotaledger/iota-core v0.0.0-00010101000000-000000000000 - github.com/iotaledger/iota.go/v4 v4.0.0-20230928100216-5ab7cddca52a + github.com/iotaledger/iota.go/v4 v4.0.0-20230928103002-093e56bf1b19 github.com/mr-tron/base58 v1.2.0 github.com/spf13/pflag v1.0.5 golang.org/x/crypto v0.13.0 diff --git a/tools/genesis-snapshot/go.sum b/tools/genesis-snapshot/go.sum index e0d81d325..7e21bba5c 100644 --- a/tools/genesis-snapshot/go.sum +++ b/tools/genesis-snapshot/go.sum @@ -50,8 +50,8 @@ github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20230926122307-d671b36 github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20230926122307-d671b36a4a65/go.mod h1:IJgaaxbgKCsNat18jlJJEAxCY2oVYR3F30B+M4vJ89I= github.com/iotaledger/hive.go/stringify v0.0.0-20230926122307-d671b36a4a65 h1:3OmUR8yYlCENhbosY99eM3bIJQJCiLijtebt+Q6sQEs= github.com/iotaledger/hive.go/stringify v0.0.0-20230926122307-d671b36a4a65/go.mod h1:FTo/UWzNYgnQ082GI9QVM9HFDERqf9rw9RivNpqrnTs= -github.com/iotaledger/iota.go/v4 v4.0.0-20230928100216-5ab7cddca52a h1:UN62GL5huiGdOzXhjXIStehwEP7qg4C1Ye4daGx3nPE= -github.com/iotaledger/iota.go/v4 v4.0.0-20230928100216-5ab7cddca52a/go.mod h1:wR9xBbsofns9hFyRHFZ2bDYIb861qsfmQPVMBKcPvDo= +github.com/iotaledger/iota.go/v4 v4.0.0-20230928103002-093e56bf1b19 h1:4vN+jZJECvlfP0Bam8tonH9ndFBJoi8G0nMb4m1kpKk= +github.com/iotaledger/iota.go/v4 v4.0.0-20230928103002-093e56bf1b19/go.mod h1:wR9xBbsofns9hFyRHFZ2bDYIb861qsfmQPVMBKcPvDo= 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 6dab42ac667638132044f26059234b0ded3bfd90 Mon Sep 17 00:00:00 2001 From: Philipp Gackstatter Date: Thu, 28 Sep 2023 12:51:45 +0200 Subject: [PATCH 23/24] Remove stray fmt printf --- pkg/protocol/engine/ledger/ledger/ledger.go | 1 - 1 file changed, 1 deletion(-) diff --git a/pkg/protocol/engine/ledger/ledger/ledger.go b/pkg/protocol/engine/ledger/ledger/ledger.go index a7673315b..c5a847b37 100644 --- a/pkg/protocol/engine/ledger/ledger/ledger.go +++ b/pkg/protocol/engine/ledger/ledger/ledger.go @@ -466,7 +466,6 @@ func (l *Ledger) prepareAccountDiffs(accountDiffs map[iotago.AccountID]*model.Ac accountDiff.BlockIssuerKeysAdded = iotago.NewBlockIssuerKeys(iotago.Ed25519PublicKeyHashBlockIssuerKeyFromImplicitAccountCreationAddress(address)) accountDiff.NewExpirySlot = iotago.MaxSlotIndex } - fmt.Printf("account diff for %s: %+v\n", createdAccountID, accountDiff) } } From e51ea10b10134600f142cf17d6540c8523d51bb7 Mon Sep 17 00:00:00 2001 From: Philipp Gackstatter Date: Thu, 28 Sep 2023 12:55:30 +0200 Subject: [PATCH 24/24] Remove fmt import --- pkg/protocol/engine/ledger/ledger/ledger.go | 1 - 1 file changed, 1 deletion(-) diff --git a/pkg/protocol/engine/ledger/ledger/ledger.go b/pkg/protocol/engine/ledger/ledger/ledger.go index c5a847b37..ba17893d4 100644 --- a/pkg/protocol/engine/ledger/ledger/ledger.go +++ b/pkg/protocol/engine/ledger/ledger/ledger.go @@ -1,7 +1,6 @@ package ledger import ( - "fmt" "io" "github.com/iotaledger/hive.go/core/safemath"