Skip to content

Commit 0a53f99

Browse files
fix panic issue when ExcessDataGas is nil (#37)
1 parent 91322eb commit 0a53f99

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

core/evm.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ func NewEVMBlockContext(header *types.Header, excessDataGas *big.Int, chain Chai
4444
beneficiary common.Address
4545
baseFee *big.Int
4646
random *common.Hash
47-
edg *big.Int
4847
)
4948

5049
// If we don't have an explicit author (i.e. not mining), extract from the header
@@ -59,8 +58,11 @@ func NewEVMBlockContext(header *types.Header, excessDataGas *big.Int, chain Chai
5958
if header.Difficulty.Cmp(common.Big0) == 0 {
6059
random = &header.MixDigest
6160
}
61+
// In the event excessDataGas is nil (which happens if the parent block is pre-sharding),
62+
// we bootstrap BlockContext.ExcessDataGas with the zero value.
63+
edg := new(big.Int)
6264
if excessDataGas != nil {
63-
edg = new(big.Int).Set(excessDataGas)
65+
edg.Set(excessDataGas)
6466
}
6567
return vm.BlockContext{
6668
CanTransfer: CanTransfer,

0 commit comments

Comments
 (0)