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

OldAccInputHash for lower forkids #898

Closed
revitteth opened this issue Aug 1, 2024 · 1 comment · Fixed by #1161
Closed

OldAccInputHash for lower forkids #898

revitteth opened this issue Aug 1, 2024 · 1 comment · Fixed by #1161
Assignees
Labels
bug Something isn't working Gateway FM

Comments

@revitteth
Copy link
Collaborator

The contract ABI is different for lower forkids, so calling to get oldAccInputHash from the L1 for lower forkids fails. This needs a little investigation and an implementation to fix.

Currently getBatchByNumber is returning the oldAccInputHash as 0x00...0 when retries are exceeded and this fails, which needs a proper fix.

@V-Staykov
Copy link
Collaborator

Turns out this will be a bit more work. First of all from the contract we only get the last batch in the sequence accInputHash. For any other batch we need to calculate it and we don't.

Here is the algorithm to calculate it according to Carlos:


each batch has a different accInputHash (since it depends on its data and on the previousAccInputHash)
how to compute intermediateAccInjputHashes?
you can get the very first hash of the sequence (ex: from 4 to 10)
you got batch_4_accInputHash & batch_10_accInputHash
you detect event:
/**
     * @dev Emitted when the trusted sequencer sends a new batch of transactions
     */
    event SequenceBatches(uint64 indexed numBatch, bytes32 l1InfoRoot);
you get the calldata: all batches data, l2Coinabse, maxSequencetimestamp
you get event data: l1InfoRoot
you can build all the intermediate accInputHahes from batch 4 to 10
you can do a sanity check that batch 10 computed batches the one on-chain

here is the js implementation for the above:
https://github.com/0xPolygonHermez/zkevm-commonjs/blob/main/src/contract-utils.js#L15

@V-Staykov V-Staykov self-assigned this Sep 10, 2024
@V-Staykov V-Staykov linked a pull request Sep 11, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Gateway FM
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants