diff --git a/rusk/src/lib/node/rusk.rs b/rusk/src/lib/node/rusk.rs index b76223657..8ec0e93a5 100644 --- a/rusk/src/lib/node/rusk.rs +++ b/rusk/src/lib/node/rusk.rs @@ -121,10 +121,11 @@ impl Rusk { let block_gas_limit = self.block_gas_limit; let generator = params.generator_pubkey.inner(); let to_slash = params.to_slash.clone(); + let prev_state_root = params.prev_state_root; let voters = ¶ms.voters_pubkey[..]; - let mut session = self.new_block_session(block_height, None)?; + let mut session = self.new_block_session(block_height, prev_state_root)?; let mut block_gas_left = block_gas_limit; @@ -179,7 +180,7 @@ impl Rusk { // transaction, since it is technically valid. if gas_spent > block_gas_left { info!("Skipping {tx_id_hex} due gas_spent {gas_spent} greater than left: {block_gas_left}"); - session = self.new_block_session(block_height, None)?; + session = self.new_block_session(block_height, prev_state_root)?; for spent_tx in &spent_txs { // We know these transactions were correctly @@ -259,6 +260,7 @@ impl Rusk { #[allow(clippy::too_many_arguments)] pub fn verify_transactions( &self, + prev_commit: [u8; 32], block_height: u64, block_hash: Hash, block_gas_limit: u64, @@ -267,7 +269,7 @@ impl Rusk { slashing: Vec, voters: &[Voter], ) -> Result<(Vec, VerificationOutput)> { - let session = self.new_block_session(block_height, None)?; + let session = self.new_block_session(block_height, prev_commit)?; accept( session, @@ -292,6 +294,7 @@ impl Rusk { #[allow(clippy::too_many_arguments)] pub fn accept_transactions( &self, + prev_commit: [u8; 32], block_height: u64, block_gas_limit: u64, block_hash: Hash, @@ -305,7 +308,7 @@ impl Rusk { VerificationOutput, Vec, )> { - let session = self.new_block_session(block_height, None)?; + let session = self.new_block_session(block_height, prev_commit)?; let (spent_txs, verification_output, session, events) = accept( session, @@ -472,9 +475,9 @@ impl Rusk { pub(crate) fn new_block_session( &self, block_height: u64, - commit: Option<[u8; 32]>, + commit: [u8; 32], ) -> Result { - let mut session = self._session(block_height, commit)?; + let mut session = self._session(block_height, Some(commit))?; let _: CallReceipt<()> = session .call(STAKE_CONTRACT, "before_state_transition", &(), u64::MAX) .expect("before_state_transition to success"); diff --git a/rusk/src/lib/node/vm.rs b/rusk/src/lib/node/vm.rs index e6b7b6f31..649944ccf 100644 --- a/rusk/src/lib/node/vm.rs +++ b/rusk/src/lib/node/vm.rs @@ -45,6 +45,7 @@ impl VMExecution for Rusk { fn verify_state_transition( &self, + prev_commit: [u8; 32], blk: &Block, voters: &[Voter], ) -> anyhow::Result { @@ -57,6 +58,7 @@ impl VMExecution for Rusk { let (_, verification_output) = self .verify_transactions( + prev_commit, blk.header().height, blk.header().hash, blk.header().gas_limit, @@ -72,6 +74,7 @@ impl VMExecution for Rusk { fn accept( &self, + prev_root: [u8; 32], blk: &Block, voters: &[Voter], ) -> anyhow::Result<( @@ -88,6 +91,7 @@ impl VMExecution for Rusk { let (txs, verification_output, stake_events) = self .accept_transactions( + prev_root, blk.header().height, blk.header().gas_limit, blk.header().hash,