Skip to content

Commit

Permalink
set of fixes to the dev branch
Browse files Browse the repository at this point in the history
  • Loading branch information
StanislavBreadless committed Apr 3, 2024
1 parent bcd9f1c commit d7103f8
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 14 deletions.
10 changes: 9 additions & 1 deletion system-contracts/bootloader/bootloader.yul
Original file line number Diff line number Diff line change
Expand Up @@ -1586,6 +1586,14 @@ object "Bootloader" {
checkEnoughGas(gasLeft)
let nearCallAbi := getNearCallABI(gasLeft)
let gasBeforePostOp := gas()

// It was expected that before this point various `isNotEnoughGasForPubdata` methods would ensure that the user
// has enough funds for pubdata. Now, we just subtract the leftovers from the user.
let spentOnPubdata := getErgsSpentForPubdata(
basePubdataSpent,
gasPerPubdata
)

pop(ZKSYNC_NEAR_CALL_callPostOp(
// Maximum number of gas that the postOp could spend
nearCallAbi,
Expand All @@ -1594,7 +1602,7 @@ object "Bootloader" {
success,
// Since the paymaster will be refunded with reservedGas,
// it should know about it
safeAdd(gasLeft, reservedGas, "jkl"),
saturatingSub(safeAdd(gasLeft, reservedGas, "jkl"), spentOnPubdata),
basePubdataSpent,
reservedGas,
gasPerPubdata
Expand Down
4 changes: 2 additions & 2 deletions system-contracts/contracts/Compressor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ contract Compressor is ICompressor, ISystemContract {
function publishCompressedBytecode(
bytes calldata _bytecode,
bytes calldata _rawCompressedData
) external payable onlyCallFromBootloader returns (bytes32 bytecodeHash) {
) external onlyCallFromBootloader returns (bytes32 bytecodeHash) {
unchecked {
(bytes calldata dictionary, bytes calldata encodedData) = _decodeRawBytecode(_rawCompressedData);

Expand Down Expand Up @@ -112,7 +112,7 @@ contract Compressor is ICompressor, ISystemContract {
uint256 _enumerationIndexSize,
bytes calldata _stateDiffs,
bytes calldata _compressedStateDiffs
) external payable onlyCallFrom(address(L1_MESSENGER_CONTRACT)) returns (bytes32 stateDiffHash) {
) external onlyCallFrom(address(L1_MESSENGER_CONTRACT)) returns (bytes32 stateDiffHash) {
// We do not enforce the operator to use the optimal, i.e. the minimally possible _enumerationIndexSize.
// We do enforce however, that the _enumerationIndexSize is not larger than 8 bytes long, which is the
// maximal ever possible size for enumeration index.
Expand Down
4 changes: 2 additions & 2 deletions system-contracts/contracts/L2BaseToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ contract L2BaseToken is IBaseToken, ISystemContract {
emit Mint(_account, _amount);
}

/// @notice Initiate the ETH withdrawal, funds will be available to claim on L1 `finalizeEthWithdrawal` method.
/// @notice Initiate the withdrawal of the base token, funds will be available to claim on L1 `finalizeEthWithdrawal` method.
/// @param _l1Receiver The address on L1 to receive the funds.
function withdraw(address _l1Receiver) external payable override {
uint256 amount = _burnMsgValue();
Expand All @@ -79,7 +79,7 @@ contract L2BaseToken is IBaseToken, ISystemContract {
emit Withdrawal(msg.sender, _l1Receiver, amount);
}

/// @notice Initiate the ETH withdrawal, with the sent message. The funds will be available to claim on L1 `finalizeEthWithdrawal` method.
/// @notice Initiate the withdrawal of the base token, with the sent message. The funds will be available to claim on L1 `finalizeEthWithdrawal` method.
/// @param _l1Receiver The address on L1 to receive the funds.
/// @param _additionalData Additional data to be sent to L1 with the withdrawal.
function withdrawWithMessage(address _l1Receiver, bytes memory _additionalData) external payable override {
Expand Down
4 changes: 2 additions & 2 deletions system-contracts/contracts/interfaces/ICompressor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ interface ICompressor {
function publishCompressedBytecode(
bytes calldata _bytecode,
bytes calldata _rawCompressedData
) external payable returns (bytes32 bytecodeHash);
) external returns (bytes32 bytecodeHash);

function verifyCompressedStateDiffs(
uint256 _numberOfStateDiffs,
uint256 _enumerationIndexSize,
bytes calldata _stateDiffs,
bytes calldata _compressedStateDiffs
) external payable returns (bytes32 stateDiffHash);
) external returns (bytes32 stateDiffHash);
}
6 changes: 3 additions & 3 deletions system-contracts/contracts/libraries/SystemContractHelper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pragma solidity 0.8.20;

import {MAX_SYSTEM_CONTRACT_ADDRESS} from "../Constants.sol";

import {CALLFLAGS_CALL_ADDRESS, CODE_ADDRESS_CALL_ADDRESS, EVENT_WRITE_ADDRESS, EVENT_INITIALIZE_ADDRESS, GET_EXTRA_ABI_DATA_ADDRESS, LOAD_CALLDATA_INTO_ACTIVE_PTR_CALL_ADDRESS, META_CODE_SHARD_ID_OFFSET, META_CALLER_SHARD_ID_OFFSET, META_SHARD_ID_OFFSET, META_AUX_HEAP_SIZE_OFFSET, META_HEAP_SIZE_OFFSET, META_GAS_PER_PUBDATA_BYTE_OFFSET, META_CALL_ADDRESS, PTR_CALLDATA_CALL_ADDRESS, PTR_ADD_INTO_ACTIVE_CALL_ADDRESS, PTR_SHRINK_INTO_ACTIVE_CALL_ADDRESS, PTR_PACK_INTO_ACTIVE_CALL_ADDRESS, PRECOMPILE_CALL_ADDRESS, SET_CONTEXT_VALUE_CALL_ADDRESS, TO_L1_CALL_ADDRESS} from "./SystemContractsCaller.sol";
import {CALLFLAGS_CALL_ADDRESS, CODE_ADDRESS_CALL_ADDRESS, EVENT_WRITE_ADDRESS, EVENT_INITIALIZE_ADDRESS, GET_EXTRA_ABI_DATA_ADDRESS, LOAD_CALLDATA_INTO_ACTIVE_PTR_CALL_ADDRESS, META_CODE_SHARD_ID_OFFSET, META_CALLER_SHARD_ID_OFFSET, META_SHARD_ID_OFFSET, META_AUX_HEAP_SIZE_OFFSET, META_HEAP_SIZE_OFFSET, META_PUBDATA_PUBLISHED_OFFSET, META_CALL_ADDRESS, PTR_CALLDATA_CALL_ADDRESS, PTR_ADD_INTO_ACTIVE_CALL_ADDRESS, PTR_SHRINK_INTO_ACTIVE_CALL_ADDRESS, PTR_PACK_INTO_ACTIVE_CALL_ADDRESS, PRECOMPILE_CALL_ADDRESS, SET_CONTEXT_VALUE_CALL_ADDRESS, TO_L1_CALL_ADDRESS} from "./SystemContractsCaller.sol";

uint256 constant UINT32_MASK = type(uint32).max;
uint256 constant UINT64_MASK = type(uint64).max;
Expand Down Expand Up @@ -224,9 +224,9 @@ library SystemContractHelper {
/// that a single byte sent to L1 as pubdata costs.
/// @notice NOTE: The behavior of this function will experience a breaking change in 2024.
/// @param meta Packed representation of the ZkSyncMeta.
/// @return pubdataPublished The current price in gas per pubdata byte.
/// @return pubdataPublished The amount of pubdata published in the system so far.
function getPubdataPublishedFromMeta(uint256 meta) internal pure returns (uint32 pubdataPublished) {
pubdataPublished = uint32(extractNumberFromMeta(meta, META_GAS_PER_PUBDATA_BYTE_OFFSET, 32));
pubdataPublished = uint32(extractNumberFromMeta(meta, META_PUBDATA_PUBLISHED_OFFSET, 32));
}

/// @notice Given the packed representation of `ZkSyncMeta`, retrieves the number of the current size
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ address constant MULTIPLICATION_HIGH_ADDRESS = address((1 << 16) - 26);
address constant GET_EXTRA_ABI_DATA_ADDRESS = address((1 << 16) - 27);

// All the offsets are in bits
uint256 constant META_GAS_PER_PUBDATA_BYTE_OFFSET = 0 * 8;
uint256 constant META_PUBDATA_PUBLISHED_OFFSET = 0 * 8;
uint256 constant META_HEAP_SIZE_OFFSET = 8 * 8;
uint256 constant META_AUX_HEAP_SIZE_OFFSET = 12 * 8;
uint256 constant META_SHARD_ID_OFFSET = 28 * 8;
Expand Down
6 changes: 3 additions & 3 deletions system-contracts/contracts/precompiles/P256Verify.yul
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ object "P256Verify" {
0, // input offset in words
5, // input length in words (the signed digest, r, s, x, y)
0, // output offset in words
1, // output length in words (success)
2, // output length in words (internalSuccess, isValid)
0 // No special meaning, secp256r1 circuit doesn't check this value
)
let gasToPay := P256_VERIFY_GAS_COST()
Expand All @@ -89,8 +89,8 @@ object "P256Verify" {
default {
// The circuits might write `0` to the memory, while providing `internalSuccess` as `1`, so
// we double check here.
let writtenValue := mload(32)
if eq(writtenValue, 0) {
let isValid := mload(32)
if eq(isValid, 0) {
return(0, 0)
}

Expand Down

0 comments on commit d7103f8

Please sign in to comment.