tracer: port call tracer withLog
to bsc (#1261)
This commit is contained in:
parent
217e474cc6
commit
13fdb9b365
@ -382,7 +382,7 @@ func TestZeroValueToNotExitCall(t *testing.T) {
|
||||
if err := json.Unmarshal(res, have); err != nil {
|
||||
t.Fatalf("failed to unmarshal trace result: %v", err)
|
||||
}
|
||||
wantStr := `{"type":"CALL","from":"0x682a80a6f560eec50d54e63cbeda1c324c5f8d1b","to":"0x00000000000000000000000000000000deadbeef","value":"0x0","gas":"0x7148","gasUsed":"0x2d0","input":"0x","output":"0x","calls":[{"type":"CALL","from":"0x00000000000000000000000000000000deadbeef","to":"0x00000000000000000000000000000000000000ff","value":"0x0","gas":"0x6cbf","gasUsed":"0x0","input":"0x","output":"0x"}]}`
|
||||
wantStr := `{"from":"0x682a80a6f560eec50d54e63cbeda1c324c5f8d1b","gas":"0x7148","gasUsed":"0x54d8","to":"0x00000000000000000000000000000000deadbeef","input":"0x","calls":[{"from":"0x00000000000000000000000000000000deadbeef","gas":"0x6cbf","gasUsed":"0x0","to":"0x00000000000000000000000000000000000000ff","input":"0x","value":"0x0","type":"CALL"}],"value":"0x0","type":"CALL"}`
|
||||
want := new(callTrace)
|
||||
json.Unmarshal([]byte(wantStr), want)
|
||||
if !jsonEqual(have, want) {
|
||||
|
@ -48,7 +48,7 @@
|
||||
"result": {
|
||||
"from": "0x13e4acefe6a6700604929946e70e6443e4e73447",
|
||||
"gas": "0x5e106",
|
||||
"gasUsed": "0x5e106",
|
||||
"gasUsed": "0x897be",
|
||||
"input": "0x606060405260405160208061077c83398101604052808051906020019091905050600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415151561007d57600080fd5b336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555080600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506001600460006101000a81548160ff02191690831515021790555050610653806101296000396000f300606060405260043610610083576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806305e4382a146100855780631c02708d146100ae5780632e1a7d4d146100c35780635114cb52146100e6578063a37dda2c146100fe578063ae200e7914610153578063b5769f70146101a8575b005b341561009057600080fd5b6100986101d1565b6040518082815260200191505060405180910390f35b34156100b957600080fd5b6100c16101d7565b005b34156100ce57600080fd5b6100e460048080359060200190919050506102eb565b005b6100fc6004808035906020019091905050610513565b005b341561010957600080fd5b6101116105d6565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b341561015e57600080fd5b6101666105fc565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34156101b357600080fd5b6101bb610621565b6040518082815260200191505060405180910390f35b60025481565b60011515600460009054906101000a900460ff1615151415156101f957600080fd5b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614806102a15750600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b15156102ac57600080fd5b6000600460006101000a81548160ff0219169083151502179055506003543073ffffffffffffffffffffffffffffffffffffffff163103600281905550565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614806103935750600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b151561039e57600080fd5b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561048357600060025411801561040757506002548111155b151561041257600080fd5b80600254036002819055506000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050151561047e57600080fd5b610510565b600060035411801561049757506003548111155b15156104a257600080fd5b8060035403600381905550600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050151561050f57600080fd5b5b50565b60011515600460009054906101000a900460ff16151514151561053557600080fd5b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614801561059657506003548160035401115b80156105bd575080600354013073ffffffffffffffffffffffffffffffffffffffff163110155b15156105c857600080fd5b806003540160038190555050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600354815600a165627a7a72305820c3b849e8440987ce43eae3097b77672a69234d516351368b03fe5b7de03807910029000000000000000000000000c65e620a3a55451316168d57e268f5702ef56a11",
|
||||
"output": "0x606060405260043610610083576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806305e4382a146100855780631c02708d146100ae5780632e1a7d4d146100c35780635114cb52146100e6578063a37dda2c146100fe578063ae200e7914610153578063b5769f70146101a8575b005b341561009057600080fd5b6100986101d1565b6040518082815260200191505060405180910390f35b34156100b957600080fd5b6100c16101d7565b005b34156100ce57600080fd5b6100e460048080359060200190919050506102eb565b005b6100fc6004808035906020019091905050610513565b005b341561010957600080fd5b6101116105d6565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b341561015e57600080fd5b6101666105fc565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34156101b357600080fd5b6101bb610621565b6040518082815260200191505060405180910390f35b60025481565b60011515600460009054906101000a900460ff1615151415156101f957600080fd5b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614806102a15750600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b15156102ac57600080fd5b6000600460006101000a81548160ff0219169083151502179055506003543073ffffffffffffffffffffffffffffffffffffffff163103600281905550565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614806103935750600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b151561039e57600080fd5b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561048357600060025411801561040757506002548111155b151561041257600080fd5b80600254036002819055506000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050151561047e57600080fd5b610510565b600060035411801561049757506003548111155b15156104a257600080fd5b8060035403600381905550600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050151561050f57600080fd5b5b50565b60011515600460009054906101000a900460ff16151514151561053557600080fd5b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614801561059657506003548160035401115b80156105bd575080600354013073ffffffffffffffffffffffffffffffffffffffff163110155b15156105c857600080fd5b806003540160038190555050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600354815600a165627a7a72305820c3b849e8440987ce43eae3097b77672a69234d516351368b03fe5b7de03807910029",
|
||||
"to": "0x7dc9c9730689ff0b0fd506c67db815f12d90a448",
|
||||
|
@ -263,7 +263,6 @@
|
||||
"gas": "0x20ee1",
|
||||
"gasUsed": "0x5374",
|
||||
"input": "0x581d5d60000000000000000000000000c212e03b9e060e36facad5fd8f4435412ca22e6b0000000000000000000000000000000000000000000000280faf689c35ac0000",
|
||||
"output": "0x",
|
||||
"to": "0xcf00ffd997ad14939736f026006498e3f099baaf",
|
||||
"type": "CALL",
|
||||
"value": "0x0"
|
||||
@ -305,7 +304,6 @@
|
||||
"gas": "0x1a91d",
|
||||
"gasUsed": "0x12fa",
|
||||
"input": "0x0accce0600000000000000000000000000000000000000000000000000000000000000025842545553440000000000000000000000000000000000000000000000000000000000000000000000000000c212e03b9e060e36facad5fd8f4435412ca22e6b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
|
||||
"output": "0x",
|
||||
"to": "0x2a98c5f40bfa3dee83431103c535f6fae9a8ad38",
|
||||
"type": "CALL",
|
||||
"value": "0x0"
|
||||
@ -377,7 +375,6 @@
|
||||
"gas": "0x16e62",
|
||||
"gasUsed": "0xebb",
|
||||
"input": "0x645a3b72584254555344000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002816d180e30c390000",
|
||||
"output": "0x",
|
||||
"to": "0x2a98c5f40bfa3dee83431103c535f6fae9a8ad38",
|
||||
"type": "CALL",
|
||||
"value": "0x0"
|
||||
@ -387,7 +384,6 @@
|
||||
"gas": "0x283b9",
|
||||
"gasUsed": "0xc51c",
|
||||
"input": "0x949ae479000000000000000000000000c212e03b9e060e36facad5fd8f4435412ca22e6b0000000000000000000000000000000000000000000000280faf689c35ac0000",
|
||||
"output": "0x",
|
||||
"to": "0x3e9286eafa2db8101246c2131c09b49080d00690",
|
||||
"type": "CALL",
|
||||
"value": "0x0"
|
||||
@ -397,7 +393,6 @@
|
||||
"gas": "0x30b4a",
|
||||
"gasUsed": "0xedb7",
|
||||
"input": "0x51a34eb80000000000000000000000000000000000000000000000280faf689c35ac0000",
|
||||
"output": "0x",
|
||||
"to": "0xb4fe7aa695b326c9d219158d2ca50db77b39f99f",
|
||||
"type": "CALL",
|
||||
"value": "0x0"
|
||||
@ -405,9 +400,8 @@
|
||||
],
|
||||
"from": "0x70c9217d814985faef62b124420f8dfbddd96433",
|
||||
"gas": "0x37b38",
|
||||
"gasUsed": "0x12bb3",
|
||||
"gasUsed": "0x1810b",
|
||||
"input": "0x51a34eb80000000000000000000000000000000000000000000000280faf689c35ac0000",
|
||||
"output": "0x",
|
||||
"to": "0xc212e03b9e060e36facad5fd8f4435412ca22e6b",
|
||||
"type": "CALL",
|
||||
"value": "0x0"
|
||||
|
@ -87,9 +87,8 @@
|
||||
],
|
||||
"from": "0xa529806c67cc6486d4d62024471772f47f6fd672",
|
||||
"gas": "0x2d6e28",
|
||||
"gasUsed": "0x64bd",
|
||||
"gasUsed": "0xbd55",
|
||||
"input": "0x7065cb480000000000000000000000001523e55a1ca4efbae03355775ae89f8d7699ad9e",
|
||||
"output": "0x",
|
||||
"to": "0x269296dddce321a6bcbaa2f0181127593d732cba",
|
||||
"type": "CALL",
|
||||
"value": "0x0"
|
||||
|
File diff suppressed because one or more lines are too long
@ -55,9 +55,7 @@
|
||||
"to": "0x6c06b16512b332e6cd8293a2974872674716ce18",
|
||||
"value": "0x0",
|
||||
"gas": "0x1a466",
|
||||
"gasUsed": "0x1dc6",
|
||||
"input": "0x2e1a7d4d00000000000000000000000000000000000000000000000014d1120d7b160000",
|
||||
"output": "0x",
|
||||
"calls": []
|
||||
"gasUsed": "0x72de",
|
||||
"input": "0x2e1a7d4d00000000000000000000000000000000000000000000000014d1120d7b160000"
|
||||
}
|
||||
}
|
||||
|
@ -72,7 +72,7 @@
|
||||
"error": "execution reverted",
|
||||
"from": "0xd4fcab9f0a6dc0493af47c864f6f17a8a5e2e826",
|
||||
"gas": "0x78d9e",
|
||||
"gasUsed": "0x76fc0",
|
||||
"gasUsed": "0x7c1c8",
|
||||
"input": "0x",
|
||||
"to": "0x33056b5dcac09a9b4becad0e1dcf92c19bd0af76",
|
||||
"type": "CALL",
|
||||
|
@ -51,7 +51,7 @@
|
||||
"error": "out of gas",
|
||||
"from": "0x94194bc2aaf494501d7880b61274a169f6502a54",
|
||||
"gas": "0x7045",
|
||||
"gasUsed": "0x7045",
|
||||
"gasUsed": "0xca1d",
|
||||
"input": "0xa9059cbb000000000000000000000000e77b1ac803616503510bed0086e3a7be2627a69900000000000000000000000000000000000000000000000000000009502f9000",
|
||||
"to": "0x43064693d3d38ad6a7cb579e0d6d9718c8aa6b62",
|
||||
"type": "CALL",
|
||||
|
@ -49,7 +49,7 @@
|
||||
"error": "execution reverted",
|
||||
"from": "0x0f6cef2b7fbb504782e35aa82a2207e816a2b7a9",
|
||||
"gas": "0x2d55e8",
|
||||
"gasUsed": "0xc3",
|
||||
"gasUsed": "0x719b",
|
||||
"input": "0x73b40a5c000000000000000000000000400de2e016bda6577407dfc379faba9899bc73ef0000000000000000000000002cc31912b2b0f3075a87b3640923d45a26cef3ee000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000064d79d8e6c7265636f76657279416464726573730000000000000000000000000000000000000000000000000000000000383e3ec32dc0f66d8fe60dbdc2f6815bdf73a988383e3ec32dc0f66d8fe60dbdc2f6815bdf73a98800000000000000000000000000000000000000000000000000000000000000000000000000000000",
|
||||
"to": "0xabbcd5b340c80b5f1c0545c04c987b87310296ae",
|
||||
"type": "CALL",
|
||||
|
@ -54,11 +54,12 @@
|
||||
"error": "execution reverted",
|
||||
"from": "0xf7579c3d8a669c89d5ed246a22eb6db8f6fedbf1",
|
||||
"gas": "0x2d7308",
|
||||
"gasUsed": "0x588",
|
||||
"gasUsed": "0x5940",
|
||||
"input": "0x5c19a95c000000000000000000000000f7579c3d8a669c89d5ed246a22eb6db8f6fedbf1",
|
||||
"to": "0xf58833cf0c791881b494eb79d461e08a1f043f52",
|
||||
"type": "CALL",
|
||||
"value": "0x0",
|
||||
"output": "0x08c379a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000001e53656c662d64656c65676174696f6e20697320646973616c6c6f7765642e0000"
|
||||
"output": "0x08c379a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000001e53656c662d64656c65676174696f6e20697320646973616c6c6f7765642e0000",
|
||||
"revertReason": "Self-delegation is disallowed."
|
||||
}
|
||||
}
|
||||
|
@ -58,16 +58,15 @@
|
||||
"gas": "0x0",
|
||||
"gasUsed": "0x0",
|
||||
"input": "0x",
|
||||
"to": "0x000000000000000000000000000000000000dEaD",
|
||||
"to": "0x000000000000000000000000000000000000dead",
|
||||
"type": "SELFDESTRUCT",
|
||||
"value": "0x4d87094125a369d9bd5"
|
||||
}
|
||||
],
|
||||
"from": "0xb436ba50d378d4bbc8660d312a13df6af6e89dfb",
|
||||
"gas": "0x10738",
|
||||
"gasUsed": "0x7533",
|
||||
"gasUsed": "0x6fcb",
|
||||
"input": "0x63e4bff40000000000000000000000000024f658a46fbb89d8ac105e98d7ac7cbbaf27c5",
|
||||
"output": "0x",
|
||||
"to": "0x3b873a919aa0512d5a0f09e6dcceaa4a6727fafe",
|
||||
"type": "CALL",
|
||||
"value": "0x0"
|
||||
|
@ -70,7 +70,7 @@
|
||||
],
|
||||
"from": "0xb436ba50d378d4bbc8660d312a13df6af6e89dfb",
|
||||
"gas": "0x10738",
|
||||
"gasUsed": "0x3ef9",
|
||||
"gasUsed": "0x9751",
|
||||
"input": "0x63e4bff40000000000000000000000000024f658a46fbb89d8ac105e98d7ac7cbbaf27c5",
|
||||
"output": "0x0000000000000000000000000000000000000000000000000000000000000001",
|
||||
"to": "0x3b873a919aa0512d5a0f09e6dcceaa4a6727fafe",
|
||||
|
@ -62,7 +62,7 @@
|
||||
"result": {
|
||||
"from": "0xb436ba50d378d4bbc8660d312a13df6af6e89dfb",
|
||||
"gas": "0x10738",
|
||||
"gasUsed": "0x3ef9",
|
||||
"gasUsed": "0x9751",
|
||||
"input": "0x63e4bff40000000000000000000000000024f658a46fbb89d8ac105e98d7ac7cbbaf27c5",
|
||||
"output": "0x0000000000000000000000000000000000000000000000000000000000000001",
|
||||
"to": "0x3b873a919aa0512d5a0f09e6dcceaa4a6727fafe",
|
||||
|
@ -53,7 +53,7 @@
|
||||
"error": "invalid jump destination",
|
||||
"from": "0x70c9217d814985faef62b124420f8dfbddd96433",
|
||||
"gas": "0x37b38",
|
||||
"gasUsed": "0x37b38",
|
||||
"gasUsed": "0x3d090",
|
||||
"input": "0x51a34eb8000000000000000000000000000000000000000000000027fad02094277c0000",
|
||||
"to": "0xc212e03b9e060e36facad5fd8f4435412ca22e6b",
|
||||
"type": "CALL",
|
||||
|
115
eth/tracers/internal/tracetest/testdata/call_tracer_withLog/calldata.json
vendored
Normal file
115
eth/tracers/internal/tracetest/testdata/call_tracer_withLog/calldata.json
vendored
Normal file
File diff suppressed because one or more lines are too long
400
eth/tracers/internal/tracetest/testdata/call_tracer_withLog/delegatecall.json
vendored
Normal file
400
eth/tracers/internal/tracetest/testdata/call_tracer_withLog/delegatecall.json
vendored
Normal file
File diff suppressed because one or more lines are too long
2295
eth/tracers/internal/tracetest/testdata/call_tracer_withLog/multi_contracts.json
vendored
Normal file
2295
eth/tracers/internal/tracetest/testdata/call_tracer_withLog/multi_contracts.json
vendored
Normal file
File diff suppressed because one or more lines are too long
530
eth/tracers/internal/tracetest/testdata/call_tracer_withLog/multilogs.json
vendored
Normal file
530
eth/tracers/internal/tracetest/testdata/call_tracer_withLog/multilogs.json
vendored
Normal file
File diff suppressed because one or more lines are too long
286
eth/tracers/internal/tracetest/testdata/call_tracer_withLog/notopic.json
vendored
Normal file
286
eth/tracers/internal/tracetest/testdata/call_tracer_withLog/notopic.json
vendored
Normal file
File diff suppressed because one or more lines are too long
84
eth/tracers/internal/tracetest/testdata/call_tracer_withLog/simple.json
vendored
Normal file
84
eth/tracers/internal/tracetest/testdata/call_tracer_withLog/simple.json
vendored
Normal file
@ -0,0 +1,84 @@
|
||||
{
|
||||
"genesis": {
|
||||
"difficulty": "8430028481555",
|
||||
"extraData": "0xd783010302844765746887676f312e352e31856c696e7578",
|
||||
"gasLimit": "3141592",
|
||||
"hash": "0xde66937783697293f2e529d2034887c531535d78afa8c9051511ae12ba48fbea",
|
||||
"miner": "0x2a65aca4d5fc5b5c859090a6c34d164135398226",
|
||||
"mixHash": "0xba28a43bfbca4a2effbb76bb70d03482a8a0c92e2883ff36cbac3d7c6dbb7df5",
|
||||
"nonce": "0xa3827ec0a82fe823",
|
||||
"number": "765824",
|
||||
"stateRoot": "0x8d96cb027a29f8ca0ccd6d31f9ea0656136ec8030ecda70bb9231849ed6f41a2",
|
||||
"timestamp": "1451389443",
|
||||
"totalDifficulty": "4838314986494741271",
|
||||
"alloc": {
|
||||
"0xd1220a0cf47c7b9be7a2e6ba89f429762e7b9adb": {
|
||||
"balance": "0x14203bee2ea6fbe8c",
|
||||
"nonce": "34"
|
||||
},
|
||||
"0xe2fe6b13287f28e193333fdfe7fedf2f6df6124a": {
|
||||
"balance": "0x2717a9c870a286f4350"
|
||||
},
|
||||
"0xf4eced2f682ce333f96f2d8966c613ded8fc95dd": {
|
||||
"balance": "0x0",
|
||||
"code": "0x606060405260e060020a600035046306fdde038114610047578063313ce567146100a457806370a08231146100b057806395d89b41146100c8578063a9059cbb14610123575b005b61015260008054602060026001831615610100026000190190921691909104601f810182900490910260809081016040526060828152929190828280156101f55780601f106101ca576101008083540402835291602001916101f5565b6101c060025460ff1681565b6101c060043560036020526000908152604090205481565b610152600180546020601f6002600019610100858716150201909316929092049182018190040260809081016040526060828152929190828280156101f55780601f106101ca576101008083540402835291602001916101f5565b610045600435602435600160a060020a033316600090815260036020526040902054819010156101fd57610002565b60405180806020018281038252838181518152602001915080519060200190808383829060006004602084601f0104600302600f01f150905090810190601f1680156101b25780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6060908152602090f35b820191906000526020600020905b8154815290600101906020018083116101d857829003601f168201915b505050505081565b600160a060020a03821660009081526040902054808201101561021f57610002565b806003600050600033600160a060020a03168152602001908152602001600020600082828250540392505081905550806003600050600084600160a060020a0316815260200190815260200160002060008282825054019250508190555081600160a060020a031633600160a060020a03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3505056",
|
||||
"storage": {
|
||||
"0x1dae8253445d3a5edbe8200da9fc39bc4f11db9362181dc1b640d08c3c2fb4d6": "0x0000000000000000000000000000000000000000000000000000000000000000",
|
||||
"0x8ba52aac7f255d80a49abcf003d6af4752aba5a9531cae94fde7ac8d72191d67": "0x000000000000000000000000000000000000000000000000000000000178e460"
|
||||
}
|
||||
}
|
||||
},
|
||||
"config": {
|
||||
"chainId": 1,
|
||||
"homesteadBlock": 1150000,
|
||||
"daoForkBlock": 1920000,
|
||||
"daoForkSupport": true,
|
||||
"eip150Block": 2463000,
|
||||
"eip150Hash": "0x2086799aeebeae135c246c65021c82b4e15a2c451340993aacfd2751886514f0",
|
||||
"eip155Block": 2675000,
|
||||
"eip158Block": 2675000,
|
||||
"byzantiumBlock": 4370000,
|
||||
"constantinopleBlock": 7280000,
|
||||
"petersburgBlock": 7280000,
|
||||
"istanbulBlock": 9069000,
|
||||
"muirGlacierBlock": 9200000,
|
||||
"berlinBlock": 12244000,
|
||||
"londonBlock": 12965000,
|
||||
"arrowGlacierBlock": 13773000,
|
||||
"grayGlacierBlock": 15050000,
|
||||
"terminalTotalDifficultyPassed": true,
|
||||
"ethash": {}
|
||||
}
|
||||
},
|
||||
"context": {
|
||||
"number": "765825",
|
||||
"difficulty": "8425912256743",
|
||||
"timestamp": "1451389488",
|
||||
"gasLimit": "3141592",
|
||||
"miner": "0xe2fe6b13287f28e193333fdfe7fedf2f6df6124a"
|
||||
},
|
||||
"input": "0xf8aa22850ba43b740083024d4594f4eced2f682ce333f96f2d8966c613ded8fc95dd80b844a9059cbb000000000000000000000000dbf03b407c01e7cd3cbea99509d93f8dddc8c6fb00000000000000000000000000000000000000000000000000000000009896801ca067da548a2e0f381a957b9b51f086073375d6bfc7312cbc9540b3647ccab7db11a042c6e5b34bc7ba821e9c25b166fa13d82ad4b0d044d16174d5587d4f04ecfcd1",
|
||||
"tracerConfig": {
|
||||
"withLog": true
|
||||
},
|
||||
"result": {
|
||||
"from": "0xd1220a0cf47c7b9be7a2e6ba89f429762e7b9adb",
|
||||
"gas": "0x1f36d",
|
||||
"gasUsed": "0xc6a5",
|
||||
"to": "0xf4eced2f682ce333f96f2d8966c613ded8fc95dd",
|
||||
"input": "0xa9059cbb000000000000000000000000dbf03b407c01e7cd3cbea99509d93f8dddc8c6fb0000000000000000000000000000000000000000000000000000000000989680",
|
||||
"logs": [
|
||||
{
|
||||
"address": "0xf4eced2f682ce333f96f2d8966c613ded8fc95dd",
|
||||
"topics": [
|
||||
"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
|
||||
"0x000000000000000000000000d1220a0cf47c7b9be7a2e6ba89f429762e7b9adb",
|
||||
"0x000000000000000000000000dbf03b407c01e7cd3cbea99509d93f8dddc8c6fb"
|
||||
],
|
||||
"data": "0x0000000000000000000000000000000000000000000000000000000000989680"
|
||||
}
|
||||
],
|
||||
"value": "0x0",
|
||||
"type": "CALL"
|
||||
}
|
||||
}
|
244
eth/tracers/internal/tracetest/testdata/call_tracer_withLog/tx_failed.json
vendored
Normal file
244
eth/tracers/internal/tracetest/testdata/call_tracer_withLog/tx_failed.json
vendored
Normal file
File diff suppressed because one or more lines are too long
107
eth/tracers/internal/tracetest/testdata/call_tracer_withLog/tx_partial_failed.json
vendored
Normal file
107
eth/tracers/internal/tracetest/testdata/call_tracer_withLog/tx_partial_failed.json
vendored
Normal file
File diff suppressed because one or more lines are too long
89
eth/tracers/internal/tracetest/testdata/call_tracer_withLog/with_onlyTopCall.json
vendored
Normal file
89
eth/tracers/internal/tracetest/testdata/call_tracer_withLog/with_onlyTopCall.json
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -20,43 +20,96 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"math/big"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
"github.com/ethereum/go-ethereum/accounts/abi"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||
"github.com/ethereum/go-ethereum/core/vm"
|
||||
"github.com/ethereum/go-ethereum/eth/tracers"
|
||||
)
|
||||
|
||||
//go:generate go run github.com/fjl/gencodec -type callFrame -field-override callFrameMarshaling -out gen_callframe_json.go
|
||||
|
||||
func init() {
|
||||
register("callTracer", newCallTracer)
|
||||
}
|
||||
|
||||
type callLog struct {
|
||||
Address common.Address `json:"address"`
|
||||
Topics []common.Hash `json:"topics"`
|
||||
Data hexutil.Bytes `json:"data"`
|
||||
}
|
||||
|
||||
type callFrame struct {
|
||||
Type string `json:"type"`
|
||||
From string `json:"from"`
|
||||
To string `json:"to,omitempty"`
|
||||
Value string `json:"value,omitempty"`
|
||||
Gas string `json:"gas"`
|
||||
GasUsed string `json:"gasUsed"`
|
||||
Input string `json:"input"`
|
||||
Output string `json:"output,omitempty"`
|
||||
Error string `json:"error,omitempty"`
|
||||
Calls []callFrame `json:"calls,omitempty"`
|
||||
Type vm.OpCode `json:"-"`
|
||||
From common.Address `json:"from"`
|
||||
Gas uint64 `json:"gas"`
|
||||
GasUsed uint64 `json:"gasUsed"`
|
||||
To common.Address `json:"to,omitempty" rlp:"optional"`
|
||||
Input []byte `json:"input" rlp:"optional"`
|
||||
Output []byte `json:"output,omitempty" rlp:"optional"`
|
||||
Error string `json:"error,omitempty" rlp:"optional"`
|
||||
Revertal string `json:"revertReason,omitempty"`
|
||||
Calls []callFrame `json:"calls,omitempty" rlp:"optional"`
|
||||
Logs []callLog `json:"logs,omitempty" rlp:"optional"`
|
||||
// Placed at end on purpose. The RLP will be decoded to 0 instead of
|
||||
// nil if there are non-empty elements after in the struct.
|
||||
Value *big.Int `json:"value,omitempty" rlp:"optional"`
|
||||
}
|
||||
|
||||
func (f callFrame) TypeString() string {
|
||||
return f.Type.String()
|
||||
}
|
||||
|
||||
func (f callFrame) failed() bool {
|
||||
return len(f.Error) > 0
|
||||
}
|
||||
|
||||
func (f *callFrame) processOutput(output []byte, err error) {
|
||||
output = common.CopyBytes(output)
|
||||
if err == nil {
|
||||
f.Output = output
|
||||
return
|
||||
}
|
||||
f.Error = err.Error()
|
||||
if f.Type == vm.CREATE || f.Type == vm.CREATE2 {
|
||||
f.To = common.Address{}
|
||||
}
|
||||
if !errors.Is(err, vm.ErrExecutionReverted) || len(output) == 0 {
|
||||
return
|
||||
}
|
||||
f.Output = output
|
||||
if len(output) < 4 {
|
||||
return
|
||||
}
|
||||
if unpacked, err := abi.UnpackRevert(output); err == nil {
|
||||
f.Revertal = unpacked
|
||||
}
|
||||
}
|
||||
|
||||
type callFrameMarshaling struct {
|
||||
TypeString string `json:"type"`
|
||||
Gas hexutil.Uint64
|
||||
GasUsed hexutil.Uint64
|
||||
Value *hexutil.Big
|
||||
Input hexutil.Bytes
|
||||
Output hexutil.Bytes
|
||||
}
|
||||
|
||||
type callTracer struct {
|
||||
env *vm.EVM
|
||||
noopTracer
|
||||
callstack []callFrame
|
||||
config callTracerConfig
|
||||
gasLimit uint64
|
||||
interrupt uint32 // Atomic flag to signal execution interruption
|
||||
reason error // Textual reason for the interruption
|
||||
}
|
||||
|
||||
type callTracerConfig struct {
|
||||
OnlyTopCall bool `json:"onlyTopCall"` // If true, call tracer won't collect any subcalls
|
||||
WithLog bool `json:"withLog"` // If true, call tracer will collect event logs
|
||||
}
|
||||
|
||||
// newCallTracer returns a native go tracer which tracks
|
||||
@ -75,39 +128,58 @@ func newCallTracer(ctx *tracers.Context, cfg json.RawMessage) (tracers.Tracer, e
|
||||
|
||||
// CaptureStart implements the EVMLogger interface to initialize the tracing operation.
|
||||
func (t *callTracer) CaptureStart(env *vm.EVM, from common.Address, to common.Address, create bool, input []byte, gas uint64, value *big.Int) {
|
||||
t.env = env
|
||||
t.callstack[0] = callFrame{
|
||||
Type: "CALL",
|
||||
From: addrToHex(from),
|
||||
To: addrToHex(to),
|
||||
Input: bytesToHex(input),
|
||||
Gas: uintToHex(gas),
|
||||
Value: bigToHex(value),
|
||||
Type: vm.CALL,
|
||||
From: from,
|
||||
To: to,
|
||||
Input: common.CopyBytes(input),
|
||||
Gas: gas,
|
||||
Value: value,
|
||||
}
|
||||
if create {
|
||||
t.callstack[0].Type = "CREATE"
|
||||
t.callstack[0].Type = vm.CREATE
|
||||
}
|
||||
}
|
||||
|
||||
// CaptureEnd is called after the call finishes to finalize the tracing.
|
||||
func (t *callTracer) CaptureEnd(output []byte, gasUsed uint64, _ time.Duration, err error) {
|
||||
t.callstack[0].GasUsed = uintToHex(gasUsed)
|
||||
if err != nil {
|
||||
t.callstack[0].Error = err.Error()
|
||||
if err.Error() == "execution reverted" && len(output) > 0 {
|
||||
t.callstack[0].Output = bytesToHex(output)
|
||||
}
|
||||
} else {
|
||||
t.callstack[0].Output = bytesToHex(output)
|
||||
}
|
||||
func (t *callTracer) CaptureEnd(output []byte, gasUsed uint64, d time.Duration, err error) {
|
||||
t.callstack[0].processOutput(output, err)
|
||||
}
|
||||
|
||||
// CaptureState implements the EVMLogger interface to trace a single step of VM execution.
|
||||
func (t *callTracer) CaptureState(pc uint64, op vm.OpCode, gas, cost uint64, scope *vm.ScopeContext, rData []byte, depth int, err error) {
|
||||
}
|
||||
// Only logs need to be captured via opcode processing
|
||||
if !t.config.WithLog {
|
||||
return
|
||||
}
|
||||
// Avoid processing nested calls when only caring about top call
|
||||
if t.config.OnlyTopCall && depth > 0 {
|
||||
return
|
||||
}
|
||||
// Skip if tracing was interrupted
|
||||
if atomic.LoadUint32(&t.interrupt) > 0 {
|
||||
return
|
||||
}
|
||||
switch op {
|
||||
case vm.LOG0, vm.LOG1, vm.LOG2, vm.LOG3, vm.LOG4:
|
||||
size := int(op - vm.LOG0)
|
||||
|
||||
// CaptureFault implements the EVMLogger interface to trace an execution fault.
|
||||
func (t *callTracer) CaptureFault(pc uint64, op vm.OpCode, gas, cost uint64, _ *vm.ScopeContext, depth int, err error) {
|
||||
stack := scope.Stack
|
||||
stackData := stack.Data()
|
||||
|
||||
// Don't modify the stack
|
||||
mStart := stackData[len(stackData)-1]
|
||||
mSize := stackData[len(stackData)-2]
|
||||
topics := make([]common.Hash, size)
|
||||
for i := 0; i < size; i++ {
|
||||
topic := stackData[len(stackData)-2-(i+1)]
|
||||
topics[i] = common.Hash(topic.Bytes32())
|
||||
}
|
||||
|
||||
data := scope.Memory.GetCopy(int64(mStart.Uint64()), int64(mSize.Uint64()))
|
||||
log := callLog{Address: scope.Contract.Address(), Topics: topics, Data: hexutil.Bytes(data)}
|
||||
t.callstack[len(t.callstack)-1].Logs = append(t.callstack[len(t.callstack)-1].Logs, log)
|
||||
}
|
||||
}
|
||||
|
||||
// CaptureEnter is called when EVM enters a new scope (via call, create or selfdestruct).
|
||||
@ -117,17 +189,16 @@ func (t *callTracer) CaptureEnter(typ vm.OpCode, from common.Address, to common.
|
||||
}
|
||||
// Skip if tracing was interrupted
|
||||
if atomic.LoadUint32(&t.interrupt) > 0 {
|
||||
t.env.Cancel()
|
||||
return
|
||||
}
|
||||
|
||||
call := callFrame{
|
||||
Type: typ.String(),
|
||||
From: addrToHex(from),
|
||||
To: addrToHex(to),
|
||||
Input: bytesToHex(input),
|
||||
Gas: uintToHex(gas),
|
||||
Value: bigToHex(value),
|
||||
Type: typ,
|
||||
From: from,
|
||||
To: to,
|
||||
Input: common.CopyBytes(input),
|
||||
Gas: gas,
|
||||
Value: value,
|
||||
}
|
||||
t.callstack = append(t.callstack, call)
|
||||
}
|
||||
@ -147,21 +218,22 @@ func (t *callTracer) CaptureExit(output []byte, gasUsed uint64, err error) {
|
||||
t.callstack = t.callstack[:size-1]
|
||||
size -= 1
|
||||
|
||||
call.GasUsed = uintToHex(gasUsed)
|
||||
if err == nil {
|
||||
call.Output = bytesToHex(output)
|
||||
} else {
|
||||
call.Error = err.Error()
|
||||
if call.Type == "CREATE" || call.Type == "CREATE2" {
|
||||
call.To = ""
|
||||
}
|
||||
}
|
||||
call.GasUsed = gasUsed
|
||||
call.processOutput(output, err)
|
||||
t.callstack[size-1].Calls = append(t.callstack[size-1].Calls, call)
|
||||
}
|
||||
|
||||
func (*callTracer) CaptureTxStart(gasLimit uint64) {}
|
||||
func (t *callTracer) CaptureTxStart(gasLimit uint64) {
|
||||
t.gasLimit = gasLimit
|
||||
}
|
||||
|
||||
func (*callTracer) CaptureTxEnd(restGas uint64) {}
|
||||
func (t *callTracer) CaptureTxEnd(restGas uint64) {
|
||||
t.callstack[0].GasUsed = t.gasLimit - restGas
|
||||
if t.config.WithLog {
|
||||
// Logs are not emitted when the call fails
|
||||
clearFailedLogs(&t.callstack[0], false)
|
||||
}
|
||||
}
|
||||
|
||||
// GetResult returns the json-encoded nested list of call traces, and any
|
||||
// error arising from the encoding or forceful termination (via `Stop`).
|
||||
@ -182,6 +254,19 @@ func (t *callTracer) Stop(err error) {
|
||||
atomic.StoreUint32(&t.interrupt, 1)
|
||||
}
|
||||
|
||||
// clearFailedLogs clears the logs of a callframe and all its children
|
||||
// in case of execution failure.
|
||||
func clearFailedLogs(cf *callFrame, parentFailed bool) {
|
||||
failed := cf.failed() || parentFailed
|
||||
// Clear own logs
|
||||
if failed {
|
||||
cf.Logs = nil
|
||||
}
|
||||
for i := range cf.Calls {
|
||||
clearFailedLogs(&cf.Calls[i], failed)
|
||||
}
|
||||
}
|
||||
|
||||
func bytesToHex(s []byte) string {
|
||||
return "0x" + common.Bytes2Hex(s)
|
||||
}
|
||||
@ -192,11 +277,3 @@ func bigToHex(n *big.Int) string {
|
||||
}
|
||||
return "0x" + n.Text(16)
|
||||
}
|
||||
|
||||
func uintToHex(n uint64) string {
|
||||
return "0x" + strconv.FormatUint(n, 16)
|
||||
}
|
||||
|
||||
func addrToHex(a common.Address) string {
|
||||
return strings.ToLower(a.Hex())
|
||||
}
|
||||
|
107
eth/tracers/native/gen_callframe_json.go
Normal file
107
eth/tracers/native/gen_callframe_json.go
Normal file
@ -0,0 +1,107 @@
|
||||
// Code generated by github.com/fjl/gencodec. DO NOT EDIT.
|
||||
|
||||
package native
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"math/big"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||
"github.com/ethereum/go-ethereum/core/vm"
|
||||
)
|
||||
|
||||
var _ = (*callFrameMarshaling)(nil)
|
||||
|
||||
// MarshalJSON marshals as JSON.
|
||||
func (c callFrame) MarshalJSON() ([]byte, error) {
|
||||
type callFrame0 struct {
|
||||
Type vm.OpCode `json:"-"`
|
||||
From common.Address `json:"from"`
|
||||
Gas hexutil.Uint64 `json:"gas"`
|
||||
GasUsed hexutil.Uint64 `json:"gasUsed"`
|
||||
To common.Address `json:"to,omitempty" rlp:"optional"`
|
||||
Input hexutil.Bytes `json:"input" rlp:"optional"`
|
||||
Output hexutil.Bytes `json:"output,omitempty" rlp:"optional"`
|
||||
Error string `json:"error,omitempty" rlp:"optional"`
|
||||
Revertal string `json:"revertReason,omitempty"`
|
||||
Calls []callFrame `json:"calls,omitempty" rlp:"optional"`
|
||||
Logs []callLog `json:"logs,omitempty" rlp:"optional"`
|
||||
Value *hexutil.Big `json:"value,omitempty" rlp:"optional"`
|
||||
TypeString string `json:"type"`
|
||||
}
|
||||
var enc callFrame0
|
||||
enc.Type = c.Type
|
||||
enc.From = c.From
|
||||
enc.Gas = hexutil.Uint64(c.Gas)
|
||||
enc.GasUsed = hexutil.Uint64(c.GasUsed)
|
||||
enc.To = c.To
|
||||
enc.Input = c.Input
|
||||
enc.Output = c.Output
|
||||
enc.Error = c.Error
|
||||
enc.Revertal = c.Revertal
|
||||
enc.Calls = c.Calls
|
||||
enc.Logs = c.Logs
|
||||
enc.Value = (*hexutil.Big)(c.Value)
|
||||
enc.TypeString = c.TypeString()
|
||||
return json.Marshal(&enc)
|
||||
}
|
||||
|
||||
// UnmarshalJSON unmarshals from JSON.
|
||||
func (c *callFrame) UnmarshalJSON(input []byte) error {
|
||||
type callFrame0 struct {
|
||||
Type *vm.OpCode `json:"-"`
|
||||
From *common.Address `json:"from"`
|
||||
Gas *hexutil.Uint64 `json:"gas"`
|
||||
GasUsed *hexutil.Uint64 `json:"gasUsed"`
|
||||
To *common.Address `json:"to,omitempty" rlp:"optional"`
|
||||
Input *hexutil.Bytes `json:"input" rlp:"optional"`
|
||||
Output *hexutil.Bytes `json:"output,omitempty" rlp:"optional"`
|
||||
Error *string `json:"error,omitempty" rlp:"optional"`
|
||||
Revertal *string `json:"revertReason,omitempty"`
|
||||
Calls []callFrame `json:"calls,omitempty" rlp:"optional"`
|
||||
Logs []callLog `json:"logs,omitempty" rlp:"optional"`
|
||||
Value *hexutil.Big `json:"value,omitempty" rlp:"optional"`
|
||||
}
|
||||
var dec callFrame0
|
||||
if err := json.Unmarshal(input, &dec); err != nil {
|
||||
return err
|
||||
}
|
||||
if dec.Type != nil {
|
||||
c.Type = *dec.Type
|
||||
}
|
||||
if dec.From != nil {
|
||||
c.From = *dec.From
|
||||
}
|
||||
if dec.Gas != nil {
|
||||
c.Gas = uint64(*dec.Gas)
|
||||
}
|
||||
if dec.GasUsed != nil {
|
||||
c.GasUsed = uint64(*dec.GasUsed)
|
||||
}
|
||||
if dec.To != nil {
|
||||
c.To = *dec.To
|
||||
}
|
||||
if dec.Input != nil {
|
||||
c.Input = *dec.Input
|
||||
}
|
||||
if dec.Output != nil {
|
||||
c.Output = *dec.Output
|
||||
}
|
||||
if dec.Error != nil {
|
||||
c.Error = *dec.Error
|
||||
}
|
||||
if dec.Revertal != nil {
|
||||
c.Revertal = *dec.Revertal
|
||||
}
|
||||
if dec.Calls != nil {
|
||||
c.Calls = dec.Calls
|
||||
}
|
||||
if dec.Logs != nil {
|
||||
c.Logs = dec.Logs
|
||||
}
|
||||
if dec.Value != nil {
|
||||
c.Value = (*big.Int)(dec.Value)
|
||||
}
|
||||
return nil
|
||||
}
|
Loading…
Reference in New Issue
Block a user