Skip to content

Commit

Permalink
standardize on eg l2CamelCase not l2camelCase
Browse files Browse the repository at this point in the history
  • Loading branch information
edmundedgar committed Nov 28, 2023
1 parent 6186a5e commit f65d166
Show file tree
Hide file tree
Showing 5 changed files with 115 additions and 115 deletions.
14 changes: 7 additions & 7 deletions contracts/L2ChainInfo.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import {IBridgeMessageReceiver} from "@RealityETH/zkevm-contracts/contracts/inte
contract L2ChainInfo is IBridgeMessageReceiver{

// These are the same for all forks
address public l2bridge;
address public l1globalChainInfoPublisher;
address public l2Bridge;
address public l1GlobalChainInfoPublisher;
uint32 public constant L1_NETWORK_ID = 0;

struct ChainInfo{
Expand All @@ -31,9 +31,9 @@ contract L2ChainInfo is IBridgeMessageReceiver{
mapping(bool=>mapping(address=>mapping(bytes32=>bytes32))) public forkQuestionResults;
mapping(bool=>mapping(address=>mapping(bytes32=>uint64))) public questionToChainID;

constructor(address _l2bridge, address _l1globalChainInfoPublisher) {
l2bridge = _l2bridge;
l1globalChainInfoPublisher = _l1globalChainInfoPublisher;
constructor(address _l2Bridge, address _l1GlobalChainInfoPublisher) {
l2Bridge = _l2Bridge;
l1GlobalChainInfoPublisher = _l1GlobalChainInfoPublisher;
}

modifier isUpToDate {
Expand All @@ -58,8 +58,8 @@ contract L2ChainInfo is IBridgeMessageReceiver{
// It could also send us information about a previous chain that's a parent of ours if we forked again before getting it for some reason.
function onMessageReceived(address _originAddress, uint32 _originNetwork, bytes memory _data) external payable {

require(msg.sender == l2bridge, "not the expected bridge");
require(_originAddress == l1globalChainInfoPublisher, "only publisher can call us");
require(msg.sender == l2Bridge, "not the expected bridge");
require(_originAddress == l1GlobalChainInfoPublisher, "only publisher can call us");
require(_originNetwork == L1_NETWORK_ID, "Bad origin network");

(uint64 chainId, address forkonomicToken, uint256 forkFee, bool isL1, address forker, bytes32 questionId, bytes32 result) = abi.decode(_data, (uint64, address, uint256, bool, address, bytes32, bytes32));
Expand Down
22 changes: 11 additions & 11 deletions contracts/L2ForkArbitrator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ contract L2ForkArbitrator is MoneyBoxUser, IBridgeMessageReceiver {
mapping(address => uint256) public refundsDue;

L2ChainInfo public chainInfo;
L1GlobalForkRequester public l1globalForkRequester;
L1GlobalForkRequester public l1GlobalForkRequester;

uint256 public disputeFee; // Normally dispute fee should generally only go down in a fork

constructor(IRealityETH _realitio, L2ChainInfo _chainInfo, L1GlobalForkRequester _l1globalForkRequester, uint256 _initialDisputeFee) {
constructor(IRealityETH _realitio, L2ChainInfo _chainInfo, L1GlobalForkRequester _l1GlobalForkRequester, uint256 _initialDisputeFee) {
realitio = _realitio;
chainInfo = _chainInfo;
l1globalForkRequester = _l1globalForkRequester;
l1GlobalForkRequester = _l1GlobalForkRequester;
disputeFee = _initialDisputeFee;
}

Expand Down Expand Up @@ -119,19 +119,19 @@ contract L2ForkArbitrator is MoneyBoxUser, IBridgeMessageReceiver {
uint256 paid = arbitrationRequests[question_id].paid;
require(paid >= forkFee, "fee paid too low");

address l2bridge = chainInfo.l2bridge();
require(l2bridge != address(0), "l2bridge not set");
address l2Bridge = chainInfo.l2Bridge();
require(l2Bridge != address(0), "l2Bridge not set");

IPolygonZkEVMBridge bridge = IPolygonZkEVMBridge(l2bridge);
IPolygonZkEVMBridge bridge = IPolygonZkEVMBridge(l2Bridge);

address forkonomicToken = chainInfo.getForkonomicToken();

// The receiving contract may get different payments from different requests
// To differentiate our payment, we will use a dedicated MoneyBox contract controlled by l1globalForkRequester
// To differentiate our payment, we will use a dedicated MoneyBox contract controlled by l1GlobalForkRequester
// The L1GlobalForkRequester will deploy this as and when it's needed.
// TODO: For now we assume only 1 request is in-flight at a time. If there might be more, differentiate them in the salt.
bytes32 salt = keccak256(abi.encodePacked(address(this), question_id));
address moneyBox = _calculateMoneyBoxAddress(address(l1globalForkRequester), salt, address(forkonomicToken));
address moneyBox = _calculateMoneyBoxAddress(address(l1GlobalForkRequester), salt, address(forkonomicToken));

bytes memory permitData;
bridge.bridgeAsset{value: forkFee}(
Expand All @@ -150,10 +150,10 @@ contract L2ForkArbitrator is MoneyBoxUser, IBridgeMessageReceiver {
// We will set FORK_REQUEST_FAILED which will allow anyone to request cancellation
function onMessageReceived(address _originAddress, uint32 _originNetwork, bytes memory _data) external payable {

address l2bridge = chainInfo.l2bridge();
require(msg.sender == l2bridge, "Not our bridge");
address l2Bridge = chainInfo.l2Bridge();
require(msg.sender == l2Bridge, "Not our bridge");
require(_originNetwork == uint32(0), "Wrong network, WTF");
require(_originAddress == address(l1globalForkRequester), "Unexpected sender");
require(_originAddress == address(l1GlobalForkRequester), "Unexpected sender");

bytes32 question_id = bytes32(_data);
RequestStatus status = arbitrationRequests[question_id].status;
Expand Down
Loading

0 comments on commit f65d166

Please sign in to comment.