-
Notifications
You must be signed in to change notification settings - Fork 324
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
[evm] fix GetHash function #2998
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2998 +/- ##
=======================================
Coverage 61.54% 61.54%
=======================================
Files 192 192
Lines 21680 21688 +8
=======================================
+ Hits 13342 13347 +5
- Misses 6661 6665 +4
+ Partials 1677 1676 -1
Continue to review full report at Codecov.
|
92ce94e
to
854fa62
Compare
require.NoError(err) | ||
acHash7, err := addOneBlock(contract, 7, zero, gasLimit, gasPrice, getBlockHash(6)) // equal to genesis block | ||
require.NoError(err) | ||
|
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.
move into for loop to make the code more clean
Could we test |
yes, the test deploys a contract which end up calling |
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.
yes, that's EVM internal implementation, it checks if the requested number is within last 256 blocks, if yes, call |
Could you check why is time fixed in L647 |
hash, err := getBlockHash(stateDB.blockHeight - n) | ||
if err != nil { | ||
hash, err := getBlockHash(n) | ||
if err == nil { |
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.
if err != nil {
}
return
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.
for clarity would rather keep it same as current code
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.
ok. Could you file a new issue to correct the style here?
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.
i don't think it's necessary? we have lots of if err == nil
in the codebase
return common.BytesToHash(hash[:]) | ||
} | ||
return common.Hash{} | ||
} | ||
} else { | ||
case featureCtx.FixGetHashFnHeight: | ||
getHashFn = func(n uint64) common.Hash { | ||
hash, err := getBlockHash(stateDB.blockHeight - (n + 1)) | ||
if err == nil { |
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.
same as above
} | ||
for _, test := range tests { | ||
r, err := dao.GetReceiptByActionHash(test.acHash, test.commitHeight) | ||
h, err := addOneBlock(contract, nonce, zero, gasLimit, gasPrice, getBlockHash(int64(test.getHashHeight))) |
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.
the name getBlockHash
is confusing. It is actually the data of the tx
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.
yes, it is the data of tx, but what the tx does is to getBlockHash
, so i think it's fine?
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.
No. the name getBlockHash
is expected to return a hash. But it returns []byte.
I'd prefer calldata
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.
added in 3rd commit
{11, 1}, | ||
{12, 4}, | ||
{13, 0}, | ||
{14, 100}, |
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.
add one more test {15, 15}?
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.
added in 2nd commit
No description provided.