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

Tracking issue: Global Variables #824

Closed
8 tasks done
LHerskind opened this issue Jun 13, 2023 · 0 comments
Closed
8 tasks done

Tracking issue: Global Variables #824

LHerskind opened this issue Jun 13, 2023 · 0 comments
Assignees
Labels
T-tracking Type: Tracking Issue. This contains tasklists.

Comments

@LHerskind
Copy link
Contributor

LHerskind commented Jun 13, 2023

This tracking issue lays out the high-level overview of the solution, 
but redirects more detailed views to its individual issues if required.

Originally discussed in https://hackmd.io/_UnW4qCUTlSQh5RBkRHY4Q

Smart contracts have access to several global functions that reflect the state of the blockchain (like what is the current block or chain ID) or give additional context about the current transaction (like who is the transaction sender).

This doc takes inspiration from Etheruem to discuss what global methods Aztec should support from Noir and if both in public and private functions.

The issue lists each of Ethereum’s global variables/functions relating to a block or the current transaction and discuss why they are useful and if it is required for Aztec. The individual issues will expand on how it can be supported, especially in the context of private execution which only have access to historic data. You can read more on the restrictuion here but the TL;DR is this prevents race conditions for private transactions, where the user generates proofs locally on their browser, much before the time of inclusion, and therefore doesn’t know about the current chain.


For structure, we will list the short term first, before extending on the longer term variables.

Short Term

  • chainid
  • version
  • block number
  • block timestamp

chainid

Exists in Ethereum: 👍
Description: Reading the L1 chainid for the current block.
Uses: Generally used for replay protection between chains, exposed in evm to protect against replays for meta transactions, EIP-712, etc. Also used widely for cross-chain messaging for sender and recipient domain identifier.
Public support: 👍
Private support: 👍

version

Exists in Ethereum: 👎
Description: Essentially the l2 chainid for the current block. Using version to clearly distinct between chainid and it from Noir.
Uses: Generally used for replay protection in Aztec, and part of cross-chain message authentication. Similar to chainid.
Public support: 👍
Private support: 👍

block.number

Exists in Ethereum: 👍
Description: Reading the current block number for L2.
Uses: Often used as a proxy for time, see compound V2 or curve locking contracts. Certain system use the discrete coarse units to make accounting easier.
Public support: 👍
Private support: 👎 (see #832)

block.timestamp

Exists in Ethereum: 👍
Description: Reading the timestamp of current block for L2.
What it is used for: Used widely for deadlines and interest computations.
Public support: 👍
Private support: 👎 (see #832)


The values can be added to the ConstantRollupData and must match throughout the full tree building and finally against public inputs from the contract, that will also constrain the variables to meaningful values.

Access to historic values should be supported through #849 and will not be handled as part of this issue.

@LHerskind LHerskind added this to A3 Jun 13, 2023
@LHerskind LHerskind converted this from a draft issue Jun 13, 2023
@LHerskind LHerskind changed the title Global available variables (Tracking issue) Tracking issue: Global available variables Jun 13, 2023
@LHerskind LHerskind added the T-tracking Type: Tracking Issue. This contains tasklists. label Jun 15, 2023
@LHerskind LHerskind changed the title Tracking issue: Global available variables Tracking issue: Global Variables and Functions Jun 15, 2023
@LHerskind LHerskind self-assigned this Jul 24, 2023
@LHerskind LHerskind changed the title Tracking issue: Global Variables and Functions Tracking issue: Global Variables Jul 31, 2023
@github-project-automation github-project-automation bot moved this from Todo to Done in A3 Jul 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-tracking Type: Tracking Issue. This contains tasklists.
Projects
Archived in project
Development

No branches or pull requests

2 participants