• Joshua Gutow's avatar
    op-node: Use unmetered L1 Attributes Transaction (#3157) · 8ae39154
    Joshua Gutow authored
    * op-node: Use unmetered L1 Attributes Transaction
    
    This enables the IsSystemTransaction flag in the L1 Attributes
    deposit & updates to the latest version of geth.
    
    * specs updates
    
    * Update specs/deposits.md
    
    * feat: bedrock deposit transaction type update
    
    * bedrock: update geth dependency
    
    * fix(core-utils): bedrock deposit tx encode/decode typescript fixes
    
    * feat(packages/contracts-bedrock): update UserDepositTransaction type and encoding to handle isSystemTransaction bool
    
    * contracts-bedrock: update differential deposit tx solidity <> js fuzzing
    
    * core-utils
    
    * contracts-bedrock
    
    * contracts-bedrock: fix test
    
    * contracts-bedrock: fix differential tests
    
    * contracts-bedrock: fix broken test
    
    * contracts-bedrock: gas snapshot
    Co-authored-by: default avatarprotolambda <proto@protolambda.com>
    Co-authored-by: default avatarMark Tyneway <mark.tyneway@gmail.com>
    8ae39154
Encoding.t.sol 2.53 KB
// SPDX-License-Identifier: MIT
pragma solidity 0.8.15;

import { CommonTest } from "./CommonTest.t.sol";
import { Types } from "../libraries/Types.sol";
import { Encoding } from "../libraries/Encoding.sol";

contract Encoding_Test is CommonTest {
    function setUp() external {
        _setUp();
    }

    function test_nonceVersioning(uint240 _nonce, uint16 _version) external {
        (uint240 nonce, uint16 version) = Encoding.decodeVersionedNonce(
            Encoding.encodeVersionedNonce(_nonce, _version)
        );
        assertEq(version, _version);
        assertEq(nonce, _nonce);
    }

    function test_decodeVersionedNonce_differential(uint240 _nonce, uint16 _version) external {
        uint256 nonce = uint256(Encoding.encodeVersionedNonce(_nonce, _version));
        (uint256 decodedNonce, uint256 decodedVersion) = ffi.decodeVersionedNonce(nonce);

        assertEq(
            _version,
            uint16(decodedVersion)
        );

        assertEq(
            _nonce,
            uint240(decodedNonce)
        );
    }

    function test_encodeCrossDomainMessage_differential(
        uint240 _nonce,
        uint8 _version,
        address _sender,
        address _target,
        uint256 _value,
        uint256 _gasLimit,
        bytes memory _data
    ) external {
        uint8 version = _version % 2;
        uint256 nonce = Encoding.encodeVersionedNonce(_nonce, version);

        bytes memory encoding = Encoding.encodeCrossDomainMessage(
            nonce,
            _sender,
            _target,
            _value,
            _gasLimit,
            _data
        );

        bytes memory _encoding = ffi.encodeCrossDomainMessage(
            nonce,
            _sender,
            _target,
            _value,
            _gasLimit,
            _data
        );

        assertEq(encoding, _encoding);
    }

    function test_encodeDepositTransaction_differential(
        address _from,
        address _to,
        uint256 _mint,
        uint256 _value,
        uint64 _gas,
        bool isCreate,
        bytes memory _data,
        uint256 _logIndex
    ) external {
        Types.UserDepositTransaction memory t = Types.UserDepositTransaction(
            _from,
            _to,
            isCreate,
            _value,
            _mint,
            _gas,
            _data,
            bytes32(uint256(0)),
            _logIndex
        );

        bytes memory txn = Encoding.encodeDepositTransaction(t);
        bytes memory _txn = ffi.encodeDepositTransaction(t);

        assertEq(
            txn,
            _txn
        );
    }
}