From b1bd67d672e54bfb4971d931a123949012ebe1dd Mon Sep 17 00:00:00 2001 From: Edmund Edgar Date: Thu, 23 Nov 2023 01:52:20 +0000 Subject: [PATCH] originNetwork in the bridge should just be 0 for L1 and 1 for L2, instead of chainID --- contracts/L1GlobalForkRequester.sol | 7 ++----- contracts/L1GlobalRouter.sol | 4 +--- contracts/L2ChainInfo.sol | 7 +++---- contracts/L2ForkArbitrator.sol | 4 ++-- test/AdjudicationIntegration.t.sol | 4 ++-- 5 files changed, 10 insertions(+), 16 deletions(-) diff --git a/contracts/L1GlobalForkRequester.sol b/contracts/L1GlobalForkRequester.sol index 086430e2..0dae2f5b 100644 --- a/contracts/L1GlobalForkRequester.sol +++ b/contracts/L1GlobalForkRequester.sol @@ -141,7 +141,6 @@ contract L1GlobalForkRequester is MoneyBoxUser { IForkingManager forkingManager = IForkingManager(IForkonomicToken(token).forkmanager()); ForkableBridge bridge = ForkableBridge(forkingManager.bridge()); - IPolygonZkEVM zkevm = IPolygonZkEVM(forkingManager.zkEVM()); // Check the relations in the other direction to make sure we don't lie to the bridge somehow require(address(bridge.forkmanager()) == address(forkingManager), "Bridge/manager mismatch, WTF"); @@ -152,11 +151,9 @@ contract L1GlobalForkRequester is MoneyBoxUser { require(amount > 0, "Nothing to return"); IForkonomicToken(token).approve(address(bridge), amount); - uint64 chainId = zkevm.chainID(); - bytes memory permitData; bridge.bridgeAsset( - uint32(chainId), + uint32(1), requester, amount, token, // TODO: Should this be address(0)? @@ -167,7 +164,7 @@ contract L1GlobalForkRequester is MoneyBoxUser { // TODO: It might be useful to send information about the failure eg fork timestamp bytes memory data = bytes.concat(requestId); bridge.bridgeMessage( - uint32(chainId), + uint32(1), requester, true, data diff --git a/contracts/L1GlobalRouter.sol b/contracts/L1GlobalRouter.sol index 7a42e3dc..a84bc543 100644 --- a/contracts/L1GlobalRouter.sol +++ b/contracts/L1GlobalRouter.sol @@ -32,8 +32,6 @@ contract L1GlobalRouter { } } - uint64 chainId = IPolygonZkEVM(forkingManager.zkEVM()).chainID(); - uint256 arbitrationFee = forkingManager.arbitrationFee(); address forkonomicToken = forkingManager.forkonomicToken(); @@ -44,7 +42,7 @@ contract L1GlobalRouter { bytes memory data = abi.encode(forkonomicToken, arbitrationFee, isL1, disputeContract, disputeContent, forkResult); IPolygonZkEVMBridge(_bridge).bridgeMessage( - uint32(chainId), + uint32(1), _l2ChainInfo, true, data diff --git a/contracts/L2ChainInfo.sol b/contracts/L2ChainInfo.sol index 70762e00..9f0adb2a 100644 --- a/contracts/L2ChainInfo.sol +++ b/contracts/L2ChainInfo.sol @@ -20,7 +20,7 @@ contract L2ChainInfo is IBridgeMessageReceiver{ // These should be fixed addresses that never change address public l2bridge; address public l1globalRouter; - uint32 public originNetwork; + uint32 public constant L1_NETWORK_ID= 0; uint256 internal chainId; address internal forkonomicToken; @@ -32,8 +32,7 @@ contract L2ChainInfo is IBridgeMessageReceiver{ mapping(bool=>mapping(address=>mapping(bytes32=>bytes32))) public forkQuestionResults; mapping(bool=>mapping(address=>mapping(bytes32=>uint256))) public questionToChainID; - constructor(uint32 _originNetwork, address _l2bridge, address _l1globalRouter) { - originNetwork = _originNetwork; + constructor(address _l2bridge, address _l1globalRouter) { l2bridge = _l2bridge; l1globalRouter = _l1globalRouter; } @@ -68,7 +67,7 @@ contract L2ChainInfo is IBridgeMessageReceiver{ require(msg.sender == l2bridge, "not the expected bridge"); require(_originAddress == l1globalRouter, "only l1globalRouter can call us"); - require(_originNetwork == originNetwork, "wrong origin network"); + require(_originNetwork == L1_NETWORK_ID, "wrong origin network"); bool isL1; address forker; diff --git a/contracts/L2ForkArbitrator.sol b/contracts/L2ForkArbitrator.sol index 9c9e5af1..851657a2 100644 --- a/contracts/L2ForkArbitrator.sol +++ b/contracts/L2ForkArbitrator.sol @@ -136,7 +136,7 @@ contract L2ForkArbitrator is MoneyBoxUser, IBridgeMessageReceiver { bytes memory permitData; bridge.bridgeAsset{value: forkFee}( - uint32(chainInfo.originNetwork()), + uint32(0), moneyBox, forkFee, // TODO: Should this be 0 since we already sent the forkFee as msg.value? address(0), // Empty address for the native token @@ -153,7 +153,7 @@ contract L2ForkArbitrator is MoneyBoxUser, IBridgeMessageReceiver { address l2bridge = chainInfo.l2bridge(); require(msg.sender == l2bridge, "Not our bridge"); - require(_originNetwork == uint32(chainInfo.originNetwork()), "Wrong network, WTF"); + require(_originNetwork == uint32(0), "Wrong network, WTF"); require(_originAddress == address(l1globalForkRequester), "Unexpected sender"); bytes32 question_id = bytes32(_data); diff --git a/test/AdjudicationIntegration.t.sol b/test/AdjudicationIntegration.t.sol index f4720704..f8a65277 100644 --- a/test/AdjudicationIntegration.t.sol +++ b/test/AdjudicationIntegration.t.sol @@ -93,7 +93,7 @@ contract AdjudicationIntegrationTest is Test { address internal l1ForkingManagerF2 = address(0x2abe13); address internal l1TokenF2 = address(0x2abe14); - uint32 internal l1chainId = 1; + uint32 internal l1chainId = 0; uint256 internal forkingFee = 5000; // Should ultimately come from l1 forkingmanager @@ -103,7 +103,7 @@ contract AdjudicationIntegrationTest is Test { // For now the values of the l1 contracts are all made up // Ultimately our tests should include a deployment on l1 - l2ChainInfo = new L2ChainInfo(l1chainId, address(l2Bridge), l1GlobalRouter); + l2ChainInfo = new L2ChainInfo(address(l2Bridge), l1GlobalRouter); // Pretend to send the initial setup to the l2 directory via the bridge // Triggers: