Running a Facet Node
Introduction
To run a Facet node you will need two pieces of software: facet-node and facet-geth. This architecture follows the Consensus/Execution split on the Ethereum L1, with facet-node
acting as the consensus client and facet-geth
as the execution layer.
facet-geth is a fork of Optimism's op-geth. facet-node is modeled after op-node, though it isn't a fork.
How it works
facet-node
connects to an L1 Ethereum RPC server and monitors each L1 block for Facet transactions—i.e., transactions whose "to: address isaddress(0xface7)
or event logs whose first topic isbytes32(uint256(0xface7))
.facet-node
extracts the Facet transaction information and combines it with other data to form a transaction payload thatfacet-geth
can understand (this is called a "Deposit Transaction").facet-node
constructs a Facet block with these Deposit transactions and sends the block tofacet-geth
using the engine API. This is the same API Ethereum consensus clients use to tell the execution layer about new blocks.
facet-node
is stateless. All data required to operate facet-node
is stored in facet-geth.
Facet Genesis State
Facet's genesis block includes state from its initial pre-EVM implementation, [legacy] Facet. This state is deterministically generated by executing the latest Facet logic against historical [legacy] Facet transactions. From the perspective of running a Facet node all you need is the final genesis.json file which is included in the facet-geth
repository.
Installation
Clone
facet-node
:and
facet-geth
:Now
cd facet-node
Install Ruby Version Manager (RVM) if not already installed:
If you encounter GPG issues, run:
Install Ruby 3.3.4:
On macOS, if you encounter OpenSSL issues:
Run
rvm use 3.3.4
Run
bundle install
Set up Foundry (make sure you install it first):
Install PostgreSQL (if not already installed). You won't need to store any data, but the schema needs to be there:
Set up environment variables. First copy the .sample.env files to .env and .env.development and .env.test:
Now edit the files. Here's what the variables are for:
Variable | Description | Default/Example | Purpose |
---|---|---|---|
L1_NETWORK | Ethereum network to derive blocks from | "sepolia" or "mainnet" | Determines which Ethereum network Facet will sync from |
L1_GENESIS_BLOCK | Starting block number | "6924910" | Block number to start syncing from. Mainnet genesis: 18684899, Sepolia genesis: 5193574 |
LOCAL_GETH_DIR | Path to local geth directory | "/path/to/geth_dir" | Location where facet-geth is cloned |
GETH_RPC_URL | Authenticated RPC endpoint | "http://127.0.0.1:8551" | Used for authenticated connections to facet-geth |
NON_AUTH_GETH_RPC_URL | Non-authenticated RPC endpoint | "http://127.0.0.1:8545" | Used for non-authenticated connections to facet-geth |
GETH_DISCOVERY_PORT | P2P discovery port | "30303" | Port used by facet-geth for peer discovery |
BLOCK_IMPORT_BATCH_SIZE | Number of blocks per batch | "5" | Controls how many simultaneous RPC requests are made |
L1_RPC_URL | Ethereum RPC endpoint | "https://eth_rpc_url" | Source of L1 block data |
JWT_SECRET | Authentication secret | "0x0101..." | Must match value in /tmp/jwtsecret for auth |
DATABASE_URL | PostgreSQL connection string | "postgres://localhost/..." | Local Facet database. |
MIGRATION_MODE | Enable migration features | "false" | Only needed when creating genesis file |
FACET_V1_VM_DATABASE_URL | Legacy database connection | "" | Only needed when creating genesis file |
Put your JWT_SECRET in
/tmp/jwtsecret
on your local machine:Set up the local database:
Run the tests to ensure everything works.
Using facet-geth
facet-geth
To use facet-geth
to process blocks instead of just in a test:
From the
facet-node
directory, generate the geth initialization command.Copy the command, cd back into
facet-geth
, and run it. Note, this command will restart the chain from genesis, deleting any blocks you've already derived. If you want to just restart geth without doing this you should only run the /build/bin/geth command.Finally, cd back into
facet-node
and start deriving Facet blocks from L1 blocks:
You should now have facet-node
and facet-geth
set up and running!
Accessing Facet Data
You can use the geth's normal RPC API to get information about Facet blocks and transactions. For example eth_getBlockByNumber. You can also query the chain directly from the geth console which the above command launches. For example eth.getBlock(1).
From the perspective of querying data, Facet will behave identically to any other EVM chain.
Last updated