From b2dbcbb6033787de57a1c9f8223c30d44797ec9f Mon Sep 17 00:00:00 2001 From: kennycud Date: Mon, 13 Jan 2025 13:52:17 -0800 Subject: [PATCH] made adjustments to support the ignore level feature trigger and removed the fail-safe feature trigger since the ignore level feature trigger now satisfies it implicitly --- src/main/java/org/qortal/block/Block.java | 45 +++++++++---------- .../java/org/qortal/block/BlockChain.java | 5 --- src/main/resources/blockchain.json | 1 - 3 files changed, 22 insertions(+), 29 deletions(-) diff --git a/src/main/java/org/qortal/block/Block.java b/src/main/java/org/qortal/block/Block.java index e22d7993..21cbddc4 100644 --- a/src/main/java/org/qortal/block/Block.java +++ b/src/main/java/org/qortal/block/Block.java @@ -418,7 +418,9 @@ public class Block { onlineAccounts.removeIf(a -> a.getNonce() == null || a.getNonce() < 0); // After feature trigger, remove any online accounts that are level 0 - if (height >= BlockChain.getInstance().getOnlineAccountMinterLevelValidationHeight()) { + // but only if they are before the ignore level feature trigger + if (height < BlockChain.getInstance().getIgnoreLevelForRewardShareHeight() && + height >= BlockChain.getInstance().getOnlineAccountMinterLevelValidationHeight()) { onlineAccounts.removeIf(a -> { try { return Account.getRewardShareEffectiveMintingLevel(repository, a.getPublicKey()) == 0; @@ -1161,34 +1163,31 @@ public class Block { if (onlineRewardShares == null) return ValidationResult.ONLINE_ACCOUNT_UNKNOWN; - // After feature trigger, require all online account minters to be greater than level 0 - if (this.getBlockData().getHeight() >= BlockChain.getInstance().getOnlineAccountMinterLevelValidationHeight()) { - if( this.blockData.getHeight() < BlockChain.getInstance().getOnlineValidationFailSafeHeight()) { - List expandedAccounts + // After feature trigger, require all online account minters to be greater than level 0, + // but only if it is before the feature trigger where we ignore level again + if (this.blockData.getHeight() < BlockChain.getInstance().getIgnoreLevelForRewardShareHeight() && + this.getBlockData().getHeight() >= BlockChain.getInstance().getOnlineAccountMinterLevelValidationHeight()) { + List expandedAccounts = this.getExpandedAccounts().stream() - .filter(expandedAccount -> expandedAccount.isMinterMember) - .collect(Collectors.toList()); + .filter(expandedAccount -> expandedAccount.isMinterMember) + .collect(Collectors.toList()); - for (ExpandedAccount account : expandedAccounts) { - if (account.getMintingAccount().getEffectiveMintingLevel() == 0) + for (ExpandedAccount account : expandedAccounts) { + if (account.getMintingAccount().getEffectiveMintingLevel() == 0) + return ValidationResult.ONLINE_ACCOUNTS_INVALID; + + if (this.getBlockData().getHeight() >= BlockChain.getInstance().getFixBatchRewardHeight()) { + if (!account.isMinterMember) return ValidationResult.ONLINE_ACCOUNTS_INVALID; - - if (this.getBlockData().getHeight() >= BlockChain.getInstance().getFixBatchRewardHeight()) { - if (!account.isMinterMember) - return ValidationResult.ONLINE_ACCOUNTS_INVALID; - } } } - // this.blockData.getHeight() >= BlockChain.getInstance().getOnlineValidationFailSafeHeight() - else { - Optional anyInvalidAccount + } + else if (this.blockData.getHeight() >= BlockChain.getInstance().getIgnoreLevelForRewardShareHeight()){ + Optional anyInvalidAccount = this.getExpandedAccounts().stream() - .filter( - account -> account.getEffectiveMintingLevel() == 0 || - !account.isMinterMember) - .findAny(); - if( anyInvalidAccount.isPresent() ) return ValidationResult.ONLINE_ACCOUNTS_INVALID; - } + .filter(account -> !account.isMinterMember) + .findAny(); + if( anyInvalidAccount.isPresent() ) return ValidationResult.ONLINE_ACCOUNTS_INVALID; } // If block is past a certain age then we simply assume the signatures were correct diff --git a/src/main/java/org/qortal/block/BlockChain.java b/src/main/java/org/qortal/block/BlockChain.java index 358874c5..ef20abe8 100644 --- a/src/main/java/org/qortal/block/BlockChain.java +++ b/src/main/java/org/qortal/block/BlockChain.java @@ -90,7 +90,6 @@ public class BlockChain { groupMemberCheckHeight, fixBatchRewardHeight, adminsReplaceFoundersHeight, - onlineValidationFailSafeHeight, nullGroupMembershipHeight, ignoreLevelForRewardShareHeight } @@ -670,10 +669,6 @@ public class BlockChain { return this.featureTriggers.get(FeatureTrigger.adminsReplaceFoundersHeight.name()).intValue(); } - public int getOnlineValidationFailSafeHeight() { - return this.featureTriggers.get(FeatureTrigger.onlineValidationFailSafeHeight.name()).intValue(); - } - public int getNullGroupMembershipHeight() { return this.featureTriggers.get(FeatureTrigger.nullGroupMembershipHeight.name()).intValue(); } diff --git a/src/main/resources/blockchain.json b/src/main/resources/blockchain.json index 2cbacd97..f1a7e76a 100644 --- a/src/main/resources/blockchain.json +++ b/src/main/resources/blockchain.json @@ -115,7 +115,6 @@ "groupMemberCheckHeight": 1902700, "fixBatchRewardHeight": 1945900, "adminsReplaceFoundersHeight": 9999999, - "onlineValidationFailSafeHeight": 9999999, "nullGroupMembershipHeight": 9999999, "ignoreLevelForRewardShareHeight": 9999999 },