From fc57b0d775d2e21461b15b604d57e5528f4c06eb Mon Sep 17 00:00:00 2001 From: Michael Maurer Date: Wed, 21 Jun 2023 13:28:06 -0400 Subject: [PATCH] Rename 3PC -> PArSEC Rename all instances of 3PC to PArSEC. Signed-off-by: Michael Maurer Co-authored-by: Alexander Jung <104335080+AlexRamRam@users.noreply.github.com> Co-authored-by: Anders Brownworth --- Dockerfile | 14 +- README.md | 18 +- docker-compose-3pc.yml | 57 -- ...test.yml => docker-compose-parsec-test.yml | 10 +- docker-compose-parsec.yml | 57 ++ docs/lifecycle.md | 2 +- ...architecture.md => parsec_architecture.md} | 4 +- ...am.svg => parsec_architecture_diagram.svg} | 0 ...svg => parsec_system_diagram_detailed.svg} | 0 ...ity_user_guide.md => parsec_user_guide.md} | 18 +- scripts/configure.sh | 2 +- .../{3pc-run-local.sh => parsec-run-local.sh} | 8 +- src/3pc/agent/runners/evm/format.hpp | 90 --- src/CMakeLists.txt | 2 +- src/{3pc => parsec}/CMakeLists.txt | 4 +- src/{3pc => parsec}/agent/CMakeLists.txt | 2 +- src/{3pc => parsec}/agent/agentd.cpp | 42 +- src/{3pc => parsec}/agent/client.cpp | 2 +- src/{3pc => parsec}/agent/client.hpp | 6 +- src/{3pc => parsec}/agent/format.cpp | 4 +- src/{3pc => parsec}/agent/format.hpp | 8 +- src/{3pc => parsec}/agent/impl.cpp | 4 +- src/{3pc => parsec}/agent/impl.hpp | 14 +- src/{3pc => parsec}/agent/interface.cpp | 2 +- src/{3pc => parsec}/agent/interface.hpp | 8 +- src/{3pc => parsec}/agent/messages.hpp | 6 +- .../agent/runners/CMakeLists.txt | 0 .../agent/runners/evm/CMakeLists.txt | 2 +- .../agent/runners/evm/address.cpp | 2 +- .../agent/runners/evm/address.hpp | 6 +- .../agent/runners/evm/format.cpp | 51 +- src/parsec/agent/runners/evm/format.hpp | 90 +++ .../agent/runners/evm/hash.cpp | 0 .../agent/runners/evm/hash.hpp | 6 +- .../agent/runners/evm/host.cpp | 2 +- .../agent/runners/evm/host.hpp | 12 +- .../agent/runners/evm/http_server.cpp | 20 +- .../agent/runners/evm/http_server.hpp | 22 +- .../agent/runners/evm/impl.cpp | 4 +- .../agent/runners/evm/impl.hpp | 12 +- .../agent/runners/evm/init_addresses.hpp | 8 +- .../agent/runners/evm/math.cpp | 2 +- .../agent/runners/evm/math.hpp | 6 +- .../agent/runners/evm/messages.hpp | 16 +- src/{3pc => parsec}/agent/runners/evm/rlp.cpp | 0 src/{3pc => parsec}/agent/runners/evm/rlp.hpp | 10 +- .../agent/runners/evm/rlp_reader.cpp | 6 +- .../agent/runners/evm/rlp_writer.cpp | 2 +- .../agent/runners/evm/serialization.cpp | 30 +- .../agent/runners/evm/serialization.hpp | 30 +- .../agent/runners/evm/signature.cpp | 6 +- .../agent/runners/evm/signature.hpp | 10 +- .../agent/runners/evm/util.cpp | 22 +- .../agent/runners/evm/util.hpp | 10 +- .../agent/runners/interface.cpp | 4 +- .../agent/runners/interface.hpp | 24 +- .../agent/runners/lua/CMakeLists.txt | 0 .../agent/runners/lua/impl.cpp | 4 +- .../agent/runners/lua/impl.hpp | 12 +- .../agent/runners/lua/server.cpp | 6 +- .../agent/runners/lua/server.hpp | 8 +- .../agent/server_interface.cpp | 4 +- .../agent/server_interface.hpp | 18 +- src/{3pc => parsec}/broker/CMakeLists.txt | 0 src/{3pc => parsec}/broker/impl.cpp | 44 +- src/{3pc => parsec}/broker/impl.hpp | 29 +- src/{3pc => parsec}/broker/interface.hpp | 10 +- src/{3pc => parsec}/directory/CMakeLists.txt | 0 src/{3pc => parsec}/directory/impl.cpp | 2 +- src/{3pc => parsec}/directory/impl.hpp | 6 +- src/{3pc => parsec}/directory/interface.hpp | 8 +- .../runtime_locking_shard/CMakeLists.txt | 2 +- .../runtime_locking_shard/client.cpp | 2 +- .../runtime_locking_shard/client.hpp | 6 +- .../runtime_locking_shard/controller.cpp | 2 +- .../runtime_locking_shard/controller.hpp | 6 +- .../runtime_locking_shard/format.cpp | 58 +- .../runtime_locking_shard/format.hpp | 62 +- .../runtime_locking_shard/impl.cpp | 2 +- .../runtime_locking_shard/impl.hpp | 6 +- .../runtime_locking_shard/interface.hpp | 10 +- .../runtime_locking_shard/messages.hpp | 6 +- .../replicated_shard.cpp | 2 +- .../replicated_shard.hpp | 6 +- .../replicated_shard_client.cpp | 2 +- .../replicated_shard_client.hpp | 6 +- .../replicated_shard_interface.hpp | 8 +- .../runtime_locking_shardd.cpp | 4 +- .../runtime_locking_shard/server.cpp | 2 +- .../runtime_locking_shard/server.hpp | 6 +- .../runtime_locking_shard/state_machine.cpp | 2 +- .../runtime_locking_shard/state_machine.hpp | 6 +- .../ticket_machine/CMakeLists.txt | 2 +- src/{3pc => parsec}/ticket_machine/client.cpp | 2 +- src/{3pc => parsec}/ticket_machine/client.hpp | 6 +- .../ticket_machine/controller.cpp | 2 +- .../ticket_machine/controller.hpp | 6 +- src/{3pc => parsec}/ticket_machine/impl.cpp | 2 +- src/{3pc => parsec}/ticket_machine/impl.hpp | 6 +- .../ticket_machine/interface.hpp | 6 +- .../ticket_machine/messages.hpp | 6 +- .../ticket_machine/state_machine.cpp | 2 +- .../ticket_machine/state_machine.hpp | 6 +- .../ticket_machine/ticket_machined.cpp | 4 +- src/{3pc => parsec}/util.cpp | 8 +- src/{3pc => parsec}/util.hpp | 6 +- tests/integration/CMakeLists.txt | 2 +- .../integration/gtest_evm_jsonrpc_client.cpp | 27 +- .../integration/gtest_evm_jsonrpc_client.hpp | 4 +- ...est.cpp => parsec_evm_end_to_end_test.cpp} | 246 ++++---- tests/integration/sample_erc20_contract.hpp | 5 +- .../3pc/agent/runners/lua/runner_test.cpp | 68 -- tests/unit/3pc/broker/CMakeLists.txt | 1 - .../3pc/runtime_locking_shard/CMakeLists.txt | 1 - tests/unit/CMakeLists.txt | 4 +- tests/unit/{3pc => parsec}/CMakeLists.txt | 2 +- .../unit/{3pc => parsec}/agent/CMakeLists.txt | 0 .../agent/runners/CMakeLists.txt | 0 .../agent/runners/evm/CMakeLists.txt | 0 .../agent/runners/evm/evm_test.cpp | 590 +++++++++--------- .../agent/runners/evm/math_test.cpp | 4 +- .../agent/runners/lua/CMakeLists.txt | 0 .../agent/runners/lua/account_test.cpp | 63 +- .../agent/runners/lua/agent_test.cpp | 115 ++-- .../agent/runners/lua/gen_pay_contract.lua | 0 .../parsec/agent/runners/lua/runner_test.cpp | 68 ++ tests/unit/parsec/broker/CMakeLists.txt | 1 + .../unit/{3pc => parsec}/broker/impl_test.cpp | 18 +- .../runtime_locking_shard/CMakeLists.txt | 1 + .../runtime_locking_shard/impl_test.cpp | 362 +++++------ tests/unit/{3pc => parsec}/util.cpp | 8 +- tests/unit/{3pc => parsec}/util.hpp | 8 +- tools/bench/CMakeLists.txt | 2 +- tools/bench/{3pc => parsec}/CMakeLists.txt | 0 tools/bench/{3pc => parsec}/evm/.clang-tidy | 0 .../bench/{3pc => parsec}/evm/CMakeLists.txt | 2 +- tools/bench/{3pc => parsec}/evm/contracts.cpp | 2 +- tools/bench/{3pc => parsec}/evm/contracts.hpp | 10 +- .../{3pc => parsec}/evm/contracts/.gitignore | 0 .../{3pc => parsec}/evm/contracts/README.md | 6 +- .../evm/contracts/contracts/ERC20.sol | 0 .../evm/contracts/gen_header.py | 10 +- .../evm/contracts/hardhat.config.js | 0 .../evm/contracts/package.json | 4 +- .../evm/contracts/pnpm-lock.yaml | 0 tools/bench/{3pc => parsec}/evm/evm_bench.cpp | 98 +-- tools/bench/{3pc => parsec}/evm/evm_bench.hpp | 10 +- tools/bench/{3pc => parsec}/evm/main.cpp | 2 +- .../bench/{3pc => parsec}/evm/rpc_client.cpp | 2 +- .../bench/{3pc => parsec}/evm/rpc_client.hpp | 6 +- .../bench/{3pc => parsec}/lua/CMakeLists.txt | 2 +- tools/bench/{3pc => parsec}/lua/lua_bench.cpp | 32 +- tools/bench/{3pc => parsec}/lua/wallet.cpp | 4 +- tools/bench/{3pc => parsec}/lua/wallet.hpp | 10 +- 154 files changed, 1482 insertions(+), 1538 deletions(-) delete mode 100644 docker-compose-3pc.yml rename docker-compose-3pc-test.yml => docker-compose-parsec-test.yml (51%) create mode 100644 docker-compose-parsec.yml rename docs/{programmability_architecture.md => parsec_architecture.md} (97%) rename docs/{programmability_architecture_diagram.svg => parsec_architecture_diagram.svg} (100%) rename docs/{programmability_system_diagram_detailed.svg => parsec_system_diagram_detailed.svg} (100%) rename docs/{programmability_user_guide.md => parsec_user_guide.md} (88%) rename scripts/{3pc-run-local.sh => parsec-run-local.sh} (88%) delete mode 100644 src/3pc/agent/runners/evm/format.hpp rename src/{3pc => parsec}/CMakeLists.txt (79%) rename src/{3pc => parsec}/agent/CMakeLists.txt (96%) rename src/{3pc => parsec}/agent/agentd.cpp (75%) rename src/{3pc => parsec}/agent/client.cpp (96%) rename src/{3pc => parsec}/agent/client.hpp (93%) rename src/{3pc => parsec}/agent/format.cpp (78%) rename src/{3pc => parsec}/agent/format.hpp (61%) rename src/{3pc => parsec}/agent/impl.cpp (99%) rename src/{3pc => parsec}/agent/impl.hpp (95%) rename src/{3pc => parsec}/agent/interface.cpp (96%) rename src/{3pc => parsec}/agent/interface.hpp (95%) rename src/{3pc => parsec}/agent/messages.hpp (85%) rename src/{3pc => parsec}/agent/runners/CMakeLists.txt (100%) rename src/{3pc => parsec}/agent/runners/evm/CMakeLists.txt (94%) rename src/{3pc => parsec}/agent/runners/evm/address.cpp (98%) rename src/{3pc => parsec}/agent/runners/evm/address.hpp (93%) rename src/{3pc => parsec}/agent/runners/evm/format.cpp (70%) create mode 100644 src/parsec/agent/runners/evm/format.hpp rename src/{3pc => parsec}/agent/runners/evm/hash.cpp (100%) rename src/{3pc => parsec}/agent/runners/evm/hash.hpp (78%) rename src/{3pc => parsec}/agent/runners/evm/host.cpp (99%) rename src/{3pc => parsec}/agent/runners/evm/host.hpp (96%) rename src/{3pc => parsec}/agent/runners/evm/http_server.cpp (99%) rename src/{3pc => parsec}/agent/runners/evm/http_server.hpp (95%) rename src/{3pc => parsec}/agent/runners/evm/impl.cpp (99%) rename src/{3pc => parsec}/agent/runners/evm/impl.hpp (95%) rename src/{3pc => parsec}/agent/runners/evm/init_addresses.hpp (98%) rename src/{3pc => parsec}/agent/runners/evm/math.cpp (98%) rename src/{3pc => parsec}/agent/runners/evm/math.hpp (90%) rename src/{3pc => parsec}/agent/runners/evm/messages.hpp (93%) rename src/{3pc => parsec}/agent/runners/evm/rlp.cpp (100%) rename src/{3pc => parsec}/agent/runners/evm/rlp.hpp (96%) rename src/{3pc => parsec}/agent/runners/evm/rlp_reader.cpp (95%) rename src/{3pc => parsec}/agent/runners/evm/rlp_writer.cpp (97%) rename src/{3pc => parsec}/agent/runners/evm/serialization.cpp (94%) rename src/{3pc => parsec}/agent/runners/evm/serialization.hpp (88%) rename src/{3pc => parsec}/agent/runners/evm/signature.cpp (96%) rename src/{3pc => parsec}/agent/runners/evm/signature.hpp (87%) rename src/{3pc => parsec}/agent/runners/evm/util.cpp (88%) rename src/{3pc => parsec}/agent/runners/evm/util.hpp (91%) rename src/{3pc => parsec}/agent/runners/interface.cpp (92%) rename src/{3pc => parsec}/agent/runners/interface.hpp (92%) rename src/{3pc => parsec}/agent/runners/lua/CMakeLists.txt (100%) rename src/{3pc => parsec}/agent/runners/lua/impl.cpp (98%) rename src/{3pc => parsec}/agent/runners/lua/impl.hpp (88%) rename src/{3pc => parsec}/agent/runners/lua/server.cpp (95%) rename src/{3pc => parsec}/agent/runners/lua/server.hpp (89%) rename src/{3pc => parsec}/agent/server_interface.cpp (95%) rename src/{3pc => parsec}/agent/server_interface.hpp (84%) rename src/{3pc => parsec}/broker/CMakeLists.txt (100%) rename src/{3pc => parsec}/broker/impl.cpp (96%) rename src/{3pc => parsec}/broker/impl.hpp (91%) rename src/{3pc => parsec}/broker/interface.hpp (97%) rename src/{3pc => parsec}/directory/CMakeLists.txt (100%) rename src/{3pc => parsec}/directory/impl.cpp (95%) rename src/{3pc => parsec}/directory/impl.hpp (89%) rename src/{3pc => parsec}/directory/interface.hpp (87%) rename src/{3pc => parsec}/runtime_locking_shard/CMakeLists.txt (95%) rename src/{3pc => parsec}/runtime_locking_shard/client.cpp (98%) rename src/{3pc => parsec}/runtime_locking_shard/client.hpp (95%) rename src/{3pc => parsec}/runtime_locking_shard/controller.cpp (98%) rename src/{3pc => parsec}/runtime_locking_shard/controller.hpp (92%) rename src/{3pc => parsec}/runtime_locking_shard/format.cpp (67%) rename src/{3pc => parsec}/runtime_locking_shard/format.hpp (50%) rename src/{3pc => parsec}/runtime_locking_shard/impl.cpp (99%) rename src/{3pc => parsec}/runtime_locking_shard/impl.hpp (97%) rename src/{3pc => parsec}/runtime_locking_shard/interface.hpp (97%) rename src/{3pc => parsec}/runtime_locking_shard/messages.hpp (94%) rename src/{3pc => parsec}/runtime_locking_shard/replicated_shard.cpp (98%) rename src/{3pc => parsec}/runtime_locking_shard/replicated_shard.hpp (89%) rename src/{3pc => parsec}/runtime_locking_shard/replicated_shard_client.cpp (99%) rename src/{3pc => parsec}/runtime_locking_shard/replicated_shard_client.hpp (93%) rename src/{3pc => parsec}/runtime_locking_shard/replicated_shard_interface.hpp (94%) rename src/{3pc => parsec}/runtime_locking_shard/runtime_locking_shardd.cpp (93%) rename src/{3pc => parsec}/runtime_locking_shard/server.cpp (99%) rename src/{3pc => parsec}/runtime_locking_shard/server.hpp (92%) rename src/{3pc => parsec}/runtime_locking_shard/state_machine.cpp (98%) rename src/{3pc => parsec}/runtime_locking_shard/state_machine.hpp (92%) rename src/{3pc => parsec}/ticket_machine/CMakeLists.txt (94%) rename src/{3pc => parsec}/ticket_machine/client.cpp (98%) rename src/{3pc => parsec}/ticket_machine/client.hpp (92%) rename src/{3pc => parsec}/ticket_machine/controller.cpp (98%) rename src/{3pc => parsec}/ticket_machine/controller.hpp (92%) rename src/{3pc => parsec}/ticket_machine/impl.cpp (94%) rename src/{3pc => parsec}/ticket_machine/impl.hpp (89%) rename src/{3pc => parsec}/ticket_machine/interface.hpp (93%) rename src/{3pc => parsec}/ticket_machine/messages.hpp (74%) rename src/{3pc => parsec}/ticket_machine/state_machine.cpp (98%) rename src/{3pc => parsec}/ticket_machine/state_machine.hpp (93%) rename src/{3pc => parsec}/ticket_machine/ticket_machined.cpp (93%) rename src/{3pc => parsec}/util.cpp (97%) rename src/{3pc => parsec}/util.hpp (96%) rename tests/integration/{threepc_evm_end_to_end_test.cpp => parsec_evm_end_to_end_test.cpp} (71%) delete mode 100644 tests/unit/3pc/agent/runners/lua/runner_test.cpp delete mode 100644 tests/unit/3pc/broker/CMakeLists.txt delete mode 100644 tests/unit/3pc/runtime_locking_shard/CMakeLists.txt rename tests/unit/{3pc => parsec}/CMakeLists.txt (69%) rename tests/unit/{3pc => parsec}/agent/CMakeLists.txt (100%) rename tests/unit/{3pc => parsec}/agent/runners/CMakeLists.txt (100%) rename tests/unit/{3pc => parsec}/agent/runners/evm/CMakeLists.txt (100%) rename tests/unit/{3pc => parsec}/agent/runners/evm/evm_test.cpp (78%) rename tests/unit/{3pc => parsec}/agent/runners/evm/math_test.cpp (92%) rename tests/unit/{3pc => parsec}/agent/runners/lua/CMakeLists.txt (100%) rename tests/unit/{3pc => parsec}/agent/runners/lua/account_test.cpp (71%) rename tests/unit/{3pc => parsec}/agent/runners/lua/agent_test.cpp (55%) rename tests/unit/{3pc => parsec}/agent/runners/lua/gen_pay_contract.lua (100%) create mode 100644 tests/unit/parsec/agent/runners/lua/runner_test.cpp create mode 100644 tests/unit/parsec/broker/CMakeLists.txt rename tests/unit/{3pc => parsec}/broker/impl_test.cpp (71%) create mode 100644 tests/unit/parsec/runtime_locking_shard/CMakeLists.txt rename tests/unit/{3pc => parsec}/runtime_locking_shard/impl_test.cpp (54%) rename tests/unit/{3pc => parsec}/util.cpp (83%) rename tests/unit/{3pc => parsec}/util.hpp (67%) rename tools/bench/{3pc => parsec}/CMakeLists.txt (100%) rename tools/bench/{3pc => parsec}/evm/.clang-tidy (100%) rename tools/bench/{3pc => parsec}/evm/CMakeLists.txt (93%) rename tools/bench/{3pc => parsec}/evm/contracts.cpp (99%) rename tools/bench/{3pc => parsec}/evm/contracts.hpp (86%) rename tools/bench/{3pc => parsec}/evm/contracts/.gitignore (100%) rename tools/bench/{3pc => parsec}/evm/contracts/README.md (58%) rename tools/bench/{3pc => parsec}/evm/contracts/contracts/ERC20.sol (100%) rename tools/bench/{3pc => parsec}/evm/contracts/gen_header.py (94%) rename tools/bench/{3pc => parsec}/evm/contracts/hardhat.config.js (100%) rename tools/bench/{3pc => parsec}/evm/contracts/package.json (82%) rename tools/bench/{3pc => parsec}/evm/contracts/pnpm-lock.yaml (100%) rename tools/bench/{3pc => parsec}/evm/evm_bench.cpp (79%) rename tools/bench/{3pc => parsec}/evm/evm_bench.hpp (94%) rename tools/bench/{3pc => parsec}/evm/main.cpp (97%) rename tools/bench/{3pc => parsec}/evm/rpc_client.cpp (96%) rename tools/bench/{3pc => parsec}/evm/rpc_client.hpp (89%) rename tools/bench/{3pc => parsec}/lua/CMakeLists.txt (94%) rename tools/bench/{3pc => parsec}/lua/lua_bench.cpp (91%) rename tools/bench/{3pc => parsec}/lua/wallet.cpp (98%) rename tools/bench/{3pc => parsec}/lua/wallet.hpp (94%) diff --git a/Dockerfile b/Dockerfile index 3cad7ca6c..5ee30d0b8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -76,20 +76,20 @@ COPY --from=builder /opt/tx-processor/build/src/uhs/client/client-cli ./build/sr # Copy atomizer config COPY --from=builder /opt/tx-processor/atomizer-compose.cfg ./atomizer-compose.cfg -# Create 3PC Deployment Image -FROM $IMAGE_VERSION AS threepc +# Create PArSEC Deployment Image +FROM $IMAGE_VERSION AS parsec # Set working directory WORKDIR /opt/tx-processor # Only copy essential binaries -COPY --from=builder /opt/tx-processor/build/src/3pc/agent/agentd ./build/src/3pc/agent/agentd -COPY --from=builder /opt/tx-processor/build/src/3pc/runtime_locking_shard/runtime_locking_shardd ./build/src/3pc/runtime_locking_shard/runtime_locking_shardd -COPY --from=builder /opt/tx-processor/build/src/3pc/ticket_machine/ticket_machined ./build/src/3pc/ticket_machine/ticket_machined +COPY --from=builder /opt/tx-processor/build/src/parsec/agent/agentd ./build/src/parsec/agent/agentd +COPY --from=builder /opt/tx-processor/build/src/parsec/runtime_locking_shard/runtime_locking_shardd ./build/src/parsec/runtime_locking_shard/runtime_locking_shardd +COPY --from=builder /opt/tx-processor/build/src/parsec/ticket_machine/ticket_machined ./build/src/parsec/ticket_machine/ticket_machined # Copy load generators -COPY --from=builder /opt/tx-processor/build/tools/bench/3pc/evm/evm_bench ./build/tools/bench/3pc/evm/evm_bench -COPY --from=builder /opt/tx-processor/build/tools/bench/3pc/lua/lua_bench ./build/tools/bench/3pc/lua/lua_bench +COPY --from=builder /opt/tx-processor/build/tools/bench/parsec/evm/evm_bench ./build/tools/bench/parsec/evm/evm_bench +COPY --from=builder /opt/tx-processor/build/tools/bench/parsec/lua/lua_bench ./build/tools/bench/parsec/lua/lua_bench # Copy wait script COPY --from=builder /opt/tx-processor/scripts/wait-for-it.sh ./scripts/wait-for-it.sh diff --git a/README.md b/README.md index f4a0dc6ed..3dee15f7c 100644 --- a/README.md +++ b/README.md @@ -40,20 +40,20 @@ There are two UHS-based architectures as follows: Read the [2PC & Atomizer architecture guide](docs/uhs-architectures.md) for a detailed description of the system components and implementation of each architecture. -## Generic Smart Contract Platform ("3PC") -We built a system that is capable of performing parallel executions of generic smart contracts. +## Parallel Architecture for Scalably Executing smart Contracts ("PArSEC") +We built a system with a generic virtual machine layer that is capable of performing parallel executions of smart contracts. The architecture is composed of two layers: 1. A distributed key-value data store with [ACID](https://en.wikipedia.org/wiki/ACID) database properties - This back-end data store is not constrained to any type of data and is agnostic to the execution later. -1. A generic computation layer that executes programs (i.e. smart contracts) and uses the back-end database to store state +1. A generic virtual machine layer that executes programs (i.e. smart contracts) and uses the distributed key-value data store to record state - This computation layer defines the data models and transaction semantics. - - We have implemented EVM and Lua as two working examples. + - We have implemented the Ethereum Virtual Machine EVM and a Lua based virtual machine as two working examples. -This architecture enables parallel execution of smart contracts (where keys are independent). -Therefore throughput is horizontally scalable with additional servers. +- This architecture enables parallel execution of smart contracts which can be scaled horizontally where keys are independent. +- Unmodified smart contracts from the Ethereum ecosystem can be deployed directly onto our EVM implementation. -Read the [Programmability Architecture Guide](docs/programmability_architecture.md) for more details. +Read the [PArSEC Architecture Guide](docs/parsec_architecture.md) for more details. # Contributing You can [sign up](https://dci.mit.edu/opencbdc-interest) to receive updates from technical working groups and to learn more about our work. @@ -93,8 +93,8 @@ Note that if you have not already installed the xcode cli tools you will need to ## UHS-based Architectures (2PC & Atomizer) See the [2PC & Atomizer User Guide](docs/2pc_atomizer_user_guide.md) -## Programmability Architecture -See the [Programmability User Guide](docs/programmability_user_guide.md) +## PArSEC Architecture +See the [PArSEC User Guide](docs/parsec_user_guide.md) # Testing Running Unit & Integration Tests diff --git a/docker-compose-3pc.yml b/docker-compose-3pc.yml deleted file mode 100644 index 043f34643..000000000 --- a/docker-compose-3pc.yml +++ /dev/null @@ -1,57 +0,0 @@ -version: '3' - -services: - - agent0: - build: - context: . - target: threepc - image: opencbdc-tx-threepc - tty: true - restart: always - command: ./scripts/wait-for-it.sh -s ticket0:7777 -t 60 -- ./scripts/wait-for-it.sh -s shard0:5556 -t 60 -- ./build/src/3pc/agent/agentd --shard_count=1 --shard0_count=1 --shard00_endpoint=shard0:5556 --node_id=0 --component_id=0 --agent_count=1 --agent0_endpoint=agent0:8080 --ticket_machine_count=1 --ticket_machine0_endpoint=ticket0:7777 --loglevel=WARN --runner_type="evm" - ports: - - 8080:8080 - networks: - - 3pc-network - healthcheck: - test: ["CMD-SHELL", "netstat -ltn | grep -c 6666"] - interval: 30s - timeout: 10s - retries: 5 - - ticket0: - build: - context: . - target: threepc - image: opencbdc-tx-threepc - tty: true - command: ./scripts/wait-for-it.sh -s shard0:5556 -t 60 -- ./build/src/3pc/ticket_machine/ticket_machined --shard_count=1 --shard0_count=1 --shard00_endpoint=shard0:5556 --node_id=0 --component_id=0 --agent_count=1 --agent0_endpoint=agent0:6666 --ticket_machine_count=1 --ticket_machine0_endpoint=ticket0:7777 --loglevel=WARN - networks: - - 3pc-network - healthcheck: - test: ["CMD-SHELL", "netstat -ltn | grep -c 7777"] - interval: 30s - timeout: 10s - retries: 5 - restart: always - - shard0: - build: - context: . - target: threepc - image: opencbdc-tx-threepc - tty: true - command: ./build/src/3pc/runtime_locking_shard/runtime_locking_shardd --shard_count=1 --shard0_count=1 --shard00_endpoint=shard0:5556 --node_id=0 --component_id=0 --agent_count=1 --agent0_endpoint=agent0:6666 --ticket_machine_count=1 --ticket_machine0_endpoint=ticket0:7777 --loglevel=WARN - networks: - - 3pc-network - healthcheck: - test: ["CMD-SHELL", "netstat -ltn | grep -c 5556"] - interval: 30s - timeout: 10s - retries: 5 - restart: always - -networks: - 3pc-network: - name: 3pc-network diff --git a/docker-compose-3pc-test.yml b/docker-compose-parsec-test.yml similarity index 51% rename from docker-compose-3pc-test.yml rename to docker-compose-parsec-test.yml index eb7ca9914..eeb679a15 100644 --- a/docker-compose-3pc-test.yml +++ b/docker-compose-parsec-test.yml @@ -5,12 +5,12 @@ services: loadgen0: build: context: . - target: threepc + target: parsec image: opencbdc-tx tty: true - command: ./scripts/wait-for-it.sh -s agent0:8080 -t 60 -- ./build/tools/bench/3pc/evm/evm_bench --shard_count=1 --shard0_count=1 --shard00_endpoint=shard0:5556 --node_id=0 --component_id=0 --agent_count=1 --agent0_endpoint=agent0:8080 --ticket_machine_count=1 --ticket_machine0_endpoint=ticket0:7777 --loadgen_accounts=8192 --loadgen_txtype=erc20 --telemetry=1 + command: ./scripts/wait-for-it.sh -s agent0:8080 -t 60 -- ./build/tools/bench/parsec/evm/evm_bench --shard_count=1 --shard0_count=1 --shard00_endpoint=shard0:5556 --node_id=0 --component_id=0 --agent_count=1 --agent0_endpoint=agent0:8080 --ticket_machine_count=1 --ticket_machine0_endpoint=ticket0:7777 --loadgen_accounts=8192 --loadgen_txtype=erc20 --telemetry=1 networks: - - 3pc-network + - parsec-network healthcheck: test: ["CMD-SHELL", "netstat -ltn | grep -c 5556"] interval: 30s @@ -21,6 +21,6 @@ services: stop_grace_period: 30s networks: - 3pc-network: - name: 3pc-network + parsec-network: + name: parsec-network driver: bridge diff --git a/docker-compose-parsec.yml b/docker-compose-parsec.yml new file mode 100644 index 000000000..fa49a1385 --- /dev/null +++ b/docker-compose-parsec.yml @@ -0,0 +1,57 @@ +version: '3' + +services: + + agent0: + build: + context: . + target: parsec + image: opencbdc-tx-parsec + tty: true + restart: always + command: ./scripts/wait-for-it.sh -s ticket0:7777 -t 60 -- ./scripts/wait-for-it.sh -s shard0:5556 -t 60 -- ./build/src/parsec/agent/agentd --shard_count=1 --shard0_count=1 --shard00_endpoint=shard0:5556 --node_id=0 --component_id=0 --agent_count=1 --agent0_endpoint=agent0:8080 --ticket_machine_count=1 --ticket_machine0_endpoint=ticket0:7777 --loglevel=WARN --runner_type="evm" + ports: + - 8080:8080 + networks: + - parsec-network + healthcheck: + test: ["CMD-SHELL", "netstat -ltn | grep -c 6666"] + interval: 30s + timeout: 10s + retries: 5 + + ticket0: + build: + context: . + target: parsec + image: opencbdc-tx-parsec + tty: true + command: ./scripts/wait-for-it.sh -s shard0:5556 -t 60 -- ./build/src/parsec/ticket_machine/ticket_machined --shard_count=1 --shard0_count=1 --shard00_endpoint=shard0:5556 --node_id=0 --component_id=0 --agent_count=1 --agent0_endpoint=agent0:6666 --ticket_machine_count=1 --ticket_machine0_endpoint=ticket0:7777 --loglevel=WARN + networks: + - parsec-network + healthcheck: + test: ["CMD-SHELL", "netstat -ltn | grep -c 7777"] + interval: 30s + timeout: 10s + retries: 5 + restart: always + + shard0: + build: + context: . + target: parsec + image: opencbdc-tx-parsec + tty: true + command: ./build/src/parsec/runtime_locking_shard/runtime_locking_shardd --shard_count=1 --shard0_count=1 --shard00_endpoint=shard0:5556 --node_id=0 --component_id=0 --agent_count=1 --agent0_endpoint=agent0:6666 --ticket_machine_count=1 --ticket_machine0_endpoint=ticket0:7777 --loglevel=WARN + networks: + - parsec-network + healthcheck: + test: ["CMD-SHELL", "netstat -ltn | grep -c 5556"] + interval: 30s + timeout: 10s + retries: 5 + restart: always + +networks: + parsec-network: + name: parsec-network diff --git a/docs/lifecycle.md b/docs/lifecycle.md index e4f7c0ffe..c3ba65e66 100644 --- a/docs/lifecycle.md +++ b/docs/lifecycle.md @@ -26,7 +26,7 @@ The [Working Groups](contributing.md#The-Hub-and-Spoke-Model) each guide one of If you're interested in contributing to an area guided by one of the Working Groups, you should attend their next meeting and propose some work you are interested in conducting. The [Leaders](contributing.md#Leader) and other Participants will discuss with you some ideas and whether or not your contribution should be pursued right now (e.g., perhaps there is other work that needs to be finished before your contribution is possible; this is an excellent opportunity to try and contribute to that effort first!). -E.g., if you're interested in implementing contingent payments (e.g., only paying someone when they've completed a bit of work for you, but cryptographically ensuring they get paid for their labor upon completion), that would most likely be under the purview of the Programmability Working Group. +E.g., if you're interested in implementing contingent payments (e.g., only paying someone when they've completed a bit of work for you, but cryptographically ensuring they get paid for their labor upon completion), that would most likely be under the purview of the PArSEC Working Group. If your contribution wouldn't fall under the purview of any of the active Working Groups, you can open a [proposal](https://github.com/mit-dci/opencbdc-tx/labels/feedback%2Fproposal) on the main repository for the [Maintainers](contributing.md#Maintainer) to review. diff --git a/docs/programmability_architecture.md b/docs/parsec_architecture.md similarity index 97% rename from docs/programmability_architecture.md rename to docs/parsec_architecture.md index 26aeb39c1..a28a23298 100644 --- a/docs/programmability_architecture.md +++ b/docs/parsec_architecture.md @@ -1,4 +1,4 @@ -# Programmability Architecture Overview +# PArSEC Architecture Overview At a high conceptual level, the architecture consists of two layers. @@ -25,7 +25,7 @@ Therefore transaction throughput is horizontally scalable with additional server For example, in contrast to the Ethereum blockchain, this system executes native value transfers and smart contract transactions (e.g. [ERC20 token](https://ethereum.org/en/developers/docs/standards/tokens/erc-20/) transfers) in parallel for independent addresses. # Architecture Diagram -![Architecture Diagram](programmability_architecture_diagram.svg) +![Architecture Diagram](PArSEC_architecture_diagram.svg) # System Components ### Agent (Transaction Coordinator) diff --git a/docs/programmability_architecture_diagram.svg b/docs/parsec_architecture_diagram.svg similarity index 100% rename from docs/programmability_architecture_diagram.svg rename to docs/parsec_architecture_diagram.svg diff --git a/docs/programmability_system_diagram_detailed.svg b/docs/parsec_system_diagram_detailed.svg similarity index 100% rename from docs/programmability_system_diagram_detailed.svg rename to docs/parsec_system_diagram_detailed.svg diff --git a/docs/programmability_user_guide.md b/docs/parsec_user_guide.md similarity index 88% rename from docs/programmability_user_guide.md rename to docs/parsec_user_guide.md index bcf969bbf..45c853cea 100644 --- a/docs/programmability_user_guide.md +++ b/docs/parsec_user_guide.md @@ -1,6 +1,6 @@ -# Programmability User Guide +# PArSEC User Guide -This guide runs through setting up the 3PC system with the EVM runner, and then interacting with it using Hardhat and MetaMask. This assumes that the system has been set up as described in the [README](https://github.com/mit-dci/opencbdc-tx#readme). +This guide runs through setting up the PArSEC system with the EVM runner, and then interacting with it using Hardhat and MetaMask. This assumes that the system has been set up as described in the [README](https://github.com/mit-dci/opencbdc-tx#readme). ## Prerequisites @@ -11,11 +11,11 @@ We also provide a [.nvmrc](https://github.com/mit-dci/opencbdc-tx/blob/trunk/.nv ### Run with Docker Spawns an agent running the EVM runner by default. -Lua runner may be used by modifying the --runner_type flag in the command keyed by agent0, in the file [`docker-compose-3pc.yml`](https://github.com/mit-dci/opencbdc-tx/blob/trunk/docker-compose-3pc.yml). +Lua runner may be used by modifying the --runner_type flag in the command keyed by agent0, in the file [`docker-compose-PArSEC.yml`](https://github.com/mit-dci/opencbdc-tx/blob/trunk/docker-compose-PArSEC.yml). ### Start it up ```console -# docker compose -f docker-compose-3pc.yml up -d +# docker compose -f docker-compose-PArSEC.yml up -d ``` The agent is now available on `http://localhost:8080/`. @@ -27,7 +27,7 @@ If you are using MacOS or an Ubuntu-like distribution, you can run the system wi Build and run the system: ```console $ ./scripts/build.sh -$ ./scripts/3pc-run-local.sh [OPTIONS] # use --help flag for help +$ ./scripts/PArSEC-run-local.sh [OPTIONS] # use --help flag for help ``` The agent is now available on the specified IP address and port (defaults to localhost:8888). @@ -40,7 +40,7 @@ Follow below for a demo. Go to a new separate directory and run `npm init` and `npm install --save-dev hardhat @nomiclabs/hardhat-waffle`: ```console -$ mkdir 3pc-playground && cd 3pc-playground +$ mkdir PArSEC-playground && cd PArSEC-playground $ npm init # all fields may be left as defaults (or blank) $ npm install --save-dev hardhat @nomiclabs/hardhat-waffle ``` @@ -61,9 +61,9 @@ However, to use the Hardhat compiler, all Solidity files should be stored in the Copy the example [hardhat.config.js](https://github.com/mit-dci/opencbdc-tx/blob/trunk/scripts/hardhat.config.js) into this directory. Edit the `url:` value in the `hardhat.config.js` file to correspond with the url of the agent RPC server. -Using Docker this will be `http://localhost:8080/`. If running outside of Docker, use the IP and port specified when running `./scripts/3pc-run-local.sh` (default is `http://localhost:8888/`). +Using Docker this will be `http://localhost:8080/`. If running outside of Docker, use the IP and port specified when running `./scripts/PArSEC-run-local.sh` (default is `http://localhost:8888/`). -Note: the value in the `accounts` array is the private key of one of the hard-coded, pre-minted accounts in 3PC/EVM. +Note: the value in the `accounts` array is the private key of one of the hard-coded, pre-minted accounts in PArSEC/EVM. You should now be able to use the Hardhat console. @@ -118,7 +118,7 @@ Note: To compile the example contract, `@openzeppelin/contracts` is a required i ```console $ npm install @openzeppelin/contracts ``` -Create a deploy script for the token. An example is provided in [opencbdc-tx/scripts/deploy.js](https://github.com/mit-dci/opencbdc-tx/blob/trunk/docs/programmability_user_guide.md). +Create a deploy script for the token. An example is provided in [opencbdc-tx/scripts/deploy.js](https://github.com/mit-dci/opencbdc-tx/blob/trunk/docs/PArSEC_user_guide.md). As written, this script requires the name of the ERC20 token to be changed to match the name of the token which is to be deployed. Note: When the Hardhat project was initialized, a `scripts/deploy.js` file was created. diff --git a/scripts/configure.sh b/scripts/configure.sh index 9a2118dd3..62b9207ca 100755 --- a/scripts/configure.sh +++ b/scripts/configure.sh @@ -108,7 +108,7 @@ $SUDO make install cd .. if [[ "$OSTYPE" != "darwin"* ]]; then - # For Mac Silicon: this curl install creates problems for building tools/bench/3pc/evm/ + # For Mac Silicon: this curl install creates problems for building tools/bench/parsec/evm/ CURL_VERSION="7.83.1" wget https://curl.se/download/curl-${CURL_VERSION}.tar.gz rm -rf curl-${CURL_VERSION} diff --git a/scripts/3pc-run-local.sh b/scripts/parsec-run-local.sh similarity index 88% rename from scripts/3pc-run-local.sh rename to scripts/parsec-run-local.sh index 60251f671..643cc79e0 100755 --- a/scripts/3pc-run-local.sh +++ b/scripts/parsec-run-local.sh @@ -6,7 +6,7 @@ RUNNER_TYPE="evm" LOGLEVEL="WARN" function print_help() { - echo "Usage: 3pc-run-local.sh [OPTIONS]" + echo "Usage: parsec-run-local.sh [OPTIONS]" echo "" echo "OPTIONS:" echo " --ip The IP address to use. Default is localhost." @@ -41,7 +41,7 @@ echo Running agent on $IP:$PORT echo Log level = $LOGLEVEL echo Runner type = $RUNNER_TYPE -./build/src/3pc/runtime_locking_shard/runtime_locking_shardd --shard_count=1 \ +./build/src/parsec/runtime_locking_shard/runtime_locking_shardd --shard_count=1 \ --shard0_count=1 --shard00_endpoint=$IP:5556 \ --shard00_raft_endpoint=$IP:5557 --node_id=0 --component_id=0 \ --agent_count=1 --agent0_endpoint=$IP:6666 --ticket_machine_count=1 \ @@ -49,14 +49,14 @@ echo Runner type = $RUNNER_TYPE > logs/shardd.log & sleep 1 ./scripts/wait-for-it.sh -s $IP:5556 -t 60 -- \ - ./build/src/3pc/ticket_machine/ticket_machined --shard_count=1 \ + ./build/src/parsec/ticket_machine/ticket_machined --shard_count=1 \ --shard0_count=1 --shard00_endpoint=$IP:5556 --node_id=0 \ --component_id=0 --agent_count=1 --agent0_endpoint=$IP:6666 \ --ticket_machine_count=1 --ticket_machine0_endpoint=$IP:7777 \ --loglevel=$LOGLEVEL > logs/ticket_machined.log & sleep 1 ./scripts/wait-for-it.sh -s $IP:7777 -t 60 -- ./scripts/wait-for-it.sh -s \ - $IP:5556 -t 60 -- ./build/src/3pc/agent/agentd --shard_count=1 \ + $IP:5556 -t 60 -- ./build/src/parsec/agent/agentd --shard_count=1 \ --shard0_count=1 --shard00_endpoint=$IP:5556 --node_id=0 --component_id=0 \ --agent_count=1 --agent0_endpoint=$IP:$PORT --ticket_machine_count=1 \ --ticket_machine0_endpoint=$IP:7777 --loglevel=$LOGLEVEL \ diff --git a/src/3pc/agent/runners/evm/format.hpp b/src/3pc/agent/runners/evm/format.hpp deleted file mode 100644 index bf5928afd..000000000 --- a/src/3pc/agent/runners/evm/format.hpp +++ /dev/null @@ -1,90 +0,0 @@ -// Copyright (c) 2022 MIT Digital Currency Initiative, -// Federal Reserve Bank of Boston -// Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. - -#ifndef OPENCBDC_TX_SRC_3PC_AGENT_RUNNERS_EVM_FORMAT_H_ -#define OPENCBDC_TX_SRC_3PC_AGENT_RUNNERS_EVM_FORMAT_H_ - -#include "messages.hpp" -#include "util/serialization/serializer.hpp" - -namespace cbdc { - auto operator<<(serializer& ser, - const threepc::agent::runner::evm_account& acc) - -> serializer&; - auto operator>>(serializer& deser, - threepc::agent::runner::evm_account& acc) -> serializer&; - - auto operator<<(serializer& ser, const evmc::address& addr) -> serializer&; - auto operator>>(serializer& deser, evmc::address& addr) -> serializer&; - - auto operator<<(serializer& ser, const evmc::bytes32& b) -> serializer&; - auto operator>>(serializer& deser, evmc::bytes32& b) -> serializer&; - - auto operator<<(serializer& ser, const threepc::agent::runner::evm_tx& tx) - -> serializer&; - auto operator>>(serializer& deser, threepc::agent::runner::evm_tx& tx) - -> serializer&; - - auto operator<<(serializer& ser, const threepc::agent::runner::evm_sig& s) - -> serializer&; - auto operator>>(serializer& deser, threepc::agent::runner::evm_sig& s) - -> serializer&; - - auto operator<<(serializer& ser, - const threepc::agent::runner::evm_access_tuple& at) - -> serializer&; - auto operator>>(serializer& deser, - threepc::agent::runner::evm_access_tuple& at) - -> serializer&; - - auto operator<<(serializer& ser, const threepc::agent::runner::evm_log& l) - -> serializer&; - auto operator>>(serializer& deser, threepc::agent::runner::evm_log& l) - -> serializer&; - - auto operator<<(serializer& ser, - const threepc::agent::runner::evm_tx_receipt& r) - -> serializer&; - auto operator>>(serializer& deser, - threepc::agent::runner::evm_tx_receipt& r) -> serializer&; - - auto operator<<(serializer& ser, const threepc::agent::runner::code_key& k) - -> serializer&; - auto operator>>(serializer& deser, threepc::agent::runner::code_key& k) - -> serializer&; - - auto operator<<(serializer& ser, - const threepc::agent::runner::storage_key& k) - -> serializer&; - auto operator>>(serializer& deser, threepc::agent::runner::storage_key& k) - -> serializer&; - auto operator<<(serializer& ser, - const threepc::agent::runner::evm_dryrun_tx& tx) - -> serializer&; - - auto operator>>(serializer& deser, - threepc::agent::runner::evm_dryrun_tx& tx) -> serializer&; - - auto operator>>(serializer& deser, - threepc::agent::runner::evm_pretend_block& b) - -> serializer&; - auto operator<<(serializer& ser, - const threepc::agent::runner::evm_pretend_block& b) - -> serializer&; - - auto operator>>(serializer& deser, - threepc::agent::runner::evm_log_query& lq) -> serializer&; - auto operator<<(serializer& ser, - const threepc::agent::runner::evm_log_query& lq) - -> serializer&; - - auto operator>>(serializer& deser, - threepc::agent::runner::evm_log_index& idx) -> serializer&; - auto operator<<(serializer& ser, - const threepc::agent::runner::evm_log_index& idx) - -> serializer&; -} - -#endif diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 320194569..35ba6b63a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -6,4 +6,4 @@ add_compile_options(-Wconversion) add_subdirectory(uhs) add_subdirectory(util) -add_subdirectory(3pc) +add_subdirectory(parsec) diff --git a/src/3pc/CMakeLists.txt b/src/parsec/CMakeLists.txt similarity index 79% rename from src/3pc/CMakeLists.txt rename to src/parsec/CMakeLists.txt index ee083767c..97f8d8ff5 100644 --- a/src/3pc/CMakeLists.txt +++ b/src/parsec/CMakeLists.txt @@ -1,8 +1,8 @@ -project(3pc) +project(parsec) include_directories(.) -add_library(threepc util.cpp) +add_library(parsec util.cpp) add_subdirectory(ticket_machine) add_subdirectory(runtime_locking_shard) diff --git a/src/3pc/agent/CMakeLists.txt b/src/parsec/agent/CMakeLists.txt similarity index 96% rename from src/3pc/agent/CMakeLists.txt rename to src/parsec/agent/CMakeLists.txt index 9bf946088..dd10b413e 100644 --- a/src/3pc/agent/CMakeLists.txt +++ b/src/parsec/agent/CMakeLists.txt @@ -13,7 +13,7 @@ target_link_libraries(agentd broker directory ticket_machine runtime_locking_shard - threepc + parsec evm_runner lua_runner agent diff --git a/src/3pc/agent/agentd.cpp b/src/parsec/agent/agentd.cpp similarity index 75% rename from src/3pc/agent/agentd.cpp rename to src/parsec/agent/agentd.cpp index a2590328f..c4b1295e0 100644 --- a/src/3pc/agent/agentd.cpp +++ b/src/parsec/agent/agentd.cpp @@ -31,7 +31,7 @@ auto main(int argc, char** argv) -> int { auto sha2_impl = SHA256AutoDetect(); log->info("using sha2: ", sha2_impl); - auto cfg = cbdc::threepc::read_config(argc, argv); + auto cfg = cbdc::parsec::read_config(argc, argv); if(!cfg.has_value()) { log->error("Error parsing options"); return 1; @@ -47,10 +47,10 @@ auto main(int argc, char** argv) -> int { log->info("Connecting to shards..."); auto shards = std::vector< - std::shared_ptr>(); + std::shared_ptr>(); for(const auto& shard_ep : cfg->m_shard_endpoints) { auto client = std::make_shared< - cbdc::threepc::runtime_locking_shard::rpc::client>( + cbdc::parsec::runtime_locking_shard::rpc::client>( std::vector{shard_ep}); if(!client->init()) { log->error("Error connecting to shard"); @@ -62,7 +62,7 @@ auto main(int argc, char** argv) -> int { log->info("Connected to shards, connecting to ticketer..."); auto ticketer - = std::make_shared( + = std::make_shared( std::vector{ cfg->m_ticket_machine_endpoints}); if(!ticketer->init()) { @@ -71,20 +71,20 @@ auto main(int argc, char** argv) -> int { } auto directory - = std::make_shared(shards.size()); + = std::make_shared(shards.size()); auto broker - = std::make_shared(cfg->m_component_id, - shards, - ticketer, - directory, - log); + = std::make_shared(cfg->m_component_id, + shards, + ticketer, + directory, + log); log->info("Requesting broker recovery..."); auto recover_success = std::promise(); auto recover_fut = recover_success.get_future(); auto success = broker->recover( - [&](cbdc::threepc::broker::interface::recover_return_type res) { + [&](cbdc::parsec::broker::interface::recover_return_type res) { recover_success.set_value(!res.has_value()); }); if(!success) { @@ -104,11 +104,11 @@ auto main(int argc, char** argv) -> int { return 1; } - if(cfg->m_runner_type == cbdc::threepc::runner_type::evm) { + if(cfg->m_runner_type == cbdc::parsec::runner_type::evm) { if(cfg->m_component_id == 0) { auto res - = cbdc::threepc::agent::runner::mint_initial_accounts(log, - broker); + = cbdc::parsec::agent::runner::mint_initial_accounts(log, + broker); if(!res) { log->error("Error minting initial accounts"); return 1; @@ -121,23 +121,23 @@ auto main(int argc, char** argv) -> int { } auto server - = std::unique_ptr(); + = std::unique_ptr(); - if(cfg->m_runner_type == cbdc::threepc::runner_type::lua) { + if(cfg->m_runner_type == cbdc::parsec::runner_type::lua) { auto rpc_server = std::make_unique< - cbdc::rpc::async_tcp_server>( + cbdc::rpc::async_tcp_server>( cfg->m_agent_endpoints[cfg->m_component_id]); - server = std::make_unique( + server = std::make_unique( std::move(rpc_server), broker, log, cfg.value()); - } else if(cfg->m_runner_type == cbdc::threepc::runner_type::evm) { + } else if(cfg->m_runner_type == cbdc::parsec::runner_type::evm) { auto rpc_server = std::make_unique( cfg->m_agent_endpoints[cfg->m_component_id], true); - server = std::make_unique( + server = std::make_unique( std::move(rpc_server), broker, log, diff --git a/src/3pc/agent/client.cpp b/src/parsec/agent/client.cpp similarity index 96% rename from src/3pc/agent/client.cpp rename to src/parsec/agent/client.cpp index ec4e5767f..18efaa7f1 100644 --- a/src/3pc/agent/client.cpp +++ b/src/parsec/agent/client.cpp @@ -8,7 +8,7 @@ #include "format.hpp" #include "util/serialization/format.hpp" -namespace cbdc::threepc::agent::rpc { +namespace cbdc::parsec::agent::rpc { client::client(std::vector endpoints) : m_client(std::make_unique( std::move(endpoints))) {} diff --git a/src/3pc/agent/client.hpp b/src/parsec/agent/client.hpp similarity index 93% rename from src/3pc/agent/client.hpp rename to src/parsec/agent/client.hpp index d2f4e3640..b104a15ce 100644 --- a/src/3pc/agent/client.hpp +++ b/src/parsec/agent/client.hpp @@ -3,14 +3,14 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#ifndef OPENCBDC_TX_SRC_3PC_AGENT_CLIENT_H_ -#define OPENCBDC_TX_SRC_3PC_AGENT_CLIENT_H_ +#ifndef OPENCBDC_TX_SRC_PARSEC_AGENT_CLIENT_H_ +#define OPENCBDC_TX_SRC_PARSEC_AGENT_CLIENT_H_ #include "interface.hpp" #include "messages.hpp" #include "util/rpc/tcp_client.hpp" -namespace cbdc::threepc::agent::rpc { +namespace cbdc::parsec::agent::rpc { /// RPC client for an agent. class client { public: diff --git a/src/3pc/agent/format.cpp b/src/parsec/agent/format.cpp similarity index 78% rename from src/3pc/agent/format.cpp rename to src/parsec/agent/format.cpp index 9e3369313..0644b8c1f 100644 --- a/src/3pc/agent/format.cpp +++ b/src/parsec/agent/format.cpp @@ -8,12 +8,12 @@ #include "util/serialization/format.hpp" namespace cbdc { - auto operator<<(serializer& ser, const threepc::agent::rpc::request& req) + auto operator<<(serializer& ser, const parsec::agent::rpc::request& req) -> serializer& { return ser << req.m_function << req.m_param << req.m_is_readonly_run; } - auto operator>>(serializer& deser, threepc::agent::rpc::request& req) + auto operator>>(serializer& deser, parsec::agent::rpc::request& req) -> serializer& { return deser >> req.m_function >> req.m_param >> req.m_is_readonly_run; } diff --git a/src/3pc/agent/format.hpp b/src/parsec/agent/format.hpp similarity index 61% rename from src/3pc/agent/format.hpp rename to src/parsec/agent/format.hpp index c5aec45b6..fc27f18ab 100644 --- a/src/3pc/agent/format.hpp +++ b/src/parsec/agent/format.hpp @@ -3,16 +3,16 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#ifndef OPENCBDC_TX_SRC_3PC_AGENT_FORMAT_H_ -#define OPENCBDC_TX_SRC_3PC_AGENT_FORMAT_H_ +#ifndef OPENCBDC_TX_SRC_PARSEC_AGENT_FORMAT_H_ +#define OPENCBDC_TX_SRC_PARSEC_AGENT_FORMAT_H_ #include "messages.hpp" #include "util/serialization/serializer.hpp" namespace cbdc { - auto operator<<(serializer& ser, const threepc::agent::rpc::request& req) + auto operator<<(serializer& ser, const parsec::agent::rpc::request& req) -> serializer&; - auto operator>>(serializer& deser, threepc::agent::rpc::request& req) + auto operator>>(serializer& deser, parsec::agent::rpc::request& req) -> serializer&; } diff --git a/src/3pc/agent/impl.cpp b/src/parsec/agent/impl.cpp similarity index 99% rename from src/3pc/agent/impl.cpp rename to src/parsec/agent/impl.cpp index 3c1e18479..9ddaf513d 100644 --- a/src/3pc/agent/impl.cpp +++ b/src/parsec/agent/impl.cpp @@ -10,9 +10,9 @@ #include -namespace cbdc::threepc::agent { +namespace cbdc::parsec::agent { impl::impl(std::shared_ptr logger, - cbdc::threepc::config cfg, + cbdc::parsec::config cfg, runner::interface::factory_type runner_factory, std::shared_ptr broker, runtime_locking_shard::key_type function, diff --git a/src/3pc/agent/impl.hpp b/src/parsec/agent/impl.hpp similarity index 95% rename from src/3pc/agent/impl.hpp rename to src/parsec/agent/impl.hpp index 1dfa351bc..8ee71ec8c 100644 --- a/src/3pc/agent/impl.hpp +++ b/src/parsec/agent/impl.hpp @@ -3,15 +3,15 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#ifndef OPENCBDC_TX_SRC_3PC_AGENT_IMPL_H_ -#define OPENCBDC_TX_SRC_3PC_AGENT_IMPL_H_ +#ifndef OPENCBDC_TX_SRC_PARSEC_AGENT_IMPL_H_ +#define OPENCBDC_TX_SRC_PARSEC_AGENT_IMPL_H_ -#include "3pc/agent/runners/interface.hpp" -#include "3pc/broker/interface.hpp" #include "interface.hpp" +#include "parsec/agent/runners/interface.hpp" +#include "parsec/broker/interface.hpp" #include "util/common/logging.hpp" -namespace cbdc::threepc::agent { +namespace cbdc::parsec::agent { /// Implementation of an agent. class impl : public interface { public: @@ -71,7 +71,7 @@ namespace cbdc::threepc::agent { /// \param secp secp256k1 context. /// \param t_pool shared thread pool between all agents. impl(std::shared_ptr logger, - cbdc::threepc::config cfg, + cbdc::parsec::config cfg, runner::interface::factory_type runner_factory, std::shared_ptr broker, runtime_locking_shard::key_type function, @@ -106,7 +106,7 @@ namespace cbdc::threepc::agent { private: std::shared_ptr m_log; - const cbdc::threepc::config m_cfg; + const cbdc::parsec::config m_cfg; runner::interface::factory_type m_runner_factory; std::shared_ptr m_broker; std::optional m_ticket_number; diff --git a/src/3pc/agent/interface.cpp b/src/parsec/agent/interface.cpp similarity index 96% rename from src/3pc/agent/interface.cpp rename to src/parsec/agent/interface.cpp index 06304bd74..4929cc28f 100644 --- a/src/3pc/agent/interface.cpp +++ b/src/parsec/agent/interface.cpp @@ -5,7 +5,7 @@ #include "interface.hpp" -namespace cbdc::threepc::agent { +namespace cbdc::parsec::agent { interface::interface(runtime_locking_shard::key_type function, parameter_type param, exec_callback_type result_callback) diff --git a/src/3pc/agent/interface.hpp b/src/parsec/agent/interface.hpp similarity index 95% rename from src/3pc/agent/interface.hpp rename to src/parsec/agent/interface.hpp index cc942c544..dc5635c2b 100644 --- a/src/3pc/agent/interface.hpp +++ b/src/parsec/agent/interface.hpp @@ -3,12 +3,12 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#ifndef OPENCBDC_TX_SRC_3PC_AGENT_INTERFACE_H_ -#define OPENCBDC_TX_SRC_3PC_AGENT_INTERFACE_H_ +#ifndef OPENCBDC_TX_SRC_PARSEC_AGENT_INTERFACE_H_ +#define OPENCBDC_TX_SRC_PARSEC_AGENT_INTERFACE_H_ -#include "3pc/broker/interface.hpp" +#include "parsec/broker/interface.hpp" -namespace cbdc::threepc::agent { +namespace cbdc::parsec::agent { /// Type of function call parameter. using parameter_type = buffer; /// Type returned after function execution. diff --git a/src/3pc/agent/messages.hpp b/src/parsec/agent/messages.hpp similarity index 85% rename from src/3pc/agent/messages.hpp rename to src/parsec/agent/messages.hpp index 396ae64fc..4936edb46 100644 --- a/src/3pc/agent/messages.hpp +++ b/src/parsec/agent/messages.hpp @@ -3,12 +3,12 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#ifndef OPENCBDC_TX_SRC_3PC_AGENT_MESSAGES_H_ -#define OPENCBDC_TX_SRC_3PC_AGENT_MESSAGES_H_ +#ifndef OPENCBDC_TX_SRC_PARSEC_AGENT_MESSAGES_H_ +#define OPENCBDC_TX_SRC_PARSEC_AGENT_MESSAGES_H_ #include "interface.hpp" -namespace cbdc::threepc::agent::rpc { +namespace cbdc::parsec::agent::rpc { /// Agent contract execution RPC request message. struct exec_request { /// Key of function bytecode. diff --git a/src/3pc/agent/runners/CMakeLists.txt b/src/parsec/agent/runners/CMakeLists.txt similarity index 100% rename from src/3pc/agent/runners/CMakeLists.txt rename to src/parsec/agent/runners/CMakeLists.txt diff --git a/src/3pc/agent/runners/evm/CMakeLists.txt b/src/parsec/agent/runners/evm/CMakeLists.txt similarity index 94% rename from src/3pc/agent/runners/evm/CMakeLists.txt rename to src/parsec/agent/runners/evm/CMakeLists.txt index 41ab0763e..83079d53d 100644 --- a/src/3pc/agent/runners/evm/CMakeLists.txt +++ b/src/parsec/agent/runners/evm/CMakeLists.txt @@ -14,7 +14,7 @@ add_library(evm_runner address.cpp util.cpp http_server.cpp) -target_link_libraries(evm_runner threepc +target_link_libraries(evm_runner parsec ${KECCAK_LIBRARY} ${EVMC_HEX_LIBRARY} ${EVMONE_LIBRARY} diff --git a/src/3pc/agent/runners/evm/address.cpp b/src/parsec/agent/runners/evm/address.cpp similarity index 98% rename from src/3pc/agent/runners/evm/address.cpp rename to src/parsec/agent/runners/evm/address.cpp index 33f3da7b1..3d41d333c 100644 --- a/src/3pc/agent/runners/evm/address.cpp +++ b/src/parsec/agent/runners/evm/address.cpp @@ -16,7 +16,7 @@ #include #include -namespace cbdc::threepc::agent::runner { +namespace cbdc::parsec::agent::runner { auto contract_address(const evmc::address& sender, const evmc::uint256be& nonce) -> evmc::address { auto new_addr = evmc::address(); diff --git a/src/3pc/agent/runners/evm/address.hpp b/src/parsec/agent/runners/evm/address.hpp similarity index 93% rename from src/3pc/agent/runners/evm/address.hpp rename to src/parsec/agent/runners/evm/address.hpp index bb5854b1a..c7450d2b2 100644 --- a/src/3pc/agent/runners/evm/address.hpp +++ b/src/parsec/agent/runners/evm/address.hpp @@ -3,8 +3,8 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#ifndef OPENCBDC_TX_SRC_3PC_AGENT_RUNNERS_EVM_ADDRESS_H_ -#define OPENCBDC_TX_SRC_3PC_AGENT_RUNNERS_EVM_ADDRESS_H_ +#ifndef OPENCBDC_TX_SRC_PARSEC_AGENT_RUNNERS_EVM_ADDRESS_H_ +#define OPENCBDC_TX_SRC_PARSEC_AGENT_RUNNERS_EVM_ADDRESS_H_ #include "messages.hpp" #include "util/common/buffer.hpp" @@ -18,7 +18,7 @@ #include #include -namespace cbdc::threepc::agent::runner { +namespace cbdc::parsec::agent::runner { /// Calculates a contract address for the CREATE call /// keccak256(rlp([sender,nonce])) /// \param sender the sender account creating the contract diff --git a/src/3pc/agent/runners/evm/format.cpp b/src/parsec/agent/runners/evm/format.cpp similarity index 70% rename from src/3pc/agent/runners/evm/format.cpp rename to src/parsec/agent/runners/evm/format.cpp index a7ae5ffc9..c9bd8b517 100644 --- a/src/3pc/agent/runners/evm/format.cpp +++ b/src/parsec/agent/runners/evm/format.cpp @@ -9,13 +9,13 @@ namespace cbdc { auto operator<<(serializer& ser, - const threepc::agent::runner::evm_account& acc) + const parsec::agent::runner::evm_account& acc) -> serializer& { return ser << acc.m_balance << acc.m_nonce; } - auto operator>>(serializer& deser, - threepc::agent::runner::evm_account& acc) -> serializer& { + auto operator>>(serializer& deser, parsec::agent::runner::evm_account& acc) + -> serializer& { return deser >> acc.m_balance >> acc.m_nonce; } @@ -40,28 +40,28 @@ namespace cbdc { return deser; } - auto operator<<(serializer& ser, const threepc::agent::runner::evm_sig& s) + auto operator<<(serializer& ser, const parsec::agent::runner::evm_sig& s) -> serializer& { return ser << s.m_v << s.m_r << s.m_s; } - auto operator>>(serializer& deser, threepc::agent::runner::evm_sig& s) + auto operator>>(serializer& deser, parsec::agent::runner::evm_sig& s) -> serializer& { return deser >> s.m_v >> s.m_r >> s.m_s; } auto operator<<(serializer& ser, - const threepc::agent::runner::evm_access_tuple& at) + const parsec::agent::runner::evm_access_tuple& at) -> serializer& { return ser << at.m_address << at.m_storage_keys; } auto operator>>(serializer& deser, - threepc::agent::runner::evm_access_tuple& at) + parsec::agent::runner::evm_access_tuple& at) -> serializer& { return deser >> at.m_address >> at.m_storage_keys; } - auto operator<<(serializer& ser, const threepc::agent::runner::evm_tx& tx) + auto operator<<(serializer& ser, const parsec::agent::runner::evm_tx& tx) -> serializer& { return ser << tx.m_type << tx.m_to << tx.m_value << tx.m_nonce << tx.m_gas_price << tx.m_gas_limit << tx.m_gas_tip_cap @@ -69,7 +69,7 @@ namespace cbdc { << tx.m_sig; } - auto operator>>(serializer& deser, threepc::agent::runner::evm_tx& tx) + auto operator>>(serializer& deser, parsec::agent::runner::evm_tx& tx) -> serializer& { return deser >> tx.m_type >> tx.m_to >> tx.m_value >> tx.m_nonce >> tx.m_gas_price >> tx.m_gas_limit >> tx.m_gas_tip_cap @@ -77,28 +77,28 @@ namespace cbdc { } auto operator<<(serializer& ser, - const threepc::agent::runner::evm_dryrun_tx& tx) + const parsec::agent::runner::evm_dryrun_tx& tx) -> serializer& { return ser << tx.m_from << tx.m_tx; } auto operator>>(serializer& deser, - threepc::agent::runner::evm_dryrun_tx& tx) -> serializer& { + parsec::agent::runner::evm_dryrun_tx& tx) -> serializer& { return deser >> tx.m_from >> tx.m_tx; } - auto operator<<(serializer& ser, const threepc::agent::runner::evm_log& l) + auto operator<<(serializer& ser, const parsec::agent::runner::evm_log& l) -> serializer& { return ser << l.m_addr << l.m_data << l.m_topics; } - auto operator>>(serializer& deser, threepc::agent::runner::evm_log& l) + auto operator>>(serializer& deser, parsec::agent::runner::evm_log& l) -> serializer& { return deser >> l.m_addr >> l.m_data >> l.m_topics; } auto operator<<(serializer& ser, - const threepc::agent::runner::evm_tx_receipt& r) + const parsec::agent::runner::evm_tx_receipt& r) -> serializer& { return ser << r.m_tx << r.m_create_address << r.m_gas_used << r.m_logs << r.m_output_data << r.m_ticket_number << r.m_timestamp @@ -106,63 +106,62 @@ namespace cbdc { } auto operator>>(serializer& deser, - threepc::agent::runner::evm_tx_receipt& r) -> serializer& { + parsec::agent::runner::evm_tx_receipt& r) -> serializer& { return deser >> r.m_tx >> r.m_create_address >> r.m_gas_used >> r.m_logs >> r.m_output_data >> r.m_ticket_number >> r.m_timestamp >> r.m_success; } - auto operator<<(serializer& ser, const threepc::agent::runner::code_key& k) + auto operator<<(serializer& ser, const parsec::agent::runner::code_key& k) -> serializer& { return ser << k.m_addr << uint8_t{}; } - auto operator>>(serializer& deser, threepc::agent::runner::code_key& k) + auto operator>>(serializer& deser, parsec::agent::runner::code_key& k) -> serializer& { uint8_t b{}; return deser >> k.m_addr >> b; } auto operator<<(serializer& ser, - const threepc::agent::runner::storage_key& k) + const parsec::agent::runner::storage_key& k) -> serializer& { return ser << k.m_addr << k.m_key; } - auto operator>>(serializer& deser, threepc::agent::runner::storage_key& k) + auto operator>>(serializer& deser, parsec::agent::runner::storage_key& k) -> serializer& { return deser >> k.m_addr >> k.m_key; } auto operator>>(serializer& deser, - threepc::agent::runner::evm_pretend_block& b) + parsec::agent::runner::evm_pretend_block& b) -> serializer& { return deser >> b.m_ticket_number >> b.m_transactions; } auto operator<<(serializer& ser, - const threepc::agent::runner::evm_pretend_block& b) + const parsec::agent::runner::evm_pretend_block& b) -> serializer& { return ser << b.m_ticket_number << b.m_transactions; } auto operator>>(serializer& deser, - threepc::agent::runner::evm_log_query& lq) -> serializer& { + parsec::agent::runner::evm_log_query& lq) -> serializer& { return deser >> lq.m_addresses >> lq.m_from_block >> lq.m_to_block >> lq.m_topics; } auto operator<<(serializer& ser, - const threepc::agent::runner::evm_log_query& lq) + const parsec::agent::runner::evm_log_query& lq) -> serializer& { return ser << lq.m_addresses << lq.m_from_block << lq.m_to_block << lq.m_topics; } auto operator>>(serializer& deser, - threepc::agent::runner::evm_log_index& idx) - -> serializer& { + parsec::agent::runner::evm_log_index& idx) -> serializer& { return deser >> idx.m_ticket_number >> idx.m_txid >> idx.m_logs; } auto operator<<(serializer& ser, - const threepc::agent::runner::evm_log_index& idx) + const parsec::agent::runner::evm_log_index& idx) -> serializer& { return ser << idx.m_ticket_number << idx.m_txid << idx.m_logs; } diff --git a/src/parsec/agent/runners/evm/format.hpp b/src/parsec/agent/runners/evm/format.hpp new file mode 100644 index 000000000..6c1a94ff9 --- /dev/null +++ b/src/parsec/agent/runners/evm/format.hpp @@ -0,0 +1,90 @@ +// Copyright (c) 2022 MIT Digital Currency Initiative, +// Federal Reserve Bank of Boston +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#ifndef OPENCBDC_TX_SRC_PARSEC_AGENT_RUNNERS_EVM_FORMAT_H_ +#define OPENCBDC_TX_SRC_PARSEC_AGENT_RUNNERS_EVM_FORMAT_H_ + +#include "messages.hpp" +#include "util/serialization/serializer.hpp" + +namespace cbdc { + auto operator<<(serializer& ser, + const parsec::agent::runner::evm_account& acc) + -> serializer&; + auto operator>>(serializer& deser, parsec::agent::runner::evm_account& acc) + -> serializer&; + + auto operator<<(serializer& ser, const evmc::address& addr) -> serializer&; + auto operator>>(serializer& deser, evmc::address& addr) -> serializer&; + + auto operator<<(serializer& ser, const evmc::bytes32& b) -> serializer&; + auto operator>>(serializer& deser, evmc::bytes32& b) -> serializer&; + + auto operator<<(serializer& ser, const parsec::agent::runner::evm_tx& tx) + -> serializer&; + auto operator>>(serializer& deser, parsec::agent::runner::evm_tx& tx) + -> serializer&; + + auto operator<<(serializer& ser, const parsec::agent::runner::evm_sig& s) + -> serializer&; + auto operator>>(serializer& deser, parsec::agent::runner::evm_sig& s) + -> serializer&; + + auto operator<<(serializer& ser, + const parsec::agent::runner::evm_access_tuple& at) + -> serializer&; + auto operator>>(serializer& deser, + parsec::agent::runner::evm_access_tuple& at) + -> serializer&; + + auto operator<<(serializer& ser, const parsec::agent::runner::evm_log& l) + -> serializer&; + auto operator>>(serializer& deser, parsec::agent::runner::evm_log& l) + -> serializer&; + + auto operator<<(serializer& ser, + const parsec::agent::runner::evm_tx_receipt& r) + -> serializer&; + auto operator>>(serializer& deser, + parsec::agent::runner::evm_tx_receipt& r) -> serializer&; + + auto operator<<(serializer& ser, const parsec::agent::runner::code_key& k) + -> serializer&; + auto operator>>(serializer& deser, parsec::agent::runner::code_key& k) + -> serializer&; + + auto operator<<(serializer& ser, + const parsec::agent::runner::storage_key& k) + -> serializer&; + auto operator>>(serializer& deser, parsec::agent::runner::storage_key& k) + -> serializer&; + auto operator<<(serializer& ser, + const parsec::agent::runner::evm_dryrun_tx& tx) + -> serializer&; + + auto operator>>(serializer& deser, + parsec::agent::runner::evm_dryrun_tx& tx) -> serializer&; + + auto operator>>(serializer& deser, + parsec::agent::runner::evm_pretend_block& b) + -> serializer&; + auto operator<<(serializer& ser, + const parsec::agent::runner::evm_pretend_block& b) + -> serializer&; + + auto operator>>(serializer& deser, + parsec::agent::runner::evm_log_query& lq) -> serializer&; + auto operator<<(serializer& ser, + const parsec::agent::runner::evm_log_query& lq) + -> serializer&; + + auto operator>>(serializer& deser, + parsec::agent::runner::evm_log_index& idx) -> serializer&; + auto operator<<(serializer& ser, + const parsec::agent::runner::evm_log_index& idx) + -> serializer&; +} + +#endif diff --git a/src/3pc/agent/runners/evm/hash.cpp b/src/parsec/agent/runners/evm/hash.cpp similarity index 100% rename from src/3pc/agent/runners/evm/hash.cpp rename to src/parsec/agent/runners/evm/hash.cpp diff --git a/src/3pc/agent/runners/evm/hash.hpp b/src/parsec/agent/runners/evm/hash.hpp similarity index 78% rename from src/3pc/agent/runners/evm/hash.hpp rename to src/parsec/agent/runners/evm/hash.hpp index 15b8f5001..9b01520bf 100644 --- a/src/3pc/agent/runners/evm/hash.hpp +++ b/src/parsec/agent/runners/evm/hash.hpp @@ -3,8 +3,8 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#ifndef OPENCBDC_TX_SRC_3PC_AGENT_RUNNERS_EVM_HASH_H_ -#define OPENCBDC_TX_SRC_3PC_AGENT_RUNNERS_EVM_HASH_H_ +#ifndef OPENCBDC_TX_SRC_PARSEC_AGENT_RUNNERS_EVM_HASH_H_ +#define OPENCBDC_TX_SRC_PARSEC_AGENT_RUNNERS_EVM_HASH_H_ #include #include @@ -18,4 +18,4 @@ namespace cbdc { auto keccak_data(const void* data, size_t len) -> hash_t; } -#endif // OPENCBDC_TX_SRC_3PC_AGENT_RUNNERS_EVM_HASH_H_ +#endif // OPENCBDC_TX_SRC_PARSEC_AGENT_RUNNERS_EVM_HASH_H_ diff --git a/src/3pc/agent/runners/evm/host.cpp b/src/parsec/agent/runners/evm/host.cpp similarity index 99% rename from src/3pc/agent/runners/evm/host.cpp rename to src/parsec/agent/runners/evm/host.cpp index 2e06fc5a8..f0d57a3aa 100644 --- a/src/3pc/agent/runners/evm/host.cpp +++ b/src/parsec/agent/runners/evm/host.cpp @@ -19,7 +19,7 @@ #include #include -namespace cbdc::threepc::agent::runner { +namespace cbdc::parsec::agent::runner { evm_host::evm_host(std::shared_ptr log, interface::try_lock_callback_type try_lock_callback, evmc_tx_context tx_context, diff --git a/src/3pc/agent/runners/evm/host.hpp b/src/parsec/agent/runners/evm/host.hpp similarity index 96% rename from src/3pc/agent/runners/evm/host.hpp rename to src/parsec/agent/runners/evm/host.hpp index 4d007db17..7eabb9153 100644 --- a/src/3pc/agent/runners/evm/host.hpp +++ b/src/parsec/agent/runners/evm/host.hpp @@ -3,19 +3,19 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#ifndef OPENCBDC_TX_SRC_3PC_AGENT_EVM_HOST_H_ -#define OPENCBDC_TX_SRC_3PC_AGENT_EVM_HOST_H_ +#ifndef OPENCBDC_TX_SRC_PARSEC_AGENT_EVM_HOST_H_ +#define OPENCBDC_TX_SRC_PARSEC_AGENT_EVM_HOST_H_ -#include "3pc/agent/runners/evm/messages.hpp" -#include "3pc/agent/runners/interface.hpp" +#include "parsec/agent/runners/evm/messages.hpp" +#include "parsec/agent/runners/interface.hpp" #include "util/serialization/util.hpp" #include #include #include -namespace cbdc::threepc::agent::runner { - /// Implementation of the evmc::Host interface using 3PC as the backend +namespace cbdc::parsec::agent::runner { + /// Implementation of the evmc::Host interface using PARSEC as the backend /// database. Manages the cached state during contract execution to support /// committing the final state updates or reverting while still charging /// gas. diff --git a/src/3pc/agent/runners/evm/http_server.cpp b/src/parsec/agent/runners/evm/http_server.cpp similarity index 99% rename from src/3pc/agent/runners/evm/http_server.cpp rename to src/parsec/agent/runners/evm/http_server.cpp index 79b901060..c7c1cad48 100644 --- a/src/3pc/agent/runners/evm/http_server.cpp +++ b/src/parsec/agent/runners/evm/http_server.cpp @@ -5,25 +5,25 @@ #include "http_server.hpp" -#include "3pc/agent/runners/evm/format.hpp" -#include "3pc/agent/runners/evm/hash.hpp" -#include "3pc/agent/runners/evm/impl.hpp" -#include "3pc/agent/runners/evm/math.hpp" -#include "3pc/agent/runners/evm/serialization.hpp" -#include "3pc/agent/runners/evm/util.hpp" #include "impl.hpp" +#include "parsec/agent/runners/evm/format.hpp" +#include "parsec/agent/runners/evm/hash.hpp" +#include "parsec/agent/runners/evm/impl.hpp" +#include "parsec/agent/runners/evm/math.hpp" +#include "parsec/agent/runners/evm/serialization.hpp" +#include "parsec/agent/runners/evm/util.hpp" #include "util/common/hash.hpp" #include "util/serialization/format.hpp" #include -using namespace cbdc::threepc::agent::runner; +using namespace cbdc::parsec::agent::runner; -namespace cbdc::threepc::agent::rpc { +namespace cbdc::parsec::agent::rpc { http_server::http_server(std::unique_ptr srv, std::shared_ptr broker, std::shared_ptr log, - const cbdc::threepc::config& cfg) + const cbdc::parsec::config& cfg) : server_interface(std::move(broker), std::move(log), cfg), m_srv(std::move(srv)) { m_srv->register_handler_callback( @@ -714,7 +714,7 @@ namespace cbdc::threepc::agent::rpc { auto http_server::parse_evm_log_query( const Json::Value& params, const server_type::result_callback_type& callback) - -> std::optional { + -> std::optional { evm_log_query qry; auto success = extract_evm_log_query_addresses(params, callback, qry); diff --git a/src/3pc/agent/runners/evm/http_server.hpp b/src/parsec/agent/runners/evm/http_server.hpp similarity index 95% rename from src/3pc/agent/runners/evm/http_server.hpp rename to src/parsec/agent/runners/evm/http_server.hpp index bf41bf236..11969a68d 100644 --- a/src/3pc/agent/runners/evm/http_server.hpp +++ b/src/parsec/agent/runners/evm/http_server.hpp @@ -3,15 +3,15 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#ifndef OPENCBDC_TX_SRC_3PC_AGENT_HTTP_SERVER_H_ -#define OPENCBDC_TX_SRC_3PC_AGENT_HTTP_SERVER_H_ - -#include "3pc/agent/impl.hpp" -#include "3pc/agent/runners/evm/impl.hpp" -#include "3pc/agent/server_interface.hpp" -#include "3pc/broker/interface.hpp" -#include "3pc/directory/interface.hpp" +#ifndef OPENCBDC_TX_SRC_PARSEC_AGENT_HTTP_SERVER_H_ +#define OPENCBDC_TX_SRC_PARSEC_AGENT_HTTP_SERVER_H_ + #include "messages.hpp" +#include "parsec/agent/impl.hpp" +#include "parsec/agent/runners/evm/impl.hpp" +#include "parsec/agent/server_interface.hpp" +#include "parsec/broker/interface.hpp" +#include "parsec/directory/interface.hpp" #include "util/common/blocking_queue.hpp" #include "util/common/thread_pool.hpp" #include "util/rpc/http/json_rpc_http_server.hpp" @@ -20,7 +20,7 @@ #include #include -namespace cbdc::threepc::agent::rpc { +namespace cbdc::parsec::agent::rpc { /// RPC server for a agent. Manages retrying function execution if it fails /// due to a transient error. class http_server : public server_interface { @@ -37,7 +37,7 @@ namespace cbdc::threepc::agent::rpc { http_server(std::unique_ptr srv, std::shared_ptr broker, std::shared_ptr log, - const cbdc::threepc::config& cfg); + const cbdc::parsec::config& cfg); /// Stops listening for incoming connections, waits for existing /// connections to drain. @@ -192,7 +192,7 @@ namespace cbdc::threepc::agent::rpc { auto parse_evm_log_query(const Json::Value& params, const server_type::result_callback_type& callback) - -> std::optional; + -> std::optional; auto fetch_block(Json::Value params, const server_type::result_callback_type& callback, diff --git a/src/3pc/agent/runners/evm/impl.cpp b/src/parsec/agent/runners/evm/impl.cpp similarity index 99% rename from src/3pc/agent/runners/evm/impl.cpp rename to src/parsec/agent/runners/evm/impl.cpp index 4d3713351..aa4c6827a 100644 --- a/src/3pc/agent/runners/evm/impl.cpp +++ b/src/parsec/agent/runners/evm/impl.cpp @@ -16,9 +16,9 @@ #include -namespace cbdc::threepc::agent::runner { +namespace cbdc::parsec::agent::runner { evm_runner::evm_runner(std::shared_ptr logger, - const cbdc::threepc::config& cfg, + const cbdc::parsec::config& cfg, runtime_locking_shard::value_type function, parameter_type param, bool is_readonly_run, diff --git a/src/3pc/agent/runners/evm/impl.hpp b/src/parsec/agent/runners/evm/impl.hpp similarity index 95% rename from src/3pc/agent/runners/evm/impl.hpp rename to src/parsec/agent/runners/evm/impl.hpp index 1ddd56ca7..16c0a6cc8 100644 --- a/src/3pc/agent/runners/evm/impl.hpp +++ b/src/parsec/agent/runners/evm/impl.hpp @@ -3,18 +3,18 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#ifndef OPENCBDC_TX_SRC_3PC_AGENT_EVM_RUNNER_H_ -#define OPENCBDC_TX_SRC_3PC_AGENT_EVM_RUNNER_H_ +#ifndef OPENCBDC_TX_SRC_PARSEC_AGENT_EVM_RUNNER_H_ +#define OPENCBDC_TX_SRC_PARSEC_AGENT_EVM_RUNNER_H_ -#include "3pc/agent/runners/interface.hpp" -#include "3pc/util.hpp" #include "host.hpp" +#include "parsec/agent/runners/interface.hpp" +#include "parsec/util.hpp" #include #include #include -namespace cbdc::threepc::agent::runner { +namespace cbdc::parsec::agent::runner { /// Commands accepted by the EVM contract runner. enum class evm_runner_function : uint8_t { /// Execute a normal transaction. @@ -48,7 +48,7 @@ namespace cbdc::threepc::agent::runner { public: /// \copydoc interface::interface evm_runner(std::shared_ptr logger, - const cbdc::threepc::config& cfg, + const cbdc::parsec::config& cfg, runtime_locking_shard::value_type function, parameter_type param, bool is_readonly_run, diff --git a/src/3pc/agent/runners/evm/init_addresses.hpp b/src/parsec/agent/runners/evm/init_addresses.hpp similarity index 98% rename from src/3pc/agent/runners/evm/init_addresses.hpp rename to src/parsec/agent/runners/evm/init_addresses.hpp index e4ab01223..dcc8d3d2f 100644 --- a/src/3pc/agent/runners/evm/init_addresses.hpp +++ b/src/parsec/agent/runners/evm/init_addresses.hpp @@ -3,13 +3,13 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#ifndef OPENCBDC_TX_SRC_3PC_AGENT_INIT_ADDRESSES_H_ -#define OPENCBDC_TX_SRC_3PC_AGENT_INIT_ADDRESSES_H_ +#ifndef OPENCBDC_TX_SRC_PARSEC_AGENT_INIT_ADDRESSES_H_ +#define OPENCBDC_TX_SRC_PARSEC_AGENT_INIT_ADDRESSES_H_ #include #include -namespace cbdc::threepc::agent { +namespace cbdc::parsec::agent { /// List of initial addresses to mint accounts for testing const std::vector init_addresses_for_testing = {std::string("01a151cc5ed14d110cc0e6b64360913de9f453f1"), @@ -270,4 +270,4 @@ namespace cbdc::threepc::agent { std::string("0fea15f94381c47d17f758c794e19c8174bee776")}; } -#endif // OPENCBDC_TX_SRC_3PC_AGENT_INIT_ADDRESSES_H_ +#endif // OPENCBDC_TX_SRC_PARSEC_AGENT_INIT_ADDRESSES_H_ diff --git a/src/3pc/agent/runners/evm/math.cpp b/src/parsec/agent/runners/evm/math.cpp similarity index 98% rename from src/3pc/agent/runners/evm/math.cpp rename to src/parsec/agent/runners/evm/math.cpp index f6c456477..fd6dd767f 100644 --- a/src/3pc/agent/runners/evm/math.cpp +++ b/src/parsec/agent/runners/evm/math.cpp @@ -10,7 +10,7 @@ // Until std::span is available in C++20, we don't have a bounds-checked way // to access the data behind evmc::uint256be. // NOLINTBEGIN(cppcoreguidelines-pro-bounds-constant-array-index) -namespace cbdc::threepc::agent::runner { +namespace cbdc::parsec::agent::runner { auto operator+(const evmc::uint256be& lhs, const evmc::uint256be& rhs) -> evmc::uint256be { auto ret = evmc::uint256be{}; diff --git a/src/3pc/agent/runners/evm/math.hpp b/src/parsec/agent/runners/evm/math.hpp similarity index 90% rename from src/3pc/agent/runners/evm/math.hpp rename to src/parsec/agent/runners/evm/math.hpp index 639ad253b..faa87ddaf 100644 --- a/src/3pc/agent/runners/evm/math.hpp +++ b/src/parsec/agent/runners/evm/math.hpp @@ -3,12 +3,12 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#ifndef OPENCBDC_TX_SRC_3PC_AGENT_EVM_MATH_H_ -#define OPENCBDC_TX_SRC_3PC_AGENT_EVM_MATH_H_ +#ifndef OPENCBDC_TX_SRC_PARSEC_AGENT_EVM_MATH_H_ +#define OPENCBDC_TX_SRC_PARSEC_AGENT_EVM_MATH_H_ #include -namespace cbdc::threepc::agent::runner { +namespace cbdc::parsec::agent::runner { /// Adds two uint256be values. /// \param lhs first value. /// \param rhs second value. diff --git a/src/3pc/agent/runners/evm/messages.hpp b/src/parsec/agent/runners/evm/messages.hpp similarity index 93% rename from src/3pc/agent/runners/evm/messages.hpp rename to src/parsec/agent/runners/evm/messages.hpp index 61b789ea9..0798c7459 100644 --- a/src/3pc/agent/runners/evm/messages.hpp +++ b/src/parsec/agent/runners/evm/messages.hpp @@ -3,10 +3,10 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#ifndef OPENCBDC_TX_SRC_3PC_AGENT_RUNNERS_EVM_MESSAGES_H_ -#define OPENCBDC_TX_SRC_3PC_AGENT_RUNNERS_EVM_MESSAGES_H_ +#ifndef OPENCBDC_TX_SRC_PARSEC_AGENT_RUNNERS_EVM_MESSAGES_H_ +#define OPENCBDC_TX_SRC_PARSEC_AGENT_RUNNERS_EVM_MESSAGES_H_ -#include "3pc/agent/runners/interface.hpp" +#include "parsec/agent/runners/interface.hpp" #include "util/common/hash.hpp" #include @@ -15,7 +15,7 @@ #include #include -namespace cbdc::threepc::agent::runner { +namespace cbdc::parsec::agent::runner { // EVM Chain ID for OpenCBDC static constexpr uint64_t opencbdc_chain_id = 0xcbdc; @@ -120,7 +120,7 @@ namespace cbdc::threepc::agent::runner { std::vector m_output_data{}; /// Ticket number that ran this TX - needed to map /// to pretend blocks - cbdc::threepc::agent::runner::interface::ticket_number_type + cbdc::parsec::agent::runner::interface::ticket_number_type m_ticket_number {}; /// Timestamp of the transaction - needed to provide /// a timestamp in pretend blocks @@ -147,11 +147,11 @@ namespace cbdc::threepc::agent::runner { /// The topics for which logs are queried std::vector m_topics{}; /// The start of the block range to query logs for - cbdc::threepc::agent::runner::interface::ticket_number_type + cbdc::parsec::agent::runner::interface::ticket_number_type m_from_block {}; /// The end of the block range to query logs for - cbdc::threepc::agent::runner::interface::ticket_number_type - m_to_block {}; + cbdc::parsec::agent::runner::interface::ticket_number_type m_to_block { + }; }; /// Index data for evm logs. This is the value stored under a key diff --git a/src/3pc/agent/runners/evm/rlp.cpp b/src/parsec/agent/runners/evm/rlp.cpp similarity index 100% rename from src/3pc/agent/runners/evm/rlp.cpp rename to src/parsec/agent/runners/evm/rlp.cpp diff --git a/src/3pc/agent/runners/evm/rlp.hpp b/src/parsec/agent/runners/evm/rlp.hpp similarity index 96% rename from src/3pc/agent/runners/evm/rlp.hpp rename to src/parsec/agent/runners/evm/rlp.hpp index 263f244c8..ca433db48 100644 --- a/src/3pc/agent/runners/evm/rlp.hpp +++ b/src/parsec/agent/runners/evm/rlp.hpp @@ -3,8 +3,8 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#ifndef OPENCBDC_TX_SRC_3PC_AGENT_RUNNERS_EVM_RLP_H_ -#define OPENCBDC_TX_SRC_3PC_AGENT_RUNNERS_EVM_RLP_H_ +#ifndef OPENCBDC_TX_SRC_PARSEC_AGENT_RUNNERS_EVM_RLP_H_ +#define OPENCBDC_TX_SRC_PARSEC_AGENT_RUNNERS_EVM_RLP_H_ #include "format.hpp" #include "util/common/buffer.hpp" @@ -178,14 +178,14 @@ namespace cbdc { /// \param access_list the access list to encode /// \return rlp_value of type rlp_value_array with the access list as contents auto rlp_encode_access_list( - const threepc::agent::runner::evm_access_list& access_list) + const parsec::agent::runner::evm_access_list& access_list) -> rlp_value; /// Decodes an access list from and rlp_value of type rlp_value_type::array /// \param rlp rlp_value to decode from /// \return evm_access_list that was decoded or std::nullopt on failure auto rlp_decode_access_list(const rlp_value& rlp) - -> std::optional; + -> std::optional; /// Decodes a binary representation for sizes that exceed the single-byte /// presentation into size_t @@ -198,4 +198,4 @@ namespace cbdc { auto operator>>(serializer& ser, cbdc::rlp_value& v) -> serializer&; } -#endif // OPENCBDC_TX_SRC_3PC_AGENT_RUNNERS_EVM_RLP_H_ +#endif // OPENCBDC_TX_SRC_PARSEC_AGENT_RUNNERS_EVM_RLP_H_ diff --git a/src/3pc/agent/runners/evm/rlp_reader.cpp b/src/parsec/agent/runners/evm/rlp_reader.cpp similarity index 95% rename from src/3pc/agent/runners/evm/rlp_reader.cpp rename to src/parsec/agent/runners/evm/rlp_reader.cpp index be3939a33..d6fdf37cb 100644 --- a/src/3pc/agent/runners/evm/rlp_reader.cpp +++ b/src/parsec/agent/runners/evm/rlp_reader.cpp @@ -90,16 +90,16 @@ namespace cbdc { } auto rlp_decode_access_list(const rlp_value& rlp) - -> std::optional { + -> std::optional { if(rlp.type() != rlp_value_type::array) { return std::nullopt; } - auto access_list = cbdc::threepc::agent::runner::evm_access_list(); + auto access_list = cbdc::parsec::agent::runner::evm_access_list(); for(size_t i = 0; i < rlp.size(); i++) { auto rlp_tuple = rlp.value_at(i); auto access_tuple - = cbdc::threepc::agent::runner::evm_access_tuple(); + = cbdc::parsec::agent::runner::evm_access_tuple(); if(rlp_tuple.type() == rlp_value_type::array && rlp_tuple.size() == 2) { access_tuple.m_address diff --git a/src/3pc/agent/runners/evm/rlp_writer.cpp b/src/parsec/agent/runners/evm/rlp_writer.cpp similarity index 97% rename from src/3pc/agent/runners/evm/rlp_writer.cpp rename to src/parsec/agent/runners/evm/rlp_writer.cpp index 0f2173a7c..b0327455f 100644 --- a/src/3pc/agent/runners/evm/rlp_writer.cpp +++ b/src/parsec/agent/runners/evm/rlp_writer.cpp @@ -83,7 +83,7 @@ namespace cbdc { } auto rlp_encode_access_list( - const threepc::agent::runner::evm_access_list& access_list) + const parsec::agent::runner::evm_access_list& access_list) -> rlp_value { auto rlp_access_list = rlp_value(rlp_value_type::array); // empty by default diff --git a/src/3pc/agent/runners/evm/serialization.cpp b/src/parsec/agent/runners/evm/serialization.cpp similarity index 94% rename from src/3pc/agent/runners/evm/serialization.cpp rename to src/parsec/agent/runners/evm/serialization.cpp index 9e7951496..5529dc32d 100644 --- a/src/3pc/agent/runners/evm/serialization.cpp +++ b/src/parsec/agent/runners/evm/serialization.cpp @@ -17,8 +17,8 @@ #include #include -namespace cbdc::threepc::agent::runner { - auto tx_id(const cbdc::threepc::agent::runner::evm_tx& tx, +namespace cbdc::parsec::agent::runner { + auto tx_id(const cbdc::parsec::agent::runner::evm_tx& tx, uint64_t chain_id) -> cbdc::hash_t { auto tx_ser = tx_encode(tx, chain_id); return keccak_data(tx_ser.data(), tx_ser.size()); @@ -47,7 +47,7 @@ namespace cbdc::threepc::agent::runner { auto check_tx_decode( const cbdc::buffer& buf, const std::shared_ptr& logger, - const std::shared_ptr& tx) + const std::shared_ptr& tx) -> std::optional { uint8_t type_byte{}; std::memcpy(&type_byte, buf.data_at(0), 1); @@ -79,8 +79,8 @@ namespace cbdc::threepc::agent::runner { const std::shared_ptr& logger, uint64_t chain_id) -> std::optional< - std::shared_ptr> { - auto tx = std::make_shared(); + std::shared_ptr> { + auto tx = std::make_shared(); auto maybe_rlp_tx = check_tx_decode(buf, logger, tx); if(!maybe_rlp_tx.has_value()) { return std::nullopt; @@ -152,7 +152,7 @@ namespace cbdc::threepc::agent::runner { return tx; } - auto tx_encode(const cbdc::threepc::agent::runner::evm_tx& tx, + auto tx_encode(const cbdc::parsec::agent::runner::evm_tx& tx, uint64_t chain_id, bool for_sighash) -> cbdc::buffer { auto buf = cbdc::buffer(); @@ -207,14 +207,14 @@ namespace cbdc::threepc::agent::runner { auto dryrun_tx_from_json(const Json::Value& json, uint64_t chain_id) -> std::optional< - std::shared_ptr> { + std::shared_ptr> { auto tx = tx_from_json(json, chain_id); if(!tx) { return std::nullopt; } auto drtx - = std::make_shared(); + = std::make_shared(); drtx->m_tx = *tx.value(); auto maybe_from = address_from_json(json["from"]); if(maybe_from) { @@ -276,7 +276,7 @@ namespace cbdc::threepc::agent::runner { } auto raw_tx_from_json(const Json::Value& param) -> std::optional< - std::shared_ptr> { + std::shared_ptr> { if(!param.isString()) { return std::nullopt; } @@ -292,8 +292,8 @@ namespace cbdc::threepc::agent::runner { auto tx_from_json(const Json::Value& json, uint64_t /*chain_id*/) -> std::optional< - std::shared_ptr> { - auto tx = std::make_shared(); + std::shared_ptr> { + auto tx = std::make_shared(); tx->m_type = evm_tx_type::legacy; if(!json["type"].empty() && json["type"].isNumeric()) { tx->m_type = static_cast(json["type"].asInt()); @@ -334,7 +334,7 @@ namespace cbdc::threepc::agent::runner { return tx; } - auto tx_to_json(cbdc::threepc::agent::runner::evm_tx& tx, + auto tx_to_json(cbdc::parsec::agent::runner::evm_tx& tx, const std::shared_ptr& ctx) -> Json::Value { auto res = Json::Value(); @@ -383,7 +383,7 @@ namespace cbdc::threepc::agent::runner { return res; } - auto tx_receipt_to_json(cbdc::threepc::agent::runner::evm_tx_receipt& rcpt, + auto tx_receipt_to_json(cbdc::parsec::agent::runner::evm_tx_receipt& rcpt, const std::shared_ptr& ctx) -> Json::Value { auto res = Json::Value(); @@ -433,7 +433,7 @@ namespace cbdc::threepc::agent::runner { return res; } - auto tx_log_to_json(cbdc::threepc::agent::runner::evm_log& log, + auto tx_log_to_json(cbdc::parsec::agent::runner::evm_log& log, interface::ticket_number_type tn, cbdc::hash_t txid) -> Json::Value { auto res = Json::Value(); @@ -461,7 +461,7 @@ namespace cbdc::threepc::agent::runner { return res; } - auto access_list_to_json(cbdc::threepc::agent::runner::evm_access_list& al) + auto access_list_to_json(cbdc::parsec::agent::runner::evm_access_list& al) -> Json::Value { auto res = Json::Value(Json::arrayValue); for(auto& tuple : al) { diff --git a/src/3pc/agent/runners/evm/serialization.hpp b/src/parsec/agent/runners/evm/serialization.hpp similarity index 88% rename from src/3pc/agent/runners/evm/serialization.hpp rename to src/parsec/agent/runners/evm/serialization.hpp index 81bf2dd4f..69c529ca1 100644 --- a/src/3pc/agent/runners/evm/serialization.hpp +++ b/src/parsec/agent/runners/evm/serialization.hpp @@ -3,8 +3,8 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#ifndef OPENCBDC_TX_SRC_3PC_AGENT_RUNNERS_EVM_SERIALIZATION_H_ -#define OPENCBDC_TX_SRC_3PC_AGENT_RUNNERS_EVM_SERIALIZATION_H_ +#ifndef OPENCBDC_TX_SRC_PARSEC_AGENT_RUNNERS_EVM_SERIALIZATION_H_ +#define OPENCBDC_TX_SRC_PARSEC_AGENT_RUNNERS_EVM_SERIALIZATION_H_ #include "messages.hpp" #include "signature.hpp" @@ -21,7 +21,7 @@ #include #include -namespace cbdc::threepc::agent::runner { +namespace cbdc::parsec::agent::runner { static constexpr uint64_t eip155_v_offset = 35; static constexpr uint64_t pre_eip155_v_offset = 27; @@ -31,7 +31,7 @@ namespace cbdc::threepc::agent::runner { /// \param chain_id the chain ID for which to encode the transaction /// \param for_sighash use the formatting needed to calculate the sighash /// \return the rlp representation of the transaction - auto tx_encode(const cbdc::threepc::agent::runner::evm_tx& tx, + auto tx_encode(const cbdc::parsec::agent::runner::evm_tx& tx, uint64_t chain_id = opencbdc_chain_id, bool for_sighash = false) -> cbdc::buffer; @@ -46,16 +46,15 @@ namespace cbdc::threepc::agent::runner { auto tx_decode(const cbdc::buffer& buf, const std::shared_ptr& logger, uint64_t chain_id = opencbdc_chain_id) - -> std::optional< - std::shared_ptr>; + -> std::optional>; /// Converts a given Json::Value to an evm_tx /// \param param Json::Value containing the raw transaction to decode /// in (0x prefixed) hexadecimal format /// \return the evm_tx that was decoded or std::nullopt if no valid /// value could be decoded - auto raw_tx_from_json(const Json::Value& param) -> std::optional< - std::shared_ptr>; + auto raw_tx_from_json(const Json::Value& param) + -> std::optional>; /// Converts a given Json::Value to an evm_tx /// \param json Json::Value containing the transaction to decode @@ -66,8 +65,7 @@ namespace cbdc::threepc::agent::runner { /// value could be decoded auto tx_from_json(const Json::Value& json, uint64_t chain_id = opencbdc_chain_id) - -> std::optional< - std::shared_ptr>; + -> std::optional>; /// Converts a given Json::Value to an evm_dryrun_tx /// \param json Json::Value containing the transaction to decode @@ -79,7 +77,7 @@ namespace cbdc::threepc::agent::runner { auto dryrun_tx_from_json(const Json::Value& json, uint64_t chain_id = opencbdc_chain_id) -> std::optional< - std::shared_ptr>; + std::shared_ptr>; /// Converts a given Json::Value to an evmc::address /// \param addr Json::Value containing the address to decode. Is expected @@ -124,7 +122,7 @@ namespace cbdc::threepc::agent::runner { /// \param ctx The secp256k1 context to use for deriving the from address /// \return a Json::Value containing the json representation of the /// transaction - auto tx_to_json(cbdc::threepc::agent::runner::evm_tx& tx, + auto tx_to_json(cbdc::parsec::agent::runner::evm_tx& tx, const std::shared_ptr& ctx) -> Json::Value; @@ -134,7 +132,7 @@ namespace cbdc::threepc::agent::runner { /// \param ctx The secp256k1 context to use for deriving the from address /// \return a Json::Value containing the json representation of the /// transaction receipt - auto tx_receipt_to_json(cbdc::threepc::agent::runner::evm_tx_receipt& rcpt, + auto tx_receipt_to_json(cbdc::parsec::agent::runner::evm_tx_receipt& rcpt, const std::shared_ptr& ctx) -> Json::Value; @@ -148,7 +146,7 @@ namespace cbdc::threepc::agent::runner { /// does not contain this data - so it has to be passed in. /// \return a Json::Value containing the json representation of the /// transaction log - auto tx_log_to_json(cbdc::threepc::agent::runner::evm_log& log, + auto tx_log_to_json(cbdc::parsec::agent::runner::evm_log& log, interface::ticket_number_type tn, cbdc::hash_t txid) -> Json::Value; @@ -157,14 +155,14 @@ namespace cbdc::threepc::agent::runner { /// \param al The access list to represent as json /// \return a Json::Value containing the json representation of the access /// list - auto access_list_to_json(cbdc::threepc::agent::runner::evm_access_list& al) + auto access_list_to_json(cbdc::parsec::agent::runner::evm_access_list& al) -> Json::Value; /// Calculate ethereum-compatible txid /// \param tx transaction to calculate ID for /// \param chain_id unique chain ID, defaults to 0xcbdc. /// \return the eth compatible txid of the transaction - auto tx_id(const cbdc::threepc::agent::runner::evm_tx& tx, + auto tx_id(const cbdc::parsec::agent::runner::evm_tx& tx, uint64_t chain_id = opencbdc_chain_id) -> cbdc::hash_t; } diff --git a/src/3pc/agent/runners/evm/signature.cpp b/src/parsec/agent/runners/evm/signature.cpp similarity index 96% rename from src/3pc/agent/runners/evm/signature.cpp rename to src/parsec/agent/runners/evm/signature.cpp index f1fb84bf7..86a7d73a9 100644 --- a/src/3pc/agent/runners/evm/signature.cpp +++ b/src/parsec/agent/runners/evm/signature.cpp @@ -18,7 +18,7 @@ #include #include -namespace cbdc::threepc::agent::runner { +namespace cbdc::parsec::agent::runner { auto secp256k1_ecdsa_recoverable_signature_to_evm_sig( secp256k1_ecdsa_recoverable_signature& sig, evm_tx_type type, @@ -101,7 +101,7 @@ namespace cbdc::threepc::agent::runner { chain_id); } - auto check_signature(const cbdc::threepc::agent::runner::evm_tx& tx, + auto check_signature(const cbdc::parsec::agent::runner::evm_tx& tx, const std::shared_ptr& ctx, uint64_t chain_id) -> std::optional { auto sighash = sig_hash(tx, chain_id); @@ -131,7 +131,7 @@ namespace cbdc::threepc::agent::runner { return eth_addr(pk, ctx); } - auto sig_hash(const cbdc::threepc::agent::runner::evm_tx& tx, + auto sig_hash(const cbdc::parsec::agent::runner::evm_tx& tx, uint64_t chain_id) -> hash_t { auto rlp_buf = tx_encode(tx, chain_id, true); return cbdc::keccak_data(rlp_buf.data(), rlp_buf.size()); diff --git a/src/3pc/agent/runners/evm/signature.hpp b/src/parsec/agent/runners/evm/signature.hpp similarity index 87% rename from src/3pc/agent/runners/evm/signature.hpp rename to src/parsec/agent/runners/evm/signature.hpp index 5d276cfc5..f84355daa 100644 --- a/src/3pc/agent/runners/evm/signature.hpp +++ b/src/parsec/agent/runners/evm/signature.hpp @@ -3,8 +3,8 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#ifndef OPENCBDC_TX_SRC_3PC_AGENT_RUNNERS_EVM_SIGNATURE_H_ -#define OPENCBDC_TX_SRC_3PC_AGENT_RUNNERS_EVM_SIGNATURE_H_ +#ifndef OPENCBDC_TX_SRC_PARSEC_AGENT_RUNNERS_EVM_SIGNATURE_H_ +#define OPENCBDC_TX_SRC_PARSEC_AGENT_RUNNERS_EVM_SIGNATURE_H_ #include "messages.hpp" #include "util/common/buffer.hpp" @@ -18,7 +18,7 @@ #include #include -namespace cbdc::threepc::agent::runner { +namespace cbdc::parsec::agent::runner { /// Signs a hash using a privkey_t using ecdsa and produces an evm_sig /// struct Used primarily in unit tests for signature checking /// \param key key to sign with @@ -39,7 +39,7 @@ namespace cbdc::threepc::agent::runner { /// \param ctx secp256k1 context to use /// \return the signer's address if the signature is valid and recoverable, /// nullopt otherwise - auto check_signature(const cbdc::threepc::agent::runner::evm_tx& tx, + auto check_signature(const cbdc::parsec::agent::runner::evm_tx& tx, const std::shared_ptr& ctx, uint64_t chain_id = opencbdc_chain_id) -> std::optional; @@ -48,7 +48,7 @@ namespace cbdc::threepc::agent::runner { /// \param tx transaction to calculate the sighash for /// \param chain_id unique chain ID, defaults to 0xcbdc. /// \return the sighash of the transaction - auto sig_hash(const cbdc::threepc::agent::runner::evm_tx& tx, + auto sig_hash(const cbdc::parsec::agent::runner::evm_tx& tx, uint64_t chain_id = opencbdc_chain_id) -> hash_t; } diff --git a/src/3pc/agent/runners/evm/util.cpp b/src/parsec/agent/runners/evm/util.cpp similarity index 88% rename from src/3pc/agent/runners/evm/util.cpp rename to src/parsec/agent/runners/evm/util.cpp index 05097dd49..b1fd24ffd 100644 --- a/src/3pc/agent/runners/evm/util.cpp +++ b/src/parsec/agent/runners/evm/util.cpp @@ -5,12 +5,12 @@ #include "util.hpp" -#include "3pc/util.hpp" #include "crypto/sha256.h" #include "format.hpp" #include "hash.hpp" #include "init_addresses.hpp" #include "math.hpp" +#include "parsec/util.hpp" #include "rlp.hpp" #include "util/common/hash.hpp" #include "util/serialization/util.hpp" @@ -19,7 +19,7 @@ #include #include -namespace cbdc::threepc::agent::runner { +namespace cbdc::parsec::agent::runner { auto to_uint64(const evmc::uint256be& v) -> uint64_t { return evmc::load64be(&v.bytes[sizeof(v.bytes) - sizeof(uint64_t)]); } @@ -100,10 +100,10 @@ namespace cbdc::threepc::agent::runner { auto mint_initial_accounts( const std::shared_ptr& log, - const std::shared_ptr& broker) -> bool { + const std::shared_ptr& broker) -> bool { log->info("Initializing init addresses"); - auto acc = cbdc::threepc::agent::runner::evm_account(); + auto acc = cbdc::parsec::agent::runner::evm_account(); static constexpr uint64_t decimals = 1000000000000000000; static constexpr uint64_t initial_mint = 1000000; acc.m_balance @@ -113,19 +113,19 @@ namespace cbdc::threepc::agent::runner { auto successes = std::vector>(); for(const auto& init_addr_hex : - cbdc::threepc::agent::init_addresses_for_testing) { + cbdc::parsec::agent::init_addresses_for_testing) { log->info("Seeding address ", init_addr_hex); auto init_addr = cbdc::buffer::from_hex(init_addr_hex).value(); auto seed_success = std::make_shared>(); auto seed_fut = seed_success->get_future(); successes.emplace_back(std::move(seed_fut)); auto success - = cbdc::threepc::put_row(broker, - init_addr, - acc_buf, - [seed_success](bool s) { - seed_success->set_value(s); - }); + = cbdc::parsec::put_row(broker, + init_addr, + acc_buf, + [seed_success](bool s) { + seed_success->set_value(s); + }); if(!success) { log->error("Error requesting seeding account"); return false; diff --git a/src/3pc/agent/runners/evm/util.hpp b/src/parsec/agent/runners/evm/util.hpp similarity index 91% rename from src/3pc/agent/runners/evm/util.hpp rename to src/parsec/agent/runners/evm/util.hpp index ba5a996c6..7709c35b9 100644 --- a/src/3pc/agent/runners/evm/util.hpp +++ b/src/parsec/agent/runners/evm/util.hpp @@ -3,11 +3,11 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#ifndef OPENCBDC_TX_SRC_3PC_AGENT_RUNNERS_EVM_UTIL_H_ -#define OPENCBDC_TX_SRC_3PC_AGENT_RUNNERS_EVM_UTIL_H_ +#ifndef OPENCBDC_TX_SRC_PARSEC_AGENT_RUNNERS_EVM_UTIL_H_ +#define OPENCBDC_TX_SRC_PARSEC_AGENT_RUNNERS_EVM_UTIL_H_ -#include "3pc/broker/interface.hpp" #include "messages.hpp" +#include "parsec/broker/interface.hpp" #include "util/common/buffer.hpp" #include "util/common/hash.hpp" #include "util/common/keys.hpp" @@ -20,7 +20,7 @@ #include #include -namespace cbdc::threepc::agent::runner { +namespace cbdc::parsec::agent::runner { /// Converts an uint256be to a uint64_t, ignoring higher order bits. /// \param v bignum to convert. /// \return converted bignum. @@ -82,7 +82,7 @@ namespace cbdc::threepc::agent::runner { /// \param broker broker instance to mint with. auto mint_initial_accounts( const std::shared_ptr& log, - const std::shared_ptr& broker) -> bool; + const std::shared_ptr& broker) -> bool; } #endif diff --git a/src/3pc/agent/runners/interface.cpp b/src/parsec/agent/runners/interface.cpp similarity index 92% rename from src/3pc/agent/runners/interface.cpp rename to src/parsec/agent/runners/interface.cpp index c4dac7c5c..a7636343f 100644 --- a/src/3pc/agent/runners/interface.cpp +++ b/src/parsec/agent/runners/interface.cpp @@ -5,9 +5,9 @@ #include "interface.hpp" -namespace cbdc::threepc::agent::runner { +namespace cbdc::parsec::agent::runner { interface::interface(std::shared_ptr logger, - const cbdc::threepc::config& cfg, + const cbdc::parsec::config& cfg, runtime_locking_shard::value_type function, parameter_type param, bool is_readonly_run, diff --git a/src/3pc/agent/runners/interface.hpp b/src/parsec/agent/runners/interface.hpp similarity index 92% rename from src/3pc/agent/runners/interface.hpp rename to src/parsec/agent/runners/interface.hpp index bcc5ae5c0..9557f7257 100644 --- a/src/3pc/agent/runners/interface.hpp +++ b/src/parsec/agent/runners/interface.hpp @@ -3,19 +3,19 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#ifndef OPENCBDC_TX_SRC_3PC_AGENT_RUNNERS_INTERFACE_H_ -#define OPENCBDC_TX_SRC_3PC_AGENT_RUNNERS_INTERFACE_H_ +#ifndef OPENCBDC_TX_SRC_PARSEC_AGENT_RUNNERS_INTERFACE_H_ +#define OPENCBDC_TX_SRC_PARSEC_AGENT_RUNNERS_INTERFACE_H_ -#include "3pc/agent/interface.hpp" -#include "3pc/broker/interface.hpp" -#include "3pc/runtime_locking_shard/interface.hpp" -#include "3pc/util.hpp" +#include "parsec/agent/interface.hpp" +#include "parsec/broker/interface.hpp" +#include "parsec/runtime_locking_shard/interface.hpp" +#include "parsec/util.hpp" #include "util/common/logging.hpp" #include "util/common/thread_pool.hpp" #include -namespace cbdc::threepc::agent::runner { +namespace cbdc::parsec::agent::runner { /// Interface for a contract runner. Subclasses should implement /// application logic to enforce specific transaction semantics. class interface { @@ -47,7 +47,7 @@ namespace cbdc::threepc::agent::runner { }; /// Type alias for a ticket number. - using ticket_number_type = threepc::ticket_machine::ticket_number_type; + using ticket_number_type = parsec::ticket_machine::ticket_number_type; /// Return type from executing a function. Either the state updates /// committed after function execution or an error code. @@ -68,7 +68,7 @@ namespace cbdc::threepc::agent::runner { /// Factory function type for instantiating new runners. using factory_type = std::function( std::shared_ptr logger, - const cbdc::threepc::config& cfg, + const cbdc::parsec::config& cfg, runtime_locking_shard::value_type function, parameter_type param, bool is_readonly_run, @@ -94,7 +94,7 @@ namespace cbdc::threepc::agent::runner { /// \param ticket_number ticket number for the ticket managed by this /// runner instance. interface(std::shared_ptr logger, - const cbdc::threepc::config& cfg, + const cbdc::parsec::config& cfg, runtime_locking_shard::value_type function, parameter_type param, bool is_readonly_run, @@ -121,7 +121,7 @@ namespace cbdc::threepc::agent::runner { private: std::shared_ptr m_log; - const cbdc::threepc::config& m_cfg; + const cbdc::parsec::config& m_cfg; runtime_locking_shard::value_type m_function; parameter_type m_param; bool m_is_readonly_run; @@ -142,7 +142,7 @@ namespace cbdc::threepc::agent::runner { /// \return new runner. static auto create(std::shared_ptr logger, - cbdc::threepc::config cfg, + cbdc::parsec::config cfg, runtime_locking_shard::value_type function, parameter_type param, bool is_readonly_run, diff --git a/src/3pc/agent/runners/lua/CMakeLists.txt b/src/parsec/agent/runners/lua/CMakeLists.txt similarity index 100% rename from src/3pc/agent/runners/lua/CMakeLists.txt rename to src/parsec/agent/runners/lua/CMakeLists.txt diff --git a/src/3pc/agent/runners/lua/impl.cpp b/src/parsec/agent/runners/lua/impl.cpp similarity index 98% rename from src/3pc/agent/runners/lua/impl.cpp rename to src/parsec/agent/runners/lua/impl.cpp index 8114abecd..4c79dc147 100644 --- a/src/3pc/agent/runners/lua/impl.cpp +++ b/src/parsec/agent/runners/lua/impl.cpp @@ -13,7 +13,7 @@ #include #include -namespace cbdc::threepc::agent::runner { +namespace cbdc::parsec::agent::runner { static const auto secp_context = std::unique_ptr( @@ -21,7 +21,7 @@ namespace cbdc::threepc::agent::runner { &secp256k1_context_destroy); lua_runner::lua_runner(std::shared_ptr logger, - const cbdc::threepc::config& cfg, + const cbdc::parsec::config& cfg, runtime_locking_shard::value_type function, parameter_type param, bool is_readonly_run, diff --git a/src/3pc/agent/runners/lua/impl.hpp b/src/parsec/agent/runners/lua/impl.hpp similarity index 88% rename from src/3pc/agent/runners/lua/impl.hpp rename to src/parsec/agent/runners/lua/impl.hpp index ab8a95e78..7b2c111d8 100644 --- a/src/3pc/agent/runners/lua/impl.hpp +++ b/src/parsec/agent/runners/lua/impl.hpp @@ -3,16 +3,16 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#ifndef OPENCBDC_TX_SRC_3PC_AGENT_RUNNER_H_ -#define OPENCBDC_TX_SRC_3PC_AGENT_RUNNER_H_ +#ifndef OPENCBDC_TX_SRC_PARSEC_AGENT_RUNNER_H_ +#define OPENCBDC_TX_SRC_PARSEC_AGENT_RUNNER_H_ -#include "3pc/agent/runners/interface.hpp" -#include "3pc/util.hpp" +#include "parsec/agent/runners/interface.hpp" +#include "parsec/util.hpp" #include #include -namespace cbdc::threepc::agent::runner { +namespace cbdc::parsec::agent::runner { /// Lua function executor. Provides an environment for contracts to execute /// in. Manages retrieval of function bytecode, locking keys during /// function execution, signature checking and commiting execution results. @@ -22,7 +22,7 @@ namespace cbdc::threepc::agent::runner { public: /// \copydoc interface::interface() lua_runner(std::shared_ptr logger, - const cbdc::threepc::config& cfg, + const cbdc::parsec::config& cfg, runtime_locking_shard::value_type function, parameter_type param, bool is_readonly_run, diff --git a/src/3pc/agent/runners/lua/server.cpp b/src/parsec/agent/runners/lua/server.cpp similarity index 95% rename from src/3pc/agent/runners/lua/server.cpp rename to src/parsec/agent/runners/lua/server.cpp index 7ee4be7e9..a0d65cde0 100644 --- a/src/3pc/agent/runners/lua/server.cpp +++ b/src/parsec/agent/runners/lua/server.cpp @@ -5,20 +5,20 @@ #include "server.hpp" -#include "3pc/agent/runners/lua/impl.hpp" #include "agent/format.hpp" #include "impl.hpp" +#include "parsec/agent/runners/lua/impl.hpp" #include "util/rpc/format.hpp" #include "util/serialization/format.hpp" #include #include -namespace cbdc::threepc::agent::rpc { +namespace cbdc::parsec::agent::rpc { server::server(std::unique_ptr srv, std::shared_ptr broker, std::shared_ptr log, - const cbdc::threepc::config& cfg) + const cbdc::parsec::config& cfg) : server_interface(std::move(broker), std::move(log), cfg), m_srv(std::move(srv)) { m_srv->register_handler_callback( diff --git a/src/3pc/agent/runners/lua/server.hpp b/src/parsec/agent/runners/lua/server.hpp similarity index 89% rename from src/3pc/agent/runners/lua/server.hpp rename to src/parsec/agent/runners/lua/server.hpp index b9e13082b..9301e76b5 100644 --- a/src/3pc/agent/runners/lua/server.hpp +++ b/src/parsec/agent/runners/lua/server.hpp @@ -3,13 +3,13 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#ifndef OPENCBDC_TX_SRC_3PC_AGENT_RUNNERS_LUA_SERVER_H_ -#define OPENCBDC_TX_SRC_3PC_AGENT_RUNNERS_LUA_SERVER_H_ +#ifndef OPENCBDC_TX_SRC_PARSEC_AGENT_RUNNERS_LUA_SERVER_H_ +#define OPENCBDC_TX_SRC_PARSEC_AGENT_RUNNERS_LUA_SERVER_H_ #include "agent/server_interface.hpp" #include "util/rpc/tcp_server.hpp" -namespace cbdc::threepc::agent::rpc { +namespace cbdc::parsec::agent::rpc { /// RPC server for an agent running a Lua exector. Manages retrying /// function execution if it fails due to a transient error. class server : public server_interface { @@ -26,7 +26,7 @@ namespace cbdc::threepc::agent::rpc { server(std::unique_ptr srv, std::shared_ptr broker, std::shared_ptr log, - const cbdc::threepc::config& cfg); + const cbdc::parsec::config& cfg); /// Stops the server. ~server() override; diff --git a/src/3pc/agent/server_interface.cpp b/src/parsec/agent/server_interface.cpp similarity index 95% rename from src/3pc/agent/server_interface.cpp rename to src/parsec/agent/server_interface.cpp index acad1652c..0f1ade3c4 100644 --- a/src/3pc/agent/server_interface.cpp +++ b/src/parsec/agent/server_interface.cpp @@ -7,11 +7,11 @@ #include -namespace cbdc::threepc::agent::rpc { +namespace cbdc::parsec::agent::rpc { server_interface::server_interface( std::shared_ptr broker, std::shared_ptr log, - const cbdc::threepc::config& cfg) + const cbdc::parsec::config& cfg) : m_broker(std::move(broker)), m_log(std::move(log)), m_cfg(cfg) { diff --git a/src/3pc/agent/server_interface.hpp b/src/parsec/agent/server_interface.hpp similarity index 84% rename from src/3pc/agent/server_interface.hpp rename to src/parsec/agent/server_interface.hpp index ce2d3806d..da3fe9729 100644 --- a/src/3pc/agent/server_interface.hpp +++ b/src/parsec/agent/server_interface.hpp @@ -3,14 +3,14 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#ifndef OPENCBDC_TX_SRC_3PC_AGENT_SERVER_INTERFACE_H_ -#define OPENCBDC_TX_SRC_3PC_AGENT_SERVER_INTERFACE_H_ +#ifndef OPENCBDC_TX_SRC_PARSEC_AGENT_SERVER_INTERFACE_H_ +#define OPENCBDC_TX_SRC_PARSEC_AGENT_SERVER_INTERFACE_H_ -#include "3pc/agent/impl.hpp" -#include "3pc/broker/interface.hpp" -#include "3pc/directory/interface.hpp" #include "interface.hpp" #include "messages.hpp" +#include "parsec/agent/impl.hpp" +#include "parsec/broker/interface.hpp" +#include "parsec/directory/interface.hpp" #include "util/common/blocking_queue.hpp" #include "util/common/thread_pool.hpp" @@ -19,7 +19,7 @@ #include #include -namespace cbdc::threepc::agent::rpc { +namespace cbdc::parsec::agent::rpc { /// Server interface for an agent. Subclasses should implement specific /// handling logic depending on the runner type. class server_interface { @@ -28,10 +28,10 @@ namespace cbdc::threepc::agent::rpc { /// RPC server using a request handler callback. /// \param broker broker instance. /// \param log log instance. - /// \param cfg system configuration options. + ///  \param cfg system configuration options. server_interface(std::shared_ptr broker, std::shared_ptr log, - const cbdc::threepc::config& cfg); + const cbdc::parsec::config& cfg); /// Stops retrying additional transactions and cleans up the runners. virtual ~server_interface(); @@ -50,7 +50,7 @@ namespace cbdc::threepc::agent::rpc { std::shared_ptr m_broker; std::shared_ptr m_log; - const cbdc::threepc::config& m_cfg; + const cbdc::parsec::config& m_cfg; mutable std::mutex m_agents_mut; std::atomic m_next_id{}; diff --git a/src/3pc/broker/CMakeLists.txt b/src/parsec/broker/CMakeLists.txt similarity index 100% rename from src/3pc/broker/CMakeLists.txt rename to src/parsec/broker/CMakeLists.txt diff --git a/src/3pc/broker/impl.cpp b/src/parsec/broker/impl.cpp similarity index 96% rename from src/3pc/broker/impl.cpp rename to src/parsec/broker/impl.cpp index 178373a63..3c6810b70 100644 --- a/src/3pc/broker/impl.cpp +++ b/src/parsec/broker/impl.cpp @@ -9,7 +9,7 @@ #include -namespace cbdc::threepc::broker { +namespace cbdc::parsec::broker { impl::impl( runtime_locking_shard::broker_id_type broker_id, std::vector> shards, @@ -25,7 +25,7 @@ namespace cbdc::threepc::broker { auto impl::begin(begin_callback_type result_callback) -> bool { if(!m_ticketer->get_ticket_number( [this, result_callback]( - std::optional res) { handle_ticket_number(result_callback, res); })) { @@ -39,13 +39,13 @@ namespace cbdc::threepc::broker { void impl::handle_ticket_number( begin_callback_type result_callback, std::optional< - threepc::ticket_machine::interface::get_ticket_number_return_type> + parsec::ticket_machine::interface::get_ticket_number_return_type> res) { if(!res.has_value()) { result_callback(error_code::ticket_number_assignment); return; } - std::visit(overloaded{[&](const threepc::ticket_machine::interface:: + std::visit(overloaded{[&](const parsec::ticket_machine::interface:: ticket_number_range_type& n) { { std::unique_lock l(m_mut); @@ -59,7 +59,7 @@ namespace cbdc::threepc::broker { } result_callback(n.first); }, - [&](const threepc::ticket_machine::interface:: + [&](const parsec::ticket_machine::interface:: error_code& /* e */) { result_callback( error_code::ticket_number_assignment); @@ -76,11 +76,11 @@ namespace cbdc::threepc::broker { key_type key, uint64_t shard_idx, const try_lock_callback_type& result_callback, - const threepc::runtime_locking_shard::interface::try_lock_return_type& + const parsec::runtime_locking_shard::interface::try_lock_return_type& res) { auto result = std::visit( overloaded{ - [&](threepc::runtime_locking_shard::value_type v) + [&](parsec::runtime_locking_shard::value_type v) -> try_lock_return_type { std::unique_lock l(m_mut); auto it = m_tickets.find(ticket_number); @@ -108,7 +108,7 @@ namespace cbdc::threepc::broker { return v; }, - [&, key](threepc::runtime_locking_shard::shard_error e) + [&, key](parsec::runtime_locking_shard::shard_error e) -> try_lock_return_type { if(e.m_wounded_details.has_value()) { m_log->trace(this, @@ -158,7 +158,7 @@ namespace cbdc::threepc::broker { if(!m_directory->key_location( key, [=](std::optional< - threepc::directory::interface::key_location_return_type> + parsec::directory::interface::key_location_return_type> res) { handle_find_key(ticket_number, key, @@ -184,7 +184,7 @@ namespace cbdc::threepc::broker { const commit_callback_type& commit_cb, ticket_number_type ticket_number, uint64_t shard_idx, - threepc::runtime_locking_shard::interface::prepare_return_type res) { + parsec::runtime_locking_shard::interface::prepare_return_type res) { auto maybe_error = [&]() -> std::optional { std::unique_lock ll(m_mut); auto itt = m_tickets.find(ticket_number); @@ -226,7 +226,7 @@ namespace cbdc::threepc::broker { ticket_number_type ticket_number, const std::shared_ptr& ts, uint64_t shard_idx, - const threepc::runtime_locking_shard::interface::prepare_return_type& + const parsec::runtime_locking_shard::interface::prepare_return_type& res) -> std::optional { auto& ss = ts->m_shard_states[shard_idx].m_state; if(ss != shard_state_type::preparing) { @@ -296,7 +296,7 @@ namespace cbdc::threepc::broker { auto sidx = shard.first; if(!m_shards[sidx]->commit( ticket_number, - [=](const threepc::runtime_locking_shard::interface:: + [=](const parsec::runtime_locking_shard::interface:: commit_return_type& comm_res) { handle_commit(commit_cb, ticket_number, sidx, comm_res); })) { @@ -311,7 +311,7 @@ namespace cbdc::threepc::broker { const commit_callback_type& commit_cb, ticket_number_type ticket_number, uint64_t shard_idx, - threepc::runtime_locking_shard::interface::commit_return_type res) { + parsec::runtime_locking_shard::interface::commit_return_type res) { auto callback = false; auto maybe_error = [&]() -> std::optional { std::unique_lock lll(m_mut); @@ -459,7 +459,7 @@ namespace cbdc::threepc::broker { result_callback, ticket_number, shard_idx - = shard.first](const threepc::runtime_locking_shard:: + = shard.first](const parsec::runtime_locking_shard:: interface::prepare_return_type& res) { handle_prepare(result_callback, ticket_number, @@ -528,7 +528,7 @@ namespace cbdc::threepc::broker { shard.second.m_state = shard_state_type::finishing; if(!m_shards[sidx]->finish( ticket_number, - [=](const threepc::runtime_locking_shard::interface:: + [=](const parsec::runtime_locking_shard::interface:: finish_return_type& res) { handle_finish(result_callback, ticket_number, @@ -601,7 +601,7 @@ namespace cbdc::threepc::broker { shard.second.m_state = shard_state_type::rolling_back; if(!m_shards[sidx]->rollback( ticket_number, - [=](const threepc::runtime_locking_shard::interface:: + [=](const parsec::runtime_locking_shard::interface:: rollback_return_type& res) { handle_rollback(result_callback, ticket_number, @@ -637,7 +637,7 @@ namespace cbdc::threepc::broker { const rollback_callback_type& result_callback, ticket_number_type ticket_number, uint64_t shard_idx, - threepc::runtime_locking_shard::interface::rollback_return_type res) { + parsec::runtime_locking_shard::interface::rollback_return_type res) { auto callback = false; auto maybe_error = [&]() -> std::optional { std::unique_lock lll(m_mut); @@ -717,7 +717,7 @@ namespace cbdc::threepc::broker { key_type key, lock_type locktype, try_lock_callback_type result_callback, - std::optional + std::optional res) { auto maybe_error = [&]() -> std::optional { std::unique_lock l(m_mut); @@ -766,7 +766,7 @@ namespace cbdc::threepc::broker { key, locktype, first_lock, - [=](const threepc::runtime_locking_shard::interface:: + [=](const parsec::runtime_locking_shard::interface:: try_lock_return_type& lock_res) { handle_lock(ticket_number, key, @@ -789,7 +789,7 @@ namespace cbdc::threepc::broker { const finish_callback_type& result_callback, ticket_number_type ticket_number, uint64_t shard_idx, - threepc::runtime_locking_shard::interface::finish_return_type res) { + parsec::runtime_locking_shard::interface::finish_return_type res) { auto callback = false; auto maybe_error = [&]() -> std::optional { std::unique_lock lll(m_mut); @@ -877,7 +877,7 @@ namespace cbdc::threepc::broker { auto success = s->get_tickets( m_broker_id, [&, result_callback, i]( - const threepc::runtime_locking_shard::interface:: + const parsec::runtime_locking_shard::interface:: get_tickets_return_type& res) { handle_get_tickets(result_callback, i, res); }); @@ -891,7 +891,7 @@ namespace cbdc::threepc::broker { void impl::handle_get_tickets(const recover_callback_type& result_callback, uint64_t shard_idx, - const threepc::runtime_locking_shard::interface:: + const parsec::runtime_locking_shard::interface:: get_tickets_return_type& res) { auto done = false; auto maybe_error = std::visit( diff --git a/src/3pc/broker/impl.hpp b/src/parsec/broker/impl.hpp similarity index 91% rename from src/3pc/broker/impl.hpp rename to src/parsec/broker/impl.hpp index 9593c8e00..6c2fc0cfb 100644 --- a/src/3pc/broker/impl.hpp +++ b/src/parsec/broker/impl.hpp @@ -3,16 +3,16 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#ifndef OPENCBDC_TX_SRC_3PC_BROKER_IMPL_H_ -#define OPENCBDC_TX_SRC_3PC_BROKER_IMPL_H_ +#ifndef OPENCBDC_TX_SRC_PARSEC_BROKER_IMPL_H_ +#define OPENCBDC_TX_SRC_PARSEC_BROKER_IMPL_H_ -#include "3pc/directory/interface.hpp" #include "interface.hpp" +#include "parsec/directory/interface.hpp" #include "util/common/logging.hpp" #include -namespace cbdc::threepc::broker { +namespace cbdc::parsec::broker { /// Implementation of a broker. Stores ticket states in memory. /// Thread-safe. class impl : public interface { @@ -157,32 +157,31 @@ namespace cbdc::threepc::broker { const commit_callback_type& commit_cb, ticket_number_type ticket_number, uint64_t shard_idx, - threepc::runtime_locking_shard::interface::prepare_return_type - res); + parsec::runtime_locking_shard::interface::prepare_return_type res); void handle_commit( const commit_callback_type& commit_cb, ticket_number_type ticket_number, uint64_t shard_idx, - threepc::runtime_locking_shard::interface::commit_return_type res); + parsec::runtime_locking_shard::interface::commit_return_type res); void handle_lock(ticket_number_type ticket_number, key_type key, uint64_t shard_idx, const try_lock_callback_type& result_callback, - const threepc::runtime_locking_shard::interface:: + const parsec::runtime_locking_shard::interface:: try_lock_return_type& res); void handle_ticket_number( begin_callback_type result_callback, - std::optional res); void handle_rollback( const rollback_callback_type& result_callback, ticket_number_type ticket_number, uint64_t shard_idx, - threepc::runtime_locking_shard::interface::rollback_return_type + parsec::runtime_locking_shard::interface::rollback_return_type res); void handle_find_key( @@ -191,17 +190,17 @@ namespace cbdc::threepc::broker { lock_type locktype, try_lock_callback_type result_callback, std::optional< - threepc::directory::interface::key_location_return_type> res); + parsec::directory::interface::key_location_return_type> res); void handle_finish( const finish_callback_type& result_callback, ticket_number_type ticket_number, uint64_t shard_idx, - threepc::runtime_locking_shard::interface::finish_return_type res); + parsec::runtime_locking_shard::interface::finish_return_type res); void handle_get_tickets(const recover_callback_type& result_callback, uint64_t shard_idx, - const threepc::runtime_locking_shard:: + const parsec::runtime_locking_shard:: interface::get_tickets_return_type& res); void @@ -227,8 +226,8 @@ namespace cbdc::threepc::broker { ticket_number_type ticket_number, const std::shared_ptr& ts, uint64_t shard_idx, - const threepc::runtime_locking_shard:: - interface::prepare_return_type& res) + const parsec::runtime_locking_shard::interface:: + prepare_return_type& res) -> std::optional; auto do_prepare(const commit_callback_type& result_callback, diff --git a/src/3pc/broker/interface.hpp b/src/parsec/broker/interface.hpp similarity index 97% rename from src/3pc/broker/interface.hpp rename to src/parsec/broker/interface.hpp index 0b3cbcf98..4306b8277 100644 --- a/src/3pc/broker/interface.hpp +++ b/src/parsec/broker/interface.hpp @@ -3,13 +3,13 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#ifndef OPENCBDC_TX_SRC_3PC_BROKER_INTERFACE_H_ -#define OPENCBDC_TX_SRC_3PC_BROKER_INTERFACE_H_ +#ifndef OPENCBDC_TX_SRC_PARSEC_BROKER_INTERFACE_H_ +#define OPENCBDC_TX_SRC_PARSEC_BROKER_INTERFACE_H_ -#include "3pc/runtime_locking_shard/interface.hpp" -#include "3pc/ticket_machine/interface.hpp" +#include "parsec/runtime_locking_shard/interface.hpp" +#include "parsec/ticket_machine/interface.hpp" -namespace cbdc::threepc::broker { +namespace cbdc::parsec::broker { /// Ticket number type. using ticket_number_type = ticket_machine::ticket_number_type; /// Shard key type. diff --git a/src/3pc/directory/CMakeLists.txt b/src/parsec/directory/CMakeLists.txt similarity index 100% rename from src/3pc/directory/CMakeLists.txt rename to src/parsec/directory/CMakeLists.txt diff --git a/src/3pc/directory/impl.cpp b/src/parsec/directory/impl.cpp similarity index 95% rename from src/3pc/directory/impl.cpp rename to src/parsec/directory/impl.cpp index 38aa95fda..d03f109dd 100644 --- a/src/3pc/directory/impl.cpp +++ b/src/parsec/directory/impl.cpp @@ -5,7 +5,7 @@ #include "impl.hpp" -namespace cbdc::threepc::directory { +namespace cbdc::parsec::directory { impl::impl(size_t n_shards) : m_n_shards(n_shards) {} auto impl::key_location(runtime_locking_shard::key_type key, diff --git a/src/3pc/directory/impl.hpp b/src/parsec/directory/impl.hpp similarity index 89% rename from src/3pc/directory/impl.hpp rename to src/parsec/directory/impl.hpp index 3aada5940..b60b49073 100644 --- a/src/3pc/directory/impl.hpp +++ b/src/parsec/directory/impl.hpp @@ -3,12 +3,12 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#ifndef OPENCBDC_TX_SRC_3PC_DIRECTORY_IMPL_H_ -#define OPENCBDC_TX_SRC_3PC_DIRECTORY_IMPL_H_ +#ifndef OPENCBDC_TX_SRC_PARSEC_DIRECTORY_IMPL_H_ +#define OPENCBDC_TX_SRC_PARSEC_DIRECTORY_IMPL_H_ #include "interface.hpp" -namespace cbdc::threepc::directory { +namespace cbdc::parsec::directory { /// Implementation of a directory which map keys to shard IDs. Thread-safe. class impl : public interface { public: diff --git a/src/3pc/directory/interface.hpp b/src/parsec/directory/interface.hpp similarity index 87% rename from src/3pc/directory/interface.hpp rename to src/parsec/directory/interface.hpp index 157a3047a..dc9eeba22 100644 --- a/src/3pc/directory/interface.hpp +++ b/src/parsec/directory/interface.hpp @@ -3,12 +3,12 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#ifndef OPENCBDC_TX_SRC_3PC_DIRECTORY_INTERFACE_H_ -#define OPENCBDC_TX_SRC_3PC_DIRECTORY_INTERFACE_H_ +#ifndef OPENCBDC_TX_SRC_PARSEC_DIRECTORY_INTERFACE_H_ +#define OPENCBDC_TX_SRC_PARSEC_DIRECTORY_INTERFACE_H_ -#include "3pc/runtime_locking_shard/interface.hpp" +#include "parsec/runtime_locking_shard/interface.hpp" -namespace cbdc::threepc::directory { +namespace cbdc::parsec::directory { /// Interface for a directory. Maps keys to shard IDs. class interface { public: diff --git a/src/3pc/runtime_locking_shard/CMakeLists.txt b/src/parsec/runtime_locking_shard/CMakeLists.txt similarity index 95% rename from src/3pc/runtime_locking_shard/CMakeLists.txt rename to src/parsec/runtime_locking_shard/CMakeLists.txt index 50382f894..21392b1ca 100644 --- a/src/3pc/runtime_locking_shard/CMakeLists.txt +++ b/src/parsec/runtime_locking_shard/CMakeLists.txt @@ -11,7 +11,7 @@ add_library(runtime_locking_shard impl.cpp add_executable(runtime_locking_shardd runtime_locking_shardd.cpp) target_link_libraries(runtime_locking_shardd runtime_locking_shard - threepc + parsec raft rpc network diff --git a/src/3pc/runtime_locking_shard/client.cpp b/src/parsec/runtime_locking_shard/client.cpp similarity index 98% rename from src/3pc/runtime_locking_shard/client.cpp rename to src/parsec/runtime_locking_shard/client.cpp index 898cdbd69..78be3f563 100644 --- a/src/3pc/runtime_locking_shard/client.cpp +++ b/src/parsec/runtime_locking_shard/client.cpp @@ -8,7 +8,7 @@ #include "format.hpp" #include "util/serialization/format.hpp" -namespace cbdc::threepc::runtime_locking_shard::rpc { +namespace cbdc::parsec::runtime_locking_shard::rpc { client::client(std::vector endpoints) : m_client(std::make_unique( std::move(endpoints))) {} diff --git a/src/3pc/runtime_locking_shard/client.hpp b/src/parsec/runtime_locking_shard/client.hpp similarity index 95% rename from src/3pc/runtime_locking_shard/client.hpp rename to src/parsec/runtime_locking_shard/client.hpp index 50e7eeeb5..3676f9399 100644 --- a/src/3pc/runtime_locking_shard/client.hpp +++ b/src/parsec/runtime_locking_shard/client.hpp @@ -3,14 +3,14 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#ifndef OPENCBDC_TX_SRC_3PC_RUNTIME_LOCKING_SHARD_CLIENT_H_ -#define OPENCBDC_TX_SRC_3PC_RUNTIME_LOCKING_SHARD_CLIENT_H_ +#ifndef OPENCBDC_TX_SRC_PARSEC_RUNTIME_LOCKING_SHARD_CLIENT_H_ +#define OPENCBDC_TX_SRC_PARSEC_RUNTIME_LOCKING_SHARD_CLIENT_H_ #include "interface.hpp" #include "messages.hpp" #include "util/rpc/tcp_client.hpp" -namespace cbdc::threepc::runtime_locking_shard::rpc { +namespace cbdc::parsec::runtime_locking_shard::rpc { /// RPC client for a runtime locking shard cluster. class client : public interface { public: diff --git a/src/3pc/runtime_locking_shard/controller.cpp b/src/parsec/runtime_locking_shard/controller.cpp similarity index 98% rename from src/3pc/runtime_locking_shard/controller.cpp rename to src/parsec/runtime_locking_shard/controller.cpp index 549ab96d9..65e5e4937 100644 --- a/src/3pc/runtime_locking_shard/controller.cpp +++ b/src/parsec/runtime_locking_shard/controller.cpp @@ -11,7 +11,7 @@ #include "util/rpc/tcp_server.hpp" #include "util/serialization/format.hpp" -namespace cbdc::threepc::runtime_locking_shard { +namespace cbdc::parsec::runtime_locking_shard { controller::controller(size_t component_id, size_t node_id, network::endpoint_t server_endpoint, diff --git a/src/3pc/runtime_locking_shard/controller.hpp b/src/parsec/runtime_locking_shard/controller.hpp similarity index 92% rename from src/3pc/runtime_locking_shard/controller.hpp rename to src/parsec/runtime_locking_shard/controller.hpp index 4749ed394..6e1a223ec 100644 --- a/src/3pc/runtime_locking_shard/controller.hpp +++ b/src/parsec/runtime_locking_shard/controller.hpp @@ -3,8 +3,8 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#ifndef OPENCBDC_TX_SRC_3PC_RUNTIME_LOCKING_SHARD_CONTROLLER_H_ -#define OPENCBDC_TX_SRC_3PC_RUNTIME_LOCKING_SHARD_CONTROLLER_H_ +#ifndef OPENCBDC_TX_SRC_PARSEC_RUNTIME_LOCKING_SHARD_CONTROLLER_H_ +#define OPENCBDC_TX_SRC_PARSEC_RUNTIME_LOCKING_SHARD_CONTROLLER_H_ #include "impl.hpp" #include "replicated_shard_client.hpp" @@ -13,7 +13,7 @@ #include "util/raft/node.hpp" #include "util/rpc/tcp_server.hpp" -namespace cbdc::threepc::runtime_locking_shard { +namespace cbdc::parsec::runtime_locking_shard { /// Manages a replicated runtime locking shard using Raft. class controller { public: diff --git a/src/3pc/runtime_locking_shard/format.cpp b/src/parsec/runtime_locking_shard/format.cpp similarity index 67% rename from src/3pc/runtime_locking_shard/format.cpp rename to src/parsec/runtime_locking_shard/format.cpp index d85d76506..04ea9403d 100644 --- a/src/3pc/runtime_locking_shard/format.cpp +++ b/src/parsec/runtime_locking_shard/format.cpp @@ -8,15 +8,15 @@ #include "util/serialization/format.hpp" namespace cbdc { - auto operator<<( - serializer& ser, - const threepc::runtime_locking_shard::rpc::try_lock_request& req) + auto + operator<<(serializer& ser, + const parsec::runtime_locking_shard::rpc::try_lock_request& req) -> serializer& { return ser << req.m_ticket_number << req.m_broker_id << req.m_key << req.m_locktype << req.m_first_lock; } auto operator>>(serializer& deser, - threepc::runtime_locking_shard::rpc::try_lock_request& req) + parsec::runtime_locking_shard::rpc::try_lock_request& req) -> serializer& { return deser >> req.m_ticket_number >> req.m_broker_id >> req.m_key >> req.m_locktype >> req.m_first_lock; @@ -24,127 +24,127 @@ namespace cbdc { auto operator<<(serializer& ser, - const threepc::runtime_locking_shard::rpc::commit_request& req) + const parsec::runtime_locking_shard::rpc::commit_request& req) -> serializer& { return ser << req.m_ticket_number; } auto operator>>(serializer& deser, - threepc::runtime_locking_shard::rpc::commit_request& req) + parsec::runtime_locking_shard::rpc::commit_request& req) -> serializer& { return deser >> req.m_ticket_number; } auto operator<<(serializer& ser, - const threepc::runtime_locking_shard::rpc::prepare_request& req) + const parsec::runtime_locking_shard::rpc::prepare_request& req) -> serializer& { return ser << req.m_ticket_number << req.m_state_updates << req.m_broker_id; } auto operator>>(serializer& deser, - threepc::runtime_locking_shard::rpc::prepare_request& req) + parsec::runtime_locking_shard::rpc::prepare_request& req) -> serializer& { return deser >> req.m_ticket_number >> req.m_state_updates >> req.m_broker_id; } - auto operator<<( - serializer& ser, - const threepc::runtime_locking_shard::rpc::rollback_request& req) + auto + operator<<(serializer& ser, + const parsec::runtime_locking_shard::rpc::rollback_request& req) -> serializer& { return ser << req.m_ticket_number; } auto operator>>(serializer& deser, - threepc::runtime_locking_shard::rpc::rollback_request& req) + parsec::runtime_locking_shard::rpc::rollback_request& req) -> serializer& { return deser >> req.m_ticket_number; } auto operator<<(serializer& ser, - const threepc::runtime_locking_shard::rpc::finish_request& req) + const parsec::runtime_locking_shard::rpc::finish_request& req) -> serializer& { return ser << req.m_ticket_number; } auto operator>>(serializer& deser, - threepc::runtime_locking_shard::rpc::finish_request& req) + parsec::runtime_locking_shard::rpc::finish_request& req) -> serializer& { return deser >> req.m_ticket_number; } auto operator<<( serializer& ser, - const threepc::runtime_locking_shard::rpc::get_tickets_request& req) + const parsec::runtime_locking_shard::rpc::get_tickets_request& req) -> serializer& { return ser << req.m_broker_id; } auto operator>>(serializer& deser, - threepc::runtime_locking_shard::rpc::get_tickets_request& req) + parsec::runtime_locking_shard::rpc::get_tickets_request& req) -> serializer& { return deser >> req.m_broker_id; } auto operator<<(serializer& ser, - const threepc::runtime_locking_shard::shard_error& err) + const parsec::runtime_locking_shard::shard_error& err) -> serializer& { return ser << err.m_error_code << err.m_wounded_details; } auto operator>>(serializer& deser, - threepc::runtime_locking_shard::shard_error& err) + parsec::runtime_locking_shard::shard_error& err) -> serializer& { return deser >> err.m_error_code >> err.m_wounded_details; } auto operator<<(serializer& ser, - const threepc::runtime_locking_shard::wounded_details& det) + const parsec::runtime_locking_shard::wounded_details& det) -> serializer& { return ser << det.m_wounding_ticket << det.m_wounding_key; } auto operator>>(serializer& deser, - threepc::runtime_locking_shard::wounded_details& det) + parsec::runtime_locking_shard::wounded_details& det) -> serializer& { return deser >> det.m_wounding_ticket >> det.m_wounding_key; } auto operator<<( serializer& ser, - const threepc::runtime_locking_shard::rpc::replicated_prepare_request& + const parsec::runtime_locking_shard::rpc::replicated_prepare_request& req) -> serializer& { return ser << req.m_ticket_number << req.m_broker_id << req.m_state_update; } auto operator>>( serializer& deser, - threepc::runtime_locking_shard::rpc::replicated_prepare_request& req) + parsec::runtime_locking_shard::rpc::replicated_prepare_request& req) -> serializer& { return deser >> req.m_ticket_number >> req.m_broker_id >> req.m_state_update; } auto operator<<(serializer& ser, - const threepc::runtime_locking_shard::rpc:: + const parsec::runtime_locking_shard::rpc:: replicated_get_tickets_request& /* req */) -> serializer& { return ser; } auto operator>>(serializer& deser, - threepc::runtime_locking_shard::rpc:: + parsec::runtime_locking_shard::rpc:: replicated_get_tickets_request& /* req */) -> serializer& { return deser; } auto operator<<(serializer& ser, - const threepc::runtime_locking_shard:: + const parsec::runtime_locking_shard:: replicated_shard_interface::ticket_type& t) -> serializer& { return ser << t.m_state << t.m_broker_id << t.m_state_update; } - auto operator>>(serializer& deser, - threepc::runtime_locking_shard:: - replicated_shard_interface::ticket_type& t) - -> serializer& { + auto operator>>( + serializer& deser, + parsec::runtime_locking_shard::replicated_shard_interface::ticket_type& + t) -> serializer& { return deser >> t.m_state >> t.m_broker_id >> t.m_state_update; } } diff --git a/src/3pc/runtime_locking_shard/format.hpp b/src/parsec/runtime_locking_shard/format.hpp similarity index 50% rename from src/3pc/runtime_locking_shard/format.hpp rename to src/parsec/runtime_locking_shard/format.hpp index b25502434..3b25f5e02 100644 --- a/src/3pc/runtime_locking_shard/format.hpp +++ b/src/parsec/runtime_locking_shard/format.hpp @@ -3,101 +3,101 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#ifndef OPENCBDC_TX_SRC_3PC_RUNTIME_LOCKING_SHARD_FORMAT_H_ -#define OPENCBDC_TX_SRC_3PC_RUNTIME_LOCKING_SHARD_FORMAT_H_ +#ifndef OPENCBDC_TX_SRC_PARSEC_RUNTIME_LOCKING_SHARD_FORMAT_H_ +#define OPENCBDC_TX_SRC_PARSEC_RUNTIME_LOCKING_SHARD_FORMAT_H_ #include "messages.hpp" #include "util/serialization/serializer.hpp" namespace cbdc { - auto operator<<( - serializer& ser, - const threepc::runtime_locking_shard::rpc::try_lock_request& req) + auto + operator<<(serializer& ser, + const parsec::runtime_locking_shard::rpc::try_lock_request& req) -> serializer&; auto operator>>(serializer& deser, - threepc::runtime_locking_shard::rpc::try_lock_request& req) + parsec::runtime_locking_shard::rpc::try_lock_request& req) -> serializer&; auto operator<<(serializer& ser, - const threepc::runtime_locking_shard::rpc::commit_request& req) + const parsec::runtime_locking_shard::rpc::commit_request& req) -> serializer&; auto operator>>(serializer& deser, - threepc::runtime_locking_shard::rpc::commit_request& req) + parsec::runtime_locking_shard::rpc::commit_request& req) -> serializer&; auto operator<<(serializer& ser, - const threepc::runtime_locking_shard::rpc::prepare_request& req) + const parsec::runtime_locking_shard::rpc::prepare_request& req) -> serializer&; auto operator>>(serializer& deser, - threepc::runtime_locking_shard::rpc::prepare_request& req) + parsec::runtime_locking_shard::rpc::prepare_request& req) -> serializer&; - auto operator<<( - serializer& ser, - const threepc::runtime_locking_shard::rpc::rollback_request& req) + auto + operator<<(serializer& ser, + const parsec::runtime_locking_shard::rpc::rollback_request& req) -> serializer&; auto operator>>(serializer& deser, - threepc::runtime_locking_shard::rpc::rollback_request& req) + parsec::runtime_locking_shard::rpc::rollback_request& req) -> serializer&; auto operator<<(serializer& ser, - const threepc::runtime_locking_shard::rpc::finish_request& req) + const parsec::runtime_locking_shard::rpc::finish_request& req) -> serializer&; auto operator>>(serializer& deser, - threepc::runtime_locking_shard::rpc::finish_request& req) + parsec::runtime_locking_shard::rpc::finish_request& req) -> serializer&; auto operator<<( serializer& ser, - const threepc::runtime_locking_shard::rpc::get_tickets_request& req) + const parsec::runtime_locking_shard::rpc::get_tickets_request& req) -> serializer&; auto operator>>(serializer& deser, - threepc::runtime_locking_shard::rpc::get_tickets_request& req) + parsec::runtime_locking_shard::rpc::get_tickets_request& req) -> serializer&; auto operator<<(serializer& ser, - const threepc::runtime_locking_shard::shard_error& err) + const parsec::runtime_locking_shard::shard_error& err) -> serializer&; auto operator>>(serializer& deser, - threepc::runtime_locking_shard::shard_error& err) + parsec::runtime_locking_shard::shard_error& err) -> serializer&; auto operator<<(serializer& ser, - const threepc::runtime_locking_shard::wounded_details& det) + const parsec::runtime_locking_shard::wounded_details& det) -> serializer&; auto operator>>(serializer& deser, - threepc::runtime_locking_shard::wounded_details& det) + parsec::runtime_locking_shard::wounded_details& det) -> serializer&; auto operator<<( serializer& ser, - const threepc::runtime_locking_shard::rpc::replicated_prepare_request& + const parsec::runtime_locking_shard::rpc::replicated_prepare_request& req) -> serializer&; auto operator>>( serializer& deser, - threepc::runtime_locking_shard::rpc::replicated_prepare_request& req) + parsec::runtime_locking_shard::rpc::replicated_prepare_request& req) -> serializer&; auto operator<<(serializer& ser, - const threepc::runtime_locking_shard::rpc:: + const parsec::runtime_locking_shard::rpc:: replicated_get_tickets_request& req) -> serializer&; auto operator>>( serializer& deser, - threepc::runtime_locking_shard::rpc::replicated_get_tickets_request& + parsec::runtime_locking_shard::rpc::replicated_get_tickets_request& req) -> serializer&; auto operator<<(serializer& ser, - const threepc::runtime_locking_shard:: - replicated_shard_interface::ticket_type& t) - -> serializer&; - auto operator>>(serializer& deser, - threepc::runtime_locking_shard:: + const parsec::runtime_locking_shard:: replicated_shard_interface::ticket_type& t) -> serializer&; + auto operator>>( + serializer& deser, + parsec::runtime_locking_shard::replicated_shard_interface::ticket_type& + t) -> serializer&; } #endif diff --git a/src/3pc/runtime_locking_shard/impl.cpp b/src/parsec/runtime_locking_shard/impl.cpp similarity index 99% rename from src/3pc/runtime_locking_shard/impl.cpp rename to src/parsec/runtime_locking_shard/impl.cpp index b996b80fb..e6e1c6728 100644 --- a/src/3pc/runtime_locking_shard/impl.cpp +++ b/src/parsec/runtime_locking_shard/impl.cpp @@ -7,7 +7,7 @@ #include -namespace cbdc::threepc::runtime_locking_shard { +namespace cbdc::parsec::runtime_locking_shard { impl::impl(std::shared_ptr logger) : m_log(std::move(logger)) {} diff --git a/src/3pc/runtime_locking_shard/impl.hpp b/src/parsec/runtime_locking_shard/impl.hpp similarity index 97% rename from src/3pc/runtime_locking_shard/impl.hpp rename to src/parsec/runtime_locking_shard/impl.hpp index ee2aaebc7..ae3bc87f1 100644 --- a/src/3pc/runtime_locking_shard/impl.hpp +++ b/src/parsec/runtime_locking_shard/impl.hpp @@ -3,8 +3,8 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#ifndef OPENCBDC_TX_SRC_3PC_RUNTIME_LOCKING_SHARD_IMPL_H_ -#define OPENCBDC_TX_SRC_3PC_RUNTIME_LOCKING_SHARD_IMPL_H_ +#ifndef OPENCBDC_TX_SRC_PARSEC_RUNTIME_LOCKING_SHARD_IMPL_H_ +#define OPENCBDC_TX_SRC_PARSEC_RUNTIME_LOCKING_SHARD_IMPL_H_ #include "interface.hpp" #include "replicated_shard.hpp" @@ -16,7 +16,7 @@ #include #include -namespace cbdc::threepc::runtime_locking_shard { +namespace cbdc::parsec::runtime_locking_shard { /// Implementation of a runtime locking shard. Stores keys in memory using /// a hash map. Thread-safe. class impl : public interface { diff --git a/src/3pc/runtime_locking_shard/interface.hpp b/src/parsec/runtime_locking_shard/interface.hpp similarity index 97% rename from src/3pc/runtime_locking_shard/interface.hpp rename to src/parsec/runtime_locking_shard/interface.hpp index 1808f52a6..12922ec06 100644 --- a/src/3pc/runtime_locking_shard/interface.hpp +++ b/src/parsec/runtime_locking_shard/interface.hpp @@ -3,19 +3,19 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#ifndef OPENCBDC_TX_SRC_3PC_RUNTIME_LOCKING_SHARD_INTERFACE_H_ -#define OPENCBDC_TX_SRC_3PC_RUNTIME_LOCKING_SHARD_INTERFACE_H_ +#ifndef OPENCBDC_TX_SRC_PARSEC_RUNTIME_LOCKING_SHARD_INTERFACE_H_ +#define OPENCBDC_TX_SRC_PARSEC_RUNTIME_LOCKING_SHARD_INTERFACE_H_ -#include "3pc/ticket_machine/interface.hpp" +#include "parsec/ticket_machine/interface.hpp" #include "util/common/buffer.hpp" #include "util/common/hashmap.hpp" #include #include -namespace cbdc::threepc::runtime_locking_shard { +namespace cbdc::parsec::runtime_locking_shard { /// Type for a ticket number. - using ticket_number_type = threepc::ticket_machine::ticket_number_type; + using ticket_number_type = parsec::ticket_machine::ticket_number_type; /// Type for keys held by shards. using key_type = buffer; /// Type for values held by shards. diff --git a/src/3pc/runtime_locking_shard/messages.hpp b/src/parsec/runtime_locking_shard/messages.hpp similarity index 94% rename from src/3pc/runtime_locking_shard/messages.hpp rename to src/parsec/runtime_locking_shard/messages.hpp index b73bf6bfd..95e7c98ea 100644 --- a/src/3pc/runtime_locking_shard/messages.hpp +++ b/src/parsec/runtime_locking_shard/messages.hpp @@ -3,13 +3,13 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#ifndef OPENCBDC_TX_SRC_3PC_RUNTIME_LOCKING_SHARD_MESSAGES_H_ -#define OPENCBDC_TX_SRC_3PC_RUNTIME_LOCKING_SHARD_MESSAGES_H_ +#ifndef OPENCBDC_TX_SRC_PARSEC_RUNTIME_LOCKING_SHARD_MESSAGES_H_ +#define OPENCBDC_TX_SRC_PARSEC_RUNTIME_LOCKING_SHARD_MESSAGES_H_ #include "interface.hpp" #include "replicated_shard_interface.hpp" -namespace cbdc::threepc::runtime_locking_shard::rpc { +namespace cbdc::parsec::runtime_locking_shard::rpc { /// Try lock request message. struct try_lock_request { /// Ticket number. diff --git a/src/3pc/runtime_locking_shard/replicated_shard.cpp b/src/parsec/runtime_locking_shard/replicated_shard.cpp similarity index 98% rename from src/3pc/runtime_locking_shard/replicated_shard.cpp rename to src/parsec/runtime_locking_shard/replicated_shard.cpp index 5255775c0..87672e3fa 100644 --- a/src/3pc/runtime_locking_shard/replicated_shard.cpp +++ b/src/parsec/runtime_locking_shard/replicated_shard.cpp @@ -5,7 +5,7 @@ #include "replicated_shard.hpp" -namespace cbdc::threepc::runtime_locking_shard { +namespace cbdc::parsec::runtime_locking_shard { auto replicated_shard::prepare(ticket_number_type ticket_number, broker_id_type broker_id, state_type state_update, diff --git a/src/3pc/runtime_locking_shard/replicated_shard.hpp b/src/parsec/runtime_locking_shard/replicated_shard.hpp similarity index 89% rename from src/3pc/runtime_locking_shard/replicated_shard.hpp rename to src/parsec/runtime_locking_shard/replicated_shard.hpp index 9cf07fbc0..2b711c9c1 100644 --- a/src/3pc/runtime_locking_shard/replicated_shard.hpp +++ b/src/parsec/runtime_locking_shard/replicated_shard.hpp @@ -3,14 +3,14 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#ifndef OPENCBDC_TX_SRC_3PC_RUNTIME_LOCKING_SHARD_REPLICATED_SHARD_H_ -#define OPENCBDC_TX_SRC_3PC_RUNTIME_LOCKING_SHARD_REPLICATED_SHARD_H_ +#ifndef OPENCBDC_TX_SRC_PARSEC_RUNTIME_LOCKING_SHARD_REPLICATED_SHARD_H_ +#define OPENCBDC_TX_SRC_PARSEC_RUNTIME_LOCKING_SHARD_REPLICATED_SHARD_H_ #include "replicated_shard_interface.hpp" #include -namespace cbdc::threepc::runtime_locking_shard { +namespace cbdc::parsec::runtime_locking_shard { /// Implementation of the replicated shard interface. Stores the shard /// state and unfinished ticket in memory. Thread-safe. class replicated_shard : public replicated_shard_interface { diff --git a/src/3pc/runtime_locking_shard/replicated_shard_client.cpp b/src/parsec/runtime_locking_shard/replicated_shard_client.cpp similarity index 99% rename from src/3pc/runtime_locking_shard/replicated_shard_client.cpp rename to src/parsec/runtime_locking_shard/replicated_shard_client.cpp index 0b3fffd22..b042b50a9 100644 --- a/src/3pc/runtime_locking_shard/replicated_shard_client.cpp +++ b/src/parsec/runtime_locking_shard/replicated_shard_client.cpp @@ -10,7 +10,7 @@ #include "util/raft/util.hpp" #include "util/serialization/format.hpp" -namespace cbdc::threepc::runtime_locking_shard { +namespace cbdc::parsec::runtime_locking_shard { replicated_shard_client::replicated_shard_client( std::shared_ptr raft_node) : m_raft(std::move(raft_node)) {} diff --git a/src/3pc/runtime_locking_shard/replicated_shard_client.hpp b/src/parsec/runtime_locking_shard/replicated_shard_client.hpp similarity index 93% rename from src/3pc/runtime_locking_shard/replicated_shard_client.hpp rename to src/parsec/runtime_locking_shard/replicated_shard_client.hpp index 3a52a9f69..21f603b2f 100644 --- a/src/3pc/runtime_locking_shard/replicated_shard_client.hpp +++ b/src/parsec/runtime_locking_shard/replicated_shard_client.hpp @@ -3,14 +3,14 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#ifndef OPENCBDC_TX_SRC_3PC_RUNTIME_LOCKING_SHARD_REPLICATED_SHARD_CLIENT_H_ -#define OPENCBDC_TX_SRC_3PC_RUNTIME_LOCKING_SHARD_REPLICATED_SHARD_CLIENT_H_ +#ifndef OPENCBDC_TX_SRC_PARSEC_RUNTIME_LOCKING_SHARD_REPLICATED_SHARD_CLIENT_H_ +#define OPENCBDC_TX_SRC_PARSEC_RUNTIME_LOCKING_SHARD_REPLICATED_SHARD_CLIENT_H_ #include "messages.hpp" #include "replicated_shard_interface.hpp" #include "util/raft/node.hpp" -namespace cbdc::threepc::runtime_locking_shard { +namespace cbdc::parsec::runtime_locking_shard { /// Client for asynchronously interacting with a raft replicated shard on /// the leader node of the cluster. class replicated_shard_client final : public replicated_shard_interface { diff --git a/src/3pc/runtime_locking_shard/replicated_shard_interface.hpp b/src/parsec/runtime_locking_shard/replicated_shard_interface.hpp similarity index 94% rename from src/3pc/runtime_locking_shard/replicated_shard_interface.hpp rename to src/parsec/runtime_locking_shard/replicated_shard_interface.hpp index 27ecf236e..c0ab41de2 100644 --- a/src/3pc/runtime_locking_shard/replicated_shard_interface.hpp +++ b/src/parsec/runtime_locking_shard/replicated_shard_interface.hpp @@ -3,12 +3,12 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#ifndef OPENCBDC_TX_SRC_3PC_RUNTIME_LOCKING_SHARD_REPLICATED_SHARD_INTERFACE_H_ -#define OPENCBDC_TX_SRC_3PC_RUNTIME_LOCKING_SHARD_REPLICATED_SHARD_INTERFACE_H_ +#ifndef OPENCBDC_TX_SRC_PARSEC_RUNTIME_LOCKING_SHARD_REPLICATED_SHARD_INTERFACE_H_ +#define OPENCBDC_TX_SRC_PARSEC_RUNTIME_LOCKING_SHARD_REPLICATED_SHARD_INTERFACE_H_ #include "interface.hpp" -namespace cbdc::threepc::runtime_locking_shard { +namespace cbdc::parsec::runtime_locking_shard { /// Interface for replicating internal state for prepared and committed /// tickets managed by a locking shard. class replicated_shard_interface { @@ -35,7 +35,7 @@ namespace cbdc::threepc::runtime_locking_shard { broker_id_type m_broker_id{}; /// State updated to apply after commit. state_update_type m_state_update; - /// State of the ticket within the 3PC protocol. + /// State of the ticket within the PArSEC protocol. ticket_state m_state{}; }; diff --git a/src/3pc/runtime_locking_shard/runtime_locking_shardd.cpp b/src/parsec/runtime_locking_shard/runtime_locking_shardd.cpp similarity index 93% rename from src/3pc/runtime_locking_shard/runtime_locking_shardd.cpp rename to src/parsec/runtime_locking_shard/runtime_locking_shardd.cpp index 8407075a2..fe0b841cd 100644 --- a/src/3pc/runtime_locking_shard/runtime_locking_shardd.cpp +++ b/src/parsec/runtime_locking_shard/runtime_locking_shardd.cpp @@ -12,7 +12,7 @@ auto main(int argc, char** argv) -> int { auto log = std::make_shared(cbdc::logging::log_level::warn); - auto cfg = cbdc::threepc::read_config(argc, argv); + auto cfg = cbdc::parsec::read_config(argc, argv); if(!cfg.has_value()) { log->error("Error parsing options"); return 1; @@ -36,7 +36,7 @@ auto main(int argc, char** argv) -> int { raft_endpoints.push_back(new_ep); } - auto controller = cbdc::threepc::runtime_locking_shard::controller( + auto controller = cbdc::parsec::runtime_locking_shard::controller( cfg->m_component_id, *cfg->m_node_id, cfg->m_shard_endpoints[cfg->m_component_id][*cfg->m_node_id], diff --git a/src/3pc/runtime_locking_shard/server.cpp b/src/parsec/runtime_locking_shard/server.cpp similarity index 99% rename from src/3pc/runtime_locking_shard/server.cpp rename to src/parsec/runtime_locking_shard/server.cpp index 56b20bf6b..062c91e45 100644 --- a/src/3pc/runtime_locking_shard/server.cpp +++ b/src/parsec/runtime_locking_shard/server.cpp @@ -7,7 +7,7 @@ #include "util/common/variant_overloaded.hpp" -namespace cbdc::threepc::runtime_locking_shard::rpc { +namespace cbdc::parsec::runtime_locking_shard::rpc { server::server( std::shared_ptr logger, std::shared_ptr impl, diff --git a/src/3pc/runtime_locking_shard/server.hpp b/src/parsec/runtime_locking_shard/server.hpp similarity index 92% rename from src/3pc/runtime_locking_shard/server.hpp rename to src/parsec/runtime_locking_shard/server.hpp index 5d4ed5ef1..eada310b5 100644 --- a/src/3pc/runtime_locking_shard/server.hpp +++ b/src/parsec/runtime_locking_shard/server.hpp @@ -3,15 +3,15 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#ifndef OPENCBDC_TX_SRC_3PC_RUNTIME_LOCKING_SHARD_SERVER_H_ -#define OPENCBDC_TX_SRC_3PC_RUNTIME_LOCKING_SHARD_SERVER_H_ +#ifndef OPENCBDC_TX_SRC_PARSEC_RUNTIME_LOCKING_SHARD_SERVER_H_ +#define OPENCBDC_TX_SRC_PARSEC_RUNTIME_LOCKING_SHARD_SERVER_H_ #include "interface.hpp" #include "messages.hpp" #include "util/common/logging.hpp" #include "util/rpc/async_server.hpp" -namespace cbdc::threepc::runtime_locking_shard::rpc { +namespace cbdc::parsec::runtime_locking_shard::rpc { /// RPC server for a runtime locking shard. class server { public: diff --git a/src/3pc/runtime_locking_shard/state_machine.cpp b/src/parsec/runtime_locking_shard/state_machine.cpp similarity index 98% rename from src/3pc/runtime_locking_shard/state_machine.cpp rename to src/parsec/runtime_locking_shard/state_machine.cpp index 55af0e7d0..e9e09e6bb 100644 --- a/src/3pc/runtime_locking_shard/state_machine.cpp +++ b/src/parsec/runtime_locking_shard/state_machine.cpp @@ -11,7 +11,7 @@ #include "util/serialization/format.hpp" #include "util/serialization/util.hpp" -namespace cbdc::threepc::runtime_locking_shard { +namespace cbdc::parsec::runtime_locking_shard { auto state_machine::commit(uint64_t log_idx, nuraft::buffer& data) -> nuraft::ptr { auto maybe_req = from_buffer(data); diff --git a/src/3pc/runtime_locking_shard/state_machine.hpp b/src/parsec/runtime_locking_shard/state_machine.hpp similarity index 92% rename from src/3pc/runtime_locking_shard/state_machine.hpp rename to src/parsec/runtime_locking_shard/state_machine.hpp index a57b60d4d..743e3e62e 100644 --- a/src/3pc/runtime_locking_shard/state_machine.hpp +++ b/src/parsec/runtime_locking_shard/state_machine.hpp @@ -3,8 +3,8 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#ifndef OPENCBDC_TX_SRC_3PC_RUNTIME_LOCKING_SHARD_STATE_MACHINE_H_ -#define OPENCBDC_TX_SRC_3PC_RUNTIME_LOCKING_SHARD_STATE_MACHINE_H_ +#ifndef OPENCBDC_TX_SRC_PARSEC_RUNTIME_LOCKING_SHARD_STATE_MACHINE_H_ +#define OPENCBDC_TX_SRC_PARSEC_RUNTIME_LOCKING_SHARD_STATE_MACHINE_H_ #include "messages.hpp" #include "replicated_shard.hpp" @@ -12,7 +12,7 @@ #include -namespace cbdc::threepc::runtime_locking_shard { +namespace cbdc::parsec::runtime_locking_shard { /// NuRaft state machine implementation for a runtime locking shard. class state_machine : public nuraft::state_machine { public: diff --git a/src/3pc/ticket_machine/CMakeLists.txt b/src/parsec/ticket_machine/CMakeLists.txt similarity index 94% rename from src/3pc/ticket_machine/CMakeLists.txt rename to src/parsec/ticket_machine/CMakeLists.txt index f889f06b7..a58803fe1 100644 --- a/src/3pc/ticket_machine/CMakeLists.txt +++ b/src/parsec/ticket_machine/CMakeLists.txt @@ -7,7 +7,7 @@ add_library(ticket_machine impl.cpp add_executable(ticket_machined ticket_machined.cpp) target_link_libraries(ticket_machined ticket_machine - threepc + parsec rpc raft network diff --git a/src/3pc/ticket_machine/client.cpp b/src/parsec/ticket_machine/client.cpp similarity index 98% rename from src/3pc/ticket_machine/client.cpp rename to src/parsec/ticket_machine/client.cpp index 78d00f28a..07dc62361 100644 --- a/src/3pc/ticket_machine/client.cpp +++ b/src/parsec/ticket_machine/client.cpp @@ -7,7 +7,7 @@ #include "util/serialization/format.hpp" -namespace cbdc::threepc::ticket_machine::rpc { +namespace cbdc::parsec::ticket_machine::rpc { client::client(std::vector endpoints) : m_client(std::make_unique( std::move(endpoints))) {} diff --git a/src/3pc/ticket_machine/client.hpp b/src/parsec/ticket_machine/client.hpp similarity index 92% rename from src/3pc/ticket_machine/client.hpp rename to src/parsec/ticket_machine/client.hpp index 241079348..52099d531 100644 --- a/src/3pc/ticket_machine/client.hpp +++ b/src/parsec/ticket_machine/client.hpp @@ -3,14 +3,14 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#ifndef OPENCBDC_TX_SRC_3PC_TICKET_MACHINE_CLIENT_H_ -#define OPENCBDC_TX_SRC_3PC_TICKET_MACHINE_CLIENT_H_ +#ifndef OPENCBDC_TX_SRC_PARSEC_TICKET_MACHINE_CLIENT_H_ +#define OPENCBDC_TX_SRC_PARSEC_TICKET_MACHINE_CLIENT_H_ #include "interface.hpp" #include "messages.hpp" #include "util/rpc/tcp_client.hpp" -namespace cbdc::threepc::ticket_machine::rpc { +namespace cbdc::parsec::ticket_machine::rpc { /// RPC client for a remote ticket machine. class client : public interface { public: diff --git a/src/3pc/ticket_machine/controller.cpp b/src/parsec/ticket_machine/controller.cpp similarity index 98% rename from src/3pc/ticket_machine/controller.cpp rename to src/parsec/ticket_machine/controller.cpp index a1cde6b80..6bb72546a 100644 --- a/src/3pc/ticket_machine/controller.cpp +++ b/src/parsec/ticket_machine/controller.cpp @@ -10,7 +10,7 @@ #include "util/rpc/tcp_server.hpp" #include "util/serialization/format.hpp" -namespace cbdc::threepc::ticket_machine { +namespace cbdc::parsec::ticket_machine { controller::controller(size_t node_id, network::endpoint_t server_endpoint, std::vector raft_endpoints, diff --git a/src/3pc/ticket_machine/controller.hpp b/src/parsec/ticket_machine/controller.hpp similarity index 92% rename from src/3pc/ticket_machine/controller.hpp rename to src/parsec/ticket_machine/controller.hpp index 6b2049799..7927f3ef2 100644 --- a/src/3pc/ticket_machine/controller.hpp +++ b/src/parsec/ticket_machine/controller.hpp @@ -3,8 +3,8 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#ifndef OPENCBDC_TX_SRC_3PC_TICKET_MACHINE_CONTROLLER_H_ -#define OPENCBDC_TX_SRC_3PC_TICKET_MACHINE_CONTROLLER_H_ +#ifndef OPENCBDC_TX_SRC_PARSEC_TICKET_MACHINE_CONTROLLER_H_ +#define OPENCBDC_TX_SRC_PARSEC_TICKET_MACHINE_CONTROLLER_H_ #include "impl.hpp" #include "state_machine.hpp" @@ -12,7 +12,7 @@ #include "util/raft/rpc_server.hpp" #include "util/rpc/tcp_server.hpp" -namespace cbdc::threepc::ticket_machine { +namespace cbdc::parsec::ticket_machine { /// Manages a replicated ticket machine using Raft. class controller { public: diff --git a/src/3pc/ticket_machine/impl.cpp b/src/parsec/ticket_machine/impl.cpp similarity index 94% rename from src/3pc/ticket_machine/impl.cpp rename to src/parsec/ticket_machine/impl.cpp index baec4c54e..6b6a1350d 100644 --- a/src/3pc/ticket_machine/impl.cpp +++ b/src/parsec/ticket_machine/impl.cpp @@ -5,7 +5,7 @@ #include "impl.hpp" -namespace cbdc::threepc::ticket_machine { +namespace cbdc::parsec::ticket_machine { impl::impl(std::shared_ptr logger, ticket_number_type range) : m_log(std::move(logger)), m_range(range) {} diff --git a/src/3pc/ticket_machine/impl.hpp b/src/parsec/ticket_machine/impl.hpp similarity index 89% rename from src/3pc/ticket_machine/impl.hpp rename to src/parsec/ticket_machine/impl.hpp index fcc9aa454..ca6e7c3da 100644 --- a/src/3pc/ticket_machine/impl.hpp +++ b/src/parsec/ticket_machine/impl.hpp @@ -3,8 +3,8 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#ifndef OPENCBDC_TX_SRC_3PC_TICKET_MACHINE_IMPL_H_ -#define OPENCBDC_TX_SRC_3PC_TICKET_MACHINE_IMPL_H_ +#ifndef OPENCBDC_TX_SRC_PARSEC_TICKET_MACHINE_IMPL_H_ +#define OPENCBDC_TX_SRC_PARSEC_TICKET_MACHINE_IMPL_H_ #include "interface.hpp" #include "util/common/logging.hpp" @@ -12,7 +12,7 @@ #include #include -namespace cbdc::threepc::ticket_machine { +namespace cbdc::parsec::ticket_machine { /// \brief Thread-safe ticket machine implementation. class impl : public interface { public: diff --git a/src/3pc/ticket_machine/interface.hpp b/src/parsec/ticket_machine/interface.hpp similarity index 93% rename from src/3pc/ticket_machine/interface.hpp rename to src/parsec/ticket_machine/interface.hpp index 02052e7f7..8dc7d537e 100644 --- a/src/3pc/ticket_machine/interface.hpp +++ b/src/parsec/ticket_machine/interface.hpp @@ -3,15 +3,15 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#ifndef OPENCBDC_TX_SRC_3PC_TICKET_MACHINE_INTERFACE_H_ -#define OPENCBDC_TX_SRC_3PC_TICKET_MACHINE_INTERFACE_H_ +#ifndef OPENCBDC_TX_SRC_PARSEC_TICKET_MACHINE_INTERFACE_H_ +#define OPENCBDC_TX_SRC_PARSEC_TICKET_MACHINE_INTERFACE_H_ #include #include #include #include -namespace cbdc::threepc::ticket_machine { +namespace cbdc::parsec::ticket_machine { /// Type alias for a ticket number. using ticket_number_type = uint64_t; diff --git a/src/3pc/ticket_machine/messages.hpp b/src/parsec/ticket_machine/messages.hpp similarity index 74% rename from src/3pc/ticket_machine/messages.hpp rename to src/parsec/ticket_machine/messages.hpp index e8f76eb34..986b757a7 100644 --- a/src/3pc/ticket_machine/messages.hpp +++ b/src/parsec/ticket_machine/messages.hpp @@ -3,12 +3,12 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#ifndef OPENCBDC_TX_SRC_3PC_TICKET_MACHINE_MESSAGES_H_ -#define OPENCBDC_TX_SRC_3PC_TICKET_MACHINE_MESSAGES_H_ +#ifndef OPENCBDC_TX_SRC_PARSEC_TICKET_MACHINE_MESSAGES_H_ +#define OPENCBDC_TX_SRC_PARSEC_TICKET_MACHINE_MESSAGES_H_ #include "interface.hpp" -namespace cbdc::threepc::ticket_machine::rpc { +namespace cbdc::parsec::ticket_machine::rpc { /// Ticket machine RPC request type. using request = std::variant; /// Ticket machine RPC response type. diff --git a/src/3pc/ticket_machine/state_machine.cpp b/src/parsec/ticket_machine/state_machine.cpp similarity index 98% rename from src/3pc/ticket_machine/state_machine.cpp rename to src/parsec/ticket_machine/state_machine.cpp index f9db0872e..ae1502bed 100644 --- a/src/3pc/ticket_machine/state_machine.cpp +++ b/src/parsec/ticket_machine/state_machine.cpp @@ -8,7 +8,7 @@ #include "util/rpc/format.hpp" #include "util/serialization/format.hpp" -namespace cbdc::threepc::ticket_machine { +namespace cbdc::parsec::ticket_machine { state_machine::state_machine(std::shared_ptr logger, ticket_number_type batch_size) : m_logger(std::move(logger)) { diff --git a/src/3pc/ticket_machine/state_machine.hpp b/src/parsec/ticket_machine/state_machine.hpp similarity index 93% rename from src/3pc/ticket_machine/state_machine.hpp rename to src/parsec/ticket_machine/state_machine.hpp index ec011d674..739d609d3 100644 --- a/src/3pc/ticket_machine/state_machine.hpp +++ b/src/parsec/ticket_machine/state_machine.hpp @@ -3,8 +3,8 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#ifndef OPENCBDC_TX_SRC_3PC_TICKET_MACHINE_STATE_MACHINE_H_ -#define OPENCBDC_TX_SRC_3PC_TICKET_MACHINE_STATE_MACHINE_H_ +#ifndef OPENCBDC_TX_SRC_PARSEC_TICKET_MACHINE_STATE_MACHINE_H_ +#define OPENCBDC_TX_SRC_PARSEC_TICKET_MACHINE_STATE_MACHINE_H_ #include "impl.hpp" #include "messages.hpp" @@ -13,7 +13,7 @@ #include -namespace cbdc::threepc::ticket_machine { +namespace cbdc::parsec::ticket_machine { /// NuRaft state machine implementation for a replicated ticket machine. class state_machine : public nuraft::state_machine, diff --git a/src/3pc/ticket_machine/ticket_machined.cpp b/src/parsec/ticket_machine/ticket_machined.cpp similarity index 93% rename from src/3pc/ticket_machine/ticket_machined.cpp rename to src/parsec/ticket_machine/ticket_machined.cpp index e53353b4f..56cf10ff3 100644 --- a/src/3pc/ticket_machine/ticket_machined.cpp +++ b/src/parsec/ticket_machine/ticket_machined.cpp @@ -15,7 +15,7 @@ auto main(int argc, char** argv) -> int { auto log = std::make_shared(cbdc::logging::log_level::warn); - auto cfg = cbdc::threepc::read_config(argc, argv); + auto cfg = cbdc::parsec::read_config(argc, argv); if(!cfg.has_value()) { log->error("Error parsing options"); return 1; @@ -33,7 +33,7 @@ auto main(int argc, char** argv) -> int { raft_endpoints.push_back(new_ep); } - auto raft_server = cbdc::threepc::ticket_machine::controller( + auto raft_server = cbdc::parsec::ticket_machine::controller( cfg->m_component_id, cfg->m_ticket_machine_endpoints[cfg->m_component_id], raft_endpoints, diff --git a/src/3pc/util.cpp b/src/parsec/util.cpp similarity index 97% rename from src/3pc/util.cpp rename to src/parsec/util.cpp index b79342ed5..2bef50686 100644 --- a/src/3pc/util.cpp +++ b/src/parsec/util.cpp @@ -7,7 +7,7 @@ #include -namespace cbdc::threepc { +namespace cbdc::parsec { auto split(const std::string& s, const std::string& delim) -> std::vector { size_t pos_start{}; @@ -197,18 +197,18 @@ namespace cbdc::threepc { const std::function& result_callback) -> bool { auto begin_res = broker->begin([=](auto begin_ret) { if(!std::holds_alternative< - cbdc::threepc::ticket_machine::ticket_number_type>( + cbdc::parsec::ticket_machine::ticket_number_type>( begin_ret)) { result_callback(false); return; } auto ticket_number - = std::get( + = std::get( begin_ret); auto lock_res = broker->try_lock( ticket_number, key, - cbdc::threepc::runtime_locking_shard::lock_type::write, + cbdc::parsec::runtime_locking_shard::lock_type::write, [=](auto try_lock_res) { if(!std::holds_alternative(try_lock_res)) { result_callback(false); diff --git a/src/3pc/util.hpp b/src/parsec/util.hpp similarity index 96% rename from src/3pc/util.hpp rename to src/parsec/util.hpp index b75ea31a2..e855624e1 100644 --- a/src/3pc/util.hpp +++ b/src/parsec/util.hpp @@ -3,14 +3,14 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#ifndef OPENCBDC_TX_SRC_3PC_UTIL_H_ -#define OPENCBDC_TX_SRC_3PC_UTIL_H_ +#ifndef OPENCBDC_TX_SRC_PARSEC_UTIL_H_ +#define OPENCBDC_TX_SRC_PARSEC_UTIL_H_ #include "broker/interface.hpp" #include "util/common/config.hpp" #include "util/common/logging.hpp" -namespace cbdc::threepc { +namespace cbdc::parsec { /// Type of load to generate for benchmarking enum class load_type { /// Base token transfer diff --git a/tests/integration/CMakeLists.txt b/tests/integration/CMakeLists.txt index 8841fa059..76f9bf979 100644 --- a/tests/integration/CMakeLists.txt +++ b/tests/integration/CMakeLists.txt @@ -10,7 +10,7 @@ add_executable(run_integration_tests mock_system.cpp shard_integration_test.cpp replicated_shard_integration_tests.cpp replicated_atomizer_integration_tests.cpp - threepc_evm_end_to_end_test.cpp + parsec_evm_end_to_end_test.cpp two_phase_end_to_end_test.cpp watchtower_integration_test.cpp) diff --git a/tests/integration/gtest_evm_jsonrpc_client.cpp b/tests/integration/gtest_evm_jsonrpc_client.cpp index 7ffa05ec4..9e5a01d60 100644 --- a/tests/integration/gtest_evm_jsonrpc_client.cpp +++ b/tests/integration/gtest_evm_jsonrpc_client.cpp @@ -5,17 +5,17 @@ #include "gtest_evm_jsonrpc_client.hpp" -#include "3pc/agent/runners/evm/address.hpp" -#include "3pc/agent/runners/evm/rlp.hpp" -#include "3pc/agent/runners/evm/serialization.hpp" -#include "3pc/agent/runners/evm/util.hpp" +#include "parsec/agent/runners/evm/address.hpp" +#include "parsec/agent/runners/evm/rlp.hpp" +#include "parsec/agent/runners/evm/serialization.hpp" +#include "parsec/agent/runners/evm/util.hpp" #include #include namespace cbdc::test { static std::string gtest_descr() { - // e.g.: "GTEST: threepc_evm_end_to_end_test.native_transfer" + // e.g.: "GTEST: parsec_evm_end_to_end_test.native_transfer" return std::string("GTEST: ") + ::testing::UnitTest::GetInstance() ->current_test_info() @@ -37,9 +37,9 @@ namespace cbdc::test { get_transaction_count_str_(addr, txcount_str); m_log->debug(gtest_descr(), std::string(__FUNCTION__) + "()", - "0x" + cbdc::threepc::agent::runner::to_hex(addr), + "0x" + cbdc::parsec::agent::runner::to_hex(addr), txcount_str); - return cbdc::threepc::agent::runner::uint256be_from_hex(txcount_str) + return cbdc::parsec::agent::runner::uint256be_from_hex(txcount_str) .value(); } @@ -47,7 +47,7 @@ namespace cbdc::test { const evmc::address& addr, std::string& out_txcount_str) { auto params = Json::Value(); - params.append("0x" + cbdc::threepc::agent::runner::to_hex(addr)); + params.append("0x" + cbdc::parsec::agent::runner::to_hex(addr)); params.append("latest"); std::atomic tx_done{false}; @@ -72,9 +72,9 @@ namespace cbdc::test { } void gtest_evm_jsonrpc_client::send_transaction( - const cbdc::threepc::agent::runner::evm_tx& etx, + const cbdc::parsec::agent::runner::evm_tx& etx, std::string& out_txid) { - const auto rlp_tx_buf = cbdc::threepc::agent::runner::tx_encode(etx); + const auto rlp_tx_buf = cbdc::parsec::agent::runner::tx_encode(etx); const auto rlp_tx_hex = "0x" + rlp_tx_buf.to_hex(); auto params = Json::Value(); @@ -152,7 +152,7 @@ namespace cbdc::test { const evmc::address& addr, std::optional& out_balance) { auto params = Json::Value(); - params.append("0x" + cbdc::threepc::agent::runner::to_hex(addr)); + params.append("0x" + cbdc::parsec::agent::runner::to_hex(addr)); std::atomic tx_done{false}; call("eth_getBalance", @@ -164,9 +164,8 @@ namespace cbdc::test { ASSERT_TRUE(v.isMember(m_json_result_key)); auto res_str = v[m_json_result_key].asString(); - out_balance - = cbdc::threepc::agent::runner::uint256be_from_hex( - res_str); + out_balance = cbdc::parsec::agent::runner::uint256be_from_hex( + res_str); tx_done = true; }); diff --git a/tests/integration/gtest_evm_jsonrpc_client.hpp b/tests/integration/gtest_evm_jsonrpc_client.hpp index 6c0e18e30..e3319e0a6 100644 --- a/tests/integration/gtest_evm_jsonrpc_client.hpp +++ b/tests/integration/gtest_evm_jsonrpc_client.hpp @@ -6,7 +6,7 @@ #ifndef OPENCBDC_TEST_INTEGRATION_GTEST_EVM_JSONRPC_CLIENT_H_ #define OPENCBDC_TEST_INTEGRATION_GTEST_EVM_JSONRPC_CLIENT_H_ -#include "3pc/agent/runners/evm/messages.hpp" +#include "parsec/agent/runners/evm/messages.hpp" #include "util/rpc/http/json_rpc_http_client.hpp" namespace cbdc::test { @@ -18,7 +18,7 @@ namespace cbdc::test { long timeout, const std::shared_ptr& log); - void send_transaction(const cbdc::threepc::agent::runner::evm_tx& tx, + void send_transaction(const cbdc::parsec::agent::runner::evm_tx& tx, std::string& out_txid); void get_transaction_receipt(const std::string& txid, diff --git a/tests/integration/threepc_evm_end_to_end_test.cpp b/tests/integration/parsec_evm_end_to_end_test.cpp similarity index 71% rename from tests/integration/threepc_evm_end_to_end_test.cpp rename to tests/integration/parsec_evm_end_to_end_test.cpp index bb4ac7173..20a5e8f70 100644 --- a/tests/integration/threepc_evm_end_to_end_test.cpp +++ b/tests/integration/parsec_evm_end_to_end_test.cpp @@ -3,18 +3,18 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#include "3pc/agent/impl.hpp" -#include "3pc/agent/runners/evm/address.hpp" -#include "3pc/agent/runners/evm/http_server.hpp" -#include "3pc/agent/runners/evm/math.hpp" -#include "3pc/agent/runners/evm/rlp.hpp" -#include "3pc/agent/runners/evm/signature.hpp" -#include "3pc/agent/runners/evm/util.hpp" -#include "3pc/broker/impl.hpp" -#include "3pc/directory/impl.hpp" -#include "3pc/runtime_locking_shard/impl.hpp" -#include "3pc/ticket_machine/impl.hpp" #include "gtest_evm_jsonrpc_client.hpp" +#include "parsec/agent/impl.hpp" +#include "parsec/agent/runners/evm/address.hpp" +#include "parsec/agent/runners/evm/http_server.hpp" +#include "parsec/agent/runners/evm/math.hpp" +#include "parsec/agent/runners/evm/rlp.hpp" +#include "parsec/agent/runners/evm/signature.hpp" +#include "parsec/agent/runners/evm/util.hpp" +#include "parsec/broker/impl.hpp" +#include "parsec/directory/impl.hpp" +#include "parsec/runtime_locking_shard/impl.hpp" +#include "parsec/ticket_machine/impl.hpp" #include "sample_erc20_contract.hpp" #include @@ -36,7 +36,7 @@ static void gtest_erc20_output_hex_to_ascii(const std::string& hex, } static std::string gtest_descr() { - // e.g.: "GTEST: threepc_evm_end_to_end_test.native_transfer" + // e.g.: "GTEST: parsec_evm_end_to_end_test.native_transfer" return std::string("GTEST: ") + ::testing::UnitTest::GetInstance() ->current_test_info() @@ -45,10 +45,10 @@ static std::string gtest_descr() { + ::testing::UnitTest::GetInstance()->current_test_info()->name(); } -class threepc_evm_end_to_end_test : public ::testing::Test { +class parsec_evm_end_to_end_test : public ::testing::Test { protected: void SetUp() override { - m_log->debug("threepc_evm_end_to_end_test::Setup()"); + m_log->debug("parsec_evm_end_to_end_test::Setup()"); const auto rpc_server_endpoint = cbdc::network::endpoint_t{"127.0.0.1", 7007}; @@ -108,10 +108,10 @@ class threepc_evm_end_to_end_test : public ::testing::Test { std::shared_ptr m_log{ std::make_shared(cbdc::logging::log_level::info)}; - cbdc::threepc::config m_cfg{}; - std::shared_ptr m_broker; + cbdc::parsec::config m_cfg{}; + std::shared_ptr m_broker; - std::unique_ptr m_rpc_server; + std::unique_ptr m_rpc_server; std::shared_ptr m_rpc_client; std::shared_ptr m_secp_context{ @@ -127,9 +127,9 @@ class threepc_evm_end_to_end_test : public ::testing::Test { evmc::uint256be m_init_acct_balance; }; -void threepc_evm_end_to_end_test::init_accounts() { +void parsec_evm_end_to_end_test::init_accounts() { // 1x10^24: i.e. 1mm with 18 decimals: - m_init_acct_balance = cbdc::threepc::agent::runner::uint256be_from_hex( + m_init_acct_balance = cbdc::parsec::agent::runner::uint256be_from_hex( "0xd3c21bcecceda1000000") .value(); @@ -138,45 +138,45 @@ void threepc_evm_end_to_end_test::init_accounts() { m_acct1_privkey = cbdc::hash_from_hex( "4bfb9012977703f9b30e8a8e98ce77f2c01e93b8dc6f46159162d5c6560e4e89"); - m_acct0_ethaddr = cbdc::threepc::agent::runner::eth_addr(m_acct0_privkey, - m_secp_context); - m_acct1_ethaddr = cbdc::threepc::agent::runner::eth_addr(m_acct1_privkey, - m_secp_context); + m_acct0_ethaddr = cbdc::parsec::agent::runner::eth_addr(m_acct0_privkey, + m_secp_context); + m_acct1_ethaddr = cbdc::parsec::agent::runner::eth_addr(m_acct1_privkey, + m_secp_context); const auto check_ok_cb = [](bool ok) { ASSERT_TRUE(ok); }; // Initialize native balances: - auto acc1 = cbdc::threepc::agent::runner::evm_account(); + auto acc1 = cbdc::parsec::agent::runner::evm_account(); acc1.m_balance = evmc::uint256be(m_init_acct_balance); - cbdc::threepc::put_row(m_broker, - cbdc::make_buffer(m_acct0_ethaddr), - cbdc::make_buffer(acc1), - check_ok_cb); + cbdc::parsec::put_row(m_broker, + cbdc::make_buffer(m_acct0_ethaddr), + cbdc::make_buffer(acc1), + check_ok_cb); - auto acc2 = cbdc::threepc::agent::runner::evm_account(); + auto acc2 = cbdc::parsec::agent::runner::evm_account(); acc2.m_balance = evmc::uint256be(m_init_acct_balance); - cbdc::threepc::put_row(m_broker, - cbdc::make_buffer(m_acct1_ethaddr), - cbdc::make_buffer(acc2), - check_ok_cb); + cbdc::parsec::put_row(m_broker, + cbdc::make_buffer(m_acct1_ethaddr), + cbdc::make_buffer(acc2), + check_ok_cb); } -void threepc_evm_end_to_end_test::init_jsonrpc_server_and_client( +void parsec_evm_end_to_end_test::init_jsonrpc_server_and_client( const cbdc::network::endpoint_t& rpc_server_endpoint) { auto shards = std::vector< - std::shared_ptr>( - {std::make_shared(m_log)}); + std::shared_ptr>( + {std::make_shared(m_log)}); - m_broker = std::make_shared( + m_broker = std::make_shared( 0, shards, - std::make_shared(m_log, 1), - std::make_shared(1), + std::make_shared(m_log, 1), + std::make_shared(1), m_log); - m_rpc_server = std::make_unique( + m_rpc_server = std::make_unique( std::make_unique(rpc_server_endpoint, true), m_broker, @@ -192,14 +192,14 @@ void threepc_evm_end_to_end_test::init_jsonrpc_server_and_client( m_log); } -void threepc_evm_end_to_end_test::test_erc20_tx_get_raw_output_data_( +void parsec_evm_end_to_end_test::test_erc20_tx_get_raw_output_data_( const evmc::address& contract_address, const evmc::address& from_address, const cbdc::privkey_t& from_privkey, const cbdc::buffer& input_data, std::string& out_raw_output_data) { - const auto make_evmtx_ = [&]() -> cbdc::threepc::agent::runner::evm_tx { - auto etx = cbdc::threepc::agent::runner::evm_tx(); + const auto make_evmtx_ = [&]() -> cbdc::parsec::agent::runner::evm_tx { + auto etx = cbdc::parsec::agent::runner::evm_tx(); etx.m_to = contract_address; etx.m_nonce = m_rpc_client->get_transaction_count(from_address); // NOTE etx.m_value is unset @@ -209,20 +209,20 @@ void threepc_evm_end_to_end_test::test_erc20_tx_get_raw_output_data_( etx.m_input.resize(input_data.size()); std::memcpy(etx.m_input.data(), input_data.data(), input_data.size()); - auto sighash = cbdc::threepc::agent::runner::sig_hash(etx); - etx.m_sig = cbdc::threepc::agent::runner::eth_sign(from_privkey, - sighash, - etx.m_type, - m_secp_context); + auto sighash = cbdc::parsec::agent::runner::sig_hash(etx); + etx.m_sig = cbdc::parsec::agent::runner::eth_sign(from_privkey, + sighash, + etx.m_type, + m_secp_context); return etx; }; m_log->info(gtest_descr(), std::string(__FUNCTION__) + "()", "From:", - cbdc::threepc::agent::runner::to_hex(from_address), + cbdc::parsec::agent::runner::to_hex(from_address), "Contract:", - cbdc::threepc::agent::runner::to_hex(contract_address)); + cbdc::parsec::agent::runner::to_hex(contract_address)); const auto etx = make_evmtx_(); @@ -236,11 +236,11 @@ void threepc_evm_end_to_end_test::test_erc20_tx_get_raw_output_data_( ASSERT_TRUE(txreceipt.isMember("from")); ASSERT_EQ(txreceipt["from"], - "0x" + cbdc::threepc::agent::runner::to_hex(from_address)); + "0x" + cbdc::parsec::agent::runner::to_hex(from_address)); ASSERT_TRUE(txreceipt.isMember("to")); ASSERT_EQ(txreceipt["to"], - "0x" + cbdc::threepc::agent::runner::to_hex(contract_address)); + "0x" + cbdc::parsec::agent::runner::to_hex(contract_address)); ASSERT_TRUE(txreceipt.isMember("transactionHash")); ASSERT_EQ(txreceipt["transactionHash"], txid); @@ -253,7 +253,7 @@ void threepc_evm_end_to_end_test::test_erc20_tx_get_raw_output_data_( ASSERT_TRUE(txreceipt.isMember("transaction")); ASSERT_TRUE(txreceipt["transaction"].isMember("value")); - ASSERT_EQ(cbdc::threepc::agent::runner::uint256be_from_hex( + ASSERT_EQ(cbdc::parsec::agent::runner::uint256be_from_hex( txreceipt["transaction"]["value"].asString()), etx.m_value); @@ -261,7 +261,7 @@ void threepc_evm_end_to_end_test::test_erc20_tx_get_raw_output_data_( out_raw_output_data = txreceipt["output_data"].asString(); } -void threepc_evm_end_to_end_test::test_erc20_name( +void parsec_evm_end_to_end_test::test_erc20_name( const evmc::address& contract_address, const evmc::address& from_address, const cbdc::privkey_t& from_privkey, @@ -283,7 +283,7 @@ void threepc_evm_end_to_end_test::test_erc20_name( ASSERT_EQ(formatted_resultstr, expected_name); } -void threepc_evm_end_to_end_test::test_erc20_symbol( +void parsec_evm_end_to_end_test::test_erc20_symbol( const evmc::address& contract_address, const evmc::address& from_address, const cbdc::privkey_t& from_privkey, @@ -305,7 +305,7 @@ void threepc_evm_end_to_end_test::test_erc20_symbol( ASSERT_EQ(formatted_resultstr, expected_symbol); } -void threepc_evm_end_to_end_test::test_erc20_decimals( +void parsec_evm_end_to_end_test::test_erc20_decimals( const evmc::address& contract_address, const evmc::address& from_address, const cbdc::privkey_t& from_privkey, @@ -314,7 +314,7 @@ void threepc_evm_end_to_end_test::test_erc20_decimals( gtest_descr(), std::string(__FUNCTION__) + "()", "Confirming that number of decimals is:", - cbdc::threepc::agent::runner::to_hex_trimmed(expected_decimals)); + cbdc::parsec::agent::runner::to_hex_trimmed(expected_decimals)); std::string raw_output_data; test_erc20_tx_get_raw_output_data_( contract_address, @@ -324,12 +324,12 @@ void threepc_evm_end_to_end_test::test_erc20_decimals( raw_output_data); const auto decimals - = cbdc::threepc::agent::runner::uint256be_from_hex(raw_output_data); + = cbdc::parsec::agent::runner::uint256be_from_hex(raw_output_data); ASSERT_TRUE(decimals.has_value()); ASSERT_EQ(decimals.value(), expected_decimals); } -void threepc_evm_end_to_end_test::test_erc20_total_supply( +void parsec_evm_end_to_end_test::test_erc20_total_supply( const evmc::address& contract_address, const evmc::address& from_address, const cbdc::privkey_t& from_privkey, @@ -338,7 +338,7 @@ void threepc_evm_end_to_end_test::test_erc20_total_supply( gtest_descr(), std::string(__FUNCTION__) + "()", "Confirming that total supply is:", - cbdc::threepc::agent::runner::to_hex_trimmed(expected_total_supply)); + cbdc::parsec::agent::runner::to_hex_trimmed(expected_total_supply)); std::string raw_output_data; test_erc20_tx_get_raw_output_data_( contract_address, @@ -348,17 +348,17 @@ void threepc_evm_end_to_end_test::test_erc20_total_supply( raw_output_data); const auto decimals - = cbdc::threepc::agent::runner::uint256be_from_hex(raw_output_data); + = cbdc::parsec::agent::runner::uint256be_from_hex(raw_output_data); ASSERT_TRUE(decimals.has_value()); ASSERT_EQ(decimals.value(), expected_total_supply); } -void threepc_evm_end_to_end_test::test_erc20_deploy_contract( +void parsec_evm_end_to_end_test::test_erc20_deploy_contract( const evmc::address& from_addr, const cbdc::privkey_t& from_privkey, evmc::address& out_contract_address) { - const auto make_evmtx_ = [&]() -> cbdc::threepc::agent::runner::evm_tx { - auto etx = cbdc::threepc::agent::runner::evm_tx(); + const auto make_evmtx_ = [&]() -> cbdc::parsec::agent::runner::evm_tx { + auto etx = cbdc::parsec::agent::runner::evm_tx(); // NOTE etx.m_to is empty for contract deployment etx.m_nonce = m_rpc_client->get_transaction_count(from_addr); // NOTE etx.m_value is unset @@ -372,18 +372,18 @@ void threepc_evm_end_to_end_test::test_erc20_deploy_contract( contract_bytecode.data(), contract_bytecode.size()); - auto sighash = cbdc::threepc::agent::runner::sig_hash(etx); - etx.m_sig = cbdc::threepc::agent::runner::eth_sign(from_privkey, - sighash, - etx.m_type, - m_secp_context); + auto sighash = cbdc::parsec::agent::runner::sig_hash(etx); + etx.m_sig = cbdc::parsec::agent::runner::eth_sign(from_privkey, + sighash, + etx.m_type, + m_secp_context); return etx; }; const auto etx = make_evmtx_(); const auto maybe_from - = cbdc::threepc::agent::runner::check_signature(etx, m_secp_context); + = cbdc::parsec::agent::runner::check_signature(etx, m_secp_context); ASSERT_TRUE(maybe_from.has_value()); ASSERT_EQ(maybe_from.value(), from_addr); @@ -392,15 +392,15 @@ void threepc_evm_end_to_end_test::test_erc20_deploy_contract( m_rpc_client->send_transaction(etx, txid); const auto expected_contract_address - = cbdc::threepc::agent::runner::contract_address(from_addr, - etx.m_nonce); + = cbdc::parsec::agent::runner::contract_address(from_addr, + etx.m_nonce); m_log->info( gtest_descr(), std::string(__FUNCTION__) + "()", "Owner:", - cbdc::threepc::agent::runner::to_hex(from_addr), + cbdc::parsec::agent::runner::to_hex(from_addr), "Contract Addr:", - cbdc::threepc::agent::runner::to_hex(expected_contract_address)); + cbdc::parsec::agent::runner::to_hex(expected_contract_address)); // Retrieve the receipt and check it: Json::Value txreceipt; @@ -408,13 +408,12 @@ void threepc_evm_end_to_end_test::test_erc20_deploy_contract( ASSERT_TRUE(txreceipt.isMember("from")); ASSERT_EQ(txreceipt["from"], - "0x" + cbdc::threepc::agent::runner::to_hex(from_addr)); + "0x" + cbdc::parsec::agent::runner::to_hex(from_addr)); ASSERT_TRUE(txreceipt.isMember("contractAddress")); ASSERT_EQ( txreceipt["contractAddress"], - "0x" - + cbdc::threepc::agent::runner::to_hex(expected_contract_address)); + "0x" + cbdc::parsec::agent::runner::to_hex(expected_contract_address)); ASSERT_TRUE(txreceipt.isMember("to")); ASSERT_TRUE(txreceipt["to"].isNull()); @@ -430,25 +429,24 @@ void threepc_evm_end_to_end_test::test_erc20_deploy_contract( ASSERT_TRUE(txreceipt.isMember("transaction")); ASSERT_TRUE(txreceipt["transaction"].isMember("value")); - ASSERT_EQ(cbdc::threepc::agent::runner::uint256be_from_hex( + ASSERT_EQ(cbdc::parsec::agent::runner::uint256be_from_hex( txreceipt["transaction"]["value"].asString()), etx.m_value); out_contract_address = expected_contract_address; } -void threepc_evm_end_to_end_test::test_erc20_get_balance( +void parsec_evm_end_to_end_test::test_erc20_get_balance( const evmc::address& contract_address, const evmc::address& acct_address, const cbdc::privkey_t& acct_privkey, const evmc::uint256be& expected_balance) { - m_log->info( - gtest_descr(), - std::string(__FUNCTION__) + "()", - "Confirming that balance of address", - cbdc::threepc::agent::runner::to_hex(acct_address), - "is", - cbdc::threepc::agent::runner::to_hex_trimmed(expected_balance)); + m_log->info(gtest_descr(), + std::string(__FUNCTION__) + "()", + "Confirming that balance of address", + cbdc::parsec::agent::runner::to_hex(acct_address), + "is", + cbdc::parsec::agent::runner::to_hex_trimmed(expected_balance)); std::string raw_output_data; test_erc20_tx_get_raw_output_data_( @@ -459,19 +457,19 @@ void threepc_evm_end_to_end_test::test_erc20_get_balance( raw_output_data); const auto decimals - = cbdc::threepc::agent::runner::uint256be_from_hex(raw_output_data); + = cbdc::parsec::agent::runner::uint256be_from_hex(raw_output_data); ASSERT_TRUE(decimals.has_value()); ASSERT_EQ(decimals.value(), expected_balance); } -void threepc_evm_end_to_end_test::test_erc20_send_tokens( +void parsec_evm_end_to_end_test::test_erc20_send_tokens( const evmc::address& contract_address, const evmc::address& from_address, const cbdc::privkey_t& from_privkey, const evmc::address& to_address, const evmc::uint256be& erc20_value) { - const auto make_evmtx_ = [&]() -> cbdc::threepc::agent::runner::evm_tx { - auto etx = cbdc::threepc::agent::runner::evm_tx(); + const auto make_evmtx_ = [&]() -> cbdc::parsec::agent::runner::evm_tx { + auto etx = cbdc::parsec::agent::runner::evm_tx(); etx.m_to = contract_address; etx.m_nonce = m_rpc_client->get_transaction_count(from_address); // NOTE etx.m_value is unset @@ -484,22 +482,22 @@ void threepc_evm_end_to_end_test::test_erc20_send_tokens( etx.m_input.resize(input_data.size()); std::memcpy(etx.m_input.data(), input_data.data(), input_data.size()); - auto sighash = cbdc::threepc::agent::runner::sig_hash(etx); - etx.m_sig = cbdc::threepc::agent::runner::eth_sign(from_privkey, - sighash, - etx.m_type, - m_secp_context); + auto sighash = cbdc::parsec::agent::runner::sig_hash(etx); + etx.m_sig = cbdc::parsec::agent::runner::eth_sign(from_privkey, + sighash, + etx.m_type, + m_secp_context); return etx; }; m_log->info(gtest_descr(), std::string(__FUNCTION__) + "()", "From:", - cbdc::threepc::agent::runner::to_hex(from_address), + cbdc::parsec::agent::runner::to_hex(from_address), "To:", - cbdc::threepc::agent::runner::to_hex(to_address), + cbdc::parsec::agent::runner::to_hex(to_address), "Contract:", - cbdc::threepc::agent::runner::to_hex(contract_address)); + cbdc::parsec::agent::runner::to_hex(contract_address)); const auto etx = make_evmtx_(); @@ -513,11 +511,11 @@ void threepc_evm_end_to_end_test::test_erc20_send_tokens( ASSERT_TRUE(txreceipt.isMember("from")); ASSERT_EQ(txreceipt["from"], - "0x" + cbdc::threepc::agent::runner::to_hex(from_address)); + "0x" + cbdc::parsec::agent::runner::to_hex(from_address)); ASSERT_TRUE(txreceipt.isMember("to")); ASSERT_EQ(txreceipt["to"], - "0x" + cbdc::threepc::agent::runner::to_hex(contract_address)); + "0x" + cbdc::parsec::agent::runner::to_hex(contract_address)); ASSERT_TRUE(txreceipt.isMember("transactionHash")); ASSERT_EQ(txreceipt["transactionHash"], txid); @@ -530,7 +528,7 @@ void threepc_evm_end_to_end_test::test_erc20_send_tokens( ASSERT_TRUE(txreceipt.isMember("transaction")); ASSERT_TRUE(txreceipt["transaction"].isMember("value")); - ASSERT_EQ(cbdc::threepc::agent::runner::uint256be_from_hex( + ASSERT_EQ(cbdc::parsec::agent::runner::uint256be_from_hex( txreceipt["transaction"]["value"].asString()), etx.m_value); @@ -540,39 +538,39 @@ void threepc_evm_end_to_end_test::test_erc20_send_tokens( ASSERT_TRUE(txreceipt["logs"][0].isMember("data")); ASSERT_TRUE(txreceipt["logs"][0]["data"].isString()); ASSERT_EQ(txreceipt["logs"][0]["data"].asString(), - "0x" + cbdc::threepc::agent::runner::to_hex(erc20_value)); + "0x" + cbdc::parsec::agent::runner::to_hex(erc20_value)); ASSERT_TRUE(txreceipt["logs"][0].isMember("address")); ASSERT_TRUE(txreceipt["logs"][0]["address"].isString()); ASSERT_EQ(txreceipt["logs"][0]["address"].asString(), - "0x" + cbdc::threepc::agent::runner::to_hex(contract_address)); + "0x" + cbdc::parsec::agent::runner::to_hex(contract_address)); ASSERT_TRUE(txreceipt["logs"][0].isMember("transactionHash")); ASSERT_TRUE(txreceipt["logs"][0]["transactionHash"].isString()); ASSERT_EQ(txreceipt["logs"][0]["transactionHash"].asString(), txid); } -TEST_F(threepc_evm_end_to_end_test, native_transfer) { +TEST_F(parsec_evm_end_to_end_test, native_transfer) { const auto send_value{evmc::uint256be(1000)}; - const auto make_evmtx_ = [&]() -> cbdc::threepc::agent::runner::evm_tx { - auto etx = cbdc::threepc::agent::runner::evm_tx(); + const auto make_evmtx_ = [&]() -> cbdc::parsec::agent::runner::evm_tx { + auto etx = cbdc::parsec::agent::runner::evm_tx(); etx.m_to = m_acct1_ethaddr; etx.m_nonce = m_rpc_client->get_transaction_count(m_acct0_ethaddr); etx.m_value = send_value; etx.m_gas_price = evmc::uint256be(0); etx.m_gas_limit = evmc::uint256be(0xffffffff); - auto sighash = cbdc::threepc::agent::runner::sig_hash(etx); - etx.m_sig = cbdc::threepc::agent::runner::eth_sign(m_acct0_privkey, - sighash, - etx.m_type, - m_secp_context); + auto sighash = cbdc::parsec::agent::runner::sig_hash(etx); + etx.m_sig = cbdc::parsec::agent::runner::eth_sign(m_acct0_privkey, + sighash, + etx.m_type, + m_secp_context); return etx; }; const auto etx = make_evmtx_(); const auto maybe_from - = cbdc::threepc::agent::runner::check_signature(etx, m_secp_context); + = cbdc::parsec::agent::runner::check_signature(etx, m_secp_context); ASSERT_TRUE(maybe_from.has_value()); ASSERT_EQ(maybe_from.value(), m_acct0_ethaddr); @@ -586,11 +584,11 @@ TEST_F(threepc_evm_end_to_end_test, native_transfer) { ASSERT_TRUE(txreceipt.isMember("from")); ASSERT_EQ(txreceipt["from"], - "0x" + cbdc::threepc::agent::runner::to_hex(m_acct0_ethaddr)); + "0x" + cbdc::parsec::agent::runner::to_hex(m_acct0_ethaddr)); ASSERT_TRUE(txreceipt.isMember("to")); ASSERT_EQ(txreceipt["to"], - "0x" + cbdc::threepc::agent::runner::to_hex(etx.m_to.value())); + "0x" + cbdc::parsec::agent::runner::to_hex(etx.m_to.value())); ASSERT_TRUE(txreceipt.isMember("transactionHash")); ASSERT_EQ(txreceipt["transactionHash"], txid); @@ -603,7 +601,7 @@ TEST_F(threepc_evm_end_to_end_test, native_transfer) { ASSERT_TRUE(txreceipt.isMember("transaction")); ASSERT_TRUE(txreceipt["transaction"].isMember("value")); - ASSERT_EQ(cbdc::threepc::agent::runner::uint256be_from_hex( + ASSERT_EQ(cbdc::parsec::agent::runner::uint256be_from_hex( txreceipt["transaction"]["value"].asString()), etx.m_value); @@ -612,18 +610,18 @@ TEST_F(threepc_evm_end_to_end_test, native_transfer) { m_rpc_client->get_balance(m_acct0_ethaddr, sender_balance); ASSERT_TRUE(sender_balance.has_value()); ASSERT_EQ(sender_balance.value(), - cbdc::threepc::agent::runner::operator-(m_init_acct_balance, - send_value)); + cbdc::parsec::agent::runner::operator-(m_init_acct_balance, + send_value)); std::optional receiver_balance; m_rpc_client->get_balance(etx.m_to.value(), receiver_balance); ASSERT_TRUE(receiver_balance.has_value()); ASSERT_EQ(receiver_balance.value(), - cbdc::threepc::agent::runner::operator+(m_init_acct_balance, - send_value)); + cbdc::parsec::agent::runner::operator+(m_init_acct_balance, + send_value)); } -TEST_F(threepc_evm_end_to_end_test, erc20_all) { +TEST_F(parsec_evm_end_to_end_test, erc20_all) { evmc::address contract_address; test_erc20_deploy_contract(m_acct0_ethaddr, m_acct0_privkey, @@ -643,7 +641,7 @@ TEST_F(threepc_evm_end_to_end_test, erc20_all) { contract_address, m_acct0_ethaddr, m_acct0_privkey, - cbdc::threepc::agent::runner::uint256be_from_hex("0x12").value()); + cbdc::parsec::agent::runner::uint256be_from_hex("0x12").value()); test_erc20_total_supply(contract_address, m_acct0_ethaddr, @@ -661,7 +659,7 @@ TEST_F(threepc_evm_end_to_end_test, erc20_all) { evmc::uint256be{}); const auto txfer_amount - = cbdc::threepc::agent::runner::uint256be_from_hex("0xF423F").value(); + = cbdc::parsec::agent::runner::uint256be_from_hex("0xF423F").value(); // Send ERC20 tokens from acct0 --> acct1 & confirm test_erc20_send_tokens(contract_address, @@ -674,8 +672,8 @@ TEST_F(threepc_evm_end_to_end_test, erc20_all) { contract_address, m_acct0_ethaddr, m_acct0_privkey, - cbdc::threepc::agent::runner::operator-(m_init_acct_balance, - txfer_amount)); + cbdc::parsec::agent::runner::operator-(m_init_acct_balance, + txfer_amount)); test_erc20_get_balance(contract_address, m_acct1_ethaddr, diff --git a/tests/integration/sample_erc20_contract.hpp b/tests/integration/sample_erc20_contract.hpp index d19279ab2..a8d026056 100644 --- a/tests/integration/sample_erc20_contract.hpp +++ b/tests/integration/sample_erc20_contract.hpp @@ -6,14 +6,15 @@ #ifndef OPENCBDC_TEST_INTEGRATION_SAMPLE_ERC20_CONTRACT_H_ #define OPENCBDC_TEST_INTEGRATION_SAMPLE_ERC20_CONTRACT_H_ -#include "3pc/agent/runners/evm/hash.hpp" +#include "parsec/agent/runners/evm/hash.hpp" #include "util/common/buffer.hpp" #include /** * This sample EVM contract bytecode and ABI interface have been copied from - * tools/bench/3pc/evm/contracts where the originating Solidity code looks as + * tools/bench/parsec/evm/contracts where the originating Solidity code looks +as * follows and was compiled using hardhat. pragma solidity ^0.8.0; diff --git a/tests/unit/3pc/agent/runners/lua/runner_test.cpp b/tests/unit/3pc/agent/runners/lua/runner_test.cpp deleted file mode 100644 index 4b73d97b3..000000000 --- a/tests/unit/3pc/agent/runners/lua/runner_test.cpp +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright (c) 2021 MIT Digital Currency Initiative, -// Federal Reserve Bank of Boston -// Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. - -#include "3pc/agent/runners/lua/impl.hpp" -#include "3pc/util.hpp" - -#include - -TEST(agent_runner_test, rollback_test) { - auto log = std::make_shared( - cbdc::logging::log_level::trace); - - auto cfg = cbdc::threepc::config(); - - static constexpr auto contract - = "1b4c7561540019930d0a1a0a0408087856000000000000000000000028774001808" - "1860100038d8b0000018e00010203810100c40002020f0000019300000052000000" - "0f0004018b000004928003058b000004c8000200c700010086048276048a636f726" - "f7574696e6504867969656c64048668656c6c6f0482740483686981000000808080" - "8080"; - auto func = cbdc::buffer::from_hex(contract).value(); - auto param = cbdc::buffer(); - - static constexpr auto exp_val = "hi"; - auto exp_val_buf = cbdc::buffer(); - exp_val_buf.append(exp_val, 2); - - static constexpr auto exp_key = "hello"; - auto exp_key_buf = cbdc::buffer(); - exp_key_buf.append(exp_key, 5); - - auto result_cb = - [&](cbdc::threepc::agent::runner::interface::run_return_type ret) { - ASSERT_TRUE( - std::holds_alternative< - cbdc::threepc::runtime_locking_shard::state_update_type>( - ret)); - auto& val = std::get< - cbdc::threepc::runtime_locking_shard::state_update_type>(ret); - ASSERT_EQ(val.size(), 1UL); - ASSERT_EQ(val[exp_key_buf], exp_val_buf); - }; - - auto try_lock_cb - = [&](const cbdc::threepc::broker::key_type& key, - cbdc::threepc::broker::lock_type /* locktype */, - const cbdc::threepc::broker::interface::try_lock_callback_type& - res_cb) -> bool { - EXPECT_EQ(key, exp_key_buf); - res_cb(cbdc::buffer()); - return true; - }; - - auto runner - = cbdc::threepc::agent::runner::lua_runner(log, - cfg, - std::move(func), - std::move(param), - false, - std::move(result_cb), - std::move(try_lock_cb), - nullptr, - nullptr, - 0); - ASSERT_TRUE(runner.run()); -} diff --git a/tests/unit/3pc/broker/CMakeLists.txt b/tests/unit/3pc/broker/CMakeLists.txt deleted file mode 100644 index 7b3966955..000000000 --- a/tests/unit/3pc/broker/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -target_sources(3pc_unit_tests PRIVATE impl_test.cpp) diff --git a/tests/unit/3pc/runtime_locking_shard/CMakeLists.txt b/tests/unit/3pc/runtime_locking_shard/CMakeLists.txt deleted file mode 100644 index 7b3966955..000000000 --- a/tests/unit/3pc/runtime_locking_shard/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -target_sources(3pc_unit_tests PRIVATE impl_test.cpp) diff --git a/tests/unit/CMakeLists.txt b/tests/unit/CMakeLists.txt index d2d74ab21..da38a1d86 100644 --- a/tests/unit/CMakeLists.txt +++ b/tests/unit/CMakeLists.txt @@ -29,7 +29,7 @@ add_executable(run_unit_tests archiver_test.cpp watchtower/tx_error_messages_test.cpp watchtower/watchtower_test.cpp) -add_subdirectory(3pc) +add_subdirectory(parsec) target_compile_options(run_unit_tests PRIVATE -ftest-coverage -fprofile-arcs) target_link_options(run_unit_tests PRIVATE --coverage) @@ -47,7 +47,7 @@ target_link_libraries(run_unit_tests ${GTEST_LIBRARY} watchtower coordinator locking_shard - 3pc_unit_tests + parsec_unit_tests evm_runner lua_runner directory diff --git a/tests/unit/3pc/CMakeLists.txt b/tests/unit/parsec/CMakeLists.txt similarity index 69% rename from tests/unit/3pc/CMakeLists.txt rename to tests/unit/parsec/CMakeLists.txt index ebc05087a..78e1d600b 100644 --- a/tests/unit/3pc/CMakeLists.txt +++ b/tests/unit/parsec/CMakeLists.txt @@ -1,4 +1,4 @@ -add_library(3pc_unit_tests util.cpp) +add_library(parsec_unit_tests util.cpp) add_subdirectory(runtime_locking_shard) add_subdirectory(broker) diff --git a/tests/unit/3pc/agent/CMakeLists.txt b/tests/unit/parsec/agent/CMakeLists.txt similarity index 100% rename from tests/unit/3pc/agent/CMakeLists.txt rename to tests/unit/parsec/agent/CMakeLists.txt diff --git a/tests/unit/3pc/agent/runners/CMakeLists.txt b/tests/unit/parsec/agent/runners/CMakeLists.txt similarity index 100% rename from tests/unit/3pc/agent/runners/CMakeLists.txt rename to tests/unit/parsec/agent/runners/CMakeLists.txt diff --git a/tests/unit/3pc/agent/runners/evm/CMakeLists.txt b/tests/unit/parsec/agent/runners/evm/CMakeLists.txt similarity index 100% rename from tests/unit/3pc/agent/runners/evm/CMakeLists.txt rename to tests/unit/parsec/agent/runners/evm/CMakeLists.txt diff --git a/tests/unit/3pc/agent/runners/evm/evm_test.cpp b/tests/unit/parsec/agent/runners/evm/evm_test.cpp similarity index 78% rename from tests/unit/3pc/agent/runners/evm/evm_test.cpp rename to tests/unit/parsec/agent/runners/evm/evm_test.cpp index c85d1fc81..d340bef0c 100644 --- a/tests/unit/3pc/agent/runners/evm/evm_test.cpp +++ b/tests/unit/parsec/agent/runners/evm/evm_test.cpp @@ -4,20 +4,20 @@ // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include "../../../util.hpp" -#include "3pc/agent/impl.hpp" -#include "3pc/agent/runners/evm/address.hpp" -#include "3pc/agent/runners/evm/format.hpp" -#include "3pc/agent/runners/evm/hash.hpp" -#include "3pc/agent/runners/evm/impl.hpp" -#include "3pc/agent/runners/evm/messages.hpp" -#include "3pc/agent/runners/evm/rlp.hpp" -#include "3pc/agent/runners/evm/serialization.hpp" -#include "3pc/agent/runners/evm/signature.hpp" -#include "3pc/agent/runners/evm/util.hpp" -#include "3pc/broker/impl.hpp" -#include "3pc/directory/impl.hpp" -#include "3pc/runtime_locking_shard/impl.hpp" -#include "3pc/ticket_machine/impl.hpp" +#include "parsec/agent/impl.hpp" +#include "parsec/agent/runners/evm/address.hpp" +#include "parsec/agent/runners/evm/format.hpp" +#include "parsec/agent/runners/evm/hash.hpp" +#include "parsec/agent/runners/evm/impl.hpp" +#include "parsec/agent/runners/evm/messages.hpp" +#include "parsec/agent/runners/evm/rlp.hpp" +#include "parsec/agent/runners/evm/serialization.hpp" +#include "parsec/agent/runners/evm/signature.hpp" +#include "parsec/agent/runners/evm/util.hpp" +#include "parsec/broker/impl.hpp" +#include "parsec/directory/impl.hpp" +#include "parsec/runtime_locking_shard/impl.hpp" +#include "parsec/ticket_machine/impl.hpp" #include #include @@ -37,11 +37,11 @@ class evm_test : public ::testing::Test { std::memcpy(m_priv1.data(), priv_buf.data_at(32), 32); std::memcpy(m_priv2.data(), priv_buf.data_at(64), 32); m_addr0_addr - = cbdc::threepc::agent::runner::eth_addr(m_priv0, m_secp_context); + = cbdc::parsec::agent::runner::eth_addr(m_priv0, m_secp_context); m_addr1_addr - = cbdc::threepc::agent::runner::eth_addr(m_priv1, m_secp_context); + = cbdc::parsec::agent::runner::eth_addr(m_priv1, m_secp_context); m_addr2_addr - = cbdc::threepc::agent::runner::eth_addr(m_priv2, m_secp_context); + = cbdc::parsec::agent::runner::eth_addr(m_priv2, m_secp_context); m_addr0.append(m_addr0_addr.bytes, 20); m_addr1.append(m_addr1_addr.bytes, 20); @@ -50,7 +50,7 @@ class evm_test : public ::testing::Test { auto contract = cbdc::buffer::from_hex("4360005543600052596000f3").value(); - auto acc = cbdc::threepc::agent::runner::evm_account(); + auto acc = cbdc::parsec::agent::runner::evm_account(); acc.m_balance = evmc::uint256be(1000000); auto acc_buf = cbdc::make_buffer(acc); @@ -60,18 +60,18 @@ class evm_test : public ::testing::Test { code_key.append(m_addr0.data(), m_addr0.size()); constexpr uint8_t code_byte = 0; code_key.append(&code_byte, sizeof(code_byte)); - auto code = cbdc::threepc::agent::runner::evm_account_code(); + auto code = cbdc::parsec::agent::runner::evm_account_code(); code.resize(contract.size()); std::memcpy(code.data(), contract.data(), contract.size()); auto code_buf = cbdc::make_buffer(code); cbdc::test::add_to_shard(m_broker, code_key, code_buf); - auto acc1 = cbdc::threepc::agent::runner::evm_account(); + auto acc1 = cbdc::parsec::agent::runner::evm_account(); acc1.m_balance = evmc::uint256be(1000000); auto acc1_buf = cbdc::make_buffer(acc1); cbdc::test::add_to_shard(m_broker, m_addr1, acc1_buf); - auto acc2 = cbdc::threepc::agent::runner::evm_account(); + auto acc2 = cbdc::parsec::agent::runner::evm_account(); acc2.m_balance = evmc::uint256be(1000000); auto acc2_buf = cbdc::make_buffer(acc2); cbdc::test::add_to_shard(m_broker, m_addr2, acc2_buf); @@ -79,18 +79,18 @@ class evm_test : public ::testing::Test { std::shared_ptr m_log{ std::make_shared(cbdc::logging::log_level::trace)}; - cbdc::threepc::config m_cfg{}; - std::shared_ptr m_shard0{ - std::make_shared(m_log)}; - std::shared_ptr m_ticketer{ - std::make_shared(m_log, 1)}; - std::shared_ptr m_directory{ - std::make_shared(1)}; - std::shared_ptr m_broker{ - std::make_shared( + cbdc::parsec::config m_cfg{}; + std::shared_ptr m_shard0{ + std::make_shared(m_log)}; + std::shared_ptr m_ticketer{ + std::make_shared(m_log, 1)}; + std::shared_ptr m_directory{ + std::make_shared(1)}; + std::shared_ptr m_broker{ + std::make_shared( 0, std::vector>({m_shard0}), + cbdc::parsec::runtime_locking_shard::interface>>({m_shard0}), m_ticketer, m_directory, m_log)}; @@ -112,42 +112,41 @@ class evm_test : public ::testing::Test { }; TEST_F(evm_test, initial_test) { - auto tx = cbdc::threepc::agent::runner::evm_tx(); + auto tx = cbdc::parsec::agent::runner::evm_tx(); tx.m_to = m_addr0_addr; tx.m_nonce = evmc::uint256be(1); tx.m_value = evmc::uint256be(1000); tx.m_gas_price = evmc::uint256be(1); tx.m_gas_limit = evmc::uint256be(200000); - auto sighash = cbdc::threepc::agent::runner::sig_hash(tx); - tx.m_sig = cbdc::threepc::agent::runner::eth_sign(m_priv1, - sighash, - tx.m_type, - m_secp_context); + auto sighash = cbdc::parsec::agent::runner::sig_hash(tx); + tx.m_sig = cbdc::parsec::agent::runner::eth_sign(m_priv1, + sighash, + tx.m_type, + m_secp_context); auto maybe_from - = cbdc::threepc::agent::runner::check_signature(tx, m_secp_context); + = cbdc::parsec::agent::runner::check_signature(tx, m_secp_context); ASSERT_TRUE(maybe_from.has_value()); ASSERT_EQ(maybe_from.value(), m_addr1_addr); auto params = cbdc::make_buffer(tx); auto prom = std::promise(); auto fut = prom.get_future(); - auto agent = std::make_shared( + auto agent = std::make_shared( m_log, m_cfg, - &cbdc::threepc::agent::runner::factory< - cbdc::threepc::agent::runner::evm_runner>::create, + &cbdc::parsec::agent::runner::factory< + cbdc::parsec::agent::runner::evm_runner>::create, m_broker, - cbdc::make_buffer(cbdc::threepc::agent::runner::evm_runner_function:: + cbdc::make_buffer(cbdc::parsec::agent::runner::evm_runner_function:: execute_transaction), params, - [&](const cbdc::threepc::agent::interface::exec_return_type& res) { + [&](const cbdc::parsec::agent::interface::exec_return_type& res) { ASSERT_TRUE( - std::holds_alternative( - res)); + std::holds_alternative(res)); prom.set_value(); }, - cbdc::threepc::agent::runner::evm_runner::initial_lock_type, + cbdc::parsec::agent::runner::evm_runner::initial_lock_type, false, m_secp_context, nullptr); @@ -170,11 +169,11 @@ TEST_F(evm_test, host_storage) { cbdc::buffer, cbdc::hashing::const_sip_hash>(); - auto host = cbdc::threepc::agent::runner::evm_host( + auto host = cbdc::parsec::agent::runner::evm_host( m_log, - [&](const cbdc::threepc::runtime_locking_shard::key_type& k, - cbdc::threepc::broker::lock_type /* locktype */, - const cbdc::threepc::broker::interface::try_lock_callback_type& + [&](const cbdc::parsec::runtime_locking_shard::key_type& k, + cbdc::parsec::broker::lock_type /* locktype */, + const cbdc::parsec::broker::interface::try_lock_callback_type& cb) { cb(m[k]); return true; @@ -187,11 +186,11 @@ TEST_F(evm_test, host_storage) { ASSERT_FALSE(host.should_retry()); m = host.get_state_updates(); - host = cbdc::threepc::agent::runner::evm_host( + host = cbdc::parsec::agent::runner::evm_host( m_log, - [&](const cbdc::threepc::runtime_locking_shard::key_type& k, - cbdc::threepc::broker::lock_type /* locktype */, - const cbdc::threepc::broker::interface::try_lock_callback_type& + [&](const cbdc::parsec::runtime_locking_shard::key_type& k, + cbdc::parsec::broker::lock_type /* locktype */, + const cbdc::parsec::broker::interface::try_lock_callback_type& cb) { cb(m[k]); return true; @@ -235,41 +234,40 @@ TEST_F(evm_test, host_storage) { } TEST_F(evm_test, simple_send) { - auto tx = cbdc::threepc::agent::runner::evm_tx(); + auto tx = cbdc::parsec::agent::runner::evm_tx(); tx.m_to = m_addr2_addr; tx.m_nonce = evmc::uint256be(1); tx.m_value = evmc::uint256be(1000); tx.m_gas_price = evmc::uint256be(1); tx.m_gas_limit = evmc::uint256be(21000); - auto sighash = cbdc::threepc::agent::runner::sig_hash(tx); - tx.m_sig = cbdc::threepc::agent::runner::eth_sign(m_priv1, - sighash, - tx.m_type, - m_secp_context); + auto sighash = cbdc::parsec::agent::runner::sig_hash(tx); + tx.m_sig = cbdc::parsec::agent::runner::eth_sign(m_priv1, + sighash, + tx.m_type, + m_secp_context); auto maybe_from - = cbdc::threepc::agent::runner::check_signature(tx, m_secp_context); + = cbdc::parsec::agent::runner::check_signature(tx, m_secp_context); ASSERT_TRUE(maybe_from.has_value()); ASSERT_EQ(maybe_from.value(), m_addr1_addr); auto params = cbdc::make_buffer(tx); auto prom = std::promise(); auto fut = prom.get_future(); - auto agent = std::make_shared( + auto agent = std::make_shared( m_log, m_cfg, - &cbdc::threepc::agent::runner::factory< - cbdc::threepc::agent::runner::evm_runner>::create, + &cbdc::parsec::agent::runner::factory< + cbdc::parsec::agent::runner::evm_runner>::create, m_broker, - cbdc::make_buffer(cbdc::threepc::agent::runner::evm_runner_function:: + cbdc::make_buffer(cbdc::parsec::agent::runner::evm_runner_function:: execute_transaction), params, - [&](const cbdc::threepc::agent::interface::exec_return_type& res) { + [&](const cbdc::parsec::agent::interface::exec_return_type& res) { ASSERT_TRUE( - std::holds_alternative( - res)); + std::holds_alternative(res)); prom.set_value(); }, - cbdc::threepc::agent::runner::evm_runner::initial_lock_type, + cbdc::parsec::agent::runner::evm_runner::initial_lock_type, false, m_secp_context, nullptr); @@ -280,29 +278,29 @@ TEST_F(evm_test, simple_send) { // Test send not working, not enough gas tx.m_gas_limit = evmc::uint256be(20999); tx.m_nonce = evmc::uint256be(2); - auto sighash2 = cbdc::threepc::agent::runner::sig_hash(tx); - tx.m_sig = cbdc::threepc::agent::runner::eth_sign(m_priv1, - sighash2, - tx.m_type, - m_secp_context); + auto sighash2 = cbdc::parsec::agent::runner::sig_hash(tx); + tx.m_sig = cbdc::parsec::agent::runner::eth_sign(m_priv1, + sighash2, + tx.m_type, + m_secp_context); params = cbdc::make_buffer(tx); prom = std::promise(); fut = prom.get_future(); - agent = std::make_shared( + agent = std::make_shared( m_log, m_cfg, - &cbdc::threepc::agent::runner::factory< - cbdc::threepc::agent::runner::evm_runner>::create, + &cbdc::parsec::agent::runner::factory< + cbdc::parsec::agent::runner::evm_runner>::create, m_broker, - cbdc::make_buffer(cbdc::threepc::agent::runner::evm_runner_function:: + cbdc::make_buffer(cbdc::parsec::agent::runner::evm_runner_function:: execute_transaction), params, - [&](const cbdc::threepc::agent::interface::exec_return_type& r) { + [&](const cbdc::parsec::agent::interface::exec_return_type& r) { ASSERT_TRUE(std::holds_alternative< - cbdc::threepc::agent::interface::error_code>(r)); + cbdc::parsec::agent::interface::error_code>(r)); prom.set_value(); }, - cbdc::threepc::agent::runner::evm_runner::initial_lock_type, + cbdc::parsec::agent::runner::evm_runner::initial_lock_type, false, m_secp_context, nullptr); @@ -312,8 +310,8 @@ TEST_F(evm_test, simple_send) { } TEST_F(evm_test, contract_deploy) { - // See tools/bench/3pc/evm/contracts for the source Solidity contract and - // other details on the generation of the following bytecode + // See tools/bench/parsec/evm/contracts for the source Solidity contract + // and other details on the generation of the following bytecode auto bytecode = cbdc::buffer::from_hex( "608060405234801561001057600080fd5b5061002d61002261003260201b602" @@ -381,7 +379,7 @@ TEST_F(evm_test, contract_deploy) { "33") .value(); - auto tx = std::make_shared(); + auto tx = std::make_shared(); tx->m_nonce = evmc::uint256be(1); tx->m_value = evmc::uint256be(0); tx->m_gas_price = evmc::uint256be(1); @@ -389,45 +387,44 @@ TEST_F(evm_test, contract_deploy) { tx->m_input.resize(bytecode.size()); std::memcpy(tx->m_input.data(), bytecode.data(), bytecode.size()); - auto sighash = cbdc::threepc::agent::runner::sig_hash(*tx); - tx->m_sig = cbdc::threepc::agent::runner::eth_sign(m_priv1, - sighash, - tx->m_type, - m_secp_context); + auto sighash = cbdc::parsec::agent::runner::sig_hash(*tx); + tx->m_sig = cbdc::parsec::agent::runner::eth_sign(m_priv1, + sighash, + tx->m_type, + m_secp_context); - auto contract_addr = cbdc::threepc::agent::runner::from_hex( + auto contract_addr = cbdc::parsec::agent::runner::from_hex( "8d1ec7694e13bf51041920b5cf4e1668b0e267a9"); auto params = cbdc::make_buffer(*tx); auto deploy_txid - = cbdc::make_buffer(cbdc::threepc::agent::runner::tx_id(*tx)); + = cbdc::make_buffer(cbdc::parsec::agent::runner::tx_id(*tx)); - auto prom = std::promise(); + auto prom = std::promise(); auto fut = prom.get_future(); - auto agent = std::make_shared( + auto agent = std::make_shared( m_log, m_cfg, - &cbdc::threepc::agent::runner::factory< - cbdc::threepc::agent::runner::evm_runner>::create, + &cbdc::parsec::agent::runner::factory< + cbdc::parsec::agent::runner::evm_runner>::create, m_broker, - cbdc::make_buffer(cbdc::threepc::agent::runner::evm_runner_function:: + cbdc::make_buffer(cbdc::parsec::agent::runner::evm_runner_function:: execute_transaction), params, - [&](cbdc::threepc::agent::interface::exec_return_type res) { + [&](cbdc::parsec::agent::interface::exec_return_type res) { ASSERT_TRUE( - std::holds_alternative( - res)); - auto& r = std::get(res); + std::holds_alternative(res)); + auto& r = std::get(res); auto it = r.find(deploy_txid); ASSERT_NE(it, r.end()); auto maybe_receipt = cbdc::from_buffer< - cbdc::threepc::agent::runner::evm_tx_receipt>(it->second); + cbdc::parsec::agent::runner::evm_tx_receipt>(it->second); ASSERT_TRUE(maybe_receipt.has_value()); auto& receipt = maybe_receipt.value(); prom.set_value(receipt); }, - cbdc::threepc::agent::runner::evm_runner::initial_lock_type, + cbdc::parsec::agent::runner::evm_runner::initial_lock_type, false, m_secp_context, nullptr); @@ -447,41 +444,41 @@ TEST_F(evm_test, contract_deploy) { tx->m_input.resize(store_input.size()); std::memcpy(tx->m_input.data(), store_input.data(), store_input.size()); - auto sighash2 = cbdc::threepc::agent::runner::sig_hash(*tx); - tx->m_sig = cbdc::threepc::agent::runner::eth_sign(m_priv1, - sighash2, - tx->m_type, - m_secp_context); + auto sighash2 = cbdc::parsec::agent::runner::sig_hash(*tx); + tx->m_sig = cbdc::parsec::agent::runner::eth_sign(m_priv1, + sighash2, + tx->m_type, + m_secp_context); params = cbdc::make_buffer(*tx); auto store_txid - = cbdc::make_buffer(cbdc::threepc::agent::runner::tx_id(*tx)); + = cbdc::make_buffer(cbdc::parsec::agent::runner::tx_id(*tx)); - prom = std::promise(); + prom = std::promise(); fut = prom.get_future(); - agent = std::make_shared( + agent = std::make_shared( m_log, m_cfg, - &cbdc::threepc::agent::runner::factory< - cbdc::threepc::agent::runner::evm_runner>::create, + &cbdc::parsec::agent::runner::factory< + cbdc::parsec::agent::runner::evm_runner>::create, m_broker, - cbdc::make_buffer(cbdc::threepc::agent::runner::evm_runner_function:: + cbdc::make_buffer(cbdc::parsec::agent::runner::evm_runner_function:: execute_transaction), params, - [&](cbdc::threepc::agent::interface::exec_return_type r) { + [&](cbdc::parsec::agent::interface::exec_return_type r) { ASSERT_TRUE( - std::holds_alternative(r)); - auto& ret = std::get(r); + std::holds_alternative(r)); + auto& ret = std::get(r); auto it = ret.find(store_txid); ASSERT_NE(it, ret.end()); auto maybe_receipt = cbdc::from_buffer< - cbdc::threepc::agent::runner::evm_tx_receipt>(it->second); + cbdc::parsec::agent::runner::evm_tx_receipt>(it->second); ASSERT_TRUE(maybe_receipt.has_value()); auto& rec = maybe_receipt.value(); prom.set_value(rec); }, - cbdc::threepc::agent::runner::evm_runner::initial_lock_type, + cbdc::parsec::agent::runner::evm_runner::initial_lock_type, false, m_secp_context, nullptr); @@ -519,38 +516,38 @@ TEST_F(evm_test, contract_deploy) { retrieve_input.size()); tx->m_nonce = evmc::uint256be(3); // Remove sig - we don't have to sign dry run TXs - tx->m_sig = cbdc::threepc::agent::runner::evm_sig{}; + tx->m_sig = cbdc::parsec::agent::runner::evm_sig{}; params = cbdc::make_buffer( - cbdc::threepc::agent::runner::evm_dryrun_tx{m_addr0_addr, *tx}); + cbdc::parsec::agent::runner::evm_dryrun_tx{m_addr0_addr, *tx}); auto retrieve_txid - = cbdc::make_buffer(cbdc::threepc::agent::runner::tx_id(*tx)); + = cbdc::make_buffer(cbdc::parsec::agent::runner::tx_id(*tx)); - prom = std::promise(); + prom = std::promise(); fut = prom.get_future(); - agent = std::make_shared( + agent = std::make_shared( m_log, m_cfg, - &cbdc::threepc::agent::runner::factory< - cbdc::threepc::agent::runner::evm_runner>::create, + &cbdc::parsec::agent::runner::factory< + cbdc::parsec::agent::runner::evm_runner>::create, m_broker, - cbdc::make_buffer(cbdc::threepc::agent::runner::evm_runner_function:: + cbdc::make_buffer(cbdc::parsec::agent::runner::evm_runner_function:: dryrun_transaction), params, - [&](cbdc::threepc::agent::interface::exec_return_type r) { + [&](cbdc::parsec::agent::interface::exec_return_type r) { ASSERT_TRUE( - std::holds_alternative(r)); - auto& ret = std::get(r); + std::holds_alternative(r)); + auto& ret = std::get(r); auto it = ret.find(retrieve_txid); ASSERT_NE(it, ret.end()); auto maybe_receipt = cbdc::from_buffer< - cbdc::threepc::agent::runner::evm_tx_receipt>(it->second); + cbdc::parsec::agent::runner::evm_tx_receipt>(it->second); ASSERT_TRUE(maybe_receipt.has_value()); auto& rec = maybe_receipt.value(); prom.set_value(rec); }, - cbdc::threepc::agent::runner::evm_runner::initial_lock_type, + cbdc::parsec::agent::runner::evm_runner::initial_lock_type, true, m_secp_context, nullptr); @@ -638,12 +635,12 @@ TEST_F(evm_test, rlp_serialize_array_test) { } TEST_F(evm_test, contract_address_test) { - auto expected = cbdc::threepc::agent::runner::from_hex( + auto expected = cbdc::parsec::agent::runner::from_hex( "8d1ec7694e13bf51041920b5cf4e1668b0e267a9"); ASSERT_EQ( expected, - cbdc::threepc::agent::runner::contract_address(m_addr1_addr, - evmc::uint256be(1))); + cbdc::parsec::agent::runner::contract_address(m_addr1_addr, + evmc::uint256be(1))); } /// Tests contract address for CREATE2 based on Example 5 from EIP-1014: @@ -677,18 +674,18 @@ TEST_F(evm_test, contract_address2_test) { ASSERT_EQ( expected, - cbdc::threepc::agent::runner::contract_address2(sender_addr, - salt_bytes, - contract_code_hash)); + cbdc::parsec::agent::runner::contract_address2(sender_addr, + salt_bytes, + contract_code_hash)); } TEST_F(evm_test, sighash_check) { // Values from https://ethereum.stackexchange.com/a/47984 - auto tx = std::make_shared(); + auto tx = std::make_shared(); tx->m_nonce = evmc::uint256be(0); tx->m_gas_price = evmc::uint256be(50000000000); tx->m_gas_limit = evmc::uint256be(21000); - tx->m_to = cbdc::threepc::agent::runner::from_hex( + tx->m_to = cbdc::parsec::agent::runner::from_hex( "7917bc33eea648809c285607579c9919fb864f8f"); tx->m_value = evmc::uint256be(1050000000000000); @@ -701,7 +698,7 @@ TEST_F(evm_test, sighash_check) { ASSERT_EQ( expected, - cbdc::threepc::agent::runner::sig_hash(*tx, eth_mainnet_chain_id)); + cbdc::parsec::agent::runner::sig_hash(*tx, eth_mainnet_chain_id)); } TEST_F(evm_test, address_test) { @@ -710,14 +707,14 @@ TEST_F(evm_test, address_test) { "ee983094141e530ac3684520862098") .value(); std::memcpy(priv.data(), priv_buf.data(), priv.size()); - auto expected_addr = cbdc::threepc::agent::runner::from_hex( + auto expected_addr = cbdc::parsec::agent::runner::from_hex( "92ecb2f4d3280b94b583f54af9177fd7ef9fe845"); - auto addr = cbdc::threepc::agent::runner::eth_addr(priv, m_secp_context); + auto addr = cbdc::parsec::agent::runner::eth_addr(priv, m_secp_context); ASSERT_EQ(addr, expected_addr); } TEST_F(evm_test, signature_check) { - auto tx = cbdc::threepc::agent::runner::evm_tx(); + auto tx = cbdc::parsec::agent::runner::evm_tx(); tx.m_nonce = evmc::uint256be(0); tx.m_gas_price = evmc::uint256be(50000000000); tx.m_gas_limit = evmc::uint256be(21000); @@ -725,19 +722,19 @@ TEST_F(evm_test, signature_check) { tx.m_value = evmc::uint256be(1050000000000000); - auto sighash = cbdc::threepc::agent::runner::sig_hash(tx); - tx.m_sig = cbdc::threepc::agent::runner::eth_sign(m_priv0, - sighash, - tx.m_type, - m_secp_context); + auto sighash = cbdc::parsec::agent::runner::sig_hash(tx); + tx.m_sig = cbdc::parsec::agent::runner::eth_sign(m_priv0, + sighash, + tx.m_type, + m_secp_context); auto maybe_from - = cbdc::threepc::agent::runner::check_signature(tx, m_secp_context); + = cbdc::parsec::agent::runner::check_signature(tx, m_secp_context); ASSERT_TRUE(maybe_from.has_value()); ASSERT_EQ(maybe_from.value(), m_addr0_addr); tx.m_sig.m_r = evmc::uint256be(0); maybe_from - = cbdc::threepc::agent::runner::check_signature(tx, m_secp_context); + = cbdc::parsec::agent::runner::check_signature(tx, m_secp_context); ASSERT_FALSE(maybe_from.has_value()); } @@ -750,8 +747,8 @@ TEST_F(evm_test, signature_check_2) { .value(); std::memcpy(priv.data(), priv_bytes.data(), priv_bytes.size()); - auto tx = cbdc::threepc::agent::runner::evm_tx(); - tx.m_to = cbdc::threepc::agent::runner::from_hex( + auto tx = cbdc::parsec::agent::runner::evm_tx(); + tx.m_to = cbdc::parsec::agent::runner::from_hex( "3535353535353535353535353535353535353535"); tx.m_nonce = evmc::uint256be(9); tx.m_gas_price = evmc::uint256be(20000000000); @@ -775,24 +772,24 @@ TEST_F(evm_test, signature_check_2) { std::memcpy(tx.m_sig.m_s.bytes, s_bytes.data(), s_bytes.size()); auto sighash - = cbdc::threepc::agent::runner::sig_hash(tx, eth_mainnet_chain_id); - auto sig = cbdc::threepc::agent::runner::eth_sign(priv, - sighash, - tx.m_type, - m_secp_context, - eth_mainnet_chain_id); + = cbdc::parsec::agent::runner::sig_hash(tx, eth_mainnet_chain_id); + auto sig = cbdc::parsec::agent::runner::eth_sign(priv, + sighash, + tx.m_type, + m_secp_context, + eth_mainnet_chain_id); ASSERT_EQ(tx.m_sig.m_r, sig.m_r); ASSERT_EQ(tx.m_sig.m_s, sig.m_s); ASSERT_EQ(tx.m_sig.m_v, sig.m_v); auto maybe_from - = cbdc::threepc::agent::runner::check_signature(tx, - m_secp_context, - eth_mainnet_chain_id); + = cbdc::parsec::agent::runner::check_signature(tx, + m_secp_context, + eth_mainnet_chain_id); ASSERT_TRUE(maybe_from.has_value()); auto expected_from - = cbdc::threepc::agent::runner::eth_addr(priv, m_secp_context); + = cbdc::parsec::agent::runner::eth_addr(priv, m_secp_context); ASSERT_EQ(maybe_from.value(), expected_from); } @@ -807,16 +804,16 @@ TEST_F(evm_test, signature_check_3) { .value(); std::memcpy(priv.data(), priv_bytes.data(), priv_bytes.size()); - auto tx = cbdc::threepc::agent::runner::evm_tx(); + auto tx = cbdc::parsec::agent::runner::evm_tx(); - tx.m_to = cbdc::threepc::agent::runner::from_hex( + tx.m_to = cbdc::parsec::agent::runner::from_hex( "5FbDB2315678afecb367f032d93F642f64180aa3"); tx.m_nonce = evmc::uint256be(1); tx.m_gas_price = evmc::uint256be(766614414); tx.m_gas_tip_cap = evmc::uint256be(0); tx.m_gas_fee_cap = evmc::uint256be(970246367); tx.m_gas_limit = evmc::uint256be(44915); - tx.m_type = cbdc::threepc::agent::runner::evm_tx_type::dynamic_fee; + tx.m_type = cbdc::parsec::agent::runner::evm_tx_type::dynamic_fee; auto input_bytes = cbdc::buffer::from_hex("6057361d000000000000000000000000000000000000" @@ -840,32 +837,31 @@ TEST_F(evm_test, signature_check_3) { std::memcpy(tx.m_sig.m_r.bytes, r_bytes.data(), r_bytes.size()); std::memcpy(tx.m_sig.m_s.bytes, s_bytes.data(), s_bytes.size()); - auto sighash - = cbdc::threepc::agent::runner::sig_hash(tx, hardhat_chain_id); - auto sig = cbdc::threepc::agent::runner::eth_sign(priv, - sighash, - tx.m_type, - m_secp_context, - hardhat_chain_id); + auto sighash = cbdc::parsec::agent::runner::sig_hash(tx, hardhat_chain_id); + auto sig = cbdc::parsec::agent::runner::eth_sign(priv, + sighash, + tx.m_type, + m_secp_context, + hardhat_chain_id); ASSERT_EQ(tx.m_sig.m_r, sig.m_r); ASSERT_EQ(tx.m_sig.m_s, sig.m_s); ASSERT_EQ(tx.m_sig.m_v, sig.m_v); auto maybe_from - = cbdc::threepc::agent::runner::check_signature(tx, - m_secp_context, - hardhat_chain_id); + = cbdc::parsec::agent::runner::check_signature(tx, + m_secp_context, + hardhat_chain_id); ASSERT_TRUE(maybe_from.has_value()); auto expected_from - = cbdc::threepc::agent::runner::eth_addr(priv, m_secp_context); + = cbdc::parsec::agent::runner::eth_addr(priv, m_secp_context); ASSERT_EQ(maybe_from.value(), expected_from); } // Using TX 0xb4b7a6679ab790549dc3324a7239a6bf7a87ffd4c4c092df523a5b0697763db7 TEST_F(evm_test, test_encode_tx_legacy) { - auto tx = cbdc::threepc::agent::runner::evm_tx(); - tx.m_to = cbdc::threepc::agent::runner::from_hex( + auto tx = cbdc::parsec::agent::runner::evm_tx(); + tx.m_to = cbdc::parsec::agent::runner::from_hex( "0xf8d3d485f86228a653d58903a2bf956fab7cd9d3"); tx.m_value = evmc::uint256be(72967931316403995); tx.m_nonce = evmc::uint256be(6); @@ -886,18 +882,18 @@ TEST_F(evm_test, test_encode_tx_legacy) { std::memcpy(tx.m_sig.m_r.bytes, r_bytes.data(), r_bytes.size()); std::memcpy(tx.m_sig.m_s.bytes, s_bytes.data(), s_bytes.size()); - auto expected_from = cbdc::threepc::agent::runner::from_hex( + auto expected_from = cbdc::parsec::agent::runner::from_hex( "0x5699bb600962bc92cb874b2d5c73bb5d502a42ce") .value(); auto recovered_from - = cbdc::threepc::agent::runner::check_signature(tx, - m_secp_context, - eth_mainnet_chain_id); + = cbdc::parsec::agent::runner::check_signature(tx, + m_secp_context, + eth_mainnet_chain_id); ASSERT_TRUE(recovered_from.has_value()); ASSERT_EQ(recovered_from.value(), expected_from); auto buf - = cbdc::threepc::agent::runner::tx_encode(tx, eth_mainnet_chain_id); + = cbdc::parsec::agent::runner::tx_encode(tx, eth_mainnet_chain_id); // https://etherscan.io/getRawTx?tx= // 0xb4b7a6679ab790549dc3324a7239a6bf7a87ffd4c4c092df523a5b0697763db7 @@ -909,7 +905,7 @@ TEST_F(evm_test, test_encode_tx_legacy) { ASSERT_EQ(buf, expected); - auto tx_id = cbdc::threepc::agent::runner::tx_id(tx, eth_mainnet_chain_id); + auto tx_id = cbdc::parsec::agent::runner::tx_id(tx, eth_mainnet_chain_id); auto expected_id_buf = cbdc::buffer::from_hex("b4b7a6679ab790549dc3324a7239a6bf7a87ffd4c4c0" "92df523a5b0697763db7") @@ -925,9 +921,9 @@ TEST_F(evm_test, test_encode_tx_legacy) { // Using TX 0x7169cc1d3b1bd3b8379d69b2f0490330cfcb98b019a9c607b48d99b9d44dedde TEST_F(evm_test, test_encode_tx_dynamic_fee) { - auto tx = cbdc::threepc::agent::runner::evm_tx(); - tx.m_type = cbdc::threepc::agent::runner::evm_tx_type::dynamic_fee; - tx.m_to = cbdc::threepc::agent::runner::from_hex( + auto tx = cbdc::parsec::agent::runner::evm_tx(); + tx.m_type = cbdc::parsec::agent::runner::evm_tx_type::dynamic_fee; + tx.m_to = cbdc::parsec::agent::runner::from_hex( "0xcfef8857e9c80e3440a823971420f7fa5f62f020"); tx.m_value = evmc::uint256be(0); tx.m_nonce = evmc::uint256be(1051); @@ -959,18 +955,18 @@ TEST_F(evm_test, test_encode_tx_dynamic_fee) { std::memcpy(tx.m_sig.m_r.bytes, r_bytes.data(), r_bytes.size()); std::memcpy(tx.m_sig.m_s.bytes, s_bytes.data(), s_bytes.size()); - auto expected_from = cbdc::threepc::agent::runner::from_hex( + auto expected_from = cbdc::parsec::agent::runner::from_hex( "0x236139118b84bd2594051b0b2424f7ebca27a282") .value(); auto recovered_from - = cbdc::threepc::agent::runner::check_signature(tx, - m_secp_context, - eth_mainnet_chain_id); + = cbdc::parsec::agent::runner::check_signature(tx, + m_secp_context, + eth_mainnet_chain_id); ASSERT_TRUE(recovered_from.has_value()); ASSERT_EQ(recovered_from.value(), expected_from); auto buf - = cbdc::threepc::agent::runner::tx_encode(tx, eth_mainnet_chain_id); + = cbdc::parsec::agent::runner::tx_encode(tx, eth_mainnet_chain_id); // https://etherscan.io/getRawTx?tx= // 0x7169cc1d3b1bd3b8379d69b2f0490330cfcb98b019a9c607b48d99b9d44dedde @@ -984,7 +980,7 @@ TEST_F(evm_test, test_encode_tx_dynamic_fee) { ASSERT_EQ(buf, expected); - auto tx_id = cbdc::threepc::agent::runner::tx_id(tx, eth_mainnet_chain_id); + auto tx_id = cbdc::parsec::agent::runner::tx_id(tx, eth_mainnet_chain_id); auto expected_id_buf = cbdc::buffer::from_hex("7169cc1d3b1bd3b8379d69b2f0490330cfcb98b019a9" "c607b48d99b9d44dedde") @@ -1000,107 +996,107 @@ TEST_F(evm_test, test_encode_tx_dynamic_fee) { // Using TX 0x2695ed62cf8cb7759d651c43dc28ffc1dd6a26103841c223721b081b55f4d0b5 TEST_F(evm_test, test_encode_tx_access_list) { - auto tx = cbdc::threepc::agent::runner::evm_tx(); - tx.m_type = cbdc::threepc::agent::runner::evm_tx_type::access_list; - tx.m_to = cbdc::threepc::agent::runner::from_hex( + auto tx = cbdc::parsec::agent::runner::evm_tx(); + tx.m_type = cbdc::parsec::agent::runner::evm_tx_type::access_list; + tx.m_to = cbdc::parsec::agent::runner::from_hex( "0x11b1f53204d03e5529f09eb3091939e4fd8c9cf3"); tx.m_value = evmc::uint256be(0); tx.m_nonce = evmc::uint256be(24084); tx.m_gas_price = evmc::uint256be(911752427978); // 911.752427978 GWei tx.m_gas_limit = evmc::uint256be(565146); - tx.m_access_list.push_back(cbdc::threepc::agent::runner::evm_access_tuple{ - cbdc::threepc::agent::runner::from_hex( + tx.m_access_list.push_back(cbdc::parsec::agent::runner::evm_access_tuple{ + cbdc::parsec::agent::runner::from_hex( "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2") .value(), std::vector{ - cbdc::threepc::agent::runner::from_hex( + cbdc::parsec::agent::runner::from_hex( "2ee79dc23d6c13edb1608e2e16eee0e5fe994c46c052a" "900ce432a6a733faa88") .value(), - cbdc::threepc::agent::runner::from_hex( + cbdc::parsec::agent::runner::from_hex( "6eeabe5c63f3d0417dd0e83521a7158c1403fd1857156" "a1663d93ddd5ce324ad") .value(), - cbdc::threepc::agent::runner::from_hex( + cbdc::parsec::agent::runner::from_hex( "32f00a85f22bf566874963d108eef7a5849bdc0aff29f" "d9e4fba7a4ca9b25972") .value(), - cbdc::threepc::agent::runner::from_hex( + cbdc::parsec::agent::runner::from_hex( "4bea0bbbfe1207d935c3c22ccdd4c0e9d76cba8d9249a" "d821f2d207045b3cba6") .value()}}); - tx.m_access_list.push_back(cbdc::threepc::agent::runner::evm_access_tuple{ - cbdc::threepc::agent::runner::from_hex( + tx.m_access_list.push_back(cbdc::parsec::agent::runner::evm_access_tuple{ + cbdc::parsec::agent::runner::from_hex( "0x0f5d2fb29fb7d3cfee444a200298f468908cc942") .value(), std::vector{ - cbdc::threepc::agent::runner::from_hex( + cbdc::parsec::agent::runner::from_hex( "149301982a2541c22d14e4a7edde07d33766add09e919" "225c441856470a1f9b7") .value(), - cbdc::threepc::agent::runner::from_hex( + cbdc::parsec::agent::runner::from_hex( "0958fe90732c073894bbab469409b16bbadc3b80f6d04" "a5d3b19436654d47636") .value(), - cbdc::threepc::agent::runner::from_hex( + cbdc::parsec::agent::runner::from_hex( "000000000000000000000000000000000000000000000" "0000000000000000003") .value(), - cbdc::threepc::agent::runner::from_hex( + cbdc::parsec::agent::runner::from_hex( "74cece5c9a88511447f6977a207255d8267a1b70f8ea4" "62864df11f2e32d3f3f") .value()}}); - tx.m_access_list.push_back(cbdc::threepc::agent::runner::evm_access_tuple{ - cbdc::threepc::agent::runner::from_hex( + tx.m_access_list.push_back(cbdc::parsec::agent::runner::evm_access_tuple{ + cbdc::parsec::agent::runner::from_hex( "0x8661ae7918c0115af9e3691662f605e9c550ddc9") .value(), std::vector{ - cbdc::threepc::agent::runner::from_hex( + cbdc::parsec::agent::runner::from_hex( "c626a27156226a4e7a2efc9720ec5bfb2e17309513243" "2577475fab25f4ee221") .value(), - cbdc::threepc::agent::runner::from_hex( + cbdc::parsec::agent::runner::from_hex( "000000000000000000000000000000000000000000000" "0000000000000000000") .value(), - cbdc::threepc::agent::runner::from_hex( + cbdc::parsec::agent::runner::from_hex( "c626a27156226a4e7a2efc9720ec5bfb2e17309513243" "2577475fab25f4ee223") .value(), - cbdc::threepc::agent::runner::from_hex( + cbdc::parsec::agent::runner::from_hex( "c626a27156226a4e7a2efc9720ec5bfb2e17309513243" "2577475fab25f4ee224") .value(), - cbdc::threepc::agent::runner::from_hex( + cbdc::parsec::agent::runner::from_hex( "9b637a02e6f8cc8aa1e3935c0b27bde663b11428c7707" "039634076a3fb8a0c48") .value(), - cbdc::threepc::agent::runner::from_hex( + cbdc::parsec::agent::runner::from_hex( "000000000000000000000000000000000000000000000" "0000000000000000001") .value(), - cbdc::threepc::agent::runner::from_hex( + cbdc::parsec::agent::runner::from_hex( "000000000000000000000000000000000000000000000" "0000000000000000002") .value(), - cbdc::threepc::agent::runner::from_hex( + cbdc::parsec::agent::runner::from_hex( "c626a27156226a4e7a2efc9720ec5bfb2e17309513243" "2577475fab25f4ee222") .value(), - cbdc::threepc::agent::runner::from_hex( + cbdc::parsec::agent::runner::from_hex( "000000000000000000000000000000000000000000000" "0000000000000000004") .value(), - cbdc::threepc::agent::runner::from_hex( + cbdc::parsec::agent::runner::from_hex( "000000000000000000000000000000000000000000000" "0000000000000000008") .value()}}); - tx.m_access_list.push_back(cbdc::threepc::agent::runner::evm_access_tuple{ - cbdc::threepc::agent::runner::from_hex( + tx.m_access_list.push_back(cbdc::parsec::agent::runner::evm_access_tuple{ + cbdc::parsec::agent::runner::from_hex( "0x230000377650db9ca400d3fdff49000076852100") .value(), std::vector{}}); @@ -1136,18 +1132,18 @@ TEST_F(evm_test, test_encode_tx_access_list) { std::memcpy(tx.m_sig.m_r.bytes, r_bytes.data(), r_bytes.size()); std::memcpy(tx.m_sig.m_s.bytes, s_bytes.data(), s_bytes.size()); - auto expected_from = cbdc::threepc::agent::runner::from_hex( + auto expected_from = cbdc::parsec::agent::runner::from_hex( "0x000000007cb2bd00ae5eb839930bb7847ae5b039") .value(); auto recovered_from - = cbdc::threepc::agent::runner::check_signature(tx, - m_secp_context, - eth_mainnet_chain_id); + = cbdc::parsec::agent::runner::check_signature(tx, + m_secp_context, + eth_mainnet_chain_id); ASSERT_TRUE(recovered_from.has_value()); ASSERT_EQ(recovered_from.value(), expected_from); auto buf - = cbdc::threepc::agent::runner::tx_encode(tx, eth_mainnet_chain_id); + = cbdc::parsec::agent::runner::tx_encode(tx, eth_mainnet_chain_id); // https://etherscan.io/getRawTx?tx= // 0x2695ed62cf8cb7759d651c43dc28ffc1dd6a26103841c223721b081b55f4d0b5 @@ -1187,7 +1183,7 @@ TEST_F(evm_test, test_encode_tx_access_list) { ASSERT_EQ(buf, expected); - auto tx_id = cbdc::threepc::agent::runner::tx_id(tx, eth_mainnet_chain_id); + auto tx_id = cbdc::parsec::agent::runner::tx_id(tx, eth_mainnet_chain_id); auto expected_id_buf = cbdc::buffer::from_hex("2695ed62cf8cb7759d651c43dc28ffc1dd6a26103841" "c223721b081b55f4d0b5") @@ -1292,14 +1288,14 @@ TEST_F(evm_test, test_decode_tx_legacy) { .value(); auto maybe_tx - = cbdc::threepc::agent::runner::tx_decode(input, - m_log, - eth_mainnet_chain_id); + = cbdc::parsec::agent::runner::tx_decode(input, + m_log, + eth_mainnet_chain_id); ASSERT_TRUE(maybe_tx.has_value()); auto tx = maybe_tx.value(); ASSERT_TRUE(tx->m_to.has_value()); ASSERT_EQ(tx->m_to.value(), - cbdc::threepc::agent::runner::from_hex( + cbdc::parsec::agent::runner::from_hex( "0xf8d3d485f86228a653d58903a2bf956fab7cd9d3")); ASSERT_EQ(tx->m_value, evmc::uint256be(72967931316403995)); ASSERT_EQ(tx->m_nonce, evmc::uint256be(6)); @@ -1328,12 +1324,12 @@ TEST_F(evm_test, test_decode_tx_legacy) { // ASSERT_EQ(tx->m_sig.m_s, expected_m_s); auto maybe_from - = cbdc::threepc::agent::runner::check_signature(*tx, - m_secp_context, - eth_mainnet_chain_id); + = cbdc::parsec::agent::runner::check_signature(*tx, + m_secp_context, + eth_mainnet_chain_id); ASSERT_TRUE(maybe_from.has_value()); ASSERT_EQ(maybe_from.value(), - cbdc::threepc::agent::runner::from_hex( + cbdc::parsec::agent::runner::from_hex( "0x5699bb600962bc92cb874b2d5c73bb5d502a42ce") .value()); } @@ -1356,17 +1352,17 @@ TEST_F(evm_test, test_decode_tx_dynamic_fee) { .value(); auto maybe_tx - = cbdc::threepc::agent::runner::tx_decode(input, - m_log, - eth_mainnet_chain_id); + = cbdc::parsec::agent::runner::tx_decode(input, + m_log, + eth_mainnet_chain_id); ASSERT_TRUE(maybe_tx.has_value()); auto tx = maybe_tx.value(); ASSERT_EQ(tx->m_type, - cbdc::threepc::agent::runner::evm_tx_type::dynamic_fee); + cbdc::parsec::agent::runner::evm_tx_type::dynamic_fee); ASSERT_TRUE(tx->m_to.has_value()); ASSERT_EQ(tx->m_to.value(), - cbdc::threepc::agent::runner::from_hex( + cbdc::parsec::agent::runner::from_hex( "0xcfef8857e9c80e3440a823971420f7fa5f62f020")); ASSERT_EQ(tx->m_value, evmc::uint256be(0)); ASSERT_EQ(tx->m_nonce, evmc::uint256be(1051)); @@ -1405,12 +1401,12 @@ TEST_F(evm_test, test_decode_tx_dynamic_fee) { ASSERT_EQ(expected_m_s, tx->m_sig.m_s); auto maybe_from - = cbdc::threepc::agent::runner::check_signature(*tx, - m_secp_context, - eth_mainnet_chain_id); + = cbdc::parsec::agent::runner::check_signature(*tx, + m_secp_context, + eth_mainnet_chain_id); ASSERT_TRUE(maybe_from.has_value()); ASSERT_EQ(maybe_from.value(), - cbdc::threepc::agent::runner::from_hex( + cbdc::parsec::agent::runner::from_hex( "0x236139118b84bd2594051b0b2424f7ebca27a282") .value()); } @@ -1487,16 +1483,16 @@ TEST_F(evm_test, test_decode_tx_access_list) { .value(); auto maybe_tx - = cbdc::threepc::agent::runner::tx_decode(input, - m_log, - eth_mainnet_chain_id); + = cbdc::parsec::agent::runner::tx_decode(input, + m_log, + eth_mainnet_chain_id); ASSERT_TRUE(maybe_tx.has_value()); auto tx = maybe_tx.value(); ASSERT_EQ(tx->m_type, - cbdc::threepc::agent::runner::evm_tx_type::access_list); + cbdc::parsec::agent::runner::evm_tx_type::access_list); ASSERT_EQ(tx->m_to, - cbdc::threepc::agent::runner::from_hex( + cbdc::parsec::agent::runner::from_hex( "0x11b1f53204d03e5529f09eb3091939e4fd8c9cf3")); ASSERT_EQ(tx->m_value, evmc::uint256be(0)); ASSERT_EQ(tx->m_nonce, evmc::uint256be(24084)); @@ -1504,104 +1500,103 @@ TEST_F(evm_test, test_decode_tx_access_list) { evmc::uint256be(911752427978)); // 911.752427978 GWei ASSERT_EQ(tx->m_gas_limit, evmc::uint256be(565146)); - auto expected_access_list - = cbdc::threepc::agent::runner::evm_access_list(); + auto expected_access_list = cbdc::parsec::agent::runner::evm_access_list(); expected_access_list.push_back( - cbdc::threepc::agent::runner::evm_access_tuple{ - cbdc::threepc::agent::runner::from_hex( + cbdc::parsec::agent::runner::evm_access_tuple{ + cbdc::parsec::agent::runner::from_hex( "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2") .value(), std::vector{ - cbdc::threepc::agent::runner::from_hex( + cbdc::parsec::agent::runner::from_hex( "2ee79dc23d6c13edb1608e2e16eee0e5fe994c46c052a" "900ce432a6a733faa88") .value(), - cbdc::threepc::agent::runner::from_hex( + cbdc::parsec::agent::runner::from_hex( "6eeabe5c63f3d0417dd0e83521a7158c1403fd1857156" "a1663d93ddd5ce324ad") .value(), - cbdc::threepc::agent::runner::from_hex( + cbdc::parsec::agent::runner::from_hex( "32f00a85f22bf566874963d108eef7a5849bdc0aff29f" "d9e4fba7a4ca9b25972") .value(), - cbdc::threepc::agent::runner::from_hex( + cbdc::parsec::agent::runner::from_hex( "4bea0bbbfe1207d935c3c22ccdd4c0e9d76cba8d9249a" "d821f2d207045b3cba6") .value()}}); expected_access_list.push_back( - cbdc::threepc::agent::runner::evm_access_tuple{ - cbdc::threepc::agent::runner::from_hex( + cbdc::parsec::agent::runner::evm_access_tuple{ + cbdc::parsec::agent::runner::from_hex( "0x0f5d2fb29fb7d3cfee444a200298f468908cc942") .value(), std::vector{ - cbdc::threepc::agent::runner::from_hex( + cbdc::parsec::agent::runner::from_hex( "149301982a2541c22d14e4a7edde07d33766add09e919" "225c441856470a1f9b7") .value(), - cbdc::threepc::agent::runner::from_hex( + cbdc::parsec::agent::runner::from_hex( "0958fe90732c073894bbab469409b16bbadc3b80f6d04" "a5d3b19436654d47636") .value(), - cbdc::threepc::agent::runner::from_hex( + cbdc::parsec::agent::runner::from_hex( "000000000000000000000000000000000000000000000" "0000000000000000003") .value(), - cbdc::threepc::agent::runner::from_hex( + cbdc::parsec::agent::runner::from_hex( "74cece5c9a88511447f6977a207255d8267a1b70f8ea4" "62864df11f2e32d3f3f") .value()}}); expected_access_list.push_back( - cbdc::threepc::agent::runner::evm_access_tuple{ - cbdc::threepc::agent::runner::from_hex( + cbdc::parsec::agent::runner::evm_access_tuple{ + cbdc::parsec::agent::runner::from_hex( "0x8661ae7918c0115af9e3691662f605e9c550ddc9") .value(), std::vector{ - cbdc::threepc::agent::runner::from_hex( + cbdc::parsec::agent::runner::from_hex( "c626a27156226a4e7a2efc9720ec5bfb2e17309513243" "2577475fab25f4ee221") .value(), - cbdc::threepc::agent::runner::from_hex( + cbdc::parsec::agent::runner::from_hex( "000000000000000000000000000000000000000000000" "0000000000000000000") .value(), - cbdc::threepc::agent::runner::from_hex( + cbdc::parsec::agent::runner::from_hex( "c626a27156226a4e7a2efc9720ec5bfb2e17309513243" "2577475fab25f4ee223") .value(), - cbdc::threepc::agent::runner::from_hex( + cbdc::parsec::agent::runner::from_hex( "c626a27156226a4e7a2efc9720ec5bfb2e17309513243" "2577475fab25f4ee224") .value(), - cbdc::threepc::agent::runner::from_hex( + cbdc::parsec::agent::runner::from_hex( "9b637a02e6f8cc8aa1e3935c0b27bde663b11428c7707" "039634076a3fb8a0c48") .value(), - cbdc::threepc::agent::runner::from_hex( + cbdc::parsec::agent::runner::from_hex( "000000000000000000000000000000000000000000000" "0000000000000000001") .value(), - cbdc::threepc::agent::runner::from_hex( + cbdc::parsec::agent::runner::from_hex( "000000000000000000000000000000000000000000000" "0000000000000000002") .value(), - cbdc::threepc::agent::runner::from_hex( + cbdc::parsec::agent::runner::from_hex( "c626a27156226a4e7a2efc9720ec5bfb2e17309513243" "2577475fab25f4ee222") .value(), - cbdc::threepc::agent::runner::from_hex( + cbdc::parsec::agent::runner::from_hex( "000000000000000000000000000000000000000000000" "0000000000000000004") .value(), - cbdc::threepc::agent::runner::from_hex( + cbdc::parsec::agent::runner::from_hex( "000000000000000000000000000000000000000000000" "0000000000000000008") .value()}}); expected_access_list.push_back( - cbdc::threepc::agent::runner::evm_access_tuple{ - cbdc::threepc::agent::runner::from_hex( + cbdc::parsec::agent::runner::evm_access_tuple{ + cbdc::parsec::agent::runner::from_hex( "0x230000377650db9ca400d3fdff49000076852100") .value(), std::vector{}}); @@ -1645,7 +1640,7 @@ TEST_F(evm_test, test_decode_tx_access_list) { ASSERT_EQ(tx->m_sig.m_s, expected_m_s); auto buf - = cbdc::threepc::agent::runner::tx_encode(*tx, eth_mainnet_chain_id); + = cbdc::parsec::agent::runner::tx_encode(*tx, eth_mainnet_chain_id); // https://etherscan.io/getRawTx?tx= // 0x2695ed62cf8cb7759d651c43dc28ffc1dd6a26103841c223721b081b55f4d0b5 @@ -1685,8 +1680,7 @@ TEST_F(evm_test, test_decode_tx_access_list) { ASSERT_EQ(buf, expected); - auto tx_id - = cbdc::threepc::agent::runner::tx_id(*tx, eth_mainnet_chain_id); + auto tx_id = cbdc::parsec::agent::runner::tx_id(*tx, eth_mainnet_chain_id); auto expected_id_buf = cbdc::buffer::from_hex("2695ed62cf8cb7759d651c43dc28ffc1dd6a26103841" "c223721b081b55f4d0b5") @@ -1700,12 +1694,12 @@ TEST_F(evm_test, test_decode_tx_access_list) { ASSERT_EQ(tx_id, expected_id); auto maybe_from - = cbdc::threepc::agent::runner::check_signature(*tx, - m_secp_context, - eth_mainnet_chain_id); + = cbdc::parsec::agent::runner::check_signature(*tx, + m_secp_context, + eth_mainnet_chain_id); ASSERT_TRUE(maybe_from.has_value()); ASSERT_EQ(maybe_from.value(), - cbdc::threepc::agent::runner::from_hex( + cbdc::parsec::agent::runner::from_hex( "0x000000007cb2bd00ae5eb839930bb7847ae5b039") .value()); } @@ -1795,7 +1789,7 @@ TEST_F(evm_test, test_failing_tx) { "88a3865a"); assert(maybe_input.has_value()); auto input = maybe_input.value(); - auto maybe_tx = cbdc::threepc::agent::runner::tx_decode(input, m_log); + auto maybe_tx = cbdc::parsec::agent::runner::tx_decode(input, m_log); ASSERT_TRUE(maybe_tx.has_value()); auto tx = maybe_tx.value(); @@ -1806,38 +1800,38 @@ TEST_F(evm_test, test_failing_tx) { "m_type:", static_cast(tx->m_type), "m_nonce:", - cbdc::threepc::agent::runner::to_uint64(tx->m_nonce), + cbdc::parsec::agent::runner::to_uint64(tx->m_nonce), "m_value:", - cbdc::threepc::agent::runner::to_uint64(tx->m_value), + cbdc::parsec::agent::runner::to_uint64(tx->m_value), "m_gas_price:", - cbdc::threepc::agent::runner::to_uint64(tx->m_gas_price), + cbdc::parsec::agent::runner::to_uint64(tx->m_gas_price), "m_gas_limit:", - cbdc::threepc::agent::runner::to_uint64(tx->m_gas_limit), + cbdc::parsec::agent::runner::to_uint64(tx->m_gas_limit), "m_gas_tip_cap:", - cbdc::threepc::agent::runner::to_uint64(tx->m_gas_tip_cap), + cbdc::parsec::agent::runner::to_uint64(tx->m_gas_tip_cap), "m_gas_fee_cap:", - cbdc::threepc::agent::runner::to_uint64(tx->m_gas_fee_cap), + cbdc::parsec::agent::runner::to_uint64(tx->m_gas_fee_cap), "m_input:", input_buf.to_hex(), "len(m_access_list):", tx->m_access_list.size(), "m_sig.m_r:", - cbdc::threepc::agent::runner::to_hex(tx->m_sig.m_r), + cbdc::parsec::agent::runner::to_hex(tx->m_sig.m_r), "m_sig.m_s:", - cbdc::threepc::agent::runner::to_hex(tx->m_sig.m_s), + cbdc::parsec::agent::runner::to_hex(tx->m_sig.m_s), "m_sig.m_v:", - cbdc::threepc::agent::runner::to_hex(tx->m_sig.m_v)); + cbdc::parsec::agent::runner::to_hex(tx->m_sig.m_v)); if(tx->m_to.has_value()) { m_log->info("m_to:", - cbdc::threepc::agent::runner::to_hex(tx->m_to.value())); + cbdc::parsec::agent::runner::to_hex(tx->m_to.value())); } auto maybe_from - = cbdc::threepc::agent::runner::check_signature(*tx, m_secp_context); + = cbdc::parsec::agent::runner::check_signature(*tx, m_secp_context); ASSERT_TRUE(maybe_from.has_value()); ASSERT_EQ(maybe_from.value(), - cbdc::threepc::agent::runner::from_hex( + cbdc::parsec::agent::runner::from_hex( "0xb695A631806BCcA49e9106Cb6Dcc2E7Fd544A592") .value()); } diff --git a/tests/unit/3pc/agent/runners/evm/math_test.cpp b/tests/unit/parsec/agent/runners/evm/math_test.cpp similarity index 92% rename from tests/unit/3pc/agent/runners/evm/math_test.cpp rename to tests/unit/parsec/agent/runners/evm/math_test.cpp index a59dafad8..8db694ca7 100644 --- a/tests/unit/3pc/agent/runners/evm/math_test.cpp +++ b/tests/unit/parsec/agent/runners/evm/math_test.cpp @@ -3,14 +3,14 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#include "3pc/agent/runners/evm/math.hpp" +#include "parsec/agent/runners/evm/math.hpp" #include #include class math_test : public ::testing::Test {}; -using namespace cbdc::threepc::agent::runner; +using namespace cbdc::parsec::agent::runner; TEST_F(math_test, addition) { auto val1 = evmc::uint256be(1000); diff --git a/tests/unit/3pc/agent/runners/lua/CMakeLists.txt b/tests/unit/parsec/agent/runners/lua/CMakeLists.txt similarity index 100% rename from tests/unit/3pc/agent/runners/lua/CMakeLists.txt rename to tests/unit/parsec/agent/runners/lua/CMakeLists.txt diff --git a/tests/unit/3pc/agent/runners/lua/account_test.cpp b/tests/unit/parsec/agent/runners/lua/account_test.cpp similarity index 71% rename from tests/unit/3pc/agent/runners/lua/account_test.cpp rename to tests/unit/parsec/agent/runners/lua/account_test.cpp index ff5acb781..13a151ead 100644 --- a/tests/unit/3pc/agent/runners/lua/account_test.cpp +++ b/tests/unit/parsec/agent/runners/lua/account_test.cpp @@ -4,13 +4,13 @@ // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include "../../../util.hpp" -#include "3pc/agent/impl.hpp" -#include "3pc/agent/runners/lua/impl.hpp" -#include "3pc/broker/impl.hpp" -#include "3pc/directory/impl.hpp" -#include "3pc/runtime_locking_shard/impl.hpp" -#include "3pc/ticket_machine/impl.hpp" #include "crypto/sha256.h" +#include "parsec/agent/impl.hpp" +#include "parsec/agent/runners/lua/impl.hpp" +#include "parsec/broker/impl.hpp" +#include "parsec/directory/impl.hpp" +#include "parsec/runtime_locking_shard/impl.hpp" +#include "parsec/ticket_machine/impl.hpp" #include "util/common/keys.hpp" #include "util/serialization/buffer_serializer.hpp" #include "util/serialization/format.hpp" @@ -30,7 +30,7 @@ class account_test : public ::testing::Test { luaL_openlibs(L); luaL_dofile( L, - "../tests/unit/3pc/agent/runners/lua/gen_pay_contract.lua"); + "../tests/unit/parsec/agent/runners/lua/gen_pay_contract.lua"); lua_getglobal(L, "gen_bytecode"); ASSERT_EQ(lua_pcall(L, 0, 1, 0), 0); m_pay_contract = cbdc::buffer::from_hex(lua_tostring(L, -1)).value(); @@ -48,24 +48,24 @@ class account_test : public ::testing::Test { std::shared_ptr m_log{ std::make_shared(cbdc::logging::log_level::trace)}; - cbdc::threepc::config m_cfg{}; - std::shared_ptr m_shard0{ - std::make_shared(m_log)}; - std::shared_ptr m_shard1{ - std::make_shared(m_log)}; - std::shared_ptr m_shard2{ - std::make_shared(m_log)}; - std::shared_ptr m_shard3{ - std::make_shared(m_log)}; - std::shared_ptr m_ticketer{ - std::make_shared(m_log, 10)}; - std::shared_ptr m_directory{ - std::make_shared(4)}; - std::shared_ptr m_broker{ - std::make_shared( + cbdc::parsec::config m_cfg{}; + std::shared_ptr m_shard0{ + std::make_shared(m_log)}; + std::shared_ptr m_shard1{ + std::make_shared(m_log)}; + std::shared_ptr m_shard2{ + std::make_shared(m_log)}; + std::shared_ptr m_shard3{ + std::make_shared(m_log)}; + std::shared_ptr m_ticketer{ + std::make_shared(m_log, 10)}; + std::shared_ptr m_directory{ + std::make_shared(4)}; + std::shared_ptr m_broker{ + std::make_shared( 0, std::vector>( + cbdc::parsec::runtime_locking_shard::interface>>( {m_shard0, m_shard1, m_shard2, m_shard3}), m_ticketer, m_directory, @@ -138,28 +138,27 @@ TEST_F(account_test, pay_test) { auto ser2 = cbdc::buffer_serializer(exp_to_acc_val); ser2 << val << m_init_sequence; - auto exp_ret = cbdc::threepc::agent::return_type( + auto exp_ret = cbdc::parsec::agent::return_type( {{exp_from_acc_key, exp_from_acc_val}, {exp_to_acc_key, exp_to_acc_val}}); auto complete = false; - auto agent = std::make_shared( + auto agent = std::make_shared( m_log, m_cfg, - &cbdc::threepc::agent::runner::factory< - cbdc::threepc::agent::runner::lua_runner>::create, + &cbdc::parsec::agent::runner::factory< + cbdc::parsec::agent::runner::lua_runner>::create, m_broker, m_pay_contract_key, params, - [&](cbdc::threepc::agent::interface::exec_return_type res) { + [&](cbdc::parsec::agent::interface::exec_return_type res) { ASSERT_TRUE( - std::holds_alternative( - res)); + std::holds_alternative(res)); ASSERT_EQ(exp_ret, - std::get(res)); + std::get(res)); complete = true; }, - cbdc::threepc::agent::runner::lua_runner::initial_lock_type, + cbdc::parsec::agent::runner::lua_runner::initial_lock_type, false, nullptr, nullptr); diff --git a/tests/unit/3pc/agent/runners/lua/agent_test.cpp b/tests/unit/parsec/agent/runners/lua/agent_test.cpp similarity index 55% rename from tests/unit/3pc/agent/runners/lua/agent_test.cpp rename to tests/unit/parsec/agent/runners/lua/agent_test.cpp index 22db347f5..cf6ab382b 100644 --- a/tests/unit/3pc/agent/runners/lua/agent_test.cpp +++ b/tests/unit/parsec/agent/runners/lua/agent_test.cpp @@ -4,12 +4,12 @@ // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include "../../../util.hpp" -#include "3pc/agent/impl.hpp" -#include "3pc/agent/runners/lua/impl.hpp" -#include "3pc/broker/impl.hpp" -#include "3pc/directory/impl.hpp" -#include "3pc/runtime_locking_shard/impl.hpp" -#include "3pc/ticket_machine/impl.hpp" +#include "parsec/agent/impl.hpp" +#include "parsec/agent/runners/lua/impl.hpp" +#include "parsec/broker/impl.hpp" +#include "parsec/directory/impl.hpp" +#include "parsec/runtime_locking_shard/impl.hpp" +#include "parsec/ticket_machine/impl.hpp" #include #include @@ -40,24 +40,24 @@ class agent_test : public ::testing::Test { std::shared_ptr m_log{ std::make_shared(cbdc::logging::log_level::trace)}; - cbdc::threepc::config m_cfg{}; - std::shared_ptr m_shard0{ - std::make_shared(m_log)}; - std::shared_ptr m_shard1{ - std::make_shared(m_log)}; - std::shared_ptr m_shard2{ - std::make_shared(m_log)}; - std::shared_ptr m_shard3{ - std::make_shared(m_log)}; - std::shared_ptr m_ticketer{ - std::make_shared(m_log, 1)}; - std::shared_ptr m_directory{ - std::make_shared(4)}; - std::shared_ptr m_broker{ - std::make_shared( + cbdc::parsec::config m_cfg{}; + std::shared_ptr m_shard0{ + std::make_shared(m_log)}; + std::shared_ptr m_shard1{ + std::make_shared(m_log)}; + std::shared_ptr m_shard2{ + std::make_shared(m_log)}; + std::shared_ptr m_shard3{ + std::make_shared(m_log)}; + std::shared_ptr m_ticketer{ + std::make_shared(m_log, 1)}; + std::shared_ptr m_directory{ + std::make_shared(4)}; + std::shared_ptr m_broker{ + std::make_shared( 0, std::vector>( + cbdc::parsec::runtime_locking_shard::interface>>( {m_shard0, m_shard1, m_shard2, m_shard3}), m_ticketer, m_directory, @@ -78,23 +78,22 @@ TEST_F(agent_test, deploy_test) { params.append(&fun_len, sizeof(fun_len)); params.append(m_deploy_contract.data(), m_deploy_contract.size()); - auto agent = std::make_shared( + auto agent = std::make_shared( m_log, m_cfg, - &cbdc::threepc::agent::runner::factory< - cbdc::threepc::agent::runner::lua_runner>::create, + &cbdc::parsec::agent::runner::factory< + cbdc::parsec::agent::runner::lua_runner>::create, m_broker, m_deploy_contract_key, params, - [&](cbdc::threepc::agent::interface::exec_return_type res) { + [&](cbdc::parsec::agent::interface::exec_return_type res) { ASSERT_TRUE( - std::holds_alternative( - res)); - auto ret = cbdc::threepc::agent::return_type( + std::holds_alternative(res)); + auto ret = cbdc::parsec::agent::return_type( {{contract_name, m_deploy_contract}}); - ASSERT_EQ(ret, std::get(res)); + ASSERT_EQ(ret, std::get(res)); }, - cbdc::threepc::agent::runner::lua_runner::initial_lock_type, + cbdc::parsec::agent::runner::lua_runner::initial_lock_type, false, nullptr, nullptr); @@ -105,25 +104,25 @@ TEST_F(agent_test, rollback_test) { auto params = cbdc::buffer(); auto callback_called = false; - auto agent = std::make_shared( + auto agent = std::make_shared( m_log, m_cfg, - &cbdc::threepc::agent::runner::factory< - cbdc::threepc::agent::runner::lua_runner>::create, + &cbdc::parsec::agent::runner::factory< + cbdc::parsec::agent::runner::lua_runner>::create, m_broker, m_deploy_contract_key, params, - [&](const cbdc::threepc::agent::interface::exec_return_type& res) { + [&](const cbdc::parsec::agent::interface::exec_return_type& res) { ASSERT_TRUE(std::holds_alternative< - cbdc::threepc::agent::interface::error_code>(res)); + cbdc::parsec::agent::interface::error_code>(res)); ASSERT_EQ( - std::get(res), - cbdc::threepc::agent::interface::error_code:: + std::get(res), + cbdc::parsec::agent::interface::error_code:: function_execution); ASSERT_FALSE(callback_called); callback_called = true; }, - cbdc::threepc::agent::runner::lua_runner::initial_lock_type, + cbdc::parsec::agent::runner::lua_runner::initial_lock_type, false, nullptr, nullptr); @@ -142,10 +141,10 @@ TEST_F(agent_test, wound_deploy_test) { params.append(&fun_len, sizeof(fun_len)); params.append(m_deploy_contract.data(), m_deploy_contract.size()); - auto broker1 = std::make_shared( + auto broker1 = std::make_shared( 1, std::vector< - std::shared_ptr>( + std::shared_ptr>( {m_shard0, m_shard1, m_shard2, m_shard3}), m_ticketer, m_directory, @@ -153,45 +152,43 @@ TEST_F(agent_test, wound_deploy_test) { auto agent0_complete = false; auto agent1_complete = false; - auto agent0 = std::make_shared( + auto agent0 = std::make_shared( m_log, m_cfg, - &cbdc::threepc::agent::runner::factory< - cbdc::threepc::agent::runner::lua_runner>::create, + &cbdc::parsec::agent::runner::factory< + cbdc::parsec::agent::runner::lua_runner>::create, m_broker, m_deploy_contract_key, params, - [&](cbdc::threepc::agent::interface::exec_return_type res) { + [&](cbdc::parsec::agent::interface::exec_return_type res) { ASSERT_TRUE( - std::holds_alternative( - res)); - auto ret = cbdc::threepc::agent::return_type( + std::holds_alternative(res)); + auto ret = cbdc::parsec::agent::return_type( {{contract_name, m_deploy_contract}}); - ASSERT_EQ(ret, std::get(res)); + ASSERT_EQ(ret, std::get(res)); agent0_complete = true; }, - cbdc::threepc::agent::runner::lua_runner::initial_lock_type, + cbdc::parsec::agent::runner::lua_runner::initial_lock_type, false, nullptr, nullptr); - auto agent1 = std::make_shared( + auto agent1 = std::make_shared( m_log, m_cfg, - &cbdc::threepc::agent::runner::factory< - cbdc::threepc::agent::runner::lua_runner>::create, + &cbdc::parsec::agent::runner::factory< + cbdc::parsec::agent::runner::lua_runner>::create, broker1, m_deploy_contract_key, params, - [&](cbdc::threepc::agent::interface::exec_return_type res) { + [&](cbdc::parsec::agent::interface::exec_return_type res) { ASSERT_TRUE( - std::holds_alternative( - res)); - auto ret = cbdc::threepc::agent::return_type( + std::holds_alternative(res)); + auto ret = cbdc::parsec::agent::return_type( {{contract_name, m_deploy_contract}}); - ASSERT_EQ(ret, std::get(res)); + ASSERT_EQ(ret, std::get(res)); agent1_complete = true; }, - cbdc::threepc::agent::runner::lua_runner::initial_lock_type, + cbdc::parsec::agent::runner::lua_runner::initial_lock_type, false, nullptr, nullptr); diff --git a/tests/unit/3pc/agent/runners/lua/gen_pay_contract.lua b/tests/unit/parsec/agent/runners/lua/gen_pay_contract.lua similarity index 100% rename from tests/unit/3pc/agent/runners/lua/gen_pay_contract.lua rename to tests/unit/parsec/agent/runners/lua/gen_pay_contract.lua diff --git a/tests/unit/parsec/agent/runners/lua/runner_test.cpp b/tests/unit/parsec/agent/runners/lua/runner_test.cpp new file mode 100644 index 000000000..2b1951eac --- /dev/null +++ b/tests/unit/parsec/agent/runners/lua/runner_test.cpp @@ -0,0 +1,68 @@ +// Copyright (c) 2021 MIT Digital Currency Initiative, +// Federal Reserve Bank of Boston +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include "parsec/agent/runners/lua/impl.hpp" +#include "parsec/util.hpp" + +#include + +TEST(agent_runner_test, rollback_test) { + auto log = std::make_shared( + cbdc::logging::log_level::trace); + + auto cfg = cbdc::parsec::config(); + + static constexpr auto contract + = "1b4c7561540019930d0a1a0a0408087856000000000000000000000028774001808" + "1860100038d8b0000018e00010203810100c40002020f0000019300000052000000" + "0f0004018b000004928003058b000004c8000200c700010086048276048a636f726" + "f7574696e6504867969656c64048668656c6c6f0482740483686981000000808080" + "8080"; + auto func = cbdc::buffer::from_hex(contract).value(); + auto param = cbdc::buffer(); + + static constexpr auto exp_val = "hi"; + auto exp_val_buf = cbdc::buffer(); + exp_val_buf.append(exp_val, 2); + + static constexpr auto exp_key = "hello"; + auto exp_key_buf = cbdc::buffer(); + exp_key_buf.append(exp_key, 5); + + auto result_cb + = [&](cbdc::parsec::agent::runner::interface::run_return_type ret) { + ASSERT_TRUE( + std::holds_alternative< + cbdc::parsec::runtime_locking_shard::state_update_type>( + ret)); + auto& val = std::get< + cbdc::parsec::runtime_locking_shard::state_update_type>(ret); + ASSERT_EQ(val.size(), 1UL); + ASSERT_EQ(val[exp_key_buf], exp_val_buf); + }; + + auto try_lock_cb + = [&](const cbdc::parsec::broker::key_type& key, + cbdc::parsec::broker::lock_type /* locktype */, + const cbdc::parsec::broker::interface::try_lock_callback_type& + res_cb) -> bool { + EXPECT_EQ(key, exp_key_buf); + res_cb(cbdc::buffer()); + return true; + }; + + auto runner + = cbdc::parsec::agent::runner::lua_runner(log, + cfg, + std::move(func), + std::move(param), + false, + std::move(result_cb), + std::move(try_lock_cb), + nullptr, + nullptr, + 0); + ASSERT_TRUE(runner.run()); +} diff --git a/tests/unit/parsec/broker/CMakeLists.txt b/tests/unit/parsec/broker/CMakeLists.txt new file mode 100644 index 000000000..888c21eaf --- /dev/null +++ b/tests/unit/parsec/broker/CMakeLists.txt @@ -0,0 +1 @@ +target_sources(parsec_unit_tests PRIVATE impl_test.cpp) diff --git a/tests/unit/3pc/broker/impl_test.cpp b/tests/unit/parsec/broker/impl_test.cpp similarity index 71% rename from tests/unit/3pc/broker/impl_test.cpp rename to tests/unit/parsec/broker/impl_test.cpp index 3b0ebf24c..812f7908d 100644 --- a/tests/unit/3pc/broker/impl_test.cpp +++ b/tests/unit/parsec/broker/impl_test.cpp @@ -4,10 +4,10 @@ // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include "../util.hpp" -#include "3pc/broker/impl.hpp" -#include "3pc/directory/impl.hpp" -#include "3pc/runtime_locking_shard/impl.hpp" -#include "3pc/ticket_machine/impl.hpp" +#include "parsec/broker/impl.hpp" +#include "parsec/directory/impl.hpp" +#include "parsec/runtime_locking_shard/impl.hpp" +#include "parsec/ticket_machine/impl.hpp" #include @@ -15,14 +15,14 @@ TEST(broker_test, deploy_test) { auto log = std::make_shared( cbdc::logging::log_level::trace); auto shard - = std::make_shared(log); + = std::make_shared(log); auto ticketer - = std::make_shared(log, 1); - auto directory = std::make_shared(1); - auto broker = std::make_shared( + = std::make_shared(log, 1); + auto directory = std::make_shared(1); + auto broker = std::make_shared( 0, std::vector< - std::shared_ptr>( + std::shared_ptr>( {shard}), ticketer, directory, diff --git a/tests/unit/parsec/runtime_locking_shard/CMakeLists.txt b/tests/unit/parsec/runtime_locking_shard/CMakeLists.txt new file mode 100644 index 000000000..888c21eaf --- /dev/null +++ b/tests/unit/parsec/runtime_locking_shard/CMakeLists.txt @@ -0,0 +1 @@ +target_sources(parsec_unit_tests PRIVATE impl_test.cpp) diff --git a/tests/unit/3pc/runtime_locking_shard/impl_test.cpp b/tests/unit/parsec/runtime_locking_shard/impl_test.cpp similarity index 54% rename from tests/unit/3pc/runtime_locking_shard/impl_test.cpp rename to tests/unit/parsec/runtime_locking_shard/impl_test.cpp index c0af0ccbb..56f48b0cd 100644 --- a/tests/unit/3pc/runtime_locking_shard/impl_test.cpp +++ b/tests/unit/parsec/runtime_locking_shard/impl_test.cpp @@ -3,7 +3,7 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#include "3pc/runtime_locking_shard/impl.hpp" +#include "parsec/runtime_locking_shard/impl.hpp" #include #include @@ -11,7 +11,7 @@ TEST(runtime_locking_shard_test, basic_test) { auto log = std::make_shared( cbdc::logging::log_level::trace); - auto shard = cbdc::threepc::runtime_locking_shard::impl(log); + auto shard = cbdc::parsec::runtime_locking_shard::impl(log); auto ticket_number = 0; auto key = cbdc::buffer::from_hex("aa").value(); @@ -20,17 +20,15 @@ TEST(runtime_locking_shard_test, basic_test) { ticket_number, 0, key, - cbdc::threepc::runtime_locking_shard::lock_type::write, + cbdc::parsec::runtime_locking_shard::lock_type::write, true, - [&](cbdc::threepc::runtime_locking_shard::interface:: + [&](cbdc::parsec::runtime_locking_shard::interface:: try_lock_return_type ret) { - ASSERT_TRUE( - std::holds_alternative< - cbdc::threepc::runtime_locking_shard::value_type>(ret)); + ASSERT_TRUE(std::holds_alternative< + cbdc::parsec::runtime_locking_shard::value_type>(ret)); auto exp = cbdc::buffer(); ASSERT_EQ( - std::get( - ret), + std::get(ret), exp); }); ASSERT_TRUE(maybe_success); @@ -41,17 +39,15 @@ TEST(runtime_locking_shard_test, basic_test) { ticket_number, 0, key1, - cbdc::threepc::runtime_locking_shard::lock_type::read, + cbdc::parsec::runtime_locking_shard::lock_type::read, false, - [&](cbdc::threepc::runtime_locking_shard::interface:: + [&](cbdc::parsec::runtime_locking_shard::interface:: try_lock_return_type ret) { - ASSERT_TRUE( - std::holds_alternative< - cbdc::threepc::runtime_locking_shard::value_type>(ret)); + ASSERT_TRUE(std::holds_alternative< + cbdc::parsec::runtime_locking_shard::value_type>(ret)); auto exp = cbdc::buffer(); ASSERT_EQ( - std::get( - ret), + std::get(ret), cbdc::buffer()); }); ASSERT_TRUE(maybe_success); @@ -62,7 +58,7 @@ TEST(runtime_locking_shard_test, basic_test) { 0, {{key, new_val}}, [](const std::optional< - cbdc::threepc::runtime_locking_shard::shard_error>& ret) { + cbdc::parsec::runtime_locking_shard::shard_error>& ret) { ASSERT_FALSE(ret.has_value()); }); ASSERT_TRUE(maybe_success); @@ -70,7 +66,7 @@ TEST(runtime_locking_shard_test, basic_test) { maybe_success = shard.commit( ticket_number, [](const std::optional< - cbdc::threepc::runtime_locking_shard::shard_error>& ret) { + cbdc::parsec::runtime_locking_shard::shard_error>& ret) { ASSERT_FALSE(ret.has_value()); }); ASSERT_TRUE(maybe_success); @@ -80,16 +76,14 @@ TEST(runtime_locking_shard_test, basic_test) { ticket_number, 0, key, - cbdc::threepc::runtime_locking_shard::lock_type::read, + cbdc::parsec::runtime_locking_shard::lock_type::read, true, - [&](cbdc::threepc::runtime_locking_shard::interface:: + [&](cbdc::parsec::runtime_locking_shard::interface:: try_lock_return_type ret) { - ASSERT_TRUE( - std::holds_alternative< - cbdc::threepc::runtime_locking_shard::value_type>(ret)); + ASSERT_TRUE(std::holds_alternative< + cbdc::parsec::runtime_locking_shard::value_type>(ret)); ASSERT_EQ( - std::get( - ret), + std::get(ret), new_val); }); ASSERT_TRUE(maybe_success); @@ -98,7 +92,7 @@ TEST(runtime_locking_shard_test, basic_test) { TEST(runtime_locking_shard_test, rollback_test) { auto log = std::make_shared( cbdc::logging::log_level::trace); - auto shard = cbdc::threepc::runtime_locking_shard::impl(log); + auto shard = cbdc::parsec::runtime_locking_shard::impl(log); auto ticket_number = 0; auto key = cbdc::buffer::from_hex("aa").value(); @@ -107,17 +101,15 @@ TEST(runtime_locking_shard_test, rollback_test) { ticket_number, 0, key, - cbdc::threepc::runtime_locking_shard::lock_type::write, + cbdc::parsec::runtime_locking_shard::lock_type::write, true, - [&](cbdc::threepc::runtime_locking_shard::interface:: + [&](cbdc::parsec::runtime_locking_shard::interface:: try_lock_return_type ret) { - ASSERT_TRUE( - std::holds_alternative< - cbdc::threepc::runtime_locking_shard::value_type>(ret)); + ASSERT_TRUE(std::holds_alternative< + cbdc::parsec::runtime_locking_shard::value_type>(ret)); auto exp = cbdc::buffer(); ASSERT_EQ( - std::get( - ret), + std::get(ret), exp); }); ASSERT_TRUE(maybe_success); @@ -128,7 +120,7 @@ TEST(runtime_locking_shard_test, rollback_test) { 0, {{key, new_val}}, [](const std::optional< - cbdc::threepc::runtime_locking_shard::shard_error>& ret) { + cbdc::parsec::runtime_locking_shard::shard_error>& ret) { ASSERT_FALSE(ret.has_value()); }); ASSERT_TRUE(maybe_success); @@ -136,7 +128,7 @@ TEST(runtime_locking_shard_test, rollback_test) { maybe_success = shard.rollback( ticket_number, [](const std::optional< - cbdc::threepc::runtime_locking_shard::shard_error>& ret) { + cbdc::parsec::runtime_locking_shard::shard_error>& ret) { ASSERT_FALSE(ret.has_value()); }); ASSERT_TRUE(maybe_success); @@ -146,16 +138,14 @@ TEST(runtime_locking_shard_test, rollback_test) { ticket_number, 0, key, - cbdc::threepc::runtime_locking_shard::lock_type::read, + cbdc::parsec::runtime_locking_shard::lock_type::read, true, - [&](cbdc::threepc::runtime_locking_shard::interface:: + [&](cbdc::parsec::runtime_locking_shard::interface:: try_lock_return_type ret) { - ASSERT_TRUE( - std::holds_alternative< - cbdc::threepc::runtime_locking_shard::value_type>(ret)); + ASSERT_TRUE(std::holds_alternative< + cbdc::parsec::runtime_locking_shard::value_type>(ret)); ASSERT_EQ( - std::get( - ret), + std::get(ret), cbdc::buffer()); }); ASSERT_TRUE(maybe_success); @@ -164,7 +154,7 @@ TEST(runtime_locking_shard_test, rollback_test) { TEST(runtime_locking_shard_test, lock_not_given_test) { auto log = std::make_shared( cbdc::logging::log_level::trace); - auto shard = cbdc::threepc::runtime_locking_shard::impl(log); + auto shard = cbdc::parsec::runtime_locking_shard::impl(log); auto ticket_number = 0; auto key = cbdc::buffer::from_hex("aa").value(); @@ -173,17 +163,15 @@ TEST(runtime_locking_shard_test, lock_not_given_test) { ticket_number, 0, key, - cbdc::threepc::runtime_locking_shard::lock_type::write, + cbdc::parsec::runtime_locking_shard::lock_type::write, true, - [&](cbdc::threepc::runtime_locking_shard::interface:: + [&](cbdc::parsec::runtime_locking_shard::interface:: try_lock_return_type ret) { - ASSERT_TRUE( - std::holds_alternative< - cbdc::threepc::runtime_locking_shard::value_type>(ret)); + ASSERT_TRUE(std::holds_alternative< + cbdc::parsec::runtime_locking_shard::value_type>(ret)); auto exp = cbdc::buffer(); ASSERT_EQ( - std::get( - ret), + std::get(ret), exp); }); ASSERT_TRUE(maybe_success); @@ -194,16 +182,14 @@ TEST(runtime_locking_shard_test, lock_not_given_test) { ticket_number + 1, 0, key, - cbdc::threepc::runtime_locking_shard::lock_type::read, + cbdc::parsec::runtime_locking_shard::lock_type::read, true, - [&](cbdc::threepc::runtime_locking_shard::interface:: + [&](cbdc::parsec::runtime_locking_shard::interface:: try_lock_return_type ret) { - ASSERT_TRUE( - std::holds_alternative< - cbdc::threepc::runtime_locking_shard::value_type>(ret)); + ASSERT_TRUE(std::holds_alternative< + cbdc::parsec::runtime_locking_shard::value_type>(ret)); ASSERT_EQ( - std::get( - ret), + std::get(ret), new_val); }); ASSERT_TRUE(maybe_success); @@ -212,16 +198,14 @@ TEST(runtime_locking_shard_test, lock_not_given_test) { ticket_number + 2, 0, key, - cbdc::threepc::runtime_locking_shard::lock_type::write, + cbdc::parsec::runtime_locking_shard::lock_type::write, true, - [&](cbdc::threepc::runtime_locking_shard::interface:: + [&](cbdc::parsec::runtime_locking_shard::interface:: try_lock_return_type ret) { - ASSERT_TRUE( - std::holds_alternative< - cbdc::threepc::runtime_locking_shard::value_type>(ret)); + ASSERT_TRUE(std::holds_alternative< + cbdc::parsec::runtime_locking_shard::value_type>(ret)); ASSERT_EQ( - std::get( - ret), + std::get(ret), new_val); }); ASSERT_TRUE(maybe_success); @@ -230,18 +214,17 @@ TEST(runtime_locking_shard_test, lock_not_given_test) { ticket_number + 1, 0, key, - cbdc::threepc::runtime_locking_shard::lock_type::read, + cbdc::parsec::runtime_locking_shard::lock_type::read, false, - [&](cbdc::threepc::runtime_locking_shard::interface:: + [&](cbdc::parsec::runtime_locking_shard::interface:: try_lock_return_type ret) { ASSERT_TRUE( std::holds_alternative< - cbdc::threepc::runtime_locking_shard::shard_error>(ret)); + cbdc::parsec::runtime_locking_shard::shard_error>(ret)); ASSERT_EQ( - std::get( - ret) + std::get(ret) .m_error_code, - cbdc::threepc::runtime_locking_shard::error_code::lock_queued); + cbdc::parsec::runtime_locking_shard::error_code::lock_queued); }); ASSERT_TRUE(maybe_success); @@ -249,12 +232,12 @@ TEST(runtime_locking_shard_test, lock_not_given_test) { ticket_number + 1, 0, {{key, new_val}}, - [](std::optional + [](std::optional ret) { ASSERT_TRUE(ret.has_value()); ASSERT_EQ( ret.value().m_error_code, - cbdc::threepc::runtime_locking_shard::error_code::lock_queued); + cbdc::parsec::runtime_locking_shard::error_code::lock_queued); }); ASSERT_TRUE(maybe_success); @@ -263,7 +246,7 @@ TEST(runtime_locking_shard_test, lock_not_given_test) { 0, {{key, new_val}}, [](const std::optional< - cbdc::threepc::runtime_locking_shard::shard_error>& ret) { + cbdc::parsec::runtime_locking_shard::shard_error>& ret) { ASSERT_FALSE(ret.has_value()); }); ASSERT_TRUE(maybe_success); @@ -271,7 +254,7 @@ TEST(runtime_locking_shard_test, lock_not_given_test) { maybe_success = shard.commit( ticket_number, [](const std::optional< - cbdc::threepc::runtime_locking_shard::shard_error>& ret) { + cbdc::parsec::runtime_locking_shard::shard_error>& ret) { ASSERT_FALSE(ret.has_value()); }); ASSERT_TRUE(maybe_success); @@ -280,18 +263,17 @@ TEST(runtime_locking_shard_test, lock_not_given_test) { ticket_number + 1, 0, key, - cbdc::threepc::runtime_locking_shard::lock_type::read, + cbdc::parsec::runtime_locking_shard::lock_type::read, false, - [&](cbdc::threepc::runtime_locking_shard::interface:: + [&](cbdc::parsec::runtime_locking_shard::interface:: try_lock_return_type ret) { ASSERT_TRUE( std::holds_alternative< - cbdc::threepc::runtime_locking_shard::shard_error>(ret)); + cbdc::parsec::runtime_locking_shard::shard_error>(ret)); ASSERT_EQ( - std::get( - ret) + std::get(ret) .m_error_code, - cbdc::threepc::runtime_locking_shard::error_code::lock_held); + cbdc::parsec::runtime_locking_shard::error_code::lock_held); }); ASSERT_TRUE(maybe_success); @@ -301,11 +283,11 @@ TEST(runtime_locking_shard_test, lock_not_given_test) { ticket_number + 1, 0, {{key1, new_val}}, - [](std::optional + [](std::optional ret) { ASSERT_TRUE(ret.has_value()); ASSERT_EQ(ret.value().m_error_code, - cbdc::threepc::runtime_locking_shard::error_code:: + cbdc::parsec::runtime_locking_shard::error_code:: lock_not_held); }); ASSERT_TRUE(maybe_success); @@ -314,11 +296,11 @@ TEST(runtime_locking_shard_test, lock_not_given_test) { ticket_number + 1, 0, {{key, new_val}}, - [](std::optional + [](std::optional ret) { ASSERT_TRUE(ret.has_value()); ASSERT_EQ(ret.value().m_error_code, - cbdc::threepc::runtime_locking_shard::error_code:: + cbdc::parsec::runtime_locking_shard::error_code:: state_update_with_read_lock); }); ASSERT_TRUE(maybe_success); @@ -326,7 +308,7 @@ TEST(runtime_locking_shard_test, lock_not_given_test) { maybe_success = shard.rollback( ticket_number + 1, [](const std::optional< - cbdc::threepc::runtime_locking_shard::shard_error>& ret) { + cbdc::parsec::runtime_locking_shard::shard_error>& ret) { ASSERT_FALSE(ret.has_value()); }); ASSERT_TRUE(maybe_success); @@ -335,7 +317,7 @@ TEST(runtime_locking_shard_test, lock_not_given_test) { TEST(runtime_locking_shard_test, wound_test) { auto log = std::make_shared( cbdc::logging::log_level::trace); - auto shard = cbdc::threepc::runtime_locking_shard::impl(log); + auto shard = cbdc::parsec::runtime_locking_shard::impl(log); auto ticket_number = 1; auto key = cbdc::buffer::from_hex("aa").value(); @@ -344,17 +326,15 @@ TEST(runtime_locking_shard_test, wound_test) { ticket_number, 0, key, - cbdc::threepc::runtime_locking_shard::lock_type::write, + cbdc::parsec::runtime_locking_shard::lock_type::write, true, - [&](cbdc::threepc::runtime_locking_shard::interface:: + [&](cbdc::parsec::runtime_locking_shard::interface:: try_lock_return_type ret) { - ASSERT_TRUE( - std::holds_alternative< - cbdc::threepc::runtime_locking_shard::value_type>(ret)); + ASSERT_TRUE(std::holds_alternative< + cbdc::parsec::runtime_locking_shard::value_type>(ret)); auto exp = cbdc::buffer(); ASSERT_EQ( - std::get( - ret), + std::get(ret), exp); }); ASSERT_TRUE(maybe_success); @@ -365,16 +345,14 @@ TEST(runtime_locking_shard_test, wound_test) { ticket_number - 1, 0, key, - cbdc::threepc::runtime_locking_shard::lock_type::read, + cbdc::parsec::runtime_locking_shard::lock_type::read, true, - [&](cbdc::threepc::runtime_locking_shard::interface:: + [&](cbdc::parsec::runtime_locking_shard::interface:: try_lock_return_type ret) { - ASSERT_TRUE( - std::holds_alternative< - cbdc::threepc::runtime_locking_shard::value_type>(ret)); + ASSERT_TRUE(std::holds_alternative< + cbdc::parsec::runtime_locking_shard::value_type>(ret)); ASSERT_EQ( - std::get( - ret), + std::get(ret), cbdc::buffer()); }); ASSERT_TRUE(maybe_success); @@ -383,12 +361,12 @@ TEST(runtime_locking_shard_test, wound_test) { ticket_number, 0, {{key, new_val}}, - [](std::optional + [](std::optional ret) { ASSERT_TRUE(ret.has_value()); ASSERT_EQ( ret.value().m_error_code, - cbdc::threepc::runtime_locking_shard::error_code::wounded); + cbdc::parsec::runtime_locking_shard::error_code::wounded); }); ASSERT_TRUE(maybe_success); @@ -396,36 +374,35 @@ TEST(runtime_locking_shard_test, wound_test) { ticket_number, 0, key, - cbdc::threepc::runtime_locking_shard::lock_type::read, + cbdc::parsec::runtime_locking_shard::lock_type::read, false, - [&](cbdc::threepc::runtime_locking_shard::interface:: + [&](cbdc::parsec::runtime_locking_shard::interface:: try_lock_return_type ret) { ASSERT_TRUE( std::holds_alternative< - cbdc::threepc::runtime_locking_shard::shard_error>(ret)); + cbdc::parsec::runtime_locking_shard::shard_error>(ret)); ASSERT_EQ( - std::get( - ret) + std::get(ret) .m_error_code, - cbdc::threepc::runtime_locking_shard::error_code::wounded); + cbdc::parsec::runtime_locking_shard::error_code::wounded); }); ASSERT_TRUE(maybe_success); maybe_success = shard.commit( ticket_number, - [](std::optional + [](std::optional ret) { ASSERT_TRUE(ret.has_value()); - ASSERT_EQ(ret.value().m_error_code, - cbdc::threepc::runtime_locking_shard::error_code:: - not_prepared); + ASSERT_EQ( + ret.value().m_error_code, + cbdc::parsec::runtime_locking_shard::error_code::not_prepared); }); ASSERT_TRUE(maybe_success); maybe_success = shard.rollback( ticket_number, [](const std::optional< - cbdc::threepc::runtime_locking_shard::shard_error>& ret) { + cbdc::parsec::runtime_locking_shard::shard_error>& ret) { ASSERT_FALSE(ret.has_value()); }); ASSERT_TRUE(maybe_success); @@ -434,25 +411,24 @@ TEST(runtime_locking_shard_test, wound_test) { ticket_number, 0, key, - cbdc::threepc::runtime_locking_shard::lock_type::write, + cbdc::parsec::runtime_locking_shard::lock_type::write, true, - [&](cbdc::threepc::runtime_locking_shard::interface:: + [&](cbdc::parsec::runtime_locking_shard::interface:: try_lock_return_type ret) { ASSERT_TRUE( std::holds_alternative< - cbdc::threepc::runtime_locking_shard::shard_error>(ret)); + cbdc::parsec::runtime_locking_shard::shard_error>(ret)); ASSERT_EQ( - std::get( - ret) + std::get(ret) .m_error_code, - cbdc::threepc::runtime_locking_shard::error_code::wounded); + cbdc::parsec::runtime_locking_shard::error_code::wounded); }); ASSERT_TRUE(maybe_success); maybe_success = shard.rollback( ticket_number, [](const std::optional< - cbdc::threepc::runtime_locking_shard::shard_error>& ret) { + cbdc::parsec::runtime_locking_shard::shard_error>& ret) { ASSERT_FALSE(ret.has_value()); }); ASSERT_TRUE(maybe_success); @@ -461,7 +437,7 @@ TEST(runtime_locking_shard_test, wound_test) { TEST(runtime_locking_shard_test, prepare_protected_test) { auto log = std::make_shared( cbdc::logging::log_level::trace); - auto shard = cbdc::threepc::runtime_locking_shard::impl(log); + auto shard = cbdc::parsec::runtime_locking_shard::impl(log); auto ticket_number = 1; auto key = cbdc::buffer::from_hex("aa").value(); @@ -470,17 +446,15 @@ TEST(runtime_locking_shard_test, prepare_protected_test) { ticket_number, 0, key, - cbdc::threepc::runtime_locking_shard::lock_type::write, + cbdc::parsec::runtime_locking_shard::lock_type::write, true, - [&](cbdc::threepc::runtime_locking_shard::interface:: + [&](cbdc::parsec::runtime_locking_shard::interface:: try_lock_return_type ret) { - ASSERT_TRUE( - std::holds_alternative< - cbdc::threepc::runtime_locking_shard::value_type>(ret)); + ASSERT_TRUE(std::holds_alternative< + cbdc::parsec::runtime_locking_shard::value_type>(ret)); auto exp = cbdc::buffer(); ASSERT_EQ( - std::get( - ret), + std::get(ret), exp); }); ASSERT_TRUE(maybe_success); @@ -492,7 +466,7 @@ TEST(runtime_locking_shard_test, prepare_protected_test) { 0, {{key, new_val}}, [](const std::optional< - cbdc::threepc::runtime_locking_shard::shard_error>& ret) { + cbdc::parsec::runtime_locking_shard::shard_error>& ret) { ASSERT_FALSE(ret.has_value()); }); ASSERT_TRUE(maybe_success); @@ -501,16 +475,14 @@ TEST(runtime_locking_shard_test, prepare_protected_test) { ticket_number - 1, 0, key, - cbdc::threepc::runtime_locking_shard::lock_type::read, + cbdc::parsec::runtime_locking_shard::lock_type::read, true, - [&](cbdc::threepc::runtime_locking_shard::interface:: + [&](cbdc::parsec::runtime_locking_shard::interface:: try_lock_return_type ret) { - ASSERT_TRUE( - std::holds_alternative< - cbdc::threepc::runtime_locking_shard::value_type>(ret)); + ASSERT_TRUE(std::holds_alternative< + cbdc::parsec::runtime_locking_shard::value_type>(ret)); ASSERT_EQ( - std::get( - ret), + std::get(ret), new_val); }); ASSERT_TRUE(maybe_success); @@ -518,7 +490,7 @@ TEST(runtime_locking_shard_test, prepare_protected_test) { maybe_success = shard.commit( ticket_number, [](const std::optional< - cbdc::threepc::runtime_locking_shard::shard_error>& ret) { + cbdc::parsec::runtime_locking_shard::shard_error>& ret) { ASSERT_FALSE(ret.has_value()); }); ASSERT_TRUE(maybe_success); @@ -527,7 +499,7 @@ TEST(runtime_locking_shard_test, prepare_protected_test) { TEST(runtime_locking_shard_test, unknown_ticket_test) { auto log = std::make_shared( cbdc::logging::log_level::trace); - auto shard = cbdc::threepc::runtime_locking_shard::impl(log); + auto shard = cbdc::parsec::runtime_locking_shard::impl(log); auto ticket_number = 0; auto key = cbdc::buffer::from_hex("aa").value(); @@ -536,33 +508,33 @@ TEST(runtime_locking_shard_test, unknown_ticket_test) { ticket_number, 0, {}, - [](std::optional + [](std::optional ret) { ASSERT_TRUE(ret.has_value()); ASSERT_EQ(ret.value().m_error_code, - cbdc::threepc::runtime_locking_shard::error_code:: + cbdc::parsec::runtime_locking_shard::error_code:: unknown_ticket); }); ASSERT_TRUE(maybe_success); maybe_success = shard.commit( ticket_number, - [](std::optional + [](std::optional ret) { ASSERT_TRUE(ret.has_value()); ASSERT_EQ(ret.value().m_error_code, - cbdc::threepc::runtime_locking_shard::error_code:: + cbdc::parsec::runtime_locking_shard::error_code:: unknown_ticket); }); ASSERT_TRUE(maybe_success); maybe_success = shard.rollback( ticket_number, - [](std::optional + [](std::optional ret) { ASSERT_TRUE(ret.has_value()); ASSERT_EQ(ret.value().m_error_code, - cbdc::threepc::runtime_locking_shard::error_code:: + cbdc::parsec::runtime_locking_shard::error_code:: unknown_ticket); }); ASSERT_TRUE(maybe_success); @@ -571,7 +543,7 @@ TEST(runtime_locking_shard_test, unknown_ticket_test) { TEST(runtime_locking_shard_test, double_prepare_test) { auto log = std::make_shared( cbdc::logging::log_level::trace); - auto shard = cbdc::threepc::runtime_locking_shard::impl(log); + auto shard = cbdc::parsec::runtime_locking_shard::impl(log); auto ticket_number = 1; auto key = cbdc::buffer::from_hex("aa").value(); @@ -580,17 +552,15 @@ TEST(runtime_locking_shard_test, double_prepare_test) { ticket_number, 0, key, - cbdc::threepc::runtime_locking_shard::lock_type::write, + cbdc::parsec::runtime_locking_shard::lock_type::write, true, - [&](cbdc::threepc::runtime_locking_shard::interface:: + [&](cbdc::parsec::runtime_locking_shard::interface:: try_lock_return_type ret) { - ASSERT_TRUE( - std::holds_alternative< - cbdc::threepc::runtime_locking_shard::value_type>(ret)); + ASSERT_TRUE(std::holds_alternative< + cbdc::parsec::runtime_locking_shard::value_type>(ret)); auto exp = cbdc::buffer(); ASSERT_EQ( - std::get( - ret), + std::get(ret), exp); }); ASSERT_TRUE(maybe_success); @@ -600,7 +570,7 @@ TEST(runtime_locking_shard_test, double_prepare_test) { 0, {}, [](const std::optional< - cbdc::threepc::runtime_locking_shard::shard_error>& ret) { + cbdc::parsec::runtime_locking_shard::shard_error>& ret) { ASSERT_FALSE(ret.has_value()); }); ASSERT_TRUE(maybe_success); @@ -609,18 +579,17 @@ TEST(runtime_locking_shard_test, double_prepare_test) { ticket_number, 0, key, - cbdc::threepc::runtime_locking_shard::lock_type::write, + cbdc::parsec::runtime_locking_shard::lock_type::write, false, - [&](cbdc::threepc::runtime_locking_shard::interface:: + [&](cbdc::parsec::runtime_locking_shard::interface:: try_lock_return_type ret) { ASSERT_TRUE( std::holds_alternative< - cbdc::threepc::runtime_locking_shard::shard_error>(ret)); + cbdc::parsec::runtime_locking_shard::shard_error>(ret)); ASSERT_EQ( - std::get( - ret) + std::get(ret) .m_error_code, - cbdc::threepc::runtime_locking_shard::error_code::prepared); + cbdc::parsec::runtime_locking_shard::error_code::prepared); }); ASSERT_TRUE(maybe_success); @@ -628,12 +597,12 @@ TEST(runtime_locking_shard_test, double_prepare_test) { ticket_number, 0, {}, - [](std::optional + [](std::optional ret) { ASSERT_TRUE(ret.has_value()); ASSERT_EQ( ret.value().m_error_code, - cbdc::threepc::runtime_locking_shard::error_code::prepared); + cbdc::parsec::runtime_locking_shard::error_code::prepared); }); ASSERT_TRUE(maybe_success); } @@ -641,7 +610,7 @@ TEST(runtime_locking_shard_test, double_prepare_test) { TEST(runtime_locking_shard_test, upgrade_lock_test) { auto log = std::make_shared( cbdc::logging::log_level::trace); - auto shard = cbdc::threepc::runtime_locking_shard::impl(log); + auto shard = cbdc::parsec::runtime_locking_shard::impl(log); auto ticket_number = 2; auto key = cbdc::buffer::from_hex("aa").value(); @@ -650,17 +619,15 @@ TEST(runtime_locking_shard_test, upgrade_lock_test) { ticket_number, 0, key, - cbdc::threepc::runtime_locking_shard::lock_type::read, + cbdc::parsec::runtime_locking_shard::lock_type::read, true, - [&](cbdc::threepc::runtime_locking_shard::interface:: + [&](cbdc::parsec::runtime_locking_shard::interface:: try_lock_return_type ret) { - ASSERT_TRUE( - std::holds_alternative< - cbdc::threepc::runtime_locking_shard::value_type>(ret)); + ASSERT_TRUE(std::holds_alternative< + cbdc::parsec::runtime_locking_shard::value_type>(ret)); auto exp = cbdc::buffer(); ASSERT_EQ( - std::get( - ret), + std::get(ret), exp); }); ASSERT_TRUE(maybe_success); @@ -670,17 +637,15 @@ TEST(runtime_locking_shard_test, upgrade_lock_test) { ticket_number, 0, key, - cbdc::threepc::runtime_locking_shard::lock_type::read, + cbdc::parsec::runtime_locking_shard::lock_type::read, true, - [&](cbdc::threepc::runtime_locking_shard::interface:: + [&](cbdc::parsec::runtime_locking_shard::interface:: try_lock_return_type ret) { - ASSERT_TRUE( - std::holds_alternative< - cbdc::threepc::runtime_locking_shard::value_type>(ret)); + ASSERT_TRUE(std::holds_alternative< + cbdc::parsec::runtime_locking_shard::value_type>(ret)); auto exp = cbdc::buffer(); ASSERT_EQ( - std::get( - ret), + std::get(ret), exp); }); ASSERT_TRUE(maybe_success); @@ -689,17 +654,15 @@ TEST(runtime_locking_shard_test, upgrade_lock_test) { ticket_number, 0, key, - cbdc::threepc::runtime_locking_shard::lock_type::write, + cbdc::parsec::runtime_locking_shard::lock_type::write, false, - [&](cbdc::threepc::runtime_locking_shard::interface:: + [&](cbdc::parsec::runtime_locking_shard::interface:: try_lock_return_type ret) { - ASSERT_TRUE( - std::holds_alternative< - cbdc::threepc::runtime_locking_shard::value_type>(ret)); + ASSERT_TRUE(std::holds_alternative< + cbdc::parsec::runtime_locking_shard::value_type>(ret)); auto exp = cbdc::buffer(); ASSERT_EQ( - std::get( - ret), + std::get(ret), exp); }); ASSERT_TRUE(maybe_success); @@ -709,18 +672,17 @@ TEST(runtime_locking_shard_test, upgrade_lock_test) { ticket_number, 0, key, - cbdc::threepc::runtime_locking_shard::lock_type::write, + cbdc::parsec::runtime_locking_shard::lock_type::write, false, - [&](cbdc::threepc::runtime_locking_shard::interface:: + [&](cbdc::parsec::runtime_locking_shard::interface:: try_lock_return_type ret) { ASSERT_TRUE( std::holds_alternative< - cbdc::threepc::runtime_locking_shard::shard_error>(ret)); + cbdc::parsec::runtime_locking_shard::shard_error>(ret)); ASSERT_EQ( - std::get( - ret) + std::get(ret) .m_error_code, - cbdc::threepc::runtime_locking_shard::error_code::wounded); + cbdc::parsec::runtime_locking_shard::error_code::wounded); }); ASSERT_TRUE(maybe_success); @@ -729,18 +691,17 @@ TEST(runtime_locking_shard_test, upgrade_lock_test) { ticket_number, 0, key, - cbdc::threepc::runtime_locking_shard::lock_type::write, + cbdc::parsec::runtime_locking_shard::lock_type::write, false, - [&](cbdc::threepc::runtime_locking_shard::interface:: + [&](cbdc::parsec::runtime_locking_shard::interface:: try_lock_return_type ret) { ASSERT_TRUE( std::holds_alternative< - cbdc::threepc::runtime_locking_shard::shard_error>(ret)); + cbdc::parsec::runtime_locking_shard::shard_error>(ret)); ASSERT_EQ( - std::get( - ret) + std::get(ret) .m_error_code, - cbdc::threepc::runtime_locking_shard::error_code::lock_held); + cbdc::parsec::runtime_locking_shard::error_code::lock_held); }); ASSERT_TRUE(maybe_success); @@ -748,18 +709,17 @@ TEST(runtime_locking_shard_test, upgrade_lock_test) { ticket_number, 0, key, - cbdc::threepc::runtime_locking_shard::lock_type::read, + cbdc::parsec::runtime_locking_shard::lock_type::read, false, - [&](cbdc::threepc::runtime_locking_shard::interface:: + [&](cbdc::parsec::runtime_locking_shard::interface:: try_lock_return_type ret) { ASSERT_TRUE( std::holds_alternative< - cbdc::threepc::runtime_locking_shard::shard_error>(ret)); + cbdc::parsec::runtime_locking_shard::shard_error>(ret)); ASSERT_EQ( - std::get( - ret) + std::get(ret) .m_error_code, - cbdc::threepc::runtime_locking_shard::error_code::lock_held); + cbdc::parsec::runtime_locking_shard::error_code::lock_held); }); ASSERT_TRUE(maybe_success); } diff --git a/tests/unit/3pc/util.cpp b/tests/unit/parsec/util.cpp similarity index 83% rename from tests/unit/3pc/util.cpp rename to tests/unit/parsec/util.cpp index 44e34fe9e..138ba638f 100644 --- a/tests/unit/3pc/util.cpp +++ b/tests/unit/parsec/util.cpp @@ -8,20 +8,20 @@ #include namespace cbdc::test { - void add_to_shard(std::shared_ptr broker, + void add_to_shard(std::shared_ptr broker, cbdc::buffer key, cbdc::buffer value) { auto begin_res = broker->begin([&](auto begin_ret) { ASSERT_TRUE(std::holds_alternative< - cbdc::threepc::ticket_machine::ticket_number_type>( + cbdc::parsec::ticket_machine::ticket_number_type>( begin_ret)); auto ticket_number - = std::get( + = std::get( begin_ret); auto lock_res = broker->try_lock( ticket_number, key, - cbdc::threepc::runtime_locking_shard::lock_type::write, + cbdc::parsec::runtime_locking_shard::lock_type::write, [&](auto try_lock_res) { ASSERT_TRUE( std::holds_alternative(try_lock_res)); diff --git a/tests/unit/3pc/util.hpp b/tests/unit/parsec/util.hpp similarity index 67% rename from tests/unit/3pc/util.hpp rename to tests/unit/parsec/util.hpp index 3feec6cd3..5d5184ce3 100644 --- a/tests/unit/3pc/util.hpp +++ b/tests/unit/parsec/util.hpp @@ -3,15 +3,15 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#ifndef TEST_UNIT_THREEPC_UTIL_INC_ -#define TEST_UNIT_THREEPC_UTIL_INC_ +#ifndef TEST_UNIT_PARSEC_UTIL_INC_ +#define TEST_UNIT_PARSEC_UTIL_INC_ -#include "3pc/broker/interface.hpp" +#include "parsec/broker/interface.hpp" #include namespace cbdc::test { - void add_to_shard(std::shared_ptr broker, + void add_to_shard(std::shared_ptr broker, cbdc::buffer key, cbdc::buffer value); } diff --git a/tools/bench/CMakeLists.txt b/tools/bench/CMakeLists.txt index 3a7cbd5c4..529079a64 100644 --- a/tools/bench/CMakeLists.txt +++ b/tools/bench/CMakeLists.txt @@ -32,4 +32,4 @@ target_link_libraries(atomizer-cli-watchtower watchtower ${NURAFT_LIBRARY} ${CMAKE_THREAD_LIBS_INIT}) -add_subdirectory(3pc) +add_subdirectory(parsec) diff --git a/tools/bench/3pc/CMakeLists.txt b/tools/bench/parsec/CMakeLists.txt similarity index 100% rename from tools/bench/3pc/CMakeLists.txt rename to tools/bench/parsec/CMakeLists.txt diff --git a/tools/bench/3pc/evm/.clang-tidy b/tools/bench/parsec/evm/.clang-tidy similarity index 100% rename from tools/bench/3pc/evm/.clang-tidy rename to tools/bench/parsec/evm/.clang-tidy diff --git a/tools/bench/3pc/evm/CMakeLists.txt b/tools/bench/parsec/evm/CMakeLists.txt similarity index 93% rename from tools/bench/3pc/evm/CMakeLists.txt rename to tools/bench/parsec/evm/CMakeLists.txt index d264436c2..3848b526e 100644 --- a/tools/bench/3pc/evm/CMakeLists.txt +++ b/tools/bench/parsec/evm/CMakeLists.txt @@ -3,7 +3,7 @@ add_executable(evm_bench evm_bench.cpp contracts.cpp main.cpp) target_link_libraries(evm_bench evm_runner - threepc + parsec json_rpc_http serialization common diff --git a/tools/bench/3pc/evm/contracts.cpp b/tools/bench/parsec/evm/contracts.cpp similarity index 99% rename from tools/bench/3pc/evm/contracts.cpp rename to tools/bench/parsec/evm/contracts.cpp index e1af42865..d1ee6cccf 100644 --- a/tools/bench/3pc/evm/contracts.cpp +++ b/tools/bench/parsec/evm/contracts.cpp @@ -5,7 +5,7 @@ #include "contracts.hpp" -namespace cbdc::threepc::evm_contracts { +namespace cbdc::parsec::evm_contracts { auto data_erc20_deploy() -> cbdc::buffer { auto buf = cbdc::buffer::from_hex( "60806040523480156200001157600080fd5b50604051806040016040528060068" diff --git a/tools/bench/3pc/evm/contracts.hpp b/tools/bench/parsec/evm/contracts.hpp similarity index 86% rename from tools/bench/3pc/evm/contracts.hpp rename to tools/bench/parsec/evm/contracts.hpp index 3c15d4a1e..b36835794 100644 --- a/tools/bench/3pc/evm/contracts.hpp +++ b/tools/bench/parsec/evm/contracts.hpp @@ -3,15 +3,15 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#ifndef OPENCBDC_TX_TOOLS_BENCH_3PC_EVM_CONTRACTS_H_ -#define OPENCBDC_TX_TOOLS_BENCH_3PC_EVM_CONTRACTS_H_ +#ifndef OPENCBDC_TX_TOOLS_BENCH_PARSEC_EVM_CONTRACTS_H_ +#define OPENCBDC_TX_TOOLS_BENCH_PARSEC_EVM_CONTRACTS_H_ -#include "3pc/agent/runners/evm/hash.hpp" +#include "parsec/agent/runners/evm/hash.hpp" #include "util/common/buffer.hpp" #include -namespace cbdc::threepc::evm_contracts { +namespace cbdc::parsec::evm_contracts { static constexpr size_t selector_size = 4; static constexpr size_t param_size = 32; @@ -52,4 +52,4 @@ namespace cbdc::threepc::evm_contracts { } -#endif // OPENCBDC_TX_TOOLS_BENCH_3PC_EVM_CONTRACTS_H_ +#endif // OPENCBDC_TX_TOOLS_BENCH_PARSEC_EVM_CONTRACTS_H_ diff --git a/tools/bench/3pc/evm/contracts/.gitignore b/tools/bench/parsec/evm/contracts/.gitignore similarity index 100% rename from tools/bench/3pc/evm/contracts/.gitignore rename to tools/bench/parsec/evm/contracts/.gitignore diff --git a/tools/bench/3pc/evm/contracts/README.md b/tools/bench/parsec/evm/contracts/README.md similarity index 58% rename from tools/bench/3pc/evm/contracts/README.md rename to tools/bench/parsec/evm/contracts/README.md index 32cfd2104..ed474347f 100644 --- a/tools/bench/3pc/evm/contracts/README.md +++ b/tools/bench/parsec/evm/contracts/README.md @@ -1,6 +1,6 @@ -# 3PC/EVM Load generator contracts +# PARSEC/EVM Load generator contracts -This folder contains the contracts used in the 3PC/EVM Load generator +This folder contains the contracts used in the PARSEC/EVM Load generator Run this to get started: @@ -18,4 +18,4 @@ in the load generator pnpm run build ``` -The final header will be placed in `tools/bench/3pc/evm/contracts.hpp` +The final header will be placed in `tools/bench/parsec/evm/contracts.hpp` diff --git a/tools/bench/3pc/evm/contracts/contracts/ERC20.sol b/tools/bench/parsec/evm/contracts/contracts/ERC20.sol similarity index 100% rename from tools/bench/3pc/evm/contracts/contracts/ERC20.sol rename to tools/bench/parsec/evm/contracts/contracts/ERC20.sol diff --git a/tools/bench/3pc/evm/contracts/gen_header.py b/tools/bench/parsec/evm/contracts/gen_header.py similarity index 94% rename from tools/bench/3pc/evm/contracts/gen_header.py rename to tools/bench/parsec/evm/contracts/gen_header.py index baa36b792..e77c9a9fd 100644 --- a/tools/bench/3pc/evm/contracts/gen_header.py +++ b/tools/bench/parsec/evm/contracts/gen_header.py @@ -38,14 +38,14 @@ def to_snake(name): f.write('// Federal Reserve Bank of Boston\n') f.write('// Distributed under the MIT software license, see the accompanying\n') f.write('// file COPYING or http://www.opensource.org/licenses/mit-license.php.\n\n') - f.write('#ifndef OPENCBDC_TX_TOOLS_BENCH_3PC_EVM_CONTRACTS_H_\n') - f.write('#define OPENCBDC_TX_TOOLS_BENCH_3PC_EVM_CONTRACTS_H_\n\n') + f.write('#ifndef OPENCBDC_TX_TOOLS_BENCH_PARSEC_EVM_CONTRACTS_H_\n') + f.write('#define OPENCBDC_TX_TOOLS_BENCH_PARSEC_EVM_CONTRACTS_H_\n\n') f.write('#include "util/common/buffer.hpp"\n\n') - f.write('#include "3pc/agent/runners/evm/hash.hpp"\n\n') + f.write('#include "parsec/agent/runners/evm/hash.hpp"\n\n') # The first 4 bytes of the input data sent to a contract are the method # selector in ETH. It is the first 4 bytes of keccak256() - f.write('namespace cbdc::threepc::evm_contracts {\n') + f.write('namespace cbdc::parsec::evm_contracts {\n') # The first 4 bytes of the input data sent to a contract are the method @@ -118,5 +118,5 @@ def to_snake(name): f.write(' }\n\n') f.write('}\n\n') - f.write('#endif // OPENCBDC_TX_TOOLS_BENCH_3PC_EVM_CONTRACTS_H_\n\n') + f.write('#endif // OPENCBDC_TX_TOOLS_BENCH_PARSEC_EVM_CONTRACTS_H_\n\n') diff --git a/tools/bench/3pc/evm/contracts/hardhat.config.js b/tools/bench/parsec/evm/contracts/hardhat.config.js similarity index 100% rename from tools/bench/3pc/evm/contracts/hardhat.config.js rename to tools/bench/parsec/evm/contracts/hardhat.config.js diff --git a/tools/bench/3pc/evm/contracts/package.json b/tools/bench/parsec/evm/contracts/package.json similarity index 82% rename from tools/bench/3pc/evm/contracts/package.json rename to tools/bench/parsec/evm/contracts/package.json index 79d65564c..25ca7ff69 100644 --- a/tools/bench/3pc/evm/contracts/package.json +++ b/tools/bench/parsec/evm/contracts/package.json @@ -1,7 +1,7 @@ { - "name": "3pc-evm-loadgen", + "name": "parsec-evm-loadgen", "version": "1.0.0", - "description": "Load generator for 3PC EVM", + "description": "Load generator for PARSEC EVM", "main": "index.js", "scripts": { "build": "npx hardhat compile && python3 gen_header.py && clang-format -i cpp_header/contracts.hpp" diff --git a/tools/bench/3pc/evm/contracts/pnpm-lock.yaml b/tools/bench/parsec/evm/contracts/pnpm-lock.yaml similarity index 100% rename from tools/bench/3pc/evm/contracts/pnpm-lock.yaml rename to tools/bench/parsec/evm/contracts/pnpm-lock.yaml diff --git a/tools/bench/3pc/evm/evm_bench.cpp b/tools/bench/parsec/evm/evm_bench.cpp similarity index 79% rename from tools/bench/3pc/evm/evm_bench.cpp rename to tools/bench/parsec/evm/evm_bench.cpp index 71e847e52..9e0f1828a 100644 --- a/tools/bench/3pc/evm/evm_bench.cpp +++ b/tools/bench/parsec/evm/evm_bench.cpp @@ -5,19 +5,19 @@ #include "evm_bench.hpp" -#include "3pc/agent/runners/evm/address.hpp" -#include "3pc/agent/runners/evm/format.hpp" -#include "3pc/agent/runners/evm/math.hpp" -#include "3pc/agent/runners/evm/serialization.hpp" -#include "3pc/agent/runners/evm/signature.hpp" #include "contracts.hpp" +#include "parsec/agent/runners/evm/address.hpp" +#include "parsec/agent/runners/evm/format.hpp" +#include "parsec/agent/runners/evm/math.hpp" +#include "parsec/agent/runners/evm/serialization.hpp" +#include "parsec/agent/runners/evm/signature.hpp" #include "util/serialization/util.hpp" -using namespace cbdc::threepc::agent::runner; +using namespace cbdc::parsec::agent::runner; evm_bench::evm_bench(size_t loadgen_id, size_t mint_tree_depth, - cbdc::threepc::config cfg, + cbdc::parsec::config cfg, std::shared_ptr log, std::shared_ptr client) : m_loadgen_id(loadgen_id), @@ -54,46 +54,46 @@ auto evm_bench::gen_tx(evmc::uint256be nonce, evmc::address to_addr, cbdc::privkey_t skey, evmc::uint256be value) -> std::string { - auto tx = cbdc::threepc::agent::runner::evm_tx(); + auto tx = cbdc::parsec::agent::runner::evm_tx(); tx.m_to = to_addr; tx.m_value = value; tx.m_gas_limit = evmc::uint256be(0xffffffff); tx.m_gas_price = evmc::uint256be(0); tx.m_nonce = nonce; - tx.m_type = cbdc::threepc::agent::runner::evm_tx_type::legacy; + tx.m_type = cbdc::parsec::agent::runner::evm_tx_type::legacy; - auto sighash = cbdc::threepc::agent::runner::sig_hash(tx); - auto sig = cbdc::threepc::agent::runner::eth_sign(skey, - sighash, - tx.m_type, - m_secp_context); + auto sighash = cbdc::parsec::agent::runner::sig_hash(tx); + auto sig = cbdc::parsec::agent::runner::eth_sign(skey, + sighash, + tx.m_type, + m_secp_context); tx.m_sig = sig; - auto tx_buf = cbdc::threepc::agent::runner::tx_encode(tx); + auto tx_buf = cbdc::parsec::agent::runner::tx_encode(tx); auto tx_hex = "0x" + tx_buf.to_hex(); return tx_hex; } auto evm_bench::deploy_erc20(evmc::uint256be nonce, cbdc::privkey_t skey) -> std::string { - auto tx = cbdc::threepc::agent::runner::evm_tx(); + auto tx = cbdc::parsec::agent::runner::evm_tx(); tx.m_gas_limit = evmc::uint256be(0xffffffff); tx.m_gas_price = evmc::uint256be(0); tx.m_nonce = nonce; - tx.m_type = cbdc::threepc::agent::runner::evm_tx_type::legacy; - auto data = cbdc::threepc::evm_contracts::data_erc20_deploy(); + tx.m_type = cbdc::parsec::agent::runner::evm_tx_type::legacy; + auto data = cbdc::parsec::evm_contracts::data_erc20_deploy(); tx.m_input.resize(data.size()); std::memcpy(tx.m_input.data(), data.data(), data.size()); - auto sighash = cbdc::threepc::agent::runner::sig_hash(tx); - auto sig = cbdc::threepc::agent::runner::eth_sign(skey, - sighash, - tx.m_type, - m_secp_context); + auto sighash = cbdc::parsec::agent::runner::sig_hash(tx); + auto sig = cbdc::parsec::agent::runner::eth_sign(skey, + sighash, + tx.m_type, + m_secp_context); tx.m_sig = sig; - auto tx_buf = cbdc::threepc::agent::runner::tx_encode(tx); + auto tx_buf = cbdc::parsec::agent::runner::tx_encode(tx); auto tx_hex = "0x" + tx_buf.to_hex(); return tx_hex; } @@ -103,25 +103,25 @@ auto evm_bench::send_erc20(evmc::address erc20_addr, evmc::address to_addr, cbdc::privkey_t skey, evmc::uint256be value) -> std::string { - auto tx = cbdc::threepc::agent::runner::evm_tx(); + auto tx = cbdc::parsec::agent::runner::evm_tx(); tx.m_to = erc20_addr; tx.m_gas_limit = evmc::uint256be(0xffffffff); tx.m_gas_price = evmc::uint256be(0); tx.m_nonce = nonce; - tx.m_type = cbdc::threepc::agent::runner::evm_tx_type::legacy; + tx.m_type = cbdc::parsec::agent::runner::evm_tx_type::legacy; auto data - = cbdc::threepc::evm_contracts::data_erc20_transfer(to_addr, value); + = cbdc::parsec::evm_contracts::data_erc20_transfer(to_addr, value); tx.m_input.resize(data.size()); std::memcpy(tx.m_input.data(), data.data(), data.size()); - auto sighash = cbdc::threepc::agent::runner::sig_hash(tx); - auto sig = cbdc::threepc::agent::runner::eth_sign(skey, - sighash, - tx.m_type, - m_secp_context); + auto sighash = cbdc::parsec::agent::runner::sig_hash(tx); + auto sig = cbdc::parsec::agent::runner::eth_sign(skey, + sighash, + tx.m_type, + m_secp_context); tx.m_sig = sig; - auto tx_buf = cbdc::threepc::agent::runner::tx_encode(tx); + auto tx_buf = cbdc::parsec::agent::runner::tx_encode(tx); auto tx_hex = "0x" + tx_buf.to_hex(); return tx_hex; } @@ -129,7 +129,7 @@ auto evm_bench::send_erc20(evmc::address erc20_addr, auto evm_bench::new_account() -> std::pair { auto new_skey = m_rnd.random_hash(); auto addr - = cbdc::threepc::agent::runner::eth_addr(new_skey, m_secp_context); + = cbdc::parsec::agent::runner::eth_addr(new_skey, m_secp_context); return {new_skey, addr}; } @@ -148,7 +148,7 @@ void evm_bench::mint_one(size_t count, cbdc::privkey_t acc_skey, size_t depth) { auto tx_from_addr - = cbdc::threepc::agent::runner::eth_addr(acc_skey, m_secp_context); + = cbdc::parsec::agent::runner::eth_addr(acc_skey, m_secp_context); auto new_acc = new_account(); auto& new_skey = new_acc.first; auto& new_addr = new_acc.second; @@ -166,10 +166,10 @@ void evm_bench::mint_one(size_t count, } std::string mint_tx_hex{}; - if(m_cfg.m_load_type == cbdc::threepc::load_type::transfer) { + if(m_cfg.m_load_type == cbdc::parsec::load_type::transfer) { mint_tx_hex = gen_tx(evmc::uint256be(count), new_addr, acc_skey, mint_amt); - } else if(m_cfg.m_load_type == cbdc::threepc::load_type::erc20) { + } else if(m_cfg.m_load_type == cbdc::parsec::load_type::erc20) { mint_tx_hex = send_erc20(m_erc20_addr, evmc::uint256be(count), new_addr, @@ -204,17 +204,17 @@ void evm_bench::mint_one(size_t count, void evm_bench::deploy() { auto from_addr - = cbdc::threepc::agent::runner::eth_addr(m_skey, m_secp_context); + = cbdc::parsec::agent::runner::eth_addr(m_skey, m_secp_context); m_log->info("Using privkey [", cbdc::to_string(m_skey), "] (address [", - cbdc::threepc::agent::runner::to_hex(from_addr), + cbdc::parsec::agent::runner::to_hex(from_addr), "])"); m_in_flight++; m_client->get_transaction_count( - cbdc::threepc::agent::runner::to_hex(from_addr), + cbdc::parsec::agent::runner::to_hex(from_addr), [this, from_addr](std::optional maybe_nonce) { m_in_flight--; if(!maybe_nonce.has_value()) { @@ -225,12 +225,12 @@ void evm_bench::deploy() { m_current_nonce = maybe_nonce.value(); auto tx_hex = std::string(); - if(m_cfg.m_load_type == cbdc::threepc::load_type::transfer) { + if(m_cfg.m_load_type == cbdc::parsec::load_type::transfer) { tx_hex = gen_tx(m_current_nonce, m_init_addr, m_skey, m_total_mint); - } else if(m_cfg.m_load_type == cbdc::threepc::load_type::erc20) { + } else if(m_cfg.m_load_type == cbdc::parsec::load_type::erc20) { tx_hex = deploy_erc20(m_current_nonce, m_skey); } @@ -246,19 +246,19 @@ void evm_bench::deploy() { return; } - if(m_cfg.m_load_type != cbdc::threepc::load_type::erc20) { + if(m_cfg.m_load_type != cbdc::parsec::load_type::erc20) { m_done = true; m_success = true; return; } m_erc20_addr - = cbdc::threepc::agent::runner::contract_address( + = cbdc::parsec::agent::runner::contract_address( from_addr, m_current_nonce); m_log->info( "Deployed ERC20 to", - cbdc::threepc::agent::runner::to_hex(m_erc20_addr)); + cbdc::parsec::agent::runner::to_hex(m_erc20_addr)); auto mint_tx_hex = send_erc20(m_erc20_addr, m_current_nonce + evmc::uint256be(1), @@ -291,9 +291,9 @@ void evm_bench::schedule_tx(size_t from, size_t to) { // When balance is too low, claim back what this account sent // to account 0 for m_contention_rate send_amt = m_sent_to_zero[tx_from_addr]; - m_log->trace(cbdc::threepc::agent::runner::to_hex(tx_from_addr), + m_log->trace(cbdc::parsec::agent::runner::to_hex(tx_from_addr), "has insufficient balance, reclaiming", - cbdc::threepc::agent::runner::to_hex(send_amt), + cbdc::parsec::agent::runner::to_hex(send_amt), "from account zero"); to = from; from = 0; @@ -307,9 +307,9 @@ void evm_bench::schedule_tx(size_t from, size_t to) { auto& to_addr = m_accounts[to].second; auto& nonce = m_nonces[from]; std::string send_tx_hex{}; - if(m_cfg.m_load_type == cbdc::threepc::load_type::transfer) { + if(m_cfg.m_load_type == cbdc::parsec::load_type::transfer) { send_tx_hex = gen_tx(nonce, to_addr, acc_skey, send_amt); - } else if(m_cfg.m_load_type == cbdc::threepc::load_type::erc20) { + } else if(m_cfg.m_load_type == cbdc::parsec::load_type::erc20) { send_tx_hex = send_erc20(m_erc20_addr, nonce, to_addr, acc_skey, send_amt); } diff --git a/tools/bench/3pc/evm/evm_bench.hpp b/tools/bench/parsec/evm/evm_bench.hpp similarity index 94% rename from tools/bench/3pc/evm/evm_bench.hpp rename to tools/bench/parsec/evm/evm_bench.hpp index b8ff2701e..92af1ba7d 100644 --- a/tools/bench/3pc/evm/evm_bench.hpp +++ b/tools/bench/parsec/evm/evm_bench.hpp @@ -3,10 +3,10 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#ifndef OPENCBDC_TX_TOOLS_BENCH_3PC_EVM_EVM_BENCH_H_ -#define OPENCBDC_TX_TOOLS_BENCH_3PC_EVM_EVM_BENCH_H_ +#ifndef OPENCBDC_TX_TOOLS_BENCH_PARSEC_EVM_EVM_BENCH_H_ +#define OPENCBDC_TX_TOOLS_BENCH_PARSEC_EVM_EVM_BENCH_H_ -#include "3pc/util.hpp" +#include "parsec/util.hpp" #include "rpc_client.hpp" #include "util/common/config.hpp" #include "util/common/keys.hpp" @@ -23,7 +23,7 @@ class evm_bench { public: evm_bench(size_t loadgen_id, size_t mint_tree_depth, - cbdc::threepc::config cfg, + cbdc::parsec::config cfg, std::shared_ptr log, std::shared_ptr client); @@ -66,7 +66,7 @@ class evm_bench { std::bernoulli_distribution m_contention_dist; size_t m_loadgen_id; - cbdc::threepc::config m_cfg; + cbdc::parsec::config m_cfg; std::shared_ptr m_log; std::shared_ptr m_client; std::unordered_map m_balances; diff --git a/tools/bench/3pc/evm/main.cpp b/tools/bench/parsec/evm/main.cpp similarity index 97% rename from tools/bench/3pc/evm/main.cpp rename to tools/bench/parsec/evm/main.cpp index e38561b75..7de461db3 100644 --- a/tools/bench/3pc/evm/main.cpp +++ b/tools/bench/parsec/evm/main.cpp @@ -8,7 +8,7 @@ #include auto main(int argc, char** argv) -> int { - auto cfg = cbdc::threepc::read_config(argc, argv); + auto cfg = cbdc::parsec::read_config(argc, argv); if(!cfg.has_value()) { std::cout << "Error parsing options" << std::endl; return 1; diff --git a/tools/bench/3pc/evm/rpc_client.cpp b/tools/bench/parsec/evm/rpc_client.cpp similarity index 96% rename from tools/bench/3pc/evm/rpc_client.cpp rename to tools/bench/parsec/evm/rpc_client.cpp index 74960f893..d86df4482 100644 --- a/tools/bench/3pc/evm/rpc_client.cpp +++ b/tools/bench/parsec/evm/rpc_client.cpp @@ -62,7 +62,7 @@ void geth_client::get_transaction_count( if(v.isMember(result_key)) { auto res_str = v[result_key].asString(); - c(cbdc::threepc::agent::runner::uint256be_from_hex(res_str)); + c(cbdc::parsec::agent::runner::uint256be_from_hex(res_str)); return; } diff --git a/tools/bench/3pc/evm/rpc_client.hpp b/tools/bench/parsec/evm/rpc_client.hpp similarity index 89% rename from tools/bench/3pc/evm/rpc_client.hpp rename to tools/bench/parsec/evm/rpc_client.hpp index 82bafe5e0..bf04620b0 100644 --- a/tools/bench/3pc/evm/rpc_client.hpp +++ b/tools/bench/parsec/evm/rpc_client.hpp @@ -3,10 +3,10 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#ifndef OPENCBDC_TX_TOOLS_BENCH_3PC_EVM_RPC_CLIENT_H_ -#define OPENCBDC_TX_TOOLS_BENCH_3PC_EVM_RPC_CLIENT_H_ +#ifndef OPENCBDC_TX_TOOLS_BENCH_PARSEC_EVM_RPC_CLIENT_H_ +#define OPENCBDC_TX_TOOLS_BENCH_PARSEC_EVM_RPC_CLIENT_H_ -#include "3pc/agent/runners/evm/util.hpp" +#include "parsec/agent/runners/evm/util.hpp" #include "util/rpc/http/json_rpc_http_client.hpp" class geth_client : public cbdc::rpc::json_rpc_http_client { diff --git a/tools/bench/3pc/lua/CMakeLists.txt b/tools/bench/parsec/lua/CMakeLists.txt similarity index 94% rename from tools/bench/3pc/lua/CMakeLists.txt rename to tools/bench/parsec/lua/CMakeLists.txt index 60807361e..f7cf37121 100644 --- a/tools/bench/3pc/lua/CMakeLists.txt +++ b/tools/bench/parsec/lua/CMakeLists.txt @@ -4,7 +4,7 @@ target_link_libraries(lua_bench broker directory runtime_locking_shard ticket_machine - threepc + parsec agent rpc network diff --git a/tools/bench/3pc/lua/lua_bench.cpp b/tools/bench/parsec/lua/lua_bench.cpp similarity index 91% rename from tools/bench/3pc/lua/lua_bench.cpp rename to tools/bench/parsec/lua/lua_bench.cpp index 8ccecca00..94972e04e 100644 --- a/tools/bench/3pc/lua/lua_bench.cpp +++ b/tools/bench/parsec/lua/lua_bench.cpp @@ -3,13 +3,13 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#include "3pc/agent/client.hpp" -#include "3pc/broker/impl.hpp" -#include "3pc/directory/impl.hpp" -#include "3pc/runtime_locking_shard/client.hpp" -#include "3pc/ticket_machine/client.hpp" -#include "3pc/util.hpp" #include "crypto/sha256.h" +#include "parsec/agent/client.hpp" +#include "parsec/broker/impl.hpp" +#include "parsec/directory/impl.hpp" +#include "parsec/runtime_locking_shard/client.hpp" +#include "parsec/ticket_machine/client.hpp" +#include "parsec/util.hpp" #include "wallet.hpp" #include @@ -27,7 +27,7 @@ auto main(int argc, char** argv) -> int { log->error("Not enough arguments"); return 1; } - auto cfg = cbdc::threepc::read_config(argc - 2, argv); + auto cfg = cbdc::parsec::read_config(argc - 2, argv); if(!cfg.has_value()) { log->error("Error parsing options"); return 1; @@ -42,10 +42,10 @@ auto main(int argc, char** argv) -> int { log->trace("Connecting to shards"); auto shards = std::vector< - std::shared_ptr>(); + std::shared_ptr>(); for(const auto& shard_ep : cfg->m_shard_endpoints) { auto client = std::make_shared< - cbdc::threepc::runtime_locking_shard::rpc::client>( + cbdc::parsec::runtime_locking_shard::rpc::client>( std::vector{shard_ep}); if(!client->init()) { log->error("Error connecting to shard"); @@ -57,7 +57,7 @@ auto main(int argc, char** argv) -> int { log->trace("Connecting to ticket machine"); auto ticketer - = std::make_shared( + = std::make_shared( std::vector{ cfg->m_ticket_machine_endpoints}); if(!ticketer->init()) { @@ -67,8 +67,8 @@ auto main(int argc, char** argv) -> int { log->trace("Connected to ticket machine"); auto directory - = std::make_shared(shards.size()); - auto broker = std::make_shared( + = std::make_shared(shards.size()); + auto broker = std::make_shared( std::numeric_limits::max(), shards, ticketer, @@ -98,7 +98,7 @@ auto main(int argc, char** argv) -> int { pay_keys.push_back(pay_contract_key); log->info("Inserting pay contract", i); - auto ret = cbdc::threepc::put_row( + auto ret = cbdc::parsec::put_row( broker, pay_contract_key, pay_contract, @@ -130,9 +130,9 @@ auto main(int argc, char** argv) -> int { } auto agents - = std::vector>(); + = std::vector>(); for(auto& a : cfg->m_agent_endpoints) { - auto agent = std::make_shared( + auto agent = std::make_shared( std::vector{a}); if(!agent->init()) { log->error("Error connecting to agent"); @@ -141,7 +141,7 @@ auto main(int argc, char** argv) -> int { agents.emplace_back(agent); } - auto wallets = std::vector(); + auto wallets = std::vector(); for(size_t i = 0; i < n_wallets; i++) { auto agent_idx = i % agents.size(); wallets.emplace_back(log, broker, agents[agent_idx], pay_keys[i]); diff --git a/tools/bench/3pc/lua/wallet.cpp b/tools/bench/parsec/lua/wallet.cpp similarity index 98% rename from tools/bench/3pc/lua/wallet.cpp rename to tools/bench/parsec/lua/wallet.cpp index d650af3e8..55c8349fd 100644 --- a/tools/bench/3pc/lua/wallet.cpp +++ b/tools/bench/parsec/lua/wallet.cpp @@ -5,7 +5,7 @@ #include "wallet.hpp" -#include "3pc/util.hpp" +#include "parsec/util.hpp" #include "util/common/config.hpp" #include "util/common/random_source.hpp" #include "util/serialization/format.hpp" @@ -13,7 +13,7 @@ #include #include -namespace cbdc::threepc { +namespace cbdc::parsec { account_wallet::account_wallet(std::shared_ptr log, std::shared_ptr broker, std::shared_ptr agent, diff --git a/tools/bench/3pc/lua/wallet.hpp b/tools/bench/parsec/lua/wallet.hpp similarity index 94% rename from tools/bench/3pc/lua/wallet.hpp rename to tools/bench/parsec/lua/wallet.hpp index dace82e7e..f02b612b6 100644 --- a/tools/bench/3pc/lua/wallet.hpp +++ b/tools/bench/parsec/lua/wallet.hpp @@ -3,17 +3,17 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#ifndef OPENCBDC_TX_SRC_3PC_TRANSACTIONS_ACCOUNT_WALLET_H_ -#define OPENCBDC_TX_SRC_3PC_TRANSACTIONS_ACCOUNT_WALLET_H_ +#ifndef OPENCBDC_TX_SRC_PARSEC_TRANSACTIONS_ACCOUNT_WALLET_H_ +#define OPENCBDC_TX_SRC_PARSEC_TRANSACTIONS_ACCOUNT_WALLET_H_ -#include "3pc/agent/client.hpp" -#include "3pc/broker/interface.hpp" +#include "parsec/agent/client.hpp" +#include "parsec/broker/interface.hpp" #include "util/common/keys.hpp" #include "util/common/logging.hpp" #include -namespace cbdc::threepc { +namespace cbdc::parsec { /// Manages an account-based wallet. class account_wallet { public: