Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error order improvement #827

Merged
merged 5 commits into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
8 changes: 4 additions & 4 deletions pkg/network/protocols/core/protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.New("failed to deserialize block request: invalid block id length"), id)

return
}
Expand All @@ -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.New("failed to deserialize slot commitment request: invalid commitment id length"), id)

return
}
Expand All @@ -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
}
Expand Down Expand Up @@ -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.New("failed to deserialize commitmentID in attestations request: invalid commitment id length"), id)

return
}
Expand Down
8 changes: 2 additions & 6 deletions pkg/protocol/engine/ledger/ledger/ledger.go
Original file line number Diff line number Diff line change
Expand Up @@ -612,19 +612,15 @@ 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
{
// input side
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())
Expand Down
6 changes: 1 addition & 5 deletions pkg/protocol/engine/ledger/ledger/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion pkg/testsuite/mock/blockissuer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion tools/gendoc/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions tools/gendoc/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
Loading