-
Notifications
You must be signed in to change notification settings - Fork 226
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP: Adapt domain types to v0.37 and add multi-version
conversions.
- Loading branch information
Showing
10 changed files
with
612 additions
and
210 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[ABCI documentation](https://github.com/tendermint/tendermint/blob/main/spec/abci/abci++_methods.md#prepareproposal) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[ABCI documentation](https://github.com/tendermint/tendermint/blob/main/spec/abci/abci++_methods.md#processproposal) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
use crate::prelude::*; | ||
use crate::{ | ||
abci::types::{CommitInfo, Misbehavior}, | ||
account, block, Error, Hash, Time, | ||
}; | ||
|
||
use bytes::Bytes; | ||
|
||
#[doc = include_str!("../doc/request-prepareproposal.md")] | ||
#[derive(Clone, Debug, PartialEq, Eq)] | ||
pub struct PrepareProposal { | ||
/// the modified transactions cannot exceed this size. | ||
pub max_tx_bytes: i64, | ||
/// txs is an array of transactions that will be included in a block, | ||
/// sent to the app for possible modifications. | ||
pub txs: Vec<Bytes>, | ||
pub local_last_commit: Option<CommitInfo>, | ||
pub misbehavior: Vec<Misbehavior>, | ||
pub height: block::Height, | ||
pub time: Time, | ||
pub next_validators_hash: Hash, | ||
/// address of the public key of the validator proposing the block. | ||
pub proposer_address: account::Id, | ||
} | ||
|
||
// ============================================================================= | ||
// Protobuf conversions | ||
// ============================================================================= | ||
|
||
use tendermint_proto::v0_37::abci as pb; | ||
use tendermint_proto::Protobuf; | ||
|
||
impl From<PrepareProposal> for pb::RequestPrepareProposal { | ||
fn from(value: PrepareProposal) -> Self { | ||
Self { | ||
max_tx_bytes: value.max_tx_bytes, | ||
txs: value.txs, | ||
local_last_commit: value.local_last_commit.map(Into::into), | ||
misbehavior: value.misbehavior.into_iter().map(Into::into).collect(), | ||
height: value.height.into(), | ||
time: Some(value.time.into()), | ||
next_validators_hash: value.next_validators_hash.into(), | ||
proposer_address: value.proposer_address.into(), | ||
} | ||
} | ||
} | ||
|
||
impl TryFrom<pb::RequestPrepareProposal> for PrepareProposal { | ||
type Error = Error; | ||
|
||
fn try_from(message: pb::RequestPrepareProposal) -> Result<Self, Self::Error> { | ||
let req = Self { | ||
max_tx_bytes: message.max_tx_bytes, | ||
txs: message.txs, | ||
local_last_commit: message | ||
.local_last_commit | ||
.map(TryInto::try_into) | ||
.transpose()?, | ||
misbehavior: message | ||
.misbehavior | ||
.into_iter() | ||
.map(TryInto::try_into) | ||
.collect::<Result<Vec<_>, _>>()?, | ||
height: message.height.try_into()?, | ||
time: message | ||
.time | ||
.ok_or_else(Error::missing_timestamp)? | ||
.try_into()?, | ||
next_validators_hash: message.next_validators_hash.try_into()?, | ||
proposer_address: message.proposer_address.try_into()?, | ||
}; | ||
Ok(req) | ||
} | ||
} | ||
|
||
impl Protobuf<pb::RequestPrepareProposal> for PrepareProposal {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
use crate::prelude::*; | ||
use crate::{ | ||
abci::types::{CommitInfo, Misbehavior}, | ||
account, block, Error, Hash, Time, | ||
}; | ||
|
||
use bytes::Bytes; | ||
|
||
#[doc = include_str!("../doc/request-processproposal.md")] | ||
#[derive(Clone, Debug, PartialEq, Eq)] | ||
pub struct ProcessProposal { | ||
/// txs is an array of transactions that will be included in a block, | ||
/// sent to the app for possible modifications. | ||
pub txs: Vec<Bytes>, | ||
pub proposed_last_commit: Option<CommitInfo>, | ||
pub misbehavior: Vec<Misbehavior>, | ||
pub hash: Hash, | ||
pub height: block::Height, | ||
pub time: Time, | ||
pub next_validators_hash: Hash, | ||
/// address of the public key of the validator proposing the block. | ||
pub proposer_address: account::Id, | ||
} | ||
|
||
// ============================================================================= | ||
// Protobuf conversions | ||
// ============================================================================= | ||
|
||
use tendermint_proto::v0_37::abci as pb; | ||
use tendermint_proto::Protobuf; | ||
|
||
impl From<ProcessProposal> for pb::RequestProcessProposal { | ||
fn from(value: ProcessProposal) -> Self { | ||
Self { | ||
txs: value.txs, | ||
proposed_last_commit: value.proposed_last_commit.map(Into::into), | ||
misbehavior: value.misbehavior.into_iter().map(Into::into).collect(), | ||
hash: value.hash.into(), | ||
height: value.height.into(), | ||
time: Some(value.time.into()), | ||
next_validators_hash: value.next_validators_hash.into(), | ||
proposer_address: value.proposer_address.into(), | ||
} | ||
} | ||
} | ||
|
||
impl TryFrom<pb::RequestProcessProposal> for ProcessProposal { | ||
type Error = Error; | ||
|
||
fn try_from(message: pb::RequestProcessProposal) -> Result<Self, Self::Error> { | ||
let req = Self { | ||
txs: message.txs, | ||
proposed_last_commit: message | ||
.proposed_last_commit | ||
.map(TryInto::try_into) | ||
.transpose()?, | ||
misbehavior: message | ||
.misbehavior | ||
.into_iter() | ||
.map(TryInto::try_into) | ||
.collect::<Result<Vec<_>, _>>()?, | ||
hash: message.hash.try_into()?, | ||
height: message.height.try_into()?, | ||
time: message | ||
.time | ||
.ok_or_else(Error::missing_timestamp)? | ||
.try_into()?, | ||
next_validators_hash: message.next_validators_hash.try_into()?, | ||
proposer_address: message.proposer_address.try_into()?, | ||
}; | ||
Ok(req) | ||
} | ||
} | ||
|
||
impl Protobuf<pb::RequestProcessProposal> for ProcessProposal {} |
Oops, something went wrong.