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

[staking] fix ToEthTx() panic #3910

Merged
merged 2 commits into from
Aug 1, 2023
Merged

Conversation

dustinxie
Copy link
Member

@dustinxie dustinxie commented Jul 28, 2023

Description

as title, issue found and reported by Jeremi

Fixes #3909

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)

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 Jul 28, 2023

Codecov Report

Merging #3910 (acc057e) into master (e1f0636) will increase coverage by 0.71%.
Report is 73 commits behind head on master.
The diff coverage is 73.81%.

❗ Current head acc057e differs from pull request most recent head 22386c4. Consider uploading reports for the commit 22386c4 to get more accurate results

@@            Coverage Diff             @@
##           master    #3910      +/-   ##
==========================================
+ Coverage   75.38%   76.09%   +0.71%     
==========================================
  Files         303      327      +24     
  Lines       25923    27840    +1917     
==========================================
+ Hits        19541    21185    +1644     
- Misses       5360     5563     +203     
- Partials     1022     1092      +70     
Files Changed 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 53 more

... and 4 files with indirect coverage changes

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

data, err := cr.encodeABIBinary()
if err != nil {
return nil, err
}
ethAddr := common.BytesToAddress(address.StakingProtocolAddrHash[:])
Copy link
Member Author

Choose a reason for hiding this comment

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

easier way of getting the address, compared to 5 lines in the left side

Copy link
Member

Choose a reason for hiding this comment

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

good to learn a new tip

Copy link
Member

Choose a reason for hiding this comment

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

also in a new pr

Copy link
Member Author

Choose a reason for hiding this comment

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

ok, will file a new PR

@millken
Copy link
Contributor

millken commented Jul 31, 2023

good fix, I found in the ops exceptions log that eth_getBlockByNumber API generated panic log (runtime error: invalid memory address or nil pointer dereference), but I tested it N times, and I don't know what parameter triggered the bug.

data, err := su.encodeABIBinary()
if err != nil {
return nil, err
}
ethAddr := common.BytesToAddress(address.StakingProtocolAddrHash[:])
Copy link
Contributor

Choose a reason for hiding this comment

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

It is used in several places, can place this in global var()?

Copy link
Member Author

Choose a reason for hiding this comment

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

will do in next PR

action/candidate_register.go Show resolved Hide resolved
data, err := cr.encodeABIBinary()
if err != nil {
return nil, err
}
ethAddr := common.BytesToAddress(address.StakingProtocolAddrHash[:])
Copy link
Member

Choose a reason for hiding this comment

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

good to learn a new tip

action/candidate_update.go Show resolved Hide resolved
@@ -22,7 +22,6 @@ type Builder struct {
}

var (
_stakingProtocolAddr, _ = address.FromString(address.StakingProtocolAddr)
Copy link
Member

Choose a reason for hiding this comment

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

filed in a new pr?

@Liuhaai
Copy link
Member

Liuhaai commented Jul 31, 2023

Bc no vriadic param is available in solidity, the query of native action is to be disabled without choices.

1 similar comment
@Liuhaai
Copy link
Member

Liuhaai commented Jul 31, 2023

Bc no vriadic param is available in solidity, the query of native action is to be disabled without choices.

rewardEthAddr := common.BytesToAddress(cu.rewardAddress.Bytes())
data, err := _candidateUpdateMethod.Inputs.Pack(cu.name, operatorEthAddr, rewardEthAddr)
if cu.operatorAddress == nil {
return nil, ErrAddress
Copy link
Member

Choose a reason for hiding this comment

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

it's not caused by an invalid address, but an option param

@sonarcloud
Copy link

sonarcloud bot commented Aug 1, 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
6.0% 6.0% Duplication

idea Catch issues before they fail your Quality Gate with our IDE extension sonarlint SonarLint

@dustinxie dustinxie merged commit 2e02ec7 into iotexproject:master Aug 1, 2023
2 of 3 checks passed
@dustinxie dustinxie mentioned this pull request Aug 2, 2023
10 tasks
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.

candidateUpdate with nil operator causing web3 server to panic
4 participants