From 14fe03cbfecf508848bcd1172ea8d2ee3e41fda4 Mon Sep 17 00:00:00 2001 From: Tyler Smith Date: Thu, 30 Jul 2020 22:00:38 -0700 Subject: TWEAK: Set minimum gas price. --- plugin/evm/block.go | 9 +++++++++ plugin/evm/vm.go | 10 ++++++++++ 2 files changed, 19 insertions(+) diff --git a/plugin/evm/block.go b/plugin/evm/block.go index 449e261..1a2bf9e 100644 --- a/plugin/evm/block.go +++ b/plugin/evm/block.go @@ -61,6 +61,15 @@ 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 + } + } + + // Attempt to add the block to the chain and consider the block valid iff it's + // accepted _, err := b.vm.chain.InsertChain([]*types.Block{b.ethBlock}) return err } diff --git a/plugin/evm/vm.go b/plugin/evm/vm.go index cf5ef8a..7b4d064 100644 --- a/plugin/evm/vm.go +++ b/plugin/evm/vm.go @@ -60,6 +60,10 @@ const ( ) var ( + // minGasPrice is the number of nAVAX required per gas unit for a transaction + // to be valid + minGasPrice = big.NewInt(85) + errEmptyBlock = errors.New("empty block") errCreateBlock = errors.New("couldn't create block") errUnknownBlock = errors.New("unknown block") @@ -140,6 +144,12 @@ func (vm *VM) Initialize( 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) } -- cgit v1.2.3-70-g09d2