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

[contract_indexer] fix transfer event handling #3887

Merged
merged 3 commits into from
Jun 15, 2023

Conversation

envestcc
Copy link
Member

Description

Currently, only the transfer events triggered during the creation of a bucket are being handled. The transfer events triggered during subsequent bucket transfers are not being handled correctly.

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

@envestcc envestcc requested review from CoderZhi, dustinxie, Liuhaai and a team as code owners June 13, 2023 12:55
@codecov
Copy link

codecov bot commented Jun 13, 2023

Codecov Report

Merging #3887 (47b97f9) into master (e1f0636) will increase coverage by 0.01%.
The diff coverage is 64.51%.

❗ Current head 47b97f9 differs from pull request most recent head 5b99895. Consider uploading reports for the commit 5b99895 to get more accurate results

@@            Coverage Diff             @@
##           master    #3887      +/-   ##
==========================================
+ Coverage   75.38%   75.39%   +0.01%     
==========================================
  Files         303      328      +25     
  Lines       25923    27812    +1889     
==========================================
+ Hits        19541    20968    +1427     
- Misses       5360     5767     +407     
- Partials     1022     1077      +55     
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/grpcserver.go 86.40% <0.00%> (ø)
api/loglistener.go 25.00% <0.00%> (ø)
api/web3server_marshal.go 93.21% <ø> (ø)
api/websocket.go 5.17% <0.00%> (ø)
blockchain/config.go 74.54% <ø> (ø)
... and 50 more

... and 3 files with indirect coverage changes

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

@@ -434,7 +434,15 @@ func (eh *contractStakingEventHandler) handleTransferEvent(event eventParam) err
return err
}

eh.tokenOwner[tokenID.Uint64()] = to
Copy link
Member

Choose a reason for hiding this comment

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

same issue on L507?

Copy link
Member

Choose a reason for hiding this comment

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

yes, please do a complete revisit of all the handlers, see if there are other places need to cover

Copy link
Member Author

Choose a reason for hiding this comment

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

only handleTransferEvent need to update

@@ -434,7 +434,15 @@ func (eh *contractStakingEventHandler) handleTransferEvent(event eventParam) err
return err
}

eh.tokenOwner[tokenID.Uint64()] = to
token := tokenID.Uint64()
Copy link
Member

Choose a reason for hiding this comment

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

token -> tokenID

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

@@ -1715,6 +1715,62 @@ func TestContractStaking(t *testing.T) {
r.True(ok)
r.EqualValues(identityset.Address(delegateIdx).String(), bt.Candidate.String())
})

t.Run("transfer token", func(t *testing.T) {
Copy link
Member

@dustinxie dustinxie Jun 13, 2023

Choose a reason for hiding this comment

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

as we discussed, every newly added funcs/APIs should be covered by a test

@sonarqubecloud
Copy link

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

@dustinxie dustinxie merged commit 4833da1 into iotexproject:master Jun 15, 2023
@envestcc envestcc deleted the bugfix_transfer branch June 15, 2023 05:15
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.

4 participants