Skip to content

Commit 1340cce

Browse files
Remove pre-Durango block building logic and verification (#2823)
1 parent 67b1aa0 commit 1340cce

File tree

3 files changed

+19
-58
lines changed

3 files changed

+19
-58
lines changed

vms/platformvm/block/builder/builder.go

+13-30
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,19 @@ func buildBlock(
263263
forceAdvanceTime bool,
264264
parentState state.Chain,
265265
) (block.Block, error) {
266+
blockTxs, err := packBlockTxs(
267+
parentID,
268+
parentState,
269+
builder.Mempool,
270+
builder.txExecutorBackend,
271+
builder.blkManager,
272+
timestamp,
273+
targetBlockSize,
274+
)
275+
if err != nil {
276+
return nil, fmt.Errorf("failed to pack block txs: %w", err)
277+
}
278+
266279
// Try rewarding stakers whose staking period ends at the new chain time.
267280
// This is done first to prioritize advancing the timestamp as quickly as
268281
// possible.
@@ -276,23 +289,6 @@ func buildBlock(
276289
return nil, fmt.Errorf("could not build tx to reward staker: %w", err)
277290
}
278291

279-
var blockTxs []*txs.Tx
280-
// TODO: Cleanup post-Durango
281-
if builder.txExecutorBackend.Config.IsDurangoActivated(timestamp) {
282-
blockTxs, err = packBlockTxs(
283-
parentID,
284-
parentState,
285-
builder.Mempool,
286-
builder.txExecutorBackend,
287-
builder.blkManager,
288-
timestamp,
289-
targetBlockSize,
290-
)
291-
if err != nil {
292-
return nil, fmt.Errorf("failed to pack block txs: %w", err)
293-
}
294-
}
295-
296292
return block.NewBanffProposalBlock(
297293
timestamp,
298294
parentID,
@@ -302,19 +298,6 @@ func buildBlock(
302298
)
303299
}
304300

305-
blockTxs, err := packBlockTxs(
306-
parentID,
307-
parentState,
308-
builder.Mempool,
309-
builder.txExecutorBackend,
310-
builder.blkManager,
311-
timestamp,
312-
targetBlockSize,
313-
)
314-
if err != nil {
315-
return nil, fmt.Errorf("failed to pack block txs: %w", err)
316-
}
317-
318301
// If there is no reason to build a block, don't.
319302
if len(blockTxs) == 0 && !forceAdvanceTime {
320303
builder.txExecutorBackend.Ctx.Log.Debug("no pending txs to issue into a block")

vms/platformvm/block/executor/proposal_block_test.go

-17
Original file line numberDiff line numberDiff line change
@@ -334,23 +334,6 @@ func TestBanffProposalBlockTimeVerification(t *testing.T) {
334334
require.ErrorIs(err, executor.ErrAdvanceTimeTxIssuedAfterBanff)
335335
}
336336

337-
{
338-
// include too many transactions
339-
statelessProposalBlock, err := block.NewBanffProposalBlock(
340-
nextStakerTime,
341-
parentID,
342-
banffParentBlk.Height()+1,
343-
blkTx,
344-
[]*txs.Tx{},
345-
)
346-
require.NoError(err)
347-
348-
statelessProposalBlock.Transactions = []*txs.Tx{blkTx}
349-
block := env.blkManager.NewBlock(statelessProposalBlock)
350-
err = block.Verify(context.Background())
351-
require.ErrorIs(err, errBanffProposalBlockWithMultipleTransactions)
352-
}
353-
354337
{
355338
// valid
356339
statelessProposalBlock, err := block.NewBanffProposalBlock(

vms/platformvm/block/executor/verifier.go

+6-11
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,11 @@ var (
2222

2323
ErrConflictingBlockTxs = errors.New("block contains conflicting transactions")
2424

25-
errApricotBlockIssuedAfterFork = errors.New("apricot block issued after fork")
26-
errBanffProposalBlockWithMultipleTransactions = errors.New("BanffProposalBlock contains multiple transactions")
27-
errBanffStandardBlockWithoutChanges = errors.New("BanffStandardBlock performs no state changes")
28-
errIncorrectBlockHeight = errors.New("incorrect block height")
29-
errChildBlockEarlierThanParent = errors.New("proposed timestamp before current chain time")
30-
errOptionBlockTimestampNotMatchingParent = errors.New("option block proposed timestamp not matching parent block one")
25+
errApricotBlockIssuedAfterFork = errors.New("apricot block issued after fork")
26+
errBanffStandardBlockWithoutChanges = errors.New("BanffStandardBlock performs no state changes")
27+
errIncorrectBlockHeight = errors.New("incorrect block height")
28+
errChildBlockEarlierThanParent = errors.New("proposed timestamp before current chain time")
29+
errOptionBlockTimestampNotMatchingParent = errors.New("option block proposed timestamp not matching parent block one")
3130
)
3231

3332
// verifier handles the logic for verifying a block.
@@ -51,11 +50,6 @@ func (v *verifier) BanffCommitBlock(b *block.BanffCommitBlock) error {
5150
}
5251

5352
func (v *verifier) BanffProposalBlock(b *block.BanffProposalBlock) error {
54-
nextChainTime := b.Timestamp()
55-
if !v.txExecutorBackend.Config.IsDurangoActivated(nextChainTime) && len(b.Transactions) != 0 {
56-
return errBanffProposalBlockWithMultipleTransactions
57-
}
58-
5953
if err := v.banffNonOptionBlock(b); err != nil {
6054
return err
6155
}
@@ -67,6 +61,7 @@ func (v *verifier) BanffProposalBlock(b *block.BanffProposalBlock) error {
6761
}
6862

6963
// Advance the time to [nextChainTime].
64+
nextChainTime := b.Timestamp()
7065
if _, err := executor.AdvanceTimeTo(v.txExecutorBackend, onDecisionState, nextChainTime); err != nil {
7166
return err
7267
}

0 commit comments

Comments
 (0)