diff --git a/vms/platformvm/block/executor/manager.go b/vms/platformvm/block/executor/manager.go index 48330dd74788..33b29354a59e 100644 --- a/vms/platformvm/block/executor/manager.go +++ b/vms/platformvm/block/executor/manager.go @@ -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" ) @@ -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,