-
Notifications
You must be signed in to change notification settings - Fork 7
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
SMR-1782 ETH Child Bridge #9
Changes from 15 commits
82d032c
ee559c7
877195d
c4c59a4
22a0f27
932ad87
6a06077
fc2eaae
e4de38e
1d5fcac
c597a9f
eb4134e
108abc4
abc5c4f
59e4a8c
56737b4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,4 +20,6 @@ docs/ | |
.vscode/ | ||
|
||
# Contract addresses | ||
addresses.json | ||
addresses.json | ||
|
||
/node_modules |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,8 @@ import {Utils} from "../../utils.t.sol"; | |
contract ChildERC20BridgeIntegrationTest is Test, IChildERC20BridgeEvents, IChildERC20BridgeErrors, Utils { | ||
string public ROOT_ADAPTOR_ADDRESS = Strings.toHexString(address(1)); | ||
string public ROOT_CHAIN_NAME = "ROOT_CHAIN"; | ||
Comment on lines
18
to
20
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think there is some coverage that is missing in the child bridge integration tests now. Namely, making sure that if the root chain's ETH address is used, that the child ETH address is chosen, and that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. looking at adding these integration tests now. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ive added more integration tests to the root and child. also removed the need for the childETH address to be passed into the rootBridge initialize method and updated tests + deploy scripts to reflect that. |
||
address constant IMX_TOKEN = address(9); | ||
address constant IMX_TOKEN_ADDRESS = address(0xccc); | ||
address constant NATIVE_ETH = address(0xeee); | ||
|
||
ChildERC20Bridge public childERC20Bridge; | ||
ChildERC20 public childERC20; | ||
|
@@ -35,7 +36,11 @@ contract ChildERC20BridgeIntegrationTest is Test, IChildERC20BridgeEvents, IChil | |
new ChildAxelarBridgeAdaptor(address(mockChildAxelarGateway), address(childERC20Bridge)); | ||
|
||
childERC20Bridge.initialize( | ||
address(childAxelarBridgeAdaptor), ROOT_ADAPTOR_ADDRESS, address(childERC20), ROOT_CHAIN_NAME, IMX_TOKEN | ||
address(childAxelarBridgeAdaptor), | ||
ROOT_ADAPTOR_ADDRESS, | ||
address(childERC20), | ||
ROOT_CHAIN_NAME, | ||
IMX_TOKEN_ADDRESS | ||
); | ||
} | ||
|
||
|
@@ -143,6 +148,47 @@ contract ChildERC20BridgeIntegrationTest is Test, IChildERC20BridgeEvents, IChil | |
); | ||
} | ||
|
||
function test_deposit_EmitsNativeDeposit() public { | ||
address sender = address(0xff); | ||
address receiver = address(0xee); | ||
uint256 amount = 100; | ||
|
||
address predictedChildETHToken = Clones.predictDeterministicAddress( | ||
address(childERC20), keccak256(abi.encodePacked(NATIVE_ETH)), address(childERC20Bridge) | ||
); | ||
|
||
bytes32 commandId = bytes32("testCommandId"); | ||
|
||
vm.expectEmit(address(childERC20Bridge)); | ||
emit NativeEthDeposit(NATIVE_ETH, predictedChildETHToken, sender, receiver, amount); | ||
|
||
childAxelarBridgeAdaptor.execute( | ||
commandId, | ||
ROOT_CHAIN_NAME, | ||
ROOT_ADAPTOR_ADDRESS, | ||
abi.encode(childERC20Bridge.DEPOSIT_SIG(), NATIVE_ETH, sender, receiver, amount) | ||
); | ||
} | ||
|
||
function test_deposit_EmitsIMXDeposit() public { | ||
address sender = address(0xff); | ||
address receiver = address(0xee); | ||
uint256 amount = 100; | ||
bytes32 commandId = bytes32("testCommandId"); | ||
|
||
vm.deal(address(childERC20Bridge), 1 ether); | ||
|
||
vm.expectEmit(address(childERC20Bridge)); | ||
emit IMXDeposit(IMX_TOKEN_ADDRESS, sender, receiver, amount); | ||
|
||
childAxelarBridgeAdaptor.execute( | ||
commandId, | ||
ROOT_CHAIN_NAME, | ||
ROOT_ADAPTOR_ADDRESS, | ||
abi.encode(childERC20Bridge.DEPOSIT_SIG(), IMX_TOKEN_ADDRESS, sender, receiver, amount) | ||
); | ||
} | ||
|
||
function test_deposit_TransfersTokenToReceiver() public { | ||
address rootTokenAddress = address(456); | ||
address sender = address(0xff); | ||
|
@@ -246,8 +292,8 @@ contract ChildERC20BridgeIntegrationTest is Test, IChildERC20BridgeEvents, IChil | |
bytes32 depositSig = childERC20Bridge.DEPOSIT_SIG(); | ||
address rootAddress = address(0x123); | ||
{ | ||
// Slot is 6 because of the Ownable, Initializable contracts coming first. | ||
uint256 rootTokenToChildTokenMappingSlot = 6; | ||
// Slot is 2 because of the Ownable, Initializable contracts coming first. | ||
uint256 rootTokenToChildTokenMappingSlot = 2; | ||
address childAddress = address(444444); | ||
bytes32 slot = getMappingStorageSlotFor(rootAddress, rootTokenToChildTokenMappingSlot); | ||
bytes32 data = bytes32(uint256(uint160(childAddress))); | ||
|
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.
We shouldn't actually deploy the token here, we should use the prediction function with the child bridge as the deployer. Otherwise it will yield an incorrect address
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.
Something like this:
See the
mapTokens
function for referenceThere 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.
Addressed