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(EVM): Use different memory layouts for constructor and deployed contract #1023

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 4 additions & 4 deletions system-contracts/SystemContractsHashes.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@
"contractName": "SystemContext",
"bytecodePath": "artifacts-zk/contracts-preprocessed/SystemContext.sol/SystemContext.json",
"sourceCodePath": "contracts-preprocessed/SystemContext.sol",
"bytecodeHash": "0x010001c5a6801732584ea1804b91e5621ac25460be6b91196fc4d68fd3a65105",
"sourceCodeHash": "0xc5ce25a94e3b510183635dd2fe0152dbcaa705bc8802fb3a4390253b5af3aa0a"
"bytecodeHash": "0x010001c516b1721bd4745d8d3a36607d4f6b65c0d51dcb1b5801aaf0234293cc",
"sourceCodeHash": "0xe2f6eb015d260aafe9405b28ef3ec27921add4de7f329b7ef61e0aa6c9365e29"
},
{
"contractName": "EventWriter",
Expand All @@ -122,8 +122,8 @@
"contractName": "EvmEmulator",
"bytecodePath": "contracts-preprocessed/artifacts/EvmEmulator.yul/EvmEmulator.yul.zbin",
"sourceCodePath": "contracts-preprocessed/EvmEmulator.yul",
"bytecodeHash": "0x01000d1da56c97d7554e0e9c8397a970b5a44c569aab6fb6661f820c5ae3e58e",
"sourceCodeHash": "0xb6b321ccc368ca848ca6675eaf968dedd4b4da388d74829cd3fb9927f4550071"
"bytecodeHash": "0x01000d6d51fe13baa8278266bb8775c03df377c8b0aa6ebca6c8d98a096b7bb2",
"sourceCodeHash": "0x676b1652efec61f16eb271efda30e3a695681ce7b2f1a509b33c4afb15c55723"
},
{
"contractName": "EvmGasManager",
Expand Down
12 changes: 10 additions & 2 deletions system-contracts/contracts/EvmEmulator.yul
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
object "EvmEmulator" {
code {
function MAX_POSSIBLE_ACTIVE_BYTECODE() -> max {
max := MAX_POSSIBLE_INIT_BYTECODE()
}

/// @dev This function is used to get the initCode.
/// @dev It assumes that the initCode has been passed via the calldata and so we use the pointer
/// to obtain the bytecode.
Expand Down Expand Up @@ -143,7 +147,7 @@ object "EvmEmulator" {
}

function MEM_OFFSET() -> offset {
offset := add(BYTECODE_OFFSET(), MAX_POSSIBLE_INIT_BYTECODE())
offset := add(BYTECODE_OFFSET(), MAX_POSSIBLE_ACTIVE_BYTECODE())
}

function MEM_OFFSET_INNER() -> offset {
Expand Down Expand Up @@ -3155,6 +3159,10 @@ object "EvmEmulator" {
}
object "EvmEmulator_deployed" {
code {
function MAX_POSSIBLE_ACTIVE_BYTECODE() -> max {
max := MAX_POSSIBLE_DEPLOYED_BYTECODE()
}

////////////////////////////////////////////////////////////////
// CONSTANTS
////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -3240,7 +3248,7 @@ object "EvmEmulator" {
}

function MEM_OFFSET() -> offset {
offset := add(BYTECODE_OFFSET(), MAX_POSSIBLE_INIT_BYTECODE())
offset := add(BYTECODE_OFFSET(), MAX_POSSIBLE_ACTIVE_BYTECODE())
}

function MEM_OFFSET_INNER() -> offset {
Expand Down
8 changes: 8 additions & 0 deletions system-contracts/evm-emulator/EvmEmulator.template.yul
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
object "EvmEmulator" {
code {
function MAX_POSSIBLE_ACTIVE_BYTECODE() -> max {
max := MAX_POSSIBLE_INIT_BYTECODE()
}

/// @dev This function is used to get the initCode.
/// @dev It assumes that the initCode has been passed via the calldata and so we use the pointer
/// to obtain the bytecode.
Expand Down Expand Up @@ -104,6 +108,10 @@ object "EvmEmulator" {
}
object "EvmEmulator_deployed" {
code {
function MAX_POSSIBLE_ACTIVE_BYTECODE() -> max {
max := MAX_POSSIBLE_DEPLOYED_BYTECODE()
}

<!-- @include EvmEmulatorFunctions.template.yul -->

function $llvm_NoInline_llvm$_simulate(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ function MAX_POSSIBLE_INIT_BYTECODE() -> max {
}

function MEM_OFFSET() -> offset {
offset := add(BYTECODE_OFFSET(), MAX_POSSIBLE_INIT_BYTECODE())
offset := add(BYTECODE_OFFSET(), MAX_POSSIBLE_ACTIVE_BYTECODE())
}

function MEM_OFFSET_INNER() -> offset {
Expand Down
Loading