Skip to content

Commit

Permalink
Be able to trigger a rollback on minor version change
Browse files Browse the repository at this point in the history
  • Loading branch information
Ouziel committed Dec 13, 2024
1 parent b8da2a8 commit 7638a70
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
21 changes: 20 additions & 1 deletion counterparty-core/counterpartycore/lib/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -1060,6 +1060,24 @@ def check_need_reparse(version_minor, message):
)


def check_need_rollback(version_minor, message):
if config.FORCE:
return
need_rollback_from = (
config.NEED_ROLLBACK_IF_MINOR_IS_LESS_THAN_TESTNET
if config.TESTNET
else config.NEED_ROLLBACK_IF_MINOR_IS_LESS_THAN
)
if need_rollback_from is not None:
for min_version_minor, min_version_block_index in need_rollback_from:
if version_minor < min_version_minor:
raise DatabaseVersionError(
message=message,
required_action="rollback",
from_block_index=min_version_block_index,
)


def database_version(db):
if config.FORCE:
return
Expand All @@ -1078,7 +1096,8 @@ def database_version(db):
message = (
f"Client minor version number mismatch: {version_minor}{config.VERSION_MINOR}. "
)
message += "Checking if a reparse is needed..."
message += "Checking if a rollback or a reparse is needed..."
check_need_rollback(version_minor, message)
check_need_reparse(version_minor, message)
raise DatabaseVersionError(message=message, required_action=None)
else:
Expand Down
6 changes: 4 additions & 2 deletions counterparty-core/counterpartycore/lib/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,16 @@
# Fo example:
# NEED_REPARSE_IF_MINOR_IS_LESS_THAN = (1, 800000)
# means that we need to reparse from block 800000 if database minor version is less than 1
NEED_REPARSE_IF_MINOR_IS_LESS_THAN = [(3, 0), (5, 865999), (6, 867000), (7, 869900), (8, 871780)]
NEED_REPARSE_IF_MINOR_IS_LESS_THAN = [(3, 0), (5, 865999), (6, 867000), (7, 869900)]
NEED_REPARSE_IF_MINOR_IS_LESS_THAN_TESTNET = [
(3, 0),
(5, 2925799),
(6, 2925799),
(7, 2925799),
(8, 3522632),
]
NEED_ROLLBACK_IF_MINOR_IS_LESS_THAN = [(8, 871780)]
NEED_ROLLBACK_IF_MINOR_IS_LESS_THAN_TESTNET = [(8, 3522632)]

# Counterparty protocol
TXTYPE_FORMAT = ">I"
SHORT_TXTYPE_FORMAT = "B"
Expand Down
2 changes: 2 additions & 0 deletions release-notes/release-notes-v10.8.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
- Catch up with RPC when ZMQ is late
- Restart RSFetcher when it returns None too many times
- Exclude transaction with SIGHASH
- Add several checkpoints
- Be able to trigger a rollback on minor version change

## API

Expand Down

0 comments on commit 7638a70

Please sign in to comment.