Skip to content

Commit

Permalink
Merge branch 'master' into remove-min-peer-error
Browse files Browse the repository at this point in the history
  • Loading branch information
sukantoraymond authored Oct 11, 2024
2 parents e3d46e1 + a7fe93b commit a7ef178
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 18 deletions.
7 changes: 5 additions & 2 deletions tests/fixture/bootstrapmonitor/e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,15 +234,18 @@ func buildImage(tc tests.TestContext, imageName string, forceNewHash bool, scrip
repoRoot, err := e2e.GetRepoRootPath(repoRelativePath)
require.NoError(err)

var args []string
args := []string{
"-x", // Ensure script output to aid in debugging
filepath.Join(repoRoot, "scripts", scriptName),
}
if forceNewHash {
// Ensure the build results in a new image hash by preventing use of a cached final stage
args = append(args, "--no-cache-filter", "execution")
}

cmd := exec.CommandContext(
tc.DefaultContext(),
filepath.Join(repoRoot, "scripts", scriptName),
"bash",
args...,
) // #nosec G204
cmd.Env = append(os.Environ(),
Expand Down
56 changes: 42 additions & 14 deletions vms/platformvm/block/executor/verifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ func (v *verifier) BanffProposalBlock(b *block.BanffProposalBlock) error {
}

return v.proposalBlock(
&b.ApricotProposalBlock,
b,
b.Tx,
onDecisionState,
onCommitState,
onAbortState,
Expand Down Expand Up @@ -129,7 +130,12 @@ func (v *verifier) BanffStandardBlock(b *block.BanffStandardBlock) error {
}

feeCalculator := state.PickFeeCalculator(v.txExecutorBackend.Config, onAcceptState)
return v.standardBlock(&b.ApricotStandardBlock, feeCalculator, onAcceptState)
return v.standardBlock(
b,
b.Transactions,
feeCalculator,
onAcceptState,
)
}

func (v *verifier) ApricotAbortBlock(b *block.ApricotAbortBlock) error {
Expand Down Expand Up @@ -165,7 +171,17 @@ func (v *verifier) ApricotProposalBlock(b *block.ApricotProposalBlock) error {
timestamp = onCommitState.GetTimestamp() // Equal to parent timestamp
feeCalculator = state.NewStaticFeeCalculator(v.txExecutorBackend.Config, timestamp)
)
return v.proposalBlock(b, nil, onCommitState, onAbortState, feeCalculator, nil, nil, nil)
return v.proposalBlock(
b,
b.Tx,
nil,
onCommitState,
onAbortState,
feeCalculator,
nil,
nil,
nil,
)
}

func (v *verifier) ApricotStandardBlock(b *block.ApricotStandardBlock) error {
Expand All @@ -183,7 +199,12 @@ func (v *verifier) ApricotStandardBlock(b *block.ApricotStandardBlock) error {
timestamp = onAcceptState.GetTimestamp() // Equal to parent timestamp
feeCalculator = state.NewStaticFeeCalculator(v.txExecutorBackend.Config, timestamp)
)
return v.standardBlock(b, feeCalculator, onAcceptState)
return v.standardBlock(
b,
b.Transactions,
feeCalculator,
onAcceptState,
)
}

func (v *verifier) ApricotAtomicBlock(b *block.ApricotAtomicBlock) error {
Expand Down Expand Up @@ -360,7 +381,8 @@ func (v *verifier) commitBlock(b block.Block) error {

// proposalBlock populates the state of this block if [nil] is returned
func (v *verifier) proposalBlock(
b *block.ApricotProposalBlock,
b block.Block,
tx *txs.Tx,
onDecisionState state.Diff,
onCommitState state.Diff,
onAbortState state.Diff,
Expand All @@ -374,19 +396,19 @@ func (v *verifier) proposalBlock(
OnAbortState: onAbortState,
Backend: v.txExecutorBackend,
FeeCalculator: feeCalculator,
Tx: b.Tx,
Tx: tx,
}

if err := b.Tx.Unsigned.Visit(&txExecutor); err != nil {
txID := b.Tx.ID()
if err := tx.Unsigned.Visit(&txExecutor); err != nil {
txID := tx.ID()
v.MarkDropped(txID, err) // cache tx as dropped
return err
}

onCommitState.AddTx(b.Tx, status.Committed)
onAbortState.AddTx(b.Tx, status.Aborted)
onCommitState.AddTx(tx, status.Committed)
onAbortState.AddTx(tx, status.Aborted)

v.Mempool.Remove(b.Tx)
v.Mempool.Remove(tx)

blkID := b.ID()
v.blkIDToState[blkID] = &blockState{
Expand All @@ -413,16 +435,22 @@ func (v *verifier) proposalBlock(

// standardBlock populates the state of this block if [nil] is returned
func (v *verifier) standardBlock(
b *block.ApricotStandardBlock,
b block.Block,
txs []*txs.Tx,
feeCalculator fee.Calculator,
onAcceptState state.Diff,
) error {
inputs, atomicRequests, onAcceptFunc, err := v.processStandardTxs(b.Transactions, feeCalculator, onAcceptState, b.Parent())
inputs, atomicRequests, onAcceptFunc, err := v.processStandardTxs(
txs,
feeCalculator,
onAcceptState,
b.Parent(),
)
if err != nil {
return err
}

v.Mempool.Remove(b.Transactions...)
v.Mempool.Remove(txs...)

blkID := b.ID()
v.blkIDToState[blkID] = &blockState{
Expand Down
5 changes: 3 additions & 2 deletions vms/platformvm/block/executor/verifier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1184,8 +1184,9 @@ func TestBlockExecutionWithComplexity(t *testing.T) {
}

require.Contains(verifier.blkIDToState, blkID)
onAcceptState := verifier.blkIDToState[blkID].onAcceptState
require.Equal(test.expectedFeeState, onAcceptState.GetFeeState())
blockState := verifier.blkIDToState[blkID]
require.Equal(blk, blockState.statelessBlock)
require.Equal(test.expectedFeeState, blockState.onAcceptState.GetFeeState())
})
}
}

0 comments on commit a7ef178

Please sign in to comment.