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

add precommit #3660

Closed
wants to merge 1 commit into from
Closed

add precommit #3660

wants to merge 1 commit into from

Conversation

CoderZhi
Copy link
Collaborator

Add an interface PreCommitter. Protocols which are PreCommitter will be called before a workingset commit.

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

@CoderZhi CoderZhi requested a review from a team as a code owner October 11, 2022 16:45
@sonarcloud
Copy link

sonarcloud bot commented Oct 11, 2022

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 2 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@codecov
Copy link

codecov bot commented Oct 11, 2022

Codecov Report

Merging #3660 (641b74c) into master (e9732a1) will decrease coverage by 0.32%.
The diff coverage is 78.83%.

@@            Coverage Diff             @@
##           master    #3660      +/-   ##
==========================================
- Coverage   74.95%   74.63%   -0.33%     
==========================================
  Files         269      266       -3     
  Lines       23819    23782      -37     
==========================================
- Hits        17854    17750     -104     
- Misses       5039     5104      +65     
- Partials      926      928       +2     
Impacted Files Coverage Δ
action/protocol/protocol.go 0.00% <ø> (ø)
db/trie/mptrie/node.go 100.00% <ø> (ø)
ioctl/newcmd/action/action.go 79.62% <ø> (+0.09%) ⬆️
ioctl/newcmd/node/nodedelegate.go 70.19% <0.00%> (-0.95%) ⬇️
ioctl/newcmd/node/nodeprobationlist.go 90.90% <0.00%> (-4.33%) ⬇️
action/protocol/execution/evm/evm.go 44.57% <26.66%> (-0.86%) ⬇️
action/protocol/staking/candidate_center.go 87.82% <40.90%> (-4.40%) ⬇️
db/trie/mptrie/hashnode.go 36.36% <41.17%> (-54.55%) ⬇️
action/protocol/staking/protocol.go 65.14% <45.45%> (-1.41%) ⬇️
db/trie/mptrie/merklepatriciatrie.go 78.73% <46.80%> (-12.70%) ⬇️
... and 24 more

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

return clone
}

func (cb *candBase) Commit(change *candChange) (int, error) {
Copy link
Member

Choose a reason for hiding this comment

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

all funcs of candBase are private now, let's use commit() to be consistent?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

do not understand why a private struct needs to have private functions

@@ -435,7 +439,27 @@ func (cb *candBase) all() CandidateList {
return list
}

func (cb *candBase) commit(change *candChange) (int, error) {
func (cb *candBase) Clone() *candBase {
Copy link
Member

Choose a reason for hiding this comment

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

same here, use clone

if err := ws.store.Commit(); err != nil {
return err
}
if err := protocolCommit(ctx, ws); err != nil {
// TODO (zhi): wrap the error and eventually panic it in caller side
Copy link
Member

Choose a reason for hiding this comment

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

could you pls file an issue? can be fixed in next hard-fork

@dustinxie
Copy link
Member

this code has been integrated into (#3661), so close it

@dustinxie dustinxie closed this Oct 14, 2022
@dustinxie dustinxie deleted the precommit branch December 17, 2022 04:08
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