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

Handle loss of acceptance #379

Merged
merged 54 commits into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
89ad1cc
Feat: Persist mutations
hmoog Sep 28, 2023
849aa71
Use mutations prunable storage to store mutations in mempool
jonastheis Sep 28, 2023
a77d2de
Update protobuf structure for warpsync response to include mutations …
jonastheis Sep 28, 2023
970e0fb
Implement warpsync response to include mutations proof and accepted t…
jonastheis Sep 28, 2023
0ec1305
Extend warp sync to validate mutation proof and force accept blocks,…
jonastheis Sep 29, 2023
1c8ce17
Store last issued validation block in settings
jonastheis Sep 20, 2023
e831a32
Implement way to react to a halted chain in block issuer by introduci…
jonastheis Sep 29, 2023
c3f821d
Add revive chain to block issuer
jonastheis Sep 29, 2023
3f4b071
Extend loss of acceptance test to have other nodes warp sync empty an…
jonastheis Sep 30, 2023
9096d47
Fix basic block issuing nil pointer
jonastheis Sep 30, 2023
7b90ad6
Fix not correctly initialized reactive variables in blocks.Block
jonastheis Sep 30, 2023
f173ff5
Make sure that blocks whose commitments is known but not in sync wind…
jonastheis Sep 30, 2023
8efab21
Do not process already committed slots in warpsync again if the commi…
jonastheis Sep 30, 2023
c8dccba
Force commitment also for empty slots and set warp sync range to 1
jonastheis Sep 30, 2023
ce57187
Fix waiting for blocks to become notarized so that attestations can b…
jonastheis Oct 1, 2023
90ef4a2
Set blocks synced with warp sync as root blocks as otherwise we could…
jonastheis Oct 1, 2023
4222336
Fix loss of acceptance test and continue issuing for 2 slots so that …
jonastheis Oct 1, 2023
cbca09e
Take a parent block from root blocks when reviving the chain
jonastheis Oct 2, 2023
58c91e3
Fix error with committee being nil when rolling back engine
jonastheis Oct 2, 2023
eaafa23
Expose AcceptedBlocksCount from notarization manager to detect a "dir…
jonastheis Oct 2, 2023
141ef3b
Reset engine in warp sync when engine is dirty
jonastheis Oct 2, 2023
4ba848c
Add TestLossOfAcceptanceFromSnapshot
jonastheis Oct 2, 2023
3f76abd
Extend all loss of acceptance tests and add TestLossOfAcceptanceWithR…
jonastheis Oct 3, 2023
8f133de
When starting up node ensure that a consistent state is created by de…
jonastheis Oct 3, 2023
2b0c61d
Merge remote-tracking branch 'origin/develop' into feat/persist-mutat…
jonastheis Oct 3, 2023
ffe86cf
Fix tests and update go.mod to latest iota.go
jonastheis Oct 3, 2023
0bc154f
Merge remote-tracking branch 'origin/develop' into feat/persist-mutat…
jonastheis Oct 3, 2023
b8a8a05
Fixes after merge
jonastheis Oct 3, 2023
133e534
Merge remote-tracking branch 'origin/develop' into feat/persist-mutat…
karimodm Oct 5, 2023
8d5b082
Address review comments
jonastheis Oct 9, 2023
6fa21b6
Do not pass latest commitment to CreateValidationBlock nullifying cha…
karimodm Oct 9, 2023
b0dd8dc
Lock createCommitment to avoid race between warpsync and acceptaance
karimodm Oct 9, 2023
608fb72
Merge remote-tracking branch 'origin/develop' into feat/persist-mutat…
karimodm Oct 9, 2023
4aff27c
Fix loss of acceptance tests
karimodm Oct 9, 2023
be357de
Adapt reviveChain logic from mock.BlockIssuer to Validator component
karimodm Oct 9, 2023
d628318
Provide BlockHandler dependency from RestAPI component
karimodm Oct 9, 2023
8cddbe4
--blockIssuer.rateSetterEnabled parameter has been dropped
karimodm Oct 9, 2023
508c49f
Merge branch 'test' into feat/persist-mutations
karimodm Oct 9, 2023
2abee9d
Point to a hive.go without queue's PanicOnModificationsAfterShutdown
karimodm Oct 9, 2023
a281a29
go.mod tidy
jonastheis Oct 10, 2023
5d4018a
Fix shutdown issue of engine by unhooking AcceptedBlockProcessed eve…
jonastheis Oct 10, 2023
9ab0609
Fix some string display issues in metrics and dashboard
jonastheis Oct 10, 2023
075b521
Reactive Booker
karimodm Oct 6, 2023
df35b21
Reactive Solidifier
karimodm Oct 6, 2023
0858b90
Handle booking error
karimodm Oct 6, 2023
8f8f8de
Remove unused workers
karimodm Oct 6, 2023
a4f999c
Remove locks from reactive variables and simplify API
karimodm Oct 7, 2023
a85cd29
Address review comments
karimodm Oct 10, 2023
762be4f
Merge remote-tracking branch 'origin/develop' into feat/persist-mutat…
karimodm Oct 10, 2023
76c7979
Revert Docker preset to Now genesis time
karimodm Oct 10, 2023
480bef1
Merge remote-tracking branch 'origin/feat/persist-mutations' into fix…
karimodm Oct 10, 2023
6edcd09
Merge pull request #404 from iotaledger/fix/reactive-solidifier
karimodm Oct 10, 2023
d037d34
Bump hive.go to get bug fixes
karimodm Oct 10, 2023
10de79e
Fix Block's String method
karimodm Oct 10, 2023
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
10 changes: 5 additions & 5 deletions components/dashboard/explorer_routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func createExplorerBlock(block *model.Block, cachedBlock *blocks.Block, metadata
SolidificationTimestamp: 0,
IssuanceTimestamp: iotaBlk.IssuingTime.Unix(),
SequenceNumber: 0,
IssuerID: iotaBlk.IssuerID.String(),
IssuerID: iotaBlk.IssuerID.ToHex(),
Signature: hexutil.EncodeHex(sigBytes),
StrongParents: iotaBlk.Block.StrongParentIDs().ToHex(),
WeakParents: iotaBlk.Block.WeakParentIDs().ToHex(),
Expand Down Expand Up @@ -164,16 +164,16 @@ func createExplorerBlock(block *model.Block, cachedBlock *blocks.Block, metadata
t.Scheduled = cachedBlock.IsScheduled()
t.ObjectivelyInvalid = cachedBlock.IsInvalid()
t.StrongChildren = lo.Map(cachedBlock.StrongChildren(), func(childBlock *blocks.Block) string {
return childBlock.ID().String()
return childBlock.ID().ToHex()
})
t.WeakChildren = lo.Map(cachedBlock.WeakChildren(), func(childBlock *blocks.Block) string {
return childBlock.ID().String()
return childBlock.ID().ToHex()
})
t.LikedInsteadChildren = lo.Map(cachedBlock.ShallowLikeChildren(), func(childBlock *blocks.Block) string {
return childBlock.ID().String()
return childBlock.ID().ToHex()
})
t.ConflictIDs = lo.Map(cachedBlock.ConflictIDs().ToSlice(), func(conflictID iotago.TransactionID) string {
return conflictID.String()
return conflictID.ToHex()
})
} else {
switch metadata.BlockState {
Expand Down
5 changes: 4 additions & 1 deletion components/debugapi/transactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ func init() {

func storeTransactionsPerSlot(scd *notarization.SlotCommittedDetails) error {
slot := scd.Commitment.Slot()
stateDiff := deps.Protocol.MainEngineInstance().Ledger.MemPool().StateDiff(slot)
stateDiff, err := deps.Protocol.MainEngineInstance().Ledger.MemPool().StateDiff(slot)
if err != nil {
return ierrors.Wrapf(err, "failed to retrieve state diff for slot %d", slot)
}
mutationsTree := ads.NewSet(mapdb.NewMapDB(), iotago.TransactionID.Bytes, iotago.TransactionIDFromBytes)
tcs := &TransactionsChangesResponse{
Index: slot,
Expand Down
2 changes: 1 addition & 1 deletion components/metrics/metrics_commitments.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ var CommitmentsMetrics = collector.NewCollection(commitmentsNamespace,
collector.WithPruningDelay(10*time.Minute),
collector.WithInitFunc(func() {
deps.Protocol.Events.Engine.Notarization.SlotCommitted.Hook(func(details *notarization.SlotCommittedDetails) {
deps.Collector.Update(commitmentsNamespace, latestCommitment, float64(details.Commitment.ID().Slot()), details.Commitment.ID().String())
deps.Collector.Update(commitmentsNamespace, latestCommitment, float64(details.Commitment.ID().Slot()), "C "+details.Commitment.ID().ToHex())
}, event.WithWorkerPool(Component.WorkerPool))
}),
)),
Expand Down
7 changes: 7 additions & 0 deletions components/restapi/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/iotaledger/hive.go/app"
"github.com/iotaledger/hive.go/ierrors"
"github.com/iotaledger/inx-app/pkg/httpserver"
"github.com/iotaledger/iota-core/pkg/blockhandler"
"github.com/iotaledger/iota-core/pkg/daemon"
"github.com/iotaledger/iota-core/pkg/jwt"
protocolpkg "github.com/iotaledger/iota-core/pkg/protocol"
Expand Down Expand Up @@ -99,6 +100,12 @@ func provide(c *dig.Container) error {
Component.LogPanic(err)
}

if err := c.Provide(func(deps dependencies) *blockhandler.BlockHandler {
return blockhandler.New(deps.Protocol)
}); err != nil {
Component.LogPanic(err)
}

return nil
}

Expand Down
87 changes: 83 additions & 4 deletions components/validator/issuer.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ import (
"context"
"time"

"github.com/iotaledger/hive.go/ierrors"
"github.com/iotaledger/iota-core/pkg/model"
iotago "github.com/iotaledger/iota.go/v4"
"github.com/iotaledger/iota.go/v4/builder"
)

var ErrBlockTooRecent = ierrors.New("block is too recent compared to latest commitment")

func issueValidatorBlock(ctx context.Context) {
// Get the main engine instance in case it changes mid-execution.
engineInstance := deps.Protocol.MainEngineInstance()

// Get the latest commitment from the engine before to avoid race conditions if something is committed after we fix block issuing time.
latestCommitment := engineInstance.Storage.Settings().LatestCommitment()

blockIssuingTime := time.Now()
nextBroadcast := blockIssuingTime.Add(ParamsValidator.CommitteeBroadcastInterval)

Expand All @@ -39,11 +39,28 @@ func issueValidatorBlock(ctx context.Context) {

parents := engineInstance.TipSelection.SelectTips(iotago.BlockTypeValidationMaxParents)

addressableCommitment, err := getAddressableCommitment(deps.Protocol.CurrentAPI().TimeProvider().SlotFromTime(blockIssuingTime))
if err != nil && ierrors.Is(err, ErrBlockTooRecent) {
commitment, parentID, reviveChainErr := reviveChain(blockIssuingTime)
if reviveChainErr != nil {
Component.LogError("error reviving chain: %s", reviveChainErr.Error())
return
}

addressableCommitment = commitment
parents = make(model.ParentReferences)
parents[iotago.StrongParentType] = []iotago.BlockID{parentID}
} else if err != nil {
Component.LogWarnf("error getting commitment: %s", err.Error())

return
}

// create the validation block here using the validation block builder from iota.go
validationBlock, err := builder.NewValidationBlockBuilder(deps.Protocol.CurrentAPI()).
IssuingTime(blockIssuingTime).
SlotCommitmentID(latestCommitment.ID()).
ProtocolParametersHash(protocolParametersHash).
SlotCommitmentID(addressableCommitment.MustID()).
HighestSupportedVersion(deps.Protocol.LatestAPI().Version()).
LatestFinalizedSlot(engineInstance.SyncManager.LatestFinalizedSlot()).
StrongParents(parents[iotago.StrongParentType]).
Expand Down Expand Up @@ -77,5 +94,67 @@ func issueValidatorBlock(ctx context.Context) {
}

Component.LogDebugf("Issued validator block: %s - commitment %s %d - latest finalized slot %d", modelBlock.ID(), modelBlock.ProtocolBlock().SlotCommitmentID, modelBlock.ProtocolBlock().SlotCommitmentID.Slot(), modelBlock.ProtocolBlock().LatestFinalizedSlot)
}

func reviveChain(issuingTime time.Time) (*iotago.Commitment, iotago.BlockID, error) {
lastCommittedSlot := deps.Protocol.MainEngineInstance().Storage.Settings().LatestCommitment().Slot()
apiForSlot := deps.Protocol.APIForSlot(lastCommittedSlot)

// Get a rootblock as recent as possible for the parent.
parentBlockID := iotago.EmptyBlockID
for rootBlock := range deps.Protocol.MainEngineInstance().EvictionState.ActiveRootBlocks() {
if rootBlock.Slot() > parentBlockID.Slot() {
parentBlockID = rootBlock
}

// Exit the loop if we found a rootblock in the last committed slot (which is the highest we can get).
if parentBlockID.Slot() == lastCommittedSlot {
break
}
}

issuingSlot := apiForSlot.TimeProvider().SlotFromTime(issuingTime)

// Force commitments until minCommittableAge relative to the block's issuing time. We basically "pretend" that
// this block was already accepted at the time of issuing so that we have a commitment to reference.
if issuingSlot < apiForSlot.ProtocolParameters().MinCommittableAge() { // Should never happen as we're beyond maxCommittableAge which is > minCommittableAge.
return nil, iotago.EmptyBlockID, ierrors.Errorf("issuing slot %d is smaller than min committable age %d", issuingSlot, apiForSlot.ProtocolParameters().MinCommittableAge())
}
commitUntilSlot := issuingSlot - apiForSlot.ProtocolParameters().MinCommittableAge()

if err := deps.Protocol.MainEngineInstance().Notarization.ForceCommitUntil(commitUntilSlot); err != nil {
return nil, iotago.EmptyBlockID, ierrors.Wrapf(err, "failed to force commit until slot %d", commitUntilSlot)
}

commitment, err := deps.Protocol.MainEngineInstance().Storage.Commitments().Load(commitUntilSlot)
if err != nil {
return nil, iotago.EmptyBlockID, ierrors.Wrapf(err, "failed to commit until slot %d to revive chain", commitUntilSlot)
}

return commitment.Commitment(), parentBlockID, nil
}

func getAddressableCommitment(blockSlot iotago.SlotIndex) (*iotago.Commitment, error) {
protoParams := deps.Protocol.CurrentAPI().ProtocolParameters()
commitment := deps.Protocol.MainEngineInstance().Storage.Settings().LatestCommitment().Commitment()

if blockSlot > commitment.Slot+protoParams.MaxCommittableAge() {
return nil, ierrors.Wrapf(ErrBlockTooRecent, "can't issue block: block slot %d is too far in the future, latest commitment is %d", blockSlot, commitment.Slot)
}

if blockSlot < commitment.Slot+protoParams.MinCommittableAge() {
if blockSlot < protoParams.MinCommittableAge() || commitment.Slot < protoParams.MinCommittableAge() {
return commitment, nil
}

commitmentSlot := commitment.Slot - protoParams.MinCommittableAge()
loadedCommitment, err := deps.Protocol.MainEngineInstance().Storage.Commitments().Load(commitmentSlot)
if err != nil {
return nil, ierrors.Wrapf(err, "error loading valid commitment of slot %d according to minCommittableAge from storage", commitmentSlot)
}

return loadedCommitment.Commitment(), nil
}

return commitment, nil
}
26 changes: 13 additions & 13 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@ require (
github.com/google/uuid v1.3.1
github.com/gorilla/websocket v1.5.0
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0
github.com/iotaledger/hive.go/ads v0.0.0-20231010083704-a2a91fb9e0ab
github.com/iotaledger/hive.go/app v0.0.0-20231010083704-a2a91fb9e0ab
github.com/iotaledger/hive.go/constraints v0.0.0-20231010083704-a2a91fb9e0ab
github.com/iotaledger/hive.go/core v1.0.0-rc.3.0.20231010083704-a2a91fb9e0ab
github.com/iotaledger/hive.go/crypto v0.0.0-20231010083704-a2a91fb9e0ab
github.com/iotaledger/hive.go/ds v0.0.0-20231010083704-a2a91fb9e0ab
github.com/iotaledger/hive.go/ierrors v0.0.0-20231010083704-a2a91fb9e0ab
github.com/iotaledger/hive.go/kvstore v0.0.0-20231010083704-a2a91fb9e0ab
github.com/iotaledger/hive.go/lo v0.0.0-20231010083704-a2a91fb9e0ab
github.com/iotaledger/hive.go/logger v0.0.0-20231010083704-a2a91fb9e0ab
github.com/iotaledger/hive.go/runtime v0.0.0-20231010083704-a2a91fb9e0ab
github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20231010083704-a2a91fb9e0ab
github.com/iotaledger/hive.go/stringify v0.0.0-20231010083704-a2a91fb9e0ab
github.com/iotaledger/hive.go/ads v0.0.0-20231010121205-23c1f3fcddd5
github.com/iotaledger/hive.go/app v0.0.0-20231010121205-23c1f3fcddd5
github.com/iotaledger/hive.go/constraints v0.0.0-20231010121205-23c1f3fcddd5
github.com/iotaledger/hive.go/core v1.0.0-rc.3.0.20231010121205-23c1f3fcddd5
github.com/iotaledger/hive.go/crypto v0.0.0-20231010121205-23c1f3fcddd5
github.com/iotaledger/hive.go/ds v0.0.0-20231010121205-23c1f3fcddd5
github.com/iotaledger/hive.go/ierrors v0.0.0-20231010121205-23c1f3fcddd5
github.com/iotaledger/hive.go/kvstore v0.0.0-20231010121205-23c1f3fcddd5
github.com/iotaledger/hive.go/lo v0.0.0-20231010121205-23c1f3fcddd5
github.com/iotaledger/hive.go/logger v0.0.0-20231010121205-23c1f3fcddd5
github.com/iotaledger/hive.go/runtime v0.0.0-20231010121205-23c1f3fcddd5
github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20231010121205-23c1f3fcddd5
github.com/iotaledger/hive.go/stringify v0.0.0-20231010121205-23c1f3fcddd5
github.com/iotaledger/inx-app v1.0.0-rc.3.0.20231005192108-08a985c2e217
github.com/iotaledger/inx/go v1.0.0-rc.2.0.20231005191759-16a3636128c4
github.com/iotaledger/iota.go/v4 v4.0.0-20231005184534-62e6761a7b7c
Expand Down
52 changes: 26 additions & 26 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -275,32 +275,32 @@ github.com/iancoleman/orderedmap v0.3.0/go.mod h1:XuLcCUkdL5owUCQeF2Ue9uuw1EptkJ
github.com/ianlancetaylor/demangle v0.0.0-20210905161508-09a460cdf81d/go.mod h1:aYm2/VgdVmcIU8iMfdMvDMsRAQjcfZSKFby6HOFvi/w=
github.com/iotaledger/grocksdb v1.7.5-0.20230220105546-5162e18885c7 h1:dTrD7X2PTNgli6EbS4tV9qu3QAm/kBU3XaYZV2xdzys=
github.com/iotaledger/grocksdb v1.7.5-0.20230220105546-5162e18885c7/go.mod h1:ZRdPu684P0fQ1z8sXz4dj9H5LWHhz4a9oCtvjunkSrw=
github.com/iotaledger/hive.go/ads v0.0.0-20231010083704-a2a91fb9e0ab h1:3U1ADSPHU9GahpWujnkwOlGxA+NMl9l0j3ch4ISH1S0=
github.com/iotaledger/hive.go/ads v0.0.0-20231010083704-a2a91fb9e0ab/go.mod h1:IAWZ/5It5P8B41mWyJXJVcG0vuikVRaTFKQnr2D2q+c=
github.com/iotaledger/hive.go/app v0.0.0-20231010083704-a2a91fb9e0ab h1:ePgcMl1XOXoF4kNfwMGn63GXZSihv+Z2t1GWLKqkGOw=
github.com/iotaledger/hive.go/app v0.0.0-20231010083704-a2a91fb9e0ab/go.mod h1:eiZgbcwTDZ7d9hEait2EAwAhixWhceW4MXmuVk2EcEw=
github.com/iotaledger/hive.go/constraints v0.0.0-20231010083704-a2a91fb9e0ab h1:u7wN87wrmlPbUpNZhHfNKN6HLLQdY/zICIiJgVCSBvM=
github.com/iotaledger/hive.go/constraints v0.0.0-20231010083704-a2a91fb9e0ab/go.mod h1:dOBOM2s4se3HcWefPe8sQLUalGXJ8yVXw58oK8jke3s=
github.com/iotaledger/hive.go/core v1.0.0-rc.3.0.20231010083704-a2a91fb9e0ab h1:u4h5GdvR1MTNZHYkLx8USCadbkMkISZyYXudH5qEhZQ=
github.com/iotaledger/hive.go/core v1.0.0-rc.3.0.20231010083704-a2a91fb9e0ab/go.mod h1:jn3TNmiNRIiQm/rS4VD+7wFHI2+UXABHvCA3PbQxBqI=
github.com/iotaledger/hive.go/crypto v0.0.0-20231010083704-a2a91fb9e0ab h1:0wGm1JPCBNK7h9WYtFZhSxmbhPmiBEzeeonUfJmVASE=
github.com/iotaledger/hive.go/crypto v0.0.0-20231010083704-a2a91fb9e0ab/go.mod h1:jP68na941d9uq7RtnA8aQ/FtIGRGz/51cU4uXrInQFU=
github.com/iotaledger/hive.go/ds v0.0.0-20231010083704-a2a91fb9e0ab h1:Wlv4bCfT6IZ3LD3jzHCgT00MdL0LR7kzhlW3zQohKKA=
github.com/iotaledger/hive.go/ds v0.0.0-20231010083704-a2a91fb9e0ab/go.mod h1:ZrqsjIJS2QCgGp7Ki+l4hWJQgzfBObUCemb5Upwlx18=
github.com/iotaledger/hive.go/ierrors v0.0.0-20231010083704-a2a91fb9e0ab h1:RMKlQlTpWSSfauU3KgNyv/8WGzTTx3G4KzFuLf1EhrM=
github.com/iotaledger/hive.go/ierrors v0.0.0-20231010083704-a2a91fb9e0ab/go.mod h1:HcE8B5lP96enc/OALTb2/rIIi+yOLouRoHOKRclKmC8=
github.com/iotaledger/hive.go/kvstore v0.0.0-20231010083704-a2a91fb9e0ab h1:50bOe5+XlIj0pPqcMNkOl+nf4BEITIhWuSr1j3fieLI=
github.com/iotaledger/hive.go/kvstore v0.0.0-20231010083704-a2a91fb9e0ab/go.mod h1:DeP4JF4N995LteD0+/o7NsW1bO5IXURIJ27A69Ca5+Y=
github.com/iotaledger/hive.go/lo v0.0.0-20231010083704-a2a91fb9e0ab h1:o9JT//S67PRsrEir1GSdlNz2hLYfG+6SDayxmJm+jKQ=
github.com/iotaledger/hive.go/lo v0.0.0-20231010083704-a2a91fb9e0ab/go.mod h1:4oKCdMEhHMLCudBz79kuvJmgSY/DhfVePNIyJhew/80=
github.com/iotaledger/hive.go/logger v0.0.0-20231010083704-a2a91fb9e0ab h1:AWU4PRv5No/ghKH02JY3/N9Xpv2he+byVLRd7DPHJGg=
github.com/iotaledger/hive.go/logger v0.0.0-20231010083704-a2a91fb9e0ab/go.mod h1:sxqWRdZ1OOxwkxVczuGcW034Mpt2vFh5ebJHO++ZYeI=
github.com/iotaledger/hive.go/runtime v0.0.0-20231010083704-a2a91fb9e0ab h1:ZE7MENkq9l8B+uIt1ulFfflDPnYX4Xxk6UYbzAPr8/U=
github.com/iotaledger/hive.go/runtime v0.0.0-20231010083704-a2a91fb9e0ab/go.mod h1:fXVyQ1MAwxe/EmjAnG8WcQqbzGk9EW/FsJ/n16H/f/w=
github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20231010083704-a2a91fb9e0ab h1:ebO3VhgcS2Dd8zBe+8Lizd8RoV00TUAm06tY0HGZmIE=
github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20231010083704-a2a91fb9e0ab/go.mod h1:IJgaaxbgKCsNat18jlJJEAxCY2oVYR3F30B+M4vJ89I=
github.com/iotaledger/hive.go/stringify v0.0.0-20231010083704-a2a91fb9e0ab h1:nDsUCc2/EPFspZcKk3T4HklhUeI+B5ed3W+HoTciYzA=
github.com/iotaledger/hive.go/stringify v0.0.0-20231010083704-a2a91fb9e0ab/go.mod h1:FTo/UWzNYgnQ082GI9QVM9HFDERqf9rw9RivNpqrnTs=
github.com/iotaledger/hive.go/ads v0.0.0-20231010121205-23c1f3fcddd5 h1:lbrYweNe+DB/kh7OYlogJMQfEDRpriyIgA+MmHmb01k=
github.com/iotaledger/hive.go/ads v0.0.0-20231010121205-23c1f3fcddd5/go.mod h1:IAWZ/5It5P8B41mWyJXJVcG0vuikVRaTFKQnr2D2q+c=
github.com/iotaledger/hive.go/app v0.0.0-20231010121205-23c1f3fcddd5 h1:P2BE6RylO7mlEtJSbNyuRz6OcJTNs0MZ0qFIN5lI3Kg=
github.com/iotaledger/hive.go/app v0.0.0-20231010121205-23c1f3fcddd5/go.mod h1:q2H/9TE6hvg6TKZI0YoxtbCdrf8O1sYBVjNT2Y3yAIU=
github.com/iotaledger/hive.go/constraints v0.0.0-20231010121205-23c1f3fcddd5 h1:AsgWEa8dpgF0JX3pc+nwaoQLlc5rKEoWAgrYdN1AIRE=
github.com/iotaledger/hive.go/constraints v0.0.0-20231010121205-23c1f3fcddd5/go.mod h1:dOBOM2s4se3HcWefPe8sQLUalGXJ8yVXw58oK8jke3s=
github.com/iotaledger/hive.go/core v1.0.0-rc.3.0.20231010121205-23c1f3fcddd5 h1:T/vnm1B2SFYWz7QiQsQq0AuoJCXKwW3hBCITudvh//c=
github.com/iotaledger/hive.go/core v1.0.0-rc.3.0.20231010121205-23c1f3fcddd5/go.mod h1:jn3TNmiNRIiQm/rS4VD+7wFHI2+UXABHvCA3PbQxBqI=
github.com/iotaledger/hive.go/crypto v0.0.0-20231010121205-23c1f3fcddd5 h1:8TgnDcl6gIqXqgTnx4wA3LZt8vwAsVfekcKlPK5WRNY=
github.com/iotaledger/hive.go/crypto v0.0.0-20231010121205-23c1f3fcddd5/go.mod h1:jP68na941d9uq7RtnA8aQ/FtIGRGz/51cU4uXrInQFU=
github.com/iotaledger/hive.go/ds v0.0.0-20231010121205-23c1f3fcddd5 h1:xyVUPe/tZtS3nkg8fU1GB1ZyUo7D32YfrY0XNA8GZhM=
github.com/iotaledger/hive.go/ds v0.0.0-20231010121205-23c1f3fcddd5/go.mod h1:ZrqsjIJS2QCgGp7Ki+l4hWJQgzfBObUCemb5Upwlx18=
github.com/iotaledger/hive.go/ierrors v0.0.0-20231010121205-23c1f3fcddd5 h1:Q8giZLqmIJRlcUS5x1TxVlS5X+iHgZ8zOq4GsK3YWnQ=
github.com/iotaledger/hive.go/ierrors v0.0.0-20231010121205-23c1f3fcddd5/go.mod h1:HcE8B5lP96enc/OALTb2/rIIi+yOLouRoHOKRclKmC8=
github.com/iotaledger/hive.go/kvstore v0.0.0-20231010121205-23c1f3fcddd5 h1:nI6LJ32saPs1c3HwA7V3T2jo3bh4+UuhBg1EsBK9N7k=
github.com/iotaledger/hive.go/kvstore v0.0.0-20231010121205-23c1f3fcddd5/go.mod h1:DeP4JF4N995LteD0+/o7NsW1bO5IXURIJ27A69Ca5+Y=
github.com/iotaledger/hive.go/lo v0.0.0-20231010121205-23c1f3fcddd5 h1:XVKwwjBJGOUuNzormIYJMWgqyscgusR5WtxA3rxql5g=
github.com/iotaledger/hive.go/lo v0.0.0-20231010121205-23c1f3fcddd5/go.mod h1:4oKCdMEhHMLCudBz79kuvJmgSY/DhfVePNIyJhew/80=
github.com/iotaledger/hive.go/logger v0.0.0-20231010121205-23c1f3fcddd5 h1:hp+Bstpyxgeci0eDnEp0CZDbavgwnhDHkBTCf/fBQv4=
github.com/iotaledger/hive.go/logger v0.0.0-20231010121205-23c1f3fcddd5/go.mod h1:sxqWRdZ1OOxwkxVczuGcW034Mpt2vFh5ebJHO++ZYeI=
github.com/iotaledger/hive.go/runtime v0.0.0-20231010121205-23c1f3fcddd5 h1:2TxlF+6APu1ZeImwny5EAwfe/n/JVlq+1NpzBybJnCU=
github.com/iotaledger/hive.go/runtime v0.0.0-20231010121205-23c1f3fcddd5/go.mod h1:fXVyQ1MAwxe/EmjAnG8WcQqbzGk9EW/FsJ/n16H/f/w=
github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20231010121205-23c1f3fcddd5 h1:SV8s8rZIHj2yhGRj8vX2AyA3MOKOWPk4rKiz0mJ/4mw=
github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20231010121205-23c1f3fcddd5/go.mod h1:IJgaaxbgKCsNat18jlJJEAxCY2oVYR3F30B+M4vJ89I=
github.com/iotaledger/hive.go/stringify v0.0.0-20231010121205-23c1f3fcddd5 h1:zD60l2AnJmYLfjwhytAILQLZbkgmOPeg7IvFSY6Uv1E=
github.com/iotaledger/hive.go/stringify v0.0.0-20231010121205-23c1f3fcddd5/go.mod h1:FTo/UWzNYgnQ082GI9QVM9HFDERqf9rw9RivNpqrnTs=
github.com/iotaledger/inx-app v1.0.0-rc.3.0.20231005192108-08a985c2e217 h1:DdrsW+J04ne2j6bjU1yVu+4C4CjpjGFYDEVMtmg0zyA=
github.com/iotaledger/inx-app v1.0.0-rc.3.0.20231005192108-08a985c2e217/go.mod h1:OWZGwG4q2Ypd/D6LJicgdPXtw9yYkhaZEvJFhkIm2Ck=
github.com/iotaledger/inx/go v1.0.0-rc.2.0.20231005191759-16a3636128c4 h1:uI+sZeZnGzAkM34JDbZBfyRIXrkkd1L0w8qVJ5rGy3E=
Expand Down
15 changes: 15 additions & 0 deletions pkg/model/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,17 @@ func BlockFromBytes(data []byte, apiProvider iotago.APIProvider) (*Block, error)
return newBlock(blockID, iotaBlock, data)
}

func BlockFromBytesFunc(apiProvider iotago.APIProvider) func(data []byte) (*Block, int, error) {
return func(data []byte) (*Block, int, error) {
block, err := BlockFromBytes(data, apiProvider)
if err != nil {
return nil, 0, err
}

return block, len(data), nil
}
}

func (blk *Block) ID() iotago.BlockID {
return blk.blockID
}
Expand All @@ -70,6 +81,10 @@ func (blk *Block) Data() []byte {
return blk.data
}

func (blk *Block) Bytes() ([]byte, error) {
return blk.data, nil
}

func (blk *Block) ProtocolBlock() *iotago.ProtocolBlock {
return blk.protocolBlock
}
Expand Down
Loading
Loading