Skip to content

Commit 75a43ae

Browse files
committed
add delegation designator to witness
1 parent 9db178c commit 75a43ae

File tree

4 files changed

+11
-2
lines changed

4 files changed

+11
-2
lines changed

cmd/evm/blockrunner.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ func blockTestCmd(ctx *cli.Context) error {
8686
continue
8787
}
8888
test := tests[name]
89-
if err := test.Run(false, rawdb.HashScheme, false, tracer, func(res error, chain *core.BlockChain) {
89+
if err := test.Run(false, rawdb.HashScheme, true, tracer, func(res error, chain *core.BlockChain) {
9090
if ctx.Bool(DumpFlag.Name) {
9191
if state, _ := chain.State(); state != nil {
9292
fmt.Println(string(state.Dump(nil)))

core/state_transition.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,8 +479,11 @@ func (st *StateTransition) TransitionDb() (*ExecutionResult, error) {
479479
}
480480
// Check the authority account 1) doesn't have code or has exisiting
481481
// delegation 2) matches the auth's nonce
482-
st.state.AddAddressToAccessList(authority)
483482
code := st.state.GetCode(authority)
483+
st.state.AddAddressToAccessList(authority)
484+
if witness := st.state.Witness(); witness != nil {
485+
witness.AddCode(code)
486+
}
484487
if _, ok := types.ParseDelegation(code); len(code) != 0 && !ok {
485488
continue
486489
}

core/vm/evm.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ func (evm *EVM) Call(caller ContractRef, addr common.Address, input []byte, gas
232232
// The contract is a scoped environment for this execution context only.
233233
code := evm.StateDB.ResolveCode(addr)
234234
if witness := evm.StateDB.Witness(); witness != nil {
235+
witness.AddCode(evm.StateDB.GetCode(addr))
235236
witness.AddCode(code)
236237
}
237238
if len(code) == 0 {
@@ -302,6 +303,7 @@ func (evm *EVM) CallCode(caller ContractRef, addr common.Address, input []byte,
302303
// The contract is a scoped environment for this execution context only.
303304
contract := NewContract(caller, AccountRef(caller.Address()), value, gas)
304305
if witness := evm.StateDB.Witness(); witness != nil {
306+
witness.AddCode(evm.StateDB.GetCode(addrCopy))
305307
witness.AddCode(evm.StateDB.ResolveCode(addrCopy))
306308
}
307309
contract.SetCallCode(&addrCopy, evm.StateDB.ResolveCodeHash(addrCopy), evm.StateDB.ResolveCode(addrCopy))
@@ -352,6 +354,7 @@ func (evm *EVM) DelegateCall(caller ContractRef, addr common.Address, input []by
352354
// Initialise a new contract and make initialise the delegate values
353355
contract := NewContract(caller, AccountRef(caller.Address()), nil, gas).AsDelegate()
354356
if witness := evm.StateDB.Witness(); witness != nil {
357+
witness.AddCode(evm.StateDB.GetCode(addrCopy))
355358
witness.AddCode(evm.StateDB.ResolveCode(addrCopy))
356359
}
357360
contract.SetCallCode(&addrCopy, evm.StateDB.ResolveCodeHash(addrCopy), evm.StateDB.ResolveCode(addrCopy))
@@ -410,6 +413,7 @@ func (evm *EVM) StaticCall(caller ContractRef, addr common.Address, input []byte
410413
// The contract is a scoped environment for this execution context only.
411414
contract := NewContract(caller, AccountRef(addrCopy), new(uint256.Int), gas)
412415
if witness := evm.StateDB.Witness(); witness != nil {
416+
witness.AddCode(evm.StateDB.GetCode(addrCopy))
413417
witness.AddCode(evm.StateDB.ResolveCode(addrCopy))
414418
}
415419
contract.SetCallCode(&addrCopy, evm.StateDB.ResolveCodeHash(addrCopy), evm.StateDB.ResolveCode(addrCopy))

core/vm/instructions.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,7 @@ func opExtCodeSize(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext)
342342
slot := scope.Stack.peek()
343343
address := slot.Bytes20()
344344
if witness := interpreter.evm.StateDB.Witness(); witness != nil {
345+
witness.AddCode(interpreter.evm.StateDB.GetCode(address))
345346
witness.AddCode(interpreter.evm.StateDB.ResolveCode(address))
346347
}
347348
slot.SetUint64(uint64(len(interpreter.evm.StateDB.ResolveCode(slot.Bytes20()))))
@@ -384,6 +385,7 @@ func opExtCodeCopy(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext)
384385
addr := common.Address(a.Bytes20())
385386
code := interpreter.evm.StateDB.ResolveCode(addr)
386387
if witness := interpreter.evm.StateDB.Witness(); witness != nil {
388+
witness.AddCode(interpreter.evm.StateDB.GetCode(addr))
387389
witness.AddCode(code)
388390
}
389391
codeCopy := getData(code, uint64CodeOffset, length.Uint64())

0 commit comments

Comments
 (0)