Skip to content
Merged
Changes from all commits
Commits
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
19 changes: 19 additions & 0 deletions vms/platformvm/block/executor/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/ava-labs/avalanchego/vms/platformvm/state"
"github.com/ava-labs/avalanchego/vms/platformvm/txs"
"github.com/ava-labs/avalanchego/vms/platformvm/txs/executor"
"github.com/ava-labs/avalanchego/vms/platformvm/txs/fee"
"github.com/ava-labs/avalanchego/vms/platformvm/txs/mempool"
"github.com/ava-labs/avalanchego/vms/platformvm/validators"
)
Expand Down Expand Up @@ -168,6 +169,24 @@ func (m *manager) VerifyTx(tx *txs.Tx) error {
return fmt.Errorf("failed to advance the chain time: %w", err)
}

if timestamp := stateDiff.GetTimestamp(); m.txExecutorBackend.Config.UpgradeConfig.IsEtnaActivated(timestamp) {
complexity, err := fee.TxComplexity(tx.Unsigned)
if err != nil {
return fmt.Errorf("failed to calculate tx complexity: %w", err)
}
gas, err := complexity.ToGas(m.txExecutorBackend.Config.DynamicFeeConfig.Weights)
if err != nil {
return fmt.Errorf("failed to calculate tx gas: %w", err)
}

// TODO: After the mempool is updated, convert this check to use the
// maximum mempool capacity.
feeState := stateDiff.GetFeeState()
if gas > feeState.Capacity {
return fmt.Errorf("tx exceeds current gas capacity: %d > %d", gas, feeState.Capacity)
}
}

feeCalculator := state.PickFeeCalculator(m.txExecutorBackend.Config, stateDiff)
_, _, _, err = executor.StandardTx(
m.txExecutorBackend,
Expand Down
Loading