From 6aa20fc839351d9b8d75cb9a1aef7c9bd07abfef Mon Sep 17 00:00:00 2001 From: Dhruba Basu <7675102+dhrubabasu@users.noreply.github.com> Date: Mon, 4 Dec 2023 17:32:07 -0500 Subject: [PATCH] `vms/platformvm`: Initialize txs in `Transactions` field for `BanffProposalBlock` (#2419) --- vms/platformvm/block/proposal_block.go | 20 ++++++++++++++++++++ vms/platformvm/block/standard_block.go | 2 +- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/vms/platformvm/block/proposal_block.go b/vms/platformvm/block/proposal_block.go index 05e23b649949..eaea68e9ce55 100644 --- a/vms/platformvm/block/proposal_block.go +++ b/vms/platformvm/block/proposal_block.go @@ -28,6 +28,18 @@ type BanffProposalBlock struct { ApricotProposalBlock `serialize:"true"` } +func (b *BanffProposalBlock) initialize(bytes []byte) error { + if err := b.ApricotProposalBlock.initialize(bytes); err != nil { + return err + } + for _, tx := range b.Transactions { + if err := tx.Initialize(txs.Codec); err != nil { + return fmt.Errorf("failed to initialize tx: %w", err) + } + } + return nil +} + func (b *BanffProposalBlock) InitCtx(ctx *snow.Context) { for _, tx := range b.Transactions { tx.Unsigned.InitCtx(ctx) @@ -39,6 +51,14 @@ func (b *BanffProposalBlock) Timestamp() time.Time { return time.Unix(int64(b.Time), 0) } +func (b *BanffProposalBlock) Txs() []*txs.Tx { + l := len(b.Transactions) + txs := make([]*txs.Tx, l+1) + copy(txs, b.Transactions) + txs[l] = b.Tx + return txs +} + func (b *BanffProposalBlock) Visit(v Visitor) error { return v.BanffProposalBlock(b) } diff --git a/vms/platformvm/block/standard_block.go b/vms/platformvm/block/standard_block.go index a088a9eab696..a3a7ee6fed39 100644 --- a/vms/platformvm/block/standard_block.go +++ b/vms/platformvm/block/standard_block.go @@ -58,7 +58,7 @@ func (b *ApricotStandardBlock) initialize(bytes []byte) error { b.CommonBlock.initialize(bytes) for _, tx := range b.Transactions { if err := tx.Initialize(txs.Codec); err != nil { - return fmt.Errorf("failed to sign block: %w", err) + return fmt.Errorf("failed to initialize tx: %w", err) } } return nil