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

fix SimulateExecution, add sgd contract check #3983

Merged
merged 7 commits into from
Nov 23, 2023

Conversation

millken
Copy link
Contributor

@millken millken commented Nov 20, 2023

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)

Test Configuration:

  • Firmware version:
  • Hardware:
  • Toolchain:
  • SDK:

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

GetBlockHash: getBlockHash,
GetBlockHash: getBlockHash,
DepositGasFunc: rewarding.DepositGasWithSGD,
Sgd: core.sgdIndexer,
Copy link
Member

Choose a reason for hiding this comment

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

will panic without WithSGDIndexer()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@@ -279,6 +280,10 @@ func ExecuteContract(
sharedGas uint64
sharedGasFee, totalGasFee *big.Int
)
// if gas price is zero, set it to smallest unit
Copy link
Member

Choose a reason for hiding this comment

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

no hard fork?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

deleted it will fix gasprice in another pr.

Comment on lines -642 to -650
// TODO: move the logic out of SimulateExecution
helperCtx := mustGetHelperCtx(ctx)
ctx = WithHelperCtx(ctx, HelperContext{
GetBlockHash: helperCtx.GetBlockHash,
DepositGasFunc: func(context.Context, protocol.StateManager, address.Address, *big.Int, *big.Int) (*action.TransactionLog, error) {
return nil, nil
},
Sgd: nil,
})
Copy link
Member

Choose a reason for hiding this comment

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

After moving this logic out, need to update on all the calling places

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed: add default depositGasFunc when ps.helperCtx.DepositGasFunc not set

Copy link

codecov bot commented Nov 21, 2023

Codecov Report

Attention: 510 lines in your changes are missing coverage. Please review.

Comparison is base (e1f0636) 75.38% compared to head (9d0a29c) 76.13%.
Report is 110 commits behind head on master.

Files Patch % Lines
blockindex/contractstaking/event_handler.go 67.23% 45 Missing and 13 partials ⚠️
action/protocol/staking/staking_statereader.go 69.76% 35 Missing and 17 partials ⚠️
action/protocol/execution/evm/evm.go 44.30% 43 Missing and 1 partial ⚠️
action/protocol/staking/protocol.go 33.33% 28 Missing ⚠️
...tion/protocol/staking/contractstake_bucket_type.go 0.00% 24 Missing ⚠️
api/coreservice.go 67.60% 17 Missing and 6 partials ⚠️
blockindex/contractstaking/util.go 39.47% 22 Missing and 1 partial ⚠️
action/protocol/rewarding/fund.go 23.07% 19 Missing and 1 partial ⚠️
api/websocket.go 0.00% 20 Missing ⚠️
action/protocol/execution/evm/evmstatedbadapter.go 0.00% 19 Missing ⚠️
... and 30 more
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3983      +/-   ##
==========================================
+ Coverage   75.38%   76.13%   +0.75%     
==========================================
  Files         303      330      +27     
  Lines       25923    28146    +2223     
==========================================
+ Hits        19541    21429    +1888     
- Misses       5360     5614     +254     
- Partials     1022     1103      +81     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -291,7 +292,14 @@ func ExecuteContract(
sharedGasFee.Mul(sharedGasFee, ps.txCtx.GasPrice)
}
totalGasFee = new(big.Int).Mul(new(big.Int).SetUint64(consumedGas), ps.txCtx.GasPrice)
depositLog, err = ps.helperCtx.DepositGasFunc(ctx, sm, receiver, totalGasFee, sharedGasFee)
if ps.helperCtx.DepositGasFunc == nil {
Copy link
Member

Choose a reason for hiding this comment

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

var depositLog, err
if ps.helperCtx.DepositGasFunc != nil {
...
}

Copy link

sonarcloud bot commented Nov 23, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

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
0.0% 0.0% Duplication

@millken millken merged commit 5df2c68 into iotexproject:master Nov 23, 2023
5 of 6 checks passed
dustinxie added a commit that referenced this pull request Aug 10, 2024
dustinxie added a commit that referenced this pull request Aug 12, 2024
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.

3 participants