Skip to content

Commit

Permalink
Merge pull request #90 from worldcoin/dcbuild3r/base-testnet
Browse files Browse the repository at this point in the history
add Base OP-Stack support
  • Loading branch information
dcbuild3r authored Aug 4, 2023
2 parents 11db1e7 + 566898c commit 3825784
Show file tree
Hide file tree
Showing 29 changed files with 499 additions and 164 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
# world-id-state-bridge

![spec](https://raw.githubusercontent.com/worldcoin/world-id-state-bridge/2cba98da38cfc5173ad773824126ce4285d240b1/docs/state-bridge.svg)
![spec](docs/state-bridge2.svg)

## Description

State bridge between the WorldID Ethereum mainnet deployment and WorldID supported networks. The [spec](./docs/spec.md)
can be found in `docs/spec.md`.

## Deployments

The addresses of the contract deployments for production and staging can be found in
[`docs/deployments.md`](./docs/deployments.md).

## Supported networks

Currently, the supported networks are Polygon PoS (for backwards compatibility) and Optimism. The next iteration of the
Expand Down
23 changes: 23 additions & 0 deletions docs/deployments.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Addresses of the production and staging deployments

## Production

### Orb (group id: 1)

- WorldID State Bridge (Ethereum mainnet):
[0x86d26ed31556ea7694bd0cc4e674d7526f70511a](https://etherscan.io/address/0x86d26ed31556ea7694bd0cc4e674d7526f70511a#code)
- OpWorldID (Optimism mainnet):
[0x42ff98c4e85212a5d31358acbfe76a621b50fc02](https://optimistic.etherscan.io/address/0x42ff98c4e85212a5d31358acbfe76a621b50fc02#code)
- PolygonWorldID (Polygon PoS mainnet):
[0x2Ad412A1dF96434Eed0779D2dB4A8694a06132f8](https://polygonscan.com/address/0x2Ad412A1dF96434Eed0779D2dB4A8694a06132f8#code)

## Staging

### Orb (group id: 1)

- WorldID State Bridge (Ethereum Goerli):
[0xCD60dA00e20bE3d23e2E135283423FD86867C98D](https://goerli.etherscan.io/address/0xcd60da00e20be3d23e2e135283423fd86867c98d#code)
- OpWorldID (Optimism Goerli):
[0x2a0c0DBEcC7E4D658f48E01e3fA353F44050c208](https://goerli.optimistic.etherscan.io/address/0x2a0c0DBEcC7E4D658f48E01e3fA353F44050c208#code)
- PolygonWorldID (Polygon Mumbai):
[0x8d6308aC8d34088587Ef345736389Ee915e2A9dA](https://mumbai.polygonscan.com/address/0x8d6308aC8d34088587Ef345736389Ee915e2A9dA#code)
42 changes: 4 additions & 38 deletions docs/spec.md
Original file line number Diff line number Diff line change
@@ -1,45 +1,11 @@
# State Bridge spec

## Design iteration

1. Push-based approach (current - v0.1.0)

- [`registerIdentities`](https://github.com/worldcoin/world-id-contracts/blob/98f4d6ae959a5a8a3c5ad5b57086e01d999d1b83/src/WorldIDIdentityManagerImplV1.sol#L288-L355)
in
[`WorldIDIdentityManagerImplV1.sol`](https://github.com/worldcoin/world-id-contracts/src/WorldIDIdentityManagerImplV1.sol)
calls a method in the [`StateBridge.sol`](../src/StateBridge.sol) contract that sends over each new state root and its
timestamp.

- Downsides:
- Hard to scale, redeploying semaphore, separate impls for diff L2s

2. Pull-based approach (CRON)

- status: archived
- idea: proxy contract you can send state roots, checks against semaphore if they are correct and proceeds to send them
to L2s. Service like Gelato periodically fetches latest state roots and checks agains semaphore before submitting to
proxy

3. Pull-based approach (external service)

- status: ideation, strong candidate the for next iteration of the state bridge functionality
- idea: leverage storage proofs of `WorldIDIdentityManager` contract on L1 and run an external relayer service that
would update all of the supported target chain contracts by providing a new root, the block timestamp and a storage
proof from Ethereum mainnet. This approach is easily generalizable to any target chain that supports the cryptography
needed to deploy a Semaphore verifier and a storage proof verifier. For EVM-based chain it is a trivial change as
contracts for this are already implemented and would only require a \<targetChain\>WorldID contract deployment and
integration to the state relayer service.

- Upsides:
- generalizeable
- proper solution (conceptually simpler, no ownability required)
- Downsides:
- non-trivial implementation for storage proofs on non-EVM chains

## Structure

![state-bridge.svg](state-bridge.svg)

Propagates new World ID merkle tree roots from the `WorldIDIdentityManager` contract
([`world-id-contracts`](https://github.com/worldcoin/world-id-contracts) repo) on Ethereum mainnet to Optimism and
Polygon PoS.

Currently the state bridge supports Optimism and Polygon PoS. The root and the timestamp get sent from
[`StateBridge.sol`](../src/StateBridge.sol) to the [`OpWorldID.sol`](../src/OpWorldID.sol) contract on the Optimism L2
which accepts them in order to allow developers on Optimism to call `verifyProof` on [WorldID](https://id.worldcoin.org)
Expand Down
17 changes: 17 additions & 0 deletions docs/state-bridge2.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 1 addition & 3 deletions src/OpWorldID.sol
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
// SPDX-License-Identifier: UNLICENSED
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.15;

import {WorldIDBridge} from "./abstract/WorldIDBridge.sol";

import {IOpWorldID} from "./interfaces/IOpWorldID.sol";
import {SemaphoreTreeDepthValidator} from "./utils/SemaphoreTreeDepthValidator.sol";
import {SemaphoreVerifier} from "semaphore/base/SemaphoreVerifier.sol";
import {CrossDomainOwnable3} from
"@eth-optimism/contracts-bedrock/contracts/L2/CrossDomainOwnable3.sol";

Expand Down
2 changes: 1 addition & 1 deletion src/PolygonWorldID.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-License-Identifier: UNLICENSED
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.15;

import {WorldIDBridge} from "./abstract/WorldIDBridge.sol";
Expand Down
Loading

0 comments on commit 3825784

Please sign in to comment.