Skip to content

Conversation

@nicholaspai
Copy link
Member

@nicholaspai nicholaspai commented Feb 14, 2022

No description provided.

@nicholaspai nicholaspai changed the title feat: add arbitrum spoke pool without unit tests feat: Add Arbitrum Spokepool and add generic cross-chain admin relayer function on HubPool Feb 14, 2022
uint256[] memory bundleLpFees
) internal {
AdapterInterface adapter = crossChainContracts[chainId].adapter;
require(address(adapter) != address(0), "Adapter not set for target chain");
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need this check? elsewhere in _executeRelayerRefundOnChain for example, we don't check that the adapter address is non0

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";

contract L1_Adapter is Base_Adapter, Lockable {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mrice32 @chrismaree I originally added this because I wanted to test HubPool.relaySpokePoolAdminFunction() in the simplest way and check that it can delegate a call to another contract, so I figured why not just build this L1 adapter to kill two birds with one stone

await expect(hubPool.connect(other).disableL1TokenForLiquidityProvision(weth.address)).to.be.reverted;
});
it("Can whitelist route for deposits and rebalances", async function () {
await hubPool.setCrossChainContracts(destinationChainId, mockAdapter.address, mockSpoke.address);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Neccessary now since whitelistRoute calls relayMessage

@nicholaspai nicholaspai marked this pull request as ready for review February 15, 2022 21:14

// Admin controlled mapping of arbitrum tokens to L1 counterpart. L1 counterpart addresses
// are neccessary to bridge tokens to L1.
mapping(address => address) public whitelistedTokens;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pain that we need this just for arbitrum but works kinda well given we have separate contracts for each chain.

abi.encodeWithSignature(
"setEnableRoute(address,uint32,bool)",
originToken,
uint32(destinationChainId),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unrelated to this PR but I think that the unit32 is too small.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm what should we use?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EIP 155 doesn't list the highest value for this so I guess its safe to just use 256

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will fix in #35

constructor(address _hubPool) Base_Adapter(_hubPool) {}

function relayMessage(address target, bytes memory message) external payable override nonReentrant onlyHubPool {
require(_executeCall(target, message), "execute call failed");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would it be cleaner to put the require part in the _executeCall function then just call this directly? we never want the success=false case so we might as well assume this method does not throw if it passed. i.e the _executeCall would not return anything and would simply have require(success,"execute call failed") at the end of the function.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. Why not

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

* @dev Uses AVM cross-domain-enabled logic for access control.
*/

contract Arbitrum_SpokePool is SpokePoolInterface, SpokePool {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this does not have any tests. shall we add that in this PR or a separate one? we also need to write OP tests, which can happen either at the same time, if we choose to wait on adding the tests here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's do separate PR

@nicholaspai nicholaspai merged commit 3c73875 into master Feb 16, 2022
@nicholaspai nicholaspai deleted the npai/arbitrum-spoke-pool branch February 16, 2022 18:29
pxrl added a commit that referenced this pull request Feb 20, 2024
Originally authored by Nick & Matt.

Signed-off-by: nicholaspai <npai.nyc@gmail.com>
Signed-off-by: Matt Rice <matthewcrice32@gmail.com>
Co-authored-by: nicholaspai <9457025+nicholaspai@users.noreply.github.com>
Co-authored-by: Matt Rice <matthewcrice32@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants