Skip to content

Commit

Permalink
originNetwork in the bridge should just be 0 for L1 and 1 for L2, ins…
Browse files Browse the repository at this point in the history
…tead of chainID
  • Loading branch information
edmundedgar committed Nov 23, 2023
1 parent 7070a35 commit b1bd67d
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 16 deletions.
7 changes: 2 additions & 5 deletions contracts/L1GlobalForkRequester.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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)?
Expand All @@ -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
Expand Down
4 changes: 1 addition & 3 deletions contracts/L1GlobalRouter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ contract L1GlobalRouter {
}
}

uint64 chainId = IPolygonZkEVM(forkingManager.zkEVM()).chainID();

uint256 arbitrationFee = forkingManager.arbitrationFee();
address forkonomicToken = forkingManager.forkonomicToken();

Expand All @@ -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
Expand Down
7 changes: 3 additions & 4 deletions contracts/L2ChainInfo.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions contracts/L2ForkArbitrator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions test/AdjudicationIntegration.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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:
Expand Down

0 comments on commit b1bd67d

Please sign in to comment.