Repository: ethereum/go-ethereum (language: go)

Issue:
`cmd/evm` ignores the `baseFeePerGas` setting in `genesis.json` when executing opcode `BASEFEE`
#### System information

Geth version: `evm version 1.14.5-stable-0dd173a7 ` and ` evm version 1.14.8-unstable-978041fe `
CL client & version: Nope
OS & Version: Ubuntu 20.04
Commit hash : Nope

#### Expected behaviour

Hello developers,

I'm currently testing EVM implementations and have encountered a peculiar issue. When executing the `BASEFEE` opcode (0x48), `evm` will return `0x3b9aca00(1000000000)` instead of the value provided in `genesis.json` .

#### Steps to reproduce the behaviour

I used the latest version of geth image pulled from dockerhub(digest bb0eb0bd6) to reproduce this bug. 

```
docker pull ethereum/client-go:alltools-latest
docker run ethereum/client-go:alltools-latest tail -f /dev/null
docker exec -it containerid /bin/sh
```

This is the `genesis.json` file for `--prestate`, which sets the baseFee to `0xffff`.

```json
{
  "config": {
    "chainId": 9599,
    "homesteadBlock": 0,
    "eip150Block": 0,
    "eip155Block": 0,
    "eip158Block": 0,
    "byzantiumBlock": 0,
    "constantinopleBlock": 0,
    "petersburgBlock": 0,
    "istanbulBlock": 0,
    "berlinBlock": 0,
    "londonBlock": 0,
    "shanghaiBlock": 0,
    "shanghaiTime":0
  },
  "alloc": {
    "0x1c7cd2d37ffd63856a5bd56a9af1643f2bcf545f": {
     "balance": "0x1234"
    }
  },
  "coinbase": "0x000000000000000000000000000000000000abcd",
  "difficulty": "0x0",
  "extraData": "",
  "gasLimit": "0xffffff",
  "nonce": "0x0000000000000042",
  "mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
  "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
  "timestamp": "0x00",
  "baseFeePerGas": "0xffff"
}
```

Use `evm` to run the bytecode `4860005260406000f3` .

```shell
evm --debug --gas 0xffffff --nomemory=false --json --code 4860005260406000f3 --prestate ./genesis.json run
```

The mnemonics of the bytecode are as follows.

```
BASEFEE
PUSH1 00
MSTORE
PUSH1 40
PUSH1 00
RETURN 
```

The result from evm's output, the stack output of `BASEFEE` is `0x3b9aca00`.

```json
{"pc":0,"op":72,"gas":"0xffffff","gasCost":"0x2","memSize":0,"stack":[],"depth":1,"refund":0,"opName":"BASEFEE"}
{"pc":1,"op":96,"gas":"0xfffffd","gasCost":"0x3","memSize":0,"stack":["0x3b9aca00"],"depth":1,"refund":0,"opName":"PUSH1"}
{"pc":3,"op":82,"gas":"0xfffffa","gasCost":"0x6","memSize":0,"stack":["0x3b9aca00","0x0"],"depth":1,"refund":0,"opName":"MSTORE"}
{"pc":4,"op":96,"gas":"0xfffff4","gasCost":"0x3","memory":"0x000000000000000000000000000000000000000000000000000000003b9aca00","memSize":32,"stack":[],"depth":1,"refund":0,"opName":"PUSH1"}
{"pc":6,"op":96,"gas":"0xfffff1","gasCost":"0x3","memory":"0x000000000000000000000000000000000000000000000000000000003b9aca00","memSize":32,"stack":["0x40"],"depth":1,"refund":0,"opName":"PUSH1"}
{"pc":8,"op":243,"gas":"0xffffee","gasCost":"0x3","memory":"0x000000000000000000000000000000000000000000000000000000003b9aca00","memSize":32,"stack":["0x40","0x0"],"depth":1,"refund":0,"opName":"RETURN"}
{"output":"000000000000000000000000000000000000000000000000000000003b9aca000000000000000000000000000000000000000000000000000000000000000000","gasUsed":"0x14"}
```

#### Backtrace

I checked in `evm version 1.14.8-unstable-978041fe` and `evm version 1.14.5-stable-0dd173a7`, the problem occured in both versions. 

It seems that the `baseFeePerGas` in `genesis.json` is just ignored.

https://github.com/ethereum/go-ethereum/blob/b37ac5c1027847de2eb65162a7251b37b9466793/cmd/evm/runner.go#L214-L228

Thanks for your time!









Discussion / hints:

Fix patch:
diff --git a/cmd/evm/runner.go b/cmd/evm/runner.go
index d06f85ed5965..c02f9f059085 100644
--- a/cmd/evm/runner.go
+++ b/cmd/evm/runner.go
@@ -221,6 +221,7 @@ func runCmd(ctx *cli.Context) error {
 		Time:        genesisConfig.Timestamp,
 		Coinbase:    genesisConfig.Coinbase,
 		BlockNumber: new(big.Int).SetUint64(genesisConfig.Number),
+		BaseFee:     genesisConfig.BaseFee,
 		BlobHashes:  blobHashes,
 		BlobBaseFee: blobBaseFee,
 		EVMConfig: vm.Config{


Test patch: