Skip to content

Commit

Permalink
dusk-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 24, 2025
1 parent f6aaa40 commit 648126c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
12 changes: 11 additions & 1 deletion vm/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

[1.0.0] - 2025-01-23
### Added

- Add `PUBLIC_SENDER` available to session [#3341]

### Changed

- Change `dusk-core` dependency to `1.0.1-alpha` [#3341]
- Change `piecrust` dependency to `0.27.1` [#3341]

## [1.0.0] - 2025-01-23

### Changed

Expand All @@ -21,6 +30,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-1.0.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 648126c

Please sign in to comment.