mirror of
https://github.com/planetmint/planetmint.git
synced 2025-07-03 19:22:30 +00:00
sq fixes
Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com>
This commit is contained in:
parent
a1803a8041
commit
2a14c707d2
@ -1,3 +1,4 @@
|
|||||||
|
---
|
||||||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||||
# Planetmint and IPDB software contributors.
|
# Planetmint and IPDB software contributors.
|
||||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||||
|
@ -120,11 +120,8 @@ def test_env_config(monkeypatch):
|
|||||||
assert result == expected
|
assert result == expected
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.skip
|
@pytest.mark.skip(reason="Disabled until we create a better config format")
|
||||||
def test_autoconfigure_read_both_from_file_and_env(
|
def test_autoconfigure_read_both_from_file_and_env(monkeypatch, request):
|
||||||
monkeypatch, request
|
|
||||||
): # TODO Disabled until we create a better config format
|
|
||||||
return
|
|
||||||
# constants
|
# constants
|
||||||
DATABASE_HOST = "test-host"
|
DATABASE_HOST = "test-host"
|
||||||
DATABASE_NAME = "test-dbname"
|
DATABASE_NAME = "test-dbname"
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
---
|
||||||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||||
# Planetmint and IPDB software contributors.
|
# Planetmint and IPDB software contributors.
|
||||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||||
@ -35,6 +36,3 @@ services:
|
|||||||
- ./integration/scripts:/scripts
|
- ./integration/scripts:/scripts
|
||||||
- ./integration/cli:/tests
|
- ./integration/cli:/tests
|
||||||
- shared:/shared
|
- shared:/shared
|
||||||
|
|
||||||
volumes:
|
|
||||||
shared:
|
|
@ -1,3 +1,4 @@
|
|||||||
|
---
|
||||||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||||
# Planetmint and IPDB software contributors.
|
# Planetmint and IPDB software contributors.
|
||||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||||
|
@ -189,7 +189,6 @@ def main():
|
|||||||
ctx["public_keys_transfer"] = tx_transfer.outputs[0].public_keys[0]
|
ctx["public_keys_transfer"] = tx_transfer.outputs[0].public_keys[0]
|
||||||
ctx["tx_transfer_id"] = tx_transfer.id
|
ctx["tx_transfer_id"] = tx_transfer.id
|
||||||
|
|
||||||
# privkey_transfer_last = 'sG3jWDtdTXUidBJK53ucSTrosktG616U3tQHBk81eQe'
|
|
||||||
pubkey_transfer_last = "3Af3fhhjU6d9WecEM9Uw5hfom9kNEwE7YuDWdqAUssqm"
|
pubkey_transfer_last = "3Af3fhhjU6d9WecEM9Uw5hfom9kNEwE7YuDWdqAUssqm"
|
||||||
|
|
||||||
cid = 0
|
cid = 0
|
||||||
|
@ -198,7 +198,6 @@ todo_include_todos = False
|
|||||||
# a list of builtin themes.
|
# a list of builtin themes.
|
||||||
#
|
#
|
||||||
html_theme = "press"
|
html_theme = "press"
|
||||||
# html_theme = 'sphinx_documatt_theme'
|
|
||||||
|
|
||||||
# Theme options are theme-specific and customize the look and feel of a theme
|
# Theme options are theme-specific and customize the look and feel of a theme
|
||||||
# further. For a list of options available for each theme, see the
|
# further. For a list of options available for each theme, see the
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
---
|
||||||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||||
# Planetmint and IPDB software contributors.
|
# Planetmint and IPDB software contributors.
|
||||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
---
|
||||||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||||
# Planetmint and IPDB software contributors.
|
# Planetmint and IPDB software contributors.
|
||||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
---
|
||||||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||||
# Planetmint and IPDB software contributors.
|
# Planetmint and IPDB software contributors.
|
||||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
---
|
||||||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||||
# Planetmint and IPDB software contributors.
|
# Planetmint and IPDB software contributors.
|
||||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||||
|
@ -82,7 +82,7 @@ class ApplicationLogic(BaseApplication):
|
|||||||
|
|
||||||
if known_chain["is_synced"]:
|
if known_chain["is_synced"]:
|
||||||
msg = (
|
msg = (
|
||||||
f"Got invalid InitChain ABCI request ({genesis}) - " f"the chain {chain_id} is already synced."
|
f"Got invalid InitChain ABCI request ({genesis}) - the chain {chain_id} is already synced."
|
||||||
)
|
)
|
||||||
logger.error(msg)
|
logger.error(msg)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
@ -238,7 +238,7 @@ class ApplicationLogic(BaseApplication):
|
|||||||
block_txn_hash = calculate_hash(self.block_txn_ids)
|
block_txn_hash = calculate_hash(self.block_txn_ids)
|
||||||
block = self.validator.models.get_latest_block()
|
block = self.validator.models.get_latest_block()
|
||||||
|
|
||||||
logger.debug("BLOCK: ", block)
|
logger.debug(f"BLOCK: {block}")
|
||||||
if self.block_txn_ids:
|
if self.block_txn_ids:
|
||||||
self.block_txn_hash = calculate_hash([block["app_hash"], block_txn_hash])
|
self.block_txn_hash = calculate_hash([block["app_hash"], block_txn_hash])
|
||||||
else:
|
else:
|
||||||
@ -279,7 +279,7 @@ class ApplicationLogic(BaseApplication):
|
|||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
logger.debug(
|
logger.debug(
|
||||||
"Commit-ing new block with hash: apphash=%s ," "height=%s, txn ids=%s",
|
"Commit-ing new block with hash: apphash=%s, height=%s, txn ids=%s",
|
||||||
data,
|
data,
|
||||||
self.new_height,
|
self.new_height,
|
||||||
self.block_txn_ids,
|
self.block_txn_ids,
|
||||||
|
@ -79,7 +79,6 @@ def new_validator_set(validators, updates):
|
|||||||
|
|
||||||
def get_public_key_decoder(pk):
|
def get_public_key_decoder(pk):
|
||||||
encoding = pk["type"]
|
encoding = pk["type"]
|
||||||
decoder = base64.b64decode
|
|
||||||
|
|
||||||
if encoding == "ed25519-base16":
|
if encoding == "ed25519-base16":
|
||||||
decoder = base64.b16decode
|
decoder = base64.b16decode
|
||||||
|
@ -62,7 +62,7 @@ class Validator:
|
|||||||
asset_id = tx.get_asset_id(input_txs)
|
asset_id = tx.get_asset_id(input_txs)
|
||||||
if asset_id != Transaction.read_out_asset_id(tx):
|
if asset_id != Transaction.read_out_asset_id(tx):
|
||||||
raise AssetIdMismatch(
|
raise AssetIdMismatch(
|
||||||
("The asset id of the input does not" " match the asset id of the" " transaction")
|
("The asset id of the input does not match the asset id of the transaction")
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
asset_ids = Transaction.get_asset_ids(input_txs)
|
asset_ids = Transaction.get_asset_ids(input_txs)
|
||||||
@ -105,9 +105,7 @@ class Validator:
|
|||||||
|
|
||||||
if output_amount != input_amount:
|
if output_amount != input_amount:
|
||||||
raise AmountError(
|
raise AmountError(
|
||||||
(
|
"The amount used in the inputs `{}` needs to be same as the amount used in the outputs `{}`".format(input_amount, output_amount)
|
||||||
"The amount used in the inputs `{}`" " needs to be same as the amount used" " in the outputs `{}`"
|
|
||||||
).format(input_amount, output_amount)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
@ -202,7 +200,7 @@ class Validator:
|
|||||||
raise InvalidProposer("Public key is not a part of the validator set")
|
raise InvalidProposer("Public key is not a part of the validator set")
|
||||||
|
|
||||||
# NOTE: Check if all validators have been assigned votes equal to their voting power
|
# NOTE: Check if all validators have been assigned votes equal to their voting power
|
||||||
if not self.is_same_topology(current_validators, transaction.outputs):
|
if not Validator.is_same_topology(current_validators, transaction.outputs):
|
||||||
raise UnequalValidatorSet("Validator set much be exactly same to the outputs of election")
|
raise UnequalValidatorSet("Validator set much be exactly same to the outputs of election")
|
||||||
|
|
||||||
if transaction.operation == VALIDATOR_ELECTION:
|
if transaction.operation == VALIDATOR_ELECTION:
|
||||||
@ -210,7 +208,8 @@ class Validator:
|
|||||||
|
|
||||||
return transaction
|
return transaction
|
||||||
|
|
||||||
def is_same_topology(cls, current_topology, election_topology):
|
@staticmethod
|
||||||
|
def is_same_topology(current_topology, election_topology):
|
||||||
voters = {}
|
voters = {}
|
||||||
for voter in election_topology:
|
for voter in election_topology:
|
||||||
if len(voter.public_keys) > 1:
|
if len(voter.public_keys) > 1:
|
||||||
|
@ -73,7 +73,7 @@ class LocalMongoDBConnection(DBConnection):
|
|||||||
try:
|
try:
|
||||||
return query.run(self.connect())
|
return query.run(self.connect())
|
||||||
except pymongo.errors.AutoReconnect:
|
except pymongo.errors.AutoReconnect:
|
||||||
logger.warning("Lost connection to the database, " "retrying query.")
|
logger.warning("Lost connection to the database, retrying query.")
|
||||||
return query.run(self.connect())
|
return query.run(self.connect())
|
||||||
except pymongo.errors.AutoReconnect as exc:
|
except pymongo.errors.AutoReconnect as exc:
|
||||||
raise ConnectionError from exc
|
raise ConnectionError from exc
|
||||||
|
@ -117,7 +117,7 @@ class Config(metaclass=Singleton):
|
|||||||
def set(self, config):
|
def set(self, config):
|
||||||
self._private_real_config = config
|
self._private_real_config = config
|
||||||
|
|
||||||
def get_db_key_map(sefl, db):
|
def get_db_key_map(self, db):
|
||||||
return sefl.__private_database_keys_map[db]
|
return sefl.__private_database_keys_map[db]
|
||||||
|
|
||||||
def get_db_map(sefl, db):
|
def get_db_map(sefl, db):
|
||||||
@ -132,14 +132,14 @@ DEFAULT_LOGGING_CONFIG = {
|
|||||||
"console": {
|
"console": {
|
||||||
"class": "logging.Formatter",
|
"class": "logging.Formatter",
|
||||||
"format": (
|
"format": (
|
||||||
"[%(asctime)s] [%(levelname)s] (%(name)s) " "%(message)s (%(processName)-10s - pid: %(process)d)"
|
"[%(asctime)s] [%(levelname)s] (%(name)s) %(message)s (%(processName)-10s - pid: %(process)d)"
|
||||||
),
|
),
|
||||||
"datefmt": "%Y-%m-%d %H:%M:%S",
|
"datefmt": "%Y-%m-%d %H:%M:%S",
|
||||||
},
|
},
|
||||||
"file": {
|
"file": {
|
||||||
"class": "logging.Formatter",
|
"class": "logging.Formatter",
|
||||||
"format": (
|
"format": (
|
||||||
"[%(asctime)s] [%(levelname)s] (%(name)s) " "%(message)s (%(processName)-10s - pid: %(process)d)"
|
"[%(asctime)s] [%(levelname)s] (%(name)s) %(message)s (%(processName)-10s - pid: %(process)d)"
|
||||||
),
|
),
|
||||||
"datefmt": "%Y-%m-%d %H:%M:%S",
|
"datefmt": "%Y-%m-%d %H:%M:%S",
|
||||||
},
|
},
|
||||||
|
@ -337,7 +337,6 @@ class DataAccessor(metaclass=Singleton):
|
|||||||
str: Merkle root in hexadecimal form.
|
str: Merkle root in hexadecimal form.
|
||||||
"""
|
"""
|
||||||
utxoset = backend.query.get_unspent_outputs(self.connection)
|
utxoset = backend.query.get_unspent_outputs(self.connection)
|
||||||
# TODO Once ready, use the already pre-computed utxo_hash field.
|
|
||||||
# See common/transactions.py for details.
|
# See common/transactions.py for details.
|
||||||
|
|
||||||
hashes = [
|
hashes = [
|
||||||
@ -346,5 +345,4 @@ class DataAccessor(metaclass=Singleton):
|
|||||||
|
|
||||||
print(sorted(hashes))
|
print(sorted(hashes))
|
||||||
|
|
||||||
# TODO Notice the sorted call!
|
|
||||||
return merkleroot(sorted(hashes))
|
return merkleroot(sorted(hashes))
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||||
|
|
||||||
|
import sys
|
||||||
import logging
|
import logging
|
||||||
import setproctitle
|
import setproctitle
|
||||||
|
|
||||||
@ -94,4 +95,4 @@ def start(args):
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
start()
|
start(sys.argv)
|
||||||
|
@ -26,6 +26,9 @@ from planetmint.backend.connection import Connection
|
|||||||
from tests.utils import generate_election, generate_validators
|
from tests.utils import generate_election, generate_validators
|
||||||
|
|
||||||
|
|
||||||
|
rpc_write_transaction_string = "planetmint.abci.rpc.ABCI_RPC.write_transaction"
|
||||||
|
|
||||||
|
|
||||||
def mock_get_validators(self, height):
|
def mock_get_validators(self, height):
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
@ -57,7 +60,7 @@ def test_chain_migration_election_show_shows_inconclusive(b_flushed, test_abci_r
|
|||||||
b = b_flushed
|
b = b_flushed
|
||||||
|
|
||||||
validators = generate_validators([1] * 4)
|
validators = generate_validators([1] * 4)
|
||||||
output = b.models.store_validator_set(1, [v["storage"] for v in validators])
|
_ = b.models.store_validator_set(1, [v["storage"] for v in validators])
|
||||||
|
|
||||||
public_key = validators[0]["public_key"]
|
public_key = validators[0]["public_key"]
|
||||||
private_key = validators[0]["private_key"]
|
private_key = validators[0]["private_key"]
|
||||||
@ -465,7 +468,7 @@ def test_election_new_upsert_validator_without_tendermint(
|
|||||||
from planetmint.model.dataaccessor import DataAccessor
|
from planetmint.model.dataaccessor import DataAccessor
|
||||||
|
|
||||||
m.setattr(DataAccessor, "get_validators", mock_get_validators)
|
m.setattr(DataAccessor, "get_validators", mock_get_validators)
|
||||||
m.setattr("planetmint.abci.rpc.ABCI_RPC.write_transaction", mock_write)
|
m.setattr(rpc_write_transaction_string, mock_write)
|
||||||
|
|
||||||
args = Namespace(
|
args = Namespace(
|
||||||
action="new",
|
action="new",
|
||||||
@ -505,7 +508,7 @@ def test_election_new_chain_migration_without_tendermint(
|
|||||||
from planetmint.model.dataaccessor import DataAccessor
|
from planetmint.model.dataaccessor import DataAccessor
|
||||||
|
|
||||||
m.setattr(DataAccessor, "get_validators", mock_get_validators)
|
m.setattr(DataAccessor, "get_validators", mock_get_validators)
|
||||||
m.setattr("planetmint.abci.rpc.ABCI_RPC.write_transaction", mock_write)
|
m.setattr(rpc_write_transaction_string, mock_write)
|
||||||
|
|
||||||
args = Namespace(action="new", election_type="migration", sk=priv_validator_path, config={})
|
args = Namespace(action="new", election_type="migration", sk=priv_validator_path, config={})
|
||||||
|
|
||||||
@ -546,7 +549,7 @@ def test_election_new_upsert_validator_invalid_power(
|
|||||||
from planetmint.model.dataaccessor import DataAccessor
|
from planetmint.model.dataaccessor import DataAccessor
|
||||||
|
|
||||||
m.setattr(DataAccessor, "get_validators", mock_get_validators)
|
m.setattr(DataAccessor, "get_validators", mock_get_validators)
|
||||||
m.setattr("planetmint.abci.rpc.ABCI_RPC.write_transaction", mock_write)
|
m.setattr(rpc_write_transaction_string, mock_write)
|
||||||
|
|
||||||
args = Namespace(
|
args = Namespace(
|
||||||
action="new",
|
action="new",
|
||||||
@ -600,7 +603,7 @@ def test_election_approve_without_tendermint(
|
|||||||
from planetmint.model.dataaccessor import DataAccessor
|
from planetmint.model.dataaccessor import DataAccessor
|
||||||
|
|
||||||
m.setattr(DataAccessor, "get_validators", mock_get_validators)
|
m.setattr(DataAccessor, "get_validators", mock_get_validators)
|
||||||
m.setattr("planetmint.abci.rpc.ABCI_RPC.write_transaction", mock_write)
|
m.setattr(rpc_write_transaction_string, mock_write)
|
||||||
|
|
||||||
b, election_id = call_election_internal(b, new_validator, node_key)
|
b, election_id = call_election_internal(b, new_validator, node_key)
|
||||||
|
|
||||||
@ -674,7 +677,7 @@ def call_election(monkeypatch, b, new_validator, node_key, abci_rpc):
|
|||||||
from planetmint.model.dataaccessor import DataAccessor
|
from planetmint.model.dataaccessor import DataAccessor
|
||||||
|
|
||||||
m.setattr(DataAccessor, "get_validators", mock_get_validators)
|
m.setattr(DataAccessor, "get_validators", mock_get_validators)
|
||||||
m.setattr("planetmint.abci.rpc.ABCI_RPC.write_transaction", mock_write)
|
m.setattr(rpc_write_transaction_string, mock_write)
|
||||||
b, election_id = call_election_internal(b, new_validator, node_key)
|
b, election_id = call_election_internal(b, new_validator, node_key)
|
||||||
m.undo()
|
m.undo()
|
||||||
return b, election_id
|
return b, election_id
|
||||||
|
Loading…
x
Reference in New Issue
Block a user