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

Rename Block Types #473

Merged
merged 10 commits into from
Oct 30, 2023
20 changes: 10 additions & 10 deletions components/dashboard/explorer_routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,24 +105,24 @@ func createExplorerBlock(block *model.Block, cachedBlock *blocks.Block, metadata
var payloadJSON []byte
basicBlock, isBasic := block.BasicBlock()
if isBasic {
payloadJSON, err = lo.PanicOnErr(deps.Protocol.APIForVersion(iotaBlk.ProtocolVersion)).JSONEncode(basicBlock.Payload)
payloadJSON, err = lo.PanicOnErr(deps.Protocol.APIForVersion(iotaBlk.Header.ProtocolVersion)).JSONEncode(basicBlock.Payload)
if err != nil {
return nil
}
}

t := &ExplorerBlock{
ID: block.ID().ToHex(),
NetworkID: iotaBlk.NetworkID,
ProtocolVersion: iotaBlk.ProtocolVersion,
NetworkID: iotaBlk.Header.NetworkID,
ProtocolVersion: iotaBlk.Header.ProtocolVersion,
SolidificationTimestamp: 0,
IssuanceTimestamp: iotaBlk.IssuingTime.Unix(),
IssuanceTimestamp: iotaBlk.Header.IssuingTime.Unix(),
SequenceNumber: 0,
IssuerID: iotaBlk.IssuerID.ToHex(),
IssuerID: iotaBlk.Header.IssuerID.ToHex(),
Signature: hexutil.EncodeHex(sigBytes),
StrongParents: iotaBlk.Block.StrongParentIDs().ToHex(),
WeakParents: iotaBlk.Block.WeakParentIDs().ToHex(),
ShallowLikedParents: iotaBlk.Block.ShallowLikeParentIDs().ToHex(),
StrongParents: iotaBlk.Body.StrongParentIDs().ToHex(),
WeakParents: iotaBlk.Body.WeakParentIDs().ToHex(),
ShallowLikedParents: iotaBlk.Body.ShallowLikeParentIDs().ToHex(),

PayloadType: func() iotago.PayloadType {
if isBasic && basicBlock.Payload != nil {
Expand Down Expand Up @@ -152,8 +152,8 @@ func createExplorerBlock(block *model.Block, cachedBlock *blocks.Block, metadata

return ""
}(),
CommitmentID: iotaBlk.SlotCommitmentID.ToHex(),
LatestConfirmedSlot: uint64(iotaBlk.LatestFinalizedSlot),
CommitmentID: iotaBlk.Header.SlotCommitmentID.ToHex(),
LatestConfirmedSlot: uint64(iotaBlk.Header.LatestFinalizedSlot),
}

if cachedBlock != nil {
Expand Down
6 changes: 3 additions & 3 deletions components/dashboard/visualizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ func sendVertex(blk *blocks.Block, confirmed bool) {

broadcastWsBlock(&wsblk{MsgTypeVertex, &vertex{
ID: blk.ID().ToHex(),
StrongParents: blk.ProtocolBlock().Block.StrongParentIDs().ToHex(),
WeakParents: blk.ProtocolBlock().Block.WeakParentIDs().ToHex(),
ShallowLikedParents: blk.ProtocolBlock().Block.ShallowLikeParentIDs().ToHex(),
StrongParents: blk.ProtocolBlock().Body.StrongParentIDs().ToHex(),
WeakParents: blk.ProtocolBlock().Body.WeakParentIDs().ToHex(),
ShallowLikedParents: blk.ProtocolBlock().Body.ShallowLikeParentIDs().ToHex(),
IsConfirmed: confirmed,
IsTx: isTx,
IsTxAccepted: func() bool {
Expand Down
4 changes: 2 additions & 2 deletions components/debugapi/debug_models.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ func BlockMetadataResponseFromBlock(block *blocks.Block) *BlockMetadataResponse
return &BlockMetadataResponse{
BlockID: block.ID().String(),
StrongParents: lo.Map(block.StrongParents(), func(blockID iotago.BlockID) string { return blockID.String() }),
WeakParents: lo.Map(block.ProtocolBlock().Block.WeakParentIDs(), func(blockID iotago.BlockID) string { return blockID.String() }),
ShallowLikeParents: lo.Map(block.ProtocolBlock().Block.ShallowLikeParentIDs(), func(blockID iotago.BlockID) string { return blockID.String() }),
WeakParents: lo.Map(block.ProtocolBlock().Body.WeakParentIDs(), func(blockID iotago.BlockID) string { return blockID.String() }),
ShallowLikeParents: lo.Map(block.ProtocolBlock().Body.ShallowLikeParentIDs(), func(blockID iotago.BlockID) string { return blockID.String() }),
Solid: block.IsSolid(),
Invalid: block.IsInvalid(),
Booked: block.IsBooked(),
Expand Down
2 changes: 1 addition & 1 deletion components/inx/server_blocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func (s *Server) SubmitBlock(ctx context.Context, rawBlock *inx.RawBlock) (*inx.
return s.attachBlock(ctx, block)
}

func (s *Server) attachBlock(ctx context.Context, block *iotago.ProtocolBlock) (*inx.BlockId, error) {
func (s *Server) attachBlock(ctx context.Context, block *iotago.Block) (*inx.BlockId, error) {
mergedCtx, mergedCtxCancel := contextutils.MergeContexts(ctx, Component.Daemon().ContextStopped())
defer mergedCtxCancel()

Expand Down
2 changes: 1 addition & 1 deletion components/metrics/metrics_accounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ var AccountMetrics = collector.NewCollection(accountNamespace,
collector.WithPruningDelay(10*time.Minute),
collector.WithInitFunc(func() {
deps.Protocol.Events.Engine.BlockGadget.BlockAccepted.Hook(func(block *blocks.Block) {
accountData, exists, _ := deps.Protocol.MainEngineInstance().Ledger.Account(block.ProtocolBlock().IssuerID, deps.Protocol.MainEngineInstance().SyncManager.LatestCommitment().Slot())
accountData, exists, _ := deps.Protocol.MainEngineInstance().Ledger.Account(block.ProtocolBlock().Header.IssuerID, deps.Protocol.MainEngineInstance().SyncManager.LatestCommitment().Slot())
if exists {
deps.Collector.Update(accountNamespace, credits, float64(accountData.Credits.Value), accountData.ID.String())
}
Expand Down
30 changes: 15 additions & 15 deletions components/metrics/metrics_scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,22 @@ var SchedulerMetrics = collector.NewCollection(schedulerNamespace,
collector.WithHelp("Current size of each node's queue (in work units)."),
collector.WithInitFunc(func() {
deps.Protocol.Events.Engine.Scheduler.BlockEnqueued.Hook(func(block *blocks.Block) {
deps.Collector.Update(schedulerNamespace, queueSizePerNodeWork, float64(deps.Protocol.MainEngineInstance().Scheduler.IssuerQueueWork(block.ProtocolBlock().IssuerID)), block.ProtocolBlock().IssuerID.String())
deps.Collector.Update(schedulerNamespace, queueSizePerNodeWork, float64(deps.Protocol.MainEngineInstance().Scheduler.IssuerQueueWork(block.ProtocolBlock().Header.IssuerID)), block.ProtocolBlock().Header.IssuerID.String())

}, event.WithWorkerPool(Component.WorkerPool))

deps.Protocol.Events.Engine.Scheduler.BlockSkipped.Hook(func(block *blocks.Block) {
deps.Collector.Update(schedulerNamespace, queueSizePerNodeWork, float64(deps.Protocol.MainEngineInstance().Scheduler.IssuerQueueWork(block.ProtocolBlock().IssuerID)), block.ProtocolBlock().IssuerID.String())
deps.Collector.Update(schedulerNamespace, queueSizePerNodeWork, float64(deps.Protocol.MainEngineInstance().Scheduler.IssuerQueueWork(block.ProtocolBlock().Header.IssuerID)), block.ProtocolBlock().Header.IssuerID.String())

}, event.WithWorkerPool(Component.WorkerPool))

deps.Protocol.Events.Engine.Scheduler.BlockDropped.Hook(func(block *blocks.Block, _ error) {
deps.Collector.Update(schedulerNamespace, queueSizePerNodeWork, float64(deps.Protocol.MainEngineInstance().Scheduler.IssuerQueueWork(block.ProtocolBlock().IssuerID)), block.ProtocolBlock().IssuerID.String())
deps.Collector.Update(schedulerNamespace, queueSizePerNodeWork, float64(deps.Protocol.MainEngineInstance().Scheduler.IssuerQueueWork(block.ProtocolBlock().Header.IssuerID)), block.ProtocolBlock().Header.IssuerID.String())

}, event.WithWorkerPool(Component.WorkerPool))

deps.Protocol.Events.Engine.Scheduler.BlockScheduled.Hook(func(block *blocks.Block) {
deps.Collector.Update(schedulerNamespace, queueSizePerNodeWork, float64(deps.Protocol.MainEngineInstance().Scheduler.IssuerQueueWork(block.ProtocolBlock().IssuerID)), block.ProtocolBlock().IssuerID.String())
deps.Collector.Update(schedulerNamespace, queueSizePerNodeWork, float64(deps.Protocol.MainEngineInstance().Scheduler.IssuerQueueWork(block.ProtocolBlock().Header.IssuerID)), block.ProtocolBlock().Header.IssuerID.String())

}, event.WithWorkerPool(Component.WorkerPool))
}),
Expand All @@ -66,25 +66,25 @@ var SchedulerMetrics = collector.NewCollection(schedulerNamespace,
collector.WithInitFunc(func() {
deps.Protocol.Events.Engine.Scheduler.BlockEnqueued.Hook(func(block *blocks.Block) {
if _, isBasic := block.BasicBlock(); isBasic {
deps.Collector.Update(schedulerNamespace, queueSizePerNodeCount, float64(deps.Protocol.MainEngineInstance().Scheduler.IssuerQueueBlockCount(block.ProtocolBlock().IssuerID)), block.ProtocolBlock().IssuerID.String())
deps.Collector.Update(schedulerNamespace, queueSizePerNodeCount, float64(deps.Protocol.MainEngineInstance().Scheduler.IssuerQueueBlockCount(block.ProtocolBlock().Header.IssuerID)), block.ProtocolBlock().Header.IssuerID.String())
}
}, event.WithWorkerPool(Component.WorkerPool))

deps.Protocol.Events.Engine.Scheduler.BlockSkipped.Hook(func(block *blocks.Block) {
if _, isBasic := block.BasicBlock(); isBasic {
deps.Collector.Update(schedulerNamespace, queueSizePerNodeCount, float64(deps.Protocol.MainEngineInstance().Scheduler.IssuerQueueBlockCount(block.ProtocolBlock().IssuerID)), block.ProtocolBlock().IssuerID.String())
deps.Collector.Update(schedulerNamespace, queueSizePerNodeCount, float64(deps.Protocol.MainEngineInstance().Scheduler.IssuerQueueBlockCount(block.ProtocolBlock().Header.IssuerID)), block.ProtocolBlock().Header.IssuerID.String())
}
}, event.WithWorkerPool(Component.WorkerPool))

deps.Protocol.Events.Engine.Scheduler.BlockDropped.Hook(func(block *blocks.Block, _ error) {
if _, isBasic := block.BasicBlock(); isBasic {
deps.Collector.Update(schedulerNamespace, queueSizePerNodeCount, float64(deps.Protocol.MainEngineInstance().Scheduler.IssuerQueueBlockCount(block.ProtocolBlock().IssuerID)), block.ProtocolBlock().IssuerID.String())
deps.Collector.Update(schedulerNamespace, queueSizePerNodeCount, float64(deps.Protocol.MainEngineInstance().Scheduler.IssuerQueueBlockCount(block.ProtocolBlock().Header.IssuerID)), block.ProtocolBlock().Header.IssuerID.String())
}
}, event.WithWorkerPool(Component.WorkerPool))

deps.Protocol.Events.Engine.Scheduler.BlockScheduled.Hook(func(block *blocks.Block) {
if _, isBasic := block.BasicBlock(); isBasic {
deps.Collector.Update(schedulerNamespace, queueSizePerNodeCount, float64(deps.Protocol.MainEngineInstance().Scheduler.IssuerQueueBlockCount(block.ProtocolBlock().IssuerID)), block.ProtocolBlock().IssuerID.String())
deps.Collector.Update(schedulerNamespace, queueSizePerNodeCount, float64(deps.Protocol.MainEngineInstance().Scheduler.IssuerQueueBlockCount(block.ProtocolBlock().Header.IssuerID)), block.ProtocolBlock().Header.IssuerID.String())
}
}, event.WithWorkerPool(Component.WorkerPool))
}),
Expand All @@ -97,25 +97,25 @@ var SchedulerMetrics = collector.NewCollection(schedulerNamespace,
collector.WithInitFunc(func() {
deps.Protocol.Events.Engine.Scheduler.BlockEnqueued.Hook(func(block *blocks.Block) {
if _, isValidation := block.ValidationBlock(); isValidation {
deps.Collector.Update(schedulerNamespace, validatorQueueSizePerNodeCount, float64(deps.Protocol.MainEngineInstance().Scheduler.ValidatorQueueBlockCount(block.ProtocolBlock().IssuerID)), block.ProtocolBlock().IssuerID.String())
deps.Collector.Update(schedulerNamespace, validatorQueueSizePerNodeCount, float64(deps.Protocol.MainEngineInstance().Scheduler.ValidatorQueueBlockCount(block.ProtocolBlock().Header.IssuerID)), block.ProtocolBlock().Header.IssuerID.String())
}
}, event.WithWorkerPool(Component.WorkerPool))

deps.Protocol.Events.Engine.Scheduler.BlockSkipped.Hook(func(block *blocks.Block) {
if _, isValidation := block.ValidationBlock(); isValidation {
deps.Collector.Update(schedulerNamespace, validatorQueueSizePerNodeCount, float64(deps.Protocol.MainEngineInstance().Scheduler.ValidatorQueueBlockCount(block.ProtocolBlock().IssuerID)), block.ProtocolBlock().IssuerID.String())
deps.Collector.Update(schedulerNamespace, validatorQueueSizePerNodeCount, float64(deps.Protocol.MainEngineInstance().Scheduler.ValidatorQueueBlockCount(block.ProtocolBlock().Header.IssuerID)), block.ProtocolBlock().Header.IssuerID.String())
}
}, event.WithWorkerPool(Component.WorkerPool))

deps.Protocol.Events.Engine.Scheduler.BlockDropped.Hook(func(block *blocks.Block, _ error) {
if _, isValidation := block.ValidationBlock(); isValidation {
deps.Collector.Update(schedulerNamespace, validatorQueueSizePerNodeCount, float64(deps.Protocol.MainEngineInstance().Scheduler.ValidatorQueueBlockCount(block.ProtocolBlock().IssuerID)), block.ProtocolBlock().IssuerID.String())
deps.Collector.Update(schedulerNamespace, validatorQueueSizePerNodeCount, float64(deps.Protocol.MainEngineInstance().Scheduler.ValidatorQueueBlockCount(block.ProtocolBlock().Header.IssuerID)), block.ProtocolBlock().Header.IssuerID.String())
}
}, event.WithWorkerPool(Component.WorkerPool))

deps.Protocol.Events.Engine.Scheduler.BlockScheduled.Hook(func(block *blocks.Block) {
if _, isValidation := block.ValidationBlock(); isValidation {
deps.Collector.Update(schedulerNamespace, validatorQueueSizePerNodeCount, float64(deps.Protocol.MainEngineInstance().Scheduler.ValidatorQueueBlockCount(block.ProtocolBlock().IssuerID)), block.ProtocolBlock().IssuerID.String())
deps.Collector.Update(schedulerNamespace, validatorQueueSizePerNodeCount, float64(deps.Protocol.MainEngineInstance().Scheduler.ValidatorQueueBlockCount(block.ProtocolBlock().Header.IssuerID)), block.ProtocolBlock().Header.IssuerID.String())
}
}, event.WithWorkerPool(Component.WorkerPool))
}),
Expand All @@ -127,14 +127,14 @@ var SchedulerMetrics = collector.NewCollection(schedulerNamespace,
collector.WithHelp("Current amount of mana of each issuer in the queue."),
collector.WithInitFunc(func() {
deps.Protocol.Events.Engine.Scheduler.BlockEnqueued.Hook(func(block *blocks.Block) {
mana, err := deps.Protocol.MainEngineInstance().Ledger.ManaManager().GetManaOnAccount(block.ProtocolBlock().IssuerID, block.SlotCommitmentID().Slot())
mana, err := deps.Protocol.MainEngineInstance().Ledger.ManaManager().GetManaOnAccount(block.ProtocolBlock().Header.IssuerID, block.SlotCommitmentID().Slot())
if err != nil {
deps.Protocol.MainEngineInstance().ErrorHandler("metrics")(ierrors.Wrapf(err, "failed to retrieve mana on account %s for slot %d", block.ProtocolBlock().IssuerID, block.SlotCommitmentID().Slot()))
deps.Protocol.MainEngineInstance().ErrorHandler("metrics")(ierrors.Wrapf(err, "failed to retrieve mana on account %s for slot %d", block.ProtocolBlock().Header.IssuerID, block.SlotCommitmentID().Slot()))

return
}

deps.Collector.Update(schedulerNamespace, manaAmountPerNode, float64(mana), block.ProtocolBlock().IssuerID.String())
deps.Collector.Update(schedulerNamespace, manaAmountPerNode, float64(mana), block.ProtocolBlock().Header.IssuerID.String())
}, event.WithWorkerPool(Component.WorkerPool))
}),
)),
Expand Down
2 changes: 1 addition & 1 deletion components/restapi/core/blocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func blockIssuanceBySlot(slotIndex iotago.SlotIndex) (*apimodels.IssuanceBlockHe
}

func sendBlock(c echo.Context) (*apimodels.BlockCreatedResponse, error) {
iotaBlock, err := httpserver.ParseRequestByHeader(c, deps.Protocol.CommittedAPI(), iotago.ProtocolBlockFromBytes(deps.Protocol))
iotaBlock, err := httpserver.ParseRequestByHeader(c, deps.Protocol.CommittedAPI(), iotago.BlockFromBytes(deps.Protocol))
if err != nil {
return nil, ierrors.Wrapf(err, "failed to parse iotablock")
}
Expand Down
2 changes: 1 addition & 1 deletion components/validator/issuer.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func issueValidatorBlock(ctx context.Context) {
return
}

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)
Component.LogDebugf("Issued validator block: %s - commitment %s %d - latest finalized slot %d", modelBlock.ID(), modelBlock.ProtocolBlock().Header.SlotCommitmentID, modelBlock.ProtocolBlock().Header.SlotCommitmentID.Slot(), modelBlock.ProtocolBlock().Header.LatestFinalizedSlot)
}

func reviveChain(issuingTime time.Time) (*iotago.Commitment, iotago.BlockID, error) {
Expand Down
18 changes: 9 additions & 9 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@ require (
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0
github.com/iotaledger/hive.go/ads v0.0.0-20231020115340-13da292c580b
github.com/iotaledger/hive.go/app v0.0.0-20231020115340-13da292c580b
github.com/iotaledger/hive.go/constraints v0.0.0-20231020115340-13da292c580b
github.com/iotaledger/hive.go/constraints v0.0.0-20231027195901-620bd7470e42
github.com/iotaledger/hive.go/core v1.0.0-rc.3.0.20231020115340-13da292c580b
github.com/iotaledger/hive.go/crypto v0.0.0-20231020115340-13da292c580b
github.com/iotaledger/hive.go/crypto v0.0.0-20231027195901-620bd7470e42
github.com/iotaledger/hive.go/ds v0.0.0-20231020115340-13da292c580b
github.com/iotaledger/hive.go/ierrors v0.0.0-20231020115340-13da292c580b
github.com/iotaledger/hive.go/ierrors v0.0.0-20231027195901-620bd7470e42
github.com/iotaledger/hive.go/kvstore v0.0.0-20231020115340-13da292c580b
github.com/iotaledger/hive.go/lo v0.0.0-20231020115340-13da292c580b
github.com/iotaledger/hive.go/lo v0.0.0-20231027195901-620bd7470e42
github.com/iotaledger/hive.go/logger v0.0.0-20231020115340-13da292c580b
github.com/iotaledger/hive.go/runtime v0.0.0-20231020115340-13da292c580b
github.com/iotaledger/hive.go/runtime v0.0.0-20231027195901-620bd7470e42
github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20231020115340-13da292c580b
github.com/iotaledger/hive.go/stringify v0.0.0-20231020115340-13da292c580b
github.com/iotaledger/inx-app v1.0.0-rc.3.0.20231026154618-820b8eaed2cc
github.com/iotaledger/inx/go v1.0.0-rc.2.0.20231026154523-9ee0c47a283a
github.com/iotaledger/iota.go/v4 v4.0.0-20231026154111-efd63ff4f03d
github.com/iotaledger/hive.go/stringify v0.0.0-20231027195901-620bd7470e42
github.com/iotaledger/inx-app v1.0.0-rc.3.0.20231028104239-869296c43f26
github.com/iotaledger/inx/go v1.0.0-rc.2.0.20231028104044-69b02af0058d
github.com/iotaledger/iota.go/v4 v4.0.0-20231028103644-b834fd54b02a
github.com/labstack/echo/v4 v4.11.2
github.com/labstack/gommon v0.4.0
github.com/libp2p/go-libp2p v0.31.0
Expand Down
Loading
Loading