diff --git a/Makefile b/Makefile index 4b972b207..138ba4b0a 100644 --- a/Makefile +++ b/Makefile @@ -29,6 +29,7 @@ L2_CHAIN_ID?=$(shell \ ) L2_CHAIN_ID_HEX:=$(shell printf "0x%064x" $(L2_CHAIN_ID)) PORTAL?=http://0.0.0.0:8080 +REGISTRY?=http://0.0.0.0:8082 TXPROXY?=http://0.0.0.0:8090 L1_RPC_URL?=https://ethereum-sepolia-rpc.publicnode.com L1_BEACON_RPC_URL?=https://ethereum-sepolia-beacon-api.publicnode.com @@ -129,6 +130,7 @@ start-based-gateway: create-network echo "Gateway Sequencing Wallet: $(GATEWAY_SEQUENCING_ADDRESS)"; \ { \ echo "PORTAL=$(PORTAL)"; \ + echo "REGISTRY=$(REGISTRY)"; \ echo "OP_NODE_GOSSIP_IP=$(PUBLIC_IP)"; \ echo "GATEWAY_SEQUENCING_KEY=$(GATEWAY_SEQUENCING_KEY)"; \ echo "MAIN_OP_NODE_GOSSIP_STATIC=$$(curl -s -X POST -H 'Content-Type: application/json' \ @@ -193,13 +195,12 @@ start-based-gateway: create-network echo "Calling registerGateway method via JSON-RPC:"; \ GATEWAY_URL=http://$(PUBLIC_IP):$$(grep -m1 '^GATEWAY_PORT[[:space:]]*=' .local_gateway_and_follower/.env | cut -d= -f2); \ GATEWAY_ADDRESS=$$wallet; \ - JWT=$$(cat .local_gateway_and_follower/config/jwt); \ - curl -X POST "$(PORTAL)" \ + curl -X POST "$(REGISTRY)" \ -H "Content-Type: application/json" \ -d "{\"jsonrpc\":\"2.0\", \ \"method\":\"registry_registerGateway\", \ \"params\":[ \ - [\"$$GATEWAY_URL\", \"$(GATEWAY_SEQUENCING_ADDRESS)\", \"$$JWT\"] \ + [\"$$GATEWAY_URL\", \"$(GATEWAY_SEQUENCING_ADDRESS)\"] \ ], \ \"id\":1}"; \ echo; echo @@ -209,7 +210,7 @@ start-based-gateway: create-network $(MAKE) start-overseer start-overseer: - docker exec -it based-gateway overseer --portal-url $(PORTAL) --rich-wallet-key $(DUMMY_RICH_WALLET_PRIVATE_KEY) + docker exec -it based-gateway overseer --portal-url $(PORTAL) --registry-url $(REGISTRY) --rich-wallet-key $(DUMMY_RICH_WALLET_PRIVATE_KEY) # start spamoor as a foreground process start-spamoor: diff --git a/README.md b/README.md index e80bc0655..de917074e 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,7 @@ A couple of commands tend to come in handy (from the top `based-op` directory): ### Add/Update based-gateways to Registry -When a based-gateway is started with `just follower-node start`, it will register itself to the Registry behind the `PORTAL`. For now, the Registry is kept in a simple json file in `.local_main_node/config/registry.json`. You can add/update/remove gateways there, the Registry and Portal will pick up on the changes every minute. +When a based-gateway is started with `just follower-node start`, it will register itself directly to the Registry (via `REGISTRY`, default `http://localhost:8082`). For now, the Registry is kept in a simple json file in `.local_main_node/config/registry.json`. You can add/update/remove gateways there, and the Registry/Portal will pick up on the changes every minute. If you have started both the main sequencing node and the gateway on the same machine, you might need to change the ip to `0.0.0.0`, by default `curl ifconfig.me` is used to populate your url. diff --git a/based/bin/overseer/src/main.rs b/based/bin/overseer/src/main.rs index 40adf69aa..9fecb9a5f 100644 --- a/based/bin/overseer/src/main.rs +++ b/based/bin/overseer/src/main.rs @@ -50,6 +50,9 @@ pub struct OverseerArgs { /// The url of the portal that is connected to the main sequencer node #[arg(short, long)] pub portal_url: Url, + /// The url of the registry for gateway `registration/listing` + #[arg(long)] + pub registry_url: Url, /// The url of the based-op-node running next to the based-gateway #[arg(long, default_value = "http://127.0.0.1:8547")] pub based_op_node_url: Url, @@ -114,6 +117,7 @@ struct OverseerConnections { walkie_talkie: WalkieTalkie, runtime: tokio::runtime::Runtime, client_portal: HttpClient, + client_registry: HttpClient, client_based_op_node: HttpClient, client_based_op_geth: HttpClient, rollup_config: RollupConfig, @@ -127,6 +131,8 @@ impl OverseerConnections { .expect("Couldn't initialize tokio runtime"); let client_portal = HttpClient::builder().build(args.portal_url.clone()).expect("Couldn't initialize portal rpc client"); + let client_registry = + HttpClient::builder().build(args.registry_url.clone()).expect("Couldn't initialize registry rpc client"); let client_based_op_node = HttpClient::builder() .build(args.based_op_node_url.clone()) .expect("Couldn't initialize based-op-node rpc client"); @@ -142,6 +148,7 @@ impl OverseerConnections { telemetry: telemetry_queue().into(), runtime, client_portal, + client_registry, client_based_op_node, client_based_op_geth, rollup_config, @@ -162,7 +169,7 @@ impl OverseerConnections { } pub fn current_gateway(&self) -> Result<(Url, Address), ClientError> { - self.runtime.block_on(self.client_portal.current_gateway()).map(|(_, url, address)| (url, address)) + self.runtime.block_on(self.client_registry.current_gateway()).map(|(_, url, address)| (url, address)) } pub fn peers_based_op_node(&self) -> Result, ClientError> { diff --git a/based/bin/portal/src/middleware.rs b/based/bin/portal/src/middleware.rs index ea8cb423b..1a1cc61dc 100644 --- a/based/bin/portal/src/middleware.rs +++ b/based/bin/portal/src/middleware.rs @@ -24,7 +24,6 @@ use crate::clients::{AuthRpcClient, RpcClient}; pub struct EngineApiProxy { pub inner: S, pub geth_client: AuthRpcClient, - pub registry_client: RpcClient, pub op_node_client: RpcClient, pub metrics: Producer, } @@ -42,7 +41,6 @@ where let inner = self.inner.clone(); let method = req.method_name().to_string(); let fallback_client = self.geth_client.clone(); - let registry_client = self.registry_client.clone(); let op_node_client = self.op_node_client.clone(); let uuid = uuid(); @@ -67,11 +65,6 @@ where inner.call(req).await; res } - Some(("registry", _)) => { - debug!(method = %method, "Received request in RegistryApiProxy"); - MetricsUpdate::send_ref(uuid, Metric::IncrementCounter(Counter::RegistryApiRequests, 1), &metrics); - external_call(registry_client.clone(), &req).await - } Some(("optimism", _)) | Some(("opp2p", _)) => { debug!(method = %method, "Received request for OP node"); MetricsUpdate::send_ref(uuid, Metric::IncrementCounter(Counter::OpNodeApiRequests, 1), &metrics); diff --git a/based/bin/portal/src/server.rs b/based/bin/portal/src/server.rs index c316c36ef..b205fac25 100644 --- a/based/bin/portal/src/server.rs +++ b/based/bin/portal/src/server.rs @@ -84,14 +84,12 @@ impl PortalServer { pub async fn run(self, addr: SocketAddr) -> eyre::Result<()> { let geth_engine_client = self.geth_engine_client.clone(); - let registry_client = self.gateway_manager.registry_client.clone(); let op_node_client = self.op_node_client.clone(); let metrics = self.metrics; let rpc_middleware = RpcServiceBuilder::new().layer_fn(move |s| EngineApiProxy { inner: s, geth_client: geth_engine_client.clone(), - registry_client: registry_client.clone(), op_node_client: op_node_client.clone(), metrics, }); diff --git a/based/follower-node.just b/based/follower-node.just index 562724923..0dd62afcf 100644 --- a/based/follower-node.just +++ b/based/follower-node.just @@ -18,6 +18,7 @@ export FOLLOWER_NODE_DIR := join(justfile_directory(), "..", "follower_node") # External environment configuration export PORTAL := shell("echo ${PORTAL:-$(" + portal + " address)}") +export REGISTRY := shell("echo ${REGISTRY:-$(" + registry + " address)}") # Force config creation export FORCE := env("FORCE", "") @@ -32,6 +33,7 @@ PORTAL_TIMEOUT := env("PORTAL_TIMEOUT", "30") self := "just -f " + justfile() parent := "just -f " + join(justfile_directory(), "..", "Justfile") portal := "just -f " + join(justfile_directory(), "portal.just") +registry := "just -f " + join(justfile_directory(), "registry.just") wallet := "just -f " + join(justfile_directory(), "scripts", "wallet.just") link := "just -f " + join(justfile_directory(), "scripts", "link.just") @@ -45,6 +47,7 @@ _generate-dotenv gossip enr enode $dotenv=join(FOLLOWER_NODE_DATA, ".env"): l2_chain_id=$({{portal}} l2_chain_id) echo "PORTAL=$PORTAL" >> $dotenv + echo "REGISTRY=$REGISTRY" >> $dotenv echo "OP_NODE_GOSSIP_IP=$PUBLIC_IP" >> $dotenv echo "GATEWAY_SEQUENCING_KEY=$GATEWAY_SEQUENCING_KEY" >> $dotenv echo "MAIN_OP_NODE_GOSSIP_STATIC={{gossip}}" >> $dotenv @@ -188,10 +191,8 @@ start-dev $dotenv=join(FOLLOWER_NODE_DATA, ".env") network="based_op_node": (doc port=$(grep -m1 '^GATEWAY_PORT[[:space:]]*=' $dotenv | cut -d= -f2) address=$({{wallet}} address {{WALLET_NAME}}) - jwt=$(cat $FOLLOWER_NODE_DATA/config/jwt) - echo "Registering gateway" - {{portal}} register-gateway "http://$ip:$port" "$address" "$jwt" + {{registry}} register-gateway "http://$ip:$port" "$address" # Start services echo "Starting gateway and monitoring services..." diff --git a/based/overseer.just b/based/overseer.just index bdc297458..a86882765 100644 --- a/based/overseer.just +++ b/based/overseer.just @@ -6,4 +6,5 @@ parent := "just -f " + join(justfile_directory(), "..", "Justfile") @start: docker exec -it based-gateway overseer \ --portal-url $({{parent}} portal address) \ + --registry-url $({{parent}} registry address) \ --rich-wallet-key {{DUMMY_RICH_WALLET_PRIVATE_KEY}} diff --git a/based/portal.just b/based/portal.just index 806dfa541..d75ef7f18 100644 --- a/based/portal.just +++ b/based/portal.just @@ -26,11 +26,6 @@ l2_chain_id: (_rpc "portal_l2ChainId") rollup: (_rpc "portal_fileRollup") genesis: (_rpc "portal_fileGenesis") -@register-gateway url address: - # The portal returns null on success so we remove the -e flag - JQ_ARGS="" {{self}} _rpc "registry_registerGateway" \ - "[[\"{{url}}\", \"{{address}}\"]]" - # Start the portal service and view logs (for main sequencing node) start: #!/usr/bin/env bash diff --git a/based/registry.just b/based/registry.just index e780263f1..e11ad24c9 100644 --- a/based/registry.just +++ b/based/registry.just @@ -5,6 +5,23 @@ self := "just -f " + justfile() service-name := "based-registry" +export REGISTRY_PORT := env("REGISTRY_PORT", "8082") +export REGISTRY := env("REGISTRY", "http://0.0.0.0:" + REGISTRY_PORT) +export JQ_ARGS := env("JQ_ARGS", "-e") + +@address: + echo $REGISTRY + +@_rpc method params="[]": + curl -s -X POST -H "Content-Type: application/json" \ + --data '{"jsonrpc": "2.0", "method": "{{method}}", "params": {{params}}, "id": 1}' \ + {{REGISTRY}} | jq -r $JQ_ARGS '.result' + +@register-gateway url address: + # The registry returns null on success so we remove the -e flag + JQ_ARGS="" {{self}} _rpc "registry_registerGateway" \ + "[[\"{{url}}\", \"{{address}}\"]]" + # Start the registry service and view logs (for main sequencing node) start: #!/usr/bin/env bash diff --git a/docs/docs/getting_started/develop.md b/docs/docs/getting_started/develop.md index 5485d973b..c410c98d2 100644 --- a/docs/docs/getting_started/develop.md +++ b/docs/docs/getting_started/develop.md @@ -34,12 +34,12 @@ The following steps have been tested on Sepolia, with a previously deployed L2 c 7b. `make logs-main-node` to output logs of all the main services #### Run a based-gateway -1. run `make start-gateway PORTAL= GATEWAY_SEQUENCING_KEY=` +1. run `make start-gateway PORTAL= REGISTRY= GATEWAY_SEQUENCING_KEY=` 2. to stop the based gateway run `make stop-gateway` 3. for logs `make logs-gateway` #### Add/Update based-gateways to Registry -When a based-gateway is started with `make start-gateway`, it will register itself to the Registry behind the `PORTAL`. For now, the Registry is kept in a simple json file in `.local_main_node/config/registry.json`. You can add/update/remove gateways there, the Registry and Portal will pick up on the changes every minute. +When a based-gateway is started with `make start-gateway`, it will register itself directly to the Registry (via `REGISTRY`). For now, the Registry is kept in a simple json file in `.local_main_node/config/registry.json`. You can add/update/remove gateways there, and the Registry/Portal will pick up on the changes every minute. If you have started both the main sequencing node and the gateway on the same machine, you might need to change the ip to `0.0.0.0`, by default `curl ifconfig.me` is used to populate your url. diff --git a/follower_node/compose.dev.yml b/follower_node/compose.dev.yml index 069b4a293..0f32e30b1 100644 --- a/follower_node/compose.dev.yml +++ b/follower_node/compose.dev.yml @@ -78,7 +78,7 @@ services: - --safedb.path=/data/op-node/op-node-beacon-data - --p2p.static=$MAIN_OP_NODE_GOSSIP_STATIC - --rpc.enable-based - - --registry=$PORTAL + - --registry=$REGISTRY - --p2p.bootnodes=$MAIN_OP_NODE_ENR - --syncmode=execution-layer - --metrics.enabled=true diff --git a/follower_node/compose.prod.yml b/follower_node/compose.prod.yml index f3505a7a2..b46bcb56e 100644 --- a/follower_node/compose.prod.yml +++ b/follower_node/compose.prod.yml @@ -80,7 +80,7 @@ services: - --safedb.path=/data/op-node/op-node-beacon-data - --p2p.static=$MAIN_OP_NODE_GOSSIP_STATIC - --rpc.enable-based - - --registry=$PORTAL + - --registry=$REGISTRY - --p2p.bootnodes=$MAIN_OP_NODE_ENR - --syncmode=execution-layer - --metrics.enabled=true diff --git a/follower_node/env_example b/follower_node/env_example index b9830b619..6287329fa 100644 --- a/follower_node/env_example +++ b/follower_node/env_example @@ -9,3 +9,5 @@ OP_GETH_WS_PORT=8646 GATEWAY_PORT=9997 GATEWAY_PORT_NO_AUTH=9994 TXPROXY=http://localhost:8090 +PORTAL=http://localhost:8080 +REGISTRY=http://localhost:8082 diff --git a/follower_node_dockerized_network/compose.yml b/follower_node_dockerized_network/compose.yml index f1e113b85..96cded343 100644 --- a/follower_node_dockerized_network/compose.yml +++ b/follower_node_dockerized_network/compose.yml @@ -96,7 +96,7 @@ services: - --safedb.path=/data/op-node/op-node-beacon-data - --p2p.static=$MAIN_OP_NODE_GOSSIP_STATIC - --rpc.enable-based - - --registry=$PORTAL + - --registry=$REGISTRY - --p2p.bootnodes=$MAIN_OP_NODE_ENR - --syncmode=execution-layer volumes: diff --git a/follower_node_dockerized_network/env_example b/follower_node_dockerized_network/env_example index 39e6f7de4..b1a2c1852 100644 --- a/follower_node_dockerized_network/env_example +++ b/follower_node_dockerized_network/env_example @@ -7,3 +7,5 @@ OP_GETH_ENGINE_RPC_PORT=8651 OP_GETH_RPC_PORT=8645 OP_GETH_WS_PORT=8646 GATEWAY_PORT=9997 +PORTAL=http://host.docker.internal:8080 +REGISTRY=http://host.docker.internal:8082