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

[api] ReadStateBucketByIndices return existing buckets #3878

Merged
merged 2 commits into from
Jun 9, 2023

Conversation

envestcc
Copy link
Member

@envestcc envestcc commented Jun 5, 2023

Description

Currently, in the composite staking code, we make separate calls to ReadStateBucketByIndices for native and contract buckets. The desired behavior is to be able to look up a bucket by its ID in either the native or contract buckets. However, the current implementation returns an error if the ID does not exist in either bucket, resulting in an error even if the ID exists in one of them.

The modification to make is changing the behavior of ReadStateBucketByIndices for native and contract buckets. Instead of returning an error when there are non-existing IDs in the parameters, we will modify it to return the existing buckets.

The reasons for choosing this approach are twofold:

  • Simple: the modification is relatively simple, which allows for a straightforward implementation without significant code changes.
  • Limit impact: since this adjustment is specific to error handling in a read-only interface, the impact of the change is expected to be limited to a specific area of the codebase.

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 Jun 5, 2023

Codecov Report

Merging #3878 (e77c814) into master (e1f0636) will increase coverage by 0.23%.
The diff coverage is 66.79%.

❗ Current head e77c814 differs from pull request most recent head 2e32818. Consider uploading reports for the commit 2e32818 to get more accurate results

@@            Coverage Diff             @@
##           master    #3878      +/-   ##
==========================================
+ Coverage   75.38%   75.61%   +0.23%     
==========================================
  Files         303      325      +22     
  Lines       25923    27574    +1651     
==========================================
+ Hits        19541    20850    +1309     
- Misses       5360     5651     +291     
- Partials     1022     1073      +51     
Impacted Files Coverage Δ
action/protocol/execution/evm/evm.go 43.52% <0.00%> (-2.95%) ⬇️
action/protocol/execution/evm/evmstatedbadapter.go 66.77% <ø> (ø)
action/protocol/poll/consortium.go 0.00% <0.00%> (ø)
action/protocol/poll/staking_committee.go 43.85% <0.00%> (ø)
...tion/protocol/staking/contractstake_bucket_type.go 0.00% <0.00%> (ø)
api/web3server_marshal.go 93.21% <ø> (ø)
blockchain/config.go 74.54% <ø> (ø)
blockindex/contractstaking/dummy_indexer.go 0.00% <0.00%> (ø)
blockindex/sgd_indexer.go 2.45% <2.45%> (ø)
action/protocol/staking/contractstake_indexer.go 14.28% <14.28%> (ø)
... and 39 more

... and 3 files with indirect coverage changes

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

@sonarcloud
Copy link

sonarcloud bot commented Jun 8, 2023

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

@dustinxie dustinxie merged commit 6d5d929 into iotexproject:master Jun 9, 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