Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add missing items from genesis #221

Merged
merged 4 commits into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion geth/genesis.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@
"extraData": "0x0000000000000000000000000000000000000000000000000000000000000000",
"gasLimit": "0x47e7c4",
"difficulty": "0x0",
"mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"alloc": {}
}
7 changes: 6 additions & 1 deletion geth/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 7 additions & 1 deletion geth/utils/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
)
Expand Down
1 change: 1 addition & 0 deletions newsfragments/221.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add missing fields for genesis data. Change mixhash -> mixHash to more closely match Geth
16 changes: 14 additions & 2 deletions tests/core/utility/test_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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",
},
Expand All @@ -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,
Expand All @@ -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",
},
Expand Down