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

Fully remove VersionedProtocolMessage #18418

Merged
merged 1 commit into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
31 changes: 1 addition & 30 deletions crates/sui-types/src/effects/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,21 @@ use crate::crypto::{
use crate::digests::{
ObjectDigest, TransactionDigest, TransactionEffectsDigest, TransactionEventsDigest,
};
use crate::error::{SuiError, SuiResult};
use crate::error::SuiResult;
use crate::event::Event;
use crate::execution::SharedInput;
use crate::execution_status::ExecutionStatus;
use crate::gas::GasCostSummary;
use crate::message_envelope::{Envelope, Message, TrustedEnvelope, VerifiedEnvelope};
use crate::object::Owner;
use crate::storage::WriteKind;
use crate::transaction::VersionedProtocolMessage;
use effects_v1::TransactionEffectsV1;
pub use effects_v2::UnchangedSharedKind;
use enum_dispatch::enum_dispatch;
pub use object_change::{EffectsObjectChange, ObjectIn, ObjectOut};
use serde::{Deserialize, Serialize};
use shared_crypto::intent::{Intent, IntentScope};
use std::collections::BTreeMap;
use sui_protocol_config::ProtocolConfig;
pub use test_effects_builder::TestEffectsBuilder;

mod effects_v1;
Expand Down Expand Up @@ -61,33 +59,6 @@ pub enum TransactionEffects {
V2(TransactionEffectsV2),
}

impl VersionedProtocolMessage for TransactionEffects {
fn message_version(&self) -> Option<u64> {
Some(match self {
Self::V1(_) => 1,
Self::V2(_) => 2,
})
}

fn check_version_and_features_supported(&self, protocol_config: &ProtocolConfig) -> SuiResult {
match self {
Self::V1(_) => Ok(()),
Self::V2(_) => {
if protocol_config.enable_effects_v2() {
Ok(())
} else {
Err(SuiError::WrongMessageVersion {
error: format!(
"TransactionEffectsV2 is not supported at protocol {:?}.",
protocol_config.version
),
})
}
}
}
}
}

impl Message for TransactionEffects {
type DigestType = TransactionEffectsDigest;
const SCOPE: IntentScope = IntentScope::TransactionEffects;
Expand Down
17 changes: 1 addition & 16 deletions crates/sui-types/src/message_envelope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@ use crate::crypto::{
use crate::error::SuiResult;
use crate::executable_transaction::CertificateProof;
use crate::messages_checkpoint::CheckpointSequenceNumber;
use crate::transaction::{SenderSignedData, VersionedProtocolMessage};
use crate::transaction::SenderSignedData;
use fastcrypto::traits::KeyPair;
use once_cell::sync::OnceCell;
use serde::{de::DeserializeOwned, Deserialize, Serialize};
use shared_crypto::intent::{Intent, IntentScope};
use std::fmt::{Debug, Display, Formatter};
use std::ops::{Deref, DerefMut};
use sui_protocol_config::ProtocolConfig;

pub trait Message {
type DigestType: Clone + Debug;
Expand Down Expand Up @@ -91,13 +90,6 @@ impl<T: Message, S> Envelope<T, S> {
}
}

impl<T: Message + VersionedProtocolMessage, S> VersionedProtocolMessage for Envelope<T, S> {
fn check_version_and_features_supported(&self, protocol_config: &ProtocolConfig) -> SuiResult {
self.data
.check_version_and_features_supported(protocol_config)
}
}

impl<T: Message + PartialEq, S: PartialEq> PartialEq for Envelope<T, S> {
fn eq(&self, other: &Self) -> bool {
self.data == other.data && self.auth_signature == other.auth_signature
Expand Down Expand Up @@ -299,13 +291,6 @@ impl<T: Message, S> VerifiedEnvelope<T, S> {
}
}

impl<T: Message + VersionedProtocolMessage, S> VersionedProtocolMessage for VerifiedEnvelope<T, S> {
fn check_version_and_features_supported(&self, protocol_config: &ProtocolConfig) -> SuiResult {
self.inner()
.check_version_and_features_supported(protocol_config)
}
}

/// After deserialization, a TrustedTransactionEnvelope can be turned back into a
/// VerifiedTransactionEnvelope.
impl<T: Message, S> From<TrustedEnvelope<T, S>> for VerifiedEnvelope<T, S> {
Expand Down
12 changes: 0 additions & 12 deletions crates/sui-types/src/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2732,18 +2732,6 @@ impl CertifiedTransaction {
pub type VerifiedCertificate = VerifiedEnvelope<SenderSignedData, AuthorityStrongQuorumSignInfo>;
pub type TrustedCertificate = TrustedEnvelope<SenderSignedData, AuthorityStrongQuorumSignInfo>;

pub trait VersionedProtocolMessage {
/// Return version of message. Some messages depend on their enclosing messages to know the
/// version number, so not every implementor implements this.
fn message_version(&self) -> Option<u64> {
None
}

/// Check that the version of the message is the correct one to use at this protocol version.
/// Also checks whether the feauures used by the message are supported by the protocol config.
fn check_version_and_features_supported(&self, protocol_config: &ProtocolConfig) -> SuiResult;
}

#[derive(Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize, PartialOrd, Ord, Hash)]
pub enum InputObjectKind {
// A Move package, must be immutable.
Expand Down
Loading