diff --git a/geth/genesis.json b/geth/genesis.json index aa20d22c..e031182f 100644 --- a/geth/genesis.json +++ b/geth/genesis.json @@ -24,6 +24,6 @@ "extraData": "0x0000000000000000000000000000000000000000000000000000000000000000", "gasLimit": "0x47e7c4", "difficulty": "0x0", - "mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000", + "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000", "alloc": {} } diff --git a/geth/types.py b/geth/types.py index 85b80768..01b1e15b 100644 --- a/geth/types.py +++ b/geth/types.py @@ -48,12 +48,17 @@ class GethKwargsTypedDict(TypedDict, total=False): class GenesisDataTypedDict(TypedDict, total=False): alloc: dict[str, dict[str, Any]] + baseFeePerGas: str + blobGasUsed: str coinbase: str config: dict[str, Any] difficulty: str + excessBlobGas: str extraData: str gasLimit: str - mixhash: str + gasUsed: str + mixHash: str nonce: str + number: str parentHash: str timestamp: str diff --git a/geth/utils/validation.py b/geth/utils/validation.py index 19e9d4bb..c9e18e88 100644 --- a/geth/utils/validation.py +++ b/geth/utils/validation.py @@ -70,6 +70,7 @@ def validate_geth_kwargs(geth_kwargs: GethKwargsTypedDict) -> None: class GenesisDataConfig(BaseModel): + chainId: int = 0 ethash: dict[str, Any] = {} # so that geth treats config as PoW -> PoS transition homesteadBlock: int = 0 daoForkBlock: int = 0 @@ -97,15 +98,20 @@ class GenesisDataConfig(BaseModel): class GenesisData(BaseModel): alloc: dict[str, dict[str, Any]] = {} + baseFeePerGas: str = "0x0" + blobGasUsed: str = "0x0" coinbase: str = "0x3333333333333333333333333333333333333333" config: dict[str, Any] = GenesisDataConfig().model_dump() difficulty: str = "0x0" + excessBlobGas: str = "0x0" extraData: str = ( "0x0000000000000000000000000000000000000000000000000000000000000000" ) gasLimit: str = "0x47e7c4" - mixhash: str = "0x0000000000000000000000000000000000000000000000000000000000000000" + gasUsed: str = "0x0" + mixHash: str = "0x0000000000000000000000000000000000000000000000000000000000000000" nonce: str = "0x0" + number: str = "0x0" parentHash: str = ( "0x0000000000000000000000000000000000000000000000000000000000000000" ) diff --git a/newsfragments/221.bugfix.rst b/newsfragments/221.bugfix.rst new file mode 100644 index 00000000..430b16ee --- /dev/null +++ b/newsfragments/221.bugfix.rst @@ -0,0 +1 @@ +Add missing fields for genesis data. Change mixhash -> mixHash to more closely match Geth diff --git a/tests/core/utility/test_validation.py b/tests/core/utility/test_validation.py index 55fb8372..3d4a2621 100644 --- a/tests/core/utility/test_validation.py +++ b/tests/core/utility/test_validation.py @@ -104,8 +104,11 @@ def test_validate_genesis_data_bad(genesis_data): }, { "alloc": {}, + "baseFeePerGas": "0x0", + "blobGasUsed": "0x0", "coinbase": "0x3333333333333333333333333333333333333333", "config": { + "chainId": 0, "ethash": {}, "homesteadBlock": 0, "daoForkBlock": 0, @@ -127,10 +130,13 @@ def test_validate_genesis_data_bad(genesis_data): "cancunTime": 0, }, "difficulty": "0x00012131", + "excessBlobGas": "0x0", "extraData": "0x0000000000000000000000000000000000000000000000000000000000000000", # noqa: E501 "gasLimit": "0x47e7c4", - "mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000", # noqa: E501 + "gasUsed": "0x0", + "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000", # noqa: E501 "nonce": "abc", + "number": "0x0", "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000", # noqa: E501 "timestamp": "1234", }, @@ -150,8 +156,11 @@ def test_validate_genesis_data_bad(genesis_data): }, { "alloc": {}, + "baseFeePerGas": "0x0", + "blobGasUsed": "0x0", "coinbase": "0x3333333333333333333333333333333333333333", "config": { + "chainId": 0, "ethash": {}, "homesteadBlock": 5, "daoForkBlock": 1, @@ -173,10 +182,13 @@ def test_validate_genesis_data_bad(genesis_data): "cancunTime": 0, }, "difficulty": "0x00012131", + "excessBlobGas": "0x0", "extraData": "0x0000000000000000000000000000000000000000000000000000000000000000", # noqa: E501 "gasLimit": "0x47e7c4", - "mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000", # noqa: E501 + "gasUsed": "0x0", + "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000", # noqa: E501 "nonce": "abc", + "number": "0x0", "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000", # noqa: E501 "timestamp": "0x0", },