Skip to content

Commit

Permalink
chore(timelock): remove environment-based timelock code for mainnet r…
Browse files Browse the repository at this point in the history
…elease
  • Loading branch information
drcpu-github committed Jan 29, 2025
1 parent d009da4 commit c7b5bc9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 17 deletions.
15 changes: 6 additions & 9 deletions data_structures/src/transaction_factory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@ use serde::{Deserialize, Serialize};

use crate::{
chain::{
DataRequestOutput, Environment, Epoch, EpochConstants, Input, OutputPointer, PublicKeyHash,
StakeOutput, ValueTransferOutput,
DataRequestOutput, Epoch, EpochConstants, Input, OutputPointer, PublicKeyHash, StakeOutput,
ValueTransferOutput,
},
error::TransactionError,
fee::{AbsoluteFee, Fee},
get_environment,
transaction::{
DRTransactionBody, StakeTransactionBody, UnstakeTransactionBody, VTTransactionBody,
INPUT_SIZE,
Expand Down Expand Up @@ -681,13 +680,11 @@ pub fn transaction_inputs_sum(
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::Mainnet || epoch > 22_000 {
return Err(TransactionError::TimeLock {
expected: vt_time_lock,
current: epoch_timestamp,
}
.into());
return Err(TransactionError::TimeLock {
expected: vt_time_lock,
current: epoch_timestamp,
}
.into());
} else {
if !seen_output_pointers.insert(input.output_pointer()) {
// If the set already contained this output pointer
Expand Down
13 changes: 5 additions & 8 deletions validations/src/validations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@ use witnet_data_structures::{
chain::{
tapi::ActiveWips, Block, BlockMerkleRoots, CheckpointBeacon, CheckpointVRF,
ConsensusConstants, ConsensusConstantsWit2, DataRequestOutput, DataRequestStage,
DataRequestState, Environment, Epoch, EpochConstants, Hash, Hashable, Input,
KeyedSignature, OutputPointer, PublicKeyHash, RADRequest, RADTally, RADType, Reputation,
ReputationEngine, SignaturesToVerify, StakeOutput, ValueTransferOutput,
DataRequestState, Epoch, EpochConstants, Hash, Hashable, Input, KeyedSignature,
OutputPointer, PublicKeyHash, RADRequest, RADTally, RADType, Reputation, ReputationEngine,
SignaturesToVerify, StakeOutput, ValueTransferOutput,
},
data_request::{
calculate_reward_collateral_ratio, calculate_tally_change, calculate_witness_reward,
calculate_witness_reward_before_second_hard_fork, create_tally,
data_request_has_too_many_witnesses, DataRequestPool,
},
error::{BlockError, DataRequestError, TransactionError},
get_environment, get_protocol_version, get_protocol_version_activation_epoch,
get_protocol_version, get_protocol_version_activation_epoch,
proto::versioning::{ProtocolVersion, VersionedHashable},
radon_report::{RadonReport, ReportContext},
staking::prelude::{Power, QueryStakesKey, StakeKey, StakesTracker},
Expand Down Expand Up @@ -1497,11 +1497,8 @@ pub fn validate_unstake_transaction<'a>(
}

// TODO: modify this to enable delegated staking with multiple withdrawer addresses on a single validator
// TODO: remove this check for mainnet release
let nonce = stake_entry.first().map(|stake| stake.value.nonce).unwrap();
if (get_environment() == Environment::Mainnet || epoch > 22_000)
&& ut_tx.body.nonce != nonce
{
if ut_tx.body.nonce != nonce {
return Err(TransactionError::UnstakeInvalidNonce {
used: ut_tx.body.nonce,
current: nonce,
Expand Down

0 comments on commit c7b5bc9

Please sign in to comment.