From a5c78de7b6d2c9a0b68d401d98a5de2c239a0e1a Mon Sep 17 00:00:00 2001 From: Vitaly Drogan Date: Thu, 20 Jun 2019 15:03:33 +0300 Subject: [PATCH 1/2] src/ -> core/ --- Cargo.toml | 22 +++++++++---------- Makefile | 4 ++-- README.md | 6 ++--- bin/db-setup | 2 +- bin/db-test | 2 +- {src => core}/circuit/Cargo.toml | 0 {src => core}/circuit/src/cheque/bitwindow.rs | 0 {src => core}/circuit/src/cheque/mod.rs | 0 {src => core}/circuit/src/deposit/circuit.rs | 0 .../circuit/src/deposit/deposit_request.rs | 0 {src => core}/circuit/src/deposit/mod.rs | 0 {src => core}/circuit/src/encoder.rs | 0 {src => core}/circuit/src/exit/circuit.rs | 0 .../circuit/src/exit/exit_request.rs | 0 {src => core}/circuit/src/exit/mod.rs | 0 {src => core}/circuit/src/leaf.rs | 0 {src => core}/circuit/src/lib.rs | 0 {src => core}/circuit/src/plasma_constants.rs | 0 {src => core}/circuit/src/transfer/circuit.rs | 0 {src => core}/circuit/src/transfer/mod.rs | 0 .../circuit/src/transfer/transaction.rs | 0 {src => core}/data_restore/Cargo.toml | 0 .../data_restore/src/accounts_state/mod.rs | 0 .../data_restore/src/block_events/mod.rs | 0 {src => core}/data_restore/src/blocks/mod.rs | 0 .../data_restore/src/data_restore_driver.rs | 0 .../src/franklin_transaction/mod.rs | 0 {src => core}/data_restore/src/helpers/mod.rs | 0 {src => core}/data_restore/src/lib.rs | 0 {src => core}/eth_client/Cargo.toml | 0 {src => core}/eth_client/src/lib.rs | 0 {src => core}/eth_client/src/signer.rs | 0 {src => core}/key_generator/Cargo.toml | 0 .../key_generator/src/depositor_key.rs | 0 {src => core}/key_generator/src/exitor_key.rs | 0 {src => core}/key_generator/src/main.rs | 0 .../key_generator/src/read_write_keys.rs | 0 .../key_generator/src/transactor_key.rs | 0 .../src/vk_contract_generator.rs | 0 {src => core}/merkle_tree/Cargo.toml | 0 {src => core}/merkle_tree/src/account_tree.rs | 0 {src => core}/merkle_tree/src/hasher.rs | 0 {src => core}/merkle_tree/src/lib.rs | 0 {src => core}/merkle_tree/src/parallel_smt.rs | 0 .../merkle_tree/src/pedersen_hasher.rs | 0 .../merkle_tree/src/sequential_smt.rs | 0 {src => core}/models/Cargo.toml | 0 {src => core}/models/src/abi.rs | 0 {src => core}/models/src/config.rs | 0 {src => core}/models/src/lib.rs | 0 {src => core}/models/src/plasma/account.rs | 0 {src => core}/models/src/plasma/block.rs | 0 .../models/src/plasma/circuit/account.rs | 0 .../models/src/plasma/circuit/deposit.rs | 0 .../models/src/plasma/circuit/exit.rs | 0 .../models/src/plasma/circuit/mod.rs | 0 .../models/src/plasma/circuit/sig.rs | 0 .../models/src/plasma/circuit/transfer.rs | 0 .../models/src/plasma/circuit/utils.rs | 0 {src => core}/models/src/plasma/mod.rs | 0 {src => core}/models/src/plasma/params.rs | 0 {src => core}/models/src/plasma/tx.rs | 0 {src => core}/models/src/primitives.rs | 0 {src => core}/plasma/Cargo.toml | 0 {src => core}/plasma/src/lib.rs | 0 {src => core}/plasma/src/state.rs | 0 {src => core}/prover/Cargo.toml | 0 {src => core}/prover/src/lib.rs | 0 {src => core}/prover/src/main.rs | 0 {src => core}/sandbox/Cargo.toml | 0 {src => core}/sandbox/src/main.rs | 0 {src => core}/sandbox/src/nonce_futures.rs | 0 {src => core}/server/Cargo.toml | 0 {src => core}/server/src/analysis.pgsql | 0 {src => core}/server/src/api_server.rs | 0 {src => core}/server/src/committer.rs | 0 {src => core}/server/src/eth_sender.rs | 0 {src => core}/server/src/eth_watch.rs | 0 {src => core}/server/src/lib.rs | 0 {src => core}/server/src/main.rs | 0 {src => core}/server/src/nonce_futures.rs | 0 {src => core}/server/src/state_keeper.rs | 0 {src => core}/storage/.gitignore | 0 {src => core}/storage/Cargo.toml | 0 {src => core}/storage/diesel.toml | 0 .../down.sql | 0 .../up.sql | 0 .../2018-12-11-084553_operations/down.sql | 0 .../2018-12-11-084553_operations/up.sql | 0 .../2019-04-02-100645_proofs/down.sql | 0 .../2019-04-02-100645_proofs/up.sql | 0 .../2019-05-02-110639_transactions/down.sql | 0 .../2019-05-02-110639_transactions/up.sql | 0 .../2019-05-08-114230_config/down.sql | 0 .../2019-05-08-114230_config/up.sql | 0 .../2019-05-16-130227_provers/down.sql | 0 .../2019-05-16-130227_provers/up.sql | 0 .../storage/sql/active_provers.pgsql | 0 {src => core}/storage/sql/prover-runs.pgsql | 0 {src => core}/storage/sql/tps.pgsql | 0 {src => core}/storage/src/lib.rs | 0 {src => core}/storage/src/schema.rs | 0 102 files changed, 18 insertions(+), 18 deletions(-) rename {src => core}/circuit/Cargo.toml (100%) rename {src => core}/circuit/src/cheque/bitwindow.rs (100%) rename {src => core}/circuit/src/cheque/mod.rs (100%) rename {src => core}/circuit/src/deposit/circuit.rs (100%) rename {src => core}/circuit/src/deposit/deposit_request.rs (100%) rename {src => core}/circuit/src/deposit/mod.rs (100%) rename {src => core}/circuit/src/encoder.rs (100%) rename {src => core}/circuit/src/exit/circuit.rs (100%) rename {src => core}/circuit/src/exit/exit_request.rs (100%) rename {src => core}/circuit/src/exit/mod.rs (100%) rename {src => core}/circuit/src/leaf.rs (100%) rename {src => core}/circuit/src/lib.rs (100%) rename {src => core}/circuit/src/plasma_constants.rs (100%) rename {src => core}/circuit/src/transfer/circuit.rs (100%) rename {src => core}/circuit/src/transfer/mod.rs (100%) rename {src => core}/circuit/src/transfer/transaction.rs (100%) rename {src => core}/data_restore/Cargo.toml (100%) rename {src => core}/data_restore/src/accounts_state/mod.rs (100%) rename {src => core}/data_restore/src/block_events/mod.rs (100%) rename {src => core}/data_restore/src/blocks/mod.rs (100%) rename {src => core}/data_restore/src/data_restore_driver.rs (100%) rename {src => core}/data_restore/src/franklin_transaction/mod.rs (100%) rename {src => core}/data_restore/src/helpers/mod.rs (100%) rename {src => core}/data_restore/src/lib.rs (100%) rename {src => core}/eth_client/Cargo.toml (100%) rename {src => core}/eth_client/src/lib.rs (100%) rename {src => core}/eth_client/src/signer.rs (100%) rename {src => core}/key_generator/Cargo.toml (100%) rename {src => core}/key_generator/src/depositor_key.rs (100%) rename {src => core}/key_generator/src/exitor_key.rs (100%) rename {src => core}/key_generator/src/main.rs (100%) rename {src => core}/key_generator/src/read_write_keys.rs (100%) rename {src => core}/key_generator/src/transactor_key.rs (100%) rename {src => core}/key_generator/src/vk_contract_generator.rs (100%) rename {src => core}/merkle_tree/Cargo.toml (100%) rename {src => core}/merkle_tree/src/account_tree.rs (100%) rename {src => core}/merkle_tree/src/hasher.rs (100%) rename {src => core}/merkle_tree/src/lib.rs (100%) rename {src => core}/merkle_tree/src/parallel_smt.rs (100%) rename {src => core}/merkle_tree/src/pedersen_hasher.rs (100%) rename {src => core}/merkle_tree/src/sequential_smt.rs (100%) rename {src => core}/models/Cargo.toml (100%) rename {src => core}/models/src/abi.rs (100%) rename {src => core}/models/src/config.rs (100%) rename {src => core}/models/src/lib.rs (100%) rename {src => core}/models/src/plasma/account.rs (100%) rename {src => core}/models/src/plasma/block.rs (100%) rename {src => core}/models/src/plasma/circuit/account.rs (100%) rename {src => core}/models/src/plasma/circuit/deposit.rs (100%) rename {src => core}/models/src/plasma/circuit/exit.rs (100%) rename {src => core}/models/src/plasma/circuit/mod.rs (100%) rename {src => core}/models/src/plasma/circuit/sig.rs (100%) rename {src => core}/models/src/plasma/circuit/transfer.rs (100%) rename {src => core}/models/src/plasma/circuit/utils.rs (100%) rename {src => core}/models/src/plasma/mod.rs (100%) rename {src => core}/models/src/plasma/params.rs (100%) rename {src => core}/models/src/plasma/tx.rs (100%) rename {src => core}/models/src/primitives.rs (100%) rename {src => core}/plasma/Cargo.toml (100%) rename {src => core}/plasma/src/lib.rs (100%) rename {src => core}/plasma/src/state.rs (100%) rename {src => core}/prover/Cargo.toml (100%) rename {src => core}/prover/src/lib.rs (100%) rename {src => core}/prover/src/main.rs (100%) rename {src => core}/sandbox/Cargo.toml (100%) rename {src => core}/sandbox/src/main.rs (100%) rename {src => core}/sandbox/src/nonce_futures.rs (100%) rename {src => core}/server/Cargo.toml (100%) rename {src => core}/server/src/analysis.pgsql (100%) rename {src => core}/server/src/api_server.rs (100%) rename {src => core}/server/src/committer.rs (100%) rename {src => core}/server/src/eth_sender.rs (100%) rename {src => core}/server/src/eth_watch.rs (100%) rename {src => core}/server/src/lib.rs (100%) rename {src => core}/server/src/main.rs (100%) rename {src => core}/server/src/nonce_futures.rs (100%) rename {src => core}/server/src/state_keeper.rs (100%) rename {src => core}/storage/.gitignore (100%) rename {src => core}/storage/Cargo.toml (100%) rename {src => core}/storage/diesel.toml (100%) rename {src => core}/storage/migrations/00000000000000_diesel_initial_setup/down.sql (100%) rename {src => core}/storage/migrations/00000000000000_diesel_initial_setup/up.sql (100%) rename {src => core}/storage/migrations/2018-12-11-084553_operations/down.sql (100%) rename {src => core}/storage/migrations/2018-12-11-084553_operations/up.sql (100%) rename {src => core}/storage/migrations/2019-04-02-100645_proofs/down.sql (100%) rename {src => core}/storage/migrations/2019-04-02-100645_proofs/up.sql (100%) rename {src => core}/storage/migrations/2019-05-02-110639_transactions/down.sql (100%) rename {src => core}/storage/migrations/2019-05-02-110639_transactions/up.sql (100%) rename {src => core}/storage/migrations/2019-05-08-114230_config/down.sql (100%) rename {src => core}/storage/migrations/2019-05-08-114230_config/up.sql (100%) rename {src => core}/storage/migrations/2019-05-16-130227_provers/down.sql (100%) rename {src => core}/storage/migrations/2019-05-16-130227_provers/up.sql (100%) rename {src => core}/storage/sql/active_provers.pgsql (100%) rename {src => core}/storage/sql/prover-runs.pgsql (100%) rename {src => core}/storage/sql/tps.pgsql (100%) rename {src => core}/storage/src/lib.rs (100%) rename {src => core}/storage/src/schema.rs (100%) diff --git a/Cargo.toml b/Cargo.toml index 05a77daee2..5e20a5d6b7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,14 +1,14 @@ [workspace] members = [ - "src/data_restore", - "src/key_generator", - "src/merkle_tree", - "src/eth_client", - "src/models", - "src/plasma", - "src/prover", - "src/sandbox", - "src/server", - "src/storage", - "src/circuit", + "core/data_restore", + "core/key_generator", + "core/merkle_tree", + "core/eth_client", + "core/models", + "core/plasma", + "core/prover", + "core/sandbox", + "core/server", + "core/storage", + "core/circuit", ] diff --git a/Makefile b/Makefile index 1bb879603d..e4d7fa1519 100644 --- a/Makefile +++ b/Makefile @@ -49,7 +49,7 @@ db-reset: confirm_action db-drop db-setup db-insert-contract @echo database is ready db-migrate: confirm_action - @cd src/storage && diesel migration run + @cd core/storage && diesel migration run db-drop: confirm_action @# this is used to clear the produciton db; cannot do `diesel database reset` because we don't own the db @@ -299,4 +299,4 @@ tesseracts-up: @docker-compose up -d tesseracts tesseracts-down: - @docker-compose stop tesseracts \ No newline at end of file + @docker-compose stop tesseracts diff --git a/README.md b/README.md index 98650426da..0975148055 100644 --- a/README.md +++ b/README.md @@ -89,9 +89,9 @@ Client UI will be available at http://localhost:8080 ## Database migrations -- ```cd src/storage``` +- ```cd core/storage``` - Add diesel migration -- Rename `src/storage/schema.rs.generated` to `schema.rs` +- Rename `core/storage/schema.rs.generated` to `schema.rs` - Run tests: ```franklin db-tests``` ## Generating keys @@ -129,4 +129,4 @@ So you need to rebuild the code on every change (to be automated). ``` franklin flatten source -``` \ No newline at end of file +``` diff --git a/bin/db-setup b/bin/db-setup index 0bcd403a76..baa155aeb7 100755 --- a/bin/db-setup +++ b/bin/db-setup @@ -3,7 +3,7 @@ # Force read env FRANKLIN_ENV= . .setup_env -cd src/storage +cd core/storage echo DATABASE_URL=$DATABASE_URL diesel database setup || exit 1 diff --git a/bin/db-test b/bin/db-test index 42c97ff502..1611d8c548 100755 --- a/bin/db-test +++ b/bin/db-test @@ -1,7 +1,7 @@ #!/bin/bash . .setup_env -cd src/storage +cd core/storage export DATABASE_URL=postgres://postgres@localhost/plasma_test diff --git a/src/circuit/Cargo.toml b/core/circuit/Cargo.toml similarity index 100% rename from src/circuit/Cargo.toml rename to core/circuit/Cargo.toml diff --git a/src/circuit/src/cheque/bitwindow.rs b/core/circuit/src/cheque/bitwindow.rs similarity index 100% rename from src/circuit/src/cheque/bitwindow.rs rename to core/circuit/src/cheque/bitwindow.rs diff --git a/src/circuit/src/cheque/mod.rs b/core/circuit/src/cheque/mod.rs similarity index 100% rename from src/circuit/src/cheque/mod.rs rename to core/circuit/src/cheque/mod.rs diff --git a/src/circuit/src/deposit/circuit.rs b/core/circuit/src/deposit/circuit.rs similarity index 100% rename from src/circuit/src/deposit/circuit.rs rename to core/circuit/src/deposit/circuit.rs diff --git a/src/circuit/src/deposit/deposit_request.rs b/core/circuit/src/deposit/deposit_request.rs similarity index 100% rename from src/circuit/src/deposit/deposit_request.rs rename to core/circuit/src/deposit/deposit_request.rs diff --git a/src/circuit/src/deposit/mod.rs b/core/circuit/src/deposit/mod.rs similarity index 100% rename from src/circuit/src/deposit/mod.rs rename to core/circuit/src/deposit/mod.rs diff --git a/src/circuit/src/encoder.rs b/core/circuit/src/encoder.rs similarity index 100% rename from src/circuit/src/encoder.rs rename to core/circuit/src/encoder.rs diff --git a/src/circuit/src/exit/circuit.rs b/core/circuit/src/exit/circuit.rs similarity index 100% rename from src/circuit/src/exit/circuit.rs rename to core/circuit/src/exit/circuit.rs diff --git a/src/circuit/src/exit/exit_request.rs b/core/circuit/src/exit/exit_request.rs similarity index 100% rename from src/circuit/src/exit/exit_request.rs rename to core/circuit/src/exit/exit_request.rs diff --git a/src/circuit/src/exit/mod.rs b/core/circuit/src/exit/mod.rs similarity index 100% rename from src/circuit/src/exit/mod.rs rename to core/circuit/src/exit/mod.rs diff --git a/src/circuit/src/leaf.rs b/core/circuit/src/leaf.rs similarity index 100% rename from src/circuit/src/leaf.rs rename to core/circuit/src/leaf.rs diff --git a/src/circuit/src/lib.rs b/core/circuit/src/lib.rs similarity index 100% rename from src/circuit/src/lib.rs rename to core/circuit/src/lib.rs diff --git a/src/circuit/src/plasma_constants.rs b/core/circuit/src/plasma_constants.rs similarity index 100% rename from src/circuit/src/plasma_constants.rs rename to core/circuit/src/plasma_constants.rs diff --git a/src/circuit/src/transfer/circuit.rs b/core/circuit/src/transfer/circuit.rs similarity index 100% rename from src/circuit/src/transfer/circuit.rs rename to core/circuit/src/transfer/circuit.rs diff --git a/src/circuit/src/transfer/mod.rs b/core/circuit/src/transfer/mod.rs similarity index 100% rename from src/circuit/src/transfer/mod.rs rename to core/circuit/src/transfer/mod.rs diff --git a/src/circuit/src/transfer/transaction.rs b/core/circuit/src/transfer/transaction.rs similarity index 100% rename from src/circuit/src/transfer/transaction.rs rename to core/circuit/src/transfer/transaction.rs diff --git a/src/data_restore/Cargo.toml b/core/data_restore/Cargo.toml similarity index 100% rename from src/data_restore/Cargo.toml rename to core/data_restore/Cargo.toml diff --git a/src/data_restore/src/accounts_state/mod.rs b/core/data_restore/src/accounts_state/mod.rs similarity index 100% rename from src/data_restore/src/accounts_state/mod.rs rename to core/data_restore/src/accounts_state/mod.rs diff --git a/src/data_restore/src/block_events/mod.rs b/core/data_restore/src/block_events/mod.rs similarity index 100% rename from src/data_restore/src/block_events/mod.rs rename to core/data_restore/src/block_events/mod.rs diff --git a/src/data_restore/src/blocks/mod.rs b/core/data_restore/src/blocks/mod.rs similarity index 100% rename from src/data_restore/src/blocks/mod.rs rename to core/data_restore/src/blocks/mod.rs diff --git a/src/data_restore/src/data_restore_driver.rs b/core/data_restore/src/data_restore_driver.rs similarity index 100% rename from src/data_restore/src/data_restore_driver.rs rename to core/data_restore/src/data_restore_driver.rs diff --git a/src/data_restore/src/franklin_transaction/mod.rs b/core/data_restore/src/franklin_transaction/mod.rs similarity index 100% rename from src/data_restore/src/franklin_transaction/mod.rs rename to core/data_restore/src/franklin_transaction/mod.rs diff --git a/src/data_restore/src/helpers/mod.rs b/core/data_restore/src/helpers/mod.rs similarity index 100% rename from src/data_restore/src/helpers/mod.rs rename to core/data_restore/src/helpers/mod.rs diff --git a/src/data_restore/src/lib.rs b/core/data_restore/src/lib.rs similarity index 100% rename from src/data_restore/src/lib.rs rename to core/data_restore/src/lib.rs diff --git a/src/eth_client/Cargo.toml b/core/eth_client/Cargo.toml similarity index 100% rename from src/eth_client/Cargo.toml rename to core/eth_client/Cargo.toml diff --git a/src/eth_client/src/lib.rs b/core/eth_client/src/lib.rs similarity index 100% rename from src/eth_client/src/lib.rs rename to core/eth_client/src/lib.rs diff --git a/src/eth_client/src/signer.rs b/core/eth_client/src/signer.rs similarity index 100% rename from src/eth_client/src/signer.rs rename to core/eth_client/src/signer.rs diff --git a/src/key_generator/Cargo.toml b/core/key_generator/Cargo.toml similarity index 100% rename from src/key_generator/Cargo.toml rename to core/key_generator/Cargo.toml diff --git a/src/key_generator/src/depositor_key.rs b/core/key_generator/src/depositor_key.rs similarity index 100% rename from src/key_generator/src/depositor_key.rs rename to core/key_generator/src/depositor_key.rs diff --git a/src/key_generator/src/exitor_key.rs b/core/key_generator/src/exitor_key.rs similarity index 100% rename from src/key_generator/src/exitor_key.rs rename to core/key_generator/src/exitor_key.rs diff --git a/src/key_generator/src/main.rs b/core/key_generator/src/main.rs similarity index 100% rename from src/key_generator/src/main.rs rename to core/key_generator/src/main.rs diff --git a/src/key_generator/src/read_write_keys.rs b/core/key_generator/src/read_write_keys.rs similarity index 100% rename from src/key_generator/src/read_write_keys.rs rename to core/key_generator/src/read_write_keys.rs diff --git a/src/key_generator/src/transactor_key.rs b/core/key_generator/src/transactor_key.rs similarity index 100% rename from src/key_generator/src/transactor_key.rs rename to core/key_generator/src/transactor_key.rs diff --git a/src/key_generator/src/vk_contract_generator.rs b/core/key_generator/src/vk_contract_generator.rs similarity index 100% rename from src/key_generator/src/vk_contract_generator.rs rename to core/key_generator/src/vk_contract_generator.rs diff --git a/src/merkle_tree/Cargo.toml b/core/merkle_tree/Cargo.toml similarity index 100% rename from src/merkle_tree/Cargo.toml rename to core/merkle_tree/Cargo.toml diff --git a/src/merkle_tree/src/account_tree.rs b/core/merkle_tree/src/account_tree.rs similarity index 100% rename from src/merkle_tree/src/account_tree.rs rename to core/merkle_tree/src/account_tree.rs diff --git a/src/merkle_tree/src/hasher.rs b/core/merkle_tree/src/hasher.rs similarity index 100% rename from src/merkle_tree/src/hasher.rs rename to core/merkle_tree/src/hasher.rs diff --git a/src/merkle_tree/src/lib.rs b/core/merkle_tree/src/lib.rs similarity index 100% rename from src/merkle_tree/src/lib.rs rename to core/merkle_tree/src/lib.rs diff --git a/src/merkle_tree/src/parallel_smt.rs b/core/merkle_tree/src/parallel_smt.rs similarity index 100% rename from src/merkle_tree/src/parallel_smt.rs rename to core/merkle_tree/src/parallel_smt.rs diff --git a/src/merkle_tree/src/pedersen_hasher.rs b/core/merkle_tree/src/pedersen_hasher.rs similarity index 100% rename from src/merkle_tree/src/pedersen_hasher.rs rename to core/merkle_tree/src/pedersen_hasher.rs diff --git a/src/merkle_tree/src/sequential_smt.rs b/core/merkle_tree/src/sequential_smt.rs similarity index 100% rename from src/merkle_tree/src/sequential_smt.rs rename to core/merkle_tree/src/sequential_smt.rs diff --git a/src/models/Cargo.toml b/core/models/Cargo.toml similarity index 100% rename from src/models/Cargo.toml rename to core/models/Cargo.toml diff --git a/src/models/src/abi.rs b/core/models/src/abi.rs similarity index 100% rename from src/models/src/abi.rs rename to core/models/src/abi.rs diff --git a/src/models/src/config.rs b/core/models/src/config.rs similarity index 100% rename from src/models/src/config.rs rename to core/models/src/config.rs diff --git a/src/models/src/lib.rs b/core/models/src/lib.rs similarity index 100% rename from src/models/src/lib.rs rename to core/models/src/lib.rs diff --git a/src/models/src/plasma/account.rs b/core/models/src/plasma/account.rs similarity index 100% rename from src/models/src/plasma/account.rs rename to core/models/src/plasma/account.rs diff --git a/src/models/src/plasma/block.rs b/core/models/src/plasma/block.rs similarity index 100% rename from src/models/src/plasma/block.rs rename to core/models/src/plasma/block.rs diff --git a/src/models/src/plasma/circuit/account.rs b/core/models/src/plasma/circuit/account.rs similarity index 100% rename from src/models/src/plasma/circuit/account.rs rename to core/models/src/plasma/circuit/account.rs diff --git a/src/models/src/plasma/circuit/deposit.rs b/core/models/src/plasma/circuit/deposit.rs similarity index 100% rename from src/models/src/plasma/circuit/deposit.rs rename to core/models/src/plasma/circuit/deposit.rs diff --git a/src/models/src/plasma/circuit/exit.rs b/core/models/src/plasma/circuit/exit.rs similarity index 100% rename from src/models/src/plasma/circuit/exit.rs rename to core/models/src/plasma/circuit/exit.rs diff --git a/src/models/src/plasma/circuit/mod.rs b/core/models/src/plasma/circuit/mod.rs similarity index 100% rename from src/models/src/plasma/circuit/mod.rs rename to core/models/src/plasma/circuit/mod.rs diff --git a/src/models/src/plasma/circuit/sig.rs b/core/models/src/plasma/circuit/sig.rs similarity index 100% rename from src/models/src/plasma/circuit/sig.rs rename to core/models/src/plasma/circuit/sig.rs diff --git a/src/models/src/plasma/circuit/transfer.rs b/core/models/src/plasma/circuit/transfer.rs similarity index 100% rename from src/models/src/plasma/circuit/transfer.rs rename to core/models/src/plasma/circuit/transfer.rs diff --git a/src/models/src/plasma/circuit/utils.rs b/core/models/src/plasma/circuit/utils.rs similarity index 100% rename from src/models/src/plasma/circuit/utils.rs rename to core/models/src/plasma/circuit/utils.rs diff --git a/src/models/src/plasma/mod.rs b/core/models/src/plasma/mod.rs similarity index 100% rename from src/models/src/plasma/mod.rs rename to core/models/src/plasma/mod.rs diff --git a/src/models/src/plasma/params.rs b/core/models/src/plasma/params.rs similarity index 100% rename from src/models/src/plasma/params.rs rename to core/models/src/plasma/params.rs diff --git a/src/models/src/plasma/tx.rs b/core/models/src/plasma/tx.rs similarity index 100% rename from src/models/src/plasma/tx.rs rename to core/models/src/plasma/tx.rs diff --git a/src/models/src/primitives.rs b/core/models/src/primitives.rs similarity index 100% rename from src/models/src/primitives.rs rename to core/models/src/primitives.rs diff --git a/src/plasma/Cargo.toml b/core/plasma/Cargo.toml similarity index 100% rename from src/plasma/Cargo.toml rename to core/plasma/Cargo.toml diff --git a/src/plasma/src/lib.rs b/core/plasma/src/lib.rs similarity index 100% rename from src/plasma/src/lib.rs rename to core/plasma/src/lib.rs diff --git a/src/plasma/src/state.rs b/core/plasma/src/state.rs similarity index 100% rename from src/plasma/src/state.rs rename to core/plasma/src/state.rs diff --git a/src/prover/Cargo.toml b/core/prover/Cargo.toml similarity index 100% rename from src/prover/Cargo.toml rename to core/prover/Cargo.toml diff --git a/src/prover/src/lib.rs b/core/prover/src/lib.rs similarity index 100% rename from src/prover/src/lib.rs rename to core/prover/src/lib.rs diff --git a/src/prover/src/main.rs b/core/prover/src/main.rs similarity index 100% rename from src/prover/src/main.rs rename to core/prover/src/main.rs diff --git a/src/sandbox/Cargo.toml b/core/sandbox/Cargo.toml similarity index 100% rename from src/sandbox/Cargo.toml rename to core/sandbox/Cargo.toml diff --git a/src/sandbox/src/main.rs b/core/sandbox/src/main.rs similarity index 100% rename from src/sandbox/src/main.rs rename to core/sandbox/src/main.rs diff --git a/src/sandbox/src/nonce_futures.rs b/core/sandbox/src/nonce_futures.rs similarity index 100% rename from src/sandbox/src/nonce_futures.rs rename to core/sandbox/src/nonce_futures.rs diff --git a/src/server/Cargo.toml b/core/server/Cargo.toml similarity index 100% rename from src/server/Cargo.toml rename to core/server/Cargo.toml diff --git a/src/server/src/analysis.pgsql b/core/server/src/analysis.pgsql similarity index 100% rename from src/server/src/analysis.pgsql rename to core/server/src/analysis.pgsql diff --git a/src/server/src/api_server.rs b/core/server/src/api_server.rs similarity index 100% rename from src/server/src/api_server.rs rename to core/server/src/api_server.rs diff --git a/src/server/src/committer.rs b/core/server/src/committer.rs similarity index 100% rename from src/server/src/committer.rs rename to core/server/src/committer.rs diff --git a/src/server/src/eth_sender.rs b/core/server/src/eth_sender.rs similarity index 100% rename from src/server/src/eth_sender.rs rename to core/server/src/eth_sender.rs diff --git a/src/server/src/eth_watch.rs b/core/server/src/eth_watch.rs similarity index 100% rename from src/server/src/eth_watch.rs rename to core/server/src/eth_watch.rs diff --git a/src/server/src/lib.rs b/core/server/src/lib.rs similarity index 100% rename from src/server/src/lib.rs rename to core/server/src/lib.rs diff --git a/src/server/src/main.rs b/core/server/src/main.rs similarity index 100% rename from src/server/src/main.rs rename to core/server/src/main.rs diff --git a/src/server/src/nonce_futures.rs b/core/server/src/nonce_futures.rs similarity index 100% rename from src/server/src/nonce_futures.rs rename to core/server/src/nonce_futures.rs diff --git a/src/server/src/state_keeper.rs b/core/server/src/state_keeper.rs similarity index 100% rename from src/server/src/state_keeper.rs rename to core/server/src/state_keeper.rs diff --git a/src/storage/.gitignore b/core/storage/.gitignore similarity index 100% rename from src/storage/.gitignore rename to core/storage/.gitignore diff --git a/src/storage/Cargo.toml b/core/storage/Cargo.toml similarity index 100% rename from src/storage/Cargo.toml rename to core/storage/Cargo.toml diff --git a/src/storage/diesel.toml b/core/storage/diesel.toml similarity index 100% rename from src/storage/diesel.toml rename to core/storage/diesel.toml diff --git a/src/storage/migrations/00000000000000_diesel_initial_setup/down.sql b/core/storage/migrations/00000000000000_diesel_initial_setup/down.sql similarity index 100% rename from src/storage/migrations/00000000000000_diesel_initial_setup/down.sql rename to core/storage/migrations/00000000000000_diesel_initial_setup/down.sql diff --git a/src/storage/migrations/00000000000000_diesel_initial_setup/up.sql b/core/storage/migrations/00000000000000_diesel_initial_setup/up.sql similarity index 100% rename from src/storage/migrations/00000000000000_diesel_initial_setup/up.sql rename to core/storage/migrations/00000000000000_diesel_initial_setup/up.sql diff --git a/src/storage/migrations/2018-12-11-084553_operations/down.sql b/core/storage/migrations/2018-12-11-084553_operations/down.sql similarity index 100% rename from src/storage/migrations/2018-12-11-084553_operations/down.sql rename to core/storage/migrations/2018-12-11-084553_operations/down.sql diff --git a/src/storage/migrations/2018-12-11-084553_operations/up.sql b/core/storage/migrations/2018-12-11-084553_operations/up.sql similarity index 100% rename from src/storage/migrations/2018-12-11-084553_operations/up.sql rename to core/storage/migrations/2018-12-11-084553_operations/up.sql diff --git a/src/storage/migrations/2019-04-02-100645_proofs/down.sql b/core/storage/migrations/2019-04-02-100645_proofs/down.sql similarity index 100% rename from src/storage/migrations/2019-04-02-100645_proofs/down.sql rename to core/storage/migrations/2019-04-02-100645_proofs/down.sql diff --git a/src/storage/migrations/2019-04-02-100645_proofs/up.sql b/core/storage/migrations/2019-04-02-100645_proofs/up.sql similarity index 100% rename from src/storage/migrations/2019-04-02-100645_proofs/up.sql rename to core/storage/migrations/2019-04-02-100645_proofs/up.sql diff --git a/src/storage/migrations/2019-05-02-110639_transactions/down.sql b/core/storage/migrations/2019-05-02-110639_transactions/down.sql similarity index 100% rename from src/storage/migrations/2019-05-02-110639_transactions/down.sql rename to core/storage/migrations/2019-05-02-110639_transactions/down.sql diff --git a/src/storage/migrations/2019-05-02-110639_transactions/up.sql b/core/storage/migrations/2019-05-02-110639_transactions/up.sql similarity index 100% rename from src/storage/migrations/2019-05-02-110639_transactions/up.sql rename to core/storage/migrations/2019-05-02-110639_transactions/up.sql diff --git a/src/storage/migrations/2019-05-08-114230_config/down.sql b/core/storage/migrations/2019-05-08-114230_config/down.sql similarity index 100% rename from src/storage/migrations/2019-05-08-114230_config/down.sql rename to core/storage/migrations/2019-05-08-114230_config/down.sql diff --git a/src/storage/migrations/2019-05-08-114230_config/up.sql b/core/storage/migrations/2019-05-08-114230_config/up.sql similarity index 100% rename from src/storage/migrations/2019-05-08-114230_config/up.sql rename to core/storage/migrations/2019-05-08-114230_config/up.sql diff --git a/src/storage/migrations/2019-05-16-130227_provers/down.sql b/core/storage/migrations/2019-05-16-130227_provers/down.sql similarity index 100% rename from src/storage/migrations/2019-05-16-130227_provers/down.sql rename to core/storage/migrations/2019-05-16-130227_provers/down.sql diff --git a/src/storage/migrations/2019-05-16-130227_provers/up.sql b/core/storage/migrations/2019-05-16-130227_provers/up.sql similarity index 100% rename from src/storage/migrations/2019-05-16-130227_provers/up.sql rename to core/storage/migrations/2019-05-16-130227_provers/up.sql diff --git a/src/storage/sql/active_provers.pgsql b/core/storage/sql/active_provers.pgsql similarity index 100% rename from src/storage/sql/active_provers.pgsql rename to core/storage/sql/active_provers.pgsql diff --git a/src/storage/sql/prover-runs.pgsql b/core/storage/sql/prover-runs.pgsql similarity index 100% rename from src/storage/sql/prover-runs.pgsql rename to core/storage/sql/prover-runs.pgsql diff --git a/src/storage/sql/tps.pgsql b/core/storage/sql/tps.pgsql similarity index 100% rename from src/storage/sql/tps.pgsql rename to core/storage/sql/tps.pgsql diff --git a/src/storage/src/lib.rs b/core/storage/src/lib.rs similarity index 100% rename from src/storage/src/lib.rs rename to core/storage/src/lib.rs diff --git a/src/storage/src/schema.rs b/core/storage/src/schema.rs similarity index 100% rename from src/storage/src/schema.rs rename to core/storage/src/schema.rs From 2a8d20d70861f8e8a45e3e447da0b6326268d0b5 Mon Sep 17 00:00:00 2001 From: Vitaly Drogan Date: Thu, 20 Jun 2019 20:05:33 +0300 Subject: [PATCH 2/2] prinln -> rust loggin with log crate --- Cargo.lock | 103 ++++++++++++++++++ core/circuit/Cargo.toml | 3 + core/circuit/src/cheque/bitwindow.rs | 17 +-- core/circuit/src/deposit/circuit.rs | 46 ++++---- core/circuit/src/exit/circuit.rs | 26 +++-- core/circuit/src/transfer/circuit.rs | 53 ++++----- core/data_restore/Cargo.toml | 1 + core/data_restore/src/accounts_state/mod.rs | 20 ++-- core/data_restore/src/block_events/mod.rs | 56 +++++----- core/data_restore/src/data_restore_driver.rs | 76 ++++++------- core/data_restore/src/lib.rs | 3 + core/eth_client/Cargo.toml | 1 + core/eth_client/src/lib.rs | 18 +-- core/eth_client/src/signer.rs | 2 +- core/key_generator/Cargo.toml | 2 + core/key_generator/src/depositor_key.rs | 6 +- core/key_generator/src/exitor_key.rs | 6 +- core/key_generator/src/main.rs | 5 + core/key_generator/src/read_write_keys.rs | 37 ++++--- core/key_generator/src/transactor_key.rs | 6 +- core/merkle_tree/Cargo.toml | 3 + core/merkle_tree/src/parallel_smt.rs | 38 ++++--- core/merkle_tree/src/pedersen_hasher.rs | 6 +- core/merkle_tree/src/sequential_smt.rs | 16 +-- core/models/Cargo.toml | 1 + core/models/src/lib.rs | 2 + core/models/src/plasma/tx.rs | 8 +- core/plasma/Cargo.toml | 1 + core/plasma/src/lib.rs | 3 + core/plasma/src/state.rs | 10 +- core/prover/Cargo.toml | 2 + core/prover/src/lib.rs | 109 ++++++++++--------- core/prover/src/main.rs | 9 +- core/sandbox/Cargo.toml | 2 + core/sandbox/src/main.rs | 11 +- core/server/Cargo.toml | 2 + core/server/src/api_server.rs | 14 +-- core/server/src/committer.rs | 4 +- core/server/src/eth_sender.rs | 10 +- core/server/src/eth_watch.rs | 22 ++-- core/server/src/lib.rs | 2 + core/server/src/main.rs | 10 +- core/server/src/state_keeper.rs | 22 ++-- core/storage/Cargo.toml | 1 + core/storage/src/lib.rs | 14 ++- etc/env/dev.env.example | 2 + 46 files changed, 491 insertions(+), 320 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1fa55acdd6..381489ee2f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -141,6 +141,16 @@ dependencies = [ "nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "atty" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", + "termion 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "autocfg" version = "0.1.4" @@ -320,6 +330,7 @@ dependencies = [ "bellman_ce 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "ff_ce 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "merkle_tree 0.1.1", "models 0.0.1", "pairing_ce 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -520,6 +531,7 @@ dependencies = [ "ff_ce 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "models 0.0.1", "pairing_ce 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)", "plasma 0.1.1", @@ -655,6 +667,18 @@ dependencies = [ "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "env_logger" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", + "humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "termcolor 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "error-chain" version = "0.8.1" @@ -680,6 +704,7 @@ dependencies = [ "ethereum-tx-sign 0.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "ethereum-types 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "models 0.0.1", "reqwest 0.9.18 (registry+https://github.com/rust-lang/crates.io-index)", "rlp 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -996,6 +1021,14 @@ name = "httparse" version = "1.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "humantime" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "hyper" version = "0.10.16" @@ -1181,8 +1214,10 @@ version = "0.1.1" dependencies = [ "bellman_ce 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "circuit 0.1.1", + "env_logger 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "ff_ce 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "models 0.0.1", "pairing_ce 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1278,6 +1313,7 @@ version = "0.1.1" dependencies = [ "ff_ce 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "models 0.0.1", "pairing_ce 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1398,6 +1434,7 @@ dependencies = [ "ff_ce 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "pairing_ce 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "sapling-crypto_ce 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1487,6 +1524,11 @@ dependencies = [ "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "numtoa" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "openssl" version = "0.10.23" @@ -1644,6 +1686,7 @@ name = "plasma" version = "0.1.1" dependencies = [ "bigdecimal 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "merkle_tree 0.1.1", "models 0.0.1", ] @@ -1689,9 +1732,11 @@ dependencies = [ "chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "circuit 0.1.1", "diesel 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "env_logger 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "ff_ce 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "models 0.0.1", "pairing_ce 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)", "plasma 0.1.1", @@ -1905,6 +1950,14 @@ name = "redox_syscall" version = "0.1.54" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "redox_termios" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "regex" version = "1.1.7" @@ -2070,8 +2123,10 @@ name = "sandbox" version = "0.0.1" dependencies = [ "bodyparser 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "env_logger 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "iron 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "persistent 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2223,6 +2278,7 @@ dependencies = [ "chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "circuit 0.1.1", "diesel 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "env_logger 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "eth_client 0.1.0", "ethabi 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "ff_ce 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2231,6 +2287,7 @@ dependencies = [ "hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "hyper 0.12.29 (registry+https://github.com/rust-lang/crates.io-index)", "im 12.3.4 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "models 0.0.1", "num-bigint 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2338,6 +2395,7 @@ dependencies = [ "diesel 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "ff_ce 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "models 0.0.1", "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2397,6 +2455,25 @@ dependencies = [ "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "termcolor" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "wincolor 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "termion" +version = "1.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", + "numtoa 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "thread_local" version = "0.3.6" @@ -3045,11 +3122,28 @@ name = "winapi-i686-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "winapi-util" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "wincolor" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "winreg" version = "0.5.1" @@ -3084,6 +3178,7 @@ dependencies = [ "checksum aho-corasick 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e6f484ae0c99fec2e858eb6134949117399f222608d84cadb3f58c1f97c2364c" "checksum arc-swap 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)" = "bc4662175ead9cd84451d5c35070517777949a2ed84551764129cedb88384841" "checksum arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "92c7fb76bc8826a8b33b4ee5bb07a247a81e76764ab4d55e8f73e3a4d8808c71" +"checksum atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9a7d5b8723950951411ee34d271d99dddcc2035a16ab25310ea2c8cfd4369652" "checksum autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "0e49efa51329a5fd37e7c79db4621af617cd4e3e5bc224939808d076077077bf" "checksum backtrace 0.3.30 (registry+https://github.com/rust-lang/crates.io-index)" = "ada4c783bb7e7443c14e0480f429ae2cc99da95065aeab7ee1b81ada0419404f" "checksum backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)" = "797c830ac25ccc92a7f8a7b9862bde440715531514594a6154e3d4a54dd769b6" @@ -3140,6 +3235,7 @@ dependencies = [ "checksum encoding-index-tradchinese 1.20141219.5 (registry+https://github.com/rust-lang/crates.io-index)" = "fd0e20d5688ce3cab59eb3ef3a2083a5c77bf496cb798dc6fcdb75f323890c18" "checksum encoding_index_tests 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "a246d82be1c9d791c5dfde9a2bd045fc3cbba3fa2b11ad558f27d01712f00569" "checksum encoding_rs 0.8.17 (registry+https://github.com/rust-lang/crates.io-index)" = "4155785c79f2f6701f185eb2e6b4caf0555ec03477cb4c70db67b465311620ed" +"checksum env_logger 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b61fa891024a945da30a9581546e8cfaf5602c7b3f4c137a2805cf388f92075a" "checksum error-chain 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3ab49e9dcb602294bc42f9a7dfc9bc6e936fca4418ea300dbfb84fe16de0b7d9" "checksum error-chain 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6930e04918388a9a2e41d518c25cf679ccafe26733fb4127dbf21993f2575d46" "checksum ethabi 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8eb362fde43ed0b50b258bb0c72b72b3dccfd29f8de9506295eaf9251c49ca31" @@ -3174,6 +3270,7 @@ dependencies = [ "checksum http 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)" = "eed324f0f0daf6ec10c474f150505af2c143f251722bf9dbd1261bd1f2ee2c1a" "checksum http-body 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6741c859c1b2463a423a1dbce98d418e6c3c3fc720fb0d45528657320920292d" "checksum httparse 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e8734b0cfd3bc3e101ec59100e101c2eecd19282202e87808b3037b442777a83" +"checksum humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3ca7e5f2e110db35f93b837c81797f3714500b81d517bf20c431b16d3ca4f114" "checksum hyper 0.10.16 (registry+https://github.com/rust-lang/crates.io-index)" = "0a0652d9a2609a968c14be1a9ea00bf4b1d64e2e1f53a1b51b6fff3a6e829273" "checksum hyper 0.12.29 (registry+https://github.com/rust-lang/crates.io-index)" = "e2cd6adf83b3347d36e271f030621a8cf95fd1fd0760546b9fc5a24a0f1447c7" "checksum hyper-tls 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "3a800d6aa50af4b5850b2b0f659625ce9504df908e9733b635720483be26174f" @@ -3222,6 +3319,7 @@ dependencies = [ "checksum num-integer 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)" = "b85e541ef8255f6cf42bbfe4ef361305c6c135d10919ecc26126c4e5ae94bc09" "checksum num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "6ba9a427cfca2be13aa6f6403b0b7e7368fe982bfa16fccc450ce74c46cd9b32" "checksum num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "bcef43580c035376c0705c42792c294b66974abbfd2789b511784023f71f3273" +"checksum numtoa 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b8f8bdf33df195859076e54ab11ee78a1b208382d3a26ec40d142ffc1ecc49ef" "checksum openssl 0.10.23 (registry+https://github.com/rust-lang/crates.io-index)" = "97c140cbb82f3b3468193dd14c1b88def39f341f68257f8a7fe8ed9ed3f628a5" "checksum openssl-probe 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "77af24da69f9d9341038eba93a073b1fdaaa1b788221b00a69bce9e762cb32de" "checksum openssl-sys 0.9.47 (registry+https://github.com/rust-lang/crates.io-index)" = "75bdd6dbbb4958d38e47a1d2348847ad1eb4dc205dc5d37473ae504391865acc" @@ -3263,6 +3361,7 @@ dependencies = [ "checksum rayon-core 1.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b055d1e92aba6877574d8fe604a63c8b5df60f60e5982bf7ccbb1338ea527356" "checksum rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" "checksum redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)" = "12229c14a0f65c4f1cb046a3b52047cdd9da1f4b30f8a39c5063c8bae515e252" +"checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76" "checksum regex 1.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "0b2f0808e7d7e4fb1cb07feb6ff2f4bc827938f24f8c2e6a3beb7370af544bdd" "checksum regex-syntax 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)" = "9d76410686f9e3a17f06128962e0ecc5755870bb890c34820c7af7f1db2e1d48" "checksum remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3488ba1b9a2084d38645c4c08276a1752dcbf2c7130d74f1569681ad5d2799c5" @@ -3312,6 +3411,8 @@ dependencies = [ "checksum syn 0.15.35 (registry+https://github.com/rust-lang/crates.io-index)" = "641e117d55514d6d918490e47102f7e08d096fdde360247e4a10f7a91a8478d3" "checksum synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "02353edf96d6e4dc81aea2d8490a7e9db177bf8acb0e951c24940bf866cb313f" "checksum tempfile 3.0.8 (registry+https://github.com/rust-lang/crates.io-index)" = "7dc4738f2e68ed2855de5ac9cdbe05c9216773ecde4739b2f095002ab03a13ef" +"checksum termcolor 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "96d6098003bde162e4277c70665bd87c326f5a0c3f3fbfb285787fa482d54e6e" +"checksum termion 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "6a8fb22f7cde82c8220e5aeacb3258ed7ce996142c77cba193f203515e26c330" "checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b" "checksum time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "db8dcfca086c1143c9270ac42a2bbd8a7ee477b78ac8e45b19abfb0cbede4b6f" "checksum tiny-keccak 1.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "dbbdebb0b801c7fa4260b6b9ac5a15980276d7d7bcc2dc2959a7c4dc8b426a1a" @@ -3372,7 +3473,9 @@ dependencies = [ "checksum winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "f10e386af2b13e47c89e7236a7a14a086791a2b88ebad6df9bf42040195cf770" "checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" "checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" +"checksum winapi-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7168bab6e1daee33b4557efd0e95d5ca70a03706d39fa5f3fe7a236f584b03c9" "checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +"checksum wincolor 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "561ed901ae465d6185fa7864d63fbd5720d0ef718366c9a4dc83cf6170d7e9ba" "checksum winreg 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a27a759395c1195c4cc5cda607ef6f8f6498f64e78f7900f5de0a127a424704a" "checksum winutil 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7daf138b6b14196e3830a588acf1e86966c694d3e8fb026fb105b8b5dca07e6e" "checksum ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" diff --git a/core/circuit/Cargo.toml b/core/circuit/Cargo.toml index 85384f609e..61c77f3408 100644 --- a/core/circuit/Cargo.toml +++ b/core/circuit/Cargo.toml @@ -18,3 +18,6 @@ ff = { package = "ff_ce", version = "0.6.0", features = ["derive"] } rand = "0.4" rust-crypto = "0.2" hex = "0.3.2" + +[dev-dependencies] +log = "0.4" diff --git a/core/circuit/src/cheque/bitwindow.rs b/core/circuit/src/cheque/bitwindow.rs index 10faabf293..f020ae83dc 100644 --- a/core/circuit/src/cheque/bitwindow.rs +++ b/core/circuit/src/cheque/bitwindow.rs @@ -456,9 +456,10 @@ impl<'a, E: JubjubEngine> Circuit for BitSet<'a, E> { #[cfg(test)] mod test { - use super::*; + use log::{debug, error}; + use bellman::groth16::{ create_random_proof, generate_random_parameters, prepare_verifying_key, verify_proof, }; @@ -514,21 +515,21 @@ mod test { instance.synthesize(&mut cs).expect("must synthesize"); - println!("{}", cs.find_unconstrained()); + debug!("{}", cs.find_unconstrained()); - println!("{}", cs.num_constraints()); + debug!("{}", cs.num_constraints()); assert_eq!(cs.num_inputs(), 1); let err = cs.which_is_unsatisfied(); if err.is_some() { - println!( + error!( "Error for bitfield = {:#b}, bit of interest = {}", existing_field, bit_of_interest ); panic!("ERROR satisfying in {}", err.unwrap()); } else { - println!("Satisfied for bit = {}", bit_of_interest); + debug!("Satisfied for bit = {}", bit_of_interest); } } } @@ -668,7 +669,7 @@ mod test { for i in 0..=max_with_shift { let x = Fr::from_str(&i.to_string()).unwrap(); let val = evaluate_at_x::(&interpolation[..], &x); - println!("X = {}, Y = {}", x, val); + debug!("X = {}, Y = {}", x, val); } } @@ -684,7 +685,7 @@ mod test { for i in 0..=max_with_shift { let x = Fr::from_str(&i.to_string()).unwrap(); let val = evaluate_at_x::(&interpolation[..], &x); - println!("X = {}, Y = {}", x, val); + debug!("X = {}, Y = {}", x, val); } } @@ -700,7 +701,7 @@ mod test { for i in 0..=full_range { let x = Fr::from_str(&i.to_string()).unwrap(); let val = evaluate_at_x::(&interpolation[..], &x); - println!("X = {}, Y = {}", x, val); + debug!("X = {}, Y = {}", x, val); } } } diff --git a/core/circuit/src/deposit/circuit.rs b/core/circuit/src/deposit/circuit.rs index 9df0e9cffe..fcd8acb32a 100644 --- a/core/circuit/src/deposit/circuit.rs +++ b/core/circuit/src/deposit/circuit.rs @@ -519,8 +519,10 @@ where #[cfg(test)] mod test { - use super::*; + + use log::debug; + use ff::PrimeFieldRepr; use sapling_crypto::jubjub::FixedGenerators; @@ -550,7 +552,7 @@ mod test { let tree_depth = plasma_constants::BALANCE_TREE_DEPTH as u32; let mut tree = CircuitAccountTree::new(tree_depth); let initial_root = tree.root_hash(); - println!("Initial root = {}", initial_root); + debug!("Initial root = {}", initial_root); let capacity = tree.capacity(); assert_eq!(capacity, 1 << plasma_constants::BALANCE_TREE_DEPTH); @@ -558,7 +560,7 @@ mod test { let sender_sk = PrivateKey::(rng.gen()); let sender_pk = PublicKey::from_private(&sender_sk, p_g, params); let (sender_x, sender_y) = sender_pk.0.into_xy(); - println!("x = {}, y = {}", sender_x, sender_y); + debug!("x = {}, y = {}", sender_x, sender_y); // give some funds to sender and make zero balance for recipient @@ -580,7 +582,7 @@ mod test { tree.insert(sender_leaf_number, sender_leaf.clone()); - println!( + debug!( "Sender leaf hash is {}", tree.get_hash((tree_depth, sender_leaf_number)) ); @@ -618,14 +620,14 @@ mod test { let new_root = tree.root_hash(); - println!("New root = {}", new_root); + debug!("New root = {}", new_root); - assert!(initial_root != new_root); + assert_ne!(initial_root, new_root); { let mut cs = TestConstraintSystem::::new(); - let mut public_data_initial_bits = vec![]; + let mut public_data_initial_bits = Vec::new(); // these two are BE encodings because an iterator is BE. This is also an Ethereum standard behavior @@ -646,7 +648,7 @@ mod test { let mut hash_result = [0u8; 32]; h.result(&mut hash_result[..]); - println!("Initial hash hex {}", hex::encode(hash_result)); + debug!("Initial hash hex {}", hex::encode(hash_result)); let mut packed_transaction_data = vec![]; let transaction_data = request.public_data_into_bits(); @@ -656,7 +658,7 @@ mod test { let packed_transaction_data_bytes = be_bit_vector_into_bytes(&packed_transaction_data); - println!( + debug!( "Packed transaction data hex {}", hex::encode(packed_transaction_data_bytes.clone()) ); @@ -670,7 +672,7 @@ mod test { hash_result = [0u8; 32]; h.result(&mut hash_result[..]); - println!("Final hash as hex {}", hex::encode(hash_result)); + debug!("Final hash as hex {}", hex::encode(hash_result)); hash_result[0] &= 0x1f; // temporary solution @@ -680,7 +682,7 @@ mod test { let public_data_commitment = Fr::from_repr(repr).unwrap(); - println!( + debug!( "Final data commitment as field element = {}", public_data_commitment ); @@ -697,9 +699,9 @@ mod test { instance.synthesize(&mut cs).unwrap(); - println!("{}", cs.find_unconstrained()); + debug!("{}", cs.find_unconstrained()); - println!("{}", cs.num_constraints()); + debug!("{}", cs.num_constraints()); assert_eq!(cs.num_inputs(), 4); @@ -761,7 +763,7 @@ mod test { tree.insert(sender_leaf_number, sender_leaf.clone()); - println!( + debug!( "Sender leaf hash is {}", tree.get_hash((tree_depth, sender_leaf_number)) ); @@ -769,7 +771,7 @@ mod test { //assert!(tree.verify_proof(sender_leaf_number, sender_leaf.clone(), tree.merkle_path(sender_leaf_number))); let initial_root = tree.root_hash(); - println!("Initial root = {}", initial_root); + debug!("Initial root = {}", initial_root); let mut double_the_amount = transfer_amount_as_field_element; double_the_amount.double(); @@ -814,7 +816,7 @@ mod test { let new_root = tree.root_hash(); - println!("New root = {}", new_root); + debug!("New root = {}", new_root); assert!(initial_root != new_root); @@ -842,7 +844,7 @@ mod test { let mut hash_result = [0u8; 32]; h.result(&mut hash_result[..]); - println!("Initial hash hex {}", hex::encode(hash_result)); + debug!("Initial hash hex {}", hex::encode(hash_result)); let mut packed_transaction_data = vec![]; let transaction_data = request.public_data_into_bits(); @@ -852,7 +854,7 @@ mod test { let packed_transaction_data_bytes = be_bit_vector_into_bytes(&packed_transaction_data); - println!( + debug!( "Packed transaction data hex {}", hex::encode(packed_transaction_data_bytes.clone()) ); @@ -866,7 +868,7 @@ mod test { hash_result = [0u8; 32]; h.result(&mut hash_result[..]); - println!("Final hash as hex {}", hex::encode(hash_result)); + debug!("Final hash as hex {}", hex::encode(hash_result)); hash_result[0] &= 0x1f; // temporary solution @@ -876,7 +878,7 @@ mod test { let public_data_commitment = Fr::from_repr(repr).unwrap(); - println!( + debug!( "Final data commitment as field element = {}", public_data_commitment ); @@ -893,9 +895,9 @@ mod test { instance.synthesize(&mut cs).unwrap(); - println!("{}", cs.find_unconstrained()); + debug!("{}", cs.find_unconstrained()); - println!("{}", cs.num_constraints()); + debug!("{}", cs.num_constraints()); assert_eq!(cs.num_inputs(), 4); diff --git a/core/circuit/src/exit/circuit.rs b/core/circuit/src/exit/circuit.rs index e350410934..e0d121479c 100644 --- a/core/circuit/src/exit/circuit.rs +++ b/core/circuit/src/exit/circuit.rs @@ -366,8 +366,10 @@ where #[cfg(test)] mod test { - use super::*; + + use log::debug; + use ff::PrimeFieldRepr; use sapling_crypto::jubjub::FixedGenerators; @@ -425,7 +427,7 @@ mod test { tree.insert(sender_leaf_number, sender_leaf.clone()); - println!( + debug!( "Sender leaf hash is {}", tree.get_hash((tree_depth, sender_leaf_number)) ); @@ -433,7 +435,7 @@ mod test { //assert!(tree.verify_proof(sender_leaf_number, sender_leaf.clone(), tree.merkle_path(sender_leaf_number))); let initial_root = tree.root_hash(); - println!("Initial root = {}", initial_root); + debug!("Initial root = {}", initial_root); let path_from: Vec> = tree .merkle_path(sender_leaf_number) @@ -478,14 +480,14 @@ mod test { let new_root = tree.root_hash(); - println!("New root = {}", new_root); + debug!("New root = {}", new_root); - assert!(initial_root != new_root); + assert_ne!(initial_root, new_root); { let mut cs = TestConstraintSystem::::new(); - let mut public_data_initial_bits = vec![]; + let mut public_data_initial_bits = Vec::new(); // these two are BE encodings because an iterator is BE. This is also an Ethereum standard behavior @@ -506,7 +508,7 @@ mod test { let mut hash_result = [0u8; 32]; h.result(&mut hash_result[..]); - println!("Initial hash hex {}", hex::encode(hash_result)); + debug!("Initial hash hex {}", hex::encode(hash_result)); let mut packed_transaction_data = vec![]; let transaction_data = request.public_data_into_bits(); @@ -516,7 +518,7 @@ mod test { let packed_transaction_data_bytes = be_bit_vector_into_bytes(&packed_transaction_data); - println!( + debug!( "Packed transaction data hex {}", hex::encode(packed_transaction_data_bytes.clone()) ); @@ -530,7 +532,7 @@ mod test { hash_result = [0u8; 32]; h.result(&mut hash_result[..]); - println!("Final hash as hex {}", hex::encode(hash_result)); + debug!("Final hash as hex {}", hex::encode(hash_result)); hash_result[0] &= 0x1f; // temporary solution @@ -540,7 +542,7 @@ mod test { let public_data_commitment = Fr::from_repr(repr).unwrap(); - println!( + debug!( "Final data commitment as field element = {}", public_data_commitment ); @@ -558,9 +560,9 @@ mod test { instance.synthesize(&mut cs).unwrap(); - println!("{}", cs.find_unconstrained()); + debug!("{}", cs.find_unconstrained()); - println!("{}", cs.num_constraints()); + debug!("{}", cs.num_constraints()); assert_eq!(cs.num_inputs(), 4); diff --git a/core/circuit/src/transfer/circuit.rs b/core/circuit/src/transfer/circuit.rs index 1054607d5b..62284e26e3 100644 --- a/core/circuit/src/transfer/circuit.rs +++ b/core/circuit/src/transfer/circuit.rs @@ -1132,8 +1132,10 @@ where #[cfg(test)] mod test { - use super::*; + + use log::debug; + use ff::{BitIterator, PrimeFieldRepr}; use models::plasma::circuit::utils::le_bit_vector_into_field_element; use sapling_crypto::circuit::float_point::convert_to_float; @@ -1147,10 +1149,11 @@ mod test { let fe: Fr = le_bit_vector_into_field_element::(&bits); - println!("{}", fe); + debug!("{}", fe); } #[test] + #[allow(clippy::cognitive_complexity)] fn test_transfer_circuit_with_witness() { use crate::CircuitAccountTree; use ff::Field; @@ -1242,19 +1245,19 @@ mod test { }; let initial_root = tree.root_hash(); - println!("Empty root = {}", initial_root); + debug!("Empty root = {}", initial_root); tree.insert(sender_leaf_number, sender_leaf.clone()); tree.insert(recipient_leaf_number, recipient_leaf.clone()); let old_root = tree.root_hash(); - println!("Old root = {}", old_root); + debug!("Old root = {}", old_root); - println!( + debug!( "Sender leaf hash is {}", tree.get_hash((tree_depth, sender_leaf_number)) ); - println!( + debug!( "Recipient leaf hash is {}", tree.get_hash((tree_depth, recipient_leaf_number)) ); @@ -1324,25 +1327,25 @@ mod test { .sub_assign(&transfer_amount_as_field_element); updated_sender_leaf.nonce.add_assign(&Fr::one()); - println!("Updated sender:"); - println!("Amount: {}", updated_sender_leaf.clone().balance); - println!("Nonce: {}", updated_sender_leaf.clone().nonce); + debug!("Updated sender:"); + debug!("Amount: {}", updated_sender_leaf.clone().balance); + debug!("Nonce: {}", updated_sender_leaf.clone().nonce); updated_recipient_leaf .balance .add_assign(&transfer_amount_as_field_element); - println!("Updated recipient:"); - println!("Amount: {}", updated_recipient_leaf.clone().balance); - println!("Nonce: {}", updated_recipient_leaf.clone().nonce); + debug!("Updated recipient:"); + debug!("Amount: {}", updated_recipient_leaf.clone().balance); + debug!("Nonce: {}", updated_recipient_leaf.clone().nonce); tree.insert(sender_leaf_number, updated_sender_leaf.clone()); tree.insert(recipient_leaf_number, updated_recipient_leaf.clone()); - println!( + debug!( "Final sender leaf hash is {}", tree.get_hash((tree_depth, sender_leaf_number)) ); - println!( + debug!( "Final recipient leaf hash is {}", tree.get_hash((tree_depth, recipient_leaf_number)) ); @@ -1352,14 +1355,14 @@ mod test { let new_root = tree.root_hash(); - println!("New root = {}", new_root); + debug!("New root = {}", new_root); - assert!(old_root != new_root); + assert_ne!(old_root, new_root); { let mut cs = TestConstraintSystem::::new(); - let mut public_data_initial_bits = vec![]; + let mut public_data_initial_bits = Vec::new(); // these two are BE encodings because an iterator is BE. This is also an Ethereum standard behavior @@ -1387,21 +1390,21 @@ mod test { let mut hash_result = [0u8; 32]; h.result(&mut hash_result[..]); - println!("Initial hash hex {}", hex::encode(hash_result)); + debug!("Initial hash hex {}", hex::encode(hash_result)); - let mut packed_transaction_data = vec![]; + let mut packed_transaction_data = Vec::new(); let transaction_data = transaction.public_data_into_bits(); packed_transaction_data.extend(transaction_data.clone().into_iter()); let packed_transaction_data_bytes = be_bit_vector_into_bytes(&packed_transaction_data); - println!( + debug!( "Packed transaction data hex {}", hex::encode(packed_transaction_data_bytes.clone()) ); - let mut next_round_hash_bytes = vec![]; + let mut next_round_hash_bytes = Vec::new(); next_round_hash_bytes.extend(hash_result.iter()); next_round_hash_bytes.extend(packed_transaction_data_bytes); // assert_eq!(next_round_hash_bytes.len(), 64); @@ -1411,7 +1414,7 @@ mod test { hash_result = [0u8; 32]; h.result(&mut hash_result[..]); - println!("Final hash as hex {}", hex::encode(hash_result)); + debug!("Final hash as hex {}", hex::encode(hash_result)); hash_result[0] &= 0x1f; // temporary solution @@ -1421,7 +1424,7 @@ mod test { let public_data_commitment = Fr::from_repr(repr).unwrap(); - println!( + debug!( "Final data commitment as field element = {}", public_data_commitment ); @@ -1439,9 +1442,9 @@ mod test { instance.synthesize(&mut cs).unwrap(); - println!("{}", cs.find_unconstrained()); + debug!("{}", cs.find_unconstrained()); - println!("{}", cs.num_constraints()); + debug!("{}", cs.num_constraints()); assert_eq!(cs.num_inputs(), 4); diff --git a/core/data_restore/Cargo.toml b/core/data_restore/Cargo.toml index ba7679ef4f..149ea9413b 100644 --- a/core/data_restore/Cargo.toml +++ b/core/data_restore/Cargo.toml @@ -15,6 +15,7 @@ ff = { package = "ff_ce", version = "0.6.0", features = ["derive"] } pairing = { package = "pairing_ce", version = "0.17.0" } tokio = "0.1" bitvec = "0.11" +log = "0.4" plasma = { path = "../plasma" } models = { path = "../models" } diff --git a/core/data_restore/src/accounts_state/mod.rs b/core/data_restore/src/accounts_state/mod.rs index f4815b1727..206fbc7635 100644 --- a/core/data_restore/src/accounts_state/mod.rs +++ b/core/data_restore/src/accounts_state/mod.rs @@ -67,14 +67,14 @@ impl FranklinAccountsStates { &mut self, transaction: &FranklinTransaction, ) -> Result<(), DataRestoreError> { - // println!("tx: {:?}", transaction.ethereum_transaction.hash); + // debug!("tx: {:?}", transaction.ethereum_transaction.hash); let transfer_txs_block = self .get_all_transactions_from_transfer_block(transaction) .map_err(|e| DataRestoreError::NoData(e.to_string()))?; for tx in transfer_txs_block { if let Some(mut from) = self.plasma_state.balance_tree.items.get(&tx.from).cloned() { let mut transacted_amount = BigDecimal::zero(); - // println!("amount tx: {:?}", &tx.amount); + // debug!("amount tx: {:?}", &tx.amount); transacted_amount += &tx.amount; transacted_amount += &tx.fee; @@ -176,17 +176,17 @@ impl FranklinAccountsStates { transaction: &FranklinTransaction, ) -> Result, DataRestoreError> { let mut tx_data_vec = transaction.commitment_data.clone(); - // println!("tx_data_vec: {:?}", tx_data_vec); + // debug!("tx_data_vec: {:?}", tx_data_vec); // let block_number = &transaction.commitment_data.clone()[0..32]; - // println!("block_number: {:?}", block_number); + // debug!("block_number: {:?}", block_number); let tx_data_len = tx_data_vec.len(); - // println!("tx_data_len: {:?}", tx_data_len); + // debug!("tx_data_len: {:?}", tx_data_len); tx_data_vec.reverse(); tx_data_vec.truncate(tx_data_len - 160); tx_data_vec.reverse(); - // println!("tx_data_vec final: {:?}", tx_data_vec); + // debug!("tx_data_vec final: {:?}", tx_data_vec); // tx_data_len = tx_data_vec.len(); - // println!("tx_data_len final: {:?}", tx_data_len); + // debug!("tx_data_len final: {:?}", tx_data_len); let txs = tx_data_vec.chunks(9); let mut transfers: Vec = vec![]; @@ -222,7 +222,7 @@ impl FranklinAccountsStates { signature: TxSignature::default(), cached_pub_key: None, }; - println!( + info!( "Transaction from account {:?} to account {:?}, amount = {:?}", from, to, amount ); @@ -364,7 +364,7 @@ impl FranklinAccountsStates { let mut all_deposits = vec![]; for (k, v) in this_batch.iter() { - println!( + info!( "Into account {:?} with public key {:x}, deposit amount = {:?}", k, v.1, v.0 ); @@ -478,7 +478,7 @@ impl FranklinAccountsStates { let mut all_exits = vec![]; for k in this_batch.iter() { - println!("Exit from account {:?}", k); + info!("Exit from account {:?}", k); let tx: ExitTx = ExitTx { account: k.as_u32(), diff --git a/core/data_restore/src/block_events/mod.rs b/core/data_restore/src/block_events/mod.rs index 5774d8c431..a96e8f5f4d 100644 --- a/core/data_restore/src/block_events/mod.rs +++ b/core/data_restore/src/block_events/mod.rs @@ -156,17 +156,17 @@ impl BlockEventsFranklin { block.block_type = BlockType::Verified; verified_blocks.push(block); // let result = self.check_committed_block_with_same_number_as_verified(&block); - // println!("Block exists: {:?}", result); + // debug!("Block exists: {:?}", result); // let tx = result.unwrap().clone().transaction_hash; - // println!("--- Starting getting tx"); + // debug!("--- Starting getting tx"); // let data = FranklinTransaction::get_transaction(InfuraEndpoint::Rinkeby, &tx); - // println!("TX data committed: {:?}", data); + // debug!("TX data committed: {:?}", data); } else if topic == block_committed_topic_h256 { block.block_type = BlockType::Committed; committed_blocks.push(block); } } - None => println!("No tx hash"), + None => warn!("No tx hash"), }; } committed_blocks.sort_by_key(|x| x.block_num); @@ -295,42 +295,42 @@ impl BlockEventsFranklin { // )); // // Subscription - // println!("subscribing to new blocks"); + // debug!("subscribing to new blocks"); // let future = web3_endpoint.eth_subscribe() // .subscribe_new_heads() // .and_then(|sub| { // sub.for_each(|log| { - // println!("---"); - // println!("Got block number {:?}", log.number); + // debug!("---"); + // debug!("Got block number {:?}", log.number); // let number_to_watch = self.last_watched_block_number + 1; // self.last_watched_block_number = number_to_watch; - // println!("Block to watch {:?}", &number_to_watch); + // debug!("Block to watch {:?}", &number_to_watch); // match self.get_sorted_logs_in_block(number_to_watch) { // Ok(mut result) => { - // println!("Old committed blocks array len: {:?}", &self.committed_blocks.len()); - // println!("Old verified blocks array len: {:?}", &self.verified_blocks.len()); - // println!("Got sorted logs"); - // println!("Committed: {:?}", &result.0); - // println!("Verified: {:?}", &result.1); + // debug!("Old committed blocks array len: {:?}", &self.committed_blocks.len()); + // debug!("Old verified blocks array len: {:?}", &self.verified_blocks.len()); + // debug!("Got sorted logs"); + // debug!("Committed: {:?}", &result.0); + // debug!("Verified: {:?}", &result.1); // self.committed_blocks.append(&mut result.0); // self.verified_blocks.append(&mut result.1); - // println!("New committed blocks array len: {:?}", &self.committed_blocks.len()); - // println!("New verified blocks array len: {:?}", &self.verified_blocks.len()); + // debug!("New committed blocks array len: {:?}", &self.committed_blocks.len()); + // debug!("New verified blocks array len: {:?}", &self.verified_blocks.len()); // }, // Err(_) => { - // println!("No new blocks"); + // debug!("No new blocks"); // } // }; // Ok(()) // }) // }) - // .map_err(|e| eprintln!("franklin log err: {}", e)); + // .map_err(|e| error!("franklin log err: {}", e)); // // Run eloop // if let Err(_err) = eloop.run(future) { - // eprintln!("Cant run eloop"); + // error!("Cant run eloop"); // } // } @@ -353,7 +353,7 @@ impl BlockEventsFranklin { // )); // // Subscription - // println!("subscribing to franklin logs {:?} {:?}...", block_verified_topic, block_committed_topic); + // debug!("subscribing to franklin logs {:?} {:?}...", block_verified_topic, block_committed_topic); // let filter = FilterBuilder::default() // .address(vec![self.franklin_contract_address.clone()]) @@ -369,29 +369,29 @@ impl BlockEventsFranklin { // .subscribe_logs(filter) // .and_then(|sub| { // sub.for_each(|log| { - // println!("---"); - // println!("got log from subscription: {:?}", log); + // debug!("---"); + // debug!("got log from subscription: {:?}", log); // let mut sorted_blocks = self.sort_logs(&vec![log]).unwrap(); // self.committed_blocks.append(&mut sorted_blocks.0); // self.verified_blocks.append(&mut sorted_blocks.1); // // let result = self.check_committed_block_with_same_number_as_verified(&block); - // // println!("Block exists: {:?}", result); + // // debug!("Block exists: {:?}", result); // // let tx = result.unwrap().clone().transaction_hash; - // // println!("--- Starting getting tx"); + // // debug!("--- Starting getting tx"); // // let data = FranklinTransaction::get_transaction(InfuraEndpoint::Rinkeby, &tx); - // // println!("TX data committed: {:?}", data); + // // debug!("TX data committed: {:?}", data); - // println!("Verified blocks in storage: {:?}", self.verified_blocks); - // println!("Committed blocks in storage: {:?}", self.committed_blocks); + // debug!("Verified blocks in storage: {:?}", self.verified_blocks); + // debug!("Committed blocks in storage: {:?}", self.committed_blocks); // Ok(()) // }) // }) - // .map_err(|e| eprintln!("franklin log err: {}", e)); + // .map_err(|e| error!("franklin log err: {}", e)); // // Run eloop // if let Err(_err) = eloop.run(future) { - // eprintln!("ERROR"); + // error!("ERROR"); // } // } } diff --git a/core/data_restore/src/data_restore_driver.rs b/core/data_restore/src/data_restore_driver.rs index e1eec4fd0b..a2d687dd14 100644 --- a/core/data_restore/src/data_restore_driver.rs +++ b/core/data_restore/src/data_restore_driver.rs @@ -42,7 +42,7 @@ impl DataRestoreDriver { } pub fn load_past_state(&mut self) -> Result<(), DataRestoreError> { - println!("Loading past state"); + info!("Loading past state"); let states = DataRestoreDriver::get_past_franklin_blocks_events_and_accounts_tree_state( self.config.clone(), self.genesis_block, @@ -53,10 +53,10 @@ impl DataRestoreDriver { self.account_states = states.1; // let accs = &self.account_states.get_accounts(); - // println!("Accs: {:?}", accs); + // debug!("Accs: {:?}", accs); let root = self.account_states.root_hash(); - println!("Root: {:?}", &root); - println!("______________"); + debug!("Root: {:?}", &root); + debug!("______________"); if let Some(ref _channel) = self.channel { let state = ProtoAccountsState { @@ -70,7 +70,7 @@ impl DataRestoreDriver { )); } } - println!("Finished loading past state"); + debug!("Finished loading past state"); Ok(()) } @@ -79,13 +79,13 @@ impl DataRestoreDriver { } pub fn run_state_updates(&mut self) -> Option { - println!("Start state updates"); + info!("Start state updates"); self.run_updates = true; let mut err: Option = None; while self.run_updates { // match DataRestoreDriver::update_franklin_blocks_events_and_accounts_tree_state(self) { // Err(error) => { - // println!("Something goes wrong: {:?}", error); + // error!("Something goes wrong: {:?}", error); // self.run_updates = false; // err = Some(DataRestoreError::StateUpdate(format!( // "Error occured: {:?}", @@ -93,21 +93,21 @@ impl DataRestoreDriver { // ))); // } // Ok(()) => { - // // println!("Updated, last watched ethereum block: {:?}", &self.block_events.last_watched_block_number); - // // println!("Committed franklin blocks count: {:?}", &self.block_events.committed_blocks.len()); - // // println!("Last committed franklin block: {:?}", &self.block_events.committed_blocks.last()); - // // println!("Verified franklin blocks count: {:?}", &self.block_events.verified_blocks.len()); - // // println!("Last verified franklin block: {:?}", &self.block_events.verified_blocks.last()); + // // debug!("Updated, last watched ethereum block: {:?}", &self.block_events.last_watched_block_number); + // // debug!("Committed franklin blocks count: {:?}", &self.block_events.committed_blocks.len()); + // // debug!("Last committed franklin block: {:?}", &self.block_events.committed_blocks.last()); + // // debug!("Verified franklin blocks count: {:?}", &self.block_events.verified_blocks.len()); + // // debug!("Last verified franklin block: {:?}", &self.block_events.verified_blocks.last()); // // let accs = self.account_states.get_accounts(); // // let root = self.account_states.root_hash(); - // // println!("Accs: {:?}", accs); - // // println!("Root: {:?}", &root); + // // debug!("Accs: {:?}", accs); + // // debug!("Root: {:?}", &root); // } // }; if let Err(error) = DataRestoreDriver::update_franklin_blocks_events_and_accounts_tree_state(self) { - println!("Something goes wrong: {:?}", error); + error!("Something goes wrong: {:?}", error); self.run_updates = false; err = Some(DataRestoreError::StateUpdate(format!( "Error occured: {:?}", @@ -115,8 +115,8 @@ impl DataRestoreDriver { ))); } let root = self.account_states.root_hash(); - println!("New root: {:?}", root); - println!("______________"); + debug!("New root: {:?}", root); + debug!("______________"); if let Some(ref _channel) = self.channel { let state = ProtoAccountsState { errored: !self.run_updates, @@ -131,7 +131,7 @@ impl DataRestoreDriver { } } } - println!("Stopped state updates"); + debug!("Stopped state updates"); err } @@ -143,14 +143,14 @@ impl DataRestoreDriver { let events_state = DataRestoreDriver::get_past_blocks_state(config.clone(), genesis_block, blocks_delta) .map_err(|e| DataRestoreError::NoData(e.to_string()))?; - // println!("Last watched block: {:?}", events_state.last_watched_block_number); + // debug!("Last watched block: {:?}", events_state.last_watched_block_number); let verified_blocks = events_state.verified_blocks.clone(); let txs = DataRestoreDriver::get_verified_committed_blocks_transactions_from_blocks_state( &events_state, &verified_blocks, ); let sorted_txs = DataRestoreDriver::sort_transactions_by_block_number(txs); - // println!("Transactions: {:?}", sorted_txs); + // debug!("Transactions: {:?}", sorted_txs); let mut accounts_state = FranklinAccountsStates::new(config.clone()); DataRestoreDriver::update_accounts_state_from_transactions( @@ -158,7 +158,7 @@ impl DataRestoreDriver { &sorted_txs, ) .map_err(|e| DataRestoreError::StateUpdate(e.to_string()))?; - println!("Accounts and events state finished update"); + info!("Accounts and events state finished update"); Ok((events_state, accounts_state)) } @@ -173,23 +173,23 @@ impl DataRestoreDriver { blocks_delta, ) .map_err(|e| DataRestoreError::NoData(e.to_string()))?; - println!( + debug!( "Got past events state till ethereum block: {:?}", &events.last_watched_block_number ); - println!( + debug!( "Committed franklin blocks count: {:?}", &events.committed_blocks.len() ); - println!( + debug!( "Last committed franklin block: {:?}", &events.committed_blocks.last() ); - println!( + debug!( "Verified franklin blocks count: {:?}", &events.verified_blocks.len() ); - println!( + debug!( "Last verified franklin block: {:?}", &events.verified_blocks.last() ); @@ -202,7 +202,7 @@ impl DataRestoreDriver { ) -> Vec { let committed_blocks = block_events_state.get_only_verified_committed_blocks(verified_blocks); - // println!("Committed verified blocks: {:?}", committed_blocks); + // debug!("Committed verified blocks: {:?}", committed_blocks); let mut transactions = vec![]; for block in committed_blocks { let tx = FranklinTransaction::get_transaction(&block_events_state.config, &block); @@ -211,7 +211,7 @@ impl DataRestoreDriver { } transactions.push(tx.unwrap()); } - println!("Transactions sorted: only verified commited"); + debug!("Transactions sorted: only verified commited"); transactions } @@ -220,7 +220,7 @@ impl DataRestoreDriver { ) -> Vec { let mut sorted_transactions = transactions; sorted_transactions.sort_by_key(|x| x.block_number); - println!("Transactions sorted: by number"); + debug!("Transactions sorted: by number"); sorted_transactions } @@ -229,13 +229,13 @@ impl DataRestoreDriver { transactions: &[FranklinTransaction], ) -> Result<(), DataRestoreError> { // let mut state = accounts_state::FranklinAccountsStates::new(config); - println!("Start accounts state updating"); + debug!("Start accounts state updating"); for transaction in transactions { state .update_accounts_states_from_transaction(&transaction) .map_err(|e| DataRestoreError::StateUpdate(e.to_string()))?; } - println!("Finished accounts state updating"); + debug!("Finished accounts state updating"); Ok(()) } @@ -252,32 +252,32 @@ impl DataRestoreDriver { match ne { Ok(result) => new_events = result, Err(error) => { - println!("Got no events: {:?}", error); + debug!("Got no events: {:?}", error); continue; } } if new_events.1.is_empty() { - println!("No new verified blocks"); + debug!("No new verified blocks"); continue; // return Err(DataRestoreError::NoData("No verified blocks".to_string())) } else { - println!( + debug!( "Got new events state till ethereum block: {:?}", &data_restore_driver.block_events.last_watched_block_number ); - println!( + debug!( "Committed franklin blocks count: {:?}", &data_restore_driver.block_events.committed_blocks.len() ); - println!( + debug!( "Last committed franklin block: {:?}", &data_restore_driver.block_events.committed_blocks.last() ); - println!( + debug!( "Verified franklin blocks count: {:?}", &data_restore_driver.block_events.verified_blocks.len() ); - println!( + debug!( "Last verified franklin block: {:?}", &data_restore_driver.block_events.verified_blocks.last() ); diff --git a/core/data_restore/src/lib.rs b/core/data_restore/src/lib.rs index 3f8036c094..972015ebde 100644 --- a/core/data_restore/src/lib.rs +++ b/core/data_restore/src/lib.rs @@ -1,3 +1,6 @@ +#[macro_use] +extern crate log; + pub mod accounts_state; pub mod block_events; pub mod blocks; diff --git a/core/eth_client/Cargo.toml b/core/eth_client/Cargo.toml index 179051c160..65ad70acc4 100644 --- a/core/eth_client/Cargo.toml +++ b/core/eth_client/Cargo.toml @@ -16,3 +16,4 @@ reqwest = "0.9.5" rlp = "0.3.0" tiny-keccak = "1.4.2" secp256k1 = "0.11.1" +log = "0.4" diff --git a/core/eth_client/src/lib.rs b/core/eth_client/src/lib.rs index 080a31cb13..43e109cd0f 100644 --- a/core/eth_client/src/lib.rs +++ b/core/eth_client/src/lib.rs @@ -1,5 +1,7 @@ #[macro_use] extern crate serde_derive; +#[macro_use] +extern crate log; use ethereum_types::{H160, H256, U256}; use hex; @@ -92,7 +94,7 @@ impl ETHClient { if gas_price < min_gas_price { gas_price = min_gas_price; } - println!( + info!( "Sending tx: gas price = {}, min = {}, factored = {}, nonce = {}", orig_gas_price, min_gas_price, gas_price, meta.nonce ); @@ -226,18 +228,18 @@ fn test_eth() { // let proof: [U256; 8] = [U256::zero(); 8]; - // println!("committing block..."); + // debug!("committing block..."); // let r = client.commit_block(block_num, total_fees, tx_data_packed, new_root); // match r { - // Err(e) => println!("{:#?}", e), - // Ok(hash) => println!("https://rinkeby.etherscan.io/tx/{:?}", hash), + // Err(e) => debug!("{:#?}", e), + // Ok(hash) => debug!("https://rinkeby.etherscan.io/tx/{:?}", hash), // }; - // println!("verifying block..."); + // debug!("verifying block..."); // let r = client.verify_block(block_num, proof); // match r { - // Err(e) => println!("{:#?}", e), - // Ok(hash) => println!("https://rinkeby.etherscan.io/tx/{:?}", hash), + // Err(e) => debug!("{:#?}", e), + // Ok(hash) => debug!("https://rinkeby.etherscan.io/tx/{:?}", hash), // }; } @@ -251,7 +253,7 @@ fn test_encoding() { .expect("failed to get function"); let inputs = &f.inputs; for i in inputs { - println!("{} = {}", i.name, i.kind); + debug!("{} = {}", i.name, i.kind); } let params = (U256::from(0), [0u64; 1], 1u64, H256::zero()); let _data = f diff --git a/core/eth_client/src/signer.rs b/core/eth_client/src/signer.rs index 59f927283e..d4422b017a 100644 --- a/core/eth_client/src/signer.rs +++ b/core/eth_client/src/signer.rs @@ -100,7 +100,7 @@ fn ecdsa_sign(hash: &[u8], private_key: &[u8], chain_id: u8) -> EcdsaSig { let key = SecretKey::from_slice(&s, private_key).unwrap(); let (v, sig_bytes) = s.sign_recoverable(&msg, &key).serialize_compact(&s); - //println!("V m8 {:?}", v); + //debug!("V m8 {:?}", v); EcdsaSig { v: vec![v.to_i32() as u8 + chain_id * 2 + 35], diff --git a/core/key_generator/Cargo.toml b/core/key_generator/Cargo.toml index 4ce3dcf5cc..7637dea707 100644 --- a/core/key_generator/Cargo.toml +++ b/core/key_generator/Cargo.toml @@ -19,3 +19,5 @@ models = { path = "../models" } hex = "0.3.2" rust-crypto = "0.2" ff = { package = "ff_ce", version = "0.6.0", features = ["derive"] } +log = "0.4" +env_logger = "0.6" diff --git a/core/key_generator/src/depositor_key.rs b/core/key_generator/src/depositor_key.rs index a16201a562..3dd462ead7 100644 --- a/core/key_generator/src/depositor_key.rs +++ b/core/key_generator/src/depositor_key.rs @@ -58,10 +58,10 @@ pub fn make_depositor_key() { requests: vec![(empty_request, empty_witness); DEPOSIT_BATCH_SIZE], }; - println!("generating setup..."); + info!("generating setup..."); let start = PreciseTime::now(); let tmp_cirtuit_params = generate_random_parameters(instance_for_generation, rng).unwrap(); - println!( + info!( "setup generated in {} s", start.to(PreciseTime::now()).num_milliseconds() as f64 / 1000.0 ); @@ -95,5 +95,5 @@ pub fn make_depositor_key() { .write_all(contract_content.as_bytes()) .expect("Unable to write contract"); - println!("Done"); + info!("Done"); } diff --git a/core/key_generator/src/exitor_key.rs b/core/key_generator/src/exitor_key.rs index ee20f6f5c4..54869f2eaf 100644 --- a/core/key_generator/src/exitor_key.rs +++ b/core/key_generator/src/exitor_key.rs @@ -55,10 +55,10 @@ pub fn make_exitor_key() { requests: vec![(empty_request, empty_witness); EXIT_BATCH_SIZE], }; - println!("generating setup..."); + info!("generating setup..."); let start = PreciseTime::now(); let tmp_cirtuit_params = generate_random_parameters(instance_for_generation, rng).unwrap(); - println!( + info!( "setup generated in {} s", start.to(PreciseTime::now()).num_milliseconds() as f64 / 1000.0 ); @@ -92,5 +92,5 @@ pub fn make_exitor_key() { .write_all(contract_content.as_bytes()) .expect("Unable to write contract"); - println!("Done"); + info!("Done"); } diff --git a/core/key_generator/src/main.rs b/core/key_generator/src/main.rs index 86816db46b..42ffeb3271 100644 --- a/core/key_generator/src/main.rs +++ b/core/key_generator/src/main.rs @@ -1,3 +1,6 @@ +#[macro_use] +extern crate log; + pub mod depositor_key; pub mod exitor_key; pub mod read_write_keys; @@ -9,6 +12,8 @@ use exitor_key::make_exitor_key; use transactor_key::make_transactor_key; fn main() { + env_logger::init(); + make_depositor_key(); make_exitor_key(); make_transactor_key(); diff --git a/core/key_generator/src/read_write_keys.rs b/core/key_generator/src/read_write_keys.rs index d84e98a8f3..074ef9e6b3 100644 --- a/core/key_generator/src/read_write_keys.rs +++ b/core/key_generator/src/read_write_keys.rs @@ -32,6 +32,7 @@ use models::plasma::params as plasma_constants; const TXES_TO_TEST: usize = 128; +#[allow(clippy::cognitive_complexity)] pub fn read_write_keys() { let p_g = FixedGenerators::SpendingKeyGenerator; let params = &AltJubjubBn256::new(); @@ -79,7 +80,7 @@ pub fn read_write_keys() { let num_accounts = existing_accounts.len(); - println!("Inserted {} accounts", num_accounts); + debug!("Inserted {} accounts", num_accounts); let initial_root = tree.root_hash(); @@ -145,7 +146,7 @@ pub fn read_write_keys() { .map(|e| Some(e.0)) .collect(); - // println!("Making a transfer from {} to {}", sender_leaf_number, recipient_leaf_number); + // debug!("Making a transfer from {} to {}", sender_leaf_number, recipient_leaf_number); let from = Fr::from_str(&sender_leaf_number.to_string()); let to = Fr::from_str(&recipient_leaf_number.to_string()); @@ -169,8 +170,8 @@ pub fn read_write_keys() { //assert!(tree.verify_proof(sender_leaf_number, sender_leaf.clone(), tree.merkle_path(sender_leaf_number))); //assert!(tree.verify_proof(recipient_leaf_number, recipient_leaf.clone(), tree.merkle_path(recipient_leaf_number))); - // println!("Sender: balance: {}, nonce: {}, pub_x: {}, pub_y: {}", sender_leaf.balance, sender_leaf.nonce, sender_leaf.pub_x, sender_leaf.pub_y); - // println!("Recipient: balance: {}, nonce: {}, pub_x: {}, pub_y: {}", recipient_leaf.balance, recipient_leaf.nonce, recipient_leaf.pub_x, recipient_leaf.pub_y); + // debug!("Sender: balance: {}, nonce: {}, pub_x: {}, pub_y: {}", sender_leaf.balance, sender_leaf.nonce, sender_leaf.pub_x, sender_leaf.pub_y); + // debug!("Recipient: balance: {}, nonce: {}, pub_x: {}, pub_y: {}", recipient_leaf.balance, recipient_leaf.nonce, recipient_leaf.pub_x, recipient_leaf.pub_y); let mut updated_sender_leaf = sender_leaf.clone(); let mut updated_recipient_leaf = recipient_leaf.clone(); @@ -190,8 +191,8 @@ pub fn read_write_keys() { total_fees.add_assign(&fee_as_field_element); - // println!("Updated sender: balance: {}, nonce: {}, pub_x: {}, pub_y: {}", updated_sender_leaf.balance, updated_sender_leaf.nonce, updated_sender_leaf.pub_x, updated_sender_leaf.pub_y); - // println!("Updated recipient: balance: {}, nonce: {}, pub_x: {}, pub_y: {}", updated_recipient_leaf.balance, updated_recipient_leaf.nonce, updated_recipient_leaf.pub_x, updated_recipient_leaf.pub_y); + // debug!("Updated sender: balance: {}, nonce: {}, pub_x: {}, pub_y: {}", updated_sender_leaf.balance, updated_sender_leaf.nonce, updated_sender_leaf.pub_x, updated_sender_leaf.pub_y); + // debug!("Updated recipient: balance: {}, nonce: {}, pub_x: {}, pub_y: {}", updated_recipient_leaf.balance, updated_recipient_leaf.nonce, updated_recipient_leaf.pub_x, updated_recipient_leaf.pub_y); tree.insert(sender_leaf_number, updated_sender_leaf.clone()); tree.insert(recipient_leaf_number, updated_recipient_leaf.clone()); @@ -230,7 +231,7 @@ pub fn read_write_keys() { let block_number = Fr::one(); - println!("Block number = {}", block_number.into_repr()); + debug!("Block number = {}", block_number.into_repr()); let final_root = tree.root_hash(); @@ -239,7 +240,7 @@ pub fn read_write_keys() { CircuitAccountTree::new(tree_depth).root_hash().into_repr() ); - println!("Final root = {}", final_root_string); + debug!("Final root = {}", final_root_string); let mut public_data_initial_bits = vec![]; @@ -275,7 +276,7 @@ pub fn read_write_keys() { next_round_hash_bytes.extend(hash_result.iter()); next_round_hash_bytes.extend(packed_transaction_data_bytes.clone()); - println!("Public data = {}", encode(packed_transaction_data_bytes)); + debug!("Public data = {}", encode(packed_transaction_data_bytes)); let mut h = Sha256::new(); @@ -295,9 +296,9 @@ pub fn read_write_keys() { let public_data_commitment = Fr::from_repr(repr).unwrap(); - println!("Total fees = {}", total_fees.into_repr()); + debug!("Total fees = {}", total_fees.into_repr()); - println!( + debug!( "Final data commitment as field element = {}", public_data_commitment ); @@ -318,8 +319,8 @@ pub fn read_write_keys() { instance_for_test_cs.synthesize(&mut cs).unwrap(); - println!("Total of {} constraints", cs.num_constraints()); - println!( + debug!("Total of {} constraints", cs.num_constraints()); + debug!( "{} constraints per TX for {} transactions", cs.num_constraints() / TXES_TO_TEST, TXES_TO_TEST @@ -342,7 +343,7 @@ pub fn read_write_keys() { if err.is_some() { panic!("ERROR satisfying in {}\n", err.unwrap()); } else { - println!("Test constraint system is satisfied"); + debug!("Test constraint system is satisfied"); } } @@ -381,10 +382,10 @@ pub fn read_write_keys() { transactions: vec![(empty_transaction, empty_witness); TXES_TO_TEST], }; - println!("generating setup..."); + debug!("generating setup..."); let start = PreciseTime::now(); let tmp_cirtuit_params = generate_random_parameters(instance_for_generation, rng).unwrap(); - println!( + debug!( "setup generated in {} s", start.to(PreciseTime::now()).num_milliseconds() as f64 / 1000.0 ); @@ -432,10 +433,10 @@ pub fn read_write_keys() { transactions: witnesses, }; - println!("creating proof..."); + debug!("creating proof..."); let start = PreciseTime::now(); let proof = create_random_proof(instance_for_proof, &circuit_params, rng).unwrap(); - println!( + debug!( "proof created in {} s", start.to(PreciseTime::now()).num_milliseconds() as f64 / 1000.0 ); diff --git a/core/key_generator/src/transactor_key.rs b/core/key_generator/src/transactor_key.rs index 285039e7b3..ab8d967866 100644 --- a/core/key_generator/src/transactor_key.rs +++ b/core/key_generator/src/transactor_key.rs @@ -62,10 +62,10 @@ pub fn make_transactor_key() { transactions: vec![(empty_transaction, empty_witness); TRANSFER_BATCH_SIZE], }; - println!("generating setup..."); + info!("generating setup..."); let start = PreciseTime::now(); let tmp_cirtuit_params = generate_random_parameters(instance_for_generation, rng).unwrap(); - println!( + info!( "setup generated in {} s", start.to(PreciseTime::now()).num_milliseconds() as f64 / 1000.0 ); @@ -99,5 +99,5 @@ pub fn make_transactor_key() { .write_all(contract_content.as_bytes()) .expect("Unable to write contract"); - println!("Done"); + info!("Done"); } diff --git a/core/merkle_tree/Cargo.toml b/core/merkle_tree/Cargo.toml index 5fbb507f10..76dbae1edf 100644 --- a/core/merkle_tree/Cargo.toml +++ b/core/merkle_tree/Cargo.toml @@ -17,3 +17,6 @@ fnv = "1.0.3" rayon = "1.0.3" rand = "0.4" +[dev-dependencies] +log = "0.4" + diff --git a/core/merkle_tree/src/parallel_smt.rs b/core/merkle_tree/src/parallel_smt.rs index b21165d39c..30f958e1fc 100644 --- a/core/merkle_tree/src/parallel_smt.rs +++ b/core/merkle_tree/src/parallel_smt.rs @@ -322,8 +322,8 @@ where pub fn print_stats() { // unsafe { - // println!("leaf hashes: {}", HN); - // println!("tree hashes: {}", HC); + // debug!("leaf hashes: {}", HN); + // debug!("tree hashes: {}", HC); // } } @@ -333,28 +333,28 @@ where // // let r = thread::scope(|scope| { // scope.spawn(move |_| { - // println!("Hello! {:?}", self.root_hash()); + // debug!("Hello! {:?}", self.root_hash()); // std::thread::sleep(Duration::from_millis(1400)); - // println!("done"); + // debug!("done"); // 3 + 5 // }); // }).unwrap(); - // println!("r {:?}", r); + // debug!("r {:?}", r); - // println!("testing cpu"); + // debug!("testing cpu"); // crossbeam_utils::thread::scope(|scope| { // scope.spawn(move || { - // println!("begin"); + // debug!("begin"); // }) // }); // Box::new(self.pool.spawn(future::lazy(move || { - // println!("begin"); + // debug!("begin"); // let r = self.root_hash(); - // println!("end: {:?}", r); + // debug!("end: {:?}", r); // future::ok::<(), ()>(()) // })))/*.then(|result| { - // println!("result {:?}", result); + // debug!("result {:?}", result); // future::ok::<(), ()>(()) // }));*/ //f.wait(); @@ -370,6 +370,8 @@ static mut HC: usize = 0; mod tests { use super::*; + use log::debug; + #[derive(Debug)] struct TestHasher {} @@ -415,7 +417,7 @@ mod tests { fn compress(&self, lhs: &u64, rhs: &u64, i: usize) -> u64 { (11 * lhs + 17 * rhs + 1 + i as u64) % 1_234_567_891 - //println!("compress {} {}, {} => {}", lhs, rhs, i, r); + //debug!("compress {} {}, {} => {}", lhs, rhs, i, r); } } @@ -439,7 +441,7 @@ mod tests { // tree.root_hash(); // } // tree.insert(usize::rand(rng) % capacity, TestLeaf(2)); - // //println!("{:?}\n", tree); + // //debug!("{:?}\n", tree); let mut n = 1000; for _i in 0..3 { @@ -455,7 +457,7 @@ mod tests { } tree.root_hash(); unsafe { - println!("{}: HN = {}, HC = {}\n", n, HN, HC); + debug!("{}: HN = {}, HC = {}\n", n, HN, HC); } n *= 10; } @@ -479,12 +481,12 @@ mod tests { tree.make_a_future(); // tree.insert(0, TestLeaf(1)); - // println!("{}", tree.root_hash()); - // println!("{:?}", tree.prehashed); - // println!("{:?}", tree.nodes); + // debug!("{}", tree.root_hash()); + // debug!("{:?}", tree.prehashed); + // debug!("{:?}", tree.nodes); // // tree.insert(0, TestLeaf(2)); - // println!("{}", tree.root_hash()); - // println!("{:?}", tree.nodes); + // debug!("{}", tree.root_hash()); + // debug!("{:?}", tree.nodes); } } diff --git a/core/merkle_tree/src/pedersen_hasher.rs b/core/merkle_tree/src/pedersen_hasher.rs index 2de8ef1e7d..e3787bceaf 100644 --- a/core/merkle_tree/src/pedersen_hasher.rs +++ b/core/merkle_tree/src/pedersen_hasher.rs @@ -46,13 +46,13 @@ fn test_pedersen_hash() { let hasher = BabyPedersenHasher::default(); let hash = hasher.hash_bits(vec![false, false, false, true, true, true, true, true]); - //println!("hash: {:?}", &hash); + //debug!("hash: {:?}", &hash); hasher.compress(&hash, &hash, 0); - //println!("compr: {:?}", &hash2); + //debug!("compr: {:?}", &hash2); hasher.compress(&hash, &hash, 1); - //println!("compr: {:?}", &hash3); + //debug!("compr: {:?}", &hash3); //assert_eq!(hasher.empty_hash(), } diff --git a/core/merkle_tree/src/sequential_smt.rs b/core/merkle_tree/src/sequential_smt.rs index 6e7fcad5cb..4f23336ba4 100644 --- a/core/merkle_tree/src/sequential_smt.rs +++ b/core/merkle_tree/src/sequential_smt.rs @@ -150,7 +150,7 @@ where let rhs_hash = self.get_hash(rhs_index); //let idx = (1 << index.0) + index.1; - //println!("({:?}, {:?}, {})", &lhs_hash, &rhs_hash, (self.tree_depth - 1 - index.0)); + //debug!("({:?}, {:?}, {})", &lhs_hash, &rhs_hash, (self.tree_depth - 1 - index.0)); let hash = self.hasher.compress( &lhs_hash, @@ -158,7 +158,7 @@ where (self.tree_depth - 1 - index.0) as usize, ); - //println!("hash [{}] = {:?}", (1 << index.0) + index.1, hash); + //debug!("hash [{}] = {:?}", (1 << index.0) + index.1, hash); self.hashes.insert(index.pack(), hash.clone()); hash @@ -231,6 +231,8 @@ where mod tests { use super::*; + use log::debug; + #[derive(Debug)] struct TestHasher {} @@ -255,7 +257,7 @@ mod tests { fn compress(&self, lhs: &u64, rhs: &u64, i: usize) -> u64 { 11 * lhs + 17 * rhs + 1 + i as u64 - //println!("compress {} {}, {} => {}", lhs, rhs, i, r); + //debug!("compress {} {}, {} => {}", lhs, rhs, i, r); } } @@ -277,15 +279,15 @@ mod tests { assert_eq!(tree.capacity(), 8); tree.insert(0, 1); - println!("{:?}", tree); + debug!("{:?}", tree); assert_eq!(tree.root_hash(), 697_516_875); tree.insert(0, 2); - println!("{:?}", tree); + debug!("{:?}", tree); assert_eq!(tree.root_hash(), 741_131_083); tree.insert(3, 2); - //println!("{:?}", tree); + //debug!("{:?}", tree); assert_eq!(tree.root_hash(), 793_215_819); } @@ -294,7 +296,7 @@ mod tests { let mut tree = TestSMT::new(3); tree.insert(2, 1); let path = tree.merkle_path(2); - //println!("{:?}", tree); + //debug!("{:?}", tree); assert_eq!(path, [(32768, false), (917_505, true), (25_690_142, false)]); } } diff --git a/core/models/Cargo.toml b/core/models/Cargo.toml index bcd1974a0c..5c97e771a9 100644 --- a/core/models/Cargo.toml +++ b/core/models/Cargo.toml @@ -16,3 +16,4 @@ serde_bytes = "0.11.1" lazy_static = "1.2.0" rand = "0.4" fnv = "1.0.3" +log = "0.4" diff --git a/core/models/src/lib.rs b/core/models/src/lib.rs index 69395f27f3..d4bd4a5432 100644 --- a/core/models/src/lib.rs +++ b/core/models/src/lib.rs @@ -2,6 +2,8 @@ extern crate serde_derive; #[macro_use] extern crate lazy_static; +#[macro_use] +extern crate log; pub mod abi; pub mod config; diff --git a/core/models/src/plasma/tx.rs b/core/models/src/plasma/tx.rs index 74d25629a6..151c6a6075 100644 --- a/core/models/src/plasma/tx.rs +++ b/core/models/src/plasma/tx.rs @@ -190,15 +190,15 @@ impl TransferTx { pub fn verify_sig(&self, public_key: &PublicKey) -> bool { let message_bits = self.message_bits(); if message_bits.len() % 8 != 0 { - println!("Invalid message length"); + error!("Invalid message length"); return false; } let as_bytes = pack_bits_into_bytes(message_bits); //use rustc_hex::ToHex; //let hex: String = as_bytes.clone().to_hex(); - //println!("Transaction bytes = {}", hex); + //debug!("Transaction bytes = {}", hex); if let Ok(signature) = self.signature.to_jubjub_eddsa() { - //println!("Successfuly converted to eddsa signature"); + //debug!("Successfuly converted to eddsa signature"); let p_g = FixedGenerators::SpendingKeyGenerator; let valid = public_key.verify_for_raw_message( &as_bytes, @@ -210,7 +210,7 @@ impl TransferTx { return valid; } - //println!("Signature was not deserialized"); + //debug!("Signature was not deserialized"); false } diff --git a/core/plasma/Cargo.toml b/core/plasma/Cargo.toml index 638b4f5312..672542242f 100644 --- a/core/plasma/Cargo.toml +++ b/core/plasma/Cargo.toml @@ -12,4 +12,5 @@ authors = [ models = { path = "../models" } merkle_tree = { path = "../merkle_tree" } bigdecimal = { version = "0.1.0", features = ["serde"]} +log = "0.4" diff --git a/core/plasma/src/lib.rs b/core/plasma/src/lib.rs index 266c62acc7..6fb2ad2756 100644 --- a/core/plasma/src/lib.rs +++ b/core/plasma/src/lib.rs @@ -1 +1,4 @@ +#[macro_use] +extern crate log; + pub mod state; diff --git a/core/plasma/src/state.rs b/core/plasma/src/state.rs index c0b8e96457..7b729e58b3 100644 --- a/core/plasma/src/state.rs +++ b/core/plasma/src/state.rs @@ -74,20 +74,20 @@ impl PlasmaState { transacted_amount += &tx.fee; if tx.nonce > from.nonce { - //println!("Nonce is too high"); + //debug!("Nonce is too high"); return Err(TransferApplicationError::NonceIsTooHigh); } else if tx.nonce < from.nonce { - //println!("Nonce is too low"); + //debug!("Nonce is too low"); return Err(TransferApplicationError::NonceIsTooLow); } if from.balance < transacted_amount { - //println!("Insufficient balance"); + //debug!("Insufficient balance"); return Err(TransferApplicationError::InsufficientBalance); } if tx.good_until_block < self.block_number { - //println!("Transaction is outdated"); + //debug!("Transaction is outdated"); return Err(TransferApplicationError::ExpiredTransaction); } @@ -142,7 +142,7 @@ impl PlasmaState { let mut agumented_tx = tx.clone(); - println!("Adding account balance to ExitTx, value = {}", acc.balance); + debug!("Adding account balance to ExitTx, value = {}", acc.balance); agumented_tx.amount = acc.balance; diff --git a/core/prover/Cargo.toml b/core/prover/Cargo.toml index 361cb50465..feaa07b133 100644 --- a/core/prover/Cargo.toml +++ b/core/prover/Cargo.toml @@ -34,3 +34,5 @@ serde_json = "1.0.39" diesel = { version = "1.4.2", features = ["postgres", "serde_json", "r2d2", "chrono"] } bigdecimal = { version = "0.1.0", features = ["serde"]} chrono = { version = "0.4", features = ["serde", "rustc-serialize"] } +log = "0.4" +env_logger = "0.6" diff --git a/core/prover/src/lib.rs b/core/prover/src/lib.rs index 877c0cddab..db3ba1dd6d 100644 --- a/core/prover/src/lib.rs +++ b/core/prover/src/lib.rs @@ -1,3 +1,6 @@ +#[macro_use] +extern crate log; + use rand::OsRng; use std::fmt; use std::iter::Iterator; @@ -206,38 +209,38 @@ impl BabyProver { .expect("db must be functional"); let initial_state = PlasmaState::new(accounts, last_block + 1); - println!("Reading proving key, may take a while"); + info!("Reading proving key, may take a while"); let keys_path = &RUNTIME_CONFIG.keys_path; let path = format!("{}/transfer_pk.key", keys_path); - println!("Reading key from {}", path); + debug!("Reading key from {}", path); let transfer_circuit_params = read_parameters(&path); if transfer_circuit_params.is_err() { return Err(transfer_circuit_params.err().unwrap()); } - println!("Done reading transfer key"); + debug!("Done reading transfer key"); let path = format!("{}/deposit_pk.key", keys_path); - println!("Reading key from {}", path); + debug!("Reading key from {}", path); let deposit_circuit_params = read_parameters(&path); if deposit_circuit_params.is_err() { return Err(deposit_circuit_params.err().unwrap()); } - println!("Done reading deposit key"); + debug!("Done reading deposit key"); let path = format!("{}/exit_pk.key", keys_path); - println!("Reading key from {}", path); + debug!("Reading key from {}", path); let exit_circuit_params = read_parameters(&path); if exit_circuit_params.is_err() { return Err(exit_circuit_params.err().unwrap()); } - println!("Done reading exit key"); + debug!("Done reading exit key"); - println!("Copying states to balance tree"); + info!("Copying states to balance tree"); // TODO: replace with .clone() by moving PedersenHasher to static context let mut tree = CircuitAccountTree::new(params::BALANCE_TREE_DEPTH as u32); @@ -256,7 +259,7 @@ impl BabyProver { let state_block_number = initial_state.block_number; - println!( + info!( "Initial root hash is {} for block {}", root, state_block_number ); @@ -317,7 +320,7 @@ impl BabyProver { ) -> Result { let block_number = block.block_number; if block_number != self.current_block_number { - println!( + debug!( "Transfer proof request is for block {}, while prover state is block {}", block_number, self.current_block_number ); @@ -481,7 +484,7 @@ impl BabyProver { )); } - println!( + info!( "Prover final root = {}, final root from state keeper = {}", final_root, block_final_root ); @@ -517,7 +520,7 @@ impl BabyProver { let bytes_to_hash = be_bit_vector_into_bytes(&public_data_initial_bits); // let hex_block_and_fee: String = bytes_to_hash.clone().to_hex(); - // println!("Packed initial hash information = {}", hex_block_and_fee); + // debug!("Packed initial hash information = {}", hex_block_and_fee); h.input(&bytes_to_hash); @@ -528,9 +531,9 @@ impl BabyProver { let packed_transaction_data_bytes = public_data.clone(); // let hex: String = packed_transaction_data_bytes.clone().to_hex(); - // println!("Packed transfers information data = {}", hex); + // debug!("Packed transfers information data = {}", hex); - let mut next_round_hash_bytes = vec![]; + let mut next_round_hash_bytes = Vec::new(); next_round_hash_bytes.extend(hash_result.iter()); next_round_hash_bytes.extend(packed_transaction_data_bytes); @@ -589,11 +592,11 @@ impl BabyProver { // if err.is_some() { // panic!("ERROR satisfying in {}\n", err.unwrap()); // } - // println!("CS is satisfied!"); + // debug!("CS is satisfied!"); // } let mut rng = OsRng::new().unwrap(); - println!("Prover has started to work transfer"); + info!("Prover has started to work transfer"); let proof = create_random_proof(instance, &self.transfer_parameters, &mut rng); if proof.is_err() { return Err(BabyProverErr::Other("proof.is_err()".to_owned())); @@ -603,7 +606,7 @@ impl BabyProver { let pvk = prepare_verifying_key(&self.transfer_parameters.vk); - println!( + info!( "Made a proof for initial root = {}, final root = {}, public data = {}", initial_root, final_root, @@ -615,7 +618,7 @@ impl BabyProver { &[initial_root, final_root, public_data_commitment], ); if success.is_err() { - println!( + error!( "Proof is verification failed with error {}", success.err().unwrap() ); @@ -624,11 +627,11 @@ impl BabyProver { )); } if !success.unwrap() { - println!("Proof is invalid"); + error!("Proof is invalid"); return Err(BabyProverErr::Other("Proof is invalid".to_owned())); } - println!("Proof generation is complete"); + info!("Proof generation is complete"); let full_proof = FullBabyProof { proof: p, @@ -647,12 +650,12 @@ impl BabyProver { block: &Block, transactions: &[DepositTx], ) -> Result { - // println!("block: {:?}", &block.block_data); - // println!("transactions: {:?}", &transactions); + // debug!("block: {:?}", &block.block_data); + // debug!("transactions: {:?}", &transactions); let block_number = block.block_number; if block_number != self.current_block_number { - println!( + error!( "Deposit proof request is for block {}, while prover state is block {}", block_number, self.current_block_number ); @@ -752,7 +755,7 @@ impl BabyProver { let final_root = self.accounts_tree.root_hash(); - println!( + info!( "Prover final root = {}, final root from state keeper = {}", final_root, block_final_root ); @@ -789,7 +792,7 @@ impl BabyProver { let bytes_to_hash = be_bit_vector_into_bytes(&public_data_initial_bits); let hex_block_and_fee: String = bytes_to_hash.clone().to_hex(); - println!( + debug!( "Packed initial hash information in deposit = {}", hex_block_and_fee ); @@ -800,13 +803,13 @@ impl BabyProver { h.result(&mut hash_result[..]); let initial_hash: String = hash_result.to_hex(); - println!("Block number hash in deposit = {}", initial_hash); + debug!("Block number hash in deposit = {}", initial_hash); { let packed_transaction_data_bytes = public_data.clone(); let hex: String = packed_transaction_data_bytes.clone().to_hex(); - println!("Packed deposit information data in deposit = {}", hex); + debug!("Packed deposit information data in deposit = {}", hex); let mut next_round_hash_bytes = vec![]; next_round_hash_bytes.extend(hash_result.iter()); @@ -840,7 +843,7 @@ impl BabyProver { }; let mut rng = OsRng::new().unwrap(); - println!("Prover has started to work deposits"); + debug!("Prover has started to work deposits"); let proof = create_random_proof(instance, &self.deposit_parameters, &mut rng); if proof.is_err() { return Err(BabyProverErr::Other("proof.is_err()".to_owned())); @@ -850,7 +853,7 @@ impl BabyProver { let pvk = prepare_verifying_key(&self.deposit_parameters.vk); - println!( + debug!( "Made an deposit proof for initial root = {}, final root = {}, public data = {}", initial_root, final_root, @@ -863,17 +866,17 @@ impl BabyProver { ); if success.is_err() { - println!( + error!( "Proof verification failed with error {}", success.err().unwrap() ); return Err(BabyProverErr::Other("Proof verification failed".to_owned())); } if !success.unwrap() { - println!("Proof is invalid"); + error!("Proof is invalid"); return Err(BabyProverErr::Other("Proof is invalid".to_owned())); } - println!("Proof generation is complete"); + info!("Proof generation is complete"); let full_proof = FullBabyProof { proof: p, @@ -894,7 +897,7 @@ impl BabyProver { ) -> Result { let block_number = block.block_number; if block_number != self.current_block_number { - println!( + info!( "Exit proof request is for block {}, while prover state is block {}", block_number, self.current_block_number ); @@ -913,12 +916,12 @@ impl BabyProver { )); } - let mut witnesses: Vec<(ExitRequest, ExitWitness)> = vec![]; + let mut witnesses: Vec<(ExitRequest, ExitWitness)> = Vec::new(); let initial_root = self.accounts_tree.root_hash(); // we also need to create public data cause we need info from state - let mut public_data: Vec = vec![]; + let mut public_data: Vec = Vec::new(); for tx in transactions { let tx = circuit::CircuitExitRequest::try_from(tx) @@ -984,7 +987,7 @@ impl BabyProver { )); } - println!( + debug!( "Prover final root = {}, final root from state keeper = {}", final_root, block_final_root ); @@ -1014,7 +1017,7 @@ impl BabyProver { let bytes_to_hash = be_bit_vector_into_bytes(&public_data_initial_bits); // let hex_block_and_fee: String = bytes_to_hash.clone().to_hex(); - // println!("Packed initial hash information in exit = {}", hex_block_and_fee); + // debug!("Packed initial hash information in exit = {}", hex_block_and_fee); h.input(&bytes_to_hash); @@ -1022,20 +1025,20 @@ impl BabyProver { h.result(&mut hash_result[..]); // let initial_hash: String = hash_result.clone().to_hex(); - // println!("Block number hash in exit = {}", initial_hash); + // debug!("Block number hash in exit = {}", initial_hash); { let packed_transaction_data_bytes = public_data.clone(); // let hex: String = packed_transaction_data_bytes.clone().to_hex(); - // println!("Packed transfers information data in exit= {}", hex); + // debug!("Packed transfers information data in exit= {}", hex); - let mut next_round_hash_bytes = vec![]; + let mut next_round_hash_bytes = Vec::new(); next_round_hash_bytes.extend(hash_result.iter()); next_round_hash_bytes.extend(packed_transaction_data_bytes); // let hex_full: String = next_round_hash_bytes.clone().to_hex(); - // println!("Final hashable information data in exit= {}", hex_full); + // debug!("Final hashable information data in exit= {}", hex_full); let mut h = Sha256::new(); @@ -1047,7 +1050,7 @@ impl BabyProver { // clip to fit into field element // let final_hash_hex: String = hash_result.clone().to_hex(); - // println!("Full public data commitment = {}", final_hash_hex); + // debug!("Full public data commitment = {}", final_hash_hex); hash_result[0] &= 0x1f; // temporary solution @@ -1076,7 +1079,7 @@ impl BabyProver { }; let mut rng = OsRng::new().unwrap(); - println!("Prover has started to work on exits"); + debug!("Prover has started to work on exits"); let proof = create_random_proof(instance, &self.exit_parameters, &mut rng); if proof.is_err() { return Err(BabyProverErr::Other("proof.is_err()".to_owned())); @@ -1086,7 +1089,7 @@ impl BabyProver { let pvk = prepare_verifying_key(&self.exit_parameters.vk); - println!( + info!( "Made an exit proof for initial root = {}, final root = {}, public data = {}", initial_root, final_root, @@ -1099,17 +1102,17 @@ impl BabyProver { ); if success.is_err() { - println!( + error!( "Proof verification failed with error {}", success.err().unwrap() ); return Err(BabyProverErr::Other("Proof verification failed".to_owned())); } if !success.unwrap() { - println!("Proof is invalid"); + error!("Proof is invalid"); return Err(BabyProverErr::Other("Proof is invalid".to_owned())); } - println!("Proof generation is complete"); + info!("Proof generation is complete"); let full_proof = FullBabyProof { proof: p, @@ -1127,7 +1130,7 @@ impl BabyProver { storage: &StorageProcessor, expected_current_block: BlockNumber, ) -> Result<(), String> { - println!( + info!( "rewinding the state from block #{} to #{}", self.current_block_number, expected_current_block ); @@ -1148,7 +1151,7 @@ impl BabyProver { if let Some(job) = job { let block_number = job.block_number as BlockNumber; - println!( + info!( "prover {} got a new job for block {}", &self.worker, block_number ); @@ -1196,7 +1199,7 @@ impl BabyProver { .fold(job_ref, |job_ref, _| { let job = job_ref.load(Ordering::Relaxed); if job > 0 { - //println!("prover is working on block {}", job); + //debug!("prover is working on block {}", job); if let Ok(storage) = StorageProcessor::establish_connection() { let _ = storage.update_prover_job(job as i32); } @@ -1210,14 +1213,14 @@ impl BabyProver { } pub fn run(&mut self, shutdown_tx: Sender<()>, stop_signal: Arc) { - println!("prover is running"); + info!("prover is running"); while !stop_signal.load(Ordering::SeqCst) { if let Err(err) = self.make_proving_attempt() { - eprint!("Error: {}", err); + error!("Error: {}", err); } self.current_job.store(0, Ordering::Relaxed); } - println!("prover stopped"); + info!("prover stopped"); shutdown_tx.send(()).unwrap(); } } diff --git a/core/prover/src/main.rs b/core/prover/src/main.rs index ac5e0611e9..7f6c3d6b39 100644 --- a/core/prover/src/main.rs +++ b/core/prover/src/main.rs @@ -1,3 +1,6 @@ +#[macro_use] +extern crate log; + use prover::BabyProver; use signal_hook::iterator::Signals; use std::env; @@ -8,6 +11,8 @@ use tokio::runtime::current_thread::Runtime; use tokio::sync::oneshot; fn main() { + env_logger::init(); + // handle ctrl+c let stop_signal = Arc::new(AtomicBool::new(false)); signal_hook::flag::register(signal_hook::SIGTERM, Arc::clone(&stop_signal)) @@ -18,7 +23,7 @@ fn main() { .expect("Error setting SIGQUIT handler"); let worker = env::var("POD_NAME").unwrap_or_else(|_| "default".to_string()); - println!("creating prover, worker: {}", worker); + info!("creating prover, worker: {}", worker); let mut prover = BabyProver::create(worker).unwrap(); let prover_id = prover.prover_id; @@ -39,7 +44,7 @@ fn main() { .expect("Signals::new() failed"); thread::spawn(move || { for _ in signals.forever() { - println!( + info!( "Termination signal received. Prover will finish the job and shut down gracefully" ); let storage = diff --git a/core/sandbox/Cargo.toml b/core/sandbox/Cargo.toml index 1aea28e8ed..2bea887e55 100644 --- a/core/sandbox/Cargo.toml +++ b/core/sandbox/Cargo.toml @@ -9,6 +9,8 @@ edition = "2018" serde = "1.0.90" serde_derive = "1.0.90" +log = "0.4" +env_logger = "0.6" # ff = { package = "ff_ce", version = "0.6.0", features = ["derive"] } # models = { path = "../models" } diff --git a/core/sandbox/src/main.rs b/core/sandbox/src/main.rs index c2eb6a3a61..4620e1e1c3 100644 --- a/core/sandbox/src/main.rs +++ b/core/sandbox/src/main.rs @@ -1,3 +1,6 @@ +#[macro_use] +extern crate log; + use futures::Future; use std::time::{Duration, Instant}; use tokio::prelude::*; @@ -8,11 +11,13 @@ mod nonce_futures; use nonce_futures::*; fn main() { + env_logger::init(); + let nm = NonceFutures::default(); let task = Interval::new(Instant::now(), Duration::from_millis(1000)) .fold((0, nm.clone()), |acc, _| { let (i, mut nm) = acc; - println!("i = {}", i); + info!("i = {}", i); if i == 2 { nm.set(1, 2); @@ -30,9 +35,9 @@ fn main() { let task = nm .nonce_await(1, i) .timeout(Duration::from_millis(5000)) - .map(|_| println!("success!")) + .map(|_| info!("success!")) .or_else(|e| { - println!("error: {:?}", e); + error!("error: {:?}", e); future::ok(()) }); tokio::spawn(task); diff --git a/core/server/Cargo.toml b/core/server/Cargo.toml index 0b01b138f0..88b286800f 100644 --- a/core/server/Cargo.toml +++ b/core/server/Cargo.toml @@ -29,6 +29,8 @@ serde = "1.0.90" serde_derive = "1.0.90" serde_bytes = "0.11.1" serde_json = "1.0.39" +log = "0.4" +env_logger = "0.6" im = "12.2.0" priority-queue = "0.5.2" diff --git a/core/server/src/api_server.rs b/core/server/src/api_server.rs index 0c3cc1dc9e..28f84fa4d2 100644 --- a/core/server/src/api_server.rs +++ b/core/server/src/api_server.rs @@ -108,14 +108,14 @@ fn handle_submit_tx( Ok((tx, account, tx_for_state)) }) .and_then(move |(tx, account, tx_for_state)| { - //println!("account {}: nonce {} received", tx.from, tx.nonce); + //debug!("account {}: nonce {} received", tx.from, tx.nonce); // Wait for nonce let future = if account.nonce == tx.nonce { nonce_futures.ready(tx.from, tx.nonce) } else { - //println!("account {}: waiting for nonce {}", tx.from, tx.nonce); + //debug!("account {}: waiting for nonce {}", tx.from, tx.nonce); nonce_futures.nonce_await(tx.from, tx.nonce) }; future @@ -124,7 +124,7 @@ fn handle_submit_tx( .or_else(|e| future::err(format!("Nonce error: {:?}", e))) }) .and_then(move |(mut tx, account, mut nonce_futures, tx_for_state)| { - //println!("account {}: nonce {} ready", tx.from, tx.nonce); + //debug!("account {}: nonce {} ready", tx.from, tx.nonce); // Verify signature @@ -134,8 +134,8 @@ fn handle_submit_tx( let verified = tx.verify_sig(&pub_key); if !verified { let (x, y) = pub_key.0.into_xy(); - println!("Got public key: {:?}, {:?}", x, y); - println!( + warn!("Got public key: {:?}, {:?}", x, y); + warn!( "Signature is invalid: (x,y,s) = ({:?},{:?},{:?})", &tx.signature.r_x, &tx.signature.r_y, &tx.signature.s ); @@ -222,7 +222,7 @@ fn handle_get_account_state(req: &HttpRequest) -> ActixResult, pool: ConnectionPool, ) { - println!("committer started"); + info!("committer started"); let storage = pool .access_storage() .expect("db connection failed for committer");; @@ -48,7 +48,7 @@ fn run_committer( tx_meta: None, id: None, }; - println!("commit block #{}", op.block.block_number); + info!("commit block #{}", op.block.block_number); let op = storage .execute_operation(&op) .expect("committer must commit the op into db"); diff --git a/core/server/src/eth_sender.rs b/core/server/src/eth_sender.rs index 16cc99f477..60fe619235 100644 --- a/core/server/src/eth_sender.rs +++ b/core/server/src/eth_sender.rs @@ -56,8 +56,8 @@ fn run_eth_sender( .access_storage() .expect("db connection failed for eth sender"); for op in rx_for_eth { - //println!("Operation requested"); - println!( + //debug!("Operation requested"); + debug!( "Operation requested: {:?}, {}", &op.action, op.block.block_number ); @@ -172,13 +172,13 @@ fn run_eth_sender( // TODO: process tx sending failure match tx { Ok(hash) => { - println!("Commitment tx hash = {:?}", hash); + debug!("Commitment tx hash = {:?}", hash); let _ = storage.save_operation_tx_hash( op.id.expect("trying to send not stored op?"), format!("{:?}", hash), ); } - Err(err) => println!("Error sending tx {}", err), + Err(err) => error!("Error sending tx {}", err), } } } @@ -192,7 +192,7 @@ pub fn start_eth_sender(pool: ConnectionPool) -> Sender { let current_nonce = eth_client .current_nonce() .expect("could not fetch current nonce"); - println!( + info!( "Starting eth_sender: sender = {}, current_nonce = {}", eth_client.current_sender(), current_nonce diff --git a/core/server/src/eth_watch.rs b/core/server/src/eth_watch.rs index e56723387f..fc2ec77ca6 100644 --- a/core/server/src/eth_watch.rs +++ b/core/server/src/eth_watch.rs @@ -95,9 +95,9 @@ impl EthWatch { this.last_deposit_batch = U256::from(expecting_deposit_batch); this.last_exit_batch = U256::from(expecting_exit_batch); - println!("Monitoring contract {:x}", this.contract_addr); - println!("Starting from deposit batch {}", this.last_deposit_batch); - println!("Starting from exit batch {}", this.last_exit_batch); + info!("Monitoring contract {:x}", this.contract_addr); + info!("Starting from deposit batch {}", this.last_deposit_batch); + info!("Starting from exit batch {}", this.last_exit_batch); this } @@ -134,13 +134,13 @@ impl EthWatch { let deposits_result = self.process_deposits(block_number, &tx_for_blocks, &web3, &contract); if let Err(err) = deposits_result { - println!("Failed to process deposit logs: {}", err); + error!("Failed to process deposit logs: {}", err); continue; } let exits_result = self.process_exits(block_number, &tx_for_blocks, &web3, &contract); if let Err(err) = exits_result { - println!("Failed to process exit logs: {}", err); + error!("Failed to process exit logs: {}", err); continue; } @@ -159,7 +159,7 @@ impl EthWatch { web3: &web3::Web3, contract: &Contract, ) -> Result<(), String> { - //println!("Processing deposits for block {}", block_number); + //debug!("Processing deposits for block {}", block_number); let total_deposit_requests_result: U256 = contract .query( "totalDepositRequests", @@ -172,7 +172,7 @@ impl EthWatch { .map_err(|err| format!("Error getting total deposit requests {}", err))?; let total_deposit_requests = total_deposit_requests_result; - //println!("total_deposit_requests = {}", total_deposit_requests); + //debug!("total_deposit_requests = {}", total_deposit_requests); let max_batch_number = total_deposit_requests / self.deposit_batch_size; @@ -318,7 +318,7 @@ impl EthWatch { let mut all_deposits = vec![]; for (k, v) in this_batch.iter() { - println!( + info!( "Into account {:x} with public key {:x}, deposit amount = {}", k, v.1, v.0 ); @@ -356,7 +356,7 @@ impl EthWatch { let len = all_deposits.len(); let block = ProtoBlock::Deposit(self.last_deposit_batch.as_u32(), all_deposits); - println!( + info!( "Deposit batch {}, {} accounts", self.last_deposit_batch, len ); @@ -376,7 +376,7 @@ impl EthWatch { web3: &web3::Web3, contract: &Contract, ) -> Result<(), String> { - //println!("Processing exits for block {}", block_number); + //debug!("Processing exits for block {}", block_number); let total_requests_result: U256 = contract .query( "totalExitRequests", @@ -528,7 +528,7 @@ impl EthWatch { let mut all_exits = vec![]; for k in this_batch.iter() { - println!("Exit from account {:x}", k); + info!("Exit from account {:x}", k); let tx: ExitTx = ExitTx { account: k.as_u32(), diff --git a/core/server/src/lib.rs b/core/server/src/lib.rs index 1c7df1b2a7..d55f378641 100644 --- a/core/server/src/lib.rs +++ b/core/server/src/lib.rs @@ -1,5 +1,7 @@ #[macro_use] extern crate serde_derive; +#[macro_use] +extern crate log; pub mod api_server; pub mod committer; diff --git a/core/server/src/main.rs b/core/server/src/main.rs index 373d1c00b4..e8245e0704 100644 --- a/core/server/src/main.rs +++ b/core/server/src/main.rs @@ -1,4 +1,6 @@ //use tokio::runtime::Runtime; +#[macro_use] +extern crate log; use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::mpsc::channel; @@ -16,7 +18,9 @@ use models::{config, StateKeeperRequest}; use storage::ConnectionPool; fn main() { - println!("starting server"); + env_logger::init(); + + debug!("starting server"); // handle ctrl+c let stop_signal = Arc::new(AtomicBool::new(false)); @@ -54,7 +58,7 @@ fn main() { // spawn threads for different processes // see https://docs.google.com/drawings/d/16UeYq7cuZnpkyMWGrgDAbmlaGviN2baY1w1y745Me70/edit?usp=sharing - println!("starting actors"); + info!("starting actors"); let (tx_for_state, rx_for_state) = channel(); start_api_server(tx_for_state.clone(), connection_pool.clone()); @@ -83,5 +87,5 @@ fn main() { thread::sleep(Duration::from_secs(1)); } - println!("terminate signal received"); + info!("terminate signal received"); } diff --git a/core/server/src/state_keeper.rs b/core/server/src/state_keeper.rs index cf365f084e..632a2e371c 100644 --- a/core/server/src/state_keeper.rs +++ b/core/server/src/state_keeper.rs @@ -49,7 +49,7 @@ type UpdatedAccounts = AccountMap; impl PlasmaStateKeeper { pub fn new(pool: ConnectionPool) -> Self { - println!("constructing state keeper instance"); + info!("constructing state keeper instance"); // here we should insert default accounts into the tree let storage = pool @@ -61,7 +61,7 @@ impl PlasmaStateKeeper { let state = PlasmaState::new(accounts, last_committed + 1); //let outstanding_txs = storage.count_outstanding_proofs(last_verified).expect("db failed"); - println!( + info!( "last_committed = {}, last_verified = {}", last_committed, last_verified ); @@ -75,7 +75,7 @@ impl PlasmaStateKeeper { }; let root = keeper.state.root_hash(); - println!("created state keeper, root hash = {}", root); + info!("created state keeper, root hash = {}", root); keeper } @@ -98,7 +98,7 @@ impl PlasmaStateKeeper { total_transactions: 0, }); if r.is_err() { - println!( + error!( "StateKeeperRequest::GetNetworkStatus: channel closed, sending failed" ); } @@ -107,7 +107,7 @@ impl PlasmaStateKeeper { let account = self.state.get_account(account_id); let r = sender.send(account); if r.is_err() { - println!("StateKeeperRequest::GetAccount: channel closed, sending failed"); + error!("StateKeeperRequest::GetAccount: channel closed, sending failed"); } } StateKeeperRequest::AddTransferTx(tx, sender) => { @@ -118,9 +118,7 @@ impl PlasmaStateKeeper { } let r = sender.send(result); if r.is_err() { - println!( - "StateKeeperRequest::AddTransferTx: channel closed, sending failed" - ); + error!("StateKeeperRequest::AddTransferTx: channel closed, sending failed"); } if self.transfer_tx_queue.len() == config::RUNTIME_CONFIG.transfer_batch_size { @@ -129,7 +127,7 @@ impl PlasmaStateKeeper { } StateKeeperRequest::AddBlock(block) => { self.block_queue.push_back(block); - //println!("new protoblock, transfer_tx_queue.len() = {}", self.transfer_tx_queue.len()); + //debug!("new protoblock, transfer_tx_queue.len() = {}", self.transfer_tx_queue.len()); if self.transfer_tx_queue.is_empty() { self.process_block_queue(&tx_for_commitments); } @@ -157,7 +155,7 @@ impl PlasmaStateKeeper { self.create_exit_block(batch_number, transactions) } }; - //println!("sending request to committer {:?}", req); + //debug!("sending request to committer {:?}", req); tx_for_commitments .send(req) .expect("must send new operation for commitment"); @@ -168,7 +166,7 @@ impl PlasmaStateKeeper { fn apply_transfer_tx(&mut self, tx: TransferTx) -> TransferTxResult { let appication_result = self.state.apply_transfer(&tx); if appication_result.is_ok() { - //println!("accepted transaction for account {}, nonce {}", tx.from, tx.nonce); + //debug!("accepted transaction for account {}, nonce {}", tx.from, tx.nonce); self.transfer_tx_queue.push(tx); } @@ -189,7 +187,7 @@ impl PlasmaStateKeeper { fn apply_padding(&mut self) { let to_pad = config::RUNTIME_CONFIG.transfer_batch_size - self.transfer_tx_queue.len(); if to_pad > 0 { - println!("padding transactions"); + debug!("padding transactions"); // TODO: move to env vars let pk_bytes = hex::decode("8ea0225bbf7f3689eb8ba6f8d7bef3d8ae2541573d71711a28d5149807b40805") diff --git a/core/storage/Cargo.toml b/core/storage/Cargo.toml index cd10d68083..7bf566d75a 100644 --- a/core/storage/Cargo.toml +++ b/core/storage/Cargo.toml @@ -14,3 +14,4 @@ diesel = { version = "1.4.2", features = ["postgres", "serde_json", "r2d2", "chr bigdecimal = { version = "0.1.0", features = ["serde"]} ff = { package = "ff_ce", version = "0.6.0", features = ["derive"] } chrono = { version = "0.4", features = ["serde", "rustc-serialize"] } +log = "0.4" diff --git a/core/storage/src/lib.rs b/core/storage/src/lib.rs index 1991738d12..2a38a7e240 100644 --- a/core/storage/src/lib.rs +++ b/core/storage/src/lib.rs @@ -2,6 +2,8 @@ #[macro_use] extern crate diesel; +#[macro_use] +extern crate log; use bigdecimal::BigDecimal; use chrono::prelude::*; @@ -119,7 +121,7 @@ impl StoredOperation { let op: Result = serde_json::from_str(&self.data.to_string()); if let Err(err) = &op { - println!("Error: {} on {}", err, debug_data) + debug!("Error: {} on {}", err, debug_data) } let mut op = op.expect("Operation deserialization"); @@ -402,7 +404,7 @@ impl StorageProcessor { }) .execute(self.conn())?; if 0 == inserted { - eprintln!("Error: could not commit all new transactions!"); + error!("Error: could not commit all new transactions!"); return Err(Error::RollbackTransaction); } } @@ -431,7 +433,7 @@ impl StorageProcessor { }) .execute(self.conn())?; if 0 == inserted { - eprintln!("Error: could not commit all new transactions!"); + error!("Error: could not commit all new transactions!"); return Err(Error::RollbackTransaction); } } @@ -460,7 +462,7 @@ impl StorageProcessor { }) .execute(self.conn())?; if 0 == inserted { - eprintln!("Error: could not commit all new transactions!"); + error!("Error: could not commit all new transactions!"); return Err(Error::RollbackTransaction); } } @@ -473,7 +475,7 @@ impl StorageProcessor { accounts_updated: &AccountMap, ) -> QueryResult<()> { for (&account_id, a) in accounts_updated.iter() { - println!( + debug!( "Committing state update for account {} in block {}", account_id, block_number ); @@ -485,7 +487,7 @@ impl StorageProcessor { }) .execute(self.conn())?; if 0 == inserted { - eprintln!("Error: could not commit all state updates!"); + error!("Error: could not commit all state updates!"); return Err(Error::RollbackTransaction); } } diff --git a/etc/env/dev.env.example b/etc/env/dev.env.example index adc746e2fe..ee05c9a710 100755 --- a/etc/env/dev.env.example +++ b/etc/env/dev.env.example @@ -64,3 +64,5 @@ TREE_RESTORE_RINKEBY_ENDPOINT=https://rinkeby.infura.io/ TREE_RESTORE_RINKEBY_CONTRACT_ADDR=4fbf331db438c88a83b1316d072b7d73d8366367 TREE_RESTORE_MAINNET_ENDPOINT=https://mainnet.infura.io/ TREE_RESTORE_MAINNET_CONTRACT_ADDR=4a89f998dce2453e96b795d47603c4b5a16144b0 + +RUST_LOG=server=info,storage=info,prover=info,plasma=info,eth_client=info,data_restore=info