-
Notifications
You must be signed in to change notification settings - Fork 189
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
Add UseOpcodeComputationCost option on debug API #1035
Add UseOpcodeComputationCost option on debug API #1035
Conversation
node/cn/api_backend.go
Outdated
@@ -208,6 +208,7 @@ func (b *CNAPIBackend) GetEVM(ctx context.Context, msg blockchain.Message, state | |||
vmError := func() error { return nil } | |||
|
|||
context := blockchain.NewEVMContext(msg, header, b.cn.BlockChain(), nil) | |||
vmCfg.UseOpcodeComputationCost = true |
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.
Is this change 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.
The GetEVM
method is only used in the DoCall
method, which is only used in api_public_blockchain.go.
The DoCall
method is used for EstimateGas
and EstimateComputationCost.
Like issue #1035, this change was added to prevent the estimation value from being changed in advance by not adding this change.
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.
DoCall
can be called by three different APIs: Call
, DoEstimateGas
, EstimateComputationCost
. Among them, DoEstimateGas
, EstimateComputationCost
already configure UseOpcodeComputationCost
. The other API, Call
, intentionally disabled UseOpcodeComputationCost
to provide unlimited computation for view functions of smart contracts. Therefore, this change was not appropriate for the current API policy.
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 got the point. I deleted that line, so please take another look. Thanks.
Proposed changes
UseOpcodeComputationCost
option to true in the debug api .Before
After
Before
After
works well!
Types of changes
Please put an x in the boxes related to your change.
Checklist
Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.
$ make test
)Related issues
Further comments
If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution you did and what alternatives you considered, etc...