Skip to content

Commit

Permalink
feat: adds support for multiple BLS keys (#468)
Browse files Browse the repository at this point in the history
* feat: wip tracking relays

* feat: wip adding relays support for builder atrib

* chore: wip new oracle input

* chore: add bls provider mapping

* feat: simplify l1listener processg

* chore: wip introduces effective recording of blskeys

* chore: updates abi

* feat: uses bls key submission

* feat: makes relayquerier testable and tests it

* feat: resolves all test changes

* chore: nit remove unused var

* chore: cleanup test suite

* chore: update relays to be holesky specific

* chore: adds verbose logging for testing

* chore: log even more data for testing

* chore: uses parent hash value

* chore: hardcode titan BLS key into devnet test signup

* chore: remove trailing 0x or registration in test

* chore: updates encoding of blskey format

* feat: updates test to recognize bls key as bytes

* chore: adds value for L1 RPC

* chore: add l1 holesky rpc

* feat: updates contracts to array of keys

* feat: updates p2p to process keys as an array

* chore: updates integration test and rpcs

* chore: update visability

* chore: manually set debug logs for now

* chore: adds a log for opened commitment

* chore: update loglevel for oracle to debug

* chore: to remove verbose logging

* chore: update to higher throughput

* chore: make contract upgradeable

* feat: adds capacity for owner to add more blskeys manually

* chore: cleans tests

* feat: merges in changes

* chore: fix merge issues

* chore: more merge conflict fixes

* chore: deletes incorrect test

* chore: remove infra changes

* chore: tmp remove bridge

* chore: clean linter issues

* chore: runs abigen

* feat: adds an event for new provider registry set

* chore: make use of multiple keys in test

* chore: cleanup comments

* chore: nit comments

* chore: remove all verbose logging

* chore: adds newline

* chore: emit event before

* chore: resolves nit comments

* chore: revert use of hours

* chore: adds use of hours everywhere

* feat: adds a mock relay service for testing

* chore: removes manually adding 0x

* chore: manually add the l1-rpc

* chore: move mock relay to testing pkg

* chore: fixes nit commentsg

* feat: add support for mock relay in test setup (#478)

* feat: add support for mock relay in test setup

* fix: comments

---------

Co-authored-by: Alok <[email protected]>

* chore: manually generate a key

* chore: fix nit comments and ordering of mock l1

* chore: add min 1 bls key requirement

* feat: adds context to relay query

* chore: nit ninja j2 file fix

* chore: fix more spacing

* chore: return rpc endpoint

* chore: removes manual port

* fix: provider (#482)

* fix: relay integration test (#483)

* fix: configure relay endpoint

* chore: remove holesky url

* chore: remove trailing newline

* refactor: add context timeout to bridge transfer (#484)

* fix: lint errors

* chore: updates to use pathescape

* fix: path escape

* fix: url creation in oracle

---------

Co-authored-by: aloknerurkar <[email protected]>
Co-authored-by: Alok <[email protected]>
Co-authored-by: mrekucci <[email protected]>
Co-authored-by: Alok Nerurkar <[email protected]>
  • Loading branch information
5 people authored Nov 15, 2024
1 parent f86e8c5 commit 0a2f8ff
Show file tree
Hide file tree
Showing 38 changed files with 1,791 additions and 700 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/infrastructure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,8 @@ jobs:
--settlement-rpc-endpoint ws://127.0.0.1:8546 \
--bootnode-rpc-urls 127.0.0.1:13524 \
--provider-rpc-urls 127.0.0.1:13624 \
--bidder-rpc-urls 127.0.0.1:13724
--bidder-rpc-urls 127.0.0.1:13724 \
--relay-endpoint http://127.0.0.1:8082
- name: Notify - Deployment Successful
if: ${{ env.IS_MANUAL_DEPLOYMENT == 'true' && success() }}
Expand Down
10 changes: 8 additions & 2 deletions bridge/standard/cmd/emulator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,18 +223,21 @@ func main() {
continue
}
startTime := time.Now()
statusC := tSettlement.Do(ctx)
cctx, cancel := context.WithTimeout(ctx, 15*time.Minute)
statusC := tSettlement.Do(cctx)
for status := range statusC {
if status.Error != nil {
logger.Error("failed transfer to settlement", "error", status.Error)
bridgeFailureDurations.WithLabelValues(
txtors[0].GetAddress().String(),
"L1->Settlement",
).Set(time.Since(startTime).Seconds())
cancel()
continue RESTART
}
logger.Info("transfer to settlement status", "message", status.Message)
}
cancel()
completionTimeSec := time.Since(startTime).Seconds()
logger.Info("completed settlement transfer",
"time", completionTimeSec,
Expand Down Expand Up @@ -268,18 +271,21 @@ func main() {
continue
}
startTime = time.Now()
statusC = tL1.Do(ctx)
cctx, cancel = context.WithTimeout(ctx, 15*time.Minute)
statusC = tL1.Do(cctx)
for status := range statusC {
if status.Error != nil {
logger.Error("failed transfer to L1", "error", status.Error)
bridgeFailureDurations.WithLabelValues(
txtors[0].GetAddress().String(),
"Settlement->L1",
).Set(time.Since(startTime).Seconds())
cancel()
continue RESTART
}
logger.Info("transfer to L1 status", "message", status.Message)
}
cancel()
completionTimeSec = time.Since(startTime).Seconds()
logger.Info("completed L1 transfer",
"time", completionTimeSec,
Expand Down
51 changes: 48 additions & 3 deletions contracts-abi/abi/BlockTracker.abi
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,19 @@
],
"stateMutability": "view"
},
{
"type": "function",
"name": "providerRegistry",
"inputs": [],
"outputs": [
{
"name": "",
"type": "address",
"internalType": "contract IProviderRegistry"
}
],
"stateMutability": "view"
},
{
"type": "function",
"name": "proxiableUUID",
Expand All @@ -265,9 +278,9 @@
"internalType": "uint256"
},
{
"name": "_winnerGraffiti",
"type": "string",
"internalType": "string"
"name": "_winnerBLSKey",
"type": "bytes",
"internalType": "bytes"
}
],
"outputs": [],
Expand All @@ -293,6 +306,19 @@
"outputs": [],
"stateMutability": "nonpayable"
},
{
"type": "function",
"name": "setProviderRegistry",
"inputs": [
{
"name": "newProviderRegistry",
"type": "address",
"internalType": "address"
}
],
"outputs": [],
"stateMutability": "nonpayable"
},
{
"type": "function",
"name": "transferOwnership",
Expand Down Expand Up @@ -471,6 +497,25 @@
],
"anonymous": false
},
{
"type": "event",
"name": "ProviderRegistrySet",
"inputs": [
{
"name": "oldProviderRegistry",
"type": "address",
"indexed": true,
"internalType": "address"
},
{
"name": "newProviderRegistry",
"type": "address",
"indexed": true,
"internalType": "address"
}
],
"anonymous": false
},
{
"type": "event",
"name": "Unpaused",
Expand Down
70 changes: 59 additions & 11 deletions contracts-abi/abi/ProviderRegistry.abi
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,25 @@
],
"stateMutability": "view"
},
{
"type": "function",
"name": "blockBuilderBLSKeyToAddress",
"inputs": [
{
"name": "",
"type": "bytes",
"internalType": "bytes"
}
],
"outputs": [
{
"name": "",
"type": "address",
"internalType": "address"
}
],
"stateMutability": "view"
},
{
"type": "function",
"name": "delegateRegisterAndStake",
Expand All @@ -87,9 +106,9 @@
"internalType": "address"
},
{
"name": "blsPublicKey",
"type": "bytes",
"internalType": "bytes"
"name": "blsPublicKeys",
"type": "bytes[]",
"internalType": "bytes[]"
}
],
"outputs": [],
Expand All @@ -110,12 +129,17 @@
},
{
"type": "function",
"name": "eoaToBlsPubkey",
"name": "eoaToBlsPubkeys",
"inputs": [
{
"name": "",
"type": "address",
"internalType": "address"
},
{
"name": "",
"type": "uint256",
"internalType": "uint256"
}
],
"outputs": [
Expand Down Expand Up @@ -155,7 +179,7 @@
},
{
"type": "function",
"name": "getBLSKey",
"name": "getBLSKeys",
"inputs": [
{
"name": "provider",
Expand All @@ -166,10 +190,29 @@
"outputs": [
{
"name": "",
"type": "bytes[]",
"internalType": "bytes[]"
}
],
"stateMutability": "view"
},
{
"type": "function",
"name": "getEoaFromBLSKey",
"inputs": [
{
"name": "blsKey",
"type": "bytes",
"internalType": "bytes"
}
],
"outputs": [
{
"name": "",
"type": "address",
"internalType": "address"
}
],
"stateMutability": "view"
},
{
Expand Down Expand Up @@ -405,9 +448,9 @@
"name": "registerAndStake",
"inputs": [
{
"name": "blsPublicKey",
"type": "bytes",
"internalType": "bytes"
"name": "blsPublicKeys",
"type": "bytes[]",
"internalType": "bytes[]"
}
],
"outputs": [],
Expand Down Expand Up @@ -877,10 +920,10 @@
"internalType": "uint256"
},
{
"name": "blsPublicKey",
"type": "bytes",
"name": "blsPublicKeys",
"type": "bytes[]",
"indexed": false,
"internalType": "bytes"
"internalType": "bytes[]"
}
],
"anonymous": false
Expand Down Expand Up @@ -992,6 +1035,11 @@
}
]
},
{
"type": "error",
"name": "AtLeastOneBLSKeyRequired",
"inputs": []
},
{
"type": "error",
"name": "BidderAmountIsZero",
Expand Down
231 changes: 218 additions & 13 deletions contracts-abi/clients/BlockTracker/BlockTracker.go

Large diffs are not rendered by default.

184 changes: 123 additions & 61 deletions contracts-abi/clients/ProviderRegistry/ProviderRegistry.go

Large diffs are not rendered by default.

15 changes: 11 additions & 4 deletions contracts/contracts/core/BlockTracker.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ pragma solidity 0.8.26;

import {IBlockTracker} from "../interfaces/IBlockTracker.sol";
import {BlockTrackerStorage} from "./BlockTrackerStorage.sol";
import {IProviderRegistry} from "../interfaces/IProviderRegistry.sol";
import {Ownable2StepUpgradeable} from "@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol";
import {UUPSUpgradeable} from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
import {PausableUpgradeable} from "@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol";
Expand Down Expand Up @@ -65,20 +66,20 @@ contract BlockTracker is IBlockTracker, BlockTrackerStorage,
string calldata builderName,
address builderAddress
) external onlyOracle whenNotPaused {
blockBuilderNameToAddress[builderName] = builderAddress;
emit BuilderAddressAdded(builderName, builderAddress);
blockBuilderNameToAddress[builderName] = builderAddress;
}

/**
* @dev Records a new L1 block and its winner.
* @param _blockNumber The number of the new L1 block.
* @param _winnerGraffiti The graffiti of the winner of the new L1 block.
* @param _winnerBLSKey The BLS key of the winner of the new L1 block.
*/
function recordL1Block(
uint256 _blockNumber,
string calldata _winnerGraffiti
bytes calldata _winnerBLSKey
) external onlyOracle whenNotPaused {
address _winner = blockBuilderNameToAddress[_winnerGraffiti];
address _winner = providerRegistry.getEoaFromBLSKey(_winnerBLSKey);
_recordBlockWinner(_blockNumber, _winner);
uint256 newWindow = (_blockNumber - 1) / WindowFromBlockNumber.BLOCKS_PER_WINDOW + 1;
if (newWindow > currentWindow) {
Expand All @@ -89,6 +90,12 @@ contract BlockTracker is IBlockTracker, BlockTrackerStorage,
emit NewL1Block(_blockNumber, _winner, currentWindow);
}

/// @dev Allows the owner to set the provider registry.
function setProviderRegistry(address newProviderRegistry) external onlyOwner {
emit ProviderRegistrySet(address(providerRegistry), newProviderRegistry);
providerRegistry = IProviderRegistry(newProviderRegistry);
}

/// @dev Allows the owner to set the oracle account.
function setOracleAccount(address newOracleAccount) external onlyOwner {
_setOracleAccount(newOracleAccount);
Expand Down
5 changes: 5 additions & 0 deletions contracts/contracts/core/BlockTrackerStorage.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// SPDX-License-Identifier: BSL 1.1
pragma solidity 0.8.26;

import {IProviderRegistry} from "../interfaces/IProviderRegistry.sol";

abstract contract BlockTrackerStorage {
/// @dev Permissioned address of the oracle account.
address public oracleAccount;
Expand All @@ -13,6 +15,9 @@ abstract contract BlockTrackerStorage {
/// @dev Maps builder names to their respective Ethereum addresses.
mapping(string => address) public blockBuilderNameToAddress;

/// @dev Interface for the ProviderRegistry contract
IProviderRegistry public providerRegistry;

/// @dev See https://docs.openzeppelin.com/upgrades-plugins/1.x/writing-upgradeable#storage-gaps
uint256[48] private __gap;
}
Loading

0 comments on commit 0a2f8ff

Please sign in to comment.