diff options
author | StephenButtolph <[email protected]> | 2020-08-20 11:56:38 -0400 |
---|---|---|
committer | StephenButtolph <[email protected]> | 2020-08-20 11:56:38 -0400 |
commit | cb5e141d930e0c245804fe87a2caf4962b8f3c5f (patch) | |
tree | 34662f4c4659a55acf33b554f8720c0b4391b305 /plugin | |
parent | 6aa9e31ed3082df34373679f98ad2b004bef2ffa (diff) | |
parent | 14fe03cbfecf508848bcd1172ea8d2ee3e41fda4 (diff) |
added fees
Diffstat (limited to 'plugin')
-rw-r--r-- | plugin/evm/block.go | 7 | ||||
-rw-r--r-- | plugin/evm/vm.go | 14 |
2 files changed, 21 insertions, 0 deletions
diff --git a/plugin/evm/block.go b/plugin/evm/block.go index 8e13c67..0779e17 100644 --- a/plugin/evm/block.go +++ b/plugin/evm/block.go @@ -74,6 +74,13 @@ func (b *Block) Parent() snowman.Block { // Verify implements the snowman.Block interface func (b *Block) Verify() error { + // Ensure the minimum gas price is paid for every transaction + for _, tx := range b.ethBlock.Transactions() { + if tx.GasPrice().Cmp(minGasPrice) < 0 { + return errInvalidBlock + } + } + vm := b.vm tx := vm.getAtomicTx(b.ethBlock) if tx != nil { diff --git a/plugin/evm/vm.go b/plugin/evm/vm.go index cc58e8b..f97de09 100644 --- a/plugin/evm/vm.go +++ b/plugin/evm/vm.go @@ -41,6 +41,7 @@ import ( geckojson "github.com/ava-labs/gecko/utils/json" "github.com/ava-labs/gecko/utils/logging" "github.com/ava-labs/gecko/utils/timer" + "github.com/ava-labs/gecko/utils/units" "github.com/ava-labs/gecko/utils/wrappers" "github.com/ava-labs/gecko/vms/components/avax" "github.com/ava-labs/gecko/vms/secp256k1fx" @@ -79,6 +80,12 @@ const ( ) var ( + // minGasPrice is the number of nAVAX required per gas unit for a transaction + // to be valid + minGasPrice = big.NewInt(47) + + txFee = units.MilliAvax + errEmptyBlock = errors.New("empty block") errCreateBlock = errors.New("couldn't create block") errUnknownBlock = errors.New("unknown block") @@ -222,12 +229,19 @@ func (vm *VM) Initialize( } vm.chainID = g.Config.ChainID + vm.txFee = txFee config := eth.DefaultConfig config.ManualCanonical = true config.Genesis = g config.Miner.ManualMining = true config.Miner.DisableUncle = true + + // Set minimum price for mining and default gas price oracle value to the min + // gas price to prevent so transactions and blocks all use the correct fees + config.Miner.GasPrice = minGasPrice + config.GPO.Default = minGasPrice + if err := config.SetGCMode("archive"); err != nil { panic(err) } |