Solved linting errors.

This commit is contained in:
ArpitShukla007 2022-02-04 07:24:57 +00:00
parent 32923e80a3
commit 0fdca70c38
8 changed files with 15 additions and 65 deletions

View File

@ -8,38 +8,20 @@ with Tendermint.
"""
import logging
import sys
import enum
from tendermint.abci import types_pb2
from abci.application import BaseApplication
from abci.application import OkCode
from tendermint.abci.types_pb2 import (
RequestInfo,
ResponseInfo,
RequestInitChain,
ResponseInitChain,
ResponseCheckTx,
ResponseDeliverTx,
RequestQuery,
ResponseQuery,
RequestBeginBlock,
ResponseBeginBlock,
RequestEndBlock,
ResponseEndBlock,
ResponseCommit,
RequestLoadSnapshotChunk,
ResponseLoadSnapshotChunk,
RequestListSnapshots,
ResponseListSnapshots,
RequestOfferSnapshot,
ResponseOfferSnapshot,
RequestApplySnapshotChunk,
ResponseApplySnapshotChunk,
ResponseCommit
)
from planetmint import Planetmint
from planetmint.elections.election import Election
from planetmint.version import __tm_supported_versions__
from planetmint.utils import tendermint_version_is_compatible
from planetmint.tendermint_utils import (decode_transaction,
calculate_hash)
from planetmint.lib import Block
@ -80,17 +62,14 @@ class App(BaseApplication):
def abort_if_abci_chain_is_not_synced(self):
if self.chain is None or self.chain['is_synced']:
return
validators = self.planetmint_node.get_validators()
self.log_abci_migration_error(self.chain['chain_id'], validators)
sys.exit(1)
def init_chain(self, genesis):
"""Initialize chain upon genesis or a migration"""
app_hash = ''
height = 0
known_chain = self.planetmint_node.get_latest_abci_chain()
if known_chain is not None:
chain_id = known_chain['chain_id']
@ -100,26 +79,21 @@ class App(BaseApplication):
f'the chain {chain_id} is already synced.')
logger.error(msg)
sys.exit(1)
if chain_id != genesis.chain_id:
validators = self.planetmint_node.get_validators()
self.log_abci_migration_error(chain_id, validators)
sys.exit(1)
# set migration values for app hash and height
block = self.planetmint_node.get_latest_block()
app_hash = '' if block is None else block['app_hash']
height = 0 if block is None else block['height'] + 1
known_validators = self.planetmint_node.get_validators()
validator_set = [vutils.decode_validator(v)
for v in genesis.validators]
if known_validators and known_validators != validator_set:
self.log_abci_migration_error(known_chain['chain_id'],
known_validators)
sys.exit(1)
block = Block(app_hash=app_hash, height=height, transactions=[])
self.planetmint_node.store_block(block._asdict())
self.planetmint_node.store_validator_set(height + 1, validator_set)

View File

@ -11,27 +11,8 @@ from planetmint.lib import Planetmint
from planetmint.tendermint_utils import decode_transaction
from abci.application import OkCode
from tendermint.abci.types_pb2 import (
RequestInfo,
ResponseInfo,
RequestInitChain,
ResponseInitChain,
#ResponseCheckTx,
#ResponseDeliverTx,
RequestQuery,
ResponseQuery,
RequestBeginBlock,
ResponseBeginBlock,
RequestEndBlock,
ResponseEndBlock,
ResponseCommit,
RequestLoadSnapshotChunk,
ResponseLoadSnapshotChunk,
RequestListSnapshots,
ResponseListSnapshots,
RequestOfferSnapshot,
ResponseOfferSnapshot,
RequestApplySnapshotChunk,
ResponseApplySnapshotChunk,
ResponseCheckTx,
ResponseDeliverTx,
)

View File

@ -1,12 +1,10 @@
import base64
import binascii
import codecs
import enum
import planetmint
from tendermint.abci import types_pb2
from tendermint.crypto import keys_pb2
from planetmint.common.exceptions import InvalidPublicKey, BigchainDBError
from planetmint.common.exceptions import InvalidPublicKey
def encode_validator(v):
ed25519_public_key = v['public_key']['value']

View File

@ -31,7 +31,7 @@ from planetmint.common.crypto import (key_pair_from_ed25519_key,
from planetmint.common.exceptions import DatabaseDoesNotExist
from planetmint.lib import Block
from tests.utils import gen_vote
import tests.tendermint.conftest
# import tests.tendermint.conftest
TEST_DB_NAME = 'planetmint_test'
@ -252,12 +252,9 @@ def eventqueue_fixture():
from multiprocessing import Queue
return Queue()
@pytest.fixture
def b_mock(b, network_validators):
b.get_validators = mock_get_validators(network_validators)
return b
@ -450,7 +447,7 @@ def event_loop():
@pytest.fixture(scope='session')
def abci_server():
from abci.server import ABCIServer
from tendermint.abci import types_pb2 as types_v0_34_11
# from tendermint.abci import types_pb2 as types_v0_34_11
from planetmint.core import App
from planetmint.utils import Process