Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 61 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions stackslib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ developer-mode = ["clarity/developer-mode"]
monitoring_prom = ["prometheus"]
slog_json = ["stacks-common/slog_json", "clarity/slog_json", "pox-locking/slog_json"]
testing = ["chrono", "stacks-common/testing", "clarity/testing"]
profiler = ["perf-event2"]

[target.'cfg(all(target_os = "linux", target_arch = "x86_64"))'.dependencies]
perf-event2 = { version = "0.7.4", optional = true }

[target.'cfg(all(any(target_arch = "x86_64", target_arch = "x86", target_arch = "aarch64"), not(any(target_os="windows"))))'.dependencies]
sha2 = { version = "0.10", features = ["asm"] }
Expand Down
4 changes: 4 additions & 0 deletions stackslib/src/chainstate/stacks/db/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,10 @@ impl<'a, 'b> ClarityTx<'a, 'b> {
})
.expect("FATAL: `ust-liquid-supply` overflowed");
}

pub fn disable_fees(&mut self) {
self.block.no_fees = true;
}
}

pub struct ChainstateTx<'a> {
Expand Down
14 changes: 11 additions & 3 deletions stackslib/src/chainstate/stacks/db/transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,7 @@ impl StacksChainState {
}

StacksChainState::account_debit(clarity_tx, &payer_account.principal, fee);

Ok(fee)
}

Expand Down Expand Up @@ -1554,6 +1555,8 @@ impl StacksChainState {
debug!("Process transaction {} ({})", tx.txid(), tx.payload.name());
let epoch = clarity_block.get_epoch();

let no_fees = clarity_block.block.no_fees;

StacksChainState::process_transaction_precheck(&clarity_block.config, tx, epoch)?;

// what version of Clarity did the transaction caller want? And, is it valid now?
Expand All @@ -1578,7 +1581,10 @@ impl StacksChainState {

let payer_address = payer_account.principal.clone();
let payer_nonce = payer_account.nonce;
StacksChainState::pay_transaction_fee(&mut transaction, fee, payer_account)?;

if !no_fees {
StacksChainState::pay_transaction_fee(&mut transaction, fee, payer_account)?;
}

// origin balance may have changed (e.g. if the origin paid the tx fee), so reload the account
let origin_account =
Expand Down Expand Up @@ -1619,8 +1625,10 @@ impl StacksChainState {
None,
)?;

let new_payer_account = StacksChainState::get_payer_account(&mut transaction, tx);
StacksChainState::pay_transaction_fee(&mut transaction, fee, new_payer_account)?;
if !no_fees {
let new_payer_account = StacksChainState::get_payer_account(&mut transaction, tx);
StacksChainState::pay_transaction_fee(&mut transaction, fee, new_payer_account)?;
}

// update the account nonces
StacksChainState::update_account_nonce(
Expand Down
8 changes: 8 additions & 0 deletions stackslib/src/clarity_vm/clarity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ pub struct ClarityBlockConnection<'a, 'b> {
mainnet: bool,
chain_id: u32,
epoch: StacksEpochId,
pub no_fees: bool,
}

///
Expand Down Expand Up @@ -318,6 +319,7 @@ impl ClarityBlockConnection<'_, '_> {
mainnet: false,
chain_id: CHAIN_ID_TESTNET,
epoch,
no_fees: false,
}
}

Expand Down Expand Up @@ -444,6 +446,7 @@ impl ClarityInstance {
mainnet: self.mainnet,
chain_id: self.chain_id,
epoch: epoch.epoch_id,
no_fees: false,
}
}

Expand All @@ -468,6 +471,7 @@ impl ClarityInstance {
mainnet: self.mainnet,
chain_id: self.chain_id,
epoch,
no_fees: false,
}
}

Expand All @@ -494,6 +498,7 @@ impl ClarityInstance {
mainnet: self.mainnet,
chain_id: self.chain_id,
epoch,
no_fees: false,
};

let use_mainnet = self.mainnet;
Expand Down Expand Up @@ -590,6 +595,7 @@ impl ClarityInstance {
mainnet: self.mainnet,
chain_id: self.chain_id,
epoch,
no_fees: false,
};

let use_mainnet = self.mainnet;
Expand Down Expand Up @@ -698,6 +704,7 @@ impl ClarityInstance {
mainnet: self.mainnet,
chain_id: self.chain_id,
epoch: epoch.epoch_id,
no_fees: false,
}
}

Expand Down Expand Up @@ -738,6 +745,7 @@ impl ClarityInstance {
mainnet: self.mainnet,
chain_id: self.chain_id,
epoch: epoch.epoch_id,
no_fees: false,
}
}

Expand Down
Loading
Loading