Skip to content

Commit

Permalink
e3: fix nil ptr bsc (erigontech#6162)
Browse files Browse the repository at this point in the history
  • Loading branch information
AskAlexSharov authored Nov 30, 2022
1 parent 400ad1a commit cb8f609
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 14 deletions.
16 changes: 12 additions & 4 deletions cmd/state/exec3/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,13 +178,21 @@ func (rw *Worker) RunTxTask(txTask *exec22.TxTask) {
ibs.Prepare(txHash, txTask.BlockHash, txTask.TxIndex)
msg := txTask.TxAsMessage

//var vmenv vm.VMInterface
//if txTask.Tx.IsStarkNet() {
// rw.starkNetEvm.Reset(evmtypes.TxContext{}, ibs)
// vmenv = rw.starkNetEvm
//} else {
// rw.evm.ResetBetweenBlocks(txTask.EvmBlockContext, core.NewEVMTxContext(msg), ibs, vmConfig, txTask.Rules)
// vmenv = rw.evm
//}
var vmenv vm.VMInterface
if txTask.Tx.IsStarkNet() {
rw.starkNetEvm.Reset(evmtypes.TxContext{}, ibs)
vmenv = rw.starkNetEvm
vmenv = &vm.CVMAdapter{Cvm: vm.NewCVM(ibs)}
} else {
rw.evm.ResetBetweenBlocks(txTask.EvmBlockContext, core.NewEVMTxContext(msg), ibs, vmConfig, txTask.Rules)
vmenv = rw.evm
blockContext := core.NewEVMBlockContext(header, txTask.GetHashFn, rw.engine, nil /* author */)
txContext := core.NewEVMTxContext(msg)
vmenv = vm.NewEVM(blockContext, txContext, ibs, rw.chainConfig, vmConfig)
}
if _, err = core.ApplyMessage(vmenv, msg, gp, true /* refunds */, false /* gasBailout */); err != nil {
txTask.Error = err
Expand Down
38 changes: 28 additions & 10 deletions core/state/rw22.go
Original file line number Diff line number Diff line change
Expand Up @@ -821,13 +821,22 @@ var writeListPool = sync.Pool{
}

func newWriteList() map[string]*exec22.KvList {
w := writeListPool.Get().(map[string]*exec22.KvList)
for _, tbl := range w {
tbl.Keys, tbl.Vals = tbl.Keys[:0], tbl.Vals[:0]
return map[string]*exec22.KvList{
kv.PlainState: {},
kv.Code: {},
kv.PlainContractCode: {},
kv.IncarnationMap: {},
}
return w

//w := writeListPool.Get().(map[string]*exec22.KvList)
//for _, tbl := range w {
// tbl.Keys, tbl.Vals = tbl.Keys[:0], tbl.Vals[:0]
//}
//return w
}
func returnWriteList(w map[string]*exec22.KvList) {
//writeListPool.Put(w)
}
func returnWriteList(w map[string]*exec22.KvList) { writeListPool.Put(w) }

var readListPool = sync.Pool{
New: func() any {
Expand All @@ -841,10 +850,19 @@ var readListPool = sync.Pool{
}

func newReadList() map[string]*exec22.KvList {
w := readListPool.Get().(map[string]*exec22.KvList)
for _, tbl := range w {
tbl.Keys, tbl.Vals = tbl.Keys[:0], tbl.Vals[:0]
return map[string]*exec22.KvList{
kv.PlainState: {},
kv.Code: {},
CodeSizeTable: {},
kv.IncarnationMap: {},
}
return w

//w := readListPool.Get().(map[string]*exec22.KvList)
//for _, tbl := range w {
// tbl.Keys, tbl.Vals = tbl.Keys[:0], tbl.Vals[:0]
//}
//return w
}
func returnReadList(w map[string]*exec22.KvList) {
//readListPool.Put(w)
}
func returnReadList(w map[string]*exec22.KvList) { readListPool.Put(w) }

0 comments on commit cb8f609

Please sign in to comment.