Skip to content

Commit

Permalink
Remove unnecessary code
Browse files Browse the repository at this point in the history
  • Loading branch information
gianbelinche committed Aug 28, 2024
1 parent 0aeb17e commit 39208c7
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 306 deletions.
6 changes: 1 addition & 5 deletions system-contracts/contracts/ContractDeployer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ contract ContractDeployer is IContractDeployer, ISystemContract {
modifier onlySystemEvm() {
require(ACCOUNT_CODE_STORAGE_SYSTEM_CONTRACT.isAccountEVM(msg.sender), "only system evm");
require(
SystemContractHelper.isSystemCall() || SystemContractHelper.isSystemContract(msg.sender),
SystemContractHelper.isSystemCall(),
"This method require system call flag"
);
_;
Expand Down Expand Up @@ -224,10 +224,6 @@ contract ContractDeployer is IContractDeployer, ISystemContract {
return newAddress;
}

function createEVMInternal(address _newAddress, bytes calldata _initCode) onlySystemEvm external payable {
_evmDeployOnAddress(_newAddress, _initCode);
}

/// @notice Deploys a contract account with similar address derivation rules to the EVM's `CREATE2` opcode.
/// @param _salt The CREATE2 salt
/// @param _bytecodeHash The correctly formatted hash of the bytecode.
Expand Down
2 changes: 1 addition & 1 deletion system-contracts/contracts/EvmGasManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ contract EvmGasManager is ISystemContract {
modifier onlySystemEvm() {
require(ACCOUNT_CODE_STORAGE_SYSTEM_CONTRACT.isAccountEVM(msg.sender), "only system evm");
require(
SystemContractHelper.isSystemCall() || SystemContractHelper.isSystemContract(msg.sender),
SystemContractHelper.isSystemCall(),
"This method require system call flag"
);
_;
Expand Down
2 changes: 1 addition & 1 deletion system-contracts/contracts/EvmInterpreter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -980,7 +980,7 @@ contract EvmInterpreter {
return (_createdAddress, _gasLeft);
}

uint32 constant CREATE_EVM_INTERNAL_SELECTOR = uint32(DEPLOYER_SYSTEM_CONTRACT.createEVMInternal.selector);
uint32 constant CREATE_EVM_INTERNAL_SELECTOR = uint32(DEPLOYER_SYSTEM_CONTRACT.createEVM.selector);

function _performCreateCall(
address _deployedAddress,
Expand Down
99 changes: 1 addition & 98 deletions system-contracts/contracts/EvmInterpreterFunctions.template.yul
Original file line number Diff line number Diff line change
Expand Up @@ -620,75 +620,6 @@ function isEOA(addr) -> ret {
}
}

function getNewAddress(addr) -> newAddr {
let digest, nonce, addressEncoded, nonceEncoded, nonceEncodedLength, listLength, listLengthEconded

nonce := getNonce(addr)

addressEncoded := and(
add(addr, shl(160, 0x94)),
0xffffffffffffffffffffffffffffffffffffffffff
)

nonceEncoded := nonce
nonceEncodedLength := 1
if iszero(nonce) {
nonceEncoded := 128
}
switch gt(nonce, 0xFFFF)
case 1 {
switch gt(nonce, 0xFFFFFF)
case 1 {
// The nonce has 4 bytes
nonceEncoded := shl(32, 0x84)
nonceEncodedLength := 5
}
default {
// The nonce has 3 bytes
nonceEncoded := shl(24, 0x83)
nonceEncodedLength := 4
}
nonceEncoded := add(nonceEncoded, nonce)
}
default {
// The nonce has 2 bytes
if gt(nonce, 0xFF) {
nonceEncoded := shl(16, 0x82)
nonceEncoded := add(nonceEncoded, nonce)
nonceEncodedLength := 3
}
// The nonce has 1 byte and it's in [0x80, 0xFF]
if and(gt(nonce, 0x7F), lt(nonce, 0x100)) {
nonceEncoded := shl(8, 0x81)
nonceEncoded := add(nonceEncoded, nonce)
nonceEncodedLength := 2
}
}

listLength := add(21, nonceEncodedLength)
listLengthEconded := add(listLength, 0xC0)

let arrayLength := add(168, mul(8, nonceEncodedLength))

digest := add(
shl(arrayLength, listLengthEconded),
add(
shl(
mul(8, nonceEncodedLength),
addressEncoded
),
nonceEncoded
)
)

mstore(0, shl(sub(248, arrayLength), digest))

newAddr := and(
keccak256(0, add(div(arrayLength, 8), 1)),
0xffffffffffffffffffffffffffffffffffffffff
)
}

function incrementNonce(addr) {
mstore(0, 0x306395C600000000000000000000000000000000000000000000000000000000)
mstore(4, addr)
Expand Down Expand Up @@ -784,19 +715,6 @@ function $llvm_AlwaysInline_llvm$_warmAddress(addr) -> isWarm {
isWarm := mload(0)
}

function getNonce(addr) -> nonce {
mstore(0, 0xFB1A9A5700000000000000000000000000000000000000000000000000000000)
mstore(4, addr)

let result := staticcall(gas(), NONCE_HOLDER_SYSTEM_CONTRACT(), 0, 36, 0, 32)

if iszero(result) {
revert(0, 0)
}

nonce := mload(0)
}

function getRawNonce(addr) -> nonce {
mstore(0, 0x5AA9B6B500000000000000000000000000000000000000000000000000000000)
mstore(4, addr)
Expand Down Expand Up @@ -1509,9 +1427,7 @@ function performCreate(evmGas,oldSp,isStatic) -> evmGasLeft, sp {
)
evmGasLeft := chargeGas(evmGasLeft, dynamicGas)

let addr := getNewAddress(address())

let result
let result, addr
result, evmGasLeft, addr := $llvm_NoInline_llvm$_genericCreate(offset, size, sp, value, evmGasLeft,false,0)

switch result
Expand Down Expand Up @@ -1555,18 +1471,5 @@ function performCreate2(evmGas, oldSp, isStatic) -> evmGasLeft, sp, result, addr
shr(2, add(size, 31))
))

{
let hashedBytecode := keccak256(add(MEM_OFFSET_INNER(), offset), size)
mstore(0, 0xFF00000000000000000000000000000000000000000000000000000000000000)
mstore(0x01, shl(0x60, address()))
mstore(0x15, salt)
mstore(0x35, hashedBytecode)
}

addr := and(
keccak256(0, 0x55),
0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
)

result, evmGasLeft, addr := $llvm_NoInline_llvm$_genericCreate(offset, size, sp, value, evmGasLeft,true,salt)
}
Loading

0 comments on commit 39208c7

Please sign in to comment.