Skip to content

Commit

Permalink
Add more fields
Browse files Browse the repository at this point in the history
  • Loading branch information
kclowes committed Jun 27, 2024
1 parent dff372c commit c567baa
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 8 deletions.
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
10 changes: 6 additions & 4 deletions geth/utils/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,22 +98,24 @@ 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"
)
timestamp: str = "0x0"
baseFeePerGas: str = "0x0"
excessBlobGas: str = "0x0"
blobGasUsed: str = "0x0"

model_config = ConfigDict(extra="forbid")

Expand Down
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

0 comments on commit c567baa

Please sign in to comment.