Skip to content

Commit

Permalink
vm: add PUBLIC_SENDER available to session
Browse files Browse the repository at this point in the history
Resolves #3341
  • Loading branch information
herr-seppia committed Jan 22, 2025
1 parent fe2670a commit 7b687f5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
5 changes: 5 additions & 0 deletions vm/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -19,6 +23,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

<!-- Issues -->
[#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
Expand Down
17 changes: 11 additions & 6 deletions vm/src/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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<Vec<u8>, ContractError>>(
let receipt = session.call::<_, Result<Vec<u8>, 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(
Expand Down

0 comments on commit 7b687f5

Please sign in to comment.