Skip to content

Commit

Permalink
[SMR-1975] TODO cleanup (#49)
Browse files Browse the repository at this point in the history
* address TODOs on bridge flowrate integration tests

* clean up last TODO

* checkout file
  • Loading branch information
tsnewnami authored Nov 21, 2023
1 parent 45acda3 commit 1652728
Show file tree
Hide file tree
Showing 6 changed files with 186 additions and 66 deletions.
1 change: 0 additions & 1 deletion script/InitializeChildContracts.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ contract InitializeChildContracts is Script {
vm.createSelectFork(params.childRpcUrl);
vm.startBroadcast(params.deployerPrivateKey);

// TODO update
IChildERC20Bridge.InitializationRoles memory roles = IChildERC20Bridge.InitializationRoles({
defaultAdmin: params.childAdminAddress,
pauser: params.childPauserAddress,
Expand Down
2 changes: 0 additions & 2 deletions script/InitializeRootContracts.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@ contract InitializeRootContracts is Script {
vm.createSelectFork(params.rootRpcUrl);
vm.startBroadcast(params.rootPrivateKey);

// TODO add pauser, unpauser roles. variable manager and Adaptor manager will be privileged transaction multisg

IRootERC20Bridge.InitializationRoles memory roles = IRootERC20Bridge.InitializationRoles({
defaultAdmin: params.rootAdminAddress,
pauser: params.rootPauserAddress,
Expand Down
1 change: 0 additions & 1 deletion src/root/RootAxelarBridgeAdaptor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ contract RootAxelarBridgeAdaptor is
string memory _childBridgeAdaptor = IRootERC20Bridge(rootBridge).childBridgeAdaptor();
string memory _childChain = childChain;

// TODO For `sender` (first param), should likely be refundRecipient (and in which case refundRecipient should be renamed to sender and used as refund recipient)
gasService.payNativeGasForContractCall{value: msg.value}(
address(this), _childChain, _childBridgeAdaptor, payload, refundRecipient
);
Expand Down
2 changes: 0 additions & 2 deletions src/root/RootERC20Bridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,6 @@ contract RootERC20Bridge is BridgeRoles, IRootERC20Bridge, IRootERC20BridgeEvent

bytes memory payload =
abi.encode(MAP_TOKEN_SIG, rootToken, rootToken.name(), rootToken.symbol(), rootToken.decimals());
// TODO investigate using delegatecall to keep the axelar message sender as the bridge contract, since adaptor can change.
rootBridgeAdaptor.sendMessage{value: msg.value}(payload, msg.sender);

emit L1TokenMapped(address(rootToken), childToken);
Expand Down Expand Up @@ -451,7 +450,6 @@ contract RootERC20Bridge is BridgeRoles, IRootERC20Bridge, IRootERC20BridgeEvent
// Deposit sig, root token address, depositor, receiver, amount
bytes memory payload = abi.encode(DEPOSIT_SIG, payloadToken, msg.sender, receiver, amount);

// TODO investigate using delegatecall to keep the axelar message sender as the bridge contract, since adaptor can change.
rootBridgeAdaptor.sendMessage{value: feeAmount}(payload, msg.sender);

if (address(rootToken) == NATIVE_ETH) {
Expand Down
20 changes: 18 additions & 2 deletions test/integration/child/ChildAxelarBridge.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,6 @@ contract ChildERC20BridgeIntegrationTest is Test, IChildERC20BridgeEvents, IChil
);
}

// TODO add mapToken calls to these to isolate the specific error we are testing for vvvv

function test_RevertIf_depositWithRootTokenZeroAddress() public {
address rootTokenAddress = address(0);
address sender = address(0xff);
Expand All @@ -280,6 +278,15 @@ contract ChildERC20BridgeIntegrationTest is Test, IChildERC20BridgeEvents, IChil
bytes32 commandId = bytes32("testCommandId");
bytes32 depositSig = childERC20Bridge.DEPOSIT_SIG();

{
// Found by running `forge inspect src/child/ChildERC20Bridge.sol:ChildERC20Bridge storageLayout | grep -B3 -A5 -i "rootTokenToChildToken"`
uint256 rootTokenToChildTokenMappingSlot = 201;
address childAddress = address(444444);
bytes32 slot = getMappingStorageSlotFor(rootTokenAddress, rootTokenToChildTokenMappingSlot);
bytes32 data = bytes32(uint256(uint160(childAddress)));
vm.store(address(childERC20Bridge), slot, data);
}

vm.expectRevert(ZeroAddress.selector);
childAxelarBridgeAdaptor.execute(
commandId,
Expand All @@ -297,6 +304,15 @@ contract ChildERC20BridgeIntegrationTest is Test, IChildERC20BridgeEvents, IChil
bytes32 commandId = bytes32("testCommandId");
bytes32 depositSig = childERC20Bridge.DEPOSIT_SIG();

{
// Found by running `forge inspect src/child/ChildERC20Bridge.sol:ChildERC20Bridge storageLayout | grep -B3 -A5 -i "rootTokenToChildToken"`
uint256 rootTokenToChildTokenMappingSlot = 201;
address childAddress = address(444444);
bytes32 slot = getMappingStorageSlotFor(rootTokenAddress, rootTokenToChildTokenMappingSlot);
bytes32 data = bytes32(uint256(uint160(childAddress)));
vm.store(address(childERC20Bridge), slot, data);
}

vm.expectRevert(ZeroAddress.selector);
childAxelarBridgeAdaptor.execute(
commandId,
Expand Down
Loading

0 comments on commit 1652728

Please sign in to comment.