@@ -16,6 +16,7 @@ import (
1616 "github.com/ava-labs/avalanchego/vms/platformvm/state"
1717 "github.com/ava-labs/avalanchego/vms/platformvm/txs"
1818 "github.com/ava-labs/avalanchego/vms/platformvm/txs/executor"
19+ "github.com/ava-labs/avalanchego/vms/platformvm/txs/fee"
1920 "github.com/ava-labs/avalanchego/vms/platformvm/txs/mempool"
2021 "github.com/ava-labs/avalanchego/vms/platformvm/validators"
2122)
@@ -168,6 +169,24 @@ func (m *manager) VerifyTx(tx *txs.Tx) error {
168169 return fmt .Errorf ("failed to advance the chain time: %w" , err )
169170 }
170171
172+ if timestamp := stateDiff .GetTimestamp (); m .txExecutorBackend .Config .UpgradeConfig .IsEtnaActivated (timestamp ) {
173+ complexity , err := fee .TxComplexity (tx .Unsigned )
174+ if err != nil {
175+ return fmt .Errorf ("failed to calculate tx complexity: %w" , err )
176+ }
177+ gas , err := complexity .ToGas (m .txExecutorBackend .Config .DynamicFeeConfig .Weights )
178+ if err != nil {
179+ return fmt .Errorf ("failed to calculate tx gas: %w" , err )
180+ }
181+
182+ // TODO: After the mempool is updated, convert this check to use the
183+ // maximum mempool capacity.
184+ feeState := stateDiff .GetFeeState ()
185+ if gas > feeState .Capacity {
186+ return fmt .Errorf ("tx exceeds current gas capacity: %d > %d" , gas , feeState .Capacity )
187+ }
188+ }
189+
171190 feeCalculator := state .PickFeeCalculator (m .txExecutorBackend .Config , stateDiff )
172191 _ , _ , _ , err = executor .StandardTx (
173192 m .txExecutorBackend ,
0 commit comments