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

fix(EVM): EVM emulator fixes after the audit #1134

Merged
merged 63 commits into from
Jan 16, 2025
Merged
Changes from 1 commit
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
44bd426
fix(EVM): Add static MCOPY cost (#1081)
0xVolosnikov Nov 27, 2024
8e8323d
fix(EVM): Cleanup in checkMemIsAccessible (#1082)
0xVolosnikov Nov 27, 2024
ef91e52
fix(EVM): Simplify OP_PC (#1084)
0xVolosnikov Nov 27, 2024
b649f5f
fix(EVM): Do not charge additionally for EraVM decommit (#1086)
0xVolosnikov Nov 27, 2024
5db2a30
fix(EVM): Fix stack overflow check (#1085)
0xVolosnikov Nov 27, 2024
ba50e19
fix(EVM): Add stack overflow check in dup (#1087)
0xVolosnikov Nov 27, 2024
30d56ad
fix(EVM): Fix SSTORE warmth check (#1089)
0xVolosnikov Nov 27, 2024
6fe1257
fix(EVM): Fix CALL in static context (#1091)
0xVolosnikov Nov 27, 2024
1818626
fix(EVM): Fix calls to contract being created (#1093)
0xVolosnikov Nov 27, 2024
12efa1c
fix(EVM): Wrap access to calldata to prevent out-of-bounds EraVM pani…
0xVolosnikov Nov 28, 2024
07f43d0
fix(EVM): Zero out frame gas left for underpaid precompiles (#1101)
0xVolosnikov Nov 28, 2024
c74c6ec
fix(EVM): Fix panics on insufficient balance in calls (#1108)
0xVolosnikov Dec 2, 2024
5869331
fix(EVM): Fix DUP1 underflow check (#1110)
0xVolosnikov Dec 2, 2024
55367f5
fix(EVM): Update LLVM options after fixes (#1112)
0xVolosnikov Dec 3, 2024
70d1de8
fix(EVM): Do not check memory boundaries if size is zero (#1114)
0xVolosnikov Dec 4, 2024
37874c7
fi(EVM): Fix EXTCODECOPY zeroing offset (#1115)
0xVolosnikov Dec 4, 2024
6a76d76
fix(EVM): Cleanup address bytes in EXTCODECOPY (#1116)
0xVolosnikov Dec 4, 2024
2bdc565
fix(EVM): Use raw calls to precompiles (#1118)
0xVolosnikov Dec 5, 2024
3299faa
fix(EVM): Make DELEGATECALL behavior closer to EVM (3) (#1120)
0xVolosnikov Dec 5, 2024
483b099
fix(EVM): Handle corner case of KECCAK with 0 size (#1121)
0xVolosnikov Dec 5, 2024
d61e38d
fix(EVM): Make fetchDeployedCode more robust (2) (#1123)
0xVolosnikov Dec 6, 2024
47b2ddd
fix(EVM): Increase max allowed memory (2) (#1124)
0xVolosnikov Dec 6, 2024
c4c964b
fix(EVM): Implement EXTCODEHASH in emulator (#1125)
0xVolosnikov Dec 6, 2024
921b3e3
fix(EVM): Add stipends for calls to zkVM contracts (#1126)
0xVolosnikov Dec 6, 2024
ef80122
fix(EVM): Make CREATE flow equivalent to EVM (#1127)
0xVolosnikov Dec 6, 2024
b61406b
Handle Empty.sol as empty account
0xVolosnikov Dec 8, 2024
72bbed0
Do not call precompiles if not enough gas provided
0xVolosnikov Dec 8, 2024
daf7022
fix(EVM): Fix logs implementation (2) (#1137)
0xVolosnikov Dec 9, 2024
fe838fc
feat(EVM): Enable EVM emulator using service call (#1141)
0xVolosnikov Dec 16, 2024
e7aa3a9
fix(EVM): Simplify and optimize out-of-bounds truncation in `CODECOPY…
0xVolosnikov Dec 18, 2024
c396c03
fix(EVM): Store unpadded EVM bytecode length in versioned bytecode ha…
0xVolosnikov Dec 19, 2024
0419d3e
fix(EVM): Add overflow checks in `JUMP` and `JUMPI` opcodes (#1159)
0xVolosnikov Dec 20, 2024
684c072
fix(EVM): Handle calldata-related opcodes in constructor (#1160)
0xVolosnikov Dec 20, 2024
f9824ea
fix(EVM): Fix and simplify memory expansion checks (#1165)
0xVolosnikov Dec 30, 2024
8349c91
fix(EVM): Fix access errors in EvmGasManager (L-02, L-06) (#1166)
0xVolosnikov Dec 30, 2024
f2677bf
fix(EVM): Use static call for isSlotWarm (L-07) (#1167)
0xVolosnikov Dec 30, 2024
34918c3
fix(EVM): Replace hardcoded memory offsets (N-01) (#1168)
0xVolosnikov Dec 30, 2024
7328b8c
fix(EVM): Fix namings (N-02) (#1169)
0xVolosnikov Dec 30, 2024
ba441ac
fix(EVM): Fix misleading comment (N-03) (#1170)
0xVolosnikov Dec 30, 2024
2947cab
fix(EVM): Gas optimizations (N-04) (#1171)
0xVolosnikov Dec 30, 2024
20bcb74
fix(EVM): Remove deadcode (N-06) (#1172)
0xVolosnikov Dec 30, 2024
ad62263
fix(EVM): Simplify set constructing bytecode hash (N-07) (#1173)
0xVolosnikov Dec 30, 2024
ddea0fc
fix(EVM): Code simplification (N-05) (#1174)
0xVolosnikov Jan 2, 2025
816c358
fix(EVM): Remove magic numbers (N-09) (#1175)
0xVolosnikov Jan 2, 2025
bfc691f
fix(EVM): Add missing documentation (N-10) (#1176)
0xVolosnikov Jan 2, 2025
26df944
fix(EVM): Remove redundant warming of EVM account during construction…
0xVolosnikov Jan 2, 2025
b494799
fix(EVM): Use constant PREVRANDAO value (N-11) (#1178)
0xVolosnikov Jan 2, 2025
e3307c3
fix(EVM): Add functionality for force EVM deploys (L-04) (#1179)
0xVolosnikov Jan 2, 2025
66c8e51
fix(EVM): Fix cross vm panic returndata logic (L-03) (#1180)
0xVolosnikov Jan 3, 2025
969886c
fix(EVM): Check the bytecode length on call (L-05) (#1181)
0xVolosnikov Jan 3, 2025
b194c86
fix(EVM): Check bytecodehash version in create functions of ContractD…
0xVolosnikov Jan 3, 2025
a539040
fix(EVM): Simplify ContractDeployer storage layout (#1143)
0xVolosnikov Jan 3, 2025
0ac215c
fix(EVM): Small misc fixes (#1184)
0xVolosnikov Jan 3, 2025
600d20a
chore(EVM): Update hashes (#1185)
0xVolosnikov Jan 6, 2025
3c77d4a
fix(EVM): Change additional stipends for calls to empty contracts (M-…
0xVolosnikov Jan 14, 2025
875d0a5
fix(EVM): Simplify padding (H-05) (#1195)
0xVolosnikov Jan 14, 2025
0d6fec7
fix(EVM): Increment nonce after EVM force deploy (L-04) (#1197)
0xVolosnikov Jan 14, 2025
16b76a2
fix(EVM): Use stricter checks for calldata (M-06, M-07) (#1200)
0xVolosnikov Jan 14, 2025
0e0a7ac
Add comments for delegate call implementation (L-10)
0xVolosnikov Jan 14, 2025
a9eb273
Apply suggested change
0xVolosnikov Jan 14, 2025
bbfd8e7
Charge additional 32k gas in contract creation from EOA or EraVM cont…
0xVolosnikov Jan 14, 2025
564b44d
Merge pull request #1196 from matter-labs/evm-emulator/additional-fix…
0xVolosnikov Jan 15, 2025
281e460
Update hashes
0xVolosnikov Jan 15, 2025
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
Prev Previous commit
Next Next commit
fix(EVM): Add functionality for force EVM deploys (L-04) (#1179)
  • Loading branch information
0xVolosnikov authored Jan 2, 2025
commit e3307c3389fcafccb4f64645cd06916f075267d7
40 changes: 23 additions & 17 deletions system-contracts/contracts/ContractDeployer.sol
Original file line number Diff line number Diff line change
@@ -181,7 +181,7 @@
function createEVM(bytes calldata _initCode) external payable override onlySystemCall returns (uint256, address) {
uint256 senderNonce;
// If the account is an EOA, use the min nonce. If it's a contract, use deployment nonce
if (msg.sender == tx.origin) {

Check warning on line 184 in system-contracts/contracts/ContractDeployer.sol

GitHub Actions / lint

Avoid to use tx.origin

Check warning on line 184 in system-contracts/contracts/ContractDeployer.sol

GitHub Actions / lint

Avoid to use tx.origin

Check warning on line 184 in system-contracts/contracts/ContractDeployer.sol

GitHub Actions / lint

Avoid to use tx.origin

Check warning on line 184 in system-contracts/contracts/ContractDeployer.sol

GitHub Actions / lint

Avoid to use tx.origin

Check warning on line 184 in system-contracts/contracts/ContractDeployer.sol

GitHub Actions / lint

Avoid to use tx.origin

Check warning on line 184 in system-contracts/contracts/ContractDeployer.sol

GitHub Actions / lint

Avoid to use tx.origin
// Subtract 1 for EOA since the nonce has already been incremented for this transaction
senderNonce = NONCE_HOLDER_SYSTEM_CONTRACT.getMinNonce(msg.sender) - 1;
} else {
@@ -302,11 +302,11 @@

/// @notice A struct that describes a forced deployment on an address
struct ForceDeployment {
// The bytecode hash to put on an address
// The bytecode hash to put on an address. Hash and length parts are ignored in case of EVM bytecode.
bytes32 bytecodeHash;
// The address on which to deploy the bytecodehash to
address newAddress;
// Whether to run the constructor on the force deployment
// Whether to run the constructor on the force deployment. Ignored in case of EVM deployment.
bool callConstructor;
// The value with which to initialize a contract
uint256 value;
@@ -318,25 +318,31 @@
/// @param _deployment Information about the forced deployment.
/// @param _sender The `msg.sender` inside the constructor call.
function forceDeployOnAddress(ForceDeployment calldata _deployment, address _sender) external payable onlySelf {
_ensureBytecodeIsKnown(_deployment.bytecodeHash);

// Since the `forceDeployOnAddress` function is called only during upgrades, the Governance is trusted to correctly select
// the addresses to deploy the new bytecodes to and to assess whether overriding the AccountInfo for the "force-deployed"
// contract is acceptable.
AccountInfo memory newAccountInfo;
newAccountInfo.supportedAAVersion = AccountAbstractionVersion.None;
// Accounts have sequential nonces by default.
newAccountInfo.nonceOrdering = AccountNonceOrdering.Sequential;
_storeAccountInfo(_deployment.newAddress, newAccountInfo);

_constructContract({
_sender: _sender,
_newAddress: _deployment.newAddress,
_bytecodeHash: _deployment.bytecodeHash,
_input: _deployment.input,
_isSystem: false,
_callConstructor: _deployment.callConstructor
});
if (Utils.isCodeHashEVM(_deployment.bytecodeHash)) {
// It is not possible to change the AccountInfo for EVM contracts.
_constructEVMContract(_sender, _deployment.newAddress, _deployment.input);
} else {
_ensureBytecodeIsKnown(_deployment.bytecodeHash);

AccountInfo memory newAccountInfo;
newAccountInfo.supportedAAVersion = AccountAbstractionVersion.None;
// Accounts have sequential nonces by default.
newAccountInfo.nonceOrdering = AccountNonceOrdering.Sequential;
_storeAccountInfo(_deployment.newAddress, newAccountInfo);

_constructContract({
_sender: _sender,
_newAddress: _deployment.newAddress,
_bytecodeHash: _deployment.bytecodeHash,
_input: _deployment.input,
_isSystem: false,
_callConstructor: _deployment.callConstructor
});
}
}

/// @notice This method is to be used only during an upgrade to set bytecodes on specific addresses.
Loading