Skip to content
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

[evm] manually correct gas refund in case opcode execution returns Er… #3690

Merged
merged 15 commits into from
Dec 2, 2022

Conversation

dustinxie
Copy link
Member

…rWriteProtection

Description

as title

Fixes #(issue)

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • [] New feature (non-breaking change which adds functionality)
  • [] Code refactor or improvement
  • [] Breaking change (fix or feature that would cause a new or changed behavior of existing functionality)
  • [] This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • make test
  • fullsync
  • [] Other test (please specify)

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

@dustinxie dustinxie requested a review from a team as a code owner November 8, 2022 04:08
go.mod Outdated
@@ -200,6 +200,6 @@ require (
gopkg.in/yaml.v3 v3.0.1 // indirect
)

replace github.com/ethereum/go-ethereum => github.com/iotexproject/go-ethereum v0.4.1
replace github.com/ethereum/go-ethereum => github.com/iotexproject/go-ethereum v1.7.4-0.20221107225611-7cbc562f7437
Copy link
Member Author

@dustinxie dustinxie Nov 8, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

iotexproject/go-ethereum@9c1b37b

once verified fullsync, it will become a tag/version

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it seems i cannot create a PR using this commit ( atari branch against v0.4.1 tag)

@codecov
Copy link

codecov bot commented Nov 8, 2022

Codecov Report

Merging #3690 (0352587) into master (263ff82) will decrease coverage by 0.50%.
The diff coverage is 84.06%.

@@            Coverage Diff             @@
##           master    #3690      +/-   ##
==========================================
- Coverage   74.47%   73.97%   -0.51%     
==========================================
  Files         269      291      +22     
  Lines       23925    24691     +766     
==========================================
+ Hits        17818    18265     +447     
- Misses       5174     5494     +320     
+ Partials      933      932       -1     
Impacted Files Coverage Δ
action/protocol/context.go 66.40% <0.00%> (-1.60%) ⬇️
action/protocol/rewarding/reward.go 90.03% <ø> (-0.04%) ⬇️
action/protocol/staking/candidate_statereader.go 53.94% <ø> (-3.38%) ⬇️
action/protocol/types.go 0.00% <0.00%> (ø)
api/web3server.go 27.59% <0.00%> (-34.51%) ⬇️
db/db_bolt.go 68.53% <0.00%> (-3.60%) ⬇️
ioctl/newcmd/action/actiontransfer.go 100.00% <ø> (ø)
ioctl/newcmd/action/stake2withdraw.go 95.74% <ø> (ø)
ioctl/newcmd/action/xrc20transferfrom.go 100.00% <ø> (ø)
ioctl/newcmd/did/didgethash.go 100.00% <ø> (ø)
... and 44 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@Liuhaai
Copy link
Member

Liuhaai commented Nov 14, 2022

lgtm, let me know if the testings pass

@millken
Copy link
Contributor

millken commented Nov 24, 2022

lgtm, let me know if the testings pass

fullsync passed


func TestSmartContractTest(t *testing.T) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can move to a t.Run() like those above?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a debug code, has been removed

Copy link
Collaborator

@CoderZhi CoderZhi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i am still not convinced that the unit tests cover all cases. try your best to enrich the unit tests if possible.

"expectedLogs": [{}],
"hasReturnValue": true,
"rawReturnValue": "",
"comment": "call make"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrong comment

"expectedLogs": [{},{}],
"hasReturnValue": true,
"rawReturnValue": "",
"comment": "call make"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrong comment

"expectedLogs": [{}],
"hasReturnValue": true,
"rawReturnValue": "",
"comment": "call make"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrong comment

"expectedLogs": [{}],
"hasReturnValue": true,
"rawReturnValue": "",
"comment": "call make"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrong comment

refundLastSnapshot = stateDB.RefundAtLastSnapshot()
currentRefund = stateDB.GetRefund()
featureCtx = protocol.MustGetFeatureCtx(ctx)
deltaRefundByDynamicGas = evm.DeltaRefundByDynamicGas
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

txcontext is not an ideal place to store the deltarefund. StateDB should be the only place to interact with evm from outside. we may add an interface to set delta refund value. Consequently, we can all stateDB.GetRefundWithDelta, and do not to fetch feature context here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the interface (SetDelta, GetRefundWithDelta) needs to be implemented in go-ethereum and iotex-core, but not necessary for go-ethereum. the current deltaRefund is just a temporary variable, I think there is no problem.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TxContext.Origin and TxContext.GasPrice are also used in our iotex-core code, so i think it's fine to use it

@sonarcloud
Copy link

sonarcloud bot commented Dec 2, 2022

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
7.3% 7.3% Duplication

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants