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

London to Pectra upgrade #50

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions .idea/linea-specification.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions _upgrades/modules/mod.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
delegate to EUC small computation ?
154 changes: 154 additions & 0 deletions _upgrades/modules/mxp.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
# MXP module redesign

let LMMS = 256^4 (linea max memory size)

| INST | LCIB | LCIW | CN ⟦ π ⟧ | OFFSET_1 ⟦ π ⟧ | OFFSET_2 ⟦ π ⟧ | SIZE_1 ⟦ π ⟧ | SIZE_2 ⟦ π ⟧ | DEPLOYING ⟦ π ⟧ | RES ⟦ π ⟧ | MXPX ⟦ π ⟧ | GAS_MXP ⟦ π ⟧ | WORDS | WORDS_NEW | C_MEM | C_MEM_NEW | LIN_COST | QUAD_COST | MAX_OFFSET | EXPANSION_REQUIRED |
| ---------------- | -- | -- | ---- | ---------- | ---------- | -------- | -------- | ----------- | ----- | ------ | --------- | ------- | ----------- | ------- | ----------- | ---------- | ----------- | ----------- | ----------- |
| MSIZE | | | | ∅ | ∅ | ∅ | ∅ | | | ∅ | ∅ | | | | | ∅ | ∅ | ∅ | ∅ |
| ---------------- | -- | -- | ---- | ---------- | ---------- | -------- | -------- | ----------- | ----- | ------ | --------- | ------- | ----------- | ------- | ----------- | ---------- | ----------- | ----------- | ----------- |
| MLOAD | | | | | ∅ | 32 | ∅ | | ∅ | | | | | | | ∅ | | | | |
| | | | | | | | | | | | | | | | | | | | | - callWcpLT on SIZE_1 and LMMS |
| | | | | | | | | | | | | | | | | | | | | . ⇒ small_offset |
| | | | | | | | | | | | | | | | | | | | | - if SIZE_1 < LMMS then compute memory expansion |
| ---------------- | --- | --- | ---- | ---------- | ---------- | -------- | -------- | ----------- | ----- | ------ | --------- | ------- | ----------- | ------- | ----------- | ---------- | ----------- | ----------- | ----------- | -------------------------------------------------- |
| MSTORE | | | | | ∅ | 32 | ∅ | | ∅ | | | | | | | ∅ | | | |
| ---------------- | --- | --- | ---- | ---------- | ---------- | -------- | -------- | ----------- | ----- | ------ | --------- | ------- | ----------- | ------- | ----------- | ---------- | ----------- | ----------- | ----------- |
| MSTORE8 | | | | | ∅ | 1 | ∅ | | ∅ | | | | | | | ∅ | | | |
| ---------------- | --- | --- | ---- | ---------- | ---------- | -------- | -------- | ----------- | ----- | ------ | --------- | ------- | ----------- | ------- | ----------- | ---------- | ----------- | ----------- | ----------- |
| CREATE | | 1 | | | ∅ | | ∅ | | ∅ | | | | | | | EIP-3860 | | | |
| ---------------- | --- | --- | ---- | ---------- | ---------- | -------- | -------- | ----------- | ----- | ------ | --------- | ------- | ----------- | ------- | ----------- | ---------- | ----------- | ----------- | ----------- |
| CREATE2 | | 1 | | | ∅ | | ∅ | | ∅ | | | | | | | | | | |
| ---------------- | --- | --- | ---- | ---------- | ---------- | -------- | -------- | ----------- | ----- | ------ | --------- | ------- | ----------- | ------- | ----------- | ---------- | ----------- | ----------- | ----------- |
| RETURN | 1 | | | | ∅ | | ∅ | T | ∅ | | | | | | | | | | |
| RETURN | 1 | | | | ∅ | | ∅ | F | ∅ | | | | | | | ∅ | | | |
| ---------------- | --- | --- | ---- | ---------- | ---------- | -------- | -------- | ----------- | ----- | ------ | --------- | ------- | ----------- | ------- | ----------- | ---------- | ----------- | ----------- | ----------- |
| REVERT | 1 | | | | ∅ | | ∅ | | ∅ | | | | | | | ∅ | | | |
| LOG-type | 1 | | | | ∅ | | ∅ | | ∅ | | | | | | | ∅ | | | |
| SHA3 | | 1 | | | ∅ | | ∅ | | ∅ | | | | | | | ∅ | | | |
| CALLDATACOPY | | 1 | | | ∅ | | ∅ | | ∅ | | | | | | | ∅ | | | |
| RETURNDATACOPY | | 1 | | | ∅ | | ∅ | | ∅ | | | | | | | ∅ | | | |
| CODECOPY | | 1 | | | ∅ | | ∅ | | ∅ | | | | | | | ∅ | | | |
| EXTCODECOPY | | 1 | | | ∅ | | ∅ | | ∅ | | | | | | | ∅ | | | |
| ---------------- | --- | --- | ---- | ---------- | ---------- | -------- | -------- | ----------- | ----- | ------ | --------- | ------- | ----------- | ------- | ----------- | ---------- | ----------- | ----------- | ----------- |
| MCOPY | | 1 | | | | | ≡ SIZE_1 | | ∅ | | | | | | | ∅ | | | |
| CALL-type | | | | | | | | | ∅ | | | | | | | ∅ | | | |
| ---------------- | --- | --- | ---- | ---------- | ---------- | -------- | -------- | ----------- | ----- | ------ | --------- | ------- | ----------- | ------- | ----------- | ---------- | ----------- | ----------- | ----------- |

Note. Absent from the above are the following columns that are predictions from the HUB:
- macro/T4MTNTOP // useful for anything that touches memory but with potentially zero size
- macro/S1NZNOMXPX
- macro/S2NZNOMXPX
Note: the last two are only useful for CALL's and RETURN/REVERT i.e. those opcodes that either set a CALL_DATA_SIZE or a RETURN_DATA_SIZE that may be nonzero in the HUB

3 types of instructions
- the pre-processing of

These are

MACRO
PREPROCESSING (MSIZE will never require this, but it may be simpler to have a single trivial preprocessing row regardless)
EXPANSION (single row if COMPUTATION_REQUIRED = false)
- MAX_OFFSET, by way of examples:
- MLOAD: OFFSET_1 + 31
- MSTORE8: OFFSET_1
- COPY instruction:
- 0 if the size is zero
- OFFSET_1 + (SIZE_1 - 1) otherwise
- compute μ' ↔ WORDS_NEW
- SIZE ≡ 0
- SIZE ≠ 0
- the EXPANSION phase has 2 modes of functioning

MACRO ==> PREPROCESSING ==> EXPANSION
- in an instruction dependent way, and on the final row of the pre-processing, we decide whether or not we require
- there are two possibilities for the PREPROCESSING: note that pre-processing is trivial for MSIZE
- depends purely on the instruction (we don't optimize for ROOB/NOOP/...)
- we will have a simple rule to set CT_MAX in this phase purely dependent on INST
- MEMORY_EXPANSION_COMPUTATION_REQUIRED
- there are two possibilities for the EXPANSION: trivial (MSIZE, or EXPANSION_REQUIRED ≡ false)
- we update the number of active WORDS in memory (or keep it the same)
- we update the MEMORY_EXPANSION_COST for everything up until this point (or keep it the same)



| INST | WORD_PRICING | BYTE_PRICING | SINGLE_MAX_OFFSET | DOUBLE_MAX_OFFSET |
|----------------|:-------------:|:------------:|:-----------------:|:-----------------:|
| MSIZE | | | | |
| MLOAD | | | 1 | |
| MSTORE | | | 1 | |
| MSTORE8 | | | 1 | |
| CREATE | [if EIP-3860] | | 1 | |
| CREATE2 | 1 | | 1 | |
| RETURN | | 1 | 1 | | is_deployment ≡ true |
| RETURN | | | 1 | | is_deployment ≡ false |
| REVERT | | | 1 | |
| LOG-type | | 1 | 1 | |
| SHA3 | 1 | | 1 | |
| CALLDATACOPY | 1 | | 1 | |
| RETURNDATACOPY | 1 | | 1 | |
| CODECOPY | 1 | | 1 | |
| EXTCODECOPY | 1 | | 1 | |
| MCOPY | 1 | | | 1 |
| CALL-type | | | | 1 |


In terms of lookups, we require:
- ISZERO checks (into WCP)
- LT checks (into WCP) between anything
- LT checks (into WCP) against LMMS
- DIV computations (by 32 into MOD, potentially into EUC)
- DIV computations (by 512 into MOD, potentially into EUC)
- lookup into the instruction decoder

ID ← duplicate the INST value and instruction decode the ID columns (1 row)
- decoder/INST
- decoder/IS_WORD_PRICING
- decoder/IS_BYTE_PRICING
- decoder/IS_MSIZE
- decoder/IS_RETURN
- decoder/IS_REVERT (?)
- decoder/IS_CALL
- decoder/SINGLE_MAX_OFFSET_COMPUTATION_REQUIRED
- decoder/DOUBLE_MAX_OFFSET_COMPUTATION_REQUIRED
- decoder/G_WORD
- decoder/G_BYTE

MACRO (1 row)
- macro/INST
- macro/OFFSET_1/2_HI/LO
- macro/SIZE_1/2_HI/LO
- macro/DEPLOYING
- macro/RES
- macro/MXPX
- macro/GAS_MXP
- macro/MAY_TRIGGER_NONTRIVIAL_MMU_OPERATION
- macro/S1NZNOMXPX
- macro/S2NZNOMXPX

SCENARIO (1 row) (to distinguish between the 6 possible scenarios)
- scenario/MSIZE
- MSIZE
- scenario/FIXED_SIZE_INSTRUCTIONS
- MLOAD, MSTORE, MSTORE8
- scenario/WORD_PRICING_AND_SINGLE_MAX_OFFSET
- CREATE, CREATE(2), CALLDATACOPY, RETURNDATACOPY, CODECOPY, EXTCODECOPY, SHA
- scenario/BYTE_PRICING_AND_SINGLE_MAX_OFFSET
- RETURN, REVERT, LOG,
- scenario/WORD_PRICING_AND_DOUBLE_MAX_OFFSET
- MCOPY
- scenario/BYTE_PRICING_AND_DOUBLE_MAX_OFFSET
- CALL-type
- scenario/WORDS
- scenario/WORDS_NEW
- scenario/C_MEM
- scenario/C_MEM_NEW

COMPUTATION (depending on the previous flags, including the expansion computation which we perform first)
- WCP_FLAG
- MOD_FLAG
- ARG_1/2_HI/LO
- RES_HI/LO
- EXO_INST

CT
CT_MAX (shared columns)
19 changes: 19 additions & 0 deletions _upgrades/modules/mxp_notes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# MXP module redesign

MXP module to become like the OOB module.
5 types of MXP instructions
- TYPE 1
- MSIZE
- TYPE 2
- MLOAD
- MSTORE
- TYPE 3
- MSTORE8
- TYPE 4
- TYPE 5
- CALL

new instructions:
- MCOPY

Will be of the same type as the other COPY instructions (CALLDATACOPY, (EXT)CODECOPY, RETURNDATACOPY)
Empty file added _upgrades/modules/rlptxn.md
Empty file.
1 change: 1 addition & 0 deletions _upgrades/modules/trm.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
delegate to WCP for PRC detection and
23 changes: 23 additions & 0 deletions _upgrades/network/Cancun/EIP-1153.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# EIP-1153: Transient storage opcodes

## Impact

- TSTORE/TLOAD likely to be included among the STORAGE instruction family
- with similar logic to STORAGE perspective (in particular wrt undoing)
- simpler as uniform pricing
- no associated refunds, no warmth
- no required comparison gas vs G_stipend = 2_300
- there is ONE difference though, in that the ABS_TX_NUM intervenes in the consistency argument
- new TRANSIENT perspective
- likely safer not to mix it with the STORAGE perspective
- will require its own (simple) consistency argument

## Notes

## Test vectors

- make tests parametric so that we can use both [S/T][STORE/LOAD]
- static stuff
- multi frame tests
- we need multitransaction tests
- stack underflow, static, out of gas
27 changes: 27 additions & 0 deletions _upgrades/network/Cancun/EIP-4788.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# EIP-4788: Beacon block root in the EVM

## Impact

## Notes

From the [Block processing](https://eips.ethereum.org/EIPS/eip-4788#block-processing) section

> Clients may decide to omit an explicit EVM call and directly set the storage values. Note: While this is a valid optimization for Ethereum mainnet, it could be problematic on non-mainnet situations in case a different contract is used.

So this means we could do this as a special operation at the start of every block

From [The Beacon Chain Ethereum 2.0 explainer you need to read first](https://ethos.dev/beacon-chain#:~:text=Slots%20and%20Epochs,is%2032%20slots%3A%206.4%20minutes.)

> A slot is a chance for a block to be added to the Beacon Chain. Every 12 seconds, one block is added when the system is running optimally. Validators do need to be roughly synchronized with time.
>
> A slot is like the block time, but slots can be empty. The Beacon Chain genesis block is at Slot 0

It seems that one way to do this would be to have a new TX_BCNRT (better: BLK_BCNRT) phase which would consist of
- a MISC/OOB row where we perform something like t ≡ TIMESTAMP mod 8191
- a STORAGE row where we insert the TIMESTAMP at t, and BEACON_ROOT at t + 8191
- maybe we need a TXN root and we must insert the BEACON_ROOT into the TXN_DATA module

Question: how do you initially deploy the SMC ?

## Test vectors

18 changes: 18 additions & 0 deletions _upgrades/network/Cancun/EIP-4844_∅?.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# EIP-4844: Shard Blob Transactions

## Impact

- new transaction type
- precompiles
- new opcode (BLOBHASH)

## Notes

- blob transactions (type 3) are not as of January 21
- no data on the precompile
- the BLOBHASH opcode, given that there are no blob transactions, could be supported and return 0

Blobhash should not be supported by the header

## Test vectors

19 changes: 19 additions & 0 deletions _upgrades/network/Cancun/EIP-5656.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# EIP-5656: MCOPY - Memory copying instruction

## Impact

- HUB
- misc/MXP
- requires double compute of the new memory size (like `CALL`'s)
- requires also detecting zero size
- misc/MMU
- these operations would be carried out in 0 or two steps, like the IDENTITY precompile
- first copy over data to fictious execution context
- then transfer value back

Thus two distinct MMU operations of the form `ramToRamSansPadding` (or whatever.)

## Notes

## Test vectors

19 changes: 19 additions & 0 deletions _upgrades/network/Cancun/EIP-6780.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# EIP-6780: SELFDESTRUCT only in same transaction

## Impact

This will impact deployments and SELFDESTRUCT:
- TX_INIT (for deployment transactions)
- any CREATE/CREATE2 will have to log its ABS_TX_NUM of the current moment
- the account/ perspective (we need a new field "deployed in transaction X"
- the processing of the SELFDESTRUCT opcode (in particular the final account wiping row will depend on whether or not the contract in question was deployed in the same transaction or not.)

## Notes

Read through
https://hackmd.io/@vbuterin/selfdestruct

## Test vectors

- interaction with CREATE (there should be some tests already)
- multitransaction test with DEPLOYMENT and CREATE
13 changes: 13 additions & 0 deletions _upgrades/network/Cancun/EIP-7516_∅?.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# EIP-7516: BLOBBASEFEE instruction

## Impact

- implementation of a new opcode
- needed if we support BLOBHASH

## Notes

See with Julien/Declan if it's a fixed value like LINEA_BASE_FEE

## Test vectors

8 changes: 8 additions & 0 deletions _upgrades/network/Paris/EIP-3675_∅.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# EIP-3675: Upgrade consensus to Proof-of-Stake

## Impact

None ?
- Consensus upgrade, not our domain

## Notes
Loading