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

RPC support for CometBFT 0.38 #1317

Merged
merged 30 commits into from
Jun 14, 2023
Merged
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
9962a4f
rpc: 0.38 support for /block_results endpoint
mzabaluev May 17, 2023
8328820
rpc: add app_hash field to /block_results response
mzabaluev May 17, 2023
320decd
tendermint: restore Deserialize on some types
mzabaluev May 19, 2023
ad73c4b
tendermint: serde impls for ExecTxResult
mzabaluev May 19, 2023
4c0cb74
rpc: support more changes in CometBFT 0.38
mzabaluev May 19, 2023
14cda47
rpc: recognize 0.38 in CompatMode::from_version
mzabaluev May 19, 2023
ba70456
Fix CompatMode parsing test
mzabaluev May 22, 2023
c8d8497
Fix deserialization of RPC results
mzabaluev May 22, 2023
009e696
rpc: 0.37 compat on /block_results response
mzabaluev May 22, 2023
7ba4b1c
Add kvstore fixtures for 0.38
mzabaluev May 22, 2023
057f169
Derive serde impls for abci responses
mzabaluev May 24, 2023
ce199fa
rpc: adapt serialization of Event for 0.38
mzabaluev May 25, 2023
07de311
base64 for app_hash in JSON of FinalizeBlock
mzabaluev May 25, 2023
c37c6c3
rpc: adjusted tests for kvstore_fixtures/v0_38
mzabaluev May 25, 2023
2cf5d78
clippy fix
mzabaluev May 25, 2023
3c12478
Fix up kvstore-test
mzabaluev May 25, 2023
e85d346
rpc: CometBFT 0.38 compat notes on new fields
mzabaluev May 29, 2023
a2015fb
rpc: version-alias latest event serde helpers
mzabaluev May 29, 2023
fa7d4b1
Changelog for #1317
mzabaluev May 29, 2023
2406f5a
rpc: swap around dialect parsing in websocket
mzabaluev May 29, 2023
77b5b63
rpc: swap around dialects in websocket test
mzabaluev May 30, 2023
c00766a
rpc: websocket_client_happy_path test for 0.38
mzabaluev May 30, 2023
a4e3804
rpc: split ser/de helpers for Event
mzabaluev Jun 6, 2023
569db8c
rpc: 0.37 serialization for /broadcast_tx_commit
mzabaluev Jun 6, 2023
8d58a1d
rpc: Fix 0.38 websocket test by proper emulation
mzabaluev Jun 7, 2023
3d3dac8
Merge branch 'main' into mikhail/cometbft-rpc-0.38
mzabaluev Jun 7, 2023
51e47d0
Remove a FIXME comment
mzabaluev Jun 12, 2023
3d05019
Merge branch 'main' into mikhail/cometbft-rpc-0.38
mzabaluev Jun 14, 2023
18ccbcc
rpc: add new fields to 0.38 fixture test
mzabaluev Jun 14, 2023
e5f141b
Update changelog for #1317
mzabaluev Jun 14, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 30 additions & 17 deletions rpc/src/client/transport/websocket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1034,8 +1034,17 @@ mod test {
event_tx: ChannelTx<Event>,
}

// A setting telling which of the CometBFT server versions to emulate
// with the test server.
#[derive(Copy, Clone)]
enum TestRpcVersion {
V0_34,
V0_37,
V0_38,
}
Comment on lines +1040 to +1044
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's almost like CompatMode could be given the new V0_38 variant as well, but it's avoidable on the client side and I think it would result in lots of unnecessary code duplication.


impl TestServer {
async fn new(addr: &str, compat: CompatMode) -> Self {
async fn new(addr: &str, version: TestRpcVersion) -> Self {
let listener = TcpListener::bind(addr).await.unwrap();
let local_addr = listener.local_addr().unwrap();
let node_addr = net::Address::Tcp {
Expand All @@ -1045,7 +1054,7 @@ mod test {
};
let (terminate_tx, terminate_rx) = unbounded();
let (event_tx, event_rx) = unbounded();
let driver = TestServerDriver::new(listener, compat, event_rx, terminate_rx);
let driver = TestServerDriver::new(listener, version, event_rx, terminate_rx);
let driver_hdl = tokio::spawn(async move { driver.run().await });
Self {
node_addr,
Expand All @@ -1068,7 +1077,7 @@ mod test {
// Manages all incoming WebSocket connections.
struct TestServerDriver {
listener: TcpListener,
compat: CompatMode,
version: TestRpcVersion,
event_rx: ChannelRx<Event>,
terminate_rx: ChannelRx<Result<(), Error>>,
handlers: Vec<TestServerHandler>,
Expand All @@ -1077,13 +1086,13 @@ mod test {
impl TestServerDriver {
fn new(
listener: TcpListener,
compat: CompatMode,
version: TestRpcVersion,
event_rx: ChannelRx<Event>,
terminate_rx: ChannelRx<Result<(), Error>>,
) -> Self {
Self {
listener,
compat,
version,
event_rx,
terminate_rx,
handlers: Vec::new(),
Expand Down Expand Up @@ -1116,7 +1125,7 @@ mod test {

async fn handle_incoming(&mut self, stream: TcpStream) {
self.handlers
.push(TestServerHandler::new(stream, self.compat).await);
.push(TestServerHandler::new(stream, self.version).await);
}

async fn terminate(&mut self) {
Expand All @@ -1139,12 +1148,12 @@ mod test {
}

impl TestServerHandler {
async fn new(stream: TcpStream, compat: CompatMode) -> Self {
async fn new(stream: TcpStream, version: TestRpcVersion) -> Self {
let conn: WebSocketStream<TokioAdapter<TcpStream>> =
accept_async(stream).await.unwrap();
let (terminate_tx, terminate_rx) = unbounded();
let (event_tx, event_rx) = unbounded();
let driver = TestServerHandlerDriver::new(conn, compat, event_rx, terminate_rx);
let driver = TestServerHandlerDriver::new(conn, version, event_rx, terminate_rx);
let driver_hdl = tokio::spawn(async move { driver.run().await });
Self {
driver_hdl,
Expand All @@ -1166,7 +1175,7 @@ mod test {
// Manages interaction with a single incoming WebSocket connection.
struct TestServerHandlerDriver {
conn: WebSocketStream<TokioAdapter<TcpStream>>,
compat: CompatMode,
version: TestRpcVersion,
event_rx: ChannelRx<Event>,
terminate_rx: ChannelRx<Result<(), Error>>,
// A mapping of subscription queries to subscription IDs for this
Expand All @@ -1177,13 +1186,13 @@ mod test {
impl TestServerHandlerDriver {
fn new(
conn: WebSocketStream<TokioAdapter<TcpStream>>,
compat: CompatMode,
version: TestRpcVersion,
event_rx: ChannelRx<Event>,
terminate_rx: ChannelRx<Result<(), Error>>,
) -> Self {
Self {
conn,
compat,
version,
event_rx,
terminate_rx,
subscriptions: HashMap::new(),
Expand Down Expand Up @@ -1212,12 +1221,16 @@ mod test {
Some(id) => Id::Str(id.clone()),
None => return,
};
match self.compat {
CompatMode::V0_37 => {
match self.version {
TestRpcVersion::V0_38 => {
let ev: event::v0_38::SerEvent = ev.into();
self.send(subs_id, ev).await;
},
TestRpcVersion::V0_37 => {
let ev: event::v0_37::SerEvent = ev.into();
self.send(subs_id, ev).await;
},
CompatMode::V0_34 => {
TestRpcVersion::V0_34 => {
let ev: event::v0_34::SerEvent = ev.into();
self.send(subs_id, ev).await;
},
Expand Down Expand Up @@ -1349,7 +1362,7 @@ mod test {
let test_events = vec![event1, event2, event3];

println!("Starting WebSocket server...");
let mut server = TestServer::new("127.0.0.1:0", CompatMode::V0_34).await;
let mut server = TestServer::new("127.0.0.1:0", TestRpcVersion::V0_34).await;
println!("Creating client RPC WebSocket connection...");
let url = server.node_addr.clone().try_into().unwrap();
let (client, driver) = WebSocketClient::builder(url)
Expand Down Expand Up @@ -1416,7 +1429,7 @@ mod test {
let test_events = vec![event1, event2, event3];

println!("Starting WebSocket server...");
let mut server = TestServer::new("127.0.0.1:0", CompatMode::V0_37).await;
let mut server = TestServer::new("127.0.0.1:0", TestRpcVersion::V0_37).await;
println!("Creating client RPC WebSocket connection...");
let url = server.node_addr.clone().try_into().unwrap();
let (client, driver) = WebSocketClient::builder(url)
Expand Down Expand Up @@ -1483,7 +1496,7 @@ mod test {
let test_events = vec![event1, event2, event3];

println!("Starting WebSocket server...");
let mut server = TestServer::new("127.0.0.1:0", CompatMode::V0_37).await;
let mut server = TestServer::new("127.0.0.1:0", TestRpcVersion::V0_38).await;
println!("Creating client RPC WebSocket connection...");
let url = server.node_addr.clone().try_into().unwrap();
let (client, driver) = WebSocketClient::builder(url)
Expand Down