Skip to content

Commit

Permalink
proto: add replay_from_slot
Browse files Browse the repository at this point in the history
  • Loading branch information
fanatid committed Nov 30, 2024
1 parent d9aa2ef commit a2f20d5
Show file tree
Hide file tree
Showing 8 changed files with 179 additions and 34 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ The minor version will be incremented upon a breaking change and the patch versi

- proto: add tonic feature ([#474](https://github.com/rpcpool/yellowstone-grpc/pull/474))
- geyser: use default compression as gzip and zstd ([#475](https://github.com/rpcpool/yellowstone-grpc/pull/475))
- proto: add `replay_from_slot` ([#477](https://github.com/rpcpool/yellowstone-grpc/pull/477))

### Breaking

Expand Down
6 changes: 6 additions & 0 deletions examples/rust/src/bin/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,10 @@ struct ActionSubscribe {
#[clap(long)]
blocks_meta: bool,

/// Replay message from slot
#[clap(long)]
replay_from_slot: Option<u64>,

/// Send ping in subscribe request
#[clap(long)]
ping: Option<i32>,
Expand Down Expand Up @@ -447,6 +451,7 @@ impl Action {
commitment: commitment.map(|x| x as i32),
accounts_data_slice,
ping,
replay_from_slot: args.replay_from_slot,
},
args.resub.unwrap_or(0),
args.stats,
Expand Down Expand Up @@ -803,6 +808,7 @@ async fn geyser_subscribe(
commitment: None,
accounts_data_slice: Vec::default(),
ping: None,
replay_from_slot: None,
})
.await
.map_err(GeyserGrpcClientError::SubscribeSendError)?;
Expand Down
1 change: 1 addition & 0 deletions examples/rust/src/bin/tx-blocktime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ async fn main() -> anyhow::Result<()> {
commitment: Some(commitment as i32),
accounts_data_slice: vec![],
ping: None,
replay_from_slot: None,
})
.await?;

Expand Down
5 changes: 3 additions & 2 deletions yellowstone-grpc-geyser/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@
"unary_concurrency_limit": 100,
"unary_disabled": false,
"x_token": null,
"filter_name_size_limit": 32,
"filter_names_size_limit": 1024,
"replay_stored_slots": 0,
"filter_name_size_limit": 128,
"filter_names_size_limit": 4096,
"filter_names_cleanup_interval": "1s",
"filter_limits": {
"accounts": {
Expand Down
7 changes: 7 additions & 0 deletions yellowstone-grpc-geyser/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ pub struct ConfigGrpc {
with = "humantime_serde"
)]
pub filter_names_cleanup_interval: Duration,
/// Number of slots stored for replay
#[serde(default = "ConfigGrpc::default_replay_stored_slots")]
pub replay_stored_slots: u64,
}

impl ConfigGrpc {
Expand Down Expand Up @@ -153,6 +156,10 @@ impl ConfigGrpc {
const fn default_filter_names_cleanup_interval() -> Duration {
Duration::from_secs(1)
}

const fn default_replay_stored_slots() -> u64 {
0
}
}

#[derive(Debug, Clone, Deserialize)]
Expand Down
183 changes: 151 additions & 32 deletions yellowstone-grpc-geyser/src/grpc.rs

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions yellowstone-grpc-proto/proto/geyser.proto
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ message SubscribeRequest {
optional CommitmentLevel commitment = 6;
repeated SubscribeRequestAccountsDataSlice accounts_data_slice = 7;
optional SubscribeRequestPing ping = 9;
optional uint64 replay_from_slot = 11;
}

message SubscribeRequestFilterAccounts {
Expand Down
9 changes: 9 additions & 0 deletions yellowstone-grpc-proto/src/plugin/filter/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1167,6 +1167,7 @@ mod tests {
commitment: None,
accounts_data_slice: Vec::new(),
ping: None,
replay_from_slot: None,
};
let limit = FilterLimits::default();
let filter = Filter::new(&config, &limit, &mut create_filter_names());
Expand Down Expand Up @@ -1198,6 +1199,7 @@ mod tests {
commitment: None,
accounts_data_slice: Vec::new(),
ping: None,
replay_from_slot: None,
};
let mut limit = FilterLimits::default();
limit.accounts.any = false;
Expand Down Expand Up @@ -1233,6 +1235,7 @@ mod tests {
commitment: None,
accounts_data_slice: Vec::new(),
ping: None,
replay_from_slot: None,
};
let mut limit = FilterLimits::default();
limit.transactions.any = false;
Expand Down Expand Up @@ -1267,6 +1270,7 @@ mod tests {
commitment: None,
accounts_data_slice: Vec::new(),
ping: None,
replay_from_slot: None,
};
let mut limit = FilterLimits::default();
limit.transactions.any = false;
Expand Down Expand Up @@ -1307,6 +1311,7 @@ mod tests {
commitment: None,
accounts_data_slice: Vec::new(),
ping: None,
replay_from_slot: None,
};
let limit = FilterLimits::default();
let filter = Filter::new(&config, &limit, &mut create_filter_names()).unwrap();
Expand Down Expand Up @@ -1371,6 +1376,7 @@ mod tests {
commitment: None,
accounts_data_slice: Vec::new(),
ping: None,
replay_from_slot: None,
};
let limit = FilterLimits::default();
let filter = Filter::new(&config, &limit, &mut create_filter_names()).unwrap();
Expand Down Expand Up @@ -1435,6 +1441,7 @@ mod tests {
commitment: None,
accounts_data_slice: Vec::new(),
ping: None,
replay_from_slot: None,
};
let limit = FilterLimits::default();
let filter = Filter::new(&config, &limit, &mut create_filter_names()).unwrap();
Expand Down Expand Up @@ -1485,6 +1492,7 @@ mod tests {
commitment: None,
accounts_data_slice: Vec::new(),
ping: None,
replay_from_slot: None,
};
let limit = FilterLimits::default();
let filter = Filter::new(&config, &limit, &mut create_filter_names()).unwrap();
Expand Down Expand Up @@ -1557,6 +1565,7 @@ mod tests {
commitment: None,
accounts_data_slice: Vec::new(),
ping: None,
replay_from_slot: None,
};
let limit = FilterLimits::default();
let filter = Filter::new(&config, &limit, &mut create_filter_names()).unwrap();
Expand Down

0 comments on commit a2f20d5

Please sign in to comment.