Skip to content

Commit

Permalink
chore: update bridge hardcoded values (#542)
Browse files Browse the repository at this point in the history
  • Loading branch information
shaspitz authored Dec 26, 2024
1 parent 83f2d75 commit 8ceeb28
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 11 deletions.
2 changes: 1 addition & 1 deletion contracts/scripts/core/DeployCore.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {console} from "forge-std/console.sol";
contract DeployTestnet is Script {

// Amount of ETH to initially fund the oracle account on L1 chain.
uint256 public constant ORACLE_INITIAL_FUNDING = 1 ether;
uint256 public constant ORACLE_INITIAL_FUNDING = 0.5 ether;
uint256 public constant PERCENT_MULTIPLIER = 1e16;

error FailedToSendETHToOracle(address addr);
Expand Down
31 changes: 21 additions & 10 deletions contracts/scripts/standard-bridge/DeployStandardBridge.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,34 @@ import {Upgrades} from "openzeppelin-foundry-upgrades/Upgrades.sol";
import {console} from "forge-std/console.sol";

contract BridgeBase is Script {
// Amount of ETH to initially fund the relayer account on the mev-commit chain.
// This should be high enough to cover the cost of enqueuing transactions as
// long as the relayer account is a zero-fee account.
uint256 public constant RELAYER_INITIAL_FUNDING_MEV_COMMIT_CHAIN = 0.03 ether;

// Amount of ETH to initially fund the oracle account on the mev-commit chain.
// This should be high enough to cover the cost of enqueuing transactions as
// long as the oracle account is a zero-fee account.
uint256 public constant ORACLE_INITIAL_FUNDING_MEV_COMMIT_CHAIN = 0.5 ether;

// Amount of ETH which must be allocated only to the contract deployer on mev-commit chain genesis.
uint256 public constant DEPLOYER_GENESIS_ALLOCATION = type(uint256).max - 500 ether;

// Amount of ETH to initially fund the relayer account on both chains.
uint256 public constant RELAYER_INITIAL_FUNDING = 1 ether;
// Amount of ETH which must be present in the deployer account after core contract deployment. The funds
// for the Oracle are already transferred.
uint256 public constant DEPLOYER_INITIAL_BALANCE = DEPLOYER_GENESIS_ALLOCATION - ORACLE_INITIAL_FUNDING_MEV_COMMIT_CHAIN;

// Amount of ETH to initially fund the oracle account on L1 chain.
uint256 public constant ORACLE_INITIAL_FUNDING = 1 ether;
// Amount of ETH to initially fund the relayer account on L1.
uint256 public constant RELAYER_INITIAL_FUNDING_L1 = 1 ether;

// Amount of ETH required by the contract deployer to initialize all bridge and core contract state,
// AND initially fund the relayer, all on mev-commit chain.
// This amount of ETH must be initially locked in the L1 gateway contract to ensure a 1:1 peg
// between mev-commit chain ETH and L1 ETH.
uint256 public constant MEV_COMMIT_CHAIN_SETUP_COST = 1 ether + RELAYER_INITIAL_FUNDING + ORACLE_INITIAL_FUNDING;
uint256 public constant MEV_COMMIT_CHAIN_SETUP_COST = 0.01 ether + ORACLE_INITIAL_FUNDING_MEV_COMMIT_CHAIN + RELAYER_INITIAL_FUNDING_MEV_COMMIT_CHAIN;

// Amount of ETH required on L1 to initialize the L1 gateway, make transfer calls, and initially fund the relayer on L1.
uint256 public constant L1_SETUP_COST = 1 ether + RELAYER_INITIAL_FUNDING;
uint256 public constant L1_SETUP_COST = 0.01 ether + RELAYER_INITIAL_FUNDING_L1;

error RelayerAddressNotSet(address addr);
error L1FinalizationFeeNotSet(uint256 fee);
Expand Down Expand Up @@ -63,8 +74,8 @@ contract DeploySettlementGateway is BridgeBase {
address relayerAddr = _getRelayerAddress();
uint256 l1FinalizationFee = _getL1FinalizationFee();

require(address(msg.sender).balance >= DEPLOYER_GENESIS_ALLOCATION,
DeployerMustHaveGenesisAllocation(address(msg.sender).balance, DEPLOYER_GENESIS_ALLOCATION));
require(address(msg.sender).balance >= DEPLOYER_INITIAL_BALANCE,
DeployerMustHaveGenesisAllocation(address(msg.sender).balance, DEPLOYER_INITIAL_BALANCE));

address allocatorProxy = Upgrades.deployUUPSProxy(
"Allocator.sol",
Expand All @@ -90,7 +101,7 @@ contract DeploySettlementGateway is BridgeBase {

allocator.addToWhitelist(address(settlementGateway));

(success, ) = payable(relayerAddr).call{value: RELAYER_INITIAL_FUNDING}("");
(success, ) = payable(relayerAddr).call{value: RELAYER_INITIAL_FUNDING_MEV_COMMIT_CHAIN}("");
require(success, FailedToSendETHToRelayer(relayerAddr));

vm.stopBroadcast();
Expand Down Expand Up @@ -127,7 +138,7 @@ contract DeployL1Gateway is BridgeBase {
(bool success, ) = payable(address(l1Gateway)).call{value: MEV_COMMIT_CHAIN_SETUP_COST}("");
require(success, FailedToFundL1Gateway(address(l1Gateway)));

(success, ) = payable(relayerAddr).call{value: RELAYER_INITIAL_FUNDING}("");
(success, ) = payable(relayerAddr).call{value: RELAYER_INITIAL_FUNDING_L1}("");
require(success, FailedToSendETHToRelayer(relayerAddr));

vm.stopBroadcast();
Expand Down
4 changes: 4 additions & 0 deletions infrastructure/nomad/playbooks/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,11 @@
echo "${ALLOC}" | jq --arg address "0x${ADDRESS}" '
. + {
($address): {
{% if profile == 'mainnet' %}
"balance": "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE4E51B291D10AFFFFF"
{% else %}
"balance": "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFD4A51000FDA0FFFF"
{% endif %}
}
}
'
Expand Down
5 changes: 5 additions & 0 deletions tools/relay-emulator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,11 @@ func main() {
return
}

if len(registeredKeys) == 0 {
http.Error(w, "No registered keys", http.StatusInternalServerError)
return
}

idx := int(blockNumber) % len(registeredKeys)
registeredLock.RLock()
key := registeredKeys[idx]
Expand Down

0 comments on commit 8ceeb28

Please sign in to comment.