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

Relay upgrade #373

Merged
merged 21 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
e287fe0
refactor(relay): Rename relay setup script to a more descriptive name
kkirkov Jul 29, 2024
1f1b0af
refactor(relay): Add better descriptions to process-compose tasks
kkirkov Jul 29, 2024
98d51ee
refactor(relay): Add ZKEY_DOWNLOAD_URL env var for faster download
kkirkov Jul 29, 2024
04a5c14
feat(relay): Use readiness_probe for proverserver not check-proverser…
kkirkov Jul 29, 2024
2cfa3f1
feat(relay):Log link to transaction
kkirkov Jul 29, 2024
44f34d0
refactor(relay): Add union type `NetworkConfig`
kkirkov Aug 5, 2024
bc0af24
fix(tsconfig): Fix import in a ts file by adding a json to `tsconfig.…
kkirkov Aug 5, 2024
08facde
refactor(env): Remove `getRootDir` func and use `rootDir` everywhere
kkirkov Aug 5, 2024
ecb56d0
refactor(ssz-utils): Add return type to `computeSyncCommitteePeriodAt
kkirkov Aug 5, 2024
88d7573
refactor(relay): Start proverServer from process-compose directly
kkirkov Aug 16, 2024
3b4bee4
refactor(relay): Run redis from the correct ignored folder
kkirkov Aug 26, 2024
d414b19
refactor(relay): Remove `run-relay.sh` - use process-compose only dir…
kkirkov Aug 26, 2024
2686ad2
refactor(relay):Make reyaler work when `REDIS_HOST` and `REDIS_PORT` …
kkirkov Aug 27, 2024
087c6aa
feat(relay): Update relay to work with finalized header DendrethAdada…
Dimo99 Aug 27, 2024
6e6e2e1
feat: Update to the new snarkjs verifier
Dimo99 Sep 4, 2024
c9e6ce4
refactor(relay): Use `follow-network` instead of `network` in logs
kkirkov Sep 5, 2024
85631f0
refactor(.env): Update `.env.example`
kkirkov Sep 10, 2024
88976d9
feat(relay): Add script that msgs a discord channel if a contract is …
kkirkov Sep 11, 2024
644f95d
fix(tests): Update BeaconLightClient tests
Dimo99 Sep 13, 2024
38a6a83
fix(discord-bot): Tag everyone when alerting
Dimo99 Sep 13, 2024
150bb83
feat(relay): Introduce additional networks
Dimo99 Sep 13, 2024
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
47 changes: 45 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
USER_PRIVATE_KEY=private_key
ALCHEMY_API_KEY=api_key
USER_PRIVATE_KEY_FILE=/.secrets/user_private_key
INFURA_API_KEY_FILE=/.secrets/infura_api_key
ALCHEMY_API_KEY_FILE=/.secrets/alchemy_api_key
ETHERSCAN_API_KEY_FILE=/.secrets/etherscan_api_key
BASE_ETHERSCAN_API_KEY_FILE=/.secrets/base_etherscan_api_key
POLYGON_MUMBAI_ETHERSCAN_API_KEY_FILE=/.secrets/polygon_mumbai_etherscan_api_key
POLYGON_ZK_ETHERSCAN_API_KEY_FILE=/.secrets/polygon_zk_etherscan_api_key
ARBITRUM_ETHERSCAN_API_KEY_FILE=/.secrets/arbitrum_etherscan_api_key
OPTIMISM_ETHERSCAN_API_KEY_FILE=/.secrets/optimism_etherscan_api_key
AVALANCHE_FUJI_ETHERSCAN_API_KEY_FILE=/.secrets/avalanche_fuji_etherscan_api_key
FTM_ETHERSCAN_API_KEY_FILE=/.secrets/ftm_etherscan_api_key
CELO_ETHERSCAN_API_KEY_FILE=/.secrets/celo_etherscan_api_key
BSC_ETHERSCAN_API_KEY_FILE=/.secrets/bsc_etherscan_api_key
CHIADO_ETHERSCAN_API_FILE=/.secrets/chiado_etherscan_api
GNOSIS_ETHERSCAN_API_FILE=/.secrets/gnosis_etherscan_api
BEACON_REST_API_PRATTER=
BEACON_REST_API_MAINNET=
BEACON_REST_API_SEPOLIA=
BEACON_REST_API_CHIADO=
BEACON_REST_API_GNOSIS=
REDIS_HOST=localhost
REDIS_PORT=6379
PROVER_SERVER_HOST=http://127.0.0.1
Expand All @@ -13,6 +31,7 @@ LC_OPTIMISTIC_GOERLI=
LC_BASE_GOERLI=
LC_ARBITRUM_GOERLI=
LC_SEPOLIA=
FOLLOW_NETWORK_SEPOLIA=chiado
LC_MUMBAI=
LC_FUJI=
LC_FANTOM=
Expand All @@ -21,9 +40,15 @@ LC_BSC=
LC_AURORA=
LC_GNOSIS=
LC_CHIADO=
FOLLOW_NETWORK_CHIADO=sepolia
LC_EVMOS=
LC_MALAGA=
LC_LUKSO=
FOLLOW_NETWORK_LUKSO=sepolia
GOERLI_HASHI=0x4169ea397fe83F55e732E11390807b3722374f78
MAINNET_HASHI=
FOLLOW_NETWORK_MAINNET=
FOLLOW_NETWORK_GNOSIS=
OPTIMISTIC_HASHI=''
BASE_HASHI=''
ARBITRUM_HASHI=''
Expand All @@ -38,3 +63,21 @@ AURORA_HASHI=''
GNOSIS_HASHI=''
FUJI_HASHI=''
BSC_HASHI=''
LUKSO_HASHI=''
MAINNET_RPC=
ROPSTEN_RPC=
SEPOLIA_RPC=
GOERLI_RPC=
OPTIMISTIC_GOERLI_RPC=
BASE_GOERLI_RPC=
ARBITRUM_GOERLI_RPC=
MUMBAI_RPC=
AVALANCHE_RPC=
FANTOM_RPC=
CELO_RPC=
BSC_RPC=
CHIADO_RPC=
GNOSIS_RPC=
EVMOS_RPC=
AURORA_RPC=
LUKSO_RPC=
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ env:
INFURA_API_KEY: '${{ secrets.INFURA_API_KEY }}'
USER_PRIVATE_KEY: '${{ secrets.USER_PRIVATE_KEY }}'
ETHERSCAN_API_KEY: '${{ secrets.ETHERSCAN_API_KEY }}'
ETHEREUM_MAINNET_RPC: https://eth.llamarpc.com
MAINNET_RPC: https://rpc.mevblocker.io
jobs:
Linter:
runs-on: self-hosted
Expand Down
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,4 @@
url = https://github.com/ethereum/consensus-spec-tests.git
[submodule "vendor/snarkjs"]
path = vendor/snarkjs
url = [email protected]:iden3/snarkjs.git
url = [email protected]:metacraft-labs/snarkjs.git
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,35 @@
pragma solidity 0.8.9;

interface ILightClient {
function currentIndex() external view returns (uint256);
struct LightClientUpdate {
bytes32 attestedHeaderRoot;
uint256 attestedHeaderSlot;
bytes32 finalizedHeaderRoot;
bytes32 finalizedExecutionStateRoot;
uint256[2] a;
uint256[2][2] b;
uint256[2] c;
}

function optimisticHeaderRoot() external view returns (bytes32);
function currentIndex() external view returns (uint256);

function optimisticHeaderSlot() external view returns (uint256);
function optimisticHeaderRoot() external view returns (bytes32);

function finalizedHeaderRoot() external view returns (bytes32);
function optimisticHeaderSlot() external view returns (uint256);

function executionStateRoot() external view returns (bytes32);
function finalizedHeaderRoot() external view returns (bytes32);

function optimisticHeaders(uint256 index) external view returns (bytes32);
function executionStateRoot() external view returns (bytes32);

function optimisticSlots(uint256 index) external view returns (uint256);
function optimisticHeaders(uint256 index) external view returns (bytes32);

function finalizedHeaders(uint256 index) external view returns (bytes32);
function optimisticSlots(uint256 index) external view returns (uint256);

function executionStateRoots(uint256 index) external view returns (bytes32);
function finalizedHeaders(uint256 index) external view returns (bytes32);

function executionStateRoots(uint256 index) external view returns (bytes32);

function lightClientUpdate(
LightClientUpdate calldata update
) external payable;
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,6 @@ import '../../interfaces/ILightClient.sol';
uint256 constant BUFER_SIZE = 32;

contract BeaconLightClient is LightClientUpdateVerifier, ILightClient {
struct LightClientUpdate {
bytes32 attestedHeaderRoot;
uint256 attestedHeaderSlot;
bytes32 finalizedHeaderRoot;
bytes32 finalizedExecutionStateRoot;
uint256[2] a;
uint256[2][2] b;
uint256[2] c;
}

bytes32[BUFER_SIZE] public optimisticHeaders;

uint256[BUFER_SIZE] public optimisticSlots;
Expand Down Expand Up @@ -62,7 +52,7 @@ contract BeaconLightClient is LightClientUpdateVerifier, ILightClient {
}

// TODO: fix name to lightClientUpdate
function light_client_update(LightClientUpdate calldata update)
function lightClientUpdate(LightClientUpdate calldata update)
external
payable
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ pragma solidity 0.8.9;

import './Verifier.sol';

contract LightClientUpdateVerifier is Verifier {
contract LightClientUpdateVerifier is Groth16Verifier {
error VerificationCallFailed();

function verifyUpdate(
uint256[2] memory a,
uint256[2][2] memory b,
Expand All @@ -14,7 +16,7 @@ contract LightClientUpdateVerifier is Verifier {
bytes32 finalizedHeaderRoot,
bytes32 executionStateRoot,
bytes32 domain
) internal view returns (bool) {
) internal returns (bool) {
bytes memory concatenated = abi.encodePacked(prevHeaderHash, nextHeaderHash, finalizedHeaderRoot, executionStateRoot, nextHeaderSlot, domain);
bytes32 commitment = sha256(concatenated);

Expand All @@ -23,6 +25,16 @@ contract LightClientUpdateVerifier is Verifier {
input[0] = (uint256(commitment) & (((1 << 253) - 1) << 3)) >> 3;
input[1] = (uint256(commitment) & ((1 << 3) - 1));

return verifyProof(a, b, c, input);
(bool success, bytes memory returnData) = address(this).call(
// Encode the call to the `verify` function with the public inputs
abi.encodeWithSelector(Groth16Verifier.verifyProof.selector, a, b, c, input)
);

// Check if the call was successful
if (!success) {
revert VerificationCallFailed();
}

return abi.decode(returnData, (bool));
}
}
Loading