aboutsummaryrefslogtreecommitdiffstats
path: root/eth/tracers/tracer.go
diff options
context:
space:
mode:
authorgary rong <garyrong0905@gmail.com>2019-01-06 04:26:50 +0800
committerMartin Holst Swende <martin@swende.se>2019-01-06 04:26:50 +0800
commite8ff318205be2d3e9f793ee876726bf0fbaf579e (patch)
tree31fa92b088c0708a31b570f310bf8bcc78200541 /eth/tracers/tracer.go
parentc1c43011211e70ffdd2a78fb1a467adb5db9f65e (diff)
downloaddexon-e8ff318205be2d3e9f793ee876726bf0fbaf579e.tar
dexon-e8ff318205be2d3e9f793ee876726bf0fbaf579e.tar.gz
dexon-e8ff318205be2d3e9f793ee876726bf0fbaf579e.tar.bz2
dexon-e8ff318205be2d3e9f793ee876726bf0fbaf579e.tar.lz
dexon-e8ff318205be2d3e9f793ee876726bf0fbaf579e.tar.xz
dexon-e8ff318205be2d3e9f793ee876726bf0fbaf579e.tar.zst
dexon-e8ff318205be2d3e9f793ee876726bf0fbaf579e.zip
eth/tracer: extend create2 (#18318)
* eth/tracer: extend create2 * eth/tracers: fix create2-flaw in prestate_tracer * eth/tracers: fix test * eth/tracers: update assets
Diffstat (limited to 'eth/tracers/tracer.go')
-rw-r--r--eth/tracers/tracer.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/eth/tracers/tracer.go b/eth/tracers/tracer.go
index 3533a831f..9d6701868 100644
--- a/eth/tracers/tracer.go
+++ b/eth/tracers/tracer.go
@@ -367,6 +367,28 @@ 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))
+ }
+ // Retrieve salt hex string from js stack
+ salt := common.HexToHash(ctx.GetString(-2))
+ // Retrieve code slice from js stack
+ var code []byte
+ if ptr, size := ctx.GetBuffer(-1); ptr != nil {
+ code = common.CopyBytes(makeSlice(ptr, size))
+ } else {
+ code = common.FromHex(ctx.GetString(-1))
+ }
+ codeHash := crypto.Keccak256(code)
+ ctx.Pop3()
+ contract := crypto.CreateAddress2(from, salt, codeHash)
+ 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)