From 0a53f995e1873b379dd5d5810863921f9626dd05 Mon Sep 17 00:00:00 2001 From: Roberto Bayardo Date: Fri, 14 Oct 2022 13:54:56 -0700 Subject: [PATCH] fix panic issue when ExcessDataGas is nil (#37) --- core/evm.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/core/evm.go b/core/evm.go index 247f11337f2d..e42221024dce 100644 --- a/core/evm.go +++ b/core/evm.go @@ -44,7 +44,6 @@ func NewEVMBlockContext(header *types.Header, excessDataGas *big.Int, chain Chai beneficiary common.Address baseFee *big.Int random *common.Hash - edg *big.Int ) // 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 if header.Difficulty.Cmp(common.Big0) == 0 { random = &header.MixDigest } + // In the event excessDataGas is nil (which happens if the parent block is pre-sharding), + // we bootstrap BlockContext.ExcessDataGas with the zero value. + edg := new(big.Int) if excessDataGas != nil { - edg = new(big.Int).Set(excessDataGas) + edg.Set(excessDataGas) } return vm.BlockContext{ CanTransfer: CanTransfer,