From 6e391c7fd5cb4b017b939d9ce2ff60b51103deff Mon Sep 17 00:00:00 2001 From: Philipp Gackstatter Date: Tue, 12 Mar 2024 14:04:03 +0800 Subject: [PATCH 1/4] Fix changes from iota.go updates --- pkg/network/protocols/core/protocol.go | 6 +++--- pkg/protocol/engine/ledger/ledger/ledger.go | 8 ++------ pkg/protocol/engine/ledger/ledger/vm.go | 6 +----- 3 files changed, 6 insertions(+), 14 deletions(-) diff --git a/pkg/network/protocols/core/protocol.go b/pkg/network/protocols/core/protocol.go index 6be570113..7f49e88b6 100644 --- a/pkg/network/protocols/core/protocol.go +++ b/pkg/network/protocols/core/protocol.go @@ -216,7 +216,7 @@ func (p *Protocol) onBlock(blockData []byte, id peer.ID) { func (p *Protocol) onBlockRequest(idBytes []byte, id peer.ID) { if len(idBytes) != iotago.BlockIDLength { - p.Events.Error.Trigger(ierrors.Wrap(iotago.ErrInvalidIdentifierLength, "failed to deserialize block request"), id) + p.Events.Error.Trigger(ierrors.Errorf("failed to deserialize block request: invalid block id length"), id) return } @@ -237,7 +237,7 @@ func (p *Protocol) onSlotCommitment(commitmentBytes []byte, id peer.ID) { func (p *Protocol) onSlotCommitmentRequest(idBytes []byte, id peer.ID) { if len(idBytes) != iotago.CommitmentIDLength { - p.Events.Error.Trigger(ierrors.Wrap(iotago.ErrInvalidIdentifierLength, "failed to deserialize slot commitment request"), id) + p.Events.Error.Trigger(ierrors.Errorf("failed to deserialize slot commitment request: invalid commitment id length"), id) return } @@ -294,7 +294,7 @@ func (p *Protocol) onAttestations(commitmentBytes []byte, attestationsBytes []by func (p *Protocol) onAttestationsRequest(commitmentIDBytes []byte, id peer.ID) { if len(commitmentIDBytes) != iotago.CommitmentIDLength { - p.Events.Error.Trigger(ierrors.Wrap(iotago.ErrInvalidIdentifierLength, "failed to deserialize commitmentID in attestations request"), id) + p.Events.Error.Trigger(ierrors.Errorf("failed to deserialize commitmentID in attestations request: invalid commitment id length"), id) return } diff --git a/pkg/protocol/engine/ledger/ledger/ledger.go b/pkg/protocol/engine/ledger/ledger/ledger.go index de2dc6aaa..22fc3b200 100644 --- a/pkg/protocol/engine/ledger/ledger/ledger.go +++ b/pkg/protocol/engine/ledger/ledger/ledger.go @@ -612,11 +612,7 @@ func (l *Ledger) processStateDiffTransactions(stateDiff mempool.StateDiff) (spen return false } - inputRefs, errInput := tx.Inputs() - if errInput != nil { - err = ierrors.Errorf("failed to retrieve inputs of %s: %w", txID, errInput) - return false - } + inputRefs := tx.Inputs() // process outputs { @@ -624,7 +620,7 @@ func (l *Ledger) processStateDiffTransactions(stateDiff mempool.StateDiff) (spen for _, inputRef := range lo.Map(inputRefs, mempool.UTXOInputStateRefFromInput) { stateWithMetadata, stateError := l.memPool.StateMetadata(inputRef) if stateError != nil { - err = ierrors.Errorf("failed to retrieve outputs of %s: %w", txID, errInput) + err = ierrors.Wrapf(stateError, "failed to retrieve outputs of %s", txID) return false } spent := utxoledger.NewSpent(l.outputFromState(stateWithMetadata.State()), txWithMeta.ID(), stateDiff.Slot()) diff --git a/pkg/protocol/engine/ledger/ledger/vm.go b/pkg/protocol/engine/ledger/ledger/vm.go index 6e3227b59..a26152e8e 100644 --- a/pkg/protocol/engine/ledger/ledger/vm.go +++ b/pkg/protocol/engine/ledger/ledger/vm.go @@ -65,11 +65,7 @@ func (v *VM) ValidateSignatures(signedTransaction mempool.SignedTransaction, res return nil, iotago.ErrTxTypeInvalid } - contextInputs, err := iotagoSignedTransaction.Transaction.ContextInputs() - if err != nil { - return nil, ierrors.Wrapf(err, "unable to retrieve context inputs from transaction") - } - + contextInputs := iotagoSignedTransaction.Transaction.ContextInputs() utxoInputSet := iotagovm.InputSet{} commitmentInput := (*iotago.Commitment)(nil) bicInputs := make([]*iotago.BlockIssuanceCreditInput, 0) From 80eb3f14ff733c6f21bc5b65e8ed075a4d752833 Mon Sep 17 00:00:00 2001 From: Philipp Gackstatter Date: Wed, 13 Mar 2024 17:33:23 +0800 Subject: [PATCH 2/4] Bum iota.go --- go.mod | 2 +- go.sum | 4 ++-- tools/gendoc/go.mod | 2 +- tools/gendoc/go.sum | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index e6015c7bd..34af69c59 100644 --- a/go.mod +++ b/go.mod @@ -28,7 +28,7 @@ require ( github.com/iotaledger/hive.go/stringify v0.0.0-20240307102857-7e23a3c59bd2 github.com/iotaledger/inx-app v1.0.0-rc.3.0.20240307101848-db58eb9353ec github.com/iotaledger/inx/go v1.0.0-rc.2.0.20240307100839-48553e1d2022 - github.com/iotaledger/iota.go/v4 v4.0.0-20240307175623-0904c71fcb38 + github.com/iotaledger/iota.go/v4 v4.0.0-20240313065735-74f8cf10c361 github.com/labstack/echo/v4 v4.11.4 github.com/labstack/gommon v0.4.2 github.com/libp2p/go-libp2p v0.33.0 diff --git a/go.sum b/go.sum index 1c366dc1c..7fab99c65 100644 --- a/go.sum +++ b/go.sum @@ -318,8 +318,8 @@ github.com/iotaledger/inx/go v1.0.0-rc.2.0.20240307100839-48553e1d2022 h1:I178Sa github.com/iotaledger/inx/go v1.0.0-rc.2.0.20240307100839-48553e1d2022/go.mod h1:jTFxIWiMUdAwO263jlJCSWcNLqEkgYEVOFXfjp5aNJM= github.com/iotaledger/iota-crypto-demo v0.0.0-20240216103559-27ca8dffd1e7 h1:t6k4MqiUov0FrBb2o2JhKlOVSdlPbIQWM8ivYHL0G0g= github.com/iotaledger/iota-crypto-demo v0.0.0-20240216103559-27ca8dffd1e7/go.mod h1:do+N3LpeDEi9qselEC4XcjqGoRc7cWGiqBtIeBOKEMs= -github.com/iotaledger/iota.go/v4 v4.0.0-20240307175623-0904c71fcb38 h1:NizJ3CALLCcJowtAtkNuDlpE4gd4qjaWZkp/kTZfeYk= -github.com/iotaledger/iota.go/v4 v4.0.0-20240307175623-0904c71fcb38/go.mod h1:8UQOTI7CC5R/3TurawUFuBZbkb37RzW8m4q8Hp7ct30= +github.com/iotaledger/iota.go/v4 v4.0.0-20240313065735-74f8cf10c361 h1:fKvfJZ4byivRRKkqF6JPj8I4pDSN0y+bgF4I4HI11Lo= +github.com/iotaledger/iota.go/v4 v4.0.0-20240313065735-74f8cf10c361/go.mod h1:8UQOTI7CC5R/3TurawUFuBZbkb37RzW8m4q8Hp7ct30= github.com/ipfs/boxo v0.18.0 h1:MOL9/AgoV3e7jlVMInicaSdbgralfqSsbkc31dZ9tmw= github.com/ipfs/boxo v0.18.0/go.mod h1:pIZgTWdm3k3pLF9Uq6MB8JEcW07UDwNJjlXW1HELW80= github.com/ipfs/go-cid v0.4.1 h1:A/T3qGvxi4kpKWWcPC/PgbvDA2bjVLO7n4UeVwnbs/s= diff --git a/tools/gendoc/go.mod b/tools/gendoc/go.mod index c18412a13..2ceae959d 100644 --- a/tools/gendoc/go.mod +++ b/tools/gendoc/go.mod @@ -73,7 +73,7 @@ require ( github.com/iotaledger/inx-app v1.0.0-rc.3.0.20240307101848-db58eb9353ec // indirect github.com/iotaledger/inx/go v1.0.0-rc.2.0.20240307100839-48553e1d2022 // indirect github.com/iotaledger/iota-crypto-demo v0.0.0-20240216103559-27ca8dffd1e7 // indirect - github.com/iotaledger/iota.go/v4 v4.0.0-20240307175623-0904c71fcb38 // indirect + github.com/iotaledger/iota.go/v4 v4.0.0-20240313065735-74f8cf10c361 // indirect github.com/ipfs/boxo v0.18.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 3e21cae0c..5be21d312 100644 --- a/tools/gendoc/go.sum +++ b/tools/gendoc/go.sum @@ -322,8 +322,8 @@ github.com/iotaledger/inx/go v1.0.0-rc.2.0.20240307100839-48553e1d2022 h1:I178Sa github.com/iotaledger/inx/go v1.0.0-rc.2.0.20240307100839-48553e1d2022/go.mod h1:jTFxIWiMUdAwO263jlJCSWcNLqEkgYEVOFXfjp5aNJM= github.com/iotaledger/iota-crypto-demo v0.0.0-20240216103559-27ca8dffd1e7 h1:t6k4MqiUov0FrBb2o2JhKlOVSdlPbIQWM8ivYHL0G0g= github.com/iotaledger/iota-crypto-demo v0.0.0-20240216103559-27ca8dffd1e7/go.mod h1:do+N3LpeDEi9qselEC4XcjqGoRc7cWGiqBtIeBOKEMs= -github.com/iotaledger/iota.go/v4 v4.0.0-20240307175623-0904c71fcb38 h1:NizJ3CALLCcJowtAtkNuDlpE4gd4qjaWZkp/kTZfeYk= -github.com/iotaledger/iota.go/v4 v4.0.0-20240307175623-0904c71fcb38/go.mod h1:8UQOTI7CC5R/3TurawUFuBZbkb37RzW8m4q8Hp7ct30= +github.com/iotaledger/iota.go/v4 v4.0.0-20240313065735-74f8cf10c361 h1:fKvfJZ4byivRRKkqF6JPj8I4pDSN0y+bgF4I4HI11Lo= +github.com/iotaledger/iota.go/v4 v4.0.0-20240313065735-74f8cf10c361/go.mod h1:8UQOTI7CC5R/3TurawUFuBZbkb37RzW8m4q8Hp7ct30= github.com/ipfs/boxo v0.18.0 h1:MOL9/AgoV3e7jlVMInicaSdbgralfqSsbkc31dZ9tmw= github.com/ipfs/boxo v0.18.0/go.mod h1:pIZgTWdm3k3pLF9Uq6MB8JEcW07UDwNJjlXW1HELW80= github.com/ipfs/go-cid v0.4.1 h1:A/T3qGvxi4kpKWWcPC/PgbvDA2bjVLO7n4UeVwnbs/s= From 8e94718d3a61886e134626ba4f681a3e70e625c0 Mon Sep 17 00:00:00 2001 From: Philipp Gackstatter Date: Wed, 13 Mar 2024 17:41:05 +0800 Subject: [PATCH 3/4] Fix wrap order in block issuer --- pkg/testsuite/mock/blockissuer.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/testsuite/mock/blockissuer.go b/pkg/testsuite/mock/blockissuer.go index 30e75a943..3b382e19e 100644 --- a/pkg/testsuite/mock/blockissuer.go +++ b/pkg/testsuite/mock/blockissuer.go @@ -515,7 +515,7 @@ func (i *BlockIssuer) getReferencesWithRetry(ctx context.Context, parentsCount i case <-timeout.C: return nil, ierrors.New("timeout while trying to select tips and determine references") case <-ctx.Done(): - return nil, ierrors.Errorf("context canceled whilst trying to select tips and determine references: %w", ctx.Err()) + return nil, ierrors.Wrap(ctx.Err(), "context canceled whilst trying to select tips and determine references") } } } From bb6c2bca7d86427d62550f72a1003bea7e4aaba9 Mon Sep 17 00:00:00 2001 From: Philipp Gackstatter Date: Wed, 13 Mar 2024 20:26:24 +0800 Subject: [PATCH 4/4] Use New instead of Errorf --- pkg/network/protocols/core/protocol.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/network/protocols/core/protocol.go b/pkg/network/protocols/core/protocol.go index 7f49e88b6..458a62015 100644 --- a/pkg/network/protocols/core/protocol.go +++ b/pkg/network/protocols/core/protocol.go @@ -216,7 +216,7 @@ func (p *Protocol) onBlock(blockData []byte, id peer.ID) { func (p *Protocol) onBlockRequest(idBytes []byte, id peer.ID) { if len(idBytes) != iotago.BlockIDLength { - p.Events.Error.Trigger(ierrors.Errorf("failed to deserialize block request: invalid block id length"), id) + p.Events.Error.Trigger(ierrors.New("failed to deserialize block request: invalid block id length"), id) return } @@ -237,7 +237,7 @@ func (p *Protocol) onSlotCommitment(commitmentBytes []byte, id peer.ID) { func (p *Protocol) onSlotCommitmentRequest(idBytes []byte, id peer.ID) { if len(idBytes) != iotago.CommitmentIDLength { - p.Events.Error.Trigger(ierrors.Errorf("failed to deserialize slot commitment request: invalid commitment id length"), id) + p.Events.Error.Trigger(ierrors.New("failed to deserialize slot commitment request: invalid commitment id length"), id) return } @@ -257,7 +257,7 @@ func (p *Protocol) onAttestations(commitmentBytes []byte, attestationsBytes []by attestationsCount, err := stream.PeekSize(reader, serializer.SeriLengthPrefixTypeAsUint32) if err != nil { - p.Events.Error.Trigger(ierrors.Errorf("failed peek attestations count"), id) + p.Events.Error.Trigger(ierrors.New("failed peek attestations count"), id) return } @@ -294,7 +294,7 @@ func (p *Protocol) onAttestations(commitmentBytes []byte, attestationsBytes []by func (p *Protocol) onAttestationsRequest(commitmentIDBytes []byte, id peer.ID) { if len(commitmentIDBytes) != iotago.CommitmentIDLength { - p.Events.Error.Trigger(ierrors.Errorf("failed to deserialize commitmentID in attestations request: invalid commitment id length"), id) + p.Events.Error.Trigger(ierrors.New("failed to deserialize commitmentID in attestations request: invalid commitment id length"), id) return }