-
Notifications
You must be signed in to change notification settings - Fork 355
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
[DO NOT MERGE]: EVM emulator #1142
base: release-v25-protocol-defense
Are you sure you want to change the base?
Conversation
Signed-off-by: Vladimir Radosavljevic <vr@matterlabs.dev> Co-authored-by: Vladimir Radosavljevic <vr@matterlabs.dev>
/// @dev Prefix for EVM contracts hashes storage slots. | ||
uint256 private constant EVM_HASHES_PREFIX = 1 << 254; | ||
/// @dev keccak256("ALLOWED_BYTECODE_TYPES_MODE_SLOT"). | ||
bytes32 private constant ALLOWED_BYTECODE_TYPES_MODE_SLOT = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO it is better to write to standard storage layout. Deprecation of variables isn't a concern. Bth my main concern would be making it simple and transparent with upgrades (all deprecated variables should be stored in the storage as a legacy, so no one ever will be confused and use the same storage slot for a different purpose)
// 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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it intended to be getCodeHash
not getRawCodeHash
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getRawCodeHash
would be better here indeed
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)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting, compiler allows this
|
||
// Setting the version of the hash | ||
hashedEVMBytecode = (hashedEVMBytecode | bytes32(uint256(EVM_BYTECODE_FLAG) << 248)); | ||
hashedEVMBytecode = hashedEVMBytecode | bytes32(_bytecode.length << 224); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should it be ?
hashedEVMBytecode = hashedEVMBytecode | bytes32(_bytecode.length << 224); | |
hashedEVMBytecode = hashedEVMBytecode | bytes32(lengthInWords << 224); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually it should be length of unpadded EVM bytecode in bytes. This will make EXTCODESIZE
implementation in Emulator a lot simpler. Right now this encoding in versioned bytecode hash (padded evm code length) actually doesn't make any sense
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WIP: #1066
5e4477e
to
9c9233e
Compare
bc802b1
to
e7aa3a9
Compare
What ❔
Why ❔
Checklist