From 7b687f5f631e2c6b1d1a47c8ac9d37c098566712 Mon Sep 17 00:00:00 2001 From: Herr Seppia Date: Wed, 22 Jan 2025 16:36:27 +0100 Subject: [PATCH] vm: add `PUBLIC_SENDER` available to session Resolves #3341 --- vm/CHANGELOG.md | 5 +++++ vm/src/execute.rs | 17 +++++++++++------ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/vm/CHANGELOG.md b/vm/CHANGELOG.md index fb7d2961a2..662b6ed383 100644 --- a/vm/CHANGELOG.md +++ b/vm/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added + +- Add `PUBLIC_SENDER` available to session [#3341] + ### Changed - Change dependency declaration to not require strict equal [#3405] @@ -19,6 +23,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 [#3235]: https://github.com/dusk-network/rusk/issues/3235 +[#3341]: https://github.com/dusk-network/rusk/issues/3341 [#3405]: https://github.com/dusk-network/rusk/issues/3405 [Unreleased]: https://github.com/dusk-network/rusk/compare/dusk-vm-0.1.0...HEAD diff --git a/vm/src/execute.rs b/vm/src/execute.rs index 0ea09ee9f1..66e8a4b6a6 100644 --- a/vm/src/execute.rs +++ b/vm/src/execute.rs @@ -5,10 +5,9 @@ // Copyright (c) DUSK NETWORK. All rights reserved. use blake2b_simd::Params; -use dusk_core::abi::{ContractError, ContractId, CONTRACT_ID_BYTES}; -use dusk_core::transfer::{ - data::ContractBytecode, Transaction, TRANSFER_CONTRACT, -}; +use dusk_core::abi::{ContractError, ContractId, Metadata, CONTRACT_ID_BYTES}; +use dusk_core::transfer::data::ContractBytecode; +use dusk_core::transfer::{Transaction, TRANSFER_CONTRACT}; use piecrust::{CallReceipt, Error, Session}; /// Executes a transaction in the provided session. @@ -73,14 +72,20 @@ pub fn execute( // with gas limit smaller than deploy charge. deploy_check(tx, gas_per_deploy_byte, min_deploy_gas_price)?; + let _ = session + .set_meta(Metadata::PUBLIC_SENDER, tx.moonlight_sender().copied()); + // Spend the inputs and execute the call. If this errors the transaction is // unspendable. - let mut receipt = session.call::<_, Result, ContractError>>( + let receipt = session.call::<_, Result, ContractError>>( TRANSFER_CONTRACT, "spend_and_execute", tx.strip_off_bytecode().as_ref().unwrap_or(tx), tx.gas_limit(), - )?; + ); + + let _ = session.remove_meta(Metadata::PUBLIC_SENDER); + let mut receipt = receipt?; // Deploy if this is a deployment transaction and spend part is successful. contract_deploy(