-
Notifications
You must be signed in to change notification settings - Fork 75
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
feat: transaction with CONTRACT_NEGATIVE_VALUE
breaks some routes
#3387
base: main
Are you sure you want to change the base?
feat: transaction with CONTRACT_NEGATIVE_VALUE
breaks some routes
#3387
Conversation
Signed-off-by: nikolay <n.atanasow94@gmail.com>
Test Results 18 files - 7 236 suites - 151 32m 48s ⏱️ - 40m 17s Results for commit c17f02a. ± Comparison against base commit 67b61c6. This pull request removes 3 tests.
♻️ This comment has been updated with latest results. |
Signed-off-by: nikolay <n.atanasow94@gmail.com>
Signed-off-by: nikolay <n.atanasow94@gmail.com>
Signed-off-by: nikolay <n.atanasow94@gmail.com>
Quality Gate passedIssues Measures |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3387 +/- ##
==========================================
- Coverage 84.87% 84.77% -0.11%
==========================================
Files 69 69
Lines 4742 4750 +8
Branches 1067 1069 +2
==========================================
+ Hits 4025 4027 +2
- Misses 400 405 +5
- Partials 317 318 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work overall. Blocking as one warning needed to be addressed.
Also, is it feasible to add an e2e test to avoid regression?
@@ -265,6 +266,33 @@ const nanOrNumberTo0x = (input: number | BigNumber | bigint | null): string => { | |||
return input == null || Number.isNaN(input) ? numberTo0x(0) : numberTo0x(input); | |||
}; | |||
|
|||
const nanOrNumberInt64To0x = (input: number | BigNumber | bigint | null): string => { | |||
if (input && input < 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This got a warning
Operator '<' cannot be applied to types 'number | bigint | BigNumber' and 'number'.ts(2365)
// the hex of a negative number can be obtained from the binary value of that number positive value | ||
// the binary value needs to be negated and then to be incremented by 1 | ||
|
||
// how the transformation works (using 16 bits) | ||
// a 16 bits integer variables have values from -32768 to +32767, so: | ||
// 0 - 0x0000 - 0000 0000 0000 0000 | ||
// 32767 - 0x7fff - 0111 1111 1111 1111 | ||
// -32768 - 0x8000 - 1000 0000 0000 0000 | ||
// -1 - 0xffff - 1111 1111 1111 1111 | ||
|
||
// converting int16 -10 will be done as following: | ||
// - make it positive = 10 | ||
// - 16 bits binary value of 10 = 0000 0000 0000 1010 | ||
// - inverse the bytes = 1111 1111 1111 0101 | ||
// - adding +1 = 1111 1111 1111 0110 | ||
// - 1111 1111 1111 0110 bits = 0xfff6 | ||
|
||
// we're using 64 bits integer because that the type returned by the mirror node - int64 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great explanation 🙌
|
||
// we're using 64 bits integer because that the type returned by the mirror node - int64 | ||
const bits = 64; | ||
return numberTo0x((BigInt(input.toString()) + (BigInt(1) << BigInt(bits))) % (BigInt(1) << BigInt(bits))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: do we expect number
bigger than 53
bits? so it's not automatically coerced to double https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER
Description:
It seems like
eth_getBlockByNumber
fails because one of the transactions in the block was a CONTRACT_NEGATIVE_VALUE failure. The expectation is for the block to be successfully returned.Steps to reproduce:
eth_getBlockByNumber
on block 73298898The problematic transaction is here
Related issue(s):
Fixes #3367
Notes for reviewer:
Checklist