diff --git a/package.json b/package.json index e958d3dd0..491ea79d6 100644 --- a/package.json +++ b/package.json @@ -19,8 +19,8 @@ "test:l2": "hardhat test test/*.l2.ts", "test:unit": "forge test", "test:e2e:local-env": "yarn hardhat test test-e2e/*", - "test:storage": "./scripts/storage_layout_test.bash", - "test:signatures": "./scripts/signatures_test.bash", + "test:storage": "./test/storage/test-storage.bash", + "test:signatures": "./test/signatures/test-sigs.bash", "test:mutation": "ts-node test-mutation/gambitTester.ts", "test:unused:errors": "./test/unused-errors/find_unused_errors.sh", "deploy:local:token-bridge": "ts-node ./scripts/local-deployment/deployCreatorAndCreateTokenBridge.ts", diff --git a/scripts/signatures_test.bash b/scripts/signatures_test.bash deleted file mode 100755 index b4e0fb163..000000000 --- a/scripts/signatures_test.bash +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash -output_dir="./test/signatures" -for CONTRACTNAME in L1ERC20Gateway L1CustomGateway L1ReverseCustomGateway L1WethGateway L2ERC20Gateway L2CustomGateway L2ReverseCustomGateway L2WethGateway L1GatewayRouter L2GatewayRouter StandardArbERC20 L1AtomicTokenBridgeCreator L1TokenBridgeRetryableSender L2AtomicTokenBridgeFactory L1OrbitCustomGateway L1OrbitERC20Gateway L1OrbitGatewayRouter L1OrbitReverseCustomGateway L1USDCGateway L1OrbitUSDCGateway L2USDCGateway -do - echo "Checking for signature changes in $CONTRACTNAME" - [ -f "$output_dir/$CONTRACTNAME" ] && mv "$output_dir/$CONTRACTNAME" "$output_dir/$CONTRACTNAME-old" - forge inspect "$CONTRACTNAME" methods > "$output_dir/$CONTRACTNAME" - diff "$output_dir/$CONTRACTNAME-old" "$output_dir/$CONTRACTNAME" - if [[ $? != "0" ]] - then - CHANGED=1 - fi -done -if [[ $CHANGED == 1 ]] -then - exit 1 -fi \ No newline at end of file diff --git a/scripts/storage_layout_test.bash b/scripts/storage_layout_test.bash deleted file mode 100755 index 73576ebc7..000000000 --- a/scripts/storage_layout_test.bash +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash -output_dir="./test/storage" -for CONTRACTNAME in L1ERC20Gateway L1CustomGateway L1ReverseCustomGateway L1WethGateway L2ERC20Gateway L2CustomGateway L2ReverseCustomGateway L2WethGateway L1GatewayRouter L2GatewayRouter StandardArbERC20 L1AtomicTokenBridgeCreator L1TokenBridgeRetryableSender L2AtomicTokenBridgeFactory L1OrbitCustomGateway L1OrbitERC20Gateway L1OrbitGatewayRouter L1OrbitReverseCustomGateway L1USDCGateway L1OrbitUSDCGateway L2USDCGateway -do - echo "Checking storage change of $CONTRACTNAME" - [ -f "$output_dir/$CONTRACTNAME" ] && mv "$output_dir/$CONTRACTNAME" "$output_dir/$CONTRACTNAME-old" - forge inspect "$CONTRACTNAME" storage > "$output_dir/$CONTRACTNAME" - diff "$output_dir/$CONTRACTNAME-old" "$output_dir/$CONTRACTNAME" - if [[ $? != "0" ]] - then - CHANGED=1 - fi -done -if [[ $CHANGED == 1 ]] -then - exit 1 -fi \ No newline at end of file diff --git a/scripts/template/print-contracts.bash b/scripts/template/print-contracts.bash new file mode 100755 index 000000000..7ad167dec --- /dev/null +++ b/scripts/template/print-contracts.bash @@ -0,0 +1,43 @@ +#!/bin/bash + +# search for all contracts defined in the contracts directory and print them + +# need to build with this flag to get AST output +# could keep an eye on this issue to optimize this: https://github.com/foundry-rs/foundry/issues/7212 +forge build --build-info > /dev/null + +if [ $? -ne 0 ]; then + echo "Build failed" + exit 1 +fi + +OUTPUT_PATH="out/" +SOURCE_PATH="contracts/" + +# find all json files in the out directory +FILES=$(find $OUTPUT_PATH -name "*.json") + +# Initialize an empty array to collect all contract names +declare -a all_contract_names=() + +# for each file, print the absolutePath +for file in $FILES; do + sol_path=$(cat "$file" | jq '.ast.absolutePath' -r) + + # make sure the path is in the source path and exclude test directory + if [[ $sol_path == $SOURCE_PATH* ]] && [[ $sol_path != *"contracts/tokenbridge/test/"* ]]; then + # Read contract names into an array and append them to the all_contract_names array + while IFS= read -r name; do + all_contract_names+=("$name") + done < <(cat $file | jq '.ast.nodes[] | select(.nodeType == "ContractDefinition" and .contractKind == "contract" and .abstract == false).name' -r) + fi +done + +# if we have no contracts, exit with an error +if [ ${#all_contract_names[@]} -eq 0 ]; then + echo "No contracts found" + exit 1 +fi + +# Print unique contract names, removing duplicates +printf "%s\n" "${all_contract_names[@]}" | sort | uniq diff --git a/test/signatures/ArbMulticall2 b/test/signatures/ArbMulticall2 new file mode 100644 index 000000000..cd495bf85 --- /dev/null +++ b/test/signatures/ArbMulticall2 @@ -0,0 +1,33 @@ + +╭-----------------------------------------------+------------╮ +| Method | Identifier | ++============================================================+ +| aggregate((address,bytes)[]) | 252dba42 | +|-----------------------------------------------+------------| +| blockAndAggregate((address,bytes)[]) | c3077fa9 | +|-----------------------------------------------+------------| +| getBlockHash(uint256) | ee82ac5e | +|-----------------------------------------------+------------| +| getBlockNumber() | 42cbb15c | +|-----------------------------------------------+------------| +| getCurrentBlockCoinbase() | a8b0574e | +|-----------------------------------------------+------------| +| getCurrentBlockDifficulty() | 72425d9d | +|-----------------------------------------------+------------| +| getCurrentBlockGasLimit() | 86d516e8 | +|-----------------------------------------------+------------| +| getCurrentBlockTimestamp() | 0f28c97d | +|-----------------------------------------------+------------| +| getEthBalance(address) | 4d2301cc | +|-----------------------------------------------+------------| +| getL1BlockNumber() | b9b3efe9 | +|-----------------------------------------------+------------| +| getLastBlockHash() | 27e86d6e | +|-----------------------------------------------+------------| +| tryAggregate(bool,(address,bytes)[]) | bce38bd7 | +|-----------------------------------------------+------------| +| tryAggregateGasRation(bool,(address,bytes)[]) | 2935cd90 | +|-----------------------------------------------+------------| +| tryBlockAndAggregate(bool,(address,bytes)[]) | 399542e9 | +╰-----------------------------------------------+------------╯ + diff --git a/test/signatures/BeaconProxyFactory b/test/signatures/BeaconProxyFactory new file mode 100644 index 000000000..d098c15ba --- /dev/null +++ b/test/signatures/BeaconProxyFactory @@ -0,0 +1,19 @@ + +╭-------------------------------------------+------------╮ +| Method | Identifier | ++========================================================+ +| beacon() | 59659e90 | +|-------------------------------------------+------------| +| calculateExpectedAddress(address,bytes32) | e75b2141 | +|-------------------------------------------+------------| +| calculateExpectedAddress(bytes32) | 396a5f95 | +|-------------------------------------------+------------| +| cloneableProxyHash() | 97881f8d | +|-------------------------------------------+------------| +| createProxy(bytes32) | 29a5c5cf | +|-------------------------------------------+------------| +| getSalt(address,bytes32) | b3e3bf42 | +|-------------------------------------------+------------| +| initialize(address) | c4d66de8 | +╰-------------------------------------------+------------╯ + diff --git a/test/signatures/ClonableBeaconProxy b/test/signatures/ClonableBeaconProxy new file mode 100644 index 000000000..b98cabea1 --- /dev/null +++ b/test/signatures/ClonableBeaconProxy @@ -0,0 +1,6 @@ + +╭--------+------------╮ +| Method | Identifier | ++=====================+ +╰--------+------------╯ + diff --git a/test/signatures/Cloneable b/test/signatures/Cloneable new file mode 100644 index 000000000..308850787 --- /dev/null +++ b/test/signatures/Cloneable @@ -0,0 +1,7 @@ + +╭------------+------------╮ +| Method | Identifier | ++=========================+ +| isMaster() | 6f791d29 | +╰------------+------------╯ + diff --git a/test/signatures/ERC20Upgradeable b/test/signatures/ERC20Upgradeable new file mode 100644 index 000000000..68fc3494b --- /dev/null +++ b/test/signatures/ERC20Upgradeable @@ -0,0 +1,27 @@ + +╭---------------------------------------+------------╮ +| Method | Identifier | ++====================================================+ +| allowance(address,address) | dd62ed3e | +|---------------------------------------+------------| +| approve(address,uint256) | 095ea7b3 | +|---------------------------------------+------------| +| balanceOf(address) | 70a08231 | +|---------------------------------------+------------| +| decimals() | 313ce567 | +|---------------------------------------+------------| +| decreaseAllowance(address,uint256) | a457c2d7 | +|---------------------------------------+------------| +| increaseAllowance(address,uint256) | 39509351 | +|---------------------------------------+------------| +| name() | 06fdde03 | +|---------------------------------------+------------| +| symbol() | 95d89b41 | +|---------------------------------------+------------| +| totalSupply() | 18160ddd | +|---------------------------------------+------------| +| transfer(address,uint256) | a9059cbb | +|---------------------------------------+------------| +| transferFrom(address,address,uint256) | 23b872dd | +╰---------------------------------------+------------╯ + diff --git a/test/signatures/L1ForceOnlyReverseCustomGateway b/test/signatures/L1ForceOnlyReverseCustomGateway new file mode 100644 index 000000000..5859efb5b --- /dev/null +++ b/test/signatures/L1ForceOnlyReverseCustomGateway @@ -0,0 +1,49 @@ + +╭-------------------------------------------------------------------------------------+------------╮ +| Method | Identifier | ++==================================================================================================+ +| calculateL2TokenAddress(address) | a7e28d48 | +|-------------------------------------------------------------------------------------+------------| +| counterpartGateway() | 2db09c1c | +|-------------------------------------------------------------------------------------+------------| +| encodeWithdrawal(uint256,address) | 020a6058 | +|-------------------------------------------------------------------------------------+------------| +| finalizeInboundTransfer(address,address,address,uint256,bytes) | 2e567b36 | +|-------------------------------------------------------------------------------------+------------| +| forceRegisterTokenToL2(address[],address[],uint256,uint256,uint256) | 1d3a689f | +|-------------------------------------------------------------------------------------+------------| +| getExternalCall(uint256,address,bytes) | f68a9082 | +|-------------------------------------------------------------------------------------+------------| +| getOutboundCalldata(address,address,address,uint256,bytes) | a0c76a96 | +|-------------------------------------------------------------------------------------+------------| +| inbox() | fb0e722b | +|-------------------------------------------------------------------------------------+------------| +| initialize(address,address,address,address) | f8c8765e | +|-------------------------------------------------------------------------------------+------------| +| l1ToL2Token(address) | 8a2dc014 | +|-------------------------------------------------------------------------------------+------------| +| outboundTransfer(address,address,uint256,uint256,uint256,bytes) | d2ce7d65 | +|-------------------------------------------------------------------------------------+------------| +| outboundTransferCustomRefund(address,address,address,uint256,uint256,uint256,bytes) | 4fb1a07b | +|-------------------------------------------------------------------------------------+------------| +| owner() | 8da5cb5b | +|-------------------------------------------------------------------------------------+------------| +| postUpgradeInit() | 95fcea78 | +|-------------------------------------------------------------------------------------+------------| +| redirectedExits(bytes32) | bcf2e6eb | +|-------------------------------------------------------------------------------------+------------| +| registerTokenToL2(address,uint256,uint256,uint256) | f26bdead | +|-------------------------------------------------------------------------------------+------------| +| registerTokenToL2(address,uint256,uint256,uint256,address) | ca346d4a | +|-------------------------------------------------------------------------------------+------------| +| router() | f887ea40 | +|-------------------------------------------------------------------------------------+------------| +| setOwner(address) | 13af4035 | +|-------------------------------------------------------------------------------------+------------| +| supportsInterface(bytes4) | 01ffc9a7 | +|-------------------------------------------------------------------------------------+------------| +| transferExitAndCall(uint256,address,address,bytes,bytes) | bd5f3e7d | +|-------------------------------------------------------------------------------------+------------| +| whitelist() | 93e59dc1 | +╰-------------------------------------------------------------------------------------+------------╯ + diff --git a/test/signatures/L2CustomGatewayToken b/test/signatures/L2CustomGatewayToken new file mode 100644 index 000000000..7e8cae5fd --- /dev/null +++ b/test/signatures/L2CustomGatewayToken @@ -0,0 +1,45 @@ + +╭---------------------------------------------------------------+------------╮ +| Method | Identifier | ++============================================================================+ +| DOMAIN_SEPARATOR() | 3644e515 | +|---------------------------------------------------------------+------------| +| allowance(address,address) | dd62ed3e | +|---------------------------------------------------------------+------------| +| approve(address,uint256) | 095ea7b3 | +|---------------------------------------------------------------+------------| +| balanceOf(address) | 70a08231 | +|---------------------------------------------------------------+------------| +| bridgeBurn(address,uint256) | 74f4f547 | +|---------------------------------------------------------------+------------| +| bridgeMint(address,uint256) | 8c2a993e | +|---------------------------------------------------------------+------------| +| decimals() | 313ce567 | +|---------------------------------------------------------------+------------| +| decreaseAllowance(address,uint256) | a457c2d7 | +|---------------------------------------------------------------+------------| +| increaseAllowance(address,uint256) | 39509351 | +|---------------------------------------------------------------+------------| +| initialize(string,string,uint8,address,address) | c820f146 | +|---------------------------------------------------------------+------------| +| l1Address() | c2eeeebd | +|---------------------------------------------------------------+------------| +| l2Gateway() | 8fa74a0e | +|---------------------------------------------------------------+------------| +| name() | 06fdde03 | +|---------------------------------------------------------------+------------| +| nonces(address) | 7ecebe00 | +|---------------------------------------------------------------+------------| +| permit(address,address,uint256,uint256,uint8,bytes32,bytes32) | d505accf | +|---------------------------------------------------------------+------------| +| symbol() | 95d89b41 | +|---------------------------------------------------------------+------------| +| totalSupply() | 18160ddd | +|---------------------------------------------------------------+------------| +| transfer(address,uint256) | a9059cbb | +|---------------------------------------------------------------+------------| +| transferAndCall(address,uint256,bytes) | 4000aea0 | +|---------------------------------------------------------------+------------| +| transferFrom(address,address,uint256) | 23b872dd | +╰---------------------------------------------------------------+------------╯ + diff --git a/test/signatures/Multicall2 b/test/signatures/Multicall2 new file mode 100644 index 000000000..197f4396c --- /dev/null +++ b/test/signatures/Multicall2 @@ -0,0 +1,31 @@ + +╭-----------------------------------------------+------------╮ +| Method | Identifier | ++============================================================+ +| aggregate((address,bytes)[]) | 252dba42 | +|-----------------------------------------------+------------| +| blockAndAggregate((address,bytes)[]) | c3077fa9 | +|-----------------------------------------------+------------| +| getBlockHash(uint256) | ee82ac5e | +|-----------------------------------------------+------------| +| getBlockNumber() | 42cbb15c | +|-----------------------------------------------+------------| +| getCurrentBlockCoinbase() | a8b0574e | +|-----------------------------------------------+------------| +| getCurrentBlockDifficulty() | 72425d9d | +|-----------------------------------------------+------------| +| getCurrentBlockGasLimit() | 86d516e8 | +|-----------------------------------------------+------------| +| getCurrentBlockTimestamp() | 0f28c97d | +|-----------------------------------------------+------------| +| getEthBalance(address) | 4d2301cc | +|-----------------------------------------------+------------| +| getLastBlockHash() | 27e86d6e | +|-----------------------------------------------+------------| +| tryAggregate(bool,(address,bytes)[]) | bce38bd7 | +|-----------------------------------------------+------------| +| tryAggregateGasRation(bool,(address,bytes)[]) | 2935cd90 | +|-----------------------------------------------+------------| +| tryBlockAndAggregate(bool,(address,bytes)[]) | 399542e9 | +╰-----------------------------------------------+------------╯ + diff --git a/test/signatures/Whitelist b/test/signatures/Whitelist new file mode 100644 index 000000000..1335ed2d1 --- /dev/null +++ b/test/signatures/Whitelist @@ -0,0 +1,15 @@ + +╭-------------------------------------+------------╮ +| Method | Identifier | ++==================================================+ +| isAllowed(address) | babcc539 | +|-------------------------------------+------------| +| owner() | 8da5cb5b | +|-------------------------------------+------------| +| setOwner(address) | 13af4035 | +|-------------------------------------+------------| +| setWhitelist(address[],bool[]) | 3b99adf7 | +|-------------------------------------+------------| +| triggerConsumers(address,address[]) | 37ca2617 | +╰-------------------------------------+------------╯ + diff --git a/test/signatures/aeERC20 b/test/signatures/aeERC20 new file mode 100644 index 000000000..c0e4769a4 --- /dev/null +++ b/test/signatures/aeERC20 @@ -0,0 +1,35 @@ + +╭---------------------------------------------------------------+------------╮ +| Method | Identifier | ++============================================================================+ +| DOMAIN_SEPARATOR() | 3644e515 | +|---------------------------------------------------------------+------------| +| allowance(address,address) | dd62ed3e | +|---------------------------------------------------------------+------------| +| approve(address,uint256) | 095ea7b3 | +|---------------------------------------------------------------+------------| +| balanceOf(address) | 70a08231 | +|---------------------------------------------------------------+------------| +| decimals() | 313ce567 | +|---------------------------------------------------------------+------------| +| decreaseAllowance(address,uint256) | a457c2d7 | +|---------------------------------------------------------------+------------| +| increaseAllowance(address,uint256) | 39509351 | +|---------------------------------------------------------------+------------| +| name() | 06fdde03 | +|---------------------------------------------------------------+------------| +| nonces(address) | 7ecebe00 | +|---------------------------------------------------------------+------------| +| permit(address,address,uint256,uint256,uint8,bytes32,bytes32) | d505accf | +|---------------------------------------------------------------+------------| +| symbol() | 95d89b41 | +|---------------------------------------------------------------+------------| +| totalSupply() | 18160ddd | +|---------------------------------------------------------------+------------| +| transfer(address,uint256) | a9059cbb | +|---------------------------------------------------------------+------------| +| transferAndCall(address,uint256,bytes) | 4000aea0 | +|---------------------------------------------------------------+------------| +| transferFrom(address,address,uint256) | 23b872dd | +╰---------------------------------------------------------------+------------╯ + diff --git a/test/signatures/aeWETH b/test/signatures/aeWETH new file mode 100644 index 000000000..dbb917143 --- /dev/null +++ b/test/signatures/aeWETH @@ -0,0 +1,53 @@ + +╭---------------------------------------------------------------+------------╮ +| Method | Identifier | ++============================================================================+ +| DOMAIN_SEPARATOR() | 3644e515 | +|---------------------------------------------------------------+------------| +| allowance(address,address) | dd62ed3e | +|---------------------------------------------------------------+------------| +| approve(address,uint256) | 095ea7b3 | +|---------------------------------------------------------------+------------| +| balanceOf(address) | 70a08231 | +|---------------------------------------------------------------+------------| +| bridgeBurn(address,uint256) | 74f4f547 | +|---------------------------------------------------------------+------------| +| bridgeMint(address,uint256) | 8c2a993e | +|---------------------------------------------------------------+------------| +| decimals() | 313ce567 | +|---------------------------------------------------------------+------------| +| decreaseAllowance(address,uint256) | a457c2d7 | +|---------------------------------------------------------------+------------| +| deposit() | d0e30db0 | +|---------------------------------------------------------------+------------| +| depositTo(address) | b760faf9 | +|---------------------------------------------------------------+------------| +| increaseAllowance(address,uint256) | 39509351 | +|---------------------------------------------------------------+------------| +| initialize(string,string,uint8,address,address) | c820f146 | +|---------------------------------------------------------------+------------| +| l1Address() | c2eeeebd | +|---------------------------------------------------------------+------------| +| l2Gateway() | 8fa74a0e | +|---------------------------------------------------------------+------------| +| name() | 06fdde03 | +|---------------------------------------------------------------+------------| +| nonces(address) | 7ecebe00 | +|---------------------------------------------------------------+------------| +| permit(address,address,uint256,uint256,uint8,bytes32,bytes32) | d505accf | +|---------------------------------------------------------------+------------| +| symbol() | 95d89b41 | +|---------------------------------------------------------------+------------| +| totalSupply() | 18160ddd | +|---------------------------------------------------------------+------------| +| transfer(address,uint256) | a9059cbb | +|---------------------------------------------------------------+------------| +| transferAndCall(address,uint256,bytes) | 4000aea0 | +|---------------------------------------------------------------+------------| +| transferFrom(address,address,uint256) | 23b872dd | +|---------------------------------------------------------------+------------| +| withdraw(uint256) | 2e1a7d4d | +|---------------------------------------------------------------+------------| +| withdrawTo(address,uint256) | 205c2878 | +╰---------------------------------------------------------------+------------╯ + diff --git a/test/signatures/test-sigs.bash b/test/signatures/test-sigs.bash new file mode 100755 index 000000000..316789aff --- /dev/null +++ b/test/signatures/test-sigs.bash @@ -0,0 +1,3 @@ +#!/bin/bash + +./test/util/forge-inspect.bash ./test/signatures methods \ No newline at end of file diff --git a/test/storage/ArbMulticall2 b/test/storage/ArbMulticall2 new file mode 100644 index 000000000..1ec5dc079 --- /dev/null +++ b/test/storage/ArbMulticall2 @@ -0,0 +1,6 @@ + +╭------+------+------+--------+-------+----------╮ +| Name | Type | Slot | Offset | Bytes | Contract | ++================================================+ +╰------+------+------+--------+-------+----------╯ + diff --git a/test/storage/BeaconProxyFactory b/test/storage/BeaconProxyFactory new file mode 100644 index 000000000..0d8059680 --- /dev/null +++ b/test/storage/BeaconProxyFactory @@ -0,0 +1,7 @@ + +╭--------+---------+------+--------+-------+----------------------------------------------------------------------------╮ +| Name | Type | Slot | Offset | Bytes | Contract | ++=======================================================================================================================+ +| beacon | address | 0 | 0 | 20 | contracts/tokenbridge/libraries/ClonableBeaconProxy.sol:BeaconProxyFactory | +╰--------+---------+------+--------+-------+----------------------------------------------------------------------------╯ + diff --git a/test/storage/ClonableBeaconProxy b/test/storage/ClonableBeaconProxy new file mode 100644 index 000000000..1ec5dc079 --- /dev/null +++ b/test/storage/ClonableBeaconProxy @@ -0,0 +1,6 @@ + +╭------+------+------+--------+-------+----------╮ +| Name | Type | Slot | Offset | Bytes | Contract | ++================================================+ +╰------+------+------+--------+-------+----------╯ + diff --git a/test/storage/Cloneable b/test/storage/Cloneable new file mode 100644 index 000000000..20e83b88d --- /dev/null +++ b/test/storage/Cloneable @@ -0,0 +1,7 @@ + +╭--------------+------+------+--------+-------+---------------------------------------------------------╮ +| Name | Type | Slot | Offset | Bytes | Contract | ++=======================================================================================================+ +| isMasterCopy | bool | 0 | 0 | 1 | contracts/tokenbridge/libraries/Cloneable.sol:Cloneable | +╰--------------+------+------+--------+-------+---------------------------------------------------------╯ + diff --git a/test/storage/ERC20Upgradeable b/test/storage/ERC20Upgradeable new file mode 100644 index 000000000..7d9706578 --- /dev/null +++ b/test/storage/ERC20Upgradeable @@ -0,0 +1,25 @@ + +╭---------------+-------------------------------------------------+------+--------+-------+-----------------------------------------------------------------------╮ +| Name | Type | Slot | Offset | Bytes | Contract | ++=================================================================================================================================================================+ +| _initialized | uint8 | 0 | 0 | 1 | contracts/tokenbridge/libraries/ERC20Upgradeable.sol:ERC20Upgradeable | +|---------------+-------------------------------------------------+------+--------+-------+-----------------------------------------------------------------------| +| _initializing | bool | 0 | 1 | 1 | contracts/tokenbridge/libraries/ERC20Upgradeable.sol:ERC20Upgradeable | +|---------------+-------------------------------------------------+------+--------+-------+-----------------------------------------------------------------------| +| __gap | uint256[50] | 1 | 0 | 1600 | contracts/tokenbridge/libraries/ERC20Upgradeable.sol:ERC20Upgradeable | +|---------------+-------------------------------------------------+------+--------+-------+-----------------------------------------------------------------------| +| _balances | mapping(address => uint256) | 51 | 0 | 32 | contracts/tokenbridge/libraries/ERC20Upgradeable.sol:ERC20Upgradeable | +|---------------+-------------------------------------------------+------+--------+-------+-----------------------------------------------------------------------| +| _allowances | mapping(address => mapping(address => uint256)) | 52 | 0 | 32 | contracts/tokenbridge/libraries/ERC20Upgradeable.sol:ERC20Upgradeable | +|---------------+-------------------------------------------------+------+--------+-------+-----------------------------------------------------------------------| +| _totalSupply | uint256 | 53 | 0 | 32 | contracts/tokenbridge/libraries/ERC20Upgradeable.sol:ERC20Upgradeable | +|---------------+-------------------------------------------------+------+--------+-------+-----------------------------------------------------------------------| +| _name | string | 54 | 0 | 32 | contracts/tokenbridge/libraries/ERC20Upgradeable.sol:ERC20Upgradeable | +|---------------+-------------------------------------------------+------+--------+-------+-----------------------------------------------------------------------| +| _symbol | string | 55 | 0 | 32 | contracts/tokenbridge/libraries/ERC20Upgradeable.sol:ERC20Upgradeable | +|---------------+-------------------------------------------------+------+--------+-------+-----------------------------------------------------------------------| +| _decimals | uint8 | 56 | 0 | 1 | contracts/tokenbridge/libraries/ERC20Upgradeable.sol:ERC20Upgradeable | +|---------------+-------------------------------------------------+------+--------+-------+-----------------------------------------------------------------------| +| __gap | uint256[44] | 57 | 0 | 1408 | contracts/tokenbridge/libraries/ERC20Upgradeable.sol:ERC20Upgradeable | +╰---------------+-------------------------------------------------+------+--------+-------+-----------------------------------------------------------------------╯ + diff --git a/test/storage/L1ForceOnlyReverseCustomGateway b/test/storage/L1ForceOnlyReverseCustomGateway new file mode 100644 index 000000000..823d855f4 --- /dev/null +++ b/test/storage/L1ForceOnlyReverseCustomGateway @@ -0,0 +1,21 @@ + +╭--------------------+---------------------------------------------------------------+------+--------+-------+------------------------------------------------------------------------------------------------------------╮ +| Name | Type | Slot | Offset | Bytes | Contract | ++=========================================================================================================================================================================================================================+ +| counterpartGateway | address | 0 | 0 | 20 | contracts/tokenbridge/ethereum/gateway/L1ForceOnlyReverseCustomGateway.sol:L1ForceOnlyReverseCustomGateway | +|--------------------+---------------------------------------------------------------+------+--------+-------+------------------------------------------------------------------------------------------------------------| +| router | address | 1 | 0 | 20 | contracts/tokenbridge/ethereum/gateway/L1ForceOnlyReverseCustomGateway.sol:L1ForceOnlyReverseCustomGateway | +|--------------------+---------------------------------------------------------------+------+--------+-------+------------------------------------------------------------------------------------------------------------| +| inbox | address | 2 | 0 | 20 | contracts/tokenbridge/ethereum/gateway/L1ForceOnlyReverseCustomGateway.sol:L1ForceOnlyReverseCustomGateway | +|--------------------+---------------------------------------------------------------+------+--------+-------+------------------------------------------------------------------------------------------------------------| +| redirectedExits | mapping(bytes32 => struct L1ArbitrumExtendedGateway.ExitData) | 3 | 0 | 32 | contracts/tokenbridge/ethereum/gateway/L1ForceOnlyReverseCustomGateway.sol:L1ForceOnlyReverseCustomGateway | +|--------------------+---------------------------------------------------------------+------+--------+-------+------------------------------------------------------------------------------------------------------------| +| l1ToL2Token | mapping(address => address) | 4 | 0 | 32 | contracts/tokenbridge/ethereum/gateway/L1ForceOnlyReverseCustomGateway.sol:L1ForceOnlyReverseCustomGateway | +|--------------------+---------------------------------------------------------------+------+--------+-------+------------------------------------------------------------------------------------------------------------| +| owner | address | 5 | 0 | 20 | contracts/tokenbridge/ethereum/gateway/L1ForceOnlyReverseCustomGateway.sol:L1ForceOnlyReverseCustomGateway | +|--------------------+---------------------------------------------------------------+------+--------+-------+------------------------------------------------------------------------------------------------------------| +| whitelist | address | 6 | 0 | 20 | contracts/tokenbridge/ethereum/gateway/L1ForceOnlyReverseCustomGateway.sol:L1ForceOnlyReverseCustomGateway | +|--------------------+---------------------------------------------------------------+------+--------+-------+------------------------------------------------------------------------------------------------------------| +| _status | uint256 | 7 | 0 | 32 | contracts/tokenbridge/ethereum/gateway/L1ForceOnlyReverseCustomGateway.sol:L1ForceOnlyReverseCustomGateway | +╰--------------------+---------------------------------------------------------------+------+--------+-------+------------------------------------------------------------------------------------------------------------╯ + diff --git a/test/storage/L2CustomGatewayToken b/test/storage/L2CustomGatewayToken new file mode 100644 index 000000000..d2b0894d5 --- /dev/null +++ b/test/storage/L2CustomGatewayToken @@ -0,0 +1,41 @@ + +╭----------------------------------+--------------------------------------------------------+------+--------+-------+-------------------------------------------------------------------------------╮ +| Name | Type | Slot | Offset | Bytes | Contract | ++===================================================================================================================================================================================================+ +| _initialized | uint8 | 0 | 0 | 1 | contracts/tokenbridge/libraries/L2CustomGatewayToken.sol:L2CustomGatewayToken | +|----------------------------------+--------------------------------------------------------+------+--------+-------+-------------------------------------------------------------------------------| +| _initializing | bool | 0 | 1 | 1 | contracts/tokenbridge/libraries/L2CustomGatewayToken.sol:L2CustomGatewayToken | +|----------------------------------+--------------------------------------------------------+------+--------+-------+-------------------------------------------------------------------------------| +| __gap | uint256[50] | 1 | 0 | 1600 | contracts/tokenbridge/libraries/L2CustomGatewayToken.sol:L2CustomGatewayToken | +|----------------------------------+--------------------------------------------------------+------+--------+-------+-------------------------------------------------------------------------------| +| _balances | mapping(address => uint256) | 51 | 0 | 32 | contracts/tokenbridge/libraries/L2CustomGatewayToken.sol:L2CustomGatewayToken | +|----------------------------------+--------------------------------------------------------+------+--------+-------+-------------------------------------------------------------------------------| +| _allowances | mapping(address => mapping(address => uint256)) | 52 | 0 | 32 | contracts/tokenbridge/libraries/L2CustomGatewayToken.sol:L2CustomGatewayToken | +|----------------------------------+--------------------------------------------------------+------+--------+-------+-------------------------------------------------------------------------------| +| _totalSupply | uint256 | 53 | 0 | 32 | contracts/tokenbridge/libraries/L2CustomGatewayToken.sol:L2CustomGatewayToken | +|----------------------------------+--------------------------------------------------------+------+--------+-------+-------------------------------------------------------------------------------| +| _name | string | 54 | 0 | 32 | contracts/tokenbridge/libraries/L2CustomGatewayToken.sol:L2CustomGatewayToken | +|----------------------------------+--------------------------------------------------------+------+--------+-------+-------------------------------------------------------------------------------| +| _symbol | string | 55 | 0 | 32 | contracts/tokenbridge/libraries/L2CustomGatewayToken.sol:L2CustomGatewayToken | +|----------------------------------+--------------------------------------------------------+------+--------+-------+-------------------------------------------------------------------------------| +| _decimals | uint8 | 56 | 0 | 1 | contracts/tokenbridge/libraries/L2CustomGatewayToken.sol:L2CustomGatewayToken | +|----------------------------------+--------------------------------------------------------+------+--------+-------+-------------------------------------------------------------------------------| +| __gap | uint256[44] | 57 | 0 | 1408 | contracts/tokenbridge/libraries/L2CustomGatewayToken.sol:L2CustomGatewayToken | +|----------------------------------+--------------------------------------------------------+------+--------+-------+-------------------------------------------------------------------------------| +| _HASHED_NAME | bytes32 | 101 | 0 | 32 | contracts/tokenbridge/libraries/L2CustomGatewayToken.sol:L2CustomGatewayToken | +|----------------------------------+--------------------------------------------------------+------+--------+-------+-------------------------------------------------------------------------------| +| _HASHED_VERSION | bytes32 | 102 | 0 | 32 | contracts/tokenbridge/libraries/L2CustomGatewayToken.sol:L2CustomGatewayToken | +|----------------------------------+--------------------------------------------------------+------+--------+-------+-------------------------------------------------------------------------------| +| __gap | uint256[50] | 103 | 0 | 1600 | contracts/tokenbridge/libraries/L2CustomGatewayToken.sol:L2CustomGatewayToken | +|----------------------------------+--------------------------------------------------------+------+--------+-------+-------------------------------------------------------------------------------| +| _nonces | mapping(address => struct CountersUpgradeable.Counter) | 153 | 0 | 32 | contracts/tokenbridge/libraries/L2CustomGatewayToken.sol:L2CustomGatewayToken | +|----------------------------------+--------------------------------------------------------+------+--------+-------+-------------------------------------------------------------------------------| +| _PERMIT_TYPEHASH_DEPRECATED_SLOT | bytes32 | 154 | 0 | 32 | contracts/tokenbridge/libraries/L2CustomGatewayToken.sol:L2CustomGatewayToken | +|----------------------------------+--------------------------------------------------------+------+--------+-------+-------------------------------------------------------------------------------| +| __gap | uint256[49] | 155 | 0 | 1568 | contracts/tokenbridge/libraries/L2CustomGatewayToken.sol:L2CustomGatewayToken | +|----------------------------------+--------------------------------------------------------+------+--------+-------+-------------------------------------------------------------------------------| +| l2Gateway | address | 204 | 0 | 20 | contracts/tokenbridge/libraries/L2CustomGatewayToken.sol:L2CustomGatewayToken | +|----------------------------------+--------------------------------------------------------+------+--------+-------+-------------------------------------------------------------------------------| +| l1Address | address | 205 | 0 | 20 | contracts/tokenbridge/libraries/L2CustomGatewayToken.sol:L2CustomGatewayToken | +╰----------------------------------+--------------------------------------------------------+------+--------+-------+-------------------------------------------------------------------------------╯ + diff --git a/test/storage/Multicall2 b/test/storage/Multicall2 new file mode 100644 index 000000000..1ec5dc079 --- /dev/null +++ b/test/storage/Multicall2 @@ -0,0 +1,6 @@ + +╭------+------+------+--------+-------+----------╮ +| Name | Type | Slot | Offset | Bytes | Contract | ++================================================+ +╰------+------+------+--------+-------+----------╯ + diff --git a/test/storage/Whitelist b/test/storage/Whitelist new file mode 100644 index 000000000..db5744451 --- /dev/null +++ b/test/storage/Whitelist @@ -0,0 +1,9 @@ + +╭-----------+--------------------------+------+--------+-------+---------------------------------------------------------╮ +| Name | Type | Slot | Offset | Bytes | Contract | ++========================================================================================================================+ +| owner | address | 0 | 0 | 20 | contracts/tokenbridge/libraries/Whitelist.sol:Whitelist | +|-----------+--------------------------+------+--------+-------+---------------------------------------------------------| +| isAllowed | mapping(address => bool) | 1 | 0 | 32 | contracts/tokenbridge/libraries/Whitelist.sol:Whitelist | +╰-----------+--------------------------+------+--------+-------+---------------------------------------------------------╯ + diff --git a/test/storage/aeERC20 b/test/storage/aeERC20 new file mode 100644 index 000000000..04f1de83a --- /dev/null +++ b/test/storage/aeERC20 @@ -0,0 +1,37 @@ + +╭----------------------------------+--------------------------------------------------------+------+--------+-------+-----------------------------------------------------╮ +| Name | Type | Slot | Offset | Bytes | Contract | ++=========================================================================================================================================================================+ +| _initialized | uint8 | 0 | 0 | 1 | contracts/tokenbridge/libraries/aeERC20.sol:aeERC20 | +|----------------------------------+--------------------------------------------------------+------+--------+-------+-----------------------------------------------------| +| _initializing | bool | 0 | 1 | 1 | contracts/tokenbridge/libraries/aeERC20.sol:aeERC20 | +|----------------------------------+--------------------------------------------------------+------+--------+-------+-----------------------------------------------------| +| __gap | uint256[50] | 1 | 0 | 1600 | contracts/tokenbridge/libraries/aeERC20.sol:aeERC20 | +|----------------------------------+--------------------------------------------------------+------+--------+-------+-----------------------------------------------------| +| _balances | mapping(address => uint256) | 51 | 0 | 32 | contracts/tokenbridge/libraries/aeERC20.sol:aeERC20 | +|----------------------------------+--------------------------------------------------------+------+--------+-------+-----------------------------------------------------| +| _allowances | mapping(address => mapping(address => uint256)) | 52 | 0 | 32 | contracts/tokenbridge/libraries/aeERC20.sol:aeERC20 | +|----------------------------------+--------------------------------------------------------+------+--------+-------+-----------------------------------------------------| +| _totalSupply | uint256 | 53 | 0 | 32 | contracts/tokenbridge/libraries/aeERC20.sol:aeERC20 | +|----------------------------------+--------------------------------------------------------+------+--------+-------+-----------------------------------------------------| +| _name | string | 54 | 0 | 32 | contracts/tokenbridge/libraries/aeERC20.sol:aeERC20 | +|----------------------------------+--------------------------------------------------------+------+--------+-------+-----------------------------------------------------| +| _symbol | string | 55 | 0 | 32 | contracts/tokenbridge/libraries/aeERC20.sol:aeERC20 | +|----------------------------------+--------------------------------------------------------+------+--------+-------+-----------------------------------------------------| +| _decimals | uint8 | 56 | 0 | 1 | contracts/tokenbridge/libraries/aeERC20.sol:aeERC20 | +|----------------------------------+--------------------------------------------------------+------+--------+-------+-----------------------------------------------------| +| __gap | uint256[44] | 57 | 0 | 1408 | contracts/tokenbridge/libraries/aeERC20.sol:aeERC20 | +|----------------------------------+--------------------------------------------------------+------+--------+-------+-----------------------------------------------------| +| _HASHED_NAME | bytes32 | 101 | 0 | 32 | contracts/tokenbridge/libraries/aeERC20.sol:aeERC20 | +|----------------------------------+--------------------------------------------------------+------+--------+-------+-----------------------------------------------------| +| _HASHED_VERSION | bytes32 | 102 | 0 | 32 | contracts/tokenbridge/libraries/aeERC20.sol:aeERC20 | +|----------------------------------+--------------------------------------------------------+------+--------+-------+-----------------------------------------------------| +| __gap | uint256[50] | 103 | 0 | 1600 | contracts/tokenbridge/libraries/aeERC20.sol:aeERC20 | +|----------------------------------+--------------------------------------------------------+------+--------+-------+-----------------------------------------------------| +| _nonces | mapping(address => struct CountersUpgradeable.Counter) | 153 | 0 | 32 | contracts/tokenbridge/libraries/aeERC20.sol:aeERC20 | +|----------------------------------+--------------------------------------------------------+------+--------+-------+-----------------------------------------------------| +| _PERMIT_TYPEHASH_DEPRECATED_SLOT | bytes32 | 154 | 0 | 32 | contracts/tokenbridge/libraries/aeERC20.sol:aeERC20 | +|----------------------------------+--------------------------------------------------------+------+--------+-------+-----------------------------------------------------| +| __gap | uint256[49] | 155 | 0 | 1568 | contracts/tokenbridge/libraries/aeERC20.sol:aeERC20 | +╰----------------------------------+--------------------------------------------------------+------+--------+-------+-----------------------------------------------------╯ + diff --git a/test/storage/aeWETH b/test/storage/aeWETH new file mode 100644 index 000000000..eb9586c61 --- /dev/null +++ b/test/storage/aeWETH @@ -0,0 +1,41 @@ + +╭----------------------------------+--------------------------------------------------------+------+--------+-------+---------------------------------------------------╮ +| Name | Type | Slot | Offset | Bytes | Contract | ++=======================================================================================================================================================================+ +| _initialized | uint8 | 0 | 0 | 1 | contracts/tokenbridge/libraries/aeWETH.sol:aeWETH | +|----------------------------------+--------------------------------------------------------+------+--------+-------+---------------------------------------------------| +| _initializing | bool | 0 | 1 | 1 | contracts/tokenbridge/libraries/aeWETH.sol:aeWETH | +|----------------------------------+--------------------------------------------------------+------+--------+-------+---------------------------------------------------| +| __gap | uint256[50] | 1 | 0 | 1600 | contracts/tokenbridge/libraries/aeWETH.sol:aeWETH | +|----------------------------------+--------------------------------------------------------+------+--------+-------+---------------------------------------------------| +| _balances | mapping(address => uint256) | 51 | 0 | 32 | contracts/tokenbridge/libraries/aeWETH.sol:aeWETH | +|----------------------------------+--------------------------------------------------------+------+--------+-------+---------------------------------------------------| +| _allowances | mapping(address => mapping(address => uint256)) | 52 | 0 | 32 | contracts/tokenbridge/libraries/aeWETH.sol:aeWETH | +|----------------------------------+--------------------------------------------------------+------+--------+-------+---------------------------------------------------| +| _totalSupply | uint256 | 53 | 0 | 32 | contracts/tokenbridge/libraries/aeWETH.sol:aeWETH | +|----------------------------------+--------------------------------------------------------+------+--------+-------+---------------------------------------------------| +| _name | string | 54 | 0 | 32 | contracts/tokenbridge/libraries/aeWETH.sol:aeWETH | +|----------------------------------+--------------------------------------------------------+------+--------+-------+---------------------------------------------------| +| _symbol | string | 55 | 0 | 32 | contracts/tokenbridge/libraries/aeWETH.sol:aeWETH | +|----------------------------------+--------------------------------------------------------+------+--------+-------+---------------------------------------------------| +| _decimals | uint8 | 56 | 0 | 1 | contracts/tokenbridge/libraries/aeWETH.sol:aeWETH | +|----------------------------------+--------------------------------------------------------+------+--------+-------+---------------------------------------------------| +| __gap | uint256[44] | 57 | 0 | 1408 | contracts/tokenbridge/libraries/aeWETH.sol:aeWETH | +|----------------------------------+--------------------------------------------------------+------+--------+-------+---------------------------------------------------| +| _HASHED_NAME | bytes32 | 101 | 0 | 32 | contracts/tokenbridge/libraries/aeWETH.sol:aeWETH | +|----------------------------------+--------------------------------------------------------+------+--------+-------+---------------------------------------------------| +| _HASHED_VERSION | bytes32 | 102 | 0 | 32 | contracts/tokenbridge/libraries/aeWETH.sol:aeWETH | +|----------------------------------+--------------------------------------------------------+------+--------+-------+---------------------------------------------------| +| __gap | uint256[50] | 103 | 0 | 1600 | contracts/tokenbridge/libraries/aeWETH.sol:aeWETH | +|----------------------------------+--------------------------------------------------------+------+--------+-------+---------------------------------------------------| +| _nonces | mapping(address => struct CountersUpgradeable.Counter) | 153 | 0 | 32 | contracts/tokenbridge/libraries/aeWETH.sol:aeWETH | +|----------------------------------+--------------------------------------------------------+------+--------+-------+---------------------------------------------------| +| _PERMIT_TYPEHASH_DEPRECATED_SLOT | bytes32 | 154 | 0 | 32 | contracts/tokenbridge/libraries/aeWETH.sol:aeWETH | +|----------------------------------+--------------------------------------------------------+------+--------+-------+---------------------------------------------------| +| __gap | uint256[49] | 155 | 0 | 1568 | contracts/tokenbridge/libraries/aeWETH.sol:aeWETH | +|----------------------------------+--------------------------------------------------------+------+--------+-------+---------------------------------------------------| +| l2Gateway | address | 204 | 0 | 20 | contracts/tokenbridge/libraries/aeWETH.sol:aeWETH | +|----------------------------------+--------------------------------------------------------+------+--------+-------+---------------------------------------------------| +| l1Address | address | 205 | 0 | 20 | contracts/tokenbridge/libraries/aeWETH.sol:aeWETH | +╰----------------------------------+--------------------------------------------------------+------+--------+-------+---------------------------------------------------╯ + diff --git a/test/storage/test-storage.bash b/test/storage/test-storage.bash new file mode 100755 index 000000000..8d2519c98 --- /dev/null +++ b/test/storage/test-storage.bash @@ -0,0 +1,3 @@ +#!/bin/bash + +./test/util/forge-inspect.bash ./test/storage storage \ No newline at end of file diff --git a/test/util/forge-inspect.bash b/test/util/forge-inspect.bash new file mode 100755 index 000000000..a988ac36f --- /dev/null +++ b/test/util/forge-inspect.bash @@ -0,0 +1,52 @@ +#!/bin/bash + +# usage: ./test/util/forge-inspect.bash + +contracts=$(./scripts/template/print-contracts.bash) +if [[ $? != "0" ]]; then + echo "Failed to get contracts" + exit 1 +fi + +outputDir=$1 +inspectType=$2 + +CHANGED=0 + +for contractName in $contracts; do + echo "Checking for $inspectType changes in $contractName" + + # if the file doesn't exist, create it + if [ ! -f "$outputDir/$contractName" ]; then + forge inspect "$contractName" "$inspectType" > "$outputDir/$contractName" + CHANGED=1 + # if the file does exist, compare it + else + mv "$outputDir/$contractName" "$outputDir/$contractName-old" + forge inspect "$contractName" "$inspectType" > "$outputDir/$contractName" + diff "$outputDir/$contractName-old" "$outputDir/$contractName" + if [[ $? != "0" ]]; then + CHANGED=1 + fi + fi +done + +rm -f "$outputDir"/*-old + +# Remove files for contracts that no longer exist +for existingFile in "$outputDir"/*; do + filename=$(basename "$existingFile") + + # skip files with extensions + if [[ "$filename" == *.* ]]; then + continue + fi + + # if the file doesn't exist in the contracts list, remove it + if ! echo "$contracts" | grep -qx "$filename"; then + rm -f "$existingFile" + CHANGED=1 + fi +done + +exit $CHANGED