Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update bridge hardcoded values #542

Merged
merged 12 commits into from
Dec 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
aloknerurkar marked this conversation as resolved.
Show resolved Hide resolved

// 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;
aloknerurkar marked this conversation as resolved.
Show resolved Hide resolved
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
Loading