mirror of
https://github.com/serai-dex/serai.git
synced 2025-01-26 12:36:12 +00:00
c182b804bc
The original intent was to use inherent transactions to prevent needing to vote on-chain, which would spam the chain with worthless votes. Inherent transactions, and our Tendermint library, would use the BFT's processs voting to also vote on all included transactions. This perfectly collapses integrity voting creating *no additional on-chain costs*. Unfortunately, this led to issues such as #6, along with questions of validator scalability when all validators are expencted to participate in consensus (in order to vote on if the included instructions are valid). This has been summarized in #241. With this change, we can remove Tendermint from Substrate. This greatly decreases our complexity. While I'm unhappy with the amount of time spent on it, just to reach this conclusion, thankfully tendermint-machine itself is still usable for #163. This also has reached a tipping point recently as the polkadot-v0.9.40 branch of substrate changed how syncing works, requiring further changes to sc-tendermint. These have no value if we're just going to get rid of it later, due to fundamental design issues, yet I would like to keep Substrate updated. This should be followed by moving back to GRANDPA, enabling closing most open Tendermint issues. Please note the current in-instructions-pallet does not actually verify the included signature yet. It's marked TODO, despite this bing critical.
81 lines
2.3 KiB
Rust
81 lines
2.3 KiB
Rust
#![cfg_attr(docsrs, feature(doc_cfg))]
|
|
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
|
|
#![cfg_attr(not(feature = "std"), no_std)]
|
|
|
|
#[cfg(feature = "std")]
|
|
use zeroize::Zeroize;
|
|
|
|
use scale::{Encode, Decode, MaxEncodedLen};
|
|
use scale_info::TypeInfo;
|
|
|
|
#[cfg(feature = "std")]
|
|
use serde::{Serialize, Deserialize};
|
|
|
|
use sp_application_crypto::sr25519::Signature;
|
|
|
|
#[cfg(not(feature = "std"))]
|
|
use sp_std::vec::Vec;
|
|
use sp_runtime::RuntimeDebug;
|
|
|
|
use serai_primitives::{BlockHash, Balance, NetworkId, SeraiAddress, ExternalAddress, Data};
|
|
|
|
mod shorthand;
|
|
pub use shorthand::*;
|
|
|
|
#[derive(Clone, Copy, PartialEq, Eq, Debug, Encode, Decode, MaxEncodedLen, TypeInfo)]
|
|
#[cfg_attr(feature = "std", derive(Zeroize, Serialize, Deserialize))]
|
|
pub enum Application {
|
|
DEX,
|
|
}
|
|
|
|
#[derive(Clone, PartialEq, Eq, Debug, Encode, Decode, MaxEncodedLen, TypeInfo)]
|
|
#[cfg_attr(feature = "std", derive(Zeroize, Serialize, Deserialize))]
|
|
pub struct ApplicationCall {
|
|
application: Application,
|
|
data: Data,
|
|
}
|
|
|
|
#[derive(Clone, PartialEq, Eq, Debug, Encode, Decode, MaxEncodedLen, TypeInfo)]
|
|
#[cfg_attr(feature = "std", derive(Zeroize, Serialize, Deserialize))]
|
|
pub enum InInstruction {
|
|
Transfer(SeraiAddress),
|
|
Call(ApplicationCall),
|
|
}
|
|
|
|
#[derive(Clone, PartialEq, Eq, Encode, Decode, TypeInfo, RuntimeDebug)]
|
|
#[cfg_attr(feature = "std", derive(Zeroize, Serialize, Deserialize))]
|
|
pub struct RefundableInInstruction {
|
|
pub origin: Option<ExternalAddress>,
|
|
pub instruction: InInstruction,
|
|
}
|
|
|
|
#[derive(Clone, PartialEq, Eq, Debug, Encode, Decode, MaxEncodedLen, TypeInfo)]
|
|
#[cfg_attr(feature = "std", derive(Zeroize, Serialize, Deserialize))]
|
|
pub struct InInstructionWithBalance {
|
|
pub instruction: InInstruction,
|
|
pub balance: Balance,
|
|
}
|
|
|
|
#[derive(Clone, PartialEq, Eq, Encode, Decode, TypeInfo, RuntimeDebug)]
|
|
#[cfg_attr(feature = "std", derive(Zeroize, Serialize, Deserialize))]
|
|
pub struct Batch {
|
|
pub network: NetworkId,
|
|
pub id: u32,
|
|
pub block: BlockHash,
|
|
pub instructions: Vec<InInstructionWithBalance>,
|
|
}
|
|
|
|
#[derive(Clone, PartialEq, Eq, Encode, Decode, TypeInfo, RuntimeDebug)]
|
|
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
|
|
pub struct SignedBatch {
|
|
pub batch: Batch,
|
|
pub signature: Signature,
|
|
}
|
|
|
|
#[cfg(feature = "std")]
|
|
impl Zeroize for SignedBatch {
|
|
fn zeroize(&mut self) {
|
|
self.batch.zeroize();
|
|
self.signature.as_mut().zeroize();
|
|
}
|
|
}
|