Skip to content

Commit

Permalink
chore: updated readme
Browse files Browse the repository at this point in the history
  • Loading branch information
merklefruit committed Oct 25, 2024
1 parent fc63e4a commit f44bdfb
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 14 deletions.
82 changes: 75 additions & 7 deletions bolt-cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,7 @@ Available commands:

- [`delegate`](#delegate) - Generate BLS delegation messages for the Constraints API.
- [`pubkeys`](#pubkeys) - List available BLS public keys from various key sources.

All above commands support three key sources:

- Local BLS secret keys (as hex-encoded strings) via `secret-keys`
- Local EIP-2335 filesystem keystore directories via `local-keystore`
- Remote Dirk keystore via `dirk` (requires TLS credentials)
- [`send`](#send) - Send a preconfirmation request to a Bolt sidecar.

---

Expand All @@ -45,6 +40,12 @@ All above commands support three key sources:
The `delegate` command generates signed delegation messages for the Constraints API.
To learn more about the Constraints API, please refer to the [Bolt documentation][bolt-docs].

The `delegate` command supports three key sources:

- Local BLS secret keys (as hex-encoded strings) via `secret-keys`
- Local EIP-2335 filesystem keystore directories via `local-keystore`
- Remote Dirk keystore via `dirk` (requires TLS credentials)

<details>
<summary>Usage</summary>

Expand Down Expand Up @@ -136,7 +137,11 @@ bolt delegate \

### `Pubkeys`

The `pubkeys` command lists available BLS public keys from different key sources.
The `pubkeys` command lists available BLS public keys from different key sources:

- Local BLS secret keys (as hex-encoded strings) via `secret-keys`
- Local EIP-2335 filesystem keystore directories via `local-keystore`
- Remote Dirk keystore via `dirk` (requires TLS credentials)

<details>
<summary>Usage</summary>
Expand Down Expand Up @@ -192,6 +197,69 @@ bolt pubkeys dirk --url https://localhost:9091 \

---

### `Send`

The `send` command sends a preconfirmation request to a Bolt sidecar.

<details>
<summary>Usage</summary>

```text
❯ bolt send --help
Send a preconfirmation request to a Bolt proposer
Usage: bolt send [OPTIONS] --private-key <PRIVATE_KEY>
Options:
--bolt-rpc-url <BOLT_RPC_URL>
Bolt RPC URL to send requests to and fetch lookahead info from
[env: BOLT_RPC_URL=]
[default: http://135.181.191.125:58017/rpc]
--private-key <PRIVATE_KEY>
The private key to sign the transaction with
[env: PRIVATE_KEY]
--override-bolt-sidecar-url <OVERRIDE_BOLT_SIDECAR_URL>
The Bolt Sidecar URL to send requests to. If provided, this will override the canonical bolt RPC URL and disregard any registration information.
This is useful for testing and development purposes.
[env: OVERRIDE_BOLT_SIDECAR_URL=]
--count <COUNT>
How many transactions to send
[env: TRANSACTION_COUNT=]
[default: 1]
--blob
If set, the transaction will be blob-carrying (type 3)
[env: BLOB=]
-h, --help
Print help (see a summary with '-h')
```

</details>

<details>
<summary>Examples</summary>

1. Sending a preconfirmation request to a Bolt sidecar

```text
bolt send --private-key $(openssl rand -hex 32)
```

</details>

---

## Security

The Bolt CLI is designed to be used offline. It does not require any network connections
Expand Down
4 changes: 4 additions & 0 deletions bolt-cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ pub struct SendCommand {
/// How many transactions to send.
#[clap(long, env = "TRANSACTION_COUNT", default_value = "1")]
pub count: u32,

/// If set, the transaction will be blob-carrying (type 3)
#[clap(long, env = "BLOB", default_value = "false")]
pub blob: bool,
}

/// The action to perform.
Expand Down
25 changes: 18 additions & 7 deletions bolt-cli/src/commands/send.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use alloy::{
consensus::{BlobTransactionSidecar, SidecarBuilder, SimpleCoder},
eips::eip2718::Encodable2718,
network::{EthereumWallet, TransactionBuilder},
primitives::{keccak256, B256, U256},
network::{EthereumWallet, TransactionBuilder, TransactionBuilder4844},
primitives::{keccak256, Address, B256, U256},
providers::{ProviderBuilder, SendableTx},
rpc::types::TransactionRequest,
signers::{local::PrivateKeySigner, Signer},
Expand Down Expand Up @@ -58,11 +59,7 @@ impl SendCommand {

for _ in 0..self.count {
// generate a simple self-transfer of ETH
let random_data = rand::thread_rng().gen::<[u8; 32]>();
let req = TransactionRequest::default()
.with_to(wallet.address())
.with_value(U256::from(100_000))
.with_input(random_data);
let req = create_tx_request(wallet.address(), self.blob);

let raw_tx = match provider.fill(req).await.wrap_err("failed to fill transaction")? {
SendableTx::Builder(_) => bail!("expected a raw transaction"),
Expand All @@ -84,6 +81,20 @@ impl SendCommand {
}
}

fn create_tx_request(to: Address, with_blob: bool) -> TransactionRequest {
let mut req = TransactionRequest::default();
req = req.with_to(to).with_value(U256::from(100_000));
req = req.with_input(rand::thread_rng().gen::<[u8; 32]>());

if with_blob {
let sidecar = SidecarBuilder::<SimpleCoder>::from_slice(b"Blobs are fun!");
let sidecar: BlobTransactionSidecar = sidecar.build().unwrap();
req = req.with_blob_sidecar(sidecar)
}

req
}

async fn send_rpc_request(
txs_rlp: Vec<String>,
tx_hashes: Vec<B256>,
Expand Down

0 comments on commit f44bdfb

Please sign in to comment.