Skip to content

Commit

Permalink
eth/tracers: add goja tracer engine
Browse files Browse the repository at this point in the history
eth/tracers: pass op to step

eth/tracers: uncap field method names

eth/tracers: fill in op methods

eth/tracers: inject biginteger logic

eth/tracers: push bigInt as argument

eth/tracers: add memory wrapper for goja

eth/tracers: add stack wrapper for goja

eth/tracers: add db wrapper for goja

eth/tracers: add contract wrapper for goja

eth/tracers: add log field accessors

eth/tracers: initial impl CaptureState and GetResult

eth/tracers: impl CaptureStart & CaptureEnd

eth/tracers: fixes

eth/tracers: callTracerLegacy tests pass for goja

eth/tracers: avoid ToValue on every step

eth/tracers: avoid Export on every step

eth/tracers: use goja.Object for log

eth/tracers: use nested log fields via goja.Objects

eth/tracers: fill-in missing methods

eth/tracers: pre-compile bigIntegerJS

eth/tracers: mv goja files to js dir

eth/tracers: minor fixes

goja: add stop method

goja: register tracer, re-enable callTracer test

impl CaptureFault

improve err handling

impl CaptureEnter

impl CaptureExit

Add test for call frame tracer goja

Dont trace step when method not exposed

Add license to goja files

Fix nil frame value

minor rename

Impl some go funcs exposed to js env

Make goja ctor private, add stack length method

comment out some goja tests

Test goja via duktape test cases

add tx hooks

update goja

set goja as default for js tracers

minor fix

convert byte arrays to js buffer

rewrite toBuffer

wrap toBig calls

drop unused fn

set up builtins in a separate func

set up converters in separate func

refactor objects passed into js

more refactor

move aux types down in file

move goja tracer struct private

minor cleanups

mv db objects setup

fix buffer returned value from builtins

explicit gas limit for runtime jstracer test

drop deprecated test

test recursion limit only for duktape

drop goja test file

minor

fix console PrettyError test

use goja interrupt

minor

fix halt test cases

fix buf imported into go

fix create2 addr
  • Loading branch information
s1na committed May 2, 2022
1 parent 559a174 commit 04d9a7a
Show file tree
Hide file tree
Showing 9 changed files with 1,007 additions and 69 deletions.
2 changes: 1 addition & 1 deletion console/console_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ func TestPrettyError(t *testing.T) {
defer tester.Close(t)
tester.console.Evaluate("throw 'hello'")

want := jsre.ErrorColor("hello") + "\n\tat <eval>:1:7(1)\n\n"
want := jsre.ErrorColor("hello") + "\n\tat <eval>:1:1(1)\n\n"
if output := tester.output.String(); output != want {
t.Fatalf("pretty error mismatch: have %s, want %s", output, want)
}
Expand Down
15 changes: 8 additions & 7 deletions core/vm/runtime/runtime_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -752,7 +752,7 @@ func TestRuntimeJSTracer(t *testing.T) {
byte(vm.CREATE),
byte(vm.POP),
},
results: []string{`"1,1,4294935775,6,12"`, `"1,1,4294935775,6,0"`},
results: []string{`"1,1,952855,6,12"`, `"1,1,952855,6,0"`},
},
{
// CREATE2
Expand All @@ -768,7 +768,7 @@ func TestRuntimeJSTracer(t *testing.T) {
byte(vm.CREATE2),
byte(vm.POP),
},
results: []string{`"1,1,4294935766,6,13"`, `"1,1,4294935766,6,0"`},
results: []string{`"1,1,952846,6,13"`, `"1,1,952846,6,0"`},
},
{
// CALL
Expand All @@ -781,7 +781,7 @@ func TestRuntimeJSTracer(t *testing.T) {
byte(vm.CALL),
byte(vm.POP),
},
results: []string{`"1,1,4294964716,6,13"`, `"1,1,4294964716,6,0"`},
results: []string{`"1,1,981796,6,13"`, `"1,1,981796,6,0"`},
},
{
// CALLCODE
Expand All @@ -794,7 +794,7 @@ func TestRuntimeJSTracer(t *testing.T) {
byte(vm.CALLCODE),
byte(vm.POP),
},
results: []string{`"1,1,4294964716,6,13"`, `"1,1,4294964716,6,0"`},
results: []string{`"1,1,981796,6,13"`, `"1,1,981796,6,0"`},
},
{
// STATICCALL
Expand All @@ -806,7 +806,7 @@ func TestRuntimeJSTracer(t *testing.T) {
byte(vm.STATICCALL),
byte(vm.POP),
},
results: []string{`"1,1,4294964719,6,12"`, `"1,1,4294964719,6,0"`},
results: []string{`"1,1,981799,6,12"`, `"1,1,981799,6,0"`},
},
{
// DELEGATECALL
Expand All @@ -818,7 +818,7 @@ func TestRuntimeJSTracer(t *testing.T) {
byte(vm.DELEGATECALL),
byte(vm.POP),
},
results: []string{`"1,1,4294964719,6,12"`, `"1,1,4294964719,6,0"`},
results: []string{`"1,1,981799,6,12"`, `"1,1,981799,6,0"`},
},
{
// CALL self-destructing contract
Expand Down Expand Up @@ -859,7 +859,8 @@ func TestRuntimeJSTracer(t *testing.T) {
t.Fatal(err)
}
_, _, err = Call(main, nil, &Config{
State: statedb,
GasLimit: 1000000,
State: statedb,
EVMConfig: vm.Config{
Debug: true,
Tracer: tracer,
Expand Down
6 changes: 5 additions & 1 deletion eth/tracers/internal/tracetest/calltrace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@ func TestCallTracerNative(t *testing.T) {
testCallTracer("callTracer", "call_tracer", t)
}

func TestCallTracerLegacyDuktape(t *testing.T) {
testCallTracer("callTracerLegacyDuktape", "call_tracer_legacy", t)
}

func testCallTracer(tracerName string, dirPath string, t *testing.T) {
files, err := ioutil.ReadDir(filepath.Join("testdata", dirPath))
if err != nil {
Expand Down Expand Up @@ -258,7 +262,7 @@ func BenchmarkTracers(b *testing.B) {
if err := json.Unmarshal(blob, test); err != nil {
b.Fatalf("failed to parse testcase: %v", err)
}
benchTracer("callTracerNative", test, b)
benchTracer("callTracer", test, b)
})
}
}
Expand Down
Loading

0 comments on commit 04d9a7a

Please sign in to comment.