forked from Qortal/qortal
Revert enable heckpoints, raise private mail size and add testnet
This commit is contained in:
parent
708a978de0
commit
21257065ff
@ -167,7 +167,7 @@ public enum Service {
|
||||
COMMENT(1800, true, 500*1024L, true, false, null),
|
||||
CHAIN_COMMENT(1810, true, 239L, true, false, null),
|
||||
MAIL(1900, true, 1024*1024L, true, false, null),
|
||||
MAIL_PRIVATE(1901, true, 1024*1024L, true, true, null),
|
||||
MAIL_PRIVATE(1901, true, 5*1024*1024L, true, true, null),
|
||||
MESSAGE(1910, true, 1024*1024L, true, false, null),
|
||||
MESSAGE_PRIVATE(1911, true, 1024*1024L, true, true, null);
|
||||
|
||||
|
@ -29,6 +29,7 @@ import org.qortal.repository.ATRepository;
|
||||
import org.qortal.repository.DataException;
|
||||
import org.qortal.repository.Repository;
|
||||
import org.qortal.repository.TransactionRepository;
|
||||
import org.qortal.settings.Settings;
|
||||
import org.qortal.transaction.AtTransaction;
|
||||
import org.qortal.transaction.Transaction;
|
||||
import org.qortal.transaction.Transaction.ApprovalStatus;
|
||||
@ -104,6 +105,7 @@ public class Block {
|
||||
protected Repository repository;
|
||||
protected BlockData blockData;
|
||||
protected PublicKeyAccount minter;
|
||||
boolean isTestnet = Settings.getInstance().isTestNet();
|
||||
|
||||
// Other properties
|
||||
private static final Logger LOGGER = LogManager.getLogger(Block.class);
|
||||
@ -1281,21 +1283,20 @@ public class Block {
|
||||
// Create repository savepoint here so we can rollback to it after testing transactions
|
||||
repository.setSavepoint();
|
||||
|
||||
if (this.blockData.getHeight() == 212937) {
|
||||
// Apply fix for block 212937 but fix will be rolled back before we exit method
|
||||
Block212937.processFix(this);
|
||||
}
|
||||
else if (this.blockData.getHeight() == 1333492) {
|
||||
// Apply fix for block 1333492 but fix will be rolled back before we exit method
|
||||
Block1333492.processFix(this);
|
||||
}
|
||||
else if (InvalidNameRegistrationBlocks.isAffectedBlock(this.blockData.getHeight())) {
|
||||
// Apply fix for affected name registration blocks, but fix will be rolled back before we exit method
|
||||
InvalidNameRegistrationBlocks.processFix(this);
|
||||
}
|
||||
else if (InvalidBalanceBlocks.isAffectedBlock(this.blockData.getHeight())) {
|
||||
// Apply fix for affected balance blocks, but fix will be rolled back before we exit method
|
||||
InvalidBalanceBlocks.processFix(this);
|
||||
if (!isTestnet) {
|
||||
if (this.blockData.getHeight() == 212937) {
|
||||
// Apply fix for block 212937 but fix will be rolled back before we exit method
|
||||
Block212937.processFix(this);
|
||||
} else if (this.blockData.getHeight() == 1333492) {
|
||||
// Apply fix for block 1333492 but fix will be rolled back before we exit method
|
||||
Block1333492.processFix(this);
|
||||
} else if (InvalidNameRegistrationBlocks.isAffectedBlock(this.blockData.getHeight())) {
|
||||
// Apply fix for affected name registration blocks, but fix will be rolled back before we exit method
|
||||
InvalidNameRegistrationBlocks.processFix(this);
|
||||
} else if (InvalidBalanceBlocks.isAffectedBlock(this.blockData.getHeight())) {
|
||||
// Apply fix for affected balance blocks, but fix will be rolled back before we exit method
|
||||
InvalidBalanceBlocks.processFix(this);
|
||||
}
|
||||
}
|
||||
|
||||
for (Transaction transaction : this.getTransactions()) {
|
||||
@ -1558,26 +1559,23 @@ public class Block {
|
||||
processBlockRewards();
|
||||
}
|
||||
|
||||
if (this.blockData.getHeight() == 212937) {
|
||||
// Apply fix for block 212937
|
||||
Block212937.processFix(this);
|
||||
}
|
||||
else if (this.blockData.getHeight() == 1333492) {
|
||||
// Apply fix for block 1333492
|
||||
Block1333492.processFix(this);
|
||||
}
|
||||
else if (InvalidBalanceBlocks.isAffectedBlock(this.blockData.getHeight())) {
|
||||
// Apply fix for affected balance blocks
|
||||
InvalidBalanceBlocks.processFix(this);
|
||||
}
|
||||
else if (this.blockData.getHeight() == BlockChain.getInstance().getSelfSponsorshipAlgoV1Height()) {
|
||||
SelfSponsorshipAlgoV1Block.processAccountPenalties(this);
|
||||
}
|
||||
else if (this.blockData.getHeight() == BlockChain.getInstance().getSelfSponsorshipAlgoV2Height()) {
|
||||
SelfSponsorshipAlgoV2Block.processAccountPenalties(this);
|
||||
}
|
||||
else if (this.blockData.getHeight() == BlockChain.getInstance().getSelfSponsorshipAlgoV3Height()) {
|
||||
SelfSponsorshipAlgoV3Block.processAccountPenalties(this);
|
||||
if (!isTestnet) {
|
||||
if (this.blockData.getHeight() == 212937) {
|
||||
// Apply fix for block 212937
|
||||
Block212937.processFix(this);
|
||||
} else if (this.blockData.getHeight() == 1333492) {
|
||||
// Apply fix for block 1333492
|
||||
Block1333492.processFix(this);
|
||||
} else if (InvalidBalanceBlocks.isAffectedBlock(this.blockData.getHeight())) {
|
||||
// Apply fix for affected balance blocks
|
||||
InvalidBalanceBlocks.processFix(this);
|
||||
} else if (this.blockData.getHeight() == BlockChain.getInstance().getSelfSponsorshipAlgoV1Height()) {
|
||||
SelfSponsorshipAlgoV1Block.processAccountPenalties(this);
|
||||
} else if (this.blockData.getHeight() == BlockChain.getInstance().getSelfSponsorshipAlgoV2Height()) {
|
||||
SelfSponsorshipAlgoV2Block.processAccountPenalties(this);
|
||||
} else if (this.blockData.getHeight() == BlockChain.getInstance().getSelfSponsorshipAlgoV3Height()) {
|
||||
SelfSponsorshipAlgoV3Block.processAccountPenalties(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1863,26 +1861,23 @@ public class Block {
|
||||
// Invalidate expandedAccounts as they may have changed due to orphaning TRANSFER_PRIVS transactions, etc.
|
||||
this.cachedExpandedAccounts = null;
|
||||
|
||||
if (this.blockData.getHeight() == 212937) {
|
||||
// Revert fix for block 212937
|
||||
Block212937.orphanFix(this);
|
||||
}
|
||||
else if (this.blockData.getHeight() == 1333492) {
|
||||
// Revert fix for block 1333492
|
||||
Block1333492.orphanFix(this);
|
||||
}
|
||||
else if (InvalidBalanceBlocks.isAffectedBlock(this.blockData.getHeight())) {
|
||||
// Revert fix for affected balance blocks
|
||||
InvalidBalanceBlocks.orphanFix(this);
|
||||
}
|
||||
else if (this.blockData.getHeight() == BlockChain.getInstance().getSelfSponsorshipAlgoV1Height()) {
|
||||
SelfSponsorshipAlgoV1Block.orphanAccountPenalties(this);
|
||||
}
|
||||
else if (this.blockData.getHeight() == BlockChain.getInstance().getSelfSponsorshipAlgoV2Height()) {
|
||||
SelfSponsorshipAlgoV2Block.orphanAccountPenalties(this);
|
||||
}
|
||||
else if (this.blockData.getHeight() == BlockChain.getInstance().getSelfSponsorshipAlgoV3Height()) {
|
||||
SelfSponsorshipAlgoV3Block.orphanAccountPenalties(this);
|
||||
if (!isTestnet) {
|
||||
if (this.blockData.getHeight() == 212937) {
|
||||
// Revert fix for block 212937
|
||||
Block212937.orphanFix(this);
|
||||
} else if (this.blockData.getHeight() == 1333492) {
|
||||
// Revert fix for block 1333492
|
||||
Block1333492.orphanFix(this);
|
||||
} else if (InvalidBalanceBlocks.isAffectedBlock(this.blockData.getHeight())) {
|
||||
// Revert fix for affected balance blocks
|
||||
InvalidBalanceBlocks.orphanFix(this);
|
||||
} else if (this.blockData.getHeight() == BlockChain.getInstance().getSelfSponsorshipAlgoV1Height()) {
|
||||
SelfSponsorshipAlgoV1Block.orphanAccountPenalties(this);
|
||||
} else if (this.blockData.getHeight() == BlockChain.getInstance().getSelfSponsorshipAlgoV2Height()) {
|
||||
SelfSponsorshipAlgoV2Block.orphanAccountPenalties(this);
|
||||
} else if (this.blockData.getHeight() == BlockChain.getInstance().getSelfSponsorshipAlgoV3Height()) {
|
||||
SelfSponsorshipAlgoV3Block.orphanAccountPenalties(this);
|
||||
}
|
||||
}
|
||||
|
||||
// Account levels and block rewards are only processed/orphaned on block reward distribution blocks
|
||||
|
@ -806,17 +806,18 @@ public class BlockChain {
|
||||
* @throws SQLException
|
||||
*/
|
||||
public static void validate() throws DataException {
|
||||
|
||||
boolean isTopOnly = Settings.getInstance().isTopOnly();
|
||||
boolean archiveEnabled = Settings.getInstance().isArchiveEnabled();
|
||||
boolean isLite = Settings.getInstance().isLite();
|
||||
boolean canBootstrap = Settings.getInstance().getBootstrap();
|
||||
boolean needsArchiveRebuild = false;
|
||||
boolean checkPointFailed = false;
|
||||
int currentChainHeight = 0;
|
||||
int checkPointHeight = 0;
|
||||
int checkHeight = 0;
|
||||
BlockData chainTip;
|
||||
|
||||
try (final Repository repository = RepositoryManager.getRepository()) {
|
||||
currentChainHeight = repository.getBlockRepository().getBlockchainHeight();
|
||||
chainTip = repository.getBlockRepository().getLastBlock();
|
||||
checkHeight = repository.getBlockRepository().getBlockchainHeight();
|
||||
|
||||
// Ensure archive is (at least partially) intact, and force a bootstrap if it isn't
|
||||
if (!isTopOnly && archiveEnabled && canBootstrap) {
|
||||
@ -832,57 +833,50 @@ public class BlockChain {
|
||||
}
|
||||
}
|
||||
|
||||
// Validate bootstrap
|
||||
if (!canBootstrap) {
|
||||
if (currentChainHeight > 2) {
|
||||
if (checkHeight > 2) {
|
||||
LOGGER.info("Retrieved block 2 from archive. Syncing from genesis block resumed!");
|
||||
} else {
|
||||
needsArchiveRebuild = (repository.getBlockArchiveRepository().fromHeight(2) == null);
|
||||
if (needsArchiveRebuild) {
|
||||
LOGGER.info("Couldn't retrieve block 2 from archive. Bootstrapping is disabled. Syncing from genesis block!");
|
||||
|
||||
// If there are minting accounts, make sure to back them up
|
||||
// Don't backup if there are no minting accounts, as this can cause problems
|
||||
if (!repository.getAccountRepository().getMintingAccounts().isEmpty()) {
|
||||
Controller.getInstance().exportRepositoryData();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Validate checkpoints
|
||||
if (!isTopOnly && !isLite) {
|
||||
// Limited to topOnly nodes for now, in order to reduce risk, and to solve a real-world problem with divergent topOnly nodes
|
||||
// TODO: remove the isTopOnly conditional below once this feature has had more testing time
|
||||
if (isTopOnly && !isLite) {
|
||||
List<Checkpoint> checkpoints = BlockChain.getInstance().getCheckpoints();
|
||||
for (Checkpoint checkpoint : checkpoints) {
|
||||
checkPointHeight = checkpoint.height;
|
||||
if (currentChainHeight > checkPointHeight) {
|
||||
BlockData blockData = repository.getBlockRepository().fromHeight(checkpoint.height);
|
||||
if (blockData == null) {
|
||||
// Try the archive
|
||||
blockData = repository.getBlockArchiveRepository().fromHeight(checkpoint.height);
|
||||
}
|
||||
if (blockData == null) {
|
||||
LOGGER.trace("Couldn't find block for height {}", checkpoint.height);
|
||||
// This is likely due to the block being pruned, so is safe to ignore.
|
||||
// Continue, as there might be other blocks we can check more definitively.
|
||||
continue;
|
||||
}
|
||||
|
||||
byte[] signature = Base58.decode(checkpoint.signature);
|
||||
if (!Arrays.equals(signature, blockData.getSignature())) {
|
||||
LOGGER.info("Error: block at height {} with sig: {} doesn't match checkpoint sig: {}. Bootstrapping / Resync...", checkpoint.height, Base58.encode(blockData.getSignature()), checkpoint.signature);
|
||||
checkPointFailed = true;
|
||||
break;
|
||||
}
|
||||
LOGGER.info("Block at height {} matches checkpoint signature", blockData.getHeight());
|
||||
BlockData blockData = repository.getBlockRepository().fromHeight(checkpoint.height);
|
||||
if (blockData == null) {
|
||||
// Try the archive
|
||||
blockData = repository.getBlockArchiveRepository().fromHeight(checkpoint.height);
|
||||
}
|
||||
if (blockData == null) {
|
||||
LOGGER.trace("Couldn't find block for height {}", checkpoint.height);
|
||||
// This is likely due to the block being pruned, so is safe to ignore.
|
||||
// Continue, as there might be other blocks we can check more definitively.
|
||||
continue;
|
||||
}
|
||||
|
||||
byte[] signature = Base58.decode(checkpoint.signature);
|
||||
if (!Arrays.equals(signature, blockData.getSignature())) {
|
||||
LOGGER.info("Error: block at height {} with signature {} doesn't match checkpoint sig: {}. Bootstrapping...", checkpoint.height, Base58.encode(blockData.getSignature()), checkpoint.signature);
|
||||
needsArchiveRebuild = true;
|
||||
break;
|
||||
}
|
||||
LOGGER.info("Block at height {} matches checkpoint signature", blockData.getHeight());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Check first block is Genesis Block
|
||||
if (!isGenesisBlockValid() || needsArchiveRebuild) {
|
||||
if (!canBootstrap && currentChainHeight < 3) {
|
||||
if (checkHeight < 3) {
|
||||
try {
|
||||
rebuildBlockchain();
|
||||
} catch (InterruptedException e) {
|
||||
@ -891,20 +885,6 @@ public class BlockChain {
|
||||
}
|
||||
}
|
||||
|
||||
// If checkpoint failed resync or bootstrap
|
||||
if (checkPointFailed) {
|
||||
try (final Repository repository = RepositoryManager.getRepository()) {
|
||||
// If there are minting accounts, make sure to back them up
|
||||
// Don't backup if there are no minting accounts, as this can cause problems
|
||||
if (!repository.getAccountRepository().getMintingAccounts().isEmpty()) {
|
||||
Controller.getInstance().exportRepositoryData();
|
||||
}
|
||||
rebuildBlockchain();
|
||||
} catch (InterruptedException e) {
|
||||
throw new DataException(String.format("Interrupted when trying to rebuild blockchain: %s", e.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
// We need to create a new connection, as the previous repository and its connections may be been
|
||||
// closed by rebuildBlockchain() if a bootstrap was applied
|
||||
try (final Repository repository = RepositoryManager.getRepository()) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user