Skip to content

Conversation

@alexggh
Copy link

@alexggh alexggh commented Dec 1, 2025

New blocks needs to be finalised and initialised otherwise blockhash opcode won't find the hash and fail.

Signed-off-by: Alexandru Gheorghe <alexandru.gheorghe@parity.io>
Signed-off-by: Alexandru Gheorghe <alexandru.gheorghe@parity.io>

revive_cheat_test!(test_custom_nonce, "Nonce");
revive_cheat_test_original!(test_nonce, "Nonce");
revive_cheat_test_original!(test_roll, "Roll");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do not we need to call revive_cheat_test!(test_custom_roll, "Roll")

Copy link
Author

Choose a reason for hiding this comment

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

The only custom stuff is this: https://github.com/paritytech/foundry-polkadot/pull/451/files#diff-91c2bf2016961cb8b7dadc4b761d94c6529077494b377ddddda2aaab10d07f3fR36, which copied from your PR, but I think is not needed because this test are already running with --polkadot.

Copy link
Collaborator

Choose a reason for hiding this comment

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

My point was that revive_cheat_test_original is looking for tests in original cheats directory. and this test we have locally in revive dir

Copy link
Author

Choose a reason for hiding this comment

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

Aaa ok, will fix it.

// Set block number in pallet-revive runtime.
self.0.lock().unwrap().execute_with(|| {
System::set_block_number(new_height.try_into().expect("Block number exceeds u64"));
let new_block_number: u64 = new_height.try_into().expect("Block number exceeds u32");
Copy link
Collaborator

Choose a reason for hiding this comment

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

should not we use System::run_to_block?

Copy link
Author

Choose a reason for hiding this comment

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

The problem with run_to_block or anything that populates all the blocks, is that roll parameter seems to be part of the fuzz test, so that test takes a really long time, I gave up after 10s of minutes.

Copy link
Collaborator

Choose a reason for hiding this comment

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

OK, should the block hashes be in sync between EVM and revive?

Copy link
Collaborator

@smiasojed smiasojed Dec 2, 2025

Choose a reason for hiding this comment

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

I see that foundry just do:

    #[inline]
    fn block_hash_ref(&self, number: u64) -> Result<B256, Self::Error> {
        Ok(keccak256(number.to_string().as_bytes()))
    }

if they do not have already this in cache.
So it means that foundry does not build blocks to calculate hash, and this is not done in roll. It is generated when we are accessing blockhash as I understand.

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.

3 participants