mirror of
https://github.com/Qortal/qortal.git
synced 2025-05-04 08:47:52 +00:00
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),
|
COMMENT(1800, true, 500*1024L, true, false, null),
|
||||||
CHAIN_COMMENT(1810, true, 239L, true, false, null),
|
CHAIN_COMMENT(1810, true, 239L, true, false, null),
|
||||||
MAIL(1900, true, 1024*1024L, 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(1910, true, 1024*1024L, true, false, null),
|
||||||
MESSAGE_PRIVATE(1911, true, 1024*1024L, true, true, 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.DataException;
|
||||||
import org.qortal.repository.Repository;
|
import org.qortal.repository.Repository;
|
||||||
import org.qortal.repository.TransactionRepository;
|
import org.qortal.repository.TransactionRepository;
|
||||||
|
import org.qortal.settings.Settings;
|
||||||
import org.qortal.transaction.AtTransaction;
|
import org.qortal.transaction.AtTransaction;
|
||||||
import org.qortal.transaction.Transaction;
|
import org.qortal.transaction.Transaction;
|
||||||
import org.qortal.transaction.Transaction.ApprovalStatus;
|
import org.qortal.transaction.Transaction.ApprovalStatus;
|
||||||
@ -104,6 +105,7 @@ public class Block {
|
|||||||
protected Repository repository;
|
protected Repository repository;
|
||||||
protected BlockData blockData;
|
protected BlockData blockData;
|
||||||
protected PublicKeyAccount minter;
|
protected PublicKeyAccount minter;
|
||||||
|
boolean isTestnet = Settings.getInstance().isTestNet();
|
||||||
|
|
||||||
// Other properties
|
// Other properties
|
||||||
private static final Logger LOGGER = LogManager.getLogger(Block.class);
|
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
|
// Create repository savepoint here so we can rollback to it after testing transactions
|
||||||
repository.setSavepoint();
|
repository.setSavepoint();
|
||||||
|
|
||||||
if (this.blockData.getHeight() == 212937) {
|
if (!isTestnet) {
|
||||||
// Apply fix for block 212937 but fix will be rolled back before we exit method
|
if (this.blockData.getHeight() == 212937) {
|
||||||
Block212937.processFix(this);
|
// Apply fix for block 212937 but fix will be rolled back before we exit method
|
||||||
}
|
Block212937.processFix(this);
|
||||||
else if (this.blockData.getHeight() == 1333492) {
|
} else if (this.blockData.getHeight() == 1333492) {
|
||||||
// Apply fix for block 1333492 but fix will be rolled back before we exit method
|
// Apply fix for block 1333492 but fix will be rolled back before we exit method
|
||||||
Block1333492.processFix(this);
|
Block1333492.processFix(this);
|
||||||
}
|
} else if (InvalidNameRegistrationBlocks.isAffectedBlock(this.blockData.getHeight())) {
|
||||||
else if (InvalidNameRegistrationBlocks.isAffectedBlock(this.blockData.getHeight())) {
|
// Apply fix for affected name registration blocks, but fix will be rolled back before we exit method
|
||||||
// Apply fix for affected name registration blocks, but fix will be rolled back before we exit method
|
InvalidNameRegistrationBlocks.processFix(this);
|
||||||
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
|
||||||
else if (InvalidBalanceBlocks.isAffectedBlock(this.blockData.getHeight())) {
|
InvalidBalanceBlocks.processFix(this);
|
||||||
// Apply fix for affected balance blocks, but fix will be rolled back before we exit method
|
}
|
||||||
InvalidBalanceBlocks.processFix(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Transaction transaction : this.getTransactions()) {
|
for (Transaction transaction : this.getTransactions()) {
|
||||||
@ -1558,26 +1559,23 @@ public class Block {
|
|||||||
processBlockRewards();
|
processBlockRewards();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.blockData.getHeight() == 212937) {
|
if (!isTestnet) {
|
||||||
// Apply fix for block 212937
|
if (this.blockData.getHeight() == 212937) {
|
||||||
Block212937.processFix(this);
|
// Apply fix for block 212937
|
||||||
}
|
Block212937.processFix(this);
|
||||||
else if (this.blockData.getHeight() == 1333492) {
|
} else if (this.blockData.getHeight() == 1333492) {
|
||||||
// Apply fix for block 1333492
|
// Apply fix for block 1333492
|
||||||
Block1333492.processFix(this);
|
Block1333492.processFix(this);
|
||||||
}
|
} else if (InvalidBalanceBlocks.isAffectedBlock(this.blockData.getHeight())) {
|
||||||
else if (InvalidBalanceBlocks.isAffectedBlock(this.blockData.getHeight())) {
|
// Apply fix for affected balance blocks
|
||||||
// Apply fix for affected balance blocks
|
InvalidBalanceBlocks.processFix(this);
|
||||||
InvalidBalanceBlocks.processFix(this);
|
} else if (this.blockData.getHeight() == BlockChain.getInstance().getSelfSponsorshipAlgoV1Height()) {
|
||||||
}
|
SelfSponsorshipAlgoV1Block.processAccountPenalties(this);
|
||||||
else if (this.blockData.getHeight() == BlockChain.getInstance().getSelfSponsorshipAlgoV1Height()) {
|
} else if (this.blockData.getHeight() == BlockChain.getInstance().getSelfSponsorshipAlgoV2Height()) {
|
||||||
SelfSponsorshipAlgoV1Block.processAccountPenalties(this);
|
SelfSponsorshipAlgoV2Block.processAccountPenalties(this);
|
||||||
}
|
} else if (this.blockData.getHeight() == BlockChain.getInstance().getSelfSponsorshipAlgoV3Height()) {
|
||||||
else if (this.blockData.getHeight() == BlockChain.getInstance().getSelfSponsorshipAlgoV2Height()) {
|
SelfSponsorshipAlgoV3Block.processAccountPenalties(this);
|
||||||
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.
|
// Invalidate expandedAccounts as they may have changed due to orphaning TRANSFER_PRIVS transactions, etc.
|
||||||
this.cachedExpandedAccounts = null;
|
this.cachedExpandedAccounts = null;
|
||||||
|
|
||||||
if (this.blockData.getHeight() == 212937) {
|
if (!isTestnet) {
|
||||||
// Revert fix for block 212937
|
if (this.blockData.getHeight() == 212937) {
|
||||||
Block212937.orphanFix(this);
|
// Revert fix for block 212937
|
||||||
}
|
Block212937.orphanFix(this);
|
||||||
else if (this.blockData.getHeight() == 1333492) {
|
} else if (this.blockData.getHeight() == 1333492) {
|
||||||
// Revert fix for block 1333492
|
// Revert fix for block 1333492
|
||||||
Block1333492.orphanFix(this);
|
Block1333492.orphanFix(this);
|
||||||
}
|
} else if (InvalidBalanceBlocks.isAffectedBlock(this.blockData.getHeight())) {
|
||||||
else if (InvalidBalanceBlocks.isAffectedBlock(this.blockData.getHeight())) {
|
// Revert fix for affected balance blocks
|
||||||
// Revert fix for affected balance blocks
|
InvalidBalanceBlocks.orphanFix(this);
|
||||||
InvalidBalanceBlocks.orphanFix(this);
|
} else if (this.blockData.getHeight() == BlockChain.getInstance().getSelfSponsorshipAlgoV1Height()) {
|
||||||
}
|
SelfSponsorshipAlgoV1Block.orphanAccountPenalties(this);
|
||||||
else if (this.blockData.getHeight() == BlockChain.getInstance().getSelfSponsorshipAlgoV1Height()) {
|
} else if (this.blockData.getHeight() == BlockChain.getInstance().getSelfSponsorshipAlgoV2Height()) {
|
||||||
SelfSponsorshipAlgoV1Block.orphanAccountPenalties(this);
|
SelfSponsorshipAlgoV2Block.orphanAccountPenalties(this);
|
||||||
}
|
} else if (this.blockData.getHeight() == BlockChain.getInstance().getSelfSponsorshipAlgoV3Height()) {
|
||||||
else if (this.blockData.getHeight() == BlockChain.getInstance().getSelfSponsorshipAlgoV2Height()) {
|
SelfSponsorshipAlgoV3Block.orphanAccountPenalties(this);
|
||||||
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
|
// Account levels and block rewards are only processed/orphaned on block reward distribution blocks
|
||||||
|
@ -806,17 +806,18 @@ public class BlockChain {
|
|||||||
* @throws SQLException
|
* @throws SQLException
|
||||||
*/
|
*/
|
||||||
public static void validate() throws DataException {
|
public static void validate() throws DataException {
|
||||||
|
|
||||||
boolean isTopOnly = Settings.getInstance().isTopOnly();
|
boolean isTopOnly = Settings.getInstance().isTopOnly();
|
||||||
boolean archiveEnabled = Settings.getInstance().isArchiveEnabled();
|
boolean archiveEnabled = Settings.getInstance().isArchiveEnabled();
|
||||||
boolean isLite = Settings.getInstance().isLite();
|
boolean isLite = Settings.getInstance().isLite();
|
||||||
boolean canBootstrap = Settings.getInstance().getBootstrap();
|
boolean canBootstrap = Settings.getInstance().getBootstrap();
|
||||||
boolean needsArchiveRebuild = false;
|
boolean needsArchiveRebuild = false;
|
||||||
boolean checkPointFailed = false;
|
int checkHeight = 0;
|
||||||
int currentChainHeight = 0;
|
BlockData chainTip;
|
||||||
int checkPointHeight = 0;
|
|
||||||
|
|
||||||
try (final Repository repository = RepositoryManager.getRepository()) {
|
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
|
// Ensure archive is (at least partially) intact, and force a bootstrap if it isn't
|
||||||
if (!isTopOnly && archiveEnabled && canBootstrap) {
|
if (!isTopOnly && archiveEnabled && canBootstrap) {
|
||||||
@ -832,57 +833,50 @@ public class BlockChain {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate bootstrap
|
|
||||||
if (!canBootstrap) {
|
if (!canBootstrap) {
|
||||||
if (currentChainHeight > 2) {
|
if (checkHeight > 2) {
|
||||||
LOGGER.info("Retrieved block 2 from archive. Syncing from genesis block resumed!");
|
LOGGER.info("Retrieved block 2 from archive. Syncing from genesis block resumed!");
|
||||||
} else {
|
} else {
|
||||||
needsArchiveRebuild = (repository.getBlockArchiveRepository().fromHeight(2) == null);
|
needsArchiveRebuild = (repository.getBlockArchiveRepository().fromHeight(2) == null);
|
||||||
if (needsArchiveRebuild) {
|
if (needsArchiveRebuild) {
|
||||||
LOGGER.info("Couldn't retrieve block 2 from archive. Bootstrapping is disabled. Syncing from genesis block!");
|
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
|
// 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();
|
List<Checkpoint> checkpoints = BlockChain.getInstance().getCheckpoints();
|
||||||
for (Checkpoint checkpoint : checkpoints) {
|
for (Checkpoint checkpoint : checkpoints) {
|
||||||
checkPointHeight = checkpoint.height;
|
BlockData blockData = repository.getBlockRepository().fromHeight(checkpoint.height);
|
||||||
if (currentChainHeight > checkPointHeight) {
|
if (blockData == null) {
|
||||||
BlockData blockData = repository.getBlockRepository().fromHeight(checkpoint.height);
|
// Try the archive
|
||||||
if (blockData == null) {
|
blockData = repository.getBlockArchiveRepository().fromHeight(checkpoint.height);
|
||||||
// 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());
|
|
||||||
}
|
}
|
||||||
|
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
|
// Check first block is Genesis Block
|
||||||
if (!isGenesisBlockValid() || needsArchiveRebuild) {
|
if (!isGenesisBlockValid() || needsArchiveRebuild) {
|
||||||
if (!canBootstrap && currentChainHeight < 3) {
|
if (checkHeight < 3) {
|
||||||
try {
|
try {
|
||||||
rebuildBlockchain();
|
rebuildBlockchain();
|
||||||
} catch (InterruptedException e) {
|
} 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
|
// 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
|
// closed by rebuildBlockchain() if a bootstrap was applied
|
||||||
try (final Repository repository = RepositoryManager.getRepository()) {
|
try (final Repository repository = RepositoryManager.getRepository()) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user