Skip to content

Commit

Permalink
fix(validations): apply timelock validations fix
Browse files Browse the repository at this point in the history
  • Loading branch information
aesedepece committed Jan 28, 2025
1 parent 203fea0 commit 6ef0aa7
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion bridges/centralized-ethereum/src/actors/dr_sender.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ impl DrSender {
// Error sending transaction: node not synced, not enough balance, etc.
// Do nothing, will retry later.
log::error!("[{}] >< cannot broadcast dr_tx: {}", dr_id, e);
// In this case, refrain from trying to send remaining data requests,
// In this case, refrain from trying to send remaining data requests,
// and let the dr_sender actor try again on next poll.
return witnet_node_pkh;
}
Expand Down
17 changes: 12 additions & 5 deletions data_structures/src/transaction_factory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,18 @@ use std::{

use serde::{Deserialize, Serialize};

use crate::transaction::UnstakeTransactionBody;
use crate::{
chain::{
DataRequestOutput, Epoch, EpochConstants, Input, OutputPointer, PublicKeyHash, StakeOutput,
ValueTransferOutput,
DataRequestOutput, Environment, Epoch, EpochConstants, Input, OutputPointer, PublicKeyHash,
StakeOutput, ValueTransferOutput,
},
error::TransactionError,
fee::{AbsoluteFee, Fee},
transaction::{DRTransactionBody, StakeTransactionBody, VTTransactionBody, INPUT_SIZE},
get_environment,
transaction::{
DRTransactionBody, StakeTransactionBody, UnstakeTransactionBody, VTTransactionBody,
INPUT_SIZE,
},
utxo_pool::{
NodeUtxos, NodeUtxosRef, OwnUnspentOutputsPool, UnspentOutputsPool, UtxoDiff,
UtxoSelectionStrategy,
Expand Down Expand Up @@ -677,7 +680,11 @@ pub fn transaction_inputs_sum(
// Verify that commits are only accepted after the time lock expired
let (epoch_timestamp, _) = epoch_constants.epoch_timestamp(epoch)?;
let vt_time_lock = i64::try_from(vt_output.time_lock)?;
if vt_time_lock > epoch_timestamp {
if (get_environment() == Environment::Development
|| get_environment() == Environment::Testnet)
&& epoch > 22_000
&& vt_time_lock > epoch_timestamp
{
return Err(TransactionError::TimeLock {
expected: vt_time_lock,
current: epoch_timestamp,
Expand Down
2 changes: 1 addition & 1 deletion validations/src/validations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1500,7 +1500,7 @@ pub fn validate_unstake_transaction<'a>(
// TODO: remove this check for mainnet release
if (get_environment() == Environment::Development
|| get_environment() == Environment::Testnet)
&& epoch > 20_000
&& epoch > 22_000
{
let nonce = stake_entry.first().map(|stake| stake.value.nonce).unwrap();
if ut_tx.body.nonce != nonce {
Expand Down

0 comments on commit 6ef0aa7

Please sign in to comment.