Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ jobs:
- run: |
yarn install
yarn build
yarn test:storage
yarn test

workflows:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ cache
build
artifacts
deployment.json
test/storage/*-old.dot
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@
"lint": "yarn lint:solidity && yarn lint:js",
"format": "prettier './**/*.{js,json,md,ts,yml,sol}' --write && yarn lint --fix",
"test:compatibility": "yarn run build:0.6 && yarn run build:0.7 && yarn run build:0.8",
"test": "hardhat test test/*",
"test": "hardhat test test/*.ts",
"test:e2e": "hardhat test test/*.e2e.ts",
"test:l1": "hardhat test test/*.l1.ts",
"test:l2": "hardhat test test/*.l2.ts",
"test:storage": "./scripts/storage_layout_test.bash",
"typechain": "hardhat typechain",
"deploy:tokenbridge": "hardhat run scripts/deploy_token_bridge_l1.ts --network mainnet",
"gen:uml": "sol2uml ./contracts/tokenbridge/arbitrum,./contracts/tokenbridge/ethereum,./contracts/tokenbridge/libraries -o ./gatewayUML.svg",
Expand Down Expand Up @@ -62,7 +63,7 @@
"prettier": "^2.3.2",
"prettier-plugin-solidity": "^1.0.0-beta.17",
"prompts": "^2.4.1",
"sol2uml": "^1.1.29",
"sol2uml": "^2.5.4",
"solhint": "^3.2.0",
"solhint-plugin-prettier": "^0.0.5",
"solidity-coverage": "v0.7.17",
Expand Down
17 changes: 17 additions & 0 deletions scripts/storage_layout_test.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash
output_dir="./test/storage"
for CONTRACTNAME in L1ERC20Gateway L1CustomGateway L1ReverseCustomGateway L1WethGateway L2ERC20Gateway L2CustomGateway L2ReverseCustomGateway L2WethGateway L1GatewayRouter L2GatewayRouter StandardArbERC20
do
echo "Checking storage change of $CONTRACTNAME"
[ -f "$output_dir/$CONTRACTNAME.dot" ] && mv "$output_dir/$CONTRACTNAME.dot" "$output_dir/$CONTRACTNAME-old.dot"
yarn sol2uml storage ./ -c "$CONTRACTNAME" -o "$output_dir/$CONTRACTNAME.dot" -f dot
diff "$output_dir/$CONTRACTNAME-old.dot" "$output_dir/$CONTRACTNAME.dot"
if [[ $? != "0" ]]
then
CHANGED=1
fi
done
if [[ $CHANGED == 1 ]]
then
exit 1
fi
13 changes: 13 additions & 0 deletions test/storage/L1CustomGateway.dot
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

digraph StorageDiagram {
rankdir=LR
arrowhead=open
bgcolor="white"
edge [color="black"]
node [shape=record, style=filled, color="black", fillcolor="gray95", fontcolor="black", fontname="Courier New"]
2 [label="L1CustomGateway \<\<Contract\>\>\n | {{ slot | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7} | { type: \<inherited contract\>.variable (bytes) | { unallocated (12) | address: TokenGateway.counterpartGateway (20) } | { unallocated (12) | address: TokenGateway.router (20) } | { unallocated (12) | address: L1ArbitrumGateway.inbox (20) } | { <7> mapping\(bytes32=\>ExitData\): L1ArbitrumExtendedGateway.redirectedExits (32) } | { mapping\(address=\>address\): l1ToL2Token (32) } | { unallocated (12) | address: owner (20) } | { unallocated (12) | address: whitelist (20) } | { uint256: _status (32) }}}"]

1 [label="ExitData \<\<Struct\>\>\n | {{ offset | 0 | 1} | { type: variable (bytes) | { unallocated (11) | address: _newTo (20) | bool: isExit (1) } | { bytes: _newData (32) }}}"]

2:7 -> 1
}
13 changes: 13 additions & 0 deletions test/storage/L1ERC20Gateway.dot
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

digraph StorageDiagram {
rankdir=LR
arrowhead=open
bgcolor="white"
edge [color="black"]
node [shape=record, style=filled, color="black", fillcolor="gray95", fontcolor="black", fontname="Courier New"]
2 [label="L1ERC20Gateway \<\<Contract\>\>\n | {{ slot | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7} | { type: \<inherited contract\>.variable (bytes) | { unallocated (12) | address: TokenGateway.counterpartGateway (20) } | { unallocated (12) | address: TokenGateway.router (20) } | { unallocated (12) | address: L1ArbitrumGateway.inbox (20) } | { <7> mapping\(bytes32=\>ExitData\): L1ArbitrumExtendedGateway.redirectedExits (32) } | { bytes32: cloneableProxyHash (32) } | { unallocated (12) | address: l2BeaconProxyFactory (20) } | { unallocated (12) | address: whitelist (20) } | { uint256: _status (32) }}}"]

1 [label="ExitData \<\<Struct\>\>\n | {{ offset | 0 | 1} | { type: variable (bytes) | { unallocated (11) | address: _newTo (20) | bool: isExit (1) } | { bytes: _newData (32) }}}"]

2:7 -> 1
}
10 changes: 10 additions & 0 deletions test/storage/L1GatewayRouter.dot
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

digraph StorageDiagram {
rankdir=LR
arrowhead=open
bgcolor="white"
edge [color="black"]
node [shape=record, style=filled, color="black", fillcolor="gray95", fontcolor="black", fontname="Courier New"]
1 [label="L1GatewayRouter \<\<Contract\>\>\n | {{ slot | 0 | 1 | 2 | 3 | 4 | 5 | 6} | { type: \<inherited contract\>.variable (bytes) | { unallocated (12) | address: WhitelistConsumer.whitelist (20) } | { unallocated (12) | address: TokenGateway.counterpartGateway (20) } | { unallocated (12) | address: TokenGateway.router (20) } | { mapping\(address=\>address\): GatewayRouter.l1TokenToGateway (32) } | { unallocated (12) | address: GatewayRouter.defaultGateway (20) } | { unallocated (12) | address: owner (20) } | { unallocated (12) | address: inbox (20) }}}"]

}
13 changes: 13 additions & 0 deletions test/storage/L1ReverseCustomGateway.dot
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

digraph StorageDiagram {
rankdir=LR
arrowhead=open
bgcolor="white"
edge [color="black"]
node [shape=record, style=filled, color="black", fillcolor="gray95", fontcolor="black", fontname="Courier New"]
2 [label="L1ReverseCustomGateway \<\<Contract\>\>\n | {{ slot | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7} | { type: \<inherited contract\>.variable (bytes) | { unallocated (12) | address: TokenGateway.counterpartGateway (20) } | { unallocated (12) | address: TokenGateway.router (20) } | { unallocated (12) | address: L1ArbitrumGateway.inbox (20) } | { <7> mapping\(bytes32=\>ExitData\): L1ArbitrumExtendedGateway.redirectedExits (32) } | { mapping\(address=\>address\): L1CustomGateway.l1ToL2Token (32) } | { unallocated (12) | address: L1CustomGateway.owner (20) } | { unallocated (12) | address: L1CustomGateway.whitelist (20) } | { uint256: L1CustomGateway._status (32) }}}"]

1 [label="ExitData \<\<Struct\>\>\n | {{ offset | 0 | 1} | { type: variable (bytes) | { unallocated (11) | address: _newTo (20) | bool: isExit (1) } | { bytes: _newData (32) }}}"]

2:7 -> 1
}
13 changes: 13 additions & 0 deletions test/storage/L1WethGateway.dot
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

digraph StorageDiagram {
rankdir=LR
arrowhead=open
bgcolor="white"
edge [color="black"]
node [shape=record, style=filled, color="black", fillcolor="gray95", fontcolor="black", fontname="Courier New"]
2 [label="L1WethGateway \<\<Contract\>\>\n | {{ slot | 0 | 1 | 2 | 3 | 4 | 5} | { type: \<inherited contract\>.variable (bytes) | { unallocated (12) | address: TokenGateway.counterpartGateway (20) } | { unallocated (12) | address: TokenGateway.router (20) } | { unallocated (12) | address: L1ArbitrumGateway.inbox (20) } | { <7> mapping\(bytes32=\>ExitData\): L1ArbitrumExtendedGateway.redirectedExits (32) } | { unallocated (12) | address: l1Weth (20) } | { unallocated (12) | address: l2Weth (20) }}}"]

1 [label="ExitData \<\<Struct\>\>\n | {{ offset | 0 | 1} | { type: variable (bytes) | { unallocated (11) | address: _newTo (20) | bool: isExit (1) } | { bytes: _newData (32) }}}"]

2:7 -> 1
}
10 changes: 10 additions & 0 deletions test/storage/L2CustomGateway.dot
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

digraph StorageDiagram {
rankdir=LR
arrowhead=open
bgcolor="white"
edge [color="black"]
node [shape=record, style=filled, color="black", fillcolor="gray95", fontcolor="black", fontname="Courier New"]
1 [label="L2CustomGateway \<\<Contract\>\>\n | {{ slot | 0 | 1 | 2 | 3} | { type: \<inherited contract\>.variable (bytes) | { unallocated (12) | address: TokenGateway.counterpartGateway (20) } | { unallocated (12) | address: TokenGateway.router (20) } | { uint256: L2ArbitrumGateway.exitNum (32) } | { mapping\(address=\>address\): l1ToL2Token (32) }}}"]

}
10 changes: 10 additions & 0 deletions test/storage/L2ERC20Gateway.dot
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

digraph StorageDiagram {
rankdir=LR
arrowhead=open
bgcolor="white"
edge [color="black"]
node [shape=record, style=filled, color="black", fillcolor="gray95", fontcolor="black", fontname="Courier New"]
1 [label="L2ERC20Gateway \<\<Contract\>\>\n | {{ slot | 0 | 1 | 2 | 3} | { type: \<inherited contract\>.variable (bytes) | { unallocated (12) | address: TokenGateway.counterpartGateway (20) } | { unallocated (12) | address: TokenGateway.router (20) } | { uint256: L2ArbitrumGateway.exitNum (32) } | { unallocated (12) | address: beaconProxyFactory (20) }}}"]

}
10 changes: 10 additions & 0 deletions test/storage/L2GatewayRouter.dot
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

digraph StorageDiagram {
rankdir=LR
arrowhead=open
bgcolor="white"
edge [color="black"]
node [shape=record, style=filled, color="black", fillcolor="gray95", fontcolor="black", fontname="Courier New"]
1 [label="L2GatewayRouter \<\<Contract\>\>\n | {{ slot | 0 | 1 | 2 | 3} | { type: \<inherited contract\>.variable (bytes) | { unallocated (12) | address: TokenGateway.counterpartGateway (20) } | { unallocated (12) | address: TokenGateway.router (20) } | { mapping\(address=\>address\): GatewayRouter.l1TokenToGateway (32) } | { unallocated (12) | address: GatewayRouter.defaultGateway (20) }}}"]

}
10 changes: 10 additions & 0 deletions test/storage/L2ReverseCustomGateway.dot
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

digraph StorageDiagram {
rankdir=LR
arrowhead=open
bgcolor="white"
edge [color="black"]
node [shape=record, style=filled, color="black", fillcolor="gray95", fontcolor="black", fontname="Courier New"]
1 [label="L2ReverseCustomGateway \<\<Contract\>\>\n | {{ slot | 0 | 1 | 2 | 3} | { type: \<inherited contract\>.variable (bytes) | { unallocated (12) | address: TokenGateway.counterpartGateway (20) } | { unallocated (12) | address: TokenGateway.router (20) } | { uint256: L2ArbitrumGateway.exitNum (32) } | { mapping\(address=\>address\): L2CustomGateway.l1ToL2Token (32) }}}"]

}
10 changes: 10 additions & 0 deletions test/storage/L2WethGateway.dot
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

digraph StorageDiagram {
rankdir=LR
arrowhead=open
bgcolor="white"
edge [color="black"]
node [shape=record, style=filled, color="black", fillcolor="gray95", fontcolor="black", fontname="Courier New"]
1 [label="L2WethGateway \<\<Contract\>\>\n | {{ slot | 0 | 1 | 2 | 3 | 4} | { type: \<inherited contract\>.variable (bytes) | { unallocated (12) | address: TokenGateway.counterpartGateway (20) } | { unallocated (12) | address: TokenGateway.router (20) } | { uint256: L2ArbitrumGateway.exitNum (32) } | { unallocated (12) | address: l1Weth (20) } | { unallocated (12) | address: l2Weth (20) }}}"]

}
28 changes: 28 additions & 0 deletions test/storage/StandardArbERC20.dot
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

digraph StorageDiagram {
rankdir=LR
arrowhead=open
bgcolor="white"
edge [color="black"]
node [shape=record, style=filled, color="black", fillcolor="gray95", fontcolor="black", fontname="Courier New"]
7 [label="StandardArbERC20 \<\<Contract\>\>\n | {{ slot | 0 | 1-50 | 51 | 52 | 53 | 54 | 55 | 56 | 57-100 | 101 | 102 | 103-152 | 153 | 154 | 155-203 | 204 | 205 | 206} | { type: \<inherited contract\>.variable (bytes) | { unallocated (30) | bool: Initializable._initializing (1) | bool: Initializable._initialized (1) } | { <8> uint256[50]: ContextUpgradeable.__gap (1600) } | { mapping\(address=\>uint256\): ERC20Upgradeable._balances (32) } | { mapping\(address=\>mapping\(address=\>uint256\)\): ERC20Upgradeable._allowances (32) } | { uint256: ERC20Upgradeable._totalSupply (32) } | { string: ERC20Upgradeable._name (32) } | { string: ERC20Upgradeable._symbol (32) } | { unallocated (31) | uint8: ERC20Upgradeable._decimals (1) } | { <20> uint256[44]: ERC20Upgradeable.__gap (1408) } | { bytes32: EIP712Upgradeable._HASHED_NAME (32) } | { bytes32: EIP712Upgradeable._HASHED_VERSION (32) } | { <28> uint256[50]: EIP712Upgradeable.__gap (1600) } | { <30> mapping\(address=\>CountersUpgradeable.Counter\): ERC20PermitUpgradeable._nonces (32) } | { bytes32: ERC20PermitUpgradeable._PERMIT_TYPEHASH (32) } | { <37> uint256[49]: ERC20PermitUpgradeable.__gap (1568) } | { unallocated (12) | address: L2GatewayToken.l2Gateway (20) } | { unallocated (11) | bool: Cloneable.isMasterCopy (1) | address: L2GatewayToken.l1Address (20) } | { <44> ERC20Getters: availableGetters (32) }}}"]

1 [label="uint256[50]: __gap \<\<Array\>\>\n | {{ slot | 1 | 2 | 3-48 | 49 | 50} | { type: variable (bytes) | { uint256 (32) } | { uint256 (32) } | { ---- (1472) } | { uint256 (32) } | { uint256 (32) }}}"]

2 [label="uint256[44]: __gap \<\<Array\>\>\n | {{ slot | 57 | 58 | 59-98 | 99 | 100} | { type: variable (bytes) | { uint256 (32) } | { uint256 (32) } | { ---- (1280) } | { uint256 (32) } | { uint256 (32) }}}"]

3 [label="uint256[50]: __gap \<\<Array\>\>\n | {{ slot | 103 | 104 | 105-150 | 151 | 152} | { type: variable (bytes) | { uint256 (32) } | { uint256 (32) } | { ---- (1472) } | { uint256 (32) } | { uint256 (32) }}}"]

4 [label="Counter \<\<Struct\>\>\n | {{ offset | 0} | { type: variable (bytes) | { uint256: _value (32) }}}"]

5 [label="uint256[49]: __gap \<\<Array\>\>\n | {{ slot | 155 | 156 | 157-201 | 202 | 203} | { type: variable (bytes) | { uint256 (32) } | { uint256 (32) } | { ---- (1440) } | { uint256 (32) } | { uint256 (32) }}}"]

6 [label="ERC20Getters \<\<Struct\>\>\n | {{ slot | 206} | { type: variable (bytes) | { unallocated (29) | bool: ignoreSymbol (1) | bool: ignoreName (1) | bool: ignoreDecimals (1) }}}"]

7:8 -> 1
7:20 -> 2
7:28 -> 3
7:30 -> 4
7:37 -> 5
7:44 -> 6
}
Loading