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

feat: streamer and member nodes #524

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
170 changes: 142 additions & 28 deletions cl/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,24 +105,6 @@ geth --verbosity 5 \
- `--syncmode full`: Synchronization mode.
- `--miner.recommit`: Frequency of miner recommit.

### Obtaining the Genesis Block Hash

You can obtain the genesis block hash by querying the latest block after initializing your node:

```bash
cast block latest -r http://localhost:8545
```

Look for the `hash` field in the output, which represents the latest block hash. Since the chain is just initialized, this will be the genesis block hash.

Alternatively, you can use `curl` to get the genesis block hash:

```bash
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getBlockByNumber","params":["0x0", false],"id":1}' -H "Content-Type: application/json" http://localhost:8545
```

Extract the `hash` value from the response and use it without `0x`.

## Running Redis

We will use Docker Compose to run Redis.
Expand Down Expand Up @@ -163,29 +145,27 @@ Ensure all dependencies are installed and build the application:

```bash
go mod tidy
go build -o consensus-client main.go
go build -o consensus-client cmd/redisapp/main.go
```

### Configuration
### Consensus Client Configuration

The consensus client can be configured via command-line flags, environment variables, or a YAML configuration file.

#### Command-Line Flags
#### Command-Line Flags for Streamer

- `--instance-id`: **(Required)** Unique instance ID for this node.
- `--eth-client-url`: Ethereum client URL (default: `http://localhost:8551`).
- `--jwt-secret`: JWT secret for Ethereum client.
- `--genesis-block-hash`: Genesis block hash.
- `--redis-addr`: Redis address (default: `127.0.0.1:7001`).
- `--evm-build-delay`: EVM build delay (default: `1s`).
- `--config`: Path to a YAML configuration file.

#### Environment Variables
#### Environment Variables for Consensus Client

- `RAPP_INSTANCE_ID`
- `RAPP_ETH_CLIENT_URL`
- `RAPP_JWT_SECRET`
- `RAPP_GENESIS_BLOCK_HASH`
- `RAPP_REDIS_ADDR`
- `RAPP_EVM_BUILD_DELAY`
- `RAPP_CONFIG`
Expand All @@ -199,25 +179,22 @@ Run the client using command-line flags:
--instance-id "node1" \
--eth-client-url "http://localhost:8551" \
--jwt-secret "your_jwt_secret" \
--genesis-block-hash "your_genesis_block_hash" \
--redis-addr "127.0.0.1:7001" \
--evm-build-delay "1s"
```

**Note**:

- Replace `"your_jwt_secret"` with the actual JWT secret you used earlier.
- Replace `"your_genesis_block_hash"` with the genesis block hash obtained earlier.

### Using a Configuration File
### Using a Configuration File for Consensus Client

Create a `config.yaml` file:

```yaml
instance-id: "node1"
eth-client-url: "http://localhost:8551"
jwt-secret: "your_jwt_secret"
genesis-block-hash: "your_genesis_block_hash"
redis-addr: "127.0.0.1:7001"
evm-build-delay: "1s"
```
Expand All @@ -232,6 +209,143 @@ Run the client with the configuration file:

- **Multiple Instances**: You can run multiple instances of the consensus client by changing the `--instance-id` and `--eth-client-url` parameters.

## Running the Streamer

The Streamer is responsible for streaming payloads to member nodes, allowing them to apply these payloads to their respective Geth instances.

### Build the Streamer

Ensure all dependencies are installed and build the Streamer application:

```bash
go mod tidy
go build -o streamer cmd/streamer/main.go
```

### Streamer Configuration

The Streamer can be configured via command-line flags, environment variables, or a YAML configuration file.

#### Command-Line Flags

- `--config`: Path to config file.
- `--redis-addr`: Redis address (default: 127.0.0.1:7001).
- `--listen-addr`: Streamer listen address (default: :50051).
- `--log-fmt`: Log format to use, options are text or json (default: text).
- `--log-level`: Log level to use, options are debug, info, warn, error (default: info).

#### Environment Variables

- `STREAMER_CONFIG`
- `STREAMER_REDIS_ADDR`
- `STREAMER_LISTEN_ADDR`
- `STREAMER_LOG_FMT`
- `STREAMER_LOG_LEVEL`

#### Run the Streamer

Run the Streamer using command-line flags:

```bash
./streamer start \
--config "config.yaml" \
--redis-addr "127.0.0.1:7001" \
--listen-addr ":50051" \
--log-fmt "json" \
--log-level "info"
```

#### Using a Configuration File for Streamer

Create a `streamer_config.yaml` file:

```yaml
redis-addr: "127.0.0.1:7001"
listen-addr: ":50051"
log-fmt: "json"
log-level: "info"
```

Run the Streamer with the configuration file:

```bash
./streamer start --config streamer_config.yaml
```

## Running member nodes

Member nodes connect to the Streamer to receive payloads from the stream and apply them to their Geth instances.

### Build the Member Client

Ensure all dependencies are installed and build the Member Client application:

```bash
go mod tidy
go build -o memberclient cmd/member/main.go
```

### Configuration

The Member Client can be configured via command-line flags, environment variables, or a YAML configuration file.

### Command-Line Flags for Member Client

- `--config`: Path to config file.
- `--client-id`: (Required) Unique client ID for this member.
- `--streamer-addr`: (Required) Streamer address.
- `--eth-client-url`: Ethereum client URL (default: <http://localhost:8551>).
- `--jwt-secret`: JWT secret for Ethereum client.
- `--log-fmt`: Log format to use, options are text or json (default: text).
- `--log-level`: Log level to use, options are debug, info, warn, error (default: info).

### Environment Variables for Member Client

- `MEMBER_CONFIG`
- `MEMBER_CLIENT_ID`
- `MEMBER_STREAMER_ADDR`
- `MEMBER_ETH_CLIENT_URL`
- `MEMBER_JWT_SECRET`
- `MEMBER_LOG_FMT`
- `MEMBER_LOG_LEVEL`

### Run the Member Client

Run the Member Client using command-line flags:

```bash
./memberclient start \
--client-id "member1" \
--streamer-addr "http://localhost:50051" \
--eth-client-url "http://localhost:8551" \
--jwt-secret "your_jwt_secret" \
--log-fmt "json" \
--log-level "info"
```

Note:

Replace "your_jwt_secret" with the actual JWT secret you used earlier.

### Using a Configuration File

Create a member_config.yaml file:

```yaml
client-id: "member1"
streamer-addr: "http://localhost:50051"
eth-client-url: "http://localhost:8551"
jwt-secret: "your_jwt_secret"
log-fmt: "json"
log-level: "info"
```

Run the Member Client with the configuration file:

```bash
./memberclient start --config member_config.yaml
```

## Conclusion

You now have a local Ethereum environment with Geth nodes, Redis, and a consensus client.
Loading
Loading