Fix nil pointer exception, statedb received in LastStateId can be nil

This commit is contained in:
Matthieu Vachon 2025-06-10 22:15:02 -04:00
parent f6679a1c19
commit 3a5287750a

View file

@ -123,8 +123,11 @@ func (gc *GenesisContractsClient) LastStateId(stateDB vm.StateDB, number uint64,
toAddress := common.HexToAddress(gc.StateReceiverContract) toAddress := common.HexToAddress(gc.StateReceiverContract)
gas := (hexutil.Uint64)(uint64(math.MaxUint64 / 2)) gas := (hexutil.Uint64)(uint64(math.MaxUint64 / 2))
var original *state.StateDB
if stateDB != nil {
// The unhooked version always return the *state.StateDB inner object // The unhooked version always return the *state.StateDB inner object
original := stateDB.Unhooked().(*state.StateDB) original = stateDB.Unhooked().(*state.StateDB)
}
// BOR: Do a 'CallWithState' so that we can fetch the last state ID from a given (incoming) // BOR: Do a 'CallWithState' so that we can fetch the last state ID from a given (incoming)
// state instead of local(canonical) chain's state. // state instead of local(canonical) chain's state.