babylonchain / optimism

Optimism is Ethereum, scaled.
https://optimism.io
MIT License
1 stars 0 forks source link

feat: L2OutputOracle add BabylonController contract address #3

Closed bap2pecs closed 1 month ago

bap2pecs commented 1 month ago

Summary

op-proposer sends tx to L2OO for state commitment, along with the EOTS sig/pub rand/proof of inclusion for verification.

L2OO calls the BabylonController contract which calls the EOTS verifier contract (https://github.com/parketh/babylon-eots-verifier) which gets the voting power data from the Babylon BTC staking oracle contract.

image

It's designed in this way to minimize the changes in the OP codebase. For example, now we don't need to store the consumer chain ID which is required by the EOTS verifier contract for security purpose. We can init the data in the BabylonController contract.

Test

follow the official tutorial, install dependencies such as direnv and hook it in shell. run ./scripts/getting-started/versions.sh and upgrade deps (e.g. pnpm) if some are less than the min version.

create .envrc file and add required ENVs. add a new one as well:

export BABYLON_CONTROLLER_ADDRESS=0x0000000000000000000000000000000000000000

then run direnv allow

run make submodules to install submodules as well.

then run ./scripts/getting-started/config.sh to create packages/contracts-bedrock/deploy-config/getting-started.json

last run npm run snapshots to generate abi, run tests and perform formal verification

Now, let's test by deploying the contract (see packages/contracts-bedrock/README.md):

add to .envrc and load it:

export DEPLOY_CONFIG_PATH=deploy-config/getting-started.json
export ETHERSCAN_API_KEY=<redacted>

then run:

forge script scripts/Deploy.s.sol:Deploy --private-key $GS_ADMIN_PRIVATE_KEY --broadcast --rpc-url $L1_RPC_URL --slow --verify --sig 'deployL2OutputOracle()'

it's successfully deployed at https://sepolia.etherscan.io/address/0xbb40F5B141B2219181DFd804826d5b8233c8B156

then load the contract in remix using some fake code to verify the state var is added correctly:

// SPDX-License-Identifier: MIT
pragma solidity 0.8.15;

contract L2OutputOracle  {
    address public babylonController;

    constructor() {
    }
}