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 test and speedup validation #3842

Merged
merged 3 commits into from
Apr 10, 2023
Merged

Conversation

dustinxie
Copy link
Member

Description

backport haixiang's fix to master branch

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

@codecov
Copy link

codecov bot commented Apr 5, 2023

Codecov Report

Merging #3842 (ba86a01) into master (e1f0636) will increase coverage by 0.00%.
The diff coverage is 68.42%.

❗ Current head ba86a01 differs from pull request most recent head 0594a62. Consider uploading reports for the commit 0594a62 to get more accurate results

@@           Coverage Diff           @@
##           master    #3842   +/-   ##
=======================================
  Coverage   75.38%   75.38%           
=======================================
  Files         303      303           
  Lines       25923    26014   +91     
=======================================
+ Hits        19541    19610   +69     
- Misses       5360     5379   +19     
- Partials     1022     1025    +3     
Impacted Files Coverage Δ
api/web3server_marshal.go 93.21% <ø> (ø)
api/web3server_utils.go 69.20% <16.66%> (-3.67%) ⬇️
state/factory/workingset.go 68.60% <28.57%> (-2.83%) ⬇️
api/serverV2.go 86.95% <50.00%> (ø)
api/web3server.go 81.41% <87.50%> (+2.74%) ⬆️
api/coreservice.go 68.09% <88.23%> (+0.74%) ⬆️
action/protocol/context.go 67.17% <100.00%> (ø)
blockchain/genesis/genesis.go 72.36% <100.00%> (ø)

... and 1 file with indirect coverage changes

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

@dustinxie dustinxie force-pushed the master branch 2 times, most recently from 189d08d to 2b01c59 Compare April 5, 2023 23:11
@dustinxie dustinxie requested a review from a team as a code owner April 5, 2023 23:11
@@ -15,5 +15,5 @@ import (
func TestTimestamp(t *testing.T) {
assert := assert.New(t)
time1 := TimestampNow()
assert.True(time.Now().After(time1))
assert.False(time.Now().Before(time1))
Copy link
Member Author

Choose a reason for hiding this comment

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

sometimes it happens that time.Now() == time1, causing CI test to fail

@@ -110,7 +110,7 @@ type (
CorrectGasRefund bool
FixRewardErroCheckPosition bool
EnableWeb3Rewarding bool
EnableNodeInfo bool
SkipSystemActionNonce bool
Copy link
Member Author

Choose a reason for hiding this comment

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

EnableNodeInfo is not used at all

} else {
if err := ws.validateNonce(ctx, blk); err != nil {
return errors.Wrap(err, "failed to validate nonce")
}
Copy link
Member Author

Choose a reason for hiding this comment

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

block 1 has 2 tx, from the same sender io1vtm2zgn830pn6auc2cvnchgwdaefa9gr4z0s86, both with nonce=0, one is a transfer, the other is grant reward (system action)

validateNonce2() will ignore the grant reward, but return error for the transfer tx (since it's expecting nonce=1 but got nonce=0), so we have to keep the height check and 2 validate()


// Special handling for genesis block
if blk.Height() == 0 {
return nil
Copy link
Member

Choose a reason for hiding this comment

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

duplicated with L338-L340, moved into checkNonceContinuity()?

Copy link
Member Author

Choose a reason for hiding this comment

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

tested it's actually not needed

return ws.checkNonceContinuity(ctx, accountNonceMap)
}

func (ws *workingSet) validateNonce2(ctx context.Context, blk *block.Block) error {
Copy link
Member

Choose a reason for hiding this comment

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

better name than validateNonce2?

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed

@sonarcloud
Copy link

sonarcloud bot commented Apr 10, 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
No Duplication information No Duplication information

@dustinxie dustinxie merged commit 64dd415 into iotexproject:master Apr 10, 2023
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