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

Constrain timestamp in global variables #948

Merged
merged 12 commits into from
Jul 3, 2023

Conversation

LHerskind
Copy link
Contributor

@LHerskind LHerskind commented Jun 30, 2023

Description

Fixes #830. Built on top of #917.

Checklist:

  • I have reviewed my diff in github, line by line.
  • Every change is related to the PR description.
  • I have linked this pull request to the issue(s) that it resolves.
  • There are no unexpected formatting changes, superfluous debug logs, or commented-out code.
  • The branch has been merged or rebased against the head of its merge target.
  • I'm happy for the PR to be merged at the reviewer's next convenience.

@LHerskind LHerskind force-pushed the lh/globals-noir-public branch from 53f1386 to cd2621b Compare July 3, 2023 08:47
Base automatically changed from lh/globals-noir-public to master July 3, 2023 09:06
@LHerskind LHerskind force-pushed the lh/constrain-timestamp-globals branch from 3af6fa6 to 058b86d Compare July 3, 2023 09:34
@LHerskind LHerskind marked this pull request as ready for review July 3, 2023 09:48
const globalVariables = new GlobalVariables(
new Fr(config.chainId),
new Fr(config.version),
new Fr(1 + i),
Fr.ZERO,
new Fr(await rollup.read.lastBlockTs()),
Copy link
Member

Choose a reason for hiding this comment

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

Why do we want the ts of the last block here? Do we not want the current timestamp?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The ts of the last block is the minimum value that will work. With the current timestamp, you have the issue of dealing with anvil not progressing time as "outside" so this was just an easy way to pick a meaningful value.

* @returns The global variables for the given block number.
*/
public async buildGlobalVariables(blockNumber: Fr): Promise<GlobalVariables> {
const lastTimestamp = new Fr(await this.reader.getLastTimestamp());
Copy link
Member

Choose a reason for hiding this comment

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

ibid

Copy link
Contributor Author

Choose a reason for hiding this comment

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

See above, also hinted in the comments above the function.

revert Errors.Rollup__TimestampInFuture();
}

// @todo @LHerskind consider if this is too strict
Copy link
Contributor

Choose a reason for hiding this comment

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

is there a relevant issue for us to come back to this later or is the plan to hash this out now?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Have not created an issue for it. Will add it to #824.

/**
* The API key of the ethereum host.
*/
apiKey?: string;
Copy link
Contributor

Choose a reason for hiding this comment

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

isn't this on sequencer config already?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, so it is just to not require the entire config to be passed to the builder. If you look at the other configs, you will see similar with values that are "shared" between them, so the full config makes up the union of them.

@LHerskind LHerskind enabled auto-merge (squash) July 3, 2023 12:31
@LHerskind LHerskind merged commit 3fd8fc3 into master Jul 3, 2023
@LHerskind LHerskind deleted the lh/constrain-timestamp-globals branch July 3, 2023 12:46
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.

feat: Constrain block timestamp on L1 contract
3 participants