diff --git a/linera-chain/src/chain.rs b/linera-chain/src/chain.rs index 0cd20923b819..af597d3e40ed 100644 --- a/linera-chain/src/chain.rs +++ b/linera-chain/src/chain.rs @@ -532,30 +532,27 @@ where } } } - - if bundle.goes_to_inbox() { - // Process the inbox bundle and update the inbox state. - let mut inbox = self.inboxes.try_load_entry_mut(origin).await?; - #[cfg(with_metrics)] - NUM_INBOXES - .with_label_values(&[]) - .observe(self.inboxes.count().await? as f64); - let entry = BundleInInbox::new(origin.clone(), &bundle); - let skippable = bundle.is_skippable(); - let newly_added = inbox - .add_bundle(bundle) - .await - .map_err(|error| match error { - InboxError::ViewError(error) => ChainError::ViewError(error), - error => ChainError::InternalError(format!( - "while processing messages in certified block: {error}" - )), - })?; - if newly_added && !skippable { - let seen = local_time; - self.unskippable_bundles - .push_back(TimestampedBundleInInbox { entry, seen }); - } + // Process the inbox bundle and update the inbox state. + let mut inbox = self.inboxes.try_load_entry_mut(origin).await?; + #[cfg(with_metrics)] + NUM_INBOXES + .with_label_values(&[]) + .observe(self.inboxes.count().await? as f64); + let entry = BundleInInbox::new(origin.clone(), &bundle); + let skippable = bundle.is_skippable(); + let newly_added = inbox + .add_bundle(bundle) + .await + .map_err(|error| match error { + InboxError::ViewError(error) => ChainError::ViewError(error), + error => ChainError::InternalError(format!( + "while processing messages in certified block: {error}" + )), + })?; + if newly_added && !skippable { + let seen = local_time; + self.unskippable_bundles + .push_back(TimestampedBundleInInbox { entry, seen }); } // Remember the certificate for future validator/client synchronizations. diff --git a/linera-chain/src/data_types.rs b/linera-chain/src/data_types.rs index 832ba65aabed..e26f03c7f50d 100644 --- a/linera-chain/src/data_types.rs +++ b/linera-chain/src/data_types.rs @@ -558,15 +558,6 @@ impl MessageBundle { pub fn is_protected(&self) -> bool { self.messages.iter().any(PostedMessage::is_protected) } - - /// Returns whether this bundle must be added to the inbox. - /// - /// If this is `false`, it gets handled immediately and should never be received in a block. - pub fn goes_to_inbox(&self) -> bool { - self.messages - .iter() - .any(|posted_message| posted_message.message.goes_to_inbox()) - } } impl PostedMessage { diff --git a/linera-core/src/chain_worker/state/mod.rs b/linera-core/src/chain_worker/state/mod.rs index 6cb29791951b..38f5908d51df 100644 --- a/linera-core/src/chain_worker/state/mod.rs +++ b/linera-core/src/chain_worker/state/mod.rs @@ -444,22 +444,10 @@ where let mut heights_by_recipient = BTreeMap::<_, BTreeMap<_, _>>::new(); let mut targets = self.chain.outboxes.indices().await?; if let Some(tracked_chains) = self.tracked_chains.as_ref() { - let publishers = self - .chain - .execution_state - .system - .subscriptions - .indices() - .await? - .iter() - .map(|subscription| subscription.chain_id) - .collect::>(); let tracked_chains = tracked_chains .read() .expect("Panics should not happen while holding a lock to `tracked_chains`"); - targets.retain(|target| { - tracked_chains.contains(&target.recipient) || publishers.contains(&target.recipient) - }); + targets.retain(|target| tracked_chains.contains(&target.recipient)); } let outboxes = self.chain.outboxes.try_load_entries(&targets).await?; for (target, outbox) in targets.into_iter().zip(outboxes) { @@ -544,20 +532,8 @@ where }; let mut targets = self.chain.outboxes.indices().await?; { - let publishers = self - .chain - .execution_state - .system - .subscriptions - .indices() - .await? - .iter() - .map(|subscription| subscription.chain_id) - .collect::>(); let tracked_chains = tracked_chains.read().unwrap(); - targets.retain(|target| { - tracked_chains.contains(&target.recipient) || publishers.contains(&target.recipient) - }); + targets.retain(|target| tracked_chains.contains(&target.recipient)); } let outboxes = self.chain.outboxes.try_load_entries(&targets).await?; for outbox in outboxes { diff --git a/linera-core/src/unit_tests/worker_tests.rs b/linera-core/src/unit_tests/worker_tests.rs index 2eba21a18a89..c3e3ce1d5b09 100644 --- a/linera-core/src/unit_tests/worker_tests.rs +++ b/linera-core/src/unit_tests/worker_tests.rs @@ -2510,16 +2510,6 @@ where *user_chain.execution_state.system.admin_id.get(), Some(admin_id) ); - assert_eq!( - user_chain - .execution_state - .system - .subscriptions - .indices() - .await? - .len(), - 0 - ); user_chain.validate_incoming_bundles().await?; matches!( &user_chain @@ -2629,16 +2619,6 @@ where *user_chain.execution_state.system.admin_id.get(), Some(admin_id) ); - assert_eq!( - user_chain - .execution_state - .system - .subscriptions - .indices() - .await? - .len(), - 0 - ); assert_eq!(user_chain.execution_state.system.committees.get().len(), 2); user_chain.validate_incoming_bundles().await?; Ok(()) diff --git a/linera-execution/src/execution_state_actor.rs b/linera-execution/src/execution_state_actor.rs index a4d852bbf319..055fe7e679c0 100644 --- a/linera-execution/src/execution_state_actor.rs +++ b/linera-execution/src/execution_state_actor.rs @@ -311,8 +311,7 @@ where if !app_permissions.can_close_chain(&application_id) { callback.respond(Err(ExecutionError::UnauthorizedApplication(application_id))); } else { - let chain_id = self.context().extra().chain_id(); - self.system.close_chain(chain_id).await?; + self.system.close_chain().await?; callback.respond(Ok(())); } } diff --git a/linera-execution/src/graphql.rs b/linera-execution/src/graphql.rs index 34f3136c5ef4..a0f8ed7c42d1 100644 --- a/linera-execution/src/graphql.rs +++ b/linera-execution/src/graphql.rs @@ -15,7 +15,7 @@ use linera_views::{context::Context, map_view::MapView}; use crate::{ committee::{Committee, Epoch, ValidatorState}, system::{Recipient, UserData}, - ChannelSubscription, ExecutionStateView, SystemExecutionStateView, + ExecutionStateView, SystemExecutionStateView, }; doc_scalar!( @@ -73,11 +73,6 @@ impl SystemExecutionStateView { self.admin_id.get() } - #[graphql(derived(name = "subscription"))] - async fn _subscriptions(&self) -> Result, async_graphql::Error> { - Ok(self.subscriptions.indices().await?) - } - #[graphql(derived(name = "committees"))] async fn _committees(&self) -> &BTreeMap { self.committees.get() diff --git a/linera-execution/src/lib.rs b/linera-execution/src/lib.rs index ad1e15ae8283..e0622055eefe 100644 --- a/linera-execution/src/lib.rs +++ b/linera-execution/src/lib.rs @@ -976,17 +976,6 @@ impl OutgoingMessage { } } -/// The identifier of a channel, relative to a particular application. -#[derive( - Eq, PartialEq, Ord, PartialOrd, Debug, Clone, Hash, Serialize, Deserialize, SimpleObject, -)] -pub struct ChannelSubscription { - /// The chain ID broadcasting on this channel. - pub chain_id: ChainId, - /// The name of the channel. - pub name: ChannelName, -} - impl OperationContext { /// Returns an account for the refund. /// Returns `None` if there is no authenticated signer of the [`OperationContext`]. @@ -1223,32 +1212,6 @@ impl Message { } } - /// Returns whether this message must be added to the inbox. - pub fn goes_to_inbox(&self) -> bool { - !matches!( - self, - Message::System(SystemMessage::Subscribe { .. } | SystemMessage::Unsubscribe { .. }) - ) - } - - pub fn matches_subscribe(&self) -> Option<(&ChainId, &ChannelSubscription)> { - match self { - Message::System(SystemMessage::Subscribe { id, subscription }) => { - Some((id, subscription)) - } - _ => None, - } - } - - pub fn matches_unsubscribe(&self) -> Option<(&ChainId, &ChannelSubscription)> { - match self { - Message::System(SystemMessage::Unsubscribe { id, subscription }) => { - Some((id, subscription)) - } - _ => None, - } - } - pub fn matches_open_chain(&self) -> Option<&OpenChainConfig> { match self { Message::System(SystemMessage::OpenChain(config)) => Some(config), diff --git a/linera-execution/src/system.rs b/linera-execution/src/system.rs index a643d51abde5..4488b88cdae8 100644 --- a/linera-execution/src/system.rs +++ b/linera-execution/src/system.rs @@ -41,9 +41,9 @@ use {linera_base::prometheus_util::register_int_counter_vec, prometheus::IntCoun use crate::test_utils::SystemExecutionState; use crate::{ committee::{Committee, Epoch}, - ApplicationDescription, ApplicationId, ChannelSubscription, ExecutionError, - ExecutionRuntimeContext, MessageContext, MessageKind, OperationContext, OutgoingMessage, - QueryContext, QueryOutcome, ResourceController, TransactionTracker, + ApplicationDescription, ApplicationId, ExecutionError, ExecutionRuntimeContext, MessageContext, + MessageKind, OperationContext, OutgoingMessage, QueryContext, QueryOutcome, ResourceController, + TransactionTracker, }; /// The relative index of the `OpenChain` message created by the `OpenChain` operation. @@ -72,8 +72,6 @@ pub struct SystemExecutionStateView { pub epoch: HashedRegisterView>, /// The admin of the chain. pub admin_id: HashedRegisterView>, - /// Track the channels that we have subscribed to. - pub subscriptions: HashedSetView, /// The committees that we trust, indexed by epoch number. // Not using a `MapView` because the set active of committees is supposed to be // small. Plus, currently, we would create the `BTreeMap` anyway in various places @@ -211,16 +209,6 @@ pub enum SystemMessage { }, /// Creates (or activates) a new chain. OpenChain(OpenChainConfig), - /// Subscribes to a channel. - Subscribe { - id: ChainId, - subscription: ChannelSubscription, - }, - /// Unsubscribes from a channel. - Unsubscribe { - id: ChainId, - subscription: ChannelSubscription, - }, /// Notifies that a new application was created. ApplicationCreated, } @@ -353,10 +341,7 @@ where ChangeApplicationPermissions(application_permissions) => { self.application_permissions.set(application_permissions); } - CloseChain => { - let messages = self.close_chain(context.chain_id).await?; - txn_tracker.add_outgoing_messages(messages)?; - } + CloseChain => self.close_chain().await?, Transfer { owner, amount, @@ -682,7 +667,7 @@ where } } // These messages are executed immediately when cross-chain requests are received. - Subscribe { .. } | Unsubscribe { .. } | OpenChain(_) => {} + OpenChain(_) => {} // This message is only a placeholder: Its ID is part of the application ID. ApplicationCreated => {} } @@ -762,27 +747,9 @@ where Ok(OutgoingMessage::new(child_id, message).with_kind(MessageKind::Protected)) } - pub async fn close_chain( - &mut self, - id: ChainId, - ) -> Result, ExecutionError> { - let mut messages = Vec::new(); - // Unsubscribe from all channels. - self.subscriptions - .for_each_index(|subscription| { - messages.push( - OutgoingMessage::new( - subscription.chain_id, - SystemMessage::Unsubscribe { id, subscription }, - ) - .with_kind(MessageKind::Protected), - ); - Ok(()) - }) - .await?; - self.subscriptions.clear(); + pub async fn close_chain(&mut self) -> Result<(), ExecutionError> { self.closed.set(true); - Ok(messages) + Ok(()) } pub async fn create_application( diff --git a/linera-execution/src/test_utils/system_execution_state.rs b/linera-execution/src/test_utils/system_execution_state.rs index a6559d4b54a7..c4ede97ff18b 100644 --- a/linera-execution/src/test_utils/system_execution_state.rs +++ b/linera-execution/src/test_utils/system_execution_state.rs @@ -24,9 +24,9 @@ use super::{MockApplication, RegisterMockApplication}; use crate::{ committee::{Committee, Epoch}, execution::UserAction, - ApplicationDescription, ChannelSubscription, ExecutionError, ExecutionRuntimeConfig, - ExecutionRuntimeContext, ExecutionStateView, OperationContext, ResourceControlPolicy, - ResourceController, ResourceTracker, TestExecutionRuntimeContext, UserContractCode, + ApplicationDescription, ExecutionError, ExecutionRuntimeConfig, ExecutionRuntimeContext, + ExecutionStateView, OperationContext, ResourceControlPolicy, ResourceController, + ResourceTracker, TestExecutionRuntimeContext, UserContractCode, }; /// A system execution state, not represented as a view but as a simple struct. @@ -35,7 +35,6 @@ pub struct SystemExecutionState { pub description: Option, pub epoch: Option, pub admin_id: Option, - pub subscriptions: BTreeSet, pub committees: BTreeMap, pub ownership: ChainOwnership, pub balance: Amount, @@ -88,7 +87,6 @@ impl SystemExecutionState { description, epoch, admin_id, - subscriptions, committees, ownership, balance, @@ -120,12 +118,6 @@ impl SystemExecutionState { view.system.description.set(description); view.system.epoch.set(epoch); view.system.admin_id.set(admin_id); - for subscription in subscriptions { - view.system - .subscriptions - .insert(&subscription) - .expect("serialization of subscription should not fail"); - } view.system.committees.set(committees); view.system.ownership.set(ownership); view.system.balance.set(balance); diff --git a/linera-rpc/tests/snapshots/format__format.yaml.snap b/linera-rpc/tests/snapshots/format__format.yaml.snap index fd0185be0704..da2ec28dfaca 100644 --- a/linera-rpc/tests/snapshots/format__format.yaml.snap +++ b/linera-rpc/tests/snapshots/format__format.yaml.snap @@ -381,12 +381,6 @@ ChannelFullName: TYPENAME: ChannelName ChannelName: NEWTYPESTRUCT: BYTES -ChannelSubscription: - STRUCT: - - chain_id: - TYPENAME: ChainId - - name: - TYPENAME: ChannelName Committee: STRUCT: - validators: @@ -1085,20 +1079,6 @@ SystemMessage: NEWTYPE: TYPENAME: OpenChainConfig 3: - Subscribe: - STRUCT: - - id: - TYPENAME: ChainId - - subscription: - TYPENAME: ChannelSubscription - 4: - Unsubscribe: - STRUCT: - - id: - TYPENAME: ChainId - - subscription: - TYPENAME: ChannelSubscription - 5: ApplicationCreated: UNIT SystemOperation: ENUM: diff --git a/linera-service-graphql-client/gql/service_requests.graphql b/linera-service-graphql-client/gql/service_requests.graphql index fc29b5aa3364..14ffa94fa467 100644 --- a/linera-service-graphql-client/gql/service_requests.graphql +++ b/linera-service-graphql-client/gql/service_requests.graphql @@ -103,10 +103,6 @@ query Chain( description epoch adminId - subscriptions { - chainId - name - } ownership balance timestamp diff --git a/linera-service-graphql-client/gql/service_schema.graphql b/linera-service-graphql-client/gql/service_schema.graphql index d7da88867b81..f174f8a28b51 100644 --- a/linera-service-graphql-client/gql/service_schema.graphql +++ b/linera-service-graphql-client/gql/service_schema.graphql @@ -395,11 +395,6 @@ A channel name together with its application ID. """ scalar ChannelFullName -""" -The name of a subscription channel -""" -scalar ChannelName - """ The state of a channel followed by subscribers. """ @@ -414,20 +409,6 @@ type ChannelStateView { blockHeights: LogView_BlockHeight_e824a938! } -""" -The identifier of a channel, relative to a particular application. -""" -type ChannelSubscription { - """ - The chain ID broadcasting on this channel. - """ - chainId: ChainId! - """ - The name of the channel. - """ - name: ChannelName! -} - """ A set of validators (identified by their public keys) and their voting rights. """ @@ -1219,7 +1200,6 @@ type SystemExecutionStateView { description: ChainDescription epoch: Epoch adminId: ChainId - subscriptions: [ChannelSubscription!]! committees: JSONObject! ownership: ChainOwnership! balance: Amount! diff --git a/linera-service-graphql-client/src/service.rs b/linera-service-graphql-client/src/service.rs index d28a543fc251..1d025a09a9aa 100644 --- a/linera-service-graphql-client/src/service.rs +++ b/linera-service-graphql-client/src/service.rs @@ -6,7 +6,7 @@ use linera_base::{ crypto::CryptoHash, data_types::{Amount, Blob, BlockHeight, OracleResponse, Round, Timestamp}, identifiers::{ - Account, AccountOwner, BlobId, ChainDescription, ChainId, ChannelName, Destination, + Account, AccountOwner, BlobId, ChainDescription, ChainId, Destination, GenericApplicationId, StreamName, }, };