Skip to content
This repository was archived by the owner on Jan 24, 2025. It is now read-only.

Commit 39c9f43

Browse files
authored
Merge pull request #827 from iotaledger/error-order-improvement
Error order improvement
2 parents eb20122 + bb6c2bc commit 39c9f43

File tree

8 files changed

+14
-22
lines changed

8 files changed

+14
-22
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ require (
2828
github.com/iotaledger/hive.go/stringify v0.0.0-20240307102857-7e23a3c59bd2
2929
github.com/iotaledger/inx-app v1.0.0-rc.3.0.20240307101848-db58eb9353ec
3030
github.com/iotaledger/inx/go v1.0.0-rc.2.0.20240307100839-48553e1d2022
31-
github.com/iotaledger/iota.go/v4 v4.0.0-20240307175623-0904c71fcb38
31+
github.com/iotaledger/iota.go/v4 v4.0.0-20240313065735-74f8cf10c361
3232
github.com/labstack/echo/v4 v4.11.4
3333
github.com/labstack/gommon v0.4.2
3434
github.com/libp2p/go-libp2p v0.33.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,8 +318,8 @@ github.com/iotaledger/inx/go v1.0.0-rc.2.0.20240307100839-48553e1d2022 h1:I178Sa
318318
github.com/iotaledger/inx/go v1.0.0-rc.2.0.20240307100839-48553e1d2022/go.mod h1:jTFxIWiMUdAwO263jlJCSWcNLqEkgYEVOFXfjp5aNJM=
319319
github.com/iotaledger/iota-crypto-demo v0.0.0-20240216103559-27ca8dffd1e7 h1:t6k4MqiUov0FrBb2o2JhKlOVSdlPbIQWM8ivYHL0G0g=
320320
github.com/iotaledger/iota-crypto-demo v0.0.0-20240216103559-27ca8dffd1e7/go.mod h1:do+N3LpeDEi9qselEC4XcjqGoRc7cWGiqBtIeBOKEMs=
321-
github.com/iotaledger/iota.go/v4 v4.0.0-20240307175623-0904c71fcb38 h1:NizJ3CALLCcJowtAtkNuDlpE4gd4qjaWZkp/kTZfeYk=
322-
github.com/iotaledger/iota.go/v4 v4.0.0-20240307175623-0904c71fcb38/go.mod h1:8UQOTI7CC5R/3TurawUFuBZbkb37RzW8m4q8Hp7ct30=
321+
github.com/iotaledger/iota.go/v4 v4.0.0-20240313065735-74f8cf10c361 h1:fKvfJZ4byivRRKkqF6JPj8I4pDSN0y+bgF4I4HI11Lo=
322+
github.com/iotaledger/iota.go/v4 v4.0.0-20240313065735-74f8cf10c361/go.mod h1:8UQOTI7CC5R/3TurawUFuBZbkb37RzW8m4q8Hp7ct30=
323323
github.com/ipfs/boxo v0.18.0 h1:MOL9/AgoV3e7jlVMInicaSdbgralfqSsbkc31dZ9tmw=
324324
github.com/ipfs/boxo v0.18.0/go.mod h1:pIZgTWdm3k3pLF9Uq6MB8JEcW07UDwNJjlXW1HELW80=
325325
github.com/ipfs/go-cid v0.4.1 h1:A/T3qGvxi4kpKWWcPC/PgbvDA2bjVLO7n4UeVwnbs/s=

pkg/network/protocols/core/protocol.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ func (p *Protocol) onBlock(blockData []byte, id peer.ID) {
216216

217217
func (p *Protocol) onBlockRequest(idBytes []byte, id peer.ID) {
218218
if len(idBytes) != iotago.BlockIDLength {
219-
p.Events.Error.Trigger(ierrors.Wrap(iotago.ErrInvalidIdentifierLength, "failed to deserialize block request"), id)
219+
p.Events.Error.Trigger(ierrors.New("failed to deserialize block request: invalid block id length"), id)
220220

221221
return
222222
}
@@ -237,7 +237,7 @@ func (p *Protocol) onSlotCommitment(commitmentBytes []byte, id peer.ID) {
237237

238238
func (p *Protocol) onSlotCommitmentRequest(idBytes []byte, id peer.ID) {
239239
if len(idBytes) != iotago.CommitmentIDLength {
240-
p.Events.Error.Trigger(ierrors.Wrap(iotago.ErrInvalidIdentifierLength, "failed to deserialize slot commitment request"), id)
240+
p.Events.Error.Trigger(ierrors.New("failed to deserialize slot commitment request: invalid commitment id length"), id)
241241

242242
return
243243
}
@@ -257,7 +257,7 @@ func (p *Protocol) onAttestations(commitmentBytes []byte, attestationsBytes []by
257257

258258
attestationsCount, err := stream.PeekSize(reader, serializer.SeriLengthPrefixTypeAsUint32)
259259
if err != nil {
260-
p.Events.Error.Trigger(ierrors.Errorf("failed peek attestations count"), id)
260+
p.Events.Error.Trigger(ierrors.New("failed peek attestations count"), id)
261261

262262
return
263263
}
@@ -294,7 +294,7 @@ func (p *Protocol) onAttestations(commitmentBytes []byte, attestationsBytes []by
294294

295295
func (p *Protocol) onAttestationsRequest(commitmentIDBytes []byte, id peer.ID) {
296296
if len(commitmentIDBytes) != iotago.CommitmentIDLength {
297-
p.Events.Error.Trigger(ierrors.Wrap(iotago.ErrInvalidIdentifierLength, "failed to deserialize commitmentID in attestations request"), id)
297+
p.Events.Error.Trigger(ierrors.New("failed to deserialize commitmentID in attestations request: invalid commitment id length"), id)
298298

299299
return
300300
}

pkg/protocol/engine/ledger/ledger/ledger.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -612,19 +612,15 @@ func (l *Ledger) processStateDiffTransactions(stateDiff mempool.StateDiff) (spen
612612
return false
613613
}
614614

615-
inputRefs, errInput := tx.Inputs()
616-
if errInput != nil {
617-
err = ierrors.Errorf("failed to retrieve inputs of %s: %w", txID, errInput)
618-
return false
619-
}
615+
inputRefs := tx.Inputs()
620616

621617
// process outputs
622618
{
623619
// input side
624620
for _, inputRef := range lo.Map(inputRefs, mempool.UTXOInputStateRefFromInput) {
625621
stateWithMetadata, stateError := l.memPool.StateMetadata(inputRef)
626622
if stateError != nil {
627-
err = ierrors.Errorf("failed to retrieve outputs of %s: %w", txID, errInput)
623+
err = ierrors.Wrapf(stateError, "failed to retrieve outputs of %s", txID)
628624
return false
629625
}
630626
spent := utxoledger.NewSpent(l.outputFromState(stateWithMetadata.State()), txWithMeta.ID(), stateDiff.Slot())

pkg/protocol/engine/ledger/ledger/vm.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,7 @@ func (v *VM) ValidateSignatures(signedTransaction mempool.SignedTransaction, res
6565
return nil, iotago.ErrTxTypeInvalid
6666
}
6767

68-
contextInputs, err := iotagoSignedTransaction.Transaction.ContextInputs()
69-
if err != nil {
70-
return nil, ierrors.Wrapf(err, "unable to retrieve context inputs from transaction")
71-
}
72-
68+
contextInputs := iotagoSignedTransaction.Transaction.ContextInputs()
7369
utxoInputSet := iotagovm.InputSet{}
7470
commitmentInput := (*iotago.Commitment)(nil)
7571
bicInputs := make([]*iotago.BlockIssuanceCreditInput, 0)

pkg/testsuite/mock/blockissuer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ func (i *BlockIssuer) getReferencesWithRetry(ctx context.Context, parentsCount i
515515
case <-timeout.C:
516516
return nil, ierrors.New("timeout while trying to select tips and determine references")
517517
case <-ctx.Done():
518-
return nil, ierrors.Errorf("context canceled whilst trying to select tips and determine references: %w", ctx.Err())
518+
return nil, ierrors.Wrap(ctx.Err(), "context canceled whilst trying to select tips and determine references")
519519
}
520520
}
521521
}

tools/gendoc/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ require (
7373
github.com/iotaledger/inx-app v1.0.0-rc.3.0.20240307101848-db58eb9353ec // indirect
7474
github.com/iotaledger/inx/go v1.0.0-rc.2.0.20240307100839-48553e1d2022 // indirect
7575
github.com/iotaledger/iota-crypto-demo v0.0.0-20240216103559-27ca8dffd1e7 // indirect
76-
github.com/iotaledger/iota.go/v4 v4.0.0-20240307175623-0904c71fcb38 // indirect
76+
github.com/iotaledger/iota.go/v4 v4.0.0-20240313065735-74f8cf10c361 // indirect
7777
github.com/ipfs/boxo v0.18.0 // indirect
7878
github.com/ipfs/go-cid v0.4.1 // indirect
7979
github.com/ipfs/go-datastore v0.6.0 // indirect

tools/gendoc/go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,8 +322,8 @@ github.com/iotaledger/inx/go v1.0.0-rc.2.0.20240307100839-48553e1d2022 h1:I178Sa
322322
github.com/iotaledger/inx/go v1.0.0-rc.2.0.20240307100839-48553e1d2022/go.mod h1:jTFxIWiMUdAwO263jlJCSWcNLqEkgYEVOFXfjp5aNJM=
323323
github.com/iotaledger/iota-crypto-demo v0.0.0-20240216103559-27ca8dffd1e7 h1:t6k4MqiUov0FrBb2o2JhKlOVSdlPbIQWM8ivYHL0G0g=
324324
github.com/iotaledger/iota-crypto-demo v0.0.0-20240216103559-27ca8dffd1e7/go.mod h1:do+N3LpeDEi9qselEC4XcjqGoRc7cWGiqBtIeBOKEMs=
325-
github.com/iotaledger/iota.go/v4 v4.0.0-20240307175623-0904c71fcb38 h1:NizJ3CALLCcJowtAtkNuDlpE4gd4qjaWZkp/kTZfeYk=
326-
github.com/iotaledger/iota.go/v4 v4.0.0-20240307175623-0904c71fcb38/go.mod h1:8UQOTI7CC5R/3TurawUFuBZbkb37RzW8m4q8Hp7ct30=
325+
github.com/iotaledger/iota.go/v4 v4.0.0-20240313065735-74f8cf10c361 h1:fKvfJZ4byivRRKkqF6JPj8I4pDSN0y+bgF4I4HI11Lo=
326+
github.com/iotaledger/iota.go/v4 v4.0.0-20240313065735-74f8cf10c361/go.mod h1:8UQOTI7CC5R/3TurawUFuBZbkb37RzW8m4q8Hp7ct30=
327327
github.com/ipfs/boxo v0.18.0 h1:MOL9/AgoV3e7jlVMInicaSdbgralfqSsbkc31dZ9tmw=
328328
github.com/ipfs/boxo v0.18.0/go.mod h1:pIZgTWdm3k3pLF9Uq6MB8JEcW07UDwNJjlXW1HELW80=
329329
github.com/ipfs/go-cid v0.4.1 h1:A/T3qGvxi4kpKWWcPC/PgbvDA2bjVLO7n4UeVwnbs/s=

0 commit comments

Comments
 (0)