Skip to content

Commit 3f89e28

Browse files
marioevzEikix
authored andcommitted
simulators/ethereum/consensus: Fix excessBlobGas genesis (ethereum#964)
simulators/ethereum/consensus: Fix excessBlobGas genesis
1 parent b6da011 commit 3f89e28

File tree

2 files changed

+26
-15
lines changed

2 files changed

+26
-15
lines changed

simulators/ethereum/consensus/main.go

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -553,15 +553,16 @@ func (tc *testcase) updateEnv(env hivesim.Params) {
553553
// toGethGenesis creates the genesis specification from a test block.
554554
func toGethGenesis(test *btJSON) *core.Genesis {
555555
genesis := &core.Genesis{
556-
Nonce: test.Genesis.Nonce.Uint64(),
557-
Timestamp: test.Genesis.Timestamp.Uint64(),
558-
ExtraData: test.Genesis.ExtraData,
559-
GasLimit: test.Genesis.GasLimit,
560-
Difficulty: test.Genesis.Difficulty,
561-
Mixhash: test.Genesis.MixHash,
562-
Coinbase: test.Genesis.Coinbase,
563-
Alloc: test.Pre,
564-
BaseFee: test.Genesis.BaseFee,
556+
Nonce: test.Genesis.Nonce.Uint64(),
557+
Timestamp: test.Genesis.Timestamp.Uint64(),
558+
ExtraData: test.Genesis.ExtraData,
559+
GasLimit: test.Genesis.GasLimit,
560+
Difficulty: test.Genesis.Difficulty,
561+
Mixhash: test.Genesis.MixHash,
562+
Coinbase: test.Genesis.Coinbase,
563+
Alloc: test.Pre,
564+
BaseFee: test.Genesis.BaseFee,
565+
ExcessBlobGas: test.Genesis.ExcessBlobGas,
565566
}
566567
return genesis
567568
}
@@ -651,7 +652,15 @@ func compareGenesis(have string, want btHeader) (string, error) {
651652
cmp(haveGenesis.GasUsed, want.GasUsed, "gasUsed")
652653
cmp(haveGenesis.Nonce, want.Nonce, "nonce")
653654
cmp(haveGenesis.BaseFee, want.BaseFee, "baseFeePerGas")
654-
cmp(haveGenesis.ExcessBlobGas, want.ExcessBlobGas, "excessBlobGas")
655-
cmp(haveGenesis.BlobGasUsed, want.BlobGasUsed, "blobGasUsed")
655+
if haveGenesis.ExcessBlobGas != nil && want.ExcessBlobGas != nil {
656+
cmp(*haveGenesis.ExcessBlobGas, *want.ExcessBlobGas, "excessBlobGas")
657+
} else {
658+
cmp(haveGenesis.ExcessBlobGas, want.ExcessBlobGas, "excessBlobGas")
659+
}
660+
if haveGenesis.BlobGasUsed != nil && want.BlobGasUsed != nil {
661+
cmp(*haveGenesis.BlobGasUsed, *want.BlobGasUsed, "blobGasUsed")
662+
} else {
663+
cmp(haveGenesis.BlobGasUsed, want.BlobGasUsed, "blobGasUsed")
664+
}
656665
return output, nil
657666
}

simulators/ethereum/consensus/types.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ type btHeader struct {
5555
GasUsed uint64 `json:"gasUsed"`
5656
Timestamp *big.Int `json:"timestamp"`
5757
BaseFee *big.Int `json:"baseFeePerGas"` // EIP-1559
58-
ExcessBlobGas uint64 `json:"excessBlobGas"` // EIP-4844
59-
BlobGasUsed uint64 `json:"blobGasUsed"` // EIP-4844
58+
ExcessBlobGas *uint64 `json:"excessBlobGas"` // EIP-4844
59+
BlobGasUsed *uint64 `json:"blobGasUsed"` // EIP-4844
6060
}
6161

6262
func (b *btHeader) UnmarshalJSON(input []byte) error {
@@ -152,10 +152,12 @@ func (b *btHeader) UnmarshalJSON(input []byte) error {
152152
b.BaseFee = (*big.Int)(dec.BaseFee)
153153
}
154154
if dec.ExcessBlobGas != nil {
155-
b.ExcessBlobGas = uint64(*dec.ExcessBlobGas)
155+
ebg := uint64(*dec.ExcessBlobGas)
156+
b.ExcessBlobGas = &ebg
156157
}
157158
if dec.BlobGasUsed != nil {
158-
b.BlobGasUsed = uint64(*dec.BlobGasUsed)
159+
bgu := uint64(*dec.BlobGasUsed)
160+
b.BlobGasUsed = &bgu
159161
}
160162
return nil
161163
}

0 commit comments

Comments
 (0)