mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 10:22:23 +00:00
eth/tracers: extend tracers for CREATE2
Signed-off-by: YaoZengzeng <yaozengzeng@zju.edu.cn>
This commit is contained in:
parent
62e94895da
commit
c49e754692
4 changed files with 34 additions and 16 deletions
File diff suppressed because one or more lines are too long
|
|
@ -38,7 +38,7 @@
|
|||
var op = log.op.toString();
|
||||
}
|
||||
// If a new contract is being created, add to the call stack
|
||||
if (syscall && op == 'CREATE') {
|
||||
if (syscall && (op == 'CREATE' || op == 'CREATE2')) {
|
||||
var inOff = log.stack.peek(1).valueOf();
|
||||
var inEnd = inOff + log.stack.peek(2).valueOf();
|
||||
|
||||
|
|
@ -116,8 +116,8 @@
|
|||
// Pop off the last call and get the execution results
|
||||
var call = this.callstack.pop();
|
||||
|
||||
if (call.type == 'CREATE') {
|
||||
// If the call was a CREATE, retrieve the contract address and output code
|
||||
if (call.type == 'CREATE' || call.type == 'CREATE2') {
|
||||
// If the call was a CREATE or CREATE2, retrieve the contract address and output code
|
||||
call.gasUsed = '0x' + bigInt(call.gasIn - call.gasCost - log.getGas()).toString(16);
|
||||
delete call.gasIn; delete call.gasCost;
|
||||
|
||||
|
|
|
|||
|
|
@ -89,6 +89,9 @@
|
|||
var from = log.contract.getAddress();
|
||||
this.lookupAccount(toContract(from, db.getNonce(from)), db);
|
||||
break;
|
||||
case "CREATE2":
|
||||
var from = log.contract.getAddress();
|
||||
this.lookupAccount(toContract2(from, log.stack.peek(3).toString(16), db.getCode(from)), db);
|
||||
case "CALL": case "CALLCODE": case "DELEGATECALL": case "STATICCALL":
|
||||
this.lookupAccount(toAddress(log.stack.peek(1).toString(16)), db);
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -365,6 +365,21 @@ func New(code string) (*Tracer, error) {
|
|||
copy(makeSlice(ctx.PushFixedBuffer(20), 20), contract[:])
|
||||
return 1
|
||||
})
|
||||
tracer.vm.PushGlobalGoFunction("toContract2", func(ctx *duktape.Context) int {
|
||||
var from common.Address
|
||||
if ptr, size := ctx.GetBuffer(-3); ptr != nil {
|
||||
from = common.BytesToAddress(makeSlice(ptr, size))
|
||||
} else {
|
||||
from = common.HexToAddress(ctx.GetString(-3))
|
||||
}
|
||||
salt := common.HexToHash(ctx.GetString(-2))
|
||||
code := common.CopyBytes(makeSlice(ctx.GetBuffer(-1)))
|
||||
ctx.Pop3()
|
||||
|
||||
contract := crypto.CreateAddress2(from, salt, code)
|
||||
copy(makeSlice(ctx.PushFixedBuffer(20), 20), contract[:])
|
||||
return 1
|
||||
})
|
||||
tracer.vm.PushGlobalGoFunction("isPrecompiled", func(ctx *duktape.Context) int {
|
||||
_, ok := vm.PrecompiledContractsByzantium[common.BytesToAddress(popSlice(ctx))]
|
||||
ctx.PushBoolean(ok)
|
||||
|
|
|
|||
Loading…
Reference in a new issue