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] correct signature's V value in returned web3 transaction #3952

Merged
merged 3 commits into from
Nov 1, 2023

Conversation

dustinxie
Copy link
Member

@dustinxie dustinxie commented Oct 26, 2023

Description

When web3 returns a tx, its signature's V value is not correctly set. Existing func in action package is used to generate the correct value

Fixes (#3944)

this PR will be needed for v1.12.1 to fix the API 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

@dustinxie dustinxie linked an issue Oct 26, 2023 that may be closed by this pull request
@@ -251,7 +254,7 @@ func TestTransactionObjectMarshal(t *testing.T) {
"input":"0x",
"r":"0x3639643839613061663237646361613637663162363261333833353934643937",
"s":"0x3539396161646432623762313634636234313132616138646466643432663839",
"v":"0x35"
"v":"0x24c7"
Copy link
Member Author

Choose a reason for hiding this comment

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

this is the correct value corresponding to chainID = 4690

receipt: receipt,
pubkey: selp.SrcPubkey(),
signature: selp.Signature(),
Copy link
Collaborator

Choose a reason for hiding this comment

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

why could signature be deleted?

Copy link
Member Author

Choose a reason for hiding this comment

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

not needed anymore, now the signed tx is generated, which contains correct signature value

@codecov
Copy link

codecov bot commented Oct 26, 2023

Codecov Report

Merging #3952 (e34810f) into master (e1f0636) will increase coverage by 0.78%.
Report is 91 commits behind head on master.
The diff coverage is 74.72%.

❗ Current head e34810f differs from pull request most recent head 94d4064. Consider uploading reports for the commit 94d4064 to get more accurate results

@@            Coverage Diff             @@
##           master    #3952      +/-   ##
==========================================
+ Coverage   75.38%   76.16%   +0.78%     
==========================================
  Files         303      328      +25     
  Lines       25923    27981    +2058     
==========================================
+ Hits        19541    21313    +1772     
- Misses       5360     5573     +213     
- Partials     1022     1095      +73     
Files Coverage Δ
action/candidate_register.go 90.00% <100.00%> (ø)
action/candidate_update.go 89.01% <100.00%> (+0.12%) ⬆️
action/claimreward.go 90.62% <100.00%> (-0.42%) ⬇️
action/depositreward.go 87.50% <100.00%> (-0.56%) ⬇️
action/protocol/context.go 67.91% <100.00%> (+0.73%) ⬆️
action/protocol/execution/evm/evmstatedbadapter.go 66.77% <ø> (ø)
action/protocol/execution/protocol.go 42.10% <100.00%> (ø)
action/protocol/rewarding/reward.go 90.07% <100.00%> (+0.60%) ⬆️
...tion/protocol/staking/candidate_buckets_indexer.go 89.31% <100.00%> (-0.47%) ⬇️
...col/staking/ethabi/stake_composite_bucketscount.go 100.00% <100.00%> (ø)
... and 67 more

... and 3 files with indirect coverage changes

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

Copy link

sonarcloud bot commented Oct 31, 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 1 Code Smell

No Coverage information No Coverage information
0.0% 0.0% Duplication


// recover public key
rawHash := types.NewEIP155Signer(big.NewInt(int64(_evmNetworkID))).Hash(&tx)
pubkey, err := crypto.RecoverPubkey(rawHash[:], sig)
Copy link
Member Author

Choose a reason for hiding this comment

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

duplicate code, same as DecodeRawTx

@dustinxie dustinxie merged commit a19f277 into iotexproject:master Nov 1, 2023
4 checks passed
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.

transaction hash is not eth-compatible
4 participants