From a350623aa79d86dcee8940702d198d2928f51183 Mon Sep 17 00:00:00 2001 From: goshawk Date: Wed, 10 Jan 2024 17:26:40 +0200 Subject: [PATCH] consensus: Rename contract_state.rs to operations.rs --- consensus/src/consensus.rs | 2 +- consensus/src/contract_state.rs | 62 ----------------------- consensus/src/execution_ctx.rs | 2 +- consensus/src/lib.rs | 2 +- consensus/src/phase.rs | 2 +- consensus/src/proposal/block_generator.rs | 8 +-- consensus/src/proposal/step.rs | 2 +- consensus/src/ratification/step.rs | 2 +- 8 files changed, 10 insertions(+), 72 deletions(-) delete mode 100644 consensus/src/contract_state.rs diff --git a/consensus/src/consensus.rs b/consensus/src/consensus.rs index 58158130d9..beb951893c 100644 --- a/consensus/src/consensus.rs +++ b/consensus/src/consensus.rs @@ -6,7 +6,7 @@ use crate::commons::{ConsensusError, Database, QuorumMsgSender, RoundUpdate}; use crate::config::CONSENSUS_MAX_ITER; -use crate::contract_state::Operations; +use crate::operations::Operations; use crate::phase::Phase; use node_data::ledger::Block; diff --git a/consensus/src/contract_state.rs b/consensus/src/contract_state.rs deleted file mode 100644 index df55e4680b..0000000000 --- a/consensus/src/contract_state.rs +++ /dev/null @@ -1,62 +0,0 @@ -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. -// -// Copyright (c) DUSK NETWORK. All rights reserved. - -use std::fmt; - -use node_data::ledger::{SpentTransaction, Transaction}; - -pub type StateRoot = [u8; 32]; -pub type EventHash = [u8; 32]; - -#[derive(Debug)] -pub enum Error { - Failed, -} - -#[derive(Default, Clone, Debug)] -pub struct CallParams { - pub round: u64, - pub block_gas_limit: u64, - pub generator_pubkey: node_data::bls::PublicKey, -} - -#[derive(Default)] -pub struct Output { - pub txs: Vec, - pub verification_output: VerificationOutput, - pub discarded_txs: Vec, -} - -#[derive(Debug, Default, PartialEq)] -pub struct VerificationOutput { - pub state_root: StateRoot, - pub event_hash: EventHash, -} - -impl fmt::Display for VerificationOutput { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!( - f, - "VerificationOutput {{ state_root: {}, event_hash: {} }}", - hex::encode(self.state_root), - hex::encode(self.event_hash) - ) - } -} - -#[async_trait::async_trait] -pub trait Operations: Send + Sync { - async fn verify_state_transition( - &self, - params: CallParams, - txs: Vec, - ) -> Result; - - async fn execute_state_transition( - &self, - params: CallParams, - ) -> Result; -} diff --git a/consensus/src/execution_ctx.rs b/consensus/src/execution_ctx.rs index 0edbea542b..789c98f19f 100644 --- a/consensus/src/execution_ctx.rs +++ b/consensus/src/execution_ctx.rs @@ -6,10 +6,10 @@ use crate::commons::{ConsensusError, Database, QuorumMsgSender, RoundUpdate}; -use crate::contract_state::Operations; use crate::iteration_ctx::IterationCtx; use crate::msg_handler::HandleMsgOutput::{Pending, Ready}; use crate::msg_handler::MsgHandler; +use crate::operations::Operations; use crate::queue::Queue; use crate::step_votes_reg::SafeCertificateInfoRegistry; use crate::user::committee::Committee; diff --git a/consensus/src/lib.rs b/consensus/src/lib.rs index d864d897d7..a74c0360c4 100644 --- a/consensus/src/lib.rs +++ b/consensus/src/lib.rs @@ -12,9 +12,9 @@ pub mod user; mod aggregator; pub mod config; -pub mod contract_state; mod execution_ctx; mod msg_handler; +pub mod operations; mod phase; mod proposal; mod queue; diff --git a/consensus/src/phase.rs b/consensus/src/phase.rs index 44c1a34fdb..9603f38923 100644 --- a/consensus/src/phase.rs +++ b/consensus/src/phase.rs @@ -5,8 +5,8 @@ // Copyright (c) DUSK NETWORK. All rights reserved. use crate::commons::{ConsensusError, Database}; -use crate::contract_state::Operations; use crate::execution_ctx::ExecutionCtx; +use crate::operations::Operations; use node_data::message::Message; use node_data::StepName; diff --git a/consensus/src/proposal/block_generator.rs b/consensus/src/proposal/block_generator.rs index 801ae386be..97ca4a9e32 100644 --- a/consensus/src/proposal/block_generator.rs +++ b/consensus/src/proposal/block_generator.rs @@ -5,12 +5,12 @@ // Copyright (c) DUSK NETWORK. All rights reserved. use crate::commons::RoundUpdate; -use crate::contract_state::CallParams; +use crate::operations::CallParams; use node_data::ledger::{to_str, Block, Certificate, IterationsInfo, Seed}; use crate::config; -use crate::contract_state::Operations; use crate::merkle::merkle_root; +use crate::operations::Operations; use dusk_bytes::Serializable; use node_data::ledger; @@ -35,7 +35,7 @@ impl Generator { ru: &RoundUpdate, iteration: u8, failed_iterations: Vec>, - ) -> Result { + ) -> Result { // Sign seed let seed = ru .secret_key @@ -82,7 +82,7 @@ impl Generator { seed: Seed, iteration: u8, failed_iterations: Vec>, - ) -> Result { + ) -> Result { let start_time = Instant::now(); let call_params = CallParams { diff --git a/consensus/src/proposal/step.rs b/consensus/src/proposal/step.rs index 296dd43cff..d8bdfe520d 100644 --- a/consensus/src/proposal/step.rs +++ b/consensus/src/proposal/step.rs @@ -5,9 +5,9 @@ // Copyright (c) DUSK NETWORK. All rights reserved. use crate::commons::{ConsensusError, Database}; -use crate::contract_state::Operations; use crate::execution_ctx::ExecutionCtx; use crate::msg_handler::{HandleMsgOutput, MsgHandler}; +use crate::operations::Operations; use node_data::message::Message; use std::cmp; use std::sync::Arc; diff --git a/consensus/src/ratification/step.rs b/consensus/src/ratification/step.rs index c70bb154f0..45e80b08f4 100644 --- a/consensus/src/ratification/step.rs +++ b/consensus/src/ratification/step.rs @@ -5,8 +5,8 @@ // Copyright (c) DUSK NETWORK. All rights reserved. use crate::commons::{ConsensusError, Database, RoundUpdate}; -use crate::contract_state::Operations; use crate::execution_ctx::ExecutionCtx; +use crate::operations::Operations; use std::marker::PhantomData; use crate::msg_handler::{HandleMsgOutput, MsgHandler};