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

Feat/cancun #31

Merged
merged 61 commits into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
a2770f3
Squashed 'evm_arithmetization/' changes from d547f8d5..016b000e
Nashtare Feb 14, 2024
2552e45
Merge commit 'a2770f36b6c03f00978c0f266531028094eaff44' into feat/cancun
Nashtare Feb 14, 2024
d43c8e2
Implement EIP-4788 for Cancun (#40)
Nashtare Feb 18, 2024
8926efd
Implement Blob transactions (type-3) and BLOBHASH opcode (#50)
Nashtare Feb 21, 2024
5f5485c
Merge remote-tracking branch 'origin/main' into cancun-main
Nashtare Feb 26, 2024
d739a7a
Merge pull request #61 from 0xPolygonZero/cancun-main
Nashtare Feb 26, 2024
f084287
Fix beacons root contract bytecode (#70)
Nashtare Feb 29, 2024
e57e753
Merge branch 'main' into feat/cancun
Nashtare Mar 6, 2024
23b7a28
LxLy exit roots (#90)
wborgeaud Mar 8, 2024
e6b137c
Eip 1153 (TLOAD/TSTORE) (#59)
4l0n50 Mar 9, 2024
d243628
Merge remote-tracking branch 'origin/main' into feat/cancun
Nashtare Mar 11, 2024
6eca575
Remove blobbasefee from block header (#100)
Nashtare Mar 11, 2024
deb4f1c
Remove blobbasefee from block header
Nashtare Mar 11, 2024
2e4258c
Merge branch 'main' into feat/cancun
Nashtare Mar 11, 2024
8c7ccb0
Remove prints
Nashtare Mar 11, 2024
366e0a2
Fix MCOPY from rebasing (#103)
Nashtare Mar 11, 2024
05fd0c1
Fix storage write for beacons root contract (#102)
Nashtare Mar 12, 2024
4f3e858
EIP-4844 part 2: Point evaluation precompile (#133)
Nashtare Apr 4, 2024
9cd5cc7
Merge remote-tracking branch 'origin/develop' into feat/cancun
Nashtare Apr 10, 2024
bfc622a
Some fixes to Cancun (#187)
Nashtare Apr 24, 2024
45d19c8
Merge remote-tracking branch 'origin/develop' into feat/cancun
Nashtare May 1, 2024
b1d0416
Insert blob versioned hashes in signature payload for hashing (#209)
Nashtare May 2, 2024
57a62a4
Fix KZG precompile context setup (#210)
Nashtare May 2, 2024
f0022eb
Fix txn type encoding for receipts (#214)
Nashtare May 3, 2024
56aa543
Merge remote-tracking branch 'origin/develop' into feat/cancun
Nashtare May 3, 2024
f225a5d
Add blob gas fee burn for type-3 txns (#219)
Nashtare May 3, 2024
052e476
Update decoder processing for cancun (#207)
Nashtare May 4, 2024
06e45bf
cancun: Add a full block test (#223)
Nashtare May 6, 2024
a5f5421
Fix KZG precompile I/O (#213)
Nashtare May 6, 2024
23ee01b
Fix selfdestruct address listing (#225)
Nashtare May 6, 2024
afb9633
Fix withdrawals without txns and add test for empty block (#228)
Nashtare May 16, 2024
c610b93
Merge remote-tracking branch 'origin/develop' into feat/cancun
Nashtare May 20, 2024
abf919d
doc: update README (#242)
Nashtare May 22, 2024
aa36464
Cleanup and bring back deadcode lint (#232)
Nashtare May 23, 2024
9af4bf7
Merge branch 'develop' into feat/cancun
Nashtare May 24, 2024
aea633c
fix(cancun): dummy payloads and public input retrieval (#249)
Nashtare May 27, 2024
d3e8357
fix: encode calldata for EIP-4780 as U256 (#253)
Nashtare May 28, 2024
82d4901
fix: handle KZG precompile errors properly (#251)
Nashtare May 28, 2024
e48f8e9
fix(cancun): `mcopy` check offsets and overwrites (#252)
Nashtare May 29, 2024
275c2dd
fix(cancun): correct search loop in transient storage (#257)
Nashtare Jun 3, 2024
ef6b99d
perf: Charge gas before tload search (#272)
Nashtare Jun 10, 2024
b2c510d
Merge remote-tracking branch 'origin/develop' into feat/cancun
Nashtare Jun 10, 2024
2ffda4f
fix: add check on decoded versioned hashes (#278)
Nashtare Jun 13, 2024
2ad611a
Merge branch 'develop' into feat/cancun
Nashtare Jun 14, 2024
b7cea48
Merge branch 'develop' into feat/cancun
Nashtare Jun 24, 2024
dfc733d
Merge remote-tracking branch 'origin/develop' into feat/cancun
Nashtare Jun 27, 2024
6536269
Merge branch 'develop' into feat/cancun
Nashtare Jul 1, 2024
b3ef414
fix: Fix CI job
Nashtare Jul 1, 2024
51256ac
fix: pacify clippy
Nashtare Jul 1, 2024
59cdfad
fix: Add beacon roots touched slots into `state_access` with native t…
Nashtare Jul 3, 2024
858d6a1
Merge branch 'develop' into feat/cancun
Nashtare Jul 8, 2024
adf00d8
feat(cancun): update test blocks (#365)
Nashtare Jul 9, 2024
7ff44ed
fix: failed to send proof
atanmarko Jul 9, 2024
f9212b5
feat: cancun jerigon test network (#367)
atanmarko Jul 9, 2024
71bcb27
Merge branch 'develop' into feat/cancun
Nashtare Jul 10, 2024
5ae6629
fix(cancun): properly update accumulator in fake_exponential() (#376)
Nashtare Jul 10, 2024
ddca6be
Merge branch 'develop' into feat/cancun
Nashtare Jul 10, 2024
3cdecff
fix(cancun): tweak ranges in integration tests (#377)
Nashtare Jul 11, 2024
60db32c
`cancun`: cleanup pre-release (#392)
Nashtare Jul 15, 2024
34de2fd
Merge remote-tracking branch 'origin/develop' into feat/cancun
Nashtare Jul 15, 2024
a7384fa
Merge remote-tracking branch 'origin/develop' into feat/cancun
Nashtare Jul 15, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/arithmetization/cpulogic.tex
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,15 @@ \subsection{Privileged instructions}
\item[0x21.] \texttt{KECCAK\_GENERAL}. Pops 2 elements (a Memory address, followed by a length $\ell$) and pushes the hash of the memory portion starting at the
constructed address and of length $\ell$. It is similar to KECCAK256 (0x20) instruction, but can be applied to any memory section (i.e. even privileged ones).

\item[0x49.] \texttt{PROVER\_INPUT}. Pushes a single prover input onto the stack.

\item[0xC0-0xDF.] \texttt{MSTORE\_32BYTES}. Pops 2 elements from the stack (a Memory address, and then a value), and pushes
a new address' onto the stack. The value is being decomposed into bytes and written to memory, starting from the fetched address. The new address being pushed is computed as the
initial address + the length of the byte sequence being written to memory. Note that similarly to PUSH (0x60-0x7F) instructions, there are 32 MSTORE\_32BYTES instructions, each
corresponding to a target byte length (length 0 is ignored, for the same reasons as MLOAD\_32BYTES, see below). Writing to memory an integer fitting in $n$ bytes with a length $\ell < n$ will
result in the integer being truncated. On the other hand, specifying a length $\ell$ greater than the byte size of the value being written will result in padding with zeroes. This
process is heavily used when resetting memory sections (by calling MSTORE\_32BYTES\_32 with the value 0).

\item[0xEE.] \texttt{PROVER\_INPUT}. Pushes a single prover input onto the stack.

\item[0xF6.] \texttt{GET\_CONTEXT}. Pushes the current context onto the stack. The kernel always has context 0.

\item[0xF7.] \texttt{SET\_CONTEXT}. Pops the top element of the stack and updates the current context to this value. It is usually used when calling another contract or precompile,
Expand Down
2 changes: 1 addition & 1 deletion evm_arithmetization/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ rand_chacha = "0.3.1"
rlp = { workspace = true }
rlp-derive = { workspace = true }
serde = { workspace = true, features = ["derive"] }
sha2 = "0.10.6"
static_assertions = "1.1.0"
hashbrown = { version = "0.14.0" }
tiny-keccak = "2.0.2"
Expand All @@ -50,7 +51,6 @@ jemallocator = "0.5.0"
criterion = "0.5.1"
hex = { workspace = true }
ripemd = "0.1.3"
sha2 = "0.10.6"

[features]
default = ["parallel"]
Expand Down
8 changes: 2 additions & 6 deletions evm_arithmetization/src/cpu/control_flow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ pub(crate) fn eval_packed_generic<P: PackedField>(
.constraint_transition(is_native_instruction * (lv.is_kernel_mode - nv.is_kernel_mode));

// Apply the same checks as before, for PROVER_INPUT.
let is_prover_input: P = lv.op.push_prover_input * (lv.opcode_bits[5] - P::ONES);
let is_prover_input: P = lv.op.push_prover_input * lv.opcode_bits[7];
yield_constr.constraint_transition(
is_prover_input * (lv.program_counter - nv.program_counter + P::ONES),
);
Expand Down Expand Up @@ -129,11 +129,7 @@ pub(crate) fn eval_ext_circuit<F: RichField + Extendable<D>, const D: usize>(
yield_constr.constraint_transition(builder, kernel_constr);

// Same constraints as before, for PROVER_INPUT.
let is_prover_input = builder.mul_sub_extension(
lv.op.push_prover_input,
lv.opcode_bits[5],
lv.op.push_prover_input,
);
let is_prover_input = builder.mul_extension(lv.op.push_prover_input, lv.opcode_bits[7]);
let pc_constr = builder.mul_add_extension(is_prover_input, pc_diff, is_prover_input);
yield_constr.constraint_transition(builder, pc_constr);
let kernel_constr = builder.mul_extension(is_prover_input, kernel_diff);
Expand Down
13 changes: 7 additions & 6 deletions evm_arithmetization/src/cpu/cpu_stark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,7 @@ pub(crate) fn ctl_arithmetic_base_rows<F: Field>() -> TableWithColumns<F> {
// (also `ops` is used as the operation filter). The list of
// operations includes binary operations which will simply ignore
// the third input.
let col_bit = Column::linear_combination_with_constant(
vec![(COL_MAP.opcode_bits[5], F::NEG_ONE)],
F::ONE,
);
let col_bit = Column::single(COL_MAP.opcode_bits[7]);
TableWithColumns::new(
*Table::Cpu,
columns,
Expand Down Expand Up @@ -263,9 +260,13 @@ pub(crate) fn ctl_data_byte_packing_push<F: Field>() -> Vec<Column<F>> {

/// CTL filter for the `PUSH` operation.
pub(crate) fn ctl_filter_byte_packing_push<F: Field>() -> Filter<F> {
let bit_col = Column::single(COL_MAP.opcode_bits[5]);
let col_bit = Column::linear_combination_with_constant(
vec![(COL_MAP.opcode_bits[7], F::NEG_ONE)],
F::ONE,
);

Filter::new(
vec![(Column::single(COL_MAP.op.push_prover_input), bit_col)],
vec![(Column::single(COL_MAP.op.push_prover_input), col_bit)],
vec![],
)
}
Expand Down
15 changes: 5 additions & 10 deletions evm_arithmetization/src/cpu/decode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,12 +197,11 @@ pub(crate) fn eval_packed_generic<P: PackedField>(

// Manually check PUSH and PROVER_INPUT.
// PROVER_INPUT is a kernel-only instruction, but not PUSH.
let push_prover_input_constr = (opcode - P::Scalar::from_canonical_usize(0x49_usize))
let push_prover_input_constr = (opcode - P::Scalar::from_canonical_usize(0xee_usize))
* (opcode_high_three - P::Scalar::from_canonical_usize(0x60_usize))
* lv.op.push_prover_input;
yield_constr.constraint(push_prover_input_constr);
let prover_input_constr =
lv.op.push_prover_input * (lv.opcode_bits[5] - P::ONES) * (P::ONES - kernel_mode);
let prover_input_constr = lv.op.push_prover_input * lv.opcode_bits[7] * (P::ONES - kernel_mode);
yield_constr.constraint(prover_input_constr);
}

Expand Down Expand Up @@ -389,20 +388,16 @@ pub(crate) fn eval_ext_circuit<F: RichField + Extendable<D>, const D: usize>(
// Manually check PUSH and PROVER_INPUT.
// PROVER_INPUT is a kernel-only instruction, but not PUSH.
let prover_input_opcode =
builder.constant_extension(F::Extension::from_canonical_usize(0x49usize));
let push_opcodes = builder.constant_extension(F::Extension::from_canonical_usize(0x60usize));
builder.constant_extension(F::Extension::from_canonical_usize(0xee_usize));
let push_opcodes = builder.constant_extension(F::Extension::from_canonical_usize(0x60_usize));

let push_constr = builder.sub_extension(opcode_high_three, push_opcodes);
let prover_input_constr = builder.sub_extension(opcode, prover_input_opcode);

let push_prover_input_constr =
builder.mul_many_extension([lv.op.push_prover_input, prover_input_constr, push_constr]);
yield_constr.constraint(builder, push_prover_input_constr);
let prover_input_filter = builder.mul_sub_extension(
lv.op.push_prover_input,
lv.opcode_bits[5],
lv.op.push_prover_input,
);
let prover_input_filter = builder.mul_extension(lv.op.push_prover_input, lv.opcode_bits[7]);
let constr = builder.mul_extension(prover_input_filter, is_not_kernel_mode);
yield_constr.constraint(builder, constr);
}
16 changes: 8 additions & 8 deletions evm_arithmetization/src/cpu/gas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,11 @@ fn eval_packed_accumulate<P: PackedField>(
);

// For PROVER_INPUT and PUSH operations.
// PUSH operations are differentiated from PROVER_INPUT by their 6th bit set to
// PUSH operations are differentiated from PROVER_INPUT by their 8th bit set to
// 1.
let push_prover_input_gas_cost = lv.opcode_bits[5]
let push_prover_input_gas_cost = (P::ONES - lv.opcode_bits[7])
* P::Scalar::from_canonical_u32(G_VERYLOW.unwrap())
+ (P::ONES - lv.opcode_bits[5]) * P::Scalar::from_canonical_u32(KERNEL_ONLY_INSTR.unwrap());
+ lv.opcode_bits[7] * P::Scalar::from_canonical_u32(KERNEL_ONLY_INSTR.unwrap());
yield_constr
.constraint_transition(lv.op.push_prover_input * (gas_diff - push_prover_input_gas_cost));
}
Expand Down Expand Up @@ -282,13 +282,13 @@ fn eval_ext_circuit_accumulate<F: RichField + Extendable<D>, const D: usize>(
yield_constr.constraint_transition(builder, constr);

// For PROVER_INPUT and PUSH operations.
// PUSH operations are differentiated from PROVER_INPUT by their 6th bit set to
// PUSH operations are differentiated from PROVER_INPUT by their 8th bit set to
// 1.
let push_prover_input_gas_cost = builder.arithmetic_extension(
F::from_canonical_u32(G_VERYLOW.unwrap())
- F::from_canonical_u32(KERNEL_ONLY_INSTR.unwrap()),
F::from_canonical_u32(KERNEL_ONLY_INSTR.unwrap()),
lv.opcode_bits[5],
F::from_canonical_u32(KERNEL_ONLY_INSTR.unwrap())
- F::from_canonical_u32(G_VERYLOW.unwrap()),
F::from_canonical_u32(G_VERYLOW.unwrap()),
lv.opcode_bits[7],
one,
one,
);
Expand Down
Loading