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): Small misc fixes #1184

Merged
merged 2 commits into from
Jan 3, 2025
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
2 changes: 1 addition & 1 deletion system-contracts/contracts/ContractDeployer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,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 179 in system-contracts/contracts/ContractDeployer.sol

View workflow job for this annotation

GitHub Actions / lint

Avoid to use tx.origin

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

View workflow job for this annotation

GitHub Actions / lint

Avoid to use tx.origin

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

View workflow job for this annotation

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 {
Expand Down Expand Up @@ -425,7 +425,7 @@
// solhint-disable-next-line reason-string, gas-custom-errors
require(NONCE_HOLDER_SYSTEM_CONTRACT.getRawNonce(_newAddress) == 0x0);
// solhint-disable-next-line reason-string, gas-custom-errors
require(ACCOUNT_CODE_STORAGE_SYSTEM_CONTRACT.getCodeHash(uint256(uint160(_newAddress))) == 0x0);
require(ACCOUNT_CODE_STORAGE_SYSTEM_CONTRACT.getRawCodeHash(_newAddress) == 0x0);
return _performDeployOnAddressEVM(_sender, _newAddress, AccountAbstractionVersion.None, _initCode);
}

Expand Down
32 changes: 16 additions & 16 deletions system-contracts/contracts/EvmEmulator.yul
Original file line number Diff line number Diff line change
Expand Up @@ -1172,10 +1172,10 @@ object "EvmEmulator" {
pushEvmFrame(gasForTheCall, false)

// move needed memory slots to the scratch space
mstore(mul(10, 32), mload(sub(offset, 0x80))
mstore(mul(11, 32), mload(sub(offset, 0x60))
mstore(mul(12, 32), mload(sub(offset, 0x40))
mstore(mul(13, 32), mload(sub(offset, 0x20))
mstore(mul(10, 32), mload(sub(offset, 0x80)))
mstore(mul(11, 32), mload(sub(offset, 0x60)))
mstore(mul(12, 32), mload(sub(offset, 0x40)))
mstore(mul(13, 32), mload(sub(offset, 0x20)))

// selector: function createEvmFromEmulator(address newAddress, bytes calldata _initCode)
mstore(sub(offset, 0x80), 0xe43cec64)
Expand All @@ -1186,10 +1186,10 @@ object "EvmEmulator" {
let result := performSystemCallForCreate(value, sub(offset, 0x64), add(size, 0x64))

// move memory slots back
mstore(sub(offset, 0x80), mload(mul(10, 32))
mstore(sub(offset, 0x60), mload(mul(11, 32))
mstore(sub(offset, 0x40), mload(mul(12, 32))
mstore(sub(offset, 0x20), mload(mul(13, 32))
mstore(sub(offset, 0x80), mload(mul(10, 32)))
mstore(sub(offset, 0x60), mload(mul(11, 32)))
mstore(sub(offset, 0x40), mload(mul(12, 32)))
mstore(sub(offset, 0x20), mload(mul(13, 32)))

let gasLeft
switch result
Expand Down Expand Up @@ -4098,10 +4098,10 @@ object "EvmEmulator" {
pushEvmFrame(gasForTheCall, false)

// move needed memory slots to the scratch space
mstore(mul(10, 32), mload(sub(offset, 0x80))
mstore(mul(11, 32), mload(sub(offset, 0x60))
mstore(mul(12, 32), mload(sub(offset, 0x40))
mstore(mul(13, 32), mload(sub(offset, 0x20))
mstore(mul(10, 32), mload(sub(offset, 0x80)))
mstore(mul(11, 32), mload(sub(offset, 0x60)))
mstore(mul(12, 32), mload(sub(offset, 0x40)))
mstore(mul(13, 32), mload(sub(offset, 0x20)))

// selector: function createEvmFromEmulator(address newAddress, bytes calldata _initCode)
mstore(sub(offset, 0x80), 0xe43cec64)
Expand All @@ -4112,10 +4112,10 @@ object "EvmEmulator" {
let result := performSystemCallForCreate(value, sub(offset, 0x64), add(size, 0x64))

// move memory slots back
mstore(sub(offset, 0x80), mload(mul(10, 32))
mstore(sub(offset, 0x60), mload(mul(11, 32))
mstore(sub(offset, 0x40), mload(mul(12, 32))
mstore(sub(offset, 0x20), mload(mul(13, 32))
mstore(sub(offset, 0x80), mload(mul(10, 32)))
mstore(sub(offset, 0x60), mload(mul(11, 32)))
mstore(sub(offset, 0x40), mload(mul(12, 32)))
mstore(sub(offset, 0x20), mload(mul(13, 32)))

let gasLeft
switch result
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1112,10 +1112,10 @@ function _executeCreate(offset, size, value, evmGasLeftOld, isCreate2, salt) ->
pushEvmFrame(gasForTheCall, false)

// move needed memory slots to the scratch space
mstore(mul(10, 32), mload(sub(offset, 0x80))
mstore(mul(11, 32), mload(sub(offset, 0x60))
mstore(mul(12, 32), mload(sub(offset, 0x40))
mstore(mul(13, 32), mload(sub(offset, 0x20))
mstore(mul(10, 32), mload(sub(offset, 0x80)))
mstore(mul(11, 32), mload(sub(offset, 0x60)))
mstore(mul(12, 32), mload(sub(offset, 0x40)))
mstore(mul(13, 32), mload(sub(offset, 0x20)))

// selector: function createEvmFromEmulator(address newAddress, bytes calldata _initCode)
mstore(sub(offset, 0x80), 0xe43cec64)
Expand All @@ -1126,10 +1126,10 @@ function _executeCreate(offset, size, value, evmGasLeftOld, isCreate2, salt) ->
let result := performSystemCallForCreate(value, sub(offset, 0x64), add(size, 0x64))

// move memory slots back
mstore(sub(offset, 0x80), mload(mul(10, 32))
mstore(sub(offset, 0x60), mload(mul(11, 32))
mstore(sub(offset, 0x40), mload(mul(12, 32))
mstore(sub(offset, 0x20), mload(mul(13, 32))
mstore(sub(offset, 0x80), mload(mul(10, 32)))
mstore(sub(offset, 0x60), mload(mul(11, 32)))
mstore(sub(offset, 0x40), mload(mul(12, 32)))
mstore(sub(offset, 0x20), mload(mul(13, 32)))

let gasLeft
switch result
Expand Down
Loading