Skip to content

Commit

Permalink
Improves logging and comments for forks/reorgs
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashy5000 committed Aug 18, 2024
1 parent 8daf22b commit edd0a2d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
6 changes: 3 additions & 3 deletions docs/whitepaper/whitepaper.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
**Polycash: An Increased-Decentralization P2P Blockchain System**

**Asher Wrobel**
*Asher Wrobel* ([email protected])

[https://github.com/Ashy5000](https://github.com/Ashy5000)
***

**Abstract**

Expand All @@ -14,7 +14,7 @@ In the current day, financial institutions have largely become adopted as an int

    To resolve these issues, a new consensus algorithm is needed: the APoW (Adjusted Proof of Work) algorithm. Instead of giving blockchain power directly proportional to mining power, APoW calculates block speed on a per-miner basis. It decreases target time (base 1 minute) by up to 50% for a miner with infinite mining rate, and increases target time by up to 50% for a miner with zero mining rate. This leads to an increase of decentralization in the blockchain and the network, and allows for a lower energy requirement than with a standard PoW blockchain.

    Another issue facing modern blockchains is the threat of quantum computing, specifically Shor's algorithm, which could, in theory, break the elliptic curve cryptography blockchains typically use for digital signatures. However, new alternatives have become available, such as the CRYSTALS-Dilithium family of public-key cryptography algorithms. Post-quantum public key cryptography algorithms must soon take on an important role in blockchain systems in order to future-proof their core systems.
    Another issue facing modern blockchains is the threat of quantum computing, specifically Shor's algorithm, which could, in theory, break the elliptic curve cryptography blockchains typically use for digital signatures. However, new alternatives have become available, such as the CRYSTALS-Dilithium family of public-key cryptography algorithms. Post-quantum public key cryptography algorithms must soon take on an important role in blockchain systems in order to future-proof their security guarantees.

A new blockchain, Polycash, is introduced to implement solutions to these issues. It utilizes the APoW consensus algorithm, Dilithium3 quantum-resistant signatures, and a new incentives system to increase decentralization, security, and efficiency.

Expand Down
15 changes: 5 additions & 10 deletions node_util/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,8 @@ func DetectFork(block Block) bool {
break
}
if b.PreviousBlockHash == block.PreviousBlockHash {
Warn("Block creates a fork.")
Log("The node software is designed to handle this edge case, so operations can continue as normal.", false)
Log("This is most likely a result of latency between miners. If the issue persists, the network may be under attack or a bug may be present; please open an issue on the GitHub repository.", true)
Log("The blockchain will be re-synced to stay on the longest chain.", true)
SyncBlockchain(len(Blockchain) + BlocksUntilFinality) // Wait for finality when switching chains
Log("Block creates a fork. Possible reorg necessary.", true)
SyncBlockchain(len(Blockchain) + BlocksUntilFinality) // Reorg if other chain is more than `BlocksUntilFinality` blocks longer than the current chain
return true
}
}
Expand Down Expand Up @@ -167,14 +164,12 @@ func VerifyBlock(block Block, blockHeight int) bool {
hash := binary.BigEndian.Uint64(hashBytes[:]) // Take the last 64 bits-- we won't ever need more than 64 zeroes.
isValid = hash <= MaximumUint64/block.Difficulty && isValid
if DetectDuplicateBlock(hashBytes) {
return false
return false
}
isValid = !DetectFork(block) && isValid
if len(Blockchain) > 0 && block.PreviousBlockHash != HashBlock(Blockchain[len(Blockchain)-1], len(Blockchain)-1) {
Log("Block has invalid previous block hash. Ignoring block request.", true)
Log("The block could be on a different fork.", true)
Log("The blockchain will be re-synced to stay on the longest chain.", true)
SyncBlockchain(len(Blockchain) + BlocksUntilFinality) // Wait for finality when switching chains
Log("Block has invalid previous block hash. Possible reorg is necessary.", true)
SyncBlockchain(len(Blockchain) + BlocksUntilFinality) // Reorg if other chain is more than `BlocksUntilFinality` blocks longer than the current chain
isValid = false
}
isValid = VerifyMiner(block.Miner) && isValid
Expand Down

0 comments on commit edd0a2d

Please sign in to comment.