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

bug: blockhash differs from testnet/mainnet #346

Open
uF4No opened this issue Sep 17, 2024 · 3 comments
Open

bug: blockhash differs from testnet/mainnet #346

uF4No opened this issue Sep 17, 2024 · 3 comments
Labels
bug 🐛 Something isn't working medium 🚩 Indicates moderately difficult item p1 🟠 Indicates high priority item

Comments

@uF4No
Copy link

uF4No commented Sep 17, 2024

🐛 Bug Report for zkSync Era In-Memory Node

📝 Description

When a new block is produced, the algorithm used to generate the blockhash is different than the one used in testnet/mainnet. This causes issues when accessing blockshash(blocknumber) in Solidity and compare its result with the hash returned by the RPC getBlock as they're different.

🔄 Reproduction Steps

  1. Clone https://github.com/desfero/blockhash-zksync-repro/
  2. Install deps
  3. Configure a testnet PK in the .env file.
  4. Run test vs testnet with npx hardhat test --network zkSyncSepoliaTestnet. Runs ok.
  5. Change PK for one of the rich era-test-node wallets
  6. Run test vs era-test-node with npx hardhat test --network inMemoryNode. Test fails

🤔 Expected Behavior

Same blockhash in Solidity and RPC for the same block

😯 Current Behavior

Blockhash differs in Solidity and RPC for the same block

🖥️ Environment

  • Rust version: rustc 1.77.2 (25ef9e3d8 2024-04-09)
  • Operating System & Version: MacOS Sonoma 14.4.1
  • Other relevant environment details: era_test_node 0.1.0-alpha.27

📋 Additional Context

N/A

📎 Log Output

Paste any relevant log output here.
@MexicanAce MexicanAce added bug 🐛 Something isn't working p1 🟠 Indicates high priority item medium 🚩 Indicates moderately difficult item labels Sep 18, 2024
@itegulov itegulov changed the title Computed blockhash differs from testnet/mainnet bug: blockhash differs from testnet/mainnet Dec 2, 2024
@itegulov
Copy link
Contributor

itegulov commented Dec 2, 2024

Moving some thoughts from https://github.com/matter-labs/era-test-node/issues/364 to here.

Indeed, era-test-node uses a placeholder block hash computation function that produces different results from zksync-era. My assumption was that this is perhaps not easily observable by users but thanks for proving me wrong that there is actual demand for this.

I think the most sane way to fix this would be to make a significant refactoring of metadata_calculator from core so that it is agnostic to where the data is coming from (it is heavily intertwined with PG connections right now).

@itegulov itegulov moved this to Todo in DevEx squad Dec 2, 2024
@dutterbutter
Copy link
Collaborator

dutterbutter commented Jan 30, 2025

@itegulov does it make sense to close this as based on your comment this work would primarily be done from core?

@itegulov
Copy link
Contributor

Most of the work needs to be done from core side but realistically has to be driven from our side as there is zero demand for having storage-agnostic metadata calculator otherwise

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something isn't working medium 🚩 Indicates moderately difficult item p1 🟠 Indicates high priority item
Projects
Status: Todo
Development

No branches or pull requests

4 participants