-
Notifications
You must be signed in to change notification settings - Fork 53
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: block properties behaviour #853
Conversation
Signed-off-by: nikolay <[email protected]>
@@ -7,8 +7,8 @@ contract BlockInfo { | |||
return block.basefee; | |||
} | |||
|
|||
function getBlockHash() public view returns (bytes32) { | |||
return blockhash(block.number - 1); | |||
function getBlockHash(uint256 blockNumber) public view returns (bytes32) { |
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 blockNumber
param for consistency because block.number - 1
depends on the current block.
@@ -26,7 +26,7 @@ describe('@solidityequiv1 BlockInfo Test Suite', function () { | |||
|
|||
before(async function () { | |||
signers = await ethers.getSigners(); | |||
provider = ethers.getDefaultProvider(); | |||
provider = signers[0].provider; |
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.
ethers.getDefaultProvider();
returns FallbackProvider
that queries Ethereum Mainnet and that's why we get inconsistent results in the tests below. We should use the signer's provider which is a JsonRpcProvider connected to the relay (described in hardhat.config.js).
const blockNumber = await provider.getBlockNumber(); | ||
const block = await provider.getBlock(blockNumber); | ||
const blockHash = await blockInfo.getBlockHash(blockNumber); | ||
expect(block.hash).to.equal(blockHash); | ||
}); | ||
|
||
it('should get the current block coinbase which is the hedera network account', async function () { |
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.
@ebadiere the problem related to the coinbase address (described in the issue) is not reproducible, could you share a little more info on how to reproduce it or verify that it's already fixed in that PR?
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.
Agreed. The test passes. Not an issue now.
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.
LG.
Description:
When retrieving in smart contracts, not all block properties match what's returned to hardhat.
0x0000000000000000000000000000000000000000000000000000000000000000
.Steps to reproduce;
should be able to get the hash of a given block when the block number is one of the 256 most recent blocks
inBlockInfo
reproduces the hash value issue. - fixed ✅should get the current block miners address using block.coinbase
reproduces the coinbase issue. - not reproducible ❌Related issue(s):
Fixes #436
Notes for reviewer:
Checklist