Skip to content

fix: increase proposal review period duration to 96 hours #129

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
38 changes: 30 additions & 8 deletions src/backend/impl/src/repositories/proposal_repository.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ mod tests {
use super::*;
use crate::{
fixtures::{self, date_time_a, date_time_b, date_time_c},
repositories::NervousSystem,
repositories::{NervousSystem, PROPOSAL_REVIEW_PERIOD_DURATION},
system_api::get_date_time,
};
use chrono::Duration;
Expand Down Expand Up @@ -401,8 +401,8 @@ mod tests {
.get_proposals(Some(ReviewPeriodStateKey::Completed))
.unwrap();

assert_eq!(in_progress_result.len(), 4);
assert_eq!(completed_result.len(), 2);
assert_eq!(in_progress_result.len(), 5);
assert_eq!(completed_result.len(), 3);
}

#[fixture]
Expand Down Expand Up @@ -441,20 +441,42 @@ mod tests {
Proposal {
state: ReviewPeriodState::InProgress,
..fixtures::nns_replica_version_management_proposal(
Some(
DateTime::new(current_time - Duration::hours(48) - Duration::minutes(1))
.unwrap(),
),
Some(DateTime::new(current_time - Duration::hours(48)).unwrap()),
Some(130396),
)
},
Proposal {
state: ReviewPeriodState::InProgress,
..fixtures::nns_replica_version_management_proposal(
Some(DateTime::new(current_time - Duration::hours(60)).unwrap()),
Some(DateTime::new(current_time - PROPOSAL_REVIEW_PERIOD_DURATION).unwrap()),
Some(130395),
)
},
Proposal {
state: ReviewPeriodState::InProgress,
..fixtures::nns_replica_version_management_proposal(
Some(
DateTime::new(
current_time - (PROPOSAL_REVIEW_PERIOD_DURATION + Duration::minutes(1)),
)
.unwrap(),
),
Some(130394),
)
},
Proposal {
state: ReviewPeriodState::InProgress,
..fixtures::nns_replica_version_management_proposal(
Some(
DateTime::new(
current_time
- (PROPOSAL_REVIEW_PERIOD_DURATION.checked_mul(2).unwrap()),
)
.unwrap(),
),
Some(130393),
)
},
]
}

Expand Down
19 changes: 14 additions & 5 deletions src/backend/impl/src/repositories/types/proposal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ use ic_stable_structures::{
};
use std::{borrow::Cow, ops::RangeBounds};

pub(crate) const PROPOSAL_REVIEW_PERIOD_DURATION: Duration = Duration::hours(96);

pub type ProposalId = Uuid;
pub type NervousSystemProposalId = u64;
pub type NeuronId = u64;
Expand Down Expand Up @@ -135,10 +137,10 @@ impl Storable for Proposal {

impl Proposal {
/// Checks if the proposal is in [ReviewPeriodState::InProgress] state
/// and was proposed more than **48 hours** ago.
/// and was proposed more than [PROPOSAL_REVIEW_PERIOD_DURATION].
pub fn is_pending(&self, current_time: &DateTime) -> bool {
self.state == ReviewPeriodState::InProgress
&& self.proposed_at().unwrap() <= current_time.sub(Duration::hours(48))
&& self.proposed_at().unwrap() <= current_time.sub(PROPOSAL_REVIEW_PERIOD_DURATION)
}

/// Checks if the proposal is in [ReviewPeriodState::Completed] state.
Expand Down Expand Up @@ -487,16 +489,23 @@ mod tests {
state: ReviewPeriodState::InProgress,
..fixtures::nns_replica_version_management_proposal(
Some(
DateTime::new(current_time - Duration::hours(48) - Duration::minutes(1))
.unwrap(),
DateTime::new(
current_time - (PROPOSAL_REVIEW_PERIOD_DURATION + Duration::minutes(1)),
)
.unwrap(),
),
None,
)
},
Proposal {
state: ReviewPeriodState::InProgress,
..fixtures::nns_replica_version_management_proposal(
Some(DateTime::new(current_time - Duration::hours(60)).unwrap()),
Some(
DateTime::new(
current_time - PROPOSAL_REVIEW_PERIOD_DURATION.checked_mul(2).unwrap(),
)
.unwrap(),
),
None,
)
},
Expand Down
6 changes: 3 additions & 3 deletions src/backend/integration/src/support/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ export async function createProposal(
}

/**
* The review period is **48 hours** in milliseconds.
* The review period is **96 hours** in milliseconds.
*/
export const REVIEW_PERIOD_MS = 48 * 60 * 60 * 1000;
export const PROPOSAL_REVIEW_PERIOD_MS = 96 * 60 * 60 * 1000;

/**
* Advances PIC's time in order to make the proposal complete.
Expand All @@ -75,7 +75,7 @@ export async function completeProposal(
proposalId: string,
) {
// advance time to make the proposal expire
await pic.advanceTime(REVIEW_PERIOD_MS);
await pic.advanceTime(PROPOSAL_REVIEW_PERIOD_MS);
// ensure timers run
await pic.tick(2);

Expand Down
6 changes: 3 additions & 3 deletions src/backend/integration/src/tests/proposal.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { describe, beforeEach, afterEach, it, expect } from 'bun:test';
import {
Governance,
REVIEW_PERIOD_MS,
PROPOSAL_REVIEW_PERIOD_MS,
TestDriver,
extractErrResponse,
extractOkResponse,
Expand Down Expand Up @@ -31,7 +31,7 @@ describe('Proposal', () => {
};

const advanceTimeToCompleteProposals = async () => {
await driver.advanceTime(REVIEW_PERIOD_MS + 1);
await driver.advanceTime(PROPOSAL_REVIEW_PERIOD_MS + 1);
};

const createProposalsBatch = async (count: number): Promise<bigint[]> => {
Expand Down Expand Up @@ -180,7 +180,7 @@ describe('Proposal', () => {
expectListProposalsResult(resInProgress);

// advance time, but do not reach the review deadline
await driver.advanceTime(REVIEW_PERIOD_MS - advancedTimeMs - 1);
await driver.advanceTime(PROPOSAL_REVIEW_PERIOD_MS - advancedTimeMs - 1);

const resCompleted = await driver.actor.list_proposals({
state: [{ completed: null }],
Expand Down