moved on_rollback behaviour to planetmint

Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com>
This commit is contained in:
Lorenz Herzberger 2022-10-10 13:07:13 +02:00
parent 7dec1b16ab
commit 54e821ebaf
No known key found for this signature in database
GPG Key ID: FA5EE906EB55316A
4 changed files with 6 additions and 14 deletions

View File

@ -947,6 +947,11 @@ class Planetmint(object):
elections = self._get_votes(txns) elections = self._get_votes(txns)
for election_id in elections: for election_id in elections:
election = self.get_transaction(election_id) election = self.get_transaction(election_id)
election.on_rollback(self, new_height) # election.on_rollback(self, new_height)
if election.operation == VALIDATOR_ELECTION:
# TODO change to `new_height + 2` when upgrading to Tendermint 0.24.0.
self.delete_validator_set(new_height + 1)
if election.operation == CHAIN_MIGRATION_ELECTION:
self.delete_abci_chain(new_height)
Block = namedtuple("Block", ("app_hash", "height", "transactions")) Block = namedtuple("Block", ("app_hash", "height", "transactions"))

View File

@ -17,6 +17,3 @@ class ChainMigrationElection(Election):
def on_approval(self, planet, *args, **kwargs): # TODO: move somewhere else def on_approval(self, planet, *args, **kwargs): # TODO: move somewhere else
planet.migrate_abci_chain() planet.migrate_abci_chain()
def on_rollback(self, planet, new_height): # TODO: move somewhere else
planet.delete_abci_chain(new_height)

View File

@ -73,9 +73,3 @@ class Election(Transaction):
other concluded elections, if required. other concluded elections, if required.
""" """
raise NotImplementedError raise NotImplementedError
def on_rollback(self, planet, new_height):
"""Override to clean up the database artifacts possibly created
in `on_approval`. Part of the `end_block`/`commit` crash recovery.
"""
raise NotImplementedError

View File

@ -31,7 +31,3 @@ class ValidatorElection(Election):
# TODO change to `new_height + 2` when upgrading to Tendermint 0.24.0. # TODO change to `new_height + 2` when upgrading to Tendermint 0.24.0.
planet.store_validator_set(new_height + 1, updated_validator_set) planet.store_validator_set(new_height + 1, updated_validator_set)
return encode_validator(self.asset["data"]) return encode_validator(self.asset["data"])
def on_rollback(self, planetmint, new_height): # TODO: move somewhere else
# TODO change to `new_height + 2` when upgrading to Tendermint 0.24.0.
planetmint.delete_validator_set(new_height + 1)