Trait ibc::core::context::ValidationContext
source · pub trait ValidationContext: Router {
Show 32 methods
// Required methods
fn client_state(
&self,
client_id: &ClientId
) -> Result<Box<dyn ClientState>, ContextError>;
fn decode_client_state(
&self,
client_state: Any
) -> Result<Box<dyn ClientState>, ContextError>;
fn consensus_state(
&self,
client_cons_state_path: &ClientConsensusStatePath
) -> Result<Box<dyn ConsensusState>, ContextError>;
fn next_consensus_state(
&self,
client_id: &ClientId,
height: &Height
) -> Result<Option<Box<dyn ConsensusState>>, ContextError>;
fn prev_consensus_state(
&self,
client_id: &ClientId,
height: &Height
) -> Result<Option<Box<dyn ConsensusState>>, ContextError>;
fn host_height(&self) -> Result<Height, ContextError>;
fn host_timestamp(&self) -> Result<Timestamp, ContextError>;
fn host_consensus_state(
&self,
height: &Height
) -> Result<Box<dyn ConsensusState>, ContextError>;
fn client_counter(&self) -> Result<u64, ContextError>;
fn connection_end(
&self,
conn_id: &ConnectionId
) -> Result<ConnectionEnd, ContextError>;
fn validate_self_client(
&self,
client_state_of_host_on_counterparty: Any
) -> Result<(), ConnectionError>;
fn commitment_prefix(&self) -> CommitmentPrefix;
fn connection_counter(&self) -> Result<u64, ContextError>;
fn channel_end(
&self,
channel_end_path: &ChannelEndPath
) -> Result<ChannelEnd, ContextError>;
fn connection_channels(
&self,
cid: &ConnectionId
) -> Result<Vec<(PortId, ChannelId)>, ContextError>;
fn get_next_sequence_send(
&self,
seq_send_path: &SeqSendPath
) -> Result<Sequence, ContextError>;
fn get_next_sequence_recv(
&self,
seq_recv_path: &SeqRecvPath
) -> Result<Sequence, ContextError>;
fn get_next_sequence_ack(
&self,
seq_ack_path: &SeqAckPath
) -> Result<Sequence, ContextError>;
fn get_packet_commitment(
&self,
commitment_path: &CommitmentPath
) -> Result<PacketCommitment, ContextError>;
fn get_packet_receipt(
&self,
receipt_path: &ReceiptPath
) -> Result<Receipt, ContextError>;
fn get_packet_acknowledgement(
&self,
ack_path: &AckPath
) -> Result<AcknowledgementCommitment, ContextError>;
fn hash(&self, value: &[u8]) -> Vec<u8> ⓘ;
fn client_update_time(
&self,
client_id: &ClientId,
height: &Height
) -> Result<Timestamp, ContextError>;
fn client_update_height(
&self,
client_id: &ClientId,
height: &Height
) -> Result<Height, ContextError>;
fn channel_counter(&self) -> Result<u64, ContextError>;
fn max_expected_time_per_block(&self) -> Duration;
// Provided methods
fn validate(&self, msg: MsgEnvelope) -> Result<(), RouterError>
where Self: Sized { ... }
fn get_compatible_versions(&self) -> Vec<ConnectionVersion> ⓘ { ... }
fn pick_version(
&self,
supported_versions: &[ConnectionVersion],
counterparty_candidate_versions: &[ConnectionVersion]
) -> Result<ConnectionVersion, ContextError> { ... }
fn packet_commitment(
&self,
packet_data: &[u8],
timeout_height: &TimeoutHeight,
timeout_timestamp: &Timestamp
) -> PacketCommitment { ... }
fn ack_commitment(&self, ack: &Acknowledgement) -> AcknowledgementCommitment { ... }
fn block_delay(&self, delay_period_time: &Duration) -> u64 { ... }
}
Required Methods§
sourcefn client_state(
&self,
client_id: &ClientId
) -> Result<Box<dyn ClientState>, ContextError>
fn client_state( &self, client_id: &ClientId ) -> Result<Box<dyn ClientState>, ContextError>
Returns the ClientState for the given identifier client_id
.
sourcefn decode_client_state(
&self,
client_state: Any
) -> Result<Box<dyn ClientState>, ContextError>
fn decode_client_state( &self, client_state: Any ) -> Result<Box<dyn ClientState>, ContextError>
Tries to decode the given client_state
into a concrete light client state.
sourcefn consensus_state(
&self,
client_cons_state_path: &ClientConsensusStatePath
) -> Result<Box<dyn ConsensusState>, ContextError>
fn consensus_state( &self, client_cons_state_path: &ClientConsensusStatePath ) -> Result<Box<dyn ConsensusState>, ContextError>
Retrieve the consensus state for the given client ID at the specified height.
Returns an error if no such state exists.
sourcefn next_consensus_state(
&self,
client_id: &ClientId,
height: &Height
) -> Result<Option<Box<dyn ConsensusState>>, ContextError>
fn next_consensus_state( &self, client_id: &ClientId, height: &Height ) -> Result<Option<Box<dyn ConsensusState>>, ContextError>
Search for the lowest consensus state higher than height
.
sourcefn prev_consensus_state(
&self,
client_id: &ClientId,
height: &Height
) -> Result<Option<Box<dyn ConsensusState>>, ContextError>
fn prev_consensus_state( &self, client_id: &ClientId, height: &Height ) -> Result<Option<Box<dyn ConsensusState>>, ContextError>
Search for the highest consensus state lower than height
.
sourcefn host_height(&self) -> Result<Height, ContextError>
fn host_height(&self) -> Result<Height, ContextError>
Returns the current height of the local chain.
sourcefn host_timestamp(&self) -> Result<Timestamp, ContextError>
fn host_timestamp(&self) -> Result<Timestamp, ContextError>
Returns the current timestamp of the local chain.
sourcefn host_consensus_state(
&self,
height: &Height
) -> Result<Box<dyn ConsensusState>, ContextError>
fn host_consensus_state( &self, height: &Height ) -> Result<Box<dyn ConsensusState>, ContextError>
Returns the ConsensusState
of the host (local) chain at a specific height.
sourcefn client_counter(&self) -> Result<u64, ContextError>
fn client_counter(&self) -> Result<u64, ContextError>
Returns a natural number, counting how many clients have been created
thus far. The value of this counter should increase only via method
ExecutionContext::increase_client_counter
.
sourcefn connection_end(
&self,
conn_id: &ConnectionId
) -> Result<ConnectionEnd, ContextError>
fn connection_end( &self, conn_id: &ConnectionId ) -> Result<ConnectionEnd, ContextError>
Returns the ConnectionEnd for the given identifier conn_id
.
sourcefn validate_self_client(
&self,
client_state_of_host_on_counterparty: Any
) -> Result<(), ConnectionError>
fn validate_self_client( &self, client_state_of_host_on_counterparty: Any ) -> Result<(), ConnectionError>
Validates the ClientState
of the client (a client referring to host) stored on the counterparty chain against the host’s internal state.
For more information on the specific requirements for validating the client state of a host chain, please refer to the ICS24 host requirements
Additionally, implementations specific to individual chains can be found in the hosts module.
sourcefn commitment_prefix(&self) -> CommitmentPrefix
fn commitment_prefix(&self) -> CommitmentPrefix
Returns the prefix that the local chain uses in the KV store.
sourcefn connection_counter(&self) -> Result<u64, ContextError>
fn connection_counter(&self) -> Result<u64, ContextError>
Returns a counter on how many connections have been created thus far.
sourcefn channel_end(
&self,
channel_end_path: &ChannelEndPath
) -> Result<ChannelEnd, ContextError>
fn channel_end( &self, channel_end_path: &ChannelEndPath ) -> Result<ChannelEnd, ContextError>
Returns the ChannelEnd for the given port_id
and chan_id
.
fn connection_channels( &self, cid: &ConnectionId ) -> Result<Vec<(PortId, ChannelId)>, ContextError>
fn get_next_sequence_send( &self, seq_send_path: &SeqSendPath ) -> Result<Sequence, ContextError>
fn get_next_sequence_recv( &self, seq_recv_path: &SeqRecvPath ) -> Result<Sequence, ContextError>
fn get_next_sequence_ack( &self, seq_ack_path: &SeqAckPath ) -> Result<Sequence, ContextError>
fn get_packet_commitment( &self, commitment_path: &CommitmentPath ) -> Result<PacketCommitment, ContextError>
fn get_packet_receipt( &self, receipt_path: &ReceiptPath ) -> Result<Receipt, ContextError>
fn get_packet_acknowledgement( &self, ack_path: &AckPath ) -> Result<AcknowledgementCommitment, ContextError>
sourcefn client_update_time(
&self,
client_id: &ClientId,
height: &Height
) -> Result<Timestamp, ContextError>
fn client_update_time( &self, client_id: &ClientId, height: &Height ) -> Result<Timestamp, ContextError>
sourcefn client_update_height(
&self,
client_id: &ClientId,
height: &Height
) -> Result<Height, ContextError>
fn client_update_height( &self, client_id: &ClientId, height: &Height ) -> Result<Height, ContextError>
sourcefn channel_counter(&self) -> Result<u64, ContextError>
fn channel_counter(&self) -> Result<u64, ContextError>
Returns a counter on the number of channel ids have been created thus far.
The value of this counter should increase only via method
ExecutionContext::increase_channel_counter
.
sourcefn max_expected_time_per_block(&self) -> Duration
fn max_expected_time_per_block(&self) -> Duration
Returns the maximum expected time per block
Provided Methods§
sourcefn validate(&self, msg: MsgEnvelope) -> Result<(), RouterError>where
Self: Sized,
fn validate(&self, msg: MsgEnvelope) -> Result<(), RouterError>where Self: Sized,
Validation entrypoint.
sourcefn get_compatible_versions(&self) -> Vec<ConnectionVersion> ⓘ
fn get_compatible_versions(&self) -> Vec<ConnectionVersion> ⓘ
Function required by ICS 03. Returns the list of all possible versions that the connection handshake protocol supports.
sourcefn pick_version(
&self,
supported_versions: &[ConnectionVersion],
counterparty_candidate_versions: &[ConnectionVersion]
) -> Result<ConnectionVersion, ContextError>
fn pick_version( &self, supported_versions: &[ConnectionVersion], counterparty_candidate_versions: &[ConnectionVersion] ) -> Result<ConnectionVersion, ContextError>
Function required by ICS 03. Returns one version out of the supplied list of versions, which the connection handshake protocol prefers.
sourcefn packet_commitment(
&self,
packet_data: &[u8],
timeout_height: &TimeoutHeight,
timeout_timestamp: &Timestamp
) -> PacketCommitment
fn packet_commitment( &self, packet_data: &[u8], timeout_height: &TimeoutHeight, timeout_timestamp: &Timestamp ) -> PacketCommitment
Compute the commitment for a packet.
Note that the absence of timeout_height
is treated as
{revision_number: 0, revision_height: 0}
to be consistent with ibc-go,
where this value is used to mean “no timeout height”:
https://github.com/cosmos/ibc-go/blob/04791984b3d6c83f704c4f058e6ca0038d155d91/modules/core/04-channel/keeper/packet.go#L206
fn ack_commitment(&self, ack: &Acknowledgement) -> AcknowledgementCommitment
sourcefn block_delay(&self, delay_period_time: &Duration) -> u64
fn block_delay(&self, delay_period_time: &Duration) -> u64
Calculates the block delay period using the connection’s delay period and the maximum expected time per block.