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

chore: Initial cleanup in EvmInterpreter #33

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
4 changes: 2 additions & 2 deletions system-contracts/contracts/Constants.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {ICompressor} from "./interfaces/ICompressor.sol";
import {IComplexUpgrader} from "./interfaces/IComplexUpgrader.sol";
import {IBootloaderUtilities} from "./interfaces/IBootloaderUtilities.sol";
import {IPubdataChunkPublisher} from "./interfaces/IPubdataChunkPublisher.sol";
import "./EvmGasManager.sol";
import {IEvmGasManager} from "./interfaces/IEvmGasManager.sol";

/// @dev All the system contracts introduced by ZKsync have their addresses
/// started from 2^15 in order to avoid collision with Ethereum precompiles.
Expand Down Expand Up @@ -85,7 +85,7 @@ address constant EVENT_WRITER_CONTRACT = address(SYSTEM_CONTRACTS_OFFSET + 0x0d)
ICompressor constant COMPRESSOR_CONTRACT = ICompressor(address(SYSTEM_CONTRACTS_OFFSET + 0x0e));

IComplexUpgrader constant COMPLEX_UPGRADER_CONTRACT = IComplexUpgrader(address(SYSTEM_CONTRACTS_OFFSET + 0x0f));
EvmGasManager constant EVM_GAS_MANAGER = EvmGasManager(address(SYSTEM_CONTRACTS_OFFSET + 0x13));
IEvmGasManager constant EVM_GAS_MANAGER = IEvmGasManager(address(SYSTEM_CONTRACTS_OFFSET + 0x13));

IPubdataChunkPublisher constant PUBDATA_CHUNK_PUBLISHER = IPubdataChunkPublisher(
address(SYSTEM_CONTRACTS_OFFSET + 0x11)
Expand Down
16 changes: 9 additions & 7 deletions system-contracts/contracts/ContractDeployer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -201,11 +201,11 @@
// Subtract 1 for EOA since the nonce has already been incremented for this transaction

uint256 deploymentNonce = NONCE_HOLDER_SYSTEM_CONTRACT.getDeploymentNonce(msg.sender);
if ((msg.sender != tx.origin) && deploymentNonce == 0) {

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

View workflow job for this annotation

GitHub Actions / lint

Avoid to use tx.origin

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

View workflow job for this annotation

GitHub Actions / lint

Avoid to use tx.origin

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

View workflow job for this annotation

GitHub Actions / lint

Avoid to use tx.origin
NONCE_HOLDER_SYSTEM_CONTRACT.incrementDeploymentNonce(msg.sender);
}

uint256 senderNonce = msg.sender == tx.origin

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

View workflow job for this annotation

GitHub Actions / lint

Avoid to use tx.origin

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

View workflow job for this annotation

GitHub Actions / lint

Avoid to use tx.origin

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

View workflow job for this annotation

GitHub Actions / lint

Avoid to use tx.origin
? NONCE_HOLDER_SYSTEM_CONTRACT.getMinNonce(msg.sender) - 1
: NONCE_HOLDER_SYSTEM_CONTRACT.incrementDeploymentNonce(msg.sender);
address newAddress = Utils.getNewAddressCreateEVM(msg.sender, senderNonce);
Expand Down Expand Up @@ -532,15 +532,17 @@
SystemContractHelper.setValueForNextFarCall(uint128(value));
}

// In case of EVM contracts returnData is the new deployed code
bool success = SystemContractHelper.mimicCall(uint32(gasleft()), _newAddress, msg.sender, _input, true, false);
bool success = EfficientCall.rawMimicCall({
_gas: uint32(gasleft()),
_address: _newAddress,
_data: _input,
_whoToMimic: msg.sender,
_isConstructor: true,
_isSystem: false
});

if (!success) {
assembly {
// Just propagate the error back
returndatacopy(0, 0, returndatasize())
revert(0, returndatasize())
}
EfficientCall.propagateRevert();
}

bytes32 codeHash = _getEvmCodeHash(_newAddress);
Expand Down
Loading
Loading