Skip to content

Commit

Permalink
Merge pull request #332 from iotaledger/booker-well-descriptive-err
Browse files Browse the repository at this point in the history
Make errors in booker more descriptive
  • Loading branch information
jkrvivian authored Sep 11, 2023
2 parents bf2c048 + 3c97704 commit 362b924
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 15 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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-20230906064556-75f5be378284
github.com/iotaledger/iota.go/v4 v4.0.0-20230911110046-2c50729c4ea0
github.com/labstack/echo/v4 v4.11.1
github.com/labstack/gommon v0.4.0
github.com/libp2p/go-libp2p v0.30.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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-20230906064556-75f5be378284 h1:SmPyo08i2/ymMZkmIQX/7EexuWWFl7CKDZjJr47zn8Q=
github.com/iotaledger/iota.go/v4 v4.0.0-20230906064556-75f5be378284/go.mod h1:MM3RLtTEsfT6Wh0EhpgmzVO/HM0/NOw+E7+mnGTnyA0=
github.com/iotaledger/iota.go/v4 v4.0.0-20230911110046-2c50729c4ea0 h1:eBVGnr/WkqF3+tlCE23uDxPvmkD/r7StkIoUerwLEqw=
github.com/iotaledger/iota.go/v4 v4.0.0-20230911110046-2c50729c4ea0/go.mod h1:MM3RLtTEsfT6Wh0EhpgmzVO/HM0/NOw+E7+mnGTnyA0=
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=
Expand Down
7 changes: 4 additions & 3 deletions pkg/protocol/engine/booker/inmemorybooker/booker.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func New(workers *workerpool.Group, apiProvider api.Provider, blockCache *blocks
b.book,
b.markInvalid,
(*blocks.Block).Parents,
causalorder.WithReferenceValidator[iotago.SlotIndex, iotago.BlockID](isReferenceValid),
causalorder.WithReferenceValidator[iotago.SlotIndex, iotago.BlockID](b.isReferenceValid),
)

blockCache.Evict.Hook(b.evict)
Expand Down Expand Up @@ -149,7 +149,6 @@ func (b *Booker) book(block *blocks.Block) error {

func (b *Booker) markInvalid(block *blocks.Block, err error) {
if block.SetInvalid() {
b.retainBlockFailure(block.ID(), apimodels.BlockFailureBookingFailure)
b.events.BlockInvalid.Trigger(block, ierrors.Wrap(err, "block marked as invalid in Booker"))
}
}
Expand All @@ -161,6 +160,7 @@ func (b *Booker) inheritConflicts(block *blocks.Block) (conflictIDs ds.Set[iotag
for _, parent := range block.ParentsWithType() {
parentBlock, exists := b.blockCache.Block(parent.ID)
if !exists {
b.retainBlockFailure(block.ID(), apimodels.BlockFailureParentNotFound)
return nil, ierrors.Errorf("parent %s does not exist", parent.ID)
}

Expand Down Expand Up @@ -195,8 +195,9 @@ func (b *Booker) inheritConflicts(block *blocks.Block) (conflictIDs ds.Set[iotag
}

// isReferenceValid checks if the reference between the child and its parent is valid.
func isReferenceValid(child *blocks.Block, parent *blocks.Block) (err error) {
func (b *Booker) isReferenceValid(child *blocks.Block, parent *blocks.Block) (err error) {
if parent.IsInvalid() {
b.retainBlockFailure(child.ID(), apimodels.BlockFailureParentInvalid)
return ierrors.Errorf("parent %s of child %s is marked as invalid", parent.ID(), child.ID())
}

Expand Down
2 changes: 1 addition & 1 deletion tools/evil-spammer/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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-20230906064556-75f5be378284
github.com/iotaledger/iota.go/v4 v4.0.0-20230911110046-2c50729c4ea0
github.com/mr-tron/base58 v1.2.0
go.uber.org/atomic v1.11.0
)
Expand Down
4 changes: 2 additions & 2 deletions tools/evil-spammer/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,8 @@ github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20230906114834-b50190b
github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20230906114834-b50190b9f9c2/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-20230906064556-75f5be378284 h1:SmPyo08i2/ymMZkmIQX/7EexuWWFl7CKDZjJr47zn8Q=
github.com/iotaledger/iota.go/v4 v4.0.0-20230906064556-75f5be378284/go.mod h1:MM3RLtTEsfT6Wh0EhpgmzVO/HM0/NOw+E7+mnGTnyA0=
github.com/iotaledger/iota.go/v4 v4.0.0-20230911110046-2c50729c4ea0 h1:eBVGnr/WkqF3+tlCE23uDxPvmkD/r7StkIoUerwLEqw=
github.com/iotaledger/iota.go/v4 v4.0.0-20230911110046-2c50729c4ea0/go.mod h1:MM3RLtTEsfT6Wh0EhpgmzVO/HM0/NOw+E7+mnGTnyA0=
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=
Expand Down
2 changes: 1 addition & 1 deletion tools/gendoc/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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-20230906064556-75f5be378284 // indirect
github.com/iotaledger/iota.go/v4 v4.0.0-20230911110046-2c50729c4ea0 // 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
Expand Down
4 changes: 2 additions & 2 deletions tools/gendoc/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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-20230906064556-75f5be378284 h1:SmPyo08i2/ymMZkmIQX/7EexuWWFl7CKDZjJr47zn8Q=
github.com/iotaledger/iota.go/v4 v4.0.0-20230906064556-75f5be378284/go.mod h1:MM3RLtTEsfT6Wh0EhpgmzVO/HM0/NOw+E7+mnGTnyA0=
github.com/iotaledger/iota.go/v4 v4.0.0-20230911110046-2c50729c4ea0 h1:eBVGnr/WkqF3+tlCE23uDxPvmkD/r7StkIoUerwLEqw=
github.com/iotaledger/iota.go/v4 v4.0.0-20230911110046-2c50729c4ea0/go.mod h1:MM3RLtTEsfT6Wh0EhpgmzVO/HM0/NOw+E7+mnGTnyA0=
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=
Expand Down
2 changes: 1 addition & 1 deletion tools/genesis-snapshot/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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-20230906064556-75f5be378284
github.com/iotaledger/iota.go/v4 v4.0.0-20230911110046-2c50729c4ea0
github.com/mr-tron/base58 v1.2.0
github.com/spf13/pflag v1.0.5
golang.org/x/crypto v0.13.0
Expand Down
4 changes: 2 additions & 2 deletions tools/genesis-snapshot/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20230906114834-b50190b
github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20230906114834-b50190b9f9c2/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-20230906064556-75f5be378284 h1:SmPyo08i2/ymMZkmIQX/7EexuWWFl7CKDZjJr47zn8Q=
github.com/iotaledger/iota.go/v4 v4.0.0-20230906064556-75f5be378284/go.mod h1:MM3RLtTEsfT6Wh0EhpgmzVO/HM0/NOw+E7+mnGTnyA0=
github.com/iotaledger/iota.go/v4 v4.0.0-20230911110046-2c50729c4ea0 h1:eBVGnr/WkqF3+tlCE23uDxPvmkD/r7StkIoUerwLEqw=
github.com/iotaledger/iota.go/v4 v4.0.0-20230911110046-2c50729c4ea0/go.mod h1:MM3RLtTEsfT6Wh0EhpgmzVO/HM0/NOw+E7+mnGTnyA0=
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=
Expand Down

0 comments on commit 362b924

Please sign in to comment.