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

Implement gasLimit Precheck #304

Merged
merged 32 commits into from
Jul 8, 2022
Merged

Implement gasLimit Precheck #304

merged 32 commits into from
Jul 8, 2022

Conversation

Ivo-Yankov
Copy link
Collaborator

Description:
Implements gasLimit over/under checks before submitting in sendRawTransactions

Related issue(s):

Fixes #128

Notes for reviewer:

Checklist

  • Documented (Code comments, README, etc.)
  • Tested (unit, integration, etc.)

Mitchell Martin and others added 25 commits June 15, 2022 14:47
Signed-off-by: Mitchell Martin <[email protected]>
Signed-off-by: Mitchell Martin <[email protected]>
# Conflicts:
#	packages/relay/src/lib/errors.ts
#	packages/relay/src/lib/precheck.ts
Signed-off-by: Ivo Yankov <[email protected]>
Signed-off-by: Ivo Yankov <[email protected]>
# Conflicts:
#	packages/relay/src/lib/errors.ts
#	packages/relay/tests/lib/precheck.spec.ts
#	packages/server/tests/acceptance/rpc.spec.ts
Signed-off-by: Ivo Yankov <[email protected]>
Signed-off-by: Ivo Yankov <[email protected]>
# Conflicts:
#	packages/relay/src/lib/eth.ts
#	packages/relay/src/lib/precheck.ts
#	packages/relay/tests/lib/precheck.spec.ts
#	packages/server/tests/acceptance/rpc.spec.ts
Signed-off-by: Ivo Yankov <[email protected]>
Signed-off-by: Ivo Yankov <[email protected]>
# Conflicts:
#	packages/relay/src/lib/eth.ts
Signed-off-by: Mitchell Martin <[email protected]>
Signed-off-by: Ivo Yankov <[email protected]>
Signed-off-by: Ivo Yankov <[email protected]>
Signed-off-by: Ivo Yankov <[email protected]>
Signed-off-by: Ivo Yankov <[email protected]>
Signed-off-by: Nana-EC <[email protected]>
@Ivo-Yankov Ivo-Yankov marked this pull request as ready for review July 7, 2022 14:36
@Ivo-Yankov Ivo-Yankov added this to the 0.3.0 milestone Jul 7, 2022
@Ivo-Yankov Ivo-Yankov added enhancement New feature or request limechain labels Jul 7, 2022
@Ivo-Yankov Ivo-Yankov added the P2 label Jul 7, 2022
@Ivo-Yankov Ivo-Yankov changed the title 128 gas limit precheck Implement gasLimit Precheck Jul 7, 2022
@codecov-commenter
Copy link

codecov-commenter commented Jul 7, 2022

Codecov Report

Merging #304 (116672d) into main (816948c) will increase coverage by 0.45%.
The diff coverage is 68.96%.

@@            Coverage Diff             @@
##             main     #304      +/-   ##
==========================================
+ Coverage   57.84%   58.29%   +0.45%     
==========================================
  Files           9        9              
  Lines         835      856      +21     
  Branches      135      139       +4     
==========================================
+ Hits          483      499      +16     
- Misses        322      325       +3     
- Partials       30       32       +2     
Impacted Files Coverage Δ
packages/relay/src/lib/constants.ts 100.00% <ø> (ø)
packages/relay/src/lib/errors.ts 85.71% <ø> (ø)
packages/relay/src/lib/eth.ts 59.48% <28.57%> (-0.16%) ⬇️
packages/relay/src/lib/precheck.ts 59.67% <81.81%> (+9.67%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 816948c...116672d. Read the comment docs.

@Nana-EC Nana-EC self-requested a review July 7, 2022 15:46
Nana-EC
Nana-EC previously approved these changes Jul 7, 2022
Copy link
Collaborator

@Nana-EC Nana-EC left a comment

Choose a reason for hiding this comment

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

LG
Hopefully this addresses the DApp test timeouts also

…gasLimit-precheck

# Conflicts:
#	packages/relay/src/lib/constants.ts
#	packages/relay/src/lib/precheck.ts
#	packages/relay/tests/lib/precheck.spec.ts
Signed-off-by: Ivo Yankov <[email protected]>
# Conflicts:
#	packages/relay/src/lib/constants.ts
#	packages/server/tests/acceptance/rpc.spec.ts
@sonarcloud
Copy link

sonarcloud bot commented Jul 8, 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 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@Ivo-Yankov Ivo-Yankov requested a review from Nana-EC July 8, 2022 13:13
}
}

const nonZeros = data.replace('0x', '').length - zeros;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This was causing a wrong calculation of the gas cost. If 0x is not removed from data, that counts as 2 nonZero bytes, and the calculated gas cost is TX_BASE_COST + 2 * ISTANBUL_TX_DATA_NON_ZERO_COST, which meant that transactions with empty data (hbar transfer transactions) could not pass the precheck if the default gasLimit (21000) was used.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Nice catch

Copy link
Collaborator

@Nana-EC Nana-EC left a comment

Choose a reason for hiding this comment

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

LG

@Ivo-Yankov Ivo-Yankov merged commit c9b55ba into main Jul 8, 2022
@Ivo-Yankov Ivo-Yankov deleted the 128-gasLimit-precheck branch July 8, 2022 13:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request limechain P2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add gasLimit precheck to eth_sendRawTransaction
3 participants