Skip to content

Commit

Permalink
Replace RPC ABCI types with ABCI domain types (#1204)
Browse files Browse the repository at this point in the history
* Remove local ABCI module import

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* Refactor abci_info endpoint to use domain type

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* Replace RPC ABCI Path with a String

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* Replace all uses of tendermint_rpc::abci::transaction::Hash with tendermint::Hash

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* rpc: Remove abci::Responses

Does not seem to be used for anything.

* rpc: Replace DeliverTx and Event with domain types

First attempt, with a serialization snag in tendermint-proto.

* Serialize some ABCI domain types directly

Instead of deriving serde on raw proto types to de/serialize
abci::response::DeliverTx, abci::Event, and abci::EventAttribute,
derive on the domain types directly.
This disentangles the serialization, now primarily used by JSON-RPC,
from protobuf struct definitions which are subject to change for
Tendermint Core 0.37 (in case of EventAttribute).

* Serialize gas as strings in response::DeliverTx

* rpc: Eliminate abci::Gas

In tendermint-rpc, the only place where Gas newtype is still used
is in the response to /broadcast_tx_commit, which is a development-only
endpoint. Leave the response struct defined through tx_commit::TxResult
for the time being.
Define serialization of abci::response::CheckTx (currently not used)
to match that of DeliverTx.

* Nullable serializer for data fields of ABCI responses

* rpc: Remove abci::Data

* rpc: Remove abci::Log

* rpc: Remove abci::Info

* rpc: Replace BeginBlock/EndBlock with domain types

Also in tendermint, remove validator::Update which duplicates
abci::types::ValidatorUpdate.

* rpc: remove abci::Codespace

With it goes mod abci::responses.

* Post-merge fixup

* Fix integration tests

* Fix clippy lints

* Convert abci::ValidatorUpdate to validator::Update

* rpc: Move abci::Code to crate tendermint

Promote this to a proper domain type.

* Replace u32 code fields with Code

* rpc: Eliminate abci::Transaction

This was the last of the ABCI helper types defined in tendermint-rpc,
and with it goes the abci module.

* Fix tools build

* Changelog entry for #1204

* Use domain types in /broadcast_tx_commit response

* Fix serialization of priority field in CheckTx response

* Default the field values of CheckTx/DeliverTx

Signed-off-by: Thane Thomson <connect@thanethomson.com>
Co-authored-by: Thane Thomson <connect@thanethomson.com>
  • Loading branch information
mzabaluev and thanethomson authored Nov 5, 2022
1 parent b849fdd commit 2ce1789
Show file tree
Hide file tree
Showing 48 changed files with 446 additions and 1,225 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- `[tendermint-rpc]` Remove ABCI-related types, change the affected field types
to standard Rust types or ABCI domain types in `[tendermint]`.
([#1090](https://github.com/informalsystems/tendermint-rs/issues/1090))
2 changes: 1 addition & 1 deletion light-client/src/evidence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use contracts::contract_trait;
pub use tendermint::evidence::Evidence;
use tendermint_rpc::abci::transaction::Hash;
use tendermint::Hash;

use crate::{components::io::IoError, verifier::types::PeerId};

Expand Down
5 changes: 3 additions & 2 deletions light-client/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ use serde::{Deserialize, Serialize};
use tendermint::{
block::Height as HeightStr,
evidence::{Duration as DurationStr, Evidence},
hash::Algorithm,
Hash,
};
use tendermint_rpc as rpc;
use tendermint_rpc::abci::transaction::Hash;

use crate::{
components::{
Expand Down Expand Up @@ -133,7 +134,7 @@ pub struct MockEvidenceReporter;
#[contract_trait]
impl EvidenceReporter for MockEvidenceReporter {
fn report(&self, _e: Evidence, _peer: PeerId) -> Result<Hash, IoError> {
Ok(Hash::new([0; 32]))
Ok(Hash::from_bytes(Algorithm::Sha256, &[0; 32]).unwrap())
}
}

Expand Down
6 changes: 4 additions & 2 deletions proto/src/serializers/bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,14 @@ pub mod base64string {
use crate::prelude::*;

/// Deserialize base64string into `Vec<u8>`
pub fn deserialize<'de, D>(deserializer: D) -> Result<Vec<u8>, D::Error>
pub fn deserialize<'de, D, T>(deserializer: D) -> Result<T, D::Error>
where
D: Deserializer<'de>,
Vec<u8>: Into<T>,
{
let string = Option::<String>::deserialize(deserializer)?.unwrap_or_default();
base64::decode(&string).map_err(serde::de::Error::custom)
let v = base64::decode(&string).map_err(serde::de::Error::custom)?;
Ok(v.into())
}

/// Deserialize base64string into String
Expand Down
34 changes: 0 additions & 34 deletions rpc/src/abci.rs

This file was deleted.

60 changes: 0 additions & 60 deletions rpc/src/abci/data.rs

This file was deleted.

71 changes: 0 additions & 71 deletions rpc/src/abci/gas.rs

This file was deleted.

21 changes: 0 additions & 21 deletions rpc/src/abci/info.rs

This file was deleted.

35 changes: 0 additions & 35 deletions rpc/src/abci/log.rs

This file was deleted.

29 changes: 0 additions & 29 deletions rpc/src/abci/path.rs

This file was deleted.

Loading

0 comments on commit 2ce1789

Please sign in to comment.