-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
support for golang tracers + add golang callTracer #558
Conversation
minor changes in API refine api_tracer.go refine Tracer interface
This PR's XXX_legacy.js tracers are not completely equal to XXX.js tracers before this PR. Shall we make XXX_legacy.js equal to prior XXX.js? |
@@ -99,14 +100,19 @@ func IntrinsicGas(data []byte, accessList types.AccessList, isContractCreation, | |||
} | |||
} | |||
// Make sure we don't exceed uint64 for all data combinations | |||
if (math.MaxUint64-gas)/params.TxDataNonZeroGas < nz { | |||
return 0, vm.ErrOutOfGas |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you have to change these parts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is for preparation of EIP2028. The reason we need EIP2028 is as follows:
If EIP2028 is not enabled, the test revert_reason.json
will not pass unless we change the test itself. Check this commit that change the test json itself: 0a496c3
So actually this code change does not necessary belong to this PR. Do you want me to undo it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The consensus will be changed if we enable eip-2028. I can include it in the PR of EIP-1559 if you need it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes please let's remove that from this PR. It would be a separate discussion if EIP-2028 is useful for XDC.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes please let's remove that from this PR. It would be a separate discussion if EIP-2028 is useful for XDC.
I removed it and force pushed commits.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The consensus will be changed if we enable eip-2028. I can include it in the PR of EIP-1559 if you need it.
No hurry. At the time of eip2028, we need to remember to undo this commit: e1b7ba6
eth/tracers/native/call.go
Outdated
) | ||
|
||
func init() { | ||
tracers.RegisterNativeTracer("callTracerNative", NewCallTracer) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can directly make this default callTracer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. Then this tracer will override js tracer with the same name. Shall we name the js tracer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right callTracer
should be the native tracer. IMO the old one can be kept as callTracerLegacy
and the "new" JS call tracer I don't think it's really necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed native tracer to the default one, for call tracer and noop tracer.
Can you post the diff? |
Sure. The diff by running
For other tracers, legacy tracer and dev-upgrade tracer are the same. |
between those two files |
So I guess |
Request: curl -s -X POST -H "Content-Type: application/json" ${RPC} -d '{
"jsonrpc": "2.0",
"id": 1001,
"method": "debug_traceBlockByNumber",
"params": [
"latest",
{"tracer":"callTracer"}
]
}' | jq Response: {
"jsonrpc": "2.0",
"id": 1001,
"result": [
{
"result": {
"type": "CALL",
"from": "xdc4398241671b3dd484fe3213a4fb7511f30e7d7c0",
"to": "xdc0000000000000000000000000000000000000089",
"value": "0x0",
"gas": "0x2b068",
"gasUsed": "0x147ce",
"input": "0xe341eaa400000000000000000000000000000000000000000000000000000000002b85b848d26996721c2750b15a0a5d37de015365ae688b0bb031e52723d6e4d73d63ae",
"output": "0x"
}
}
]
} Why from and to are xdc prefix ? |
eth/tracers/native/call.go
Outdated
@@ -166,5 +166,6 @@ func uintToHex(n uint64) string { | |||
} | |||
|
|||
func addrToHex(a common.Address) string { | |||
return strings.ToLower(a.Hex()) | |||
s, _ := a.MarshalText() | |||
return strings.ToLower(string(s)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why call strings.ToLower
? I think return string(s)
is enough:
- We should keep the address is checksumed
- reduce CPU cost and network response time
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. Ethereum uses lower case. If we don't need lower case we can just return the string(s)
The |
core/state_transition.go
Outdated
@@ -273,7 +266,7 @@ func (st *StateTransition) TransitionDb(owner common.Address) (ret []byte, usedG | |||
// sufficient balance to make the transfer happen. The first | |||
// balance transfer may never fail. | |||
if vmerr == vm.ErrInsufficientBalance { | |||
return nil, 0, false, vmerr, nil | |||
return nil, 0, false, nil, vmerr |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain this change? It is a sensitive part of the code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am convinced this will introduce a bug and should be resolved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. I checked history geth commit: ethereum@b9df7ec
Although the variable name is vmerr, this error means no balance to pay for the tx. It should be consensus err and should be returned in 4-th err
place.
I'll revert this
@@ -1,4 +1,4 @@ | |||
// Copyright 2017 The go-ethereum Authors | |||
// Copyright 2021 The go-ethereum Authors |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe there is no way to access this particular tracer. It has the same name as the native callTracer. IMHO we can simply drop this (or replace the callTracerLegacy
with it). Depends if we want users to still access the "old tracer".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can drop it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe there is no way to access this particular tracer. It has the same name as the native callTracer. IMHO we can simply drop this (or replace the
callTracerLegacy
with it). Depends if we want users to still access the "old tracer".
fixed and code pushed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me
* feat: rename Tracer interface to EVMLogger; minor changes in API refine api_tracer.go refine Tracer interface * fix: broken tracer tests * feat: add BenchmarkTransactionTrace * feat: tracer CaptureEnter CaptureExit in evm * feat: upgrade js tracers with geth upstream * chore: clean test * feat: eth/tracers: support for golang tracers + add golang callTracer cf. ethereum#23708 * chore: clean testdata json * fix: change test due to IntrinsicGas is not upgraded * feat: make native Tracer the default Tracer * fix: update tracers.New in api * fix: addr prefix in callTracer * fix: remove `native` in BenchmarkTracers * fix: return consensus error of InsufficientBalance for tx, instead of vmerr * chore: drop js tracers: call and noop
Proposed changes
support for golang tracers + add golang callTracer
Types of changes
What types of changes does your code introduce to XDC network?
Put an
✅
in the boxes that applyImpacted Components
Which part of the codebase this PR will touch base on,
Put an
✅
in the boxes that applyChecklist
Put an
✅
in the boxes once you have confirmed below actions (or provide reasons on not doing so) that