Skip to content
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

Remove 3h compatibility code #3069

Merged
merged 7 commits into from
Sep 30, 2024
Merged
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
5 changes: 1 addition & 4 deletions crates/pallet-domains/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -628,9 +628,6 @@ mod pallet {
/// only store the consensus block hash for a domain
/// if that consensus block contains bundle of the domain, the hash will be pruned when the ER
/// that point to the consensus block is pruned.
///
/// TODO: this storage is unbounded in some cases, see https://github.com/autonomys/subspace/issues/1673
/// for more details, this will be fixed once https://github.com/autonomys/subspace/issues/1731 is implemented.
#[pallet::storage]
#[pallet::getter(fn consensus_block_info)]
pub type ConsensusBlockHash<T: Config> =
Expand Down Expand Up @@ -2240,7 +2237,7 @@ impl<T: Config> Pallet<T> {
fn validate_eligibility(
to_sign: &[u8],
signature: &OperatorSignature,
proof_of_election: &ProofOfElection<T::Hash>,
proof_of_election: &ProofOfElection,
domain_config: &DomainConfig<T::AccountId, BalanceOf<T>>,
pre_dispatch: bool,
) -> Result<(), BundleError> {
Expand Down
16 changes: 7 additions & 9 deletions crates/pallet-domains/src/staking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ pub(crate) struct Withdrawal<Balance, Share, DomainBlockNumber> {
/// Total amount of storage fee on withdraw (including withdrawal in shares)
pub(crate) total_storage_fee_withdrawal: Balance,
/// Individual withdrawal amounts with their unlocking block for a given domain
// TODO: fixed number of withdrawal & uhlock all ready withdrawal at once
pub(crate) withdrawals: VecDeque<WithdrawalInBalance<DomainBlockNumber, Balance>>,
/// Withdrawal that was initiated by nominator and not converted to balance due to
/// unfinished domain epoch.
Expand Down Expand Up @@ -191,8 +190,7 @@ pub struct Operator<Balance, Share, DomainBlockNumber> {
/// The status of the operator, it may be stale due to the `OperatorStatus::PendingSlash` is
/// not assigned to this field directly, thus MUST use the `status()` method to query the status
/// instead.
/// TODO: update the filed to `_status` to avoid accidental access in next network reset
status: OperatorStatus<DomainBlockNumber>,
partial_status: OperatorStatus<DomainBlockNumber>,
/// Total deposits during the previous epoch
pub deposits_in_epoch: Balance,
/// Total withdrew shares during the previous epoch
Expand All @@ -203,17 +201,17 @@ pub struct Operator<Balance, Share, DomainBlockNumber> {

impl<Balance, Share, DomainBlockNumber> Operator<Balance, Share, DomainBlockNumber> {
pub fn status<T: Config>(&self, operator_id: OperatorId) -> &OperatorStatus<DomainBlockNumber> {
if matches!(self.status, OperatorStatus::Slashed) {
if matches!(self.partial_status, OperatorStatus::Slashed) {
&OperatorStatus::Slashed
} else if Pallet::<T>::is_operator_pending_to_slash(self.current_domain_id, operator_id) {
&OperatorStatus::PendingSlash
} else {
&self.status
&self.partial_status
}
}

pub fn update_status(&mut self, new_status: OperatorStatus<DomainBlockNumber>) {
self.status = new_status;
self.partial_status = new_status;
}
}

Expand All @@ -233,7 +231,7 @@ impl<Balance: Zero, Share: Zero, DomainBlockNumber> Operator<Balance, Share, Dom
current_total_stake: Zero::zero(),
current_epoch_rewards: Zero::zero(),
current_total_shares: Zero::zero(),
status: OperatorStatus::Registered,
partial_status: OperatorStatus::Registered,
deposits_in_epoch: Zero::zero(),
withdrawals_in_epoch: Zero::zero(),
total_storage_fee_deposit: Zero::zero(),
Expand Down Expand Up @@ -401,7 +399,7 @@ pub fn do_register_operator<T: Config>(
current_total_stake: Zero::zero(),
current_epoch_rewards: Zero::zero(),
current_total_shares: Zero::zero(),
status: OperatorStatus::Registered,
partial_status: OperatorStatus::Registered,
// sum total deposits added during this epoch.
deposits_in_epoch: new_deposit.staking,
withdrawals_in_epoch: Zero::zero(),
Expand Down Expand Up @@ -1681,7 +1679,7 @@ pub(crate) mod tests {
current_total_stake: operator_stake,
current_epoch_rewards: 0,
current_total_shares: operator_stake,
status: OperatorStatus::Registered,
partial_status: OperatorStatus::Registered,
deposits_in_epoch: 0,
withdrawals_in_epoch: 0,
total_storage_fee_deposit: operator_storage_fee_deposit,
Expand Down
8 changes: 1 addition & 7 deletions crates/pallet-subspace-mmr/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@ pub use pallet::*;
use sp_core::Get;
use sp_mmr_primitives::{LeafDataProvider, OnNewRoot};
use sp_runtime::traits::{CheckedSub, One};
use sp_runtime::DigestItem;
use sp_subspace_mmr::subspace_mmr_runtime_interface::get_mmr_leaf_data;
use sp_subspace_mmr::{LeafDataV0, MmrDigest, MmrLeaf};
use sp_subspace_mmr::{LeafDataV0, MmrLeaf};

#[frame_support::pallet]
mod pallet {
Expand Down Expand Up @@ -56,11 +55,6 @@ mod pallet {

impl<T: Config> OnNewRoot<T::MmrRootHash> for Pallet<T> {
fn on_new_root(root: &T::MmrRootHash) {
// TODO: this digest is not used remove it before next network reset but keep it
// as is for now to keep compatible with gemini-3h.
let digest = DigestItem::new_mmr_root(*root);
<frame_system::Pallet<T>>::deposit_log(digest);

let block_number = frame_system::Pallet::<T>::block_number();
<MmrRootHashes<T>>::insert(block_number, *root);
if let Some(to_prune) = block_number.checked_sub(&T::MmrRootHashCount::get().into()) {
Expand Down
Loading
Loading