From 32a2c7d7809ed0952d3243dd96de672935502737 Mon Sep 17 00:00:00 2001 From: eyesofish <2694601913@qq.com> Date: Mon, 27 Oct 2025 16:01:56 -0700 Subject: [PATCH 01/16] changeto wsl --- .asf.yaml | 84 +- .bazelignore | 2 +- .bazelrc | 8 +- .bazelversion | 2 +- .clang-format | 336 +- .github/workflows/build-push.yml | 128 +- .github/workflows/build.yml | 106 +- .github/workflows/license.yml | 74 +- .github/workflows/loc.yml | 124 +- .github/workflows/main.yml | 94 +- .github/workflows/ut.yml | 104 +- .gitignore | 44 +- .licenserc.yaml | 42 +- BUILD.bazel | 70 +- CHANGELOG.md | 336 +- CODE_OF_CONDUCT.md | 190 +- DISCLAIMER | 44 +- Docker/Dockerfile | 112 +- Docker/Dockerfile_mac | 106 +- INSTALL.sh | 128 +- INSTALL/README.md | 124 +- INSTALL/bazel/install_bazel.sh | 54 +- INSTALL/protobuf/install_protobuf.sh | 40 +- LICENSE | 470 +- NOTICE | 12 +- README.md | 952 +- WORKSPACE | 516 +- api/BUILD | 76 +- api/README.md | 132 +- api/kv_operation.py | 92 +- api/pybind_kv_service.cpp | 132 +- benchmark/protocols/pbft/BUILD | 86 +- .../protocols/pbft/kv_server_performance.cpp | 162 +- benchmark/protocols/pbft/kv_service_tools.cpp | 102 +- benchmark/protocols/poe/BUILD | 66 +- .../protocols/poe/kv_server_performance.cpp | 166 +- chain/state/BUILD | 76 +- chain/state/chain_state.cpp | 88 +- chain/state/chain_state.h | 84 +- chain/state/chain_state_test.cpp | 130 +- chain/storage/BUILD | 164 +- chain/storage/kv_storage_test.cpp | 474 +- chain/storage/leveldb.cpp | 668 +- chain/storage/leveldb.h | 178 +- chain/storage/leveldb_test.cpp | 232 +- chain/storage/memory_db.cpp | 340 +- chain/storage/memory_db.h | 176 +- chain/storage/mock_storage.h | 112 +- chain/storage/proto/BUILD | 88 +- chain/storage/proto/kv.proto | 64 +- chain/storage/proto/leveldb_config.proto | 60 +- chain/storage/setting/BUILD | 70 +- chain/storage/storage.h | 120 +- common/BUILD | 170 +- common/crypto/BUILD | 208 +- common/crypto/hash.cpp | 96 +- common/crypto/hash.h | 62 +- common/crypto/hash_test.cpp | 100 +- common/crypto/key_generator.cpp | 312 +- common/crypto/key_generator.h | 62 +- common/crypto/mock_signature_verifier.h | 70 +- common/crypto/signature_utils.cpp | 294 +- common/crypto/signature_utils.h | 80 +- common/crypto/signature_verifier.cpp | 558 +- common/crypto/signature_verifier.h | 166 +- .../crypto/signature_verifier_interface.cpp | 58 +- common/crypto/signature_verifier_interface.h | 74 +- common/crypto/signature_verifier_test.cpp | 320 +- common/lru/BUILD | 70 +- common/lru/lru_cache.cpp | 242 +- common/lru/lru_cache.h | 102 +- common/lru/lru_cache_test.cpp | 188 +- common/proto/BUILD | 76 +- common/proto/signature_info.proto | 160 +- common/test/BUILD | 124 +- common/test/json_test.cpp | 110 +- common/test/test.proto | 68 +- common/test/test_macros.h | 94 +- common/utils/BUILD | 50 +- common/utils/utils.cpp | 72 +- common/utils/utils.h | 56 +- dev/.rat-excludes | 52 +- dev/check-license | 172 +- documents/doxygen/.gitignore | 4 +- documents/doxygen/Doxyfile | 5598 +- documents/doxygen/DoxygenLayout.xml | 512 +- documents/doxygen/doxygen_html_style.css | 40 +- documents/doxygen/header | 160 +- documents/file/Nexres-1654906717062.json | 5784 +- documents/file/prometheus.yml | 132 +- ecosystem/README.md | 150 +- .../cache/resilient-node-cache/.gitignore | 4 +- .../cache/resilient-node-cache/README.md | 408 +- .../resilient-node-cache/dev/.rat-excludes | 36 +- .../resilient-node-cache/dev/check-license | 170 +- .../resilient-node-cache/package-lock.json | 8234 +- .../cache/resilient-node-cache/package.json | 78 +- .../cache/resilient-node-cache/src/index.ts | 792 +- .../cache/resilient-node-cache/tsconfig.json | 26 +- .../cache/resilient-python-cache/.gitignore | 314 +- .../cache/resilient-python-cache/README.md | 288 +- .../resilient-python-cache/dev/.rat-excludes | 36 +- .../resilient-python-cache/dev/check-license | 170 +- .../resilient-python-cache/pyproject.toml | 96 +- .../resilient_python_cache/__init__.py | 60 +- .../resilient_python_cache/cache.py | 612 +- .../resilient_python_cache/config.py | 76 +- .../resilient_python_cache/exceptions.py | 44 +- ecosystem/deployment/orbit/.gitignore | 46 +- ecosystem/deployment/orbit/.npmrc | 2 +- ecosystem/deployment/orbit/.prettierignore | 8 +- ecosystem/deployment/orbit/.prettierrc | 34 +- .../deployment/orbit/.vscode/extensions.json | 18 +- ecosystem/deployment/orbit/CHANGES.md | 52 +- ecosystem/deployment/orbit/README.md | 72 +- ecosystem/deployment/orbit/components.json | 34 +- ecosystem/deployment/orbit/dev/.rat-excludes | 44 +- ecosystem/deployment/orbit/dev/check-license | 170 +- ecosystem/deployment/orbit/package.json | 84 +- ecosystem/deployment/orbit/postcss.config.js | 50 +- .../deployment/orbit/src-tauri/.gitignore | 46 +- .../deployment/orbit/src-tauri/Cargo.lock | 8970 +- .../deployment/orbit/src-tauri/Cargo.toml | 80 +- ecosystem/deployment/orbit/src-tauri/build.rs | 44 +- .../orbit/src-tauri/capabilities/default.json | 22 +- .../orbit/src-tauri/src/commands.rs | 44 +- .../deployment/orbit/src-tauri/src/lib.rs | 60 +- .../deployment/orbit/src-tauri/src/main.rs | 482 +- .../orbit/src-tauri/tauri.conf.json | 74 +- ecosystem/deployment/orbit/src/app.css | 186 +- ecosystem/deployment/orbit/src/app.d.ts | 64 +- ecosystem/deployment/orbit/src/app.html | 66 +- .../orbit/src/lib/commands.svelte.ts | 112 +- .../src/lib/components/ui/badge/badge.svelte | 138 +- .../src/lib/components/ui/badge/index.ts | 42 +- .../lib/components/ui/button/button.svelte | 186 +- .../src/lib/components/ui/button/index.ts | 72 +- .../components/ui/card/card-content.svelte | 70 +- .../ui/card/card-description.svelte | 70 +- .../lib/components/ui/card/card-footer.svelte | 70 +- .../lib/components/ui/card/card-header.svelte | 70 +- .../lib/components/ui/card/card-title.svelte | 88 +- .../src/lib/components/ui/card/card.svelte | 78 +- .../orbit/src/lib/components/ui/card/index.ts | 82 +- .../src/lib/components/ui/input/index.ts | 52 +- .../src/lib/components/ui/input/input.svelte | 82 +- .../src/lib/components/ui/table/index.ts | 94 +- .../lib/components/ui/table/table-body.svelte | 64 +- .../components/ui/table/table-caption.svelte | 64 +- .../lib/components/ui/table/table-cell.svelte | 74 +- .../components/ui/table/table-footer.svelte | 64 +- .../lib/components/ui/table/table-head.svelte | 76 +- .../components/ui/table/table-header.svelte | 66 +- .../lib/components/ui/table/table-row.svelte | 82 +- .../src/lib/components/ui/table/table.svelte | 68 +- ecosystem/deployment/orbit/src/lib/index.ts | 40 +- ecosystem/deployment/orbit/src/lib/utils.ts | 50 +- .../orbit/src/routes/+layout.svelte | 50 +- .../deployment/orbit/src/routes/+layout.ts | 40 +- .../deployment/orbit/src/routes/+page.svelte | 660 +- ecosystem/deployment/orbit/svelte.config.js | 74 +- ecosystem/deployment/orbit/tailwind.config.ts | 230 +- ecosystem/deployment/orbit/tsconfig.json | 38 +- ecosystem/deployment/orbit/vite.config.ts | 98 +- ecosystem/graphql/.bazelrc | 8 +- ecosystem/graphql/.gitignore | 264 +- ecosystem/graphql/Dockerfile | 132 +- ecosystem/graphql/INSTALL.sh | 60 +- ecosystem/graphql/README.md | 610 +- ecosystem/graphql/WORKSPACE | 486 +- ecosystem/graphql/app.py | 252 +- ecosystem/graphql/docs/doxygen/.gitignore | 44 +- ecosystem/graphql/docs/doxygen/Doxyfile | 5598 +- .../graphql/docs/doxygen/DoxygenLayout.xml | 528 +- .../docs/doxygen/doxygen_html_style.css | 54 +- ecosystem/graphql/docs/doxygen/header | 158 +- ecosystem/graphql/docs/nft_market.md | 276 +- ecosystem/graphql/docs/research.md | 100 +- ecosystem/graphql/entrypoint.sh | 46 +- ecosystem/graphql/requirements.txt | 140 +- ecosystem/graphql/resdb_driver/__init__.py | 42 +- ecosystem/graphql/resdb_driver/connection.py | 302 +- ecosystem/graphql/resdb_driver/crypto.py | 102 +- ecosystem/graphql/resdb_driver/driver.py | 1086 +- .../graphql/resdb_driver/driver_experiment.py | 584 +- ecosystem/graphql/resdb_driver/exceptions.py | 398 +- ecosystem/graphql/resdb_driver/offchain.py | 706 +- ecosystem/graphql/resdb_driver/pool.py | 156 +- ecosystem/graphql/resdb_driver/transaction.py | 2550 +- ecosystem/graphql/resdb_driver/transport.py | 214 +- ecosystem/graphql/resdb_driver/utils.py | 278 +- ecosystem/graphql/resdb_driver/validate.py | 180 +- ecosystem/graphql/service/http_server/BUILD | 110 +- .../graphql/service/http_server/README.md | 112 +- .../service/http_server/crow_service.cpp | 1098 +- .../service/http_server/crow_service.h | 118 +- .../service/http_server/crow_service_main.cpp | 78 +- .../service/http_server/crow_service_test.cpp | 192 +- .../graphql/service/http_server/example/BUILD | 70 +- .../http_server/example/crow_example.cpp | 88 +- .../http_server/example/pistache_example.cpp | 80 +- .../service/http_server/sdk_transaction.cpp | 78 +- .../service/http_server/sdk_transaction.h | 64 +- .../service/http_server/server_config.config | 8 +- ecosystem/graphql/service/kv_service/BUILD | 150 +- .../graphql/service/kv_service/README.md | 40 +- .../graphql/service/kv_service/kv_server.cpp | 166 +- .../service/kv_service/kv_service_tools.cpp | 180 +- .../kv_service_transaction_manager.cpp | 192 +- .../kv_service_transaction_manager.h | 104 +- .../graphql/service/kv_service/proto/BUILD | 68 +- .../service/kv_service/proto/kv_server.proto | 88 +- .../service/kv_service/py_verificator.cpp | 196 +- .../service/kv_service/py_verificator.h | 68 +- .../service/kv_service/resdb_kv_client.cpp | 160 +- .../service/kv_service/resdb_kv_client.h | 76 +- ecosystem/graphql/service/pybind_sample/BUILD | 60 +- .../graphql/service/pybind_sample/README.md | 80 +- .../graphql/service/pybind_sample/client.cpp | 170 +- .../service/pybind_sample/endpoint_test.py | 58 +- .../service/pybind_sample/print_sample.py | 42 +- .../pybind_sample/validator_example.py | 116 +- .../graphql/service/sdk_validator/README.md | 120 +- .../service/sdk_validator/docs/nft_market.md | 276 +- .../service/sdk_validator/docs/research.md | 100 +- .../service/sdk_validator/requirements.txt | 48 +- .../sdk_validator/resdb_validator/__init__.py | 50 +- .../sdk_validator/resdb_validator/crypto.py | 134 +- .../resdb_validator/exceptions.py | 260 +- .../sdk_validator/resdb_validator/lib.py | 992 +- .../sdk_validator/resdb_validator/memoize.py | 152 +- .../sdk_validator/resdb_validator/models.py | 174 +- .../resdb_validator/transaction.py | 2688 +- .../sdk_validator/resdb_validator/utils.py | 358 +- .../service/sdk_validator/validator.py | 108 +- .../tools/config/interface/client.config | 2 +- .../tools/config/interface/service.config | 6 +- .../tools/config/interface/service0.config | 6 +- .../service/tools/config/server/server.config | 80 +- .../tools/config/server/utxo_config.config | 24 +- .../service/tools/start_kv_service_sdk.sh | 68 +- ecosystem/graphql/test_driver.py | 196 +- ecosystem/graphql/test_driver_2.py | 198 +- ecosystem/graphql/test_sdk.py | 198 +- ecosystem/graphql/test_update_metadata.py | 292 +- ecosystem/graphql/third_party/BUILD | 74 +- ecosystem/graphql/third_party/asio.BUILD | 78 +- ecosystem/graphql/third_party/crow.BUILD | 78 +- ecosystem/graphql/third_party/rapidjson.BUILD | 56 +- ecosystem/graphql/wsgi.py | 46 +- .../monitoring/reslens-middleware/.gitignore | 8 +- .../monitoring/reslens-middleware/README.md | 216 +- .../reslens-middleware/docker-compose.yml | 134 +- .../middleware/.dockerignore | 46 +- .../middleware/.env.example | 52 +- .../reslens-middleware/middleware/.prettierrc | 46 +- .../reslens-middleware/middleware/Dockerfile | 84 +- .../reslens-middleware/middleware/app.js | 88 +- .../middleware/controllers/explorer.js | 482 +- .../middleware/controllers/nodeExporter.js | 534 +- .../middleware/controllers/processExporter.js | 134 +- .../middleware/controllers/pyroscope.js | 296 +- .../middleware/controllers/statsExporter.js | 196 +- .../middleware/controllers/transactions.js | 322 +- .../middleware/cron/Dockerfile | 70 +- .../middleware/cron/syncTransactionHistory.js | 734 +- .../middleware/package-lock.json | 5898 +- .../middleware/package.json | 82 +- .../middleware/routes/explorer.js | 64 +- .../middleware/routes/healthcheck.js | 72 +- .../middleware/routes/nodeExporter.js | 72 +- .../middleware/routes/pyroscope.js | 66 +- .../middleware/routes/statsExporter.js | 62 +- .../middleware/routes/transactions.js | 66 +- .../reslens-middleware/middleware/server.js | 60 +- .../middleware/tmp/dummy_analysis.md | 116 +- .../middleware/utils/encoding.js | 236 +- .../middleware/utils/envParser.js | 106 +- .../middleware/utils/logger.js | 66 +- .../middleware/utils/pprofConverter.js | 324 +- .../middleware/utils/profileAnalyzer.js | 146 +- .../middleware/utils/time.js | 176 +- .../middleware/utils/urlHelper.js | 70 +- .../process-exporter/Dockerfile | 54 +- .../process-exporter/config.yml | 46 +- .../reslens-middleware/pyroscope/Dockerfile | 86 +- .../pyroscope/connect_pyroscope.js | 88 +- .../reslens-middleware/pyroscope/package.json | 16 +- ecosystem/monitoring/reslens/.eslintrc.json | 6 +- ecosystem/monitoring/reslens/.gitignore | 84 +- ecosystem/monitoring/reslens/.licenserc.yaml | 52 +- .../monitoring/reslens/.vscode/launch.json | 28 +- .../monitoring/reslens/.vscode/settings.json | 2 +- ecosystem/monitoring/reslens/INSTALLATION.md | 158 +- ecosystem/monitoring/reslens/README.md | 282 +- ecosystem/monitoring/reslens/components.json | 42 +- ecosystem/monitoring/reslens/eslint.config.js | 96 +- ecosystem/monitoring/reslens/graphviz.html | 250 +- ecosystem/monitoring/reslens/index.html | 72 +- .../monitoring/reslens/package-lock.json | 37234 +++---- ecosystem/monitoring/reslens/package.json | 182 +- .../monitoring/reslens/postcss.config.js | 52 +- .../reslens/public/Reslens logo.svg | 40 +- ecosystem/monitoring/reslens/public/vite.svg | 40 +- ecosystem/monitoring/reslens/src/App.css | 130 +- ecosystem/monitoring/reslens/src/App.tsx | 90 +- .../monitoring/reslens/src/assets/react.svg | 40 +- .../src/components/Authors/3d-card.tsx | 358 +- .../src/components/Authors/AuthorPage.tsx | 172 +- .../src/components/Authors/Authorcard.tsx | 182 +- .../reslens/src/components/craft.tsx | 752 +- .../src/components/dashboard/dashboard.tsx | 422 +- .../graphs/MemorySpecs/memoryMetricsGrid.tsx | 750 +- .../graphs/MemorySpecs/memoryTrackerPage.tsx | 120 +- .../MemorySpecs/storageEngineMetrics.tsx | 1084 +- .../graphs/MemorySpecs/terminal.tsx | 310 +- .../components/graphs/TransactionChart.tsx | 432 +- .../reslens/src/components/graphs/cpuCard.tsx | 82 +- .../src/components/graphs/dependency.tsx | 342 +- .../src/components/graphs/explorer.tsx | 734 +- .../src/components/graphs/flamegraph.tsx | 680 +- .../src/components/graphs/lineGraph.tsx | 768 +- .../reslens/src/components/graphs/resView.tsx | 126 +- .../reslens/src/components/graphs/table.tsx | 916 +- .../src/components/home-page/PBFTFullView.tsx | 272 +- .../src/components/home-page/description.tsx | 178 +- .../reslens/src/components/home-page/hero.tsx | 108 +- .../src/components/home-page/homePage.tsx | 96 +- .../reslens/src/components/theme-provider.tsx | 186 +- .../reslens/src/components/toggle.tsx | 198 +- .../src/components/ui/LineGraphChart.tsx | 780 +- .../ui/PBFT graph/FullScreenButton.tsx | 94 +- .../ui/PBFT graph/PBFTVisualization.css | 278 +- .../ui/PBFT graph/PBFTVisualization.tsx | 574 +- .../src/components/ui/ScrollEffectHP.tsx | 396 +- .../reslens/src/components/ui/alert.tsx | 158 +- .../reslens/src/components/ui/badge.tsx | 112 +- .../reslens/src/components/ui/banner.tsx | 100 +- .../reslens/src/components/ui/button.tsx | 154 +- .../reslens/src/components/ui/card.tsx | 206 +- .../src/components/ui/copyToClipboard.tsx | 138 +- .../src/components/ui/dropdown-menu.tsx | 442 +- .../reslens/src/components/ui/footer.tsx | 240 +- .../reslens/src/components/ui/input.tsx | 84 +- .../reslens/src/components/ui/loader.tsx | 104 +- .../reslens/src/components/ui/navbar.tsx | 258 +- .../reslens/src/components/ui/not-found.tsx | 116 +- .../reslens/src/components/ui/progress.tsx | 96 +- .../reslens/src/components/ui/select.tsx | 358 +- .../reslens/src/components/ui/skeleton.tsx | 70 +- .../reslens/src/components/ui/starcardcta.tsx | 400 +- .../reslens/src/components/ui/table.tsx | 280 +- .../reslens/src/components/ui/tabs.tsx | 150 +- .../reslens/src/components/ui/toast.tsx | 298 +- .../reslens/src/components/ui/toaster.tsx | 110 +- .../reslens/src/components/ui/tooltip.tsx | 104 +- .../reslens/src/components/ui/tour.tsx | 204 +- .../monitoring/reslens/src/hooks/context.ts | 46 +- .../reslens/src/hooks/use-mobile.tsx | 78 +- .../monitoring/reslens/src/hooks/use-toast.ts | 422 +- .../monitoring/reslens/src/hooks/use-tour.tsx | 170 +- ecosystem/monitoring/reslens/src/index.css | 342 +- ecosystem/monitoring/reslens/src/lib/api.ts | 60 +- ecosystem/monitoring/reslens/src/lib/utils.ts | 106 +- ecosystem/monitoring/reslens/src/main.tsx | 60 +- .../reslens/src/static/MemoryStats.ts | 6456 +- .../reslens/src/static/dependencyGraphData.ts | 932 +- .../monitoring/reslens/src/static/encoding.ts | 242 +- .../reslens/src/static/processCpuChartData.ts | 6226 +- .../reslens/src/static/testFlamegraph.ts | 18570 ++-- .../reslens/src/static/transactionHistory.ts | 2394 +- .../monitoring/reslens/src/static/url.ts | 40 +- .../monitoring/reslens/src/vite-env.d.ts | 42 +- .../monitoring/reslens/tailwind.config.ts | 192 +- .../monitoring/reslens/tsconfig.app.json | 62 +- ecosystem/monitoring/reslens/tsconfig.json | 34 +- .../monitoring/reslens/tsconfig.node.json | 46 +- ecosystem/monitoring/reslens/vercel.json | 16 +- ecosystem/monitoring/reslens/vite.config.ts | 64 +- ecosystem/sdk/resdb-orm/.bazelrc | 4 +- ecosystem/sdk/resdb-orm/.gitignore | 324 +- ecosystem/sdk/resdb-orm/INSTALL.sh | 434 +- ecosystem/sdk/resdb-orm/MANIFEST.in | 42 +- ecosystem/sdk/resdb-orm/README.md | 248 +- ecosystem/sdk/resdb-orm/config.yaml | 34 +- ecosystem/sdk/resdb-orm/dev/.rat-excludes | 36 +- ecosystem/sdk/resdb-orm/dev/check-license | 170 +- ecosystem/sdk/resdb-orm/requirements.txt | 36 +- ecosystem/sdk/resdb-orm/resdb_orm/__init__.py | 32 +- ecosystem/sdk/resdb-orm/resdb_orm/orm.py | 188 +- ecosystem/sdk/resdb-orm/setup.py | 82 +- ecosystem/sdk/resdb-orm/tests/test.py | 84 +- ecosystem/sdk/resvault-sdk/.gitignore | 260 +- ecosystem/sdk/resvault-sdk/README.md | 256 +- ecosystem/sdk/resvault-sdk/dev/.rat-excludes | 36 +- ecosystem/sdk/resvault-sdk/dev/check-license | 170 +- ecosystem/sdk/resvault-sdk/package-lock.json | 26 +- ecosystem/sdk/resvault-sdk/package.json | 28 +- .../sdk/resvault-sdk/src/resvault-sdk.ts | 298 +- ecosystem/sdk/resvault-sdk/tsconfig.json | 94 +- ecosystem/sdk/rust-sdk/.asf.yaml | 84 +- .../rust-sdk/.github/workflows/license.yml | 72 +- .../sdk/rust-sdk/.github/workflows/rust.yml | 82 +- ecosystem/sdk/rust-sdk/.gitignore | 40 +- ecosystem/sdk/rust-sdk/.licenserc.yaml | 52 +- ecosystem/sdk/rust-sdk/.vscode/settings.json | 8 +- ecosystem/sdk/rust-sdk/Cargo.toml | 90 +- ecosystem/sdk/rust-sdk/README.md | 174 +- ecosystem/sdk/rust-sdk/dev/.rat-excludes | 36 +- ecosystem/sdk/rust-sdk/dev/check-license | 170 +- ecosystem/sdk/rust-sdk/src/blocks.rs | 284 +- ecosystem/sdk/rust-sdk/src/crypto.rs | 110 +- ecosystem/sdk/rust-sdk/src/lib.rs | 66 +- ecosystem/sdk/rust-sdk/src/resdb.rs | 846 +- ecosystem/sdk/rust-sdk/src/transaction.rs | 298 +- ecosystem/sdk/rust-sdk/test/Cargo.toml | 54 +- ecosystem/sdk/rust-sdk/test/src/main.rs | 572 +- ecosystem/sdk/rust-sdk/test/src/models.rs | 326 +- .../smart-contract/rescontract/.gitignore | 4 +- .../smart-contract/rescontract/README.md | 418 +- .../smart-contract/rescontract/config.js | 118 +- .../smart-contract/rescontract/config.yaml | 32 +- .../rescontract/dev/.rat-excludes | 36 +- .../rescontract/dev/check-license | 170 +- ecosystem/smart-contract/rescontract/index.js | 842 +- .../smart-contract/rescontract/logger.js | 92 +- .../rescontract/package-lock.json | 1672 +- .../smart-contract/rescontract/package.json | 54 +- .../rescontract/scripts/postinstall.js | 134 +- .../smart-contract/rescontract/token.sol | 96 +- .../resilient-contract-kit/.gitignore | 280 +- .../resilient-contract-kit/README.md | 40 +- .../resilient-contract-kit/dev/.rat-excludes | 36 +- .../resilient-contract-kit/dev/check-license | 170 +- .../resilient-contract-kit/jest.config.js | 64 +- .../resilient-contract-kit/package.json | 54 +- .../src/graphql-client.ts | 56 +- .../resilient-contract-kit/src/index.ts | 118 +- .../resilient-contract-kit/src/utils.ts | 58 +- .../tests/executeSmartContract.test.ts | 86 +- .../tests/integration.test.ts | 70 +- .../resilient-contract-kit/tsconfig.json | 28 +- .../smart-contract-graphql/.gitignore | 12 +- .../smart-contract-graphql/INSTALL.sh | 140 +- .../smart-contract-graphql/README.md | 736 +- .../smart-contract-graphql/cli-functions.js | 484 +- .../smart-contract-graphql/config.yaml | 32 +- .../smart-contract-graphql/dev/.rat-excludes | 36 +- .../smart-contract-graphql/dev/check-license | 170 +- .../smart-contract-graphql/logger.js | 94 +- .../smart-contract-graphql/package-lock.json | 7396 +- .../smart-contract-graphql/package.json | 70 +- .../smart-contract-graphql/schema.js | 314 +- .../smart-contract-graphql/server.js | 90 +- .../test/server.test.js | 92 +- .../smart-contract-graphql/token.sol | 96 +- .../tools/create-resilient-app/.gitignore | 44 +- .../tools/create-resilient-app/README.md | 260 +- .../create-resilient-app/dev/.rat-excludes | 36 +- .../create-resilient-app/dev/check-license | 170 +- .../create-resilient-app/package-lock.json | 2244 +- .../tools/create-resilient-app/package.json | 78 +- .../create-resilient-app/src/add-shebang.ts | 90 +- .../tools/create-resilient-app/src/index.ts | 278 +- .../templates/react-js-resvault-sdk/README.md | 178 +- .../react-js-resvault-sdk/package.json | 90 +- .../react-js-resvault-sdk/public/index.html | 124 +- .../public/manifest.json | 50 +- .../react-js-resvault-sdk/public/robots.txt | 46 +- .../react-js-resvault-sdk/src/App.css | 382 +- .../react-js-resvault-sdk/src/App.js | 136 +- .../src/assets/images/bg.svg | 32 +- .../src/assets/images/resilientdb.svg | 60 +- .../src/components/Loader.js | 62 +- .../src/components/Login.js | 318 +- .../src/components/NotificationModal.js | 80 +- .../src/components/TransactionForm.js | 364 +- .../react-js-resvault-sdk/src/index.css | 64 +- .../react-js-resvault-sdk/src/index.js | 60 +- .../react-js-resvault-sdk/src/logo.svg | 32 +- .../react-js-resvault-sdk/src/setupTests.js | 48 +- .../templates/react-ts-resvault-sdk/README.md | 132 +- .../react-ts-resvault-sdk/package.json | 112 +- .../react-ts-resvault-sdk/public/index.html | 124 +- .../public/manifest.json | 50 +- .../react-ts-resvault-sdk/public/robots.txt | 46 +- .../react-ts-resvault-sdk/src/App.css | 382 +- .../react-ts-resvault-sdk/src/App.tsx | 136 +- .../src/assets/images/bg.svg | 32 +- .../src/assets/images/resilientdb.svg | 60 +- .../src/components/Loader.tsx | 62 +- .../src/components/Login.tsx | 306 +- .../src/components/NotificationModal.tsx | 94 +- .../src/components/TransactionForm.tsx | 346 +- .../react-ts-resvault-sdk/src/index.css | 64 +- .../react-ts-resvault-sdk/src/index.tsx | 70 +- .../src/react-app-env.d.ts | 40 +- .../react-ts-resvault-sdk/tsconfig.json | 52 +- .../.vscode/extensions.json | 6 +- .../templates/vue-js-resvault-sdk/README.md | 50 +- .../templates/vue-js-resvault-sdk/index.html | 64 +- .../vue-js-resvault-sdk/package.json | 52 +- .../vue-js-resvault-sdk/public/vite.svg | 32 +- .../templates/vue-js-resvault-sdk/src/App.css | 382 +- .../templates/vue-js-resvault-sdk/src/App.vue | 60 +- .../src/assets/images/bg.svg | 32 +- .../src/assets/images/resilientdb.svg | 60 +- .../src/components/Home.vue | 94 +- .../src/components/Loader.vue | 64 +- .../src/components/Login.vue | 348 +- .../src/components/NotificationModal.vue | 212 +- .../src/components/TransactionForm.vue | 390 +- .../templates/vue-js-resvault-sdk/src/main.js | 80 +- .../vue-js-resvault-sdk/src/router/index.js | 78 +- .../vue-js-resvault-sdk/src/store/index.js | 134 +- .../vue-js-resvault-sdk/src/style.css | 196 +- .../vue-js-resvault-sdk/vite.config.js | 52 +- .../.vscode/extensions.json | 6 +- .../templates/vue-ts-resvault-sdk/README.md | 50 +- .../templates/vue-ts-resvault-sdk/index.html | 64 +- .../vue-ts-resvault-sdk/package.json | 56 +- .../vue-ts-resvault-sdk/public/vite.svg | 32 +- .../templates/vue-ts-resvault-sdk/src/App.css | 382 +- .../templates/vue-ts-resvault-sdk/src/App.vue | 62 +- .../src/assets/images/bg.svg | 32 +- .../src/assets/images/resilientdb.svg | 60 +- .../src/components/Home.vue | 96 +- .../src/components/Loader.vue | 66 +- .../src/components/Login.vue | 356 +- .../src/components/NotificationModal.vue | 210 +- .../src/components/TransactionForm.vue | 392 +- .../templates/vue-ts-resvault-sdk/src/main.ts | 68 +- .../vue-ts-resvault-sdk/src/router/index.ts | 78 +- .../vue-ts-resvault-sdk/src/store/index.ts | 134 +- .../vue-ts-resvault-sdk/src/vite-env.d.ts | 40 +- .../vue-ts-resvault-sdk/tsconfig.app.json | 48 +- .../vue-ts-resvault-sdk/tsconfig.json | 14 +- .../vue-ts-resvault-sdk/tsconfig.node.json | 44 +- .../vue-ts-resvault-sdk/vite.config.ts | 52 +- .../tools/create-resilient-app/tsconfig.json | 26 +- ecosystem/tools/resvault/.gitignore | 50 +- ecosystem/tools/resvault/README.md | 194 +- ecosystem/tools/resvault/config-overrides.js | 68 +- ecosystem/tools/resvault/dev/.rat-excludes | 36 +- ecosystem/tools/resvault/dev/check-license | 170 +- ecosystem/tools/resvault/package-lock.json | 92110 ++++++++-------- ecosystem/tools/resvault/package.json | 164 +- ecosystem/tools/resvault/public/background.js | 1682 +- ecosystem/tools/resvault/public/content.js | 950 +- ecosystem/tools/resvault/public/index.html | 126 +- ecosystem/tools/resvault/public/manifest.json | 72 +- ecosystem/tools/resvault/public/robots.txt | 48 +- ecosystem/tools/resvault/src/App.js | 120 +- ecosystem/tools/resvault/src/App.test.js | 58 +- .../resvault/src/context/GlobalContext.js | 852 +- ecosystem/tools/resvault/src/css/App.css | 7556 +- .../tools/resvault/src/data/version.json | 4 +- .../resvault/src/images/icons/arrow-back.svg | 48 +- .../resvault/src/images/icons/arrow-down.svg | 50 +- .../tools/resvault/src/images/icons/card.svg | 66 +- .../src/images/icons/checked-simple.svg | 54 +- .../tools/resvault/src/images/splash.svg | 60 +- ecosystem/tools/resvault/src/index.css | 68 +- ecosystem/tools/resvault/src/index.js | 112 +- ecosystem/tools/resvault/src/logo.svg | 72 +- .../tools/resvault/src/pages/Contract.jsx | 2188 +- .../tools/resvault/src/pages/Dashboard.jsx | 1876 +- ecosystem/tools/resvault/src/pages/Home.jsx | 186 +- ecosystem/tools/resvault/src/pages/Login.jsx | 510 +- ecosystem/tools/resvault/src/pages/SignUp.jsx | 482 +- .../tools/resvault/src/reportWebVitals.js | 66 +- ecosystem/tools/resvault/src/setupTests.js | 52 +- ecosystem/tools/resvault/webpack.config.js | 114 +- entrypoint.sh | 46 +- executor/common/BUILD | 88 +- executor/common/custom_query.h | 72 +- executor/common/mock_transaction_manager.h | 86 +- executor/common/transaction_manager.cpp | 196 +- executor/common/transaction_manager.h | 132 +- executor/contract/executor/BUILD | 92 +- .../contract/executor/contract_executor.cpp | 314 +- .../contract/executor/contract_executor.h | 106 +- .../executor/contract_executor_test.cpp | 1040 +- executor/contract/executor/test_data/BUILD | 38 +- .../contract/executor/test_data/contract.json | 26 +- .../contract/executor/test_data/token.json | 26 +- executor/contract/manager/BUILD | 214 +- executor/contract/manager/address_manager.cpp | 116 +- executor/contract/manager/address_manager.h | 94 +- .../contract/manager/address_manager_test.cpp | 102 +- .../contract/manager/contract_manager.cpp | 312 +- executor/contract/manager/contract_manager.h | 130 +- .../manager/contract_manager_test.cpp | 510 +- executor/contract/manager/evm_state.h | 86 +- executor/contract/manager/global_state.cpp | 178 +- executor/contract/manager/global_state.h | 126 +- executor/contract/manager/global_view.cpp | 86 +- executor/contract/manager/global_view.h | 88 +- executor/contract/manager/test_data/BUILD | 38 +- .../contract/manager/test_data/contract.json | 38 +- executor/contract/manager/utils.h | 60 +- executor/kv/BUILD | 90 +- executor/kv/kv_executor.cpp | 428 +- executor/kv/kv_executor.h | 130 +- executor/kv/kv_executor_test.cpp | 686 +- executor/utxo/executor/BUILD | 92 +- executor/utxo/executor/utxo_executor.cpp | 158 +- executor/utxo/executor/utxo_executor.h | 114 +- executor/utxo/executor/utxo_executor_test.cpp | 160 +- executor/utxo/manager/BUILD | 164 +- executor/utxo/manager/transaction.cpp | 380 +- executor/utxo/manager/transaction.h | 112 +- executor/utxo/manager/transaction_test.cpp | 234 +- executor/utxo/manager/tx_mempool.cpp | 256 +- executor/utxo/manager/tx_mempool.h | 110 +- executor/utxo/manager/tx_mempool_test.cpp | 392 +- executor/utxo/manager/wallet.cpp | 76 +- executor/utxo/manager/wallet.h | 82 +- executor/utxo/manager/wallet_test.cpp | 80 +- interface/common/BUILD | 148 +- interface/common/mock_resdb_txn_accessor.h | 74 +- interface/common/resdb_state_accessor.cpp | 118 +- interface/common/resdb_state_accessor.h | 94 +- .../common/resdb_state_accessor_test.cpp | 212 +- interface/common/resdb_txn_accessor.cpp | 382 +- interface/common/resdb_txn_accessor.h | 108 +- interface/common/resdb_txn_accessor_test.cpp | 324 +- interface/contract/BUILD | 64 +- interface/contract/contract_client.cpp | 242 +- interface/contract/contract_client.h | 94 +- interface/kv/BUILD | 86 +- interface/kv/contract_client.cpp | 338 +- interface/kv/contract_client.h | 108 +- interface/kv/kv_client.cpp | 296 +- interface/kv/kv_client.h | 132 +- interface/rdbc/BUILD | 154 +- interface/rdbc/mock_net_channel.h | 84 +- interface/rdbc/mock_resdb_txn_accessor.h | 74 +- interface/rdbc/net_channel.cpp | 462 +- interface/rdbc/net_channel.h | 218 +- interface/rdbc/net_channel_test.cpp | 428 +- interface/rdbc/transaction_constructor.cpp | 178 +- interface/rdbc/transaction_constructor.h | 102 +- .../rdbc/transaction_constructor_test.cpp | 320 +- interface/utxo/BUILD | 60 +- interface/utxo/utxo_client.cpp | 196 +- interface/utxo/utxo_client.h | 80 +- monitoring/README.md | 108 +- monitoring/prometheus/prometheus.yml | 148 +- package-lock.json | 22 +- platform/common/data_comm/BUILD | 70 +- platform/common/data_comm/data_comm.h | 78 +- platform/common/data_comm/network_comm.h | 64 +- platform/common/network/BUILD | 116 +- platform/common/network/mock_socket.h | 86 +- platform/common/network/network_utils.cpp | 100 +- platform/common/network/network_utils.h | 64 +- .../common/network/network_utils_test.cpp | 86 +- platform/common/network/socket.h | 102 +- platform/common/network/tcp_socket.cpp | 474 +- platform/common/network/tcp_socket.h | 118 +- platform/common/network/tcp_socket_test.cpp | 188 +- platform/common/queue/BUILD | 130 +- platform/common/queue/batch_queue.h | 158 +- platform/common/queue/batch_queue_test.cpp | 196 +- platform/common/queue/blocking_queue.h | 212 +- platform/common/queue/lock_free_queue.h | 156 +- .../common/queue/lock_free_queue_test.cpp | 100 +- platform/config/BUILD | 112 +- platform/config/resdb_config.cpp | 512 +- platform/config/resdb_config.h | 304 +- platform/config/resdb_config_test.cpp | 252 +- platform/config/resdb_config_utils.cpp | 314 +- platform/config/resdb_config_utils.h | 86 +- platform/config/resdb_poc_config.cpp | 148 +- platform/config/resdb_poc_config.h | 142 +- platform/consensus/checkpoint/BUILD | 72 +- platform/consensus/checkpoint/checkpoint.h | 64 +- .../consensus/checkpoint/mock_checkpoint.h | 66 +- platform/consensus/execution/BUILD | 264 +- .../consensus/execution/duplicate_manager.cpp | 286 +- .../consensus/execution/duplicate_manager.h | 138 +- .../execution/geo_global_executor.cpp | 262 +- .../consensus/execution/geo_global_executor.h | 140 +- .../execution/geo_global_executor_test.cpp | 190 +- .../execution/geo_transaction_executor.cpp | 254 +- .../execution/geo_transaction_executor.h | 116 +- .../geo_transaction_executor_test.cpp | 300 +- .../execution/mock_geo_global_executor.h | 74 +- platform/consensus/execution/system_info.cpp | 150 +- platform/consensus/execution/system_info.h | 108 +- .../consensus/execution/system_info_test.cpp | 150 +- .../execution/transaction_executor.cpp | 998 +- .../execution/transaction_executor.h | 296 +- .../execution/transaction_executor_test.cpp | 564 +- platform/consensus/ordering/common/BUILD | 58 +- .../consensus/ordering/common/algorithm/BUILD | 58 +- .../common/algorithm/protocol_base.cpp | 130 +- .../ordering/common/algorithm/protocol_base.h | 174 +- .../consensus/ordering/common/framework/BUILD | 132 +- .../ordering/common/framework/consensus.cpp | 336 +- .../ordering/common/framework/consensus.h | 156 +- .../common/framework/performance_manager.cpp | 552 +- .../common/framework/performance_manager.h | 194 +- .../common/framework/response_manager.cpp | 472 +- .../common/framework/response_manager.h | 158 +- .../common/framework/transaction_utils.cpp | 86 +- .../common/framework/transaction_utils.h | 78 +- .../ordering/common/transaction_utils.cpp | 82 +- .../ordering/common/transaction_utils.h | 66 +- platform/consensus/ordering/geo_pbft/BUILD | 136 +- .../consensus/ordering/geo_pbft/README.md | 46 +- .../geo_pbft/consensus_manager_geo_pbft.cpp | 90 +- .../geo_pbft/consensus_manager_geo_pbft.h | 86 +- .../ordering/geo_pbft/geo_pbft_commitment.cpp | 284 +- .../ordering/geo_pbft/geo_pbft_commitment.h | 136 +- .../geo_pbft/geo_pbft_commitment_test.cpp | 432 +- .../consensus/ordering/geo_pbft/hash_set.h | 138 +- platform/consensus/ordering/pbft/BUILD | 536 +- platform/consensus/ordering/pbft/README.md | 100 +- .../ordering/pbft/checkpoint_manager.cpp | 762 +- .../ordering/pbft/checkpoint_manager.h | 236 +- .../ordering/pbft/checkpoint_manager_test.cpp | 614 +- .../consensus/ordering/pbft/commitment.cpp | 666 +- platform/consensus/ordering/pbft/commitment.h | 158 +- .../ordering/pbft/commitment_test.cpp | 740 +- .../ordering/pbft/consensus_manager_pbft.cpp | 532 +- .../ordering/pbft/consensus_manager_pbft.h | 176 +- .../pbft/lock_free_collector_pool.cpp | 140 +- .../ordering/pbft/lock_free_collector_pool.h | 92 +- .../pbft/lock_free_collector_pool_test.cpp | 128 +- .../ordering/pbft/message_manager.cpp | 586 +- .../consensus/ordering/pbft/message_manager.h | 288 +- .../ordering/pbft/mock_checkpoint_manager.h | 94 +- .../ordering/pbft/performance_manager.cpp | 820 +- .../ordering/pbft/performance_manager.h | 236 +- .../pbft/pre_very_consensus_service_pbft.h | 110 +- platform/consensus/ordering/pbft/query.cpp | 296 +- platform/consensus/ordering/pbft/query.h | 96 +- .../consensus/ordering/pbft/query_test.cpp | 410 +- .../ordering/pbft/response_manager.cpp | 820 +- .../ordering/pbft/response_manager.h | 218 +- .../ordering/pbft/response_manager_test.cpp | 416 +- .../ordering/pbft/transaction_collector.cpp | 476 +- .../ordering/pbft/transaction_collector.h | 282 +- .../pbft/transaction_collector_test.cpp | 794 +- .../ordering/pbft/transaction_utils.cpp | 82 +- .../ordering/pbft/transaction_utils.h | 76 +- .../ordering/pbft/viewchange_manager.cpp | 1236 +- .../ordering/pbft/viewchange_manager.h | 320 +- .../ordering/pbft/viewchange_manager_test.cpp | 248 +- .../consensus/ordering/poe/algorithm/BUILD | 66 +- .../consensus/ordering/poe/algorithm/poe.cpp | 182 +- .../consensus/ordering/poe/algorithm/poe.h | 118 +- .../consensus/ordering/poe/framework/BUILD | 66 +- .../ordering/poe/framework/consensus.cpp | 196 +- .../ordering/poe/framework/consensus.h | 106 +- platform/consensus/ordering/poe/proto/BUILD | 68 +- .../ordering/poe/proto/proposal.proto | 92 +- platform/consensus/recovery/BUILD | 94 +- platform/consensus/recovery/recovery.cpp | 1060 +- platform/consensus/recovery/recovery.h | 212 +- platform/consensus/recovery/recovery_test.cpp | 924 +- platform/networkstrate/BUILD | 392 +- platform/networkstrate/README.md | 72 +- platform/networkstrate/async_acceptor.cpp | 324 +- platform/networkstrate/async_acceptor.h | 152 +- .../networkstrate/async_acceptor_test.cpp | 270 +- .../networkstrate/async_replica_client.cpp | 224 +- platform/networkstrate/async_replica_client.h | 126 +- .../async_replica_client_test.cpp | 340 +- platform/networkstrate/consensus_manager.cpp | 746 +- platform/networkstrate/consensus_manager.h | 228 +- .../networkstrate/consensus_manager_test.cpp | 606 +- .../networkstrate/mock_async_replica_client.h | 70 +- .../networkstrate/mock_replica_communicator.h | 98 +- .../networkstrate/mock_service_interface.h | 74 +- .../networkstrate/replica_communicator.cpp | 670 +- platform/networkstrate/replica_communicator.h | 222 +- .../replica_communicator_test.cpp | 278 +- platform/networkstrate/server_comm.h | 64 +- platform/networkstrate/service_interface.cpp | 76 +- platform/networkstrate/service_interface.h | 94 +- platform/networkstrate/service_network.cpp | 282 +- platform/networkstrate/service_network.h | 136 +- .../networkstrate/service_network_test.cpp | 232 +- platform/proto/BUILD | 302 +- platform/proto/broadcast.proto | 52 +- platform/proto/checkpoint_info.proto | 88 +- platform/proto/client_test.proto | 60 +- platform/proto/logging.proto | 74 +- platform/proto/network_type.proto | 58 +- platform/proto/replica_info.proto | 154 +- platform/proto/resdb.proto | 418 +- platform/proto/system_info_data.proto | 54 +- platform/proto/viewchange_message.proto | 98 +- platform/rdbc/BUILD | 68 +- platform/rdbc/acceptor.cpp | 196 +- platform/rdbc/acceptor.h | 114 +- platform/statistic/BUILD | 114 +- platform/statistic/README.md | 376 +- platform/statistic/prometheus_handler.cpp | 216 +- platform/statistic/prometheus_handler.h | 158 +- platform/statistic/set_random_data.cpp | 178 +- platform/statistic/stats.cpp | 1210 +- platform/statistic/stats.h | 334 +- platform/test/BUILD | 76 +- platform/test/proto/BUILD | 66 +- platform/test/proto/resdb_test.proto | 58 +- platform/test/resdb_test.cpp | 336 +- platform/test/test_data/BUILD | 50 +- platform/test/test_data/kv_config.config | 54 +- platform/test/test_data/server.config | 54 +- proto/contract/BUILD | 136 +- proto/contract/account.proto | 56 +- proto/contract/contract.proto | 60 +- proto/contract/func_params.proto | 80 +- proto/contract/rpc.proto | 118 +- proto/kv/BUILD | 64 +- proto/kv/kv.proto | 148 +- proto/utxo/BUILD | 110 +- proto/utxo/config.proto | 68 +- proto/utxo/rpc.proto | 88 +- proto/utxo/utxo.proto | 84 +- repositories.bzl | 216 +- script.js | 246 +- scripts/deploy/README.md | 158 +- scripts/deploy/config/key_example.conf | 4 +- .../deploy/config/kv_performance_server.conf | 18 +- .../config/kv_performance_server_local.conf | 18 +- scripts/deploy/config/kv_server.conf | 16 +- scripts/deploy/config/pbft.config | 20 +- scripts/deploy/config/poe.config | 20 +- scripts/deploy/config/template.config | 12 +- .../deploy/performance/calculate_result.py | 142 +- .../deploy/performance/pbft_performance.sh | 48 +- scripts/deploy/performance/poe_performance.sh | 46 +- scripts/deploy/performance/run_performance.sh | 118 +- .../performance_local/calculate_result.py | 142 +- .../performance_local/pbft_performance.sh | 48 +- .../performance_local/poe_performance.sh | 46 +- .../performance_local/run_performance.sh | 120 +- scripts/deploy/script/deploy.sh | 364 +- scripts/deploy/script/deploy_local.sh | 338 +- scripts/deploy/script/env.sh | 92 +- scripts/deploy/script/generate_admin_key.sh | 60 +- scripts/deploy/script/generate_config.sh | 164 +- scripts/deploy/script/generate_key.sh | 66 +- scripts/deploy/script/load_config.sh | 52 +- scripts/format.sh | 44 +- service/contract/BUILD | 62 +- service/contract/contract_service.cpp | 144 +- service/kv/BUILD | 86 +- service/kv/kv_service.cpp | 158 +- service/tools/config/interface/service.config | 6 +- .../tools/config/interface/service0.config | 6 +- .../config/server/contract_server.config | 72 +- service/tools/config/server/server.config | 76 +- .../tools/config/server/utxo_config.config | 24 +- service/tools/contract/README.md | 74 +- service/tools/contract/api_tools/BUILD | 62 +- .../contract/api_tools/client_config.config | 2 +- .../api_tools/config/server_config.config | 56 +- .../contract/api_tools/contract_tools.cpp | 360 +- service/tools/contract/api_tools/create.js | 46 +- service/tools/contract/api_tools/deploy.js | 52 +- .../api_tools/example_contract/compile.sh | 40 +- .../api_tools/example_contract/token.json | 26 +- .../api_tools/example_contract/token.sol | 90 +- service/tools/contract/api_tools/execute.js | 54 +- .../service_tools/start_contract_service.sh | 64 +- service/tools/kv/api_tools/BUILD | 104 +- .../kv/api_tools/contract_service_tools.cpp | 470 +- service/tools/kv/api_tools/create.js | 44 +- service/tools/kv/api_tools/deploy.js | 52 +- .../kv/api_tools/example_contract/compile.sh | 42 +- .../kv/api_tools/example_contract/token.json | 26 +- .../kv/api_tools/example_contract/token.sol | 90 +- service/tools/kv/api_tools/execute.js | 54 +- service/tools/kv/api_tools/get_balance.js | 46 +- .../kv/api_tools/kv_client_txn_tools.cpp | 134 +- .../tools/kv/api_tools/kv_service_tools.cpp | 560 +- service/tools/kv/api_tools/set_balance.js | 48 +- service/tools/utxo/README.md | 106 +- .../utxo/service_tools/start_utxo_service.sh | 68 +- service/tools/utxo/wallet_tool/cpp/BUILD | 96 +- .../tools/utxo/wallet_tool/cpp/addr_utils.cpp | 82 +- .../tools/utxo/wallet_tool/cpp/addr_utils.h | 64 +- .../utxo/wallet_tool/cpp/client_config.config | 2 +- .../tools/utxo/wallet_tool/cpp/key_utils.cpp | 72 +- .../tools/utxo/wallet_tool/cpp/key_utils.h | 60 +- .../wallet_tool/cpp/server_config0.config | 2 +- .../wallet_tool/cpp/utxo_client_tools.cpp | 364 +- service/tools/utxo/wallet_tool/py/BUILD | 80 +- service/tools/utxo/wallet_tool/py/addr.py | 64 +- service/tools/utxo/wallet_tool/py/keys.py | 52 +- service/tools/utxo/wallet_tool/pybind/BUILD | 76 +- .../wallet_tool/pybind/wallet_tools_py.cpp | 76 +- service/tools/utxo/wallet_tool/test/BUILD | 96 +- .../tools/utxo/wallet_tool/test/key_tester.py | 52 +- .../wallet_tool/test/key_tester_utils.cpp | 94 +- service/utils/BUILD | 62 +- service/utils/server_factory.cpp | 96 +- service/utils/server_factory.h | 248 +- service/utxo/BUILD | 60 +- service/utxo/config/server_config.config | 56 +- service/utxo/config/utxo_config.config | 24 +- service/utxo/start_contract_server.sh | 64 +- service/utxo/utxo_service.cpp | 192 +- test_enum.o | Bin 0 -> 1424 bytes third_party/BUILD | 122 +- third_party/asio.BUILD | 76 +- third_party/civetweb.BUILD | 104 +- third_party/crow.BUILD | 76 +- third_party/date.BUILD | 60 +- third_party/eEVM.BUILD | 110 +- third_party/json.BUILD | 58 +- third_party/leveldb.BUILD | 108 +- third_party/loc_script/action.yml | 144 +- third_party/loc_script/src/index.js | 218 +- third_party/prometheus.BUILD | 66 +- third_party/rapidjson.BUILD | 60 +- third_party/snappy.BUILD | 148 +- third_party/z.BUILD | 68 +- third_party/zlib.BUILD | 120 +- tools/BUILD | 158 +- tools/certificate_tools.cpp | 274 +- tools/certificate_tools_test.cpp | 190 +- tools/generate_certificate.sh | 110 +- tools/generate_client.sh | 44 +- tools/generate_cluster.sh | 58 +- tools/generate_key.sh | 42 +- tools/generate_mulregion_config.py | 138 +- tools/generate_region_config.py | 168 +- tools/key_generator_tools.cpp | 164 +- tools/resdb_state_accessor_tools.cpp | 86 +- tools/resdb_txn_accessor_tools.cpp | 116 +- 937 files changed, 193999 insertions(+), 193999 deletions(-) create mode 100644 test_enum.o diff --git a/.asf.yaml b/.asf.yaml index 6aed65d9cd..2ba00197e2 100644 --- a/.asf.yaml +++ b/.asf.yaml @@ -1,42 +1,42 @@ -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -github: - description: Global-Scale Sustainable Blockchain Fabric - homepage: https://resilientdb.incubator.apache.org/ - labels: - - crypto - - smart-contracts - - blockchain - - solidity - - distributed-database - - key-value-database - - distributed-ledger - - blockchain-platform - - utxo - enabled_merge_buttons: - squash: true - merge: false - rebase: false - protected_branches: - master: - required_status_checks: - strict: true - -notifications: - commits: commits@resilientdb.apache.org - issues: commits@resilientdb.apache.org - pullrequests: commits@resilientdb.apache.org +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +github: + description: Global-Scale Sustainable Blockchain Fabric + homepage: https://resilientdb.incubator.apache.org/ + labels: + - crypto + - smart-contracts + - blockchain + - solidity + - distributed-database + - key-value-database + - distributed-ledger + - blockchain-platform + - utxo + enabled_merge_buttons: + squash: true + merge: false + rebase: false + protected_branches: + master: + required_status_checks: + strict: true + +notifications: + commits: commits@resilientdb.apache.org + issues: commits@resilientdb.apache.org + pullrequests: commits@resilientdb.apache.org diff --git a/.bazelignore b/.bazelignore index 081bf6b481..bdbb16a91d 100644 --- a/.bazelignore +++ b/.bazelignore @@ -1 +1 @@ -ecosystem/ +ecosystem/ diff --git a/.bazelrc b/.bazelrc index cc3d1af5c3..1ea525dd47 100644 --- a/.bazelrc +++ b/.bazelrc @@ -1,4 +1,4 @@ -build --cxxopt='-std=c++17' --copt=-O3 --jobs=40 -#build --action_env=PYTHON_BIN_PATH="/usr/bin/python3.10" -#build --action_env=PYTHON_LIB_PATH="/usr/include/python3.10" - +build --cxxopt='-std=c++17' --copt=-O3 --jobs=40 +#build --action_env=PYTHON_BIN_PATH="/usr/bin/python3.10" +#build --action_env=PYTHON_LIB_PATH="/usr/include/python3.10" + diff --git a/.bazelversion b/.bazelversion index 09b254e90c..6837a3bdb8 100644 --- a/.bazelversion +++ b/.bazelversion @@ -1 +1 @@ -6.0.0 +6.0.0 diff --git a/.clang-format b/.clang-format index f2dd0de378..ca23701a44 100644 --- a/.clang-format +++ b/.clang-format @@ -1,168 +1,168 @@ ---- -Language: Cpp -# BasedOnStyle: Google -AccessModifierOffset: -1 -AlignAfterOpenBracket: Align -AlignConsecutiveMacros: false -AlignConsecutiveAssignments: false -AlignConsecutiveDeclarations: false -AlignEscapedNewlines: Left -AlignOperands: true -AlignTrailingComments: true -AllowAllArgumentsOnNextLine: true -AllowAllConstructorInitializersOnNextLine: true -AllowAllParametersOfDeclarationOnNextLine: true -AllowShortBlocksOnASingleLine: Never -AllowShortCaseLabelsOnASingleLine: false -AllowShortFunctionsOnASingleLine: All -AllowShortLambdasOnASingleLine: All -AllowShortIfStatementsOnASingleLine: WithoutElse -AllowShortLoopsOnASingleLine: true -AlwaysBreakAfterDefinitionReturnType: None -AlwaysBreakAfterReturnType: None -AlwaysBreakBeforeMultilineStrings: true -AlwaysBreakTemplateDeclarations: Yes -BinPackArguments: true -BinPackParameters: true -BraceWrapping: - AfterCaseLabel: false - AfterClass: false - AfterControlStatement: false - AfterEnum: false - AfterFunction: false - AfterNamespace: false - AfterObjCDeclaration: false - AfterStruct: false - AfterUnion: false - AfterExternBlock: false - BeforeCatch: false - BeforeElse: false - IndentBraces: false - SplitEmptyFunction: true - SplitEmptyRecord: true - SplitEmptyNamespace: true -BreakBeforeBinaryOperators: None -BreakBeforeBraces: Attach -BreakBeforeInheritanceComma: false -BreakInheritanceList: BeforeColon -BreakBeforeTernaryOperators: true -BreakConstructorInitializersBeforeComma: false -BreakConstructorInitializers: BeforeColon -BreakAfterJavaFieldAnnotations: false -BreakStringLiterals: true -ColumnLimit: 80 -CommentPragmas: '^ IWYU pragma:' -CompactNamespaces: false -ConstructorInitializerAllOnOneLineOrOnePerLine: true -ConstructorInitializerIndentWidth: 4 -ContinuationIndentWidth: 4 -Cpp11BracedListStyle: true -DeriveLineEnding: true -DerivePointerAlignment: true -DisableFormat: false -ExperimentalAutoDetectBinPacking: false -FixNamespaceComments: true -ForEachMacros: - - foreach - - Q_FOREACH - - BOOST_FOREACH -IncludeBlocks: Regroup -IncludeCategories: - - Regex: '^' - Priority: 2 - SortPriority: 0 - - Regex: '^<.*\.h>' - Priority: 1 - SortPriority: 0 - - Regex: '^<.*' - Priority: 2 - SortPriority: 0 - - Regex: '.*' - Priority: 3 - SortPriority: 0 -IncludeIsMainRegex: '([-_](test|unittest))?$' -IncludeIsMainSourceRegex: '' -IndentCaseLabels: true -IndentGotoLabels: true -IndentPPDirectives: None -IndentWidth: 2 -IndentWrappedFunctionNames: false -JavaScriptQuotes: Leave -JavaScriptWrapImports: true -KeepEmptyLinesAtTheStartOfBlocks: false -MacroBlockBegin: '' -MacroBlockEnd: '' -MaxEmptyLinesToKeep: 1 -NamespaceIndentation: None -ObjCBinPackProtocolList: Never -ObjCBlockIndentWidth: 2 -ObjCSpaceAfterProperty: false -ObjCSpaceBeforeProtocolList: true -PenaltyBreakAssignment: 2 -PenaltyBreakBeforeFirstCallParameter: 1 -PenaltyBreakComment: 300 -PenaltyBreakFirstLessLess: 120 -PenaltyBreakString: 1000 -PenaltyBreakTemplateDeclaration: 10 -PenaltyExcessCharacter: 1000000 -PenaltyReturnTypeOnItsOwnLine: 200 -PointerAlignment: Left -RawStringFormats: - - Language: Cpp - Delimiters: - - cc - - CC - - cpp - - Cpp - - CPP - - 'c++' - - 'C++' - CanonicalDelimiter: '' - BasedOnStyle: google - - Language: TextProto - Delimiters: - - pb - - PB - - proto - - PROTO - EnclosingFunctions: - - EqualsProto - - EquivToProto - - PARSE_PARTIAL_TEXT_PROTO - - PARSE_TEST_PROTO - - PARSE_TEXT_PROTO - - ParseTextOrDie - - ParseTextProtoOrDie - CanonicalDelimiter: '' - BasedOnStyle: google -ReflowComments: true -SortIncludes: true -SortUsingDeclarations: true -SpaceAfterCStyleCast: false -SpaceAfterLogicalNot: false -SpaceAfterTemplateKeyword: true -SpaceBeforeAssignmentOperators: true -SpaceBeforeCpp11BracedList: false -SpaceBeforeCtorInitializerColon: true -SpaceBeforeInheritanceColon: true -SpaceBeforeParens: ControlStatements -SpaceBeforeRangeBasedForLoopColon: true -SpaceInEmptyBlock: false -SpaceInEmptyParentheses: false -SpacesBeforeTrailingComments: 2 -SpacesInAngles: false -SpacesInConditionalStatement: false -SpacesInContainerLiterals: true -SpacesInCStyleCastParentheses: false -SpacesInParentheses: false -SpacesInSquareBrackets: false -SpaceBeforeSquareBrackets: false -Standard: Auto -StatementMacros: - - Q_UNUSED - - QT_REQUIRE_VERSION -TabWidth: 8 -UseCRLF: false -UseTab: Never -... - +--- +Language: Cpp +# BasedOnStyle: Google +AccessModifierOffset: -1 +AlignAfterOpenBracket: Align +AlignConsecutiveMacros: false +AlignConsecutiveAssignments: false +AlignConsecutiveDeclarations: false +AlignEscapedNewlines: Left +AlignOperands: true +AlignTrailingComments: true +AllowAllArgumentsOnNextLine: true +AllowAllConstructorInitializersOnNextLine: true +AllowAllParametersOfDeclarationOnNextLine: true +AllowShortBlocksOnASingleLine: Never +AllowShortCaseLabelsOnASingleLine: false +AllowShortFunctionsOnASingleLine: All +AllowShortLambdasOnASingleLine: All +AllowShortIfStatementsOnASingleLine: WithoutElse +AllowShortLoopsOnASingleLine: true +AlwaysBreakAfterDefinitionReturnType: None +AlwaysBreakAfterReturnType: None +AlwaysBreakBeforeMultilineStrings: true +AlwaysBreakTemplateDeclarations: Yes +BinPackArguments: true +BinPackParameters: true +BraceWrapping: + AfterCaseLabel: false + AfterClass: false + AfterControlStatement: false + AfterEnum: false + AfterFunction: false + AfterNamespace: false + AfterObjCDeclaration: false + AfterStruct: false + AfterUnion: false + AfterExternBlock: false + BeforeCatch: false + BeforeElse: false + IndentBraces: false + SplitEmptyFunction: true + SplitEmptyRecord: true + SplitEmptyNamespace: true +BreakBeforeBinaryOperators: None +BreakBeforeBraces: Attach +BreakBeforeInheritanceComma: false +BreakInheritanceList: BeforeColon +BreakBeforeTernaryOperators: true +BreakConstructorInitializersBeforeComma: false +BreakConstructorInitializers: BeforeColon +BreakAfterJavaFieldAnnotations: false +BreakStringLiterals: true +ColumnLimit: 80 +CommentPragmas: '^ IWYU pragma:' +CompactNamespaces: false +ConstructorInitializerAllOnOneLineOrOnePerLine: true +ConstructorInitializerIndentWidth: 4 +ContinuationIndentWidth: 4 +Cpp11BracedListStyle: true +DeriveLineEnding: true +DerivePointerAlignment: true +DisableFormat: false +ExperimentalAutoDetectBinPacking: false +FixNamespaceComments: true +ForEachMacros: + - foreach + - Q_FOREACH + - BOOST_FOREACH +IncludeBlocks: Regroup +IncludeCategories: + - Regex: '^' + Priority: 2 + SortPriority: 0 + - Regex: '^<.*\.h>' + Priority: 1 + SortPriority: 0 + - Regex: '^<.*' + Priority: 2 + SortPriority: 0 + - Regex: '.*' + Priority: 3 + SortPriority: 0 +IncludeIsMainRegex: '([-_](test|unittest))?$' +IncludeIsMainSourceRegex: '' +IndentCaseLabels: true +IndentGotoLabels: true +IndentPPDirectives: None +IndentWidth: 2 +IndentWrappedFunctionNames: false +JavaScriptQuotes: Leave +JavaScriptWrapImports: true +KeepEmptyLinesAtTheStartOfBlocks: false +MacroBlockBegin: '' +MacroBlockEnd: '' +MaxEmptyLinesToKeep: 1 +NamespaceIndentation: None +ObjCBinPackProtocolList: Never +ObjCBlockIndentWidth: 2 +ObjCSpaceAfterProperty: false +ObjCSpaceBeforeProtocolList: true +PenaltyBreakAssignment: 2 +PenaltyBreakBeforeFirstCallParameter: 1 +PenaltyBreakComment: 300 +PenaltyBreakFirstLessLess: 120 +PenaltyBreakString: 1000 +PenaltyBreakTemplateDeclaration: 10 +PenaltyExcessCharacter: 1000000 +PenaltyReturnTypeOnItsOwnLine: 200 +PointerAlignment: Left +RawStringFormats: + - Language: Cpp + Delimiters: + - cc + - CC + - cpp + - Cpp + - CPP + - 'c++' + - 'C++' + CanonicalDelimiter: '' + BasedOnStyle: google + - Language: TextProto + Delimiters: + - pb + - PB + - proto + - PROTO + EnclosingFunctions: + - EqualsProto + - EquivToProto + - PARSE_PARTIAL_TEXT_PROTO + - PARSE_TEST_PROTO + - PARSE_TEXT_PROTO + - ParseTextOrDie + - ParseTextProtoOrDie + CanonicalDelimiter: '' + BasedOnStyle: google +ReflowComments: true +SortIncludes: true +SortUsingDeclarations: true +SpaceAfterCStyleCast: false +SpaceAfterLogicalNot: false +SpaceAfterTemplateKeyword: true +SpaceBeforeAssignmentOperators: true +SpaceBeforeCpp11BracedList: false +SpaceBeforeCtorInitializerColon: true +SpaceBeforeInheritanceColon: true +SpaceBeforeParens: ControlStatements +SpaceBeforeRangeBasedForLoopColon: true +SpaceInEmptyBlock: false +SpaceInEmptyParentheses: false +SpacesBeforeTrailingComments: 2 +SpacesInAngles: false +SpacesInConditionalStatement: false +SpacesInContainerLiterals: true +SpacesInCStyleCastParentheses: false +SpacesInParentheses: false +SpacesInSquareBrackets: false +SpaceBeforeSquareBrackets: false +Standard: Auto +StatementMacros: + - Q_UNUSED + - QT_REQUIRE_VERSION +TabWidth: 8 +UseCRLF: false +UseTab: Never +... + diff --git a/.github/workflows/build-push.yml b/.github/workflows/build-push.yml index e8e1460ead..af862cae3a 100644 --- a/.github/workflows/build-push.yml +++ b/.github/workflows/build-push.yml @@ -1,64 +1,64 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -name: ci - -on: - push: - branches: - - 'master' - -jobs: - docker: - runs-on: ubuntu-latest - steps: - - - name: Checkout - uses: actions/checkout@v3 - - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Login to Docker Hub - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Build and push Dockerfile - uses: docker/build-push-action@v5 - with: - file: ./Docker/Dockerfile - context: . - platforms: linux/amd64 - push: true - tags: expolab/resdb:amd64 - - - - name: Build and push Dockerfile mac - uses: docker/build-push-action@v5 - with: - file: ./Docker/Dockerfile_mac - context: . - platforms: linux/arm64 - push: true - tags: expolab/resdb:arm64 +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +name: ci + +on: + push: + branches: + - 'master' + +jobs: + docker: + runs-on: ubuntu-latest + steps: + - + name: Checkout + uses: actions/checkout@v3 + - + name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - + name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - + name: Build and push Dockerfile + uses: docker/build-push-action@v5 + with: + file: ./Docker/Dockerfile + context: . + platforms: linux/amd64 + push: true + tags: expolab/resdb:amd64 + + - + name: Build and push Dockerfile mac + uses: docker/build-push-action@v5 + with: + file: ./Docker/Dockerfile_mac + context: . + platforms: linux/arm64 + push: true + tags: expolab/resdb:arm64 diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index eb68982300..70eebaa5be 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,53 +1,53 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -name: bazel-build CI - -on: - push: - branches: - - master - - pull_request: - branches: - - master - -jobs: - ubuntu-build: - name: build - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v1 - - name: Mount bazel cache - uses: actions/cache@v3 - with: - path: "/home/runner/.cache/bazel" - key: bazel - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: '3.10' - - name: build - shell: bash - env: - CC: gcc-11 - CXX: g++-11 - run: | - sudo apt install gcc-11 g++-11 - bazel build ... +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +name: bazel-build CI + +on: + push: + branches: + - master + + pull_request: + branches: + - master + +jobs: + ubuntu-build: + name: build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - name: Mount bazel cache + uses: actions/cache@v3 + with: + path: "/home/runner/.cache/bazel" + key: bazel + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.10' + - name: build + shell: bash + env: + CC: gcc-11 + CXX: g++-11 + run: | + sudo apt install gcc-11 g++-11 + bazel build ... diff --git a/.github/workflows/license.yml b/.github/workflows/license.yml index 9468e3960f..25696f2e9b 100644 --- a/.github/workflows/license.yml +++ b/.github/workflows/license.yml @@ -1,37 +1,37 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -name: Check Apache License - -on: - push - -jobs: - ubuntu-build: - name: check license - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - with: - repository: ${{github.repository}} - ref: ${{ env.BRANCH_NAME }} - - - name: Check License Header - uses: apache/skywalking-eyes/header@main +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +name: Check Apache License + +on: + push + +jobs: + ubuntu-build: + name: check license + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + repository: ${{github.repository}} + ref: ${{ env.BRANCH_NAME }} + + - name: Check License Header + uses: apache/skywalking-eyes/header@main diff --git a/.github/workflows/loc.yml b/.github/workflows/loc.yml index dc418b1e21..a848d2f643 100644 --- a/.github/workflows/loc.yml +++ b/.github/workflows/loc.yml @@ -1,62 +1,62 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -name: LOC - -on: - push: - branches: - - master - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v2 - with: - repository: ${{github.repository}} - ref: ${{ env.BRANCH_NAME }} - - - name: NPM Init - run: npm init -y - - - name: NPM Install - run: npm install badgen @actions/core glob-gitignore - - - name: Launch the local action - id: badge - uses: ./third_party/loc_script/ # Uses an action in the root directory - with: - debug: true - directory: ./ - patterns: '**/*.h|**/*.cpp' - badge: ./output/badge.svg - ignore: 'node_modules/|README' - - - name: Deploy to image-data branch - uses: peaceiris/actions-gh-pages@v3 - with: - publish_dir: ./output - publish_branch: image-data - github_token: ${{ secrets.GITHUB_TOKEN }} - user_name: 'github-actions[bot]' - user_email: 'github-actions[bot]@users.noreply.github.com' - +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +name: LOC + +on: + push: + branches: + - master + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + repository: ${{github.repository}} + ref: ${{ env.BRANCH_NAME }} + + - name: NPM Init + run: npm init -y + + - name: NPM Install + run: npm install badgen @actions/core glob-gitignore + + - name: Launch the local action + id: badge + uses: ./third_party/loc_script/ # Uses an action in the root directory + with: + debug: true + directory: ./ + patterns: '**/*.h|**/*.cpp' + badge: ./output/badge.svg + ignore: 'node_modules/|README' + + - name: Deploy to image-data branch + uses: peaceiris/actions-gh-pages@v3 + with: + publish_dir: ./output + publish_branch: image-data + github_token: ${{ secrets.GITHUB_TOKEN }} + user_name: 'github-actions[bot]' + user_email: 'github-actions[bot]@users.noreply.github.com' + diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 3034255fa3..c540208956 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,47 +1,47 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -name: Doxygen Action - -on: - push: - branches: [ master ] - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - - name: Doxygen Action - uses: mattnotmitt/doxygen-action@v1.1.0 - with: - # Path to Doxyfile - doxyfile-path: "Doxyfile" # default is ./Doxyfile - # Working directory - working-directory: "documents/doxygen/" # default is . - - - name: Deploy - uses: peaceiris/actions-gh-pages@v3 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: documents/doxygen/html - cname: api.resilientdb.com - +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +name: Doxygen Action + +on: + push: + branches: [ master ] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Doxygen Action + uses: mattnotmitt/doxygen-action@v1.1.0 + with: + # Path to Doxyfile + doxyfile-path: "Doxyfile" # default is ./Doxyfile + # Working directory + working-directory: "documents/doxygen/" # default is . + + - name: Deploy + uses: peaceiris/actions-gh-pages@v3 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: documents/doxygen/html + cname: api.resilientdb.com + diff --git a/.github/workflows/ut.yml b/.github/workflows/ut.yml index 7df6153104..fca24e3a5e 100644 --- a/.github/workflows/ut.yml +++ b/.github/workflows/ut.yml @@ -1,53 +1,53 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -name: Unite Test - -on: - push: - branches: - - master - - pull_request: - branches: - - master - -jobs: - ubuntu-build: - name: build - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v1 - - name: Mount bazel cache - uses: actions/cache@v3 - with: - path: "/home/runner/.cache/bazel" - key: bazel - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: '3.10' - - name: build - shell: bash - env: - CC: gcc-11 - CXX: g++-11 - run: | - sudo apt install gcc-11 g++-11 +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +name: Unite Test + +on: + push: + branches: + - master + + pull_request: + branches: + - master + +jobs: + ubuntu-build: + name: build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - name: Mount bazel cache + uses: actions/cache@v3 + with: + path: "/home/runner/.cache/bazel" + key: bazel + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.10' + - name: build + shell: bash + env: + CC: gcc-11 + CXX: g++-11 + run: | + sudo apt install gcc-11 g++-11 bazel build ... \ No newline at end of file diff --git a/.gitignore b/.gitignore index 6d1b093fe9..9d571cdd0d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,23 +1,23 @@ -deps/*/ -scripts/deploy/config/key.conf -scripts/deploy/config_out/ -deploy/kv_server/output/ -.idea/ -.vscode/ -.DS_Store -bazel-* -*.log -*.bak -venv -sdk_validator/venv -__pycache__ -MODULE.* -apache_release -*.out.* -*.data.* -*.pb.* -.cache/ -resdb/ -100*_db/ -gmon.out +deps/*/ +scripts/deploy/config/key.conf +scripts/deploy/config_out/ +deploy/kv_server/output/ +.idea/ +.vscode/ +.DS_Store +bazel-* +*.log +*.bak +venv +sdk_validator/venv +__pycache__ +MODULE.* +apache_release +*.out.* +*.data.* +*.pb.* +.cache/ +resdb/ +100*_db/ +gmon.out .history/ \ No newline at end of file diff --git a/.licenserc.yaml b/.licenserc.yaml index badb8a63cd..582c02d728 100644 --- a/.licenserc.yaml +++ b/.licenserc.yaml @@ -1,21 +1,21 @@ -header: - license: - spdx-id: Apache-2.0 - copyright-owner: Apache Software Foundation - - paths-ignore: - - '.*' - - '.**/**' - - '**/*.sol' - - CNAME - - DISCLAIMER - - LICENSE - - NOTICE - - 'dev/.rat-excludes' - - 'documents/doxygen/.gitignore' - - 'third_party/loc_script/src/index.js' - - - - comment: on-failure - +header: + license: + spdx-id: Apache-2.0 + copyright-owner: Apache Software Foundation + + paths-ignore: + - '.*' + - '.**/**' + - '**/*.sol' + - CNAME + - DISCLAIMER + - LICENSE + - NOTICE + - 'dev/.rat-excludes' + - 'documents/doxygen/.gitignore' + - 'third_party/loc_script/src/index.js' + + + + comment: on-failure + diff --git a/BUILD.bazel b/BUILD.bazel index a2966540e1..7aebd582a4 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -1,35 +1,35 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -package(default_visibility = ["//visibility:public"]) - -load("@rules_foreign_cc//foreign_cc:defs.bzl", "make") - -make( - name = "cryptopp", - lib_source = "@cryptopp//:all_srcs", - out_static_libs = ["libcryptopp.a"], -) - -cc_library( - name = "cryptopp_lib", - deps = [ - ":cryptopp", - ], -) +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +package(default_visibility = ["//visibility:public"]) + +load("@rules_foreign_cc//foreign_cc:defs.bzl", "make") + +make( + name = "cryptopp", + lib_source = "@cryptopp//:all_srcs", + out_static_libs = ["libcryptopp.a"], +) + +cc_library( + name = "cryptopp_lib", + deps = [ + ":cryptopp", + ], +) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7708eaf63a..c0922705a3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,168 +1,168 @@ - - -# Change Log - -### Apache ResilientDB v1.11.0 ([2025-4-27](https://github.com/resilientdb/resilientdb/releases/tag/v1.11.0)) -* Support Combined Runtime for SmartContact and Key-value Service. ([Junchao Chen](https://github.com/cjcchen)) - - -### Apache ResilientDB v1.10.1 ([2024-4-16](https://github.com/resilientdb/resilientdb/releases/tag/v1.10.1)) -* Remove the binary keys from the source code. ([Junchao Chen](https://github.com/cjcchen)) -* Fix few bugs on Docker and performance tools. ([Gopal Nambiar](gopalnambiar2@gmail.com), [Junchao Chen](https://github.com/cjcchen)) - -### Apache ResilientDB v1.10.0 ([2024-4-16](https://github.com/resilientdb/resilientdb/releases/tag/v1.10.0-rc01)) - -Add the prototype of PoE. ([Junchao Chen](https://github.com/cjcchen)) - -* Implement the base version of the Proof-of-Execution (PoE) Consensus Protocol [EDBT 2011]. - -Add ResView Data Collection and APIs ([Saipranav-Kotamreddy](https://github.com/Saipranav-Kotamreddy)) - -* Consensus data such as PBFT messages and states is now collected and stored -* Added APIs to query consensus data and progress of replicas -* Added APIs to trigger faultiness and test view change - -### NexRes v1.9.0 ([2023-11-29](https://github.com/resilientdb/resilientdb/releases/tag/nexres-v1.9.0)) - -Support Multi-version Key-Value Interface. ([Junchao Chen](https://github.com/cjcchen)) - -* Get and Set need to provide a version number to fetch the correct version of the data (if exists) or write to the correct version of data (if not overwritten already), respectively. -* Provide interfaces to obtain historical data with a specific version or a range of versions. - - -### NexRes v1.8.0 ([2023-08-21](https://github.com/resilientdb/resilientdb/releases/tag/nexres-v1.8.0)) - -**Implemented Enhancements:** The view-change recovery protocol was extensively expanded to support the following Byzantine failures through primary/leader replacement and replica recovery. ([Dakai Kang](https://github.com/DakaiKang)) - -* Byzantine primary becomes non-responsive, stopping proposing any new Pre-Prepare messages. -* Byzantine primary equivocates, proposing two different client requests to two subsets of replicas. -* Byzantine replicas try to keep some non-faulty replicas in the dark. -* Byzantine new primary becomes non-responsive, refusing to broadcast New-View messages. - -### NexRes v1.7.0 ([2023-08-04](https://github.com/resilientdb/resilientdb/releases/tag/nexres-v1.7.0)) - -**Implemented Enhancements:** For each replica local recovery from durable storage upon system restart was added.([Junchao Chen](https://github.com/cjcchen)) - - -### NexRes v1.6.0 ([2023-05-30](https://github.com/resilientdb/resilientdb/releases/tag/nexres-v1.6.0)) - -**Implemented Enhancements:** Refactoring and enhancement of the codebase to highlight the entire software stack of ResilientDB consisting of the following layers ([Junchao Chen](https://github.com/cjcchen)) - -* SDK Layer (C++, Python, Go, Solidity) -* Interface Layer (key-value, smart contract, UTXO) -* ResilientDB Database Connectivity (RDBC) API -* Platform Layer (consensus, chain, network, notary) -* Transaction Layer (execution runtime and in-memory chain state) -* Storage Layer (chain and chain state durability) - - -### NexRes v1.5.0 ([2023-04-04](https://github.com/resilientdb/resilientdb/releases/tag/nexres-v1.5.0)) - -**Implemented Enhancements:** -* A complete refactoring of the codebase such that (1) the core engine code is now moved to the platform folder, including the formwork architectures and protocols implementations; (2) the API/interface-related code is moved to the service folder, including UTXO, smart contract, and key-value interface; (3) the python SDK code is moved to a different repository [here](https://github.com/resilientdb/sdk) ([Junchao Chen](https://github.com/cjcchen)). - -### NexRes v1.4.0 ([2023-02-28](https://github.com/resilientdb/resilientdb/releases/tag/nexres-v.1.4.0)) -Major Changes -* Support of UTXO model and wallet integration: [Detailed Documentation](https://blog.resilientdb.com/2023/02/12/GettingStartedOnUtxo.html) ([Junchao Chen](https://github.com/cjcchen)) - - -### NexRes v1.3.0 ([2023-02-22](https://github.com/resilientdb/resilientdb/releases/tag/nexres-v1.3.0)) - -**Implemented Enhancements:** -* Added Python SDK that supports UTXO-like transactions such as asset creation, transfer, and multi-party validations. ([Arindaam Roy](https://github.com/royari), [Glenn Chen](https://github.com/glenn-chen), and [Julieta Duarte](https://github.com/juduarte00)) -* Added REST CROW endpoints to interface with the on-chain KV service. ([Glenn Chen](https://github.com/glenn-chen) and [Julieta Duarte](https://github.com/juduarte00)) -* Extended KV service range queries. ([Glenn Chen](https://github.com/glenn-chen) and [Julieta Duarte](https://github.com/juduarte00)) - -**Fixed Bugs:** -* Fixed KV service queries on all values retrieving empty placeholder values ([Glenn Chen](https://github.com/glenn-chen)) - -### NexRes v1.2.0 ([2023-01-29](https://github.com/resilientdb/resilientdb/releases/tag/nexres-v1.2.0)) - -**Implemented Enhancements:** -* Support smart contract compiled from Solidity. ([Junchao Chen](https://github.com/cjcchen)) -* Use eEVM as a back-end service to execute the contract functions. ([Junchao Chen](https://github.com/cjcchen)) - -### NexRes v1.1.0 ([2023-01-03](https://github.com/resilientdb/resilientdb/releases/tag/nexres-v1.1.0)) - -**Implemented Enhancements:** - -* Added Geo-Scale Byzantine Fault-tolerant consensus protocol, referred to as GeoBFT. It is designed for excellent scalability by using a topological-aware grouping of replicas in local clusters, giving rise to parallelization of consensus at the local level and by minimizing communication between clusters. ([WayneWang](https://github.com/WayneJa)) - -ResilientDB: Global Scale Resilient Blockchain Fabric, VLDB 2020 - -### NexRes v1.0.1 ([2022-10-13](https://github.com/resilientdb/resilientdb/releases/tag/nexres-v1.0.1)) - -**Implemented Enhancements:** - -* Add node manager backend for resilientdb.com to launch NexRes locally. ([Vishnu](https://github.com/sheshavpd) and [Junchao Chen](https://github.com/cjcchen)) - -### NexRes v1.0.0 ([2022-09-30](https://github.com/resilientdb/resilientdb/releases/tag/nexres-v1.0.0)) - -**Implemented Enhancements:** - -* Release the next generation of RelisientDB referred to as NexRes. ([Junchao Chen](https://github.com/cjcchen)) -* NexRes supports PBFT as the default core protocol and provides a KV-Server as a service. ([Junchao Chen](https://github.com/cjcchen)) -* NexRes also supports LevelDB and RocksDB as the durable storage layer. ([Junchao Chen](https://github.com/cjcchen)) -* Add SDK endpoints. ([Junchao Chen](https://github.com/cjcchen)) -* Add implementation of Dashboard. ([Jianxio](https://github.com/jyu25utk)) -* Add the recovery protocol and checkpoint on PBFT. ([Junchao Chen](https://github.com/cjcchen) and [Vishnu](https://github.com/sheshavpd)) - - -### NexRes v1.0.0-alpha ([2022-09-22](https://github.com/resilientdb/resilientdb/releases/tag/nexres-alpha)) - -**Implemented Enhancements:** -* Release the next generation of RelisientDB, a complete rewrite and re-architecting, referred to as NexRes. ([Junchao Chen](https://github.com/cjcchen)) -* NexRes supports PBFT as the default core protocol and provides a KV-Server as a service. ([Junchao Chen](https://github.com/cjcchen)) -* NexRes also supports LevelDB and RocksDB as the durable storage layer. ([Glenn Chen](https://github.com/glenn-chen), [Julieta Duarte](https://github.com/juduarte00), and [Junchao Chen](https://github.com/cjcchen)) - - -### v3.0 ([2021-09-30](https://github.com/resilientdb/resilientdb/releases/tag/v3.0)) - -**Implemented Enhancements:** -* GeoBFT Protocol Added ([Sajjad Rahnama](https://github.com/sajjadrahnama)) -* Work Queue structure changed ([Sajjad Rahnama](https://github.com/sajjadrahnama)) -* Refactoring, and added Statistics and Scripts ([Sajjad Rahnama](https://github.com/sajjadrahnama)) - - -### v2.0 ([2020-02-29](https://github.com/resilientdb/resilientdb/releases/tag/v2.0)) - -**Implemented Enhancements:** -* A GUI display for ResilientDB to ease user interaction and analysis. [#9](https://github.com/resilientdb/resilientdb/issues/9) ([Sajjad Rahnama](https://github.com/sajjadrahnama) and [RohanSogani](https://github.com/RohanSogani)) -* Added support for Smart Contracts with a Banking use case. [#7](https://github.com/resilientdb/resilientdb/issues/7) ([Sajjad Rahnama](https://github.com/sajjadrahnama)) -* Monitoring results for visualizing graphs using influxdb. [#8](https://github.com/resilientdb/resilientdb/issues/8) ([Sajjad Rahnama](https://github.com/sajjadrahnama), [Dhruv Krishnan](https://github.com/DhruvKrish) and [Priya Holani](https://github.com/Holani)) -* Added support for SQLite and provided a new representation for in-memory storage. [#6](https://github.com/resilientdb/resilientdb/issues/6) ([Sajjad Rahnama](https://github.com/sajjadrahnama)) - -**Fixed Bugs:** -* Bug in the Chain Initialization [#5](https://github.com/resilientdb/resilientdb/issues/5) ([Sajjad Rahnama](https://github.com/sajjadrahnama)) - - -### v1.1 ([2019-12-05](https://github.com/resilientdb/resilientdb/releases/tag/v1.1)) - -**Implemented Enhancements:** -* Defined class to represent ledger. [6b0fdc5](https://github.com/resilientdb/resilientdb/commit/56f500fe5e4749c45f57dc8e62d12bc7a218ce69) ([Suyash Gupta](https://github.com/gupta-suyash)) - -**Fixed Bugs:** -* Docker script fails to run for multiple client [#1](https://github.com/resilientdb/resilientdb/issues/1) ([RohanSogani](https://github.com/RohanSogani)) - -### v1.0 ([2019-11-24](https://github.com/resilientdb/resilientdb/releases/tag/v1.0)) - -Launched ResilientDB ([Suyash Gupta](https://github.com/gupta-suyash) and [Sajjad Rahnama](https://github.com/sajjadrahnama)) - - + + +# Change Log + +### Apache ResilientDB v1.11.0 ([2025-4-27](https://github.com/resilientdb/resilientdb/releases/tag/v1.11.0)) +* Support Combined Runtime for SmartContact and Key-value Service. ([Junchao Chen](https://github.com/cjcchen)) + + +### Apache ResilientDB v1.10.1 ([2024-4-16](https://github.com/resilientdb/resilientdb/releases/tag/v1.10.1)) +* Remove the binary keys from the source code. ([Junchao Chen](https://github.com/cjcchen)) +* Fix few bugs on Docker and performance tools. ([Gopal Nambiar](gopalnambiar2@gmail.com), [Junchao Chen](https://github.com/cjcchen)) + +### Apache ResilientDB v1.10.0 ([2024-4-16](https://github.com/resilientdb/resilientdb/releases/tag/v1.10.0-rc01)) + +Add the prototype of PoE. ([Junchao Chen](https://github.com/cjcchen)) + +* Implement the base version of the Proof-of-Execution (PoE) Consensus Protocol [EDBT 2011]. + +Add ResView Data Collection and APIs ([Saipranav-Kotamreddy](https://github.com/Saipranav-Kotamreddy)) + +* Consensus data such as PBFT messages and states is now collected and stored +* Added APIs to query consensus data and progress of replicas +* Added APIs to trigger faultiness and test view change + +### NexRes v1.9.0 ([2023-11-29](https://github.com/resilientdb/resilientdb/releases/tag/nexres-v1.9.0)) + +Support Multi-version Key-Value Interface. ([Junchao Chen](https://github.com/cjcchen)) + +* Get and Set need to provide a version number to fetch the correct version of the data (if exists) or write to the correct version of data (if not overwritten already), respectively. +* Provide interfaces to obtain historical data with a specific version or a range of versions. + + +### NexRes v1.8.0 ([2023-08-21](https://github.com/resilientdb/resilientdb/releases/tag/nexres-v1.8.0)) + +**Implemented Enhancements:** The view-change recovery protocol was extensively expanded to support the following Byzantine failures through primary/leader replacement and replica recovery. ([Dakai Kang](https://github.com/DakaiKang)) + +* Byzantine primary becomes non-responsive, stopping proposing any new Pre-Prepare messages. +* Byzantine primary equivocates, proposing two different client requests to two subsets of replicas. +* Byzantine replicas try to keep some non-faulty replicas in the dark. +* Byzantine new primary becomes non-responsive, refusing to broadcast New-View messages. + +### NexRes v1.7.0 ([2023-08-04](https://github.com/resilientdb/resilientdb/releases/tag/nexres-v1.7.0)) + +**Implemented Enhancements:** For each replica local recovery from durable storage upon system restart was added.([Junchao Chen](https://github.com/cjcchen)) + + +### NexRes v1.6.0 ([2023-05-30](https://github.com/resilientdb/resilientdb/releases/tag/nexres-v1.6.0)) + +**Implemented Enhancements:** Refactoring and enhancement of the codebase to highlight the entire software stack of ResilientDB consisting of the following layers ([Junchao Chen](https://github.com/cjcchen)) + +* SDK Layer (C++, Python, Go, Solidity) +* Interface Layer (key-value, smart contract, UTXO) +* ResilientDB Database Connectivity (RDBC) API +* Platform Layer (consensus, chain, network, notary) +* Transaction Layer (execution runtime and in-memory chain state) +* Storage Layer (chain and chain state durability) + + +### NexRes v1.5.0 ([2023-04-04](https://github.com/resilientdb/resilientdb/releases/tag/nexres-v1.5.0)) + +**Implemented Enhancements:** +* A complete refactoring of the codebase such that (1) the core engine code is now moved to the platform folder, including the formwork architectures and protocols implementations; (2) the API/interface-related code is moved to the service folder, including UTXO, smart contract, and key-value interface; (3) the python SDK code is moved to a different repository [here](https://github.com/resilientdb/sdk) ([Junchao Chen](https://github.com/cjcchen)). + +### NexRes v1.4.0 ([2023-02-28](https://github.com/resilientdb/resilientdb/releases/tag/nexres-v.1.4.0)) +Major Changes +* Support of UTXO model and wallet integration: [Detailed Documentation](https://blog.resilientdb.com/2023/02/12/GettingStartedOnUtxo.html) ([Junchao Chen](https://github.com/cjcchen)) + + +### NexRes v1.3.0 ([2023-02-22](https://github.com/resilientdb/resilientdb/releases/tag/nexres-v1.3.0)) + +**Implemented Enhancements:** +* Added Python SDK that supports UTXO-like transactions such as asset creation, transfer, and multi-party validations. ([Arindaam Roy](https://github.com/royari), [Glenn Chen](https://github.com/glenn-chen), and [Julieta Duarte](https://github.com/juduarte00)) +* Added REST CROW endpoints to interface with the on-chain KV service. ([Glenn Chen](https://github.com/glenn-chen) and [Julieta Duarte](https://github.com/juduarte00)) +* Extended KV service range queries. ([Glenn Chen](https://github.com/glenn-chen) and [Julieta Duarte](https://github.com/juduarte00)) + +**Fixed Bugs:** +* Fixed KV service queries on all values retrieving empty placeholder values ([Glenn Chen](https://github.com/glenn-chen)) + +### NexRes v1.2.0 ([2023-01-29](https://github.com/resilientdb/resilientdb/releases/tag/nexres-v1.2.0)) + +**Implemented Enhancements:** +* Support smart contract compiled from Solidity. ([Junchao Chen](https://github.com/cjcchen)) +* Use eEVM as a back-end service to execute the contract functions. ([Junchao Chen](https://github.com/cjcchen)) + +### NexRes v1.1.0 ([2023-01-03](https://github.com/resilientdb/resilientdb/releases/tag/nexres-v1.1.0)) + +**Implemented Enhancements:** + +* Added Geo-Scale Byzantine Fault-tolerant consensus protocol, referred to as GeoBFT. It is designed for excellent scalability by using a topological-aware grouping of replicas in local clusters, giving rise to parallelization of consensus at the local level and by minimizing communication between clusters. ([WayneWang](https://github.com/WayneJa)) + +ResilientDB: Global Scale Resilient Blockchain Fabric, VLDB 2020 + +### NexRes v1.0.1 ([2022-10-13](https://github.com/resilientdb/resilientdb/releases/tag/nexres-v1.0.1)) + +**Implemented Enhancements:** + +* Add node manager backend for resilientdb.com to launch NexRes locally. ([Vishnu](https://github.com/sheshavpd) and [Junchao Chen](https://github.com/cjcchen)) + +### NexRes v1.0.0 ([2022-09-30](https://github.com/resilientdb/resilientdb/releases/tag/nexres-v1.0.0)) + +**Implemented Enhancements:** + +* Release the next generation of RelisientDB referred to as NexRes. ([Junchao Chen](https://github.com/cjcchen)) +* NexRes supports PBFT as the default core protocol and provides a KV-Server as a service. ([Junchao Chen](https://github.com/cjcchen)) +* NexRes also supports LevelDB and RocksDB as the durable storage layer. ([Junchao Chen](https://github.com/cjcchen)) +* Add SDK endpoints. ([Junchao Chen](https://github.com/cjcchen)) +* Add implementation of Dashboard. ([Jianxio](https://github.com/jyu25utk)) +* Add the recovery protocol and checkpoint on PBFT. ([Junchao Chen](https://github.com/cjcchen) and [Vishnu](https://github.com/sheshavpd)) + + +### NexRes v1.0.0-alpha ([2022-09-22](https://github.com/resilientdb/resilientdb/releases/tag/nexres-alpha)) + +**Implemented Enhancements:** +* Release the next generation of RelisientDB, a complete rewrite and re-architecting, referred to as NexRes. ([Junchao Chen](https://github.com/cjcchen)) +* NexRes supports PBFT as the default core protocol and provides a KV-Server as a service. ([Junchao Chen](https://github.com/cjcchen)) +* NexRes also supports LevelDB and RocksDB as the durable storage layer. ([Glenn Chen](https://github.com/glenn-chen), [Julieta Duarte](https://github.com/juduarte00), and [Junchao Chen](https://github.com/cjcchen)) + + +### v3.0 ([2021-09-30](https://github.com/resilientdb/resilientdb/releases/tag/v3.0)) + +**Implemented Enhancements:** +* GeoBFT Protocol Added ([Sajjad Rahnama](https://github.com/sajjadrahnama)) +* Work Queue structure changed ([Sajjad Rahnama](https://github.com/sajjadrahnama)) +* Refactoring, and added Statistics and Scripts ([Sajjad Rahnama](https://github.com/sajjadrahnama)) + + +### v2.0 ([2020-02-29](https://github.com/resilientdb/resilientdb/releases/tag/v2.0)) + +**Implemented Enhancements:** +* A GUI display for ResilientDB to ease user interaction and analysis. [#9](https://github.com/resilientdb/resilientdb/issues/9) ([Sajjad Rahnama](https://github.com/sajjadrahnama) and [RohanSogani](https://github.com/RohanSogani)) +* Added support for Smart Contracts with a Banking use case. [#7](https://github.com/resilientdb/resilientdb/issues/7) ([Sajjad Rahnama](https://github.com/sajjadrahnama)) +* Monitoring results for visualizing graphs using influxdb. [#8](https://github.com/resilientdb/resilientdb/issues/8) ([Sajjad Rahnama](https://github.com/sajjadrahnama), [Dhruv Krishnan](https://github.com/DhruvKrish) and [Priya Holani](https://github.com/Holani)) +* Added support for SQLite and provided a new representation for in-memory storage. [#6](https://github.com/resilientdb/resilientdb/issues/6) ([Sajjad Rahnama](https://github.com/sajjadrahnama)) + +**Fixed Bugs:** +* Bug in the Chain Initialization [#5](https://github.com/resilientdb/resilientdb/issues/5) ([Sajjad Rahnama](https://github.com/sajjadrahnama)) + + +### v1.1 ([2019-12-05](https://github.com/resilientdb/resilientdb/releases/tag/v1.1)) + +**Implemented Enhancements:** +* Defined class to represent ledger. [6b0fdc5](https://github.com/resilientdb/resilientdb/commit/56f500fe5e4749c45f57dc8e62d12bc7a218ce69) ([Suyash Gupta](https://github.com/gupta-suyash)) + +**Fixed Bugs:** +* Docker script fails to run for multiple client [#1](https://github.com/resilientdb/resilientdb/issues/1) ([RohanSogani](https://github.com/RohanSogani)) + +### v1.0 ([2019-11-24](https://github.com/resilientdb/resilientdb/releases/tag/v1.0)) + +Launched ResilientDB ([Suyash Gupta](https://github.com/gupta-suyash) and [Sajjad Rahnama](https://github.com/sajjadrahnama)) + + diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index ccd3a3bd3f..1685d4f19b 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -1,95 +1,95 @@ - - -# Contributor Covenant Code of Conduct - -## Our Pledge - -In the interest of fostering an open and welcoming environment, we as -contributors and maintainers pledge to making participation in our project and -our community a harassment-free experience for everyone, regardless of age, body -size, disability, ethnicity, sex characteristics, gender identity and expression, -level of experience, education, socio-economic status, nationality, personal -appearance, race, religion, or sexual identity and orientation. - -## Our Standards - -Examples of behavior that contributes to creating a positive environment -include: - -* Using welcoming and inclusive language -* Being respectful of differing viewpoints and experiences -* Gracefully accepting constructive criticism -* Focusing on what is best for the community -* Showing empathy towards other community members - -Examples of unacceptable behavior by participants include: - -* The use of sexualized language or imagery and unwelcome sexual attention or - advances -* Trolling, insulting/derogatory comments, and personal or political attacks -* Public or private harassment -* Publishing others' private information, such as a physical or electronic - address, without explicit permission -* Other conduct which could reasonably be considered inappropriate in a - professional setting - -## Our Responsibilities - -Project maintainers are responsible for clarifying the standards of acceptable -behavior and are expected to take appropriate and fair corrective action in -response to any instances of unacceptable behavior. - -Project maintainers have the right and responsibility to remove, edit, or -reject comments, commits, code, wiki edits, issues, and other contributions -that are not aligned to this Code of Conduct, or to ban temporarily or -permanently any contributor for other behaviors that they deem inappropriate, -threatening, offensive, or harmful. - -## Scope - -This Code of Conduct applies both within project spaces and in public spaces -when an individual is representing the project or its community. Examples of -representing a project or community include using an official project e-mail -address, posting via an official social media account, or acting as an appointed -representative at an online or offline event. Representation of a project may be -further defined and clarified by project maintainers. - -## Enforcement - -Instances of abusive, harassing, or otherwise unacceptable behavior may be -reported by contacting the project team at support@resilientdb.com. All -complaints will be reviewed and investigated and will result in a response that -is deemed necessary and appropriate to the circumstances. The project team is -obligated to maintain confidentiality with regard to the reporter of an incident. -Further details of specific enforcement policies may be posted separately. - -Project maintainers who do not follow or enforce the Code of Conduct in good -faith may face temporary or permanent repercussions as determined by other -members of the project's leadership. - -## Attribution - -This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, -available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html - -[homepage]: https://www.contributor-covenant.org - -For answers to common questions about this code of conduct, see -https://www.contributor-covenant.org/faq + + +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to making participation in our project and +our community a harassment-free experience for everyone, regardless of age, body +size, disability, ethnicity, sex characteristics, gender identity and expression, +level of experience, education, socio-economic status, nationality, personal +appearance, race, religion, or sexual identity and orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment +include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or + advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic + address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable +behavior and are expected to take appropriate and fair corrective action in +response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or +reject comments, commits, code, wiki edits, issues, and other contributions +that are not aligned to this Code of Conduct, or to ban temporarily or +permanently any contributor for other behaviors that they deem inappropriate, +threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces +when an individual is representing the project or its community. Examples of +representing a project or community include using an official project e-mail +address, posting via an official social media account, or acting as an appointed +representative at an online or offline event. Representation of a project may be +further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported by contacting the project team at support@resilientdb.com. All +complaints will be reviewed and investigated and will result in a response that +is deemed necessary and appropriate to the circumstances. The project team is +obligated to maintain confidentiality with regard to the reporter of an incident. +Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good +faith may face temporary or permanent repercussions as determined by other +members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, +available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html + +[homepage]: https://www.contributor-covenant.org + +For answers to common questions about this code of conduct, see +https://www.contributor-covenant.org/faq diff --git a/DISCLAIMER b/DISCLAIMER index d94e089d85..bf7063451c 100644 --- a/DISCLAIMER +++ b/DISCLAIMER @@ -1,22 +1,22 @@ -Apache ResilientDB is an effort undergoing incubation at the Apache Software -Foundation (ASF), sponsored by the Apache Incubator PMC. - -Incubation is required of all newly accepted projects until a further review -indicates that the infrastructure, communications, and decision making process -have stabilized in a manner consistent with other successful ASF projects. - -While incubation status is not necessarily a reflection of the completeness -or stability of the code, it does indicate that the project has yet to be -fully endorsed by the ASF. - -Some of the incubating project’s releases may not be fully compliant with ASF policy. -For example, releases may have incomplete or un-reviewed licensing conditions. -What follows is a list of known issues the project is currently aware of -(note that this list, by definition, is likely to be incomplete): - -If you are planning to incorporate this work into your product/project, please -be aware that you will need to conduct a thorough licensing review to determine -the overall implications of including this work. For the current status of this -project through the Apache Incubator visit: -https://incubator.apache.org/projects/resilientdb.html - +Apache ResilientDB is an effort undergoing incubation at the Apache Software +Foundation (ASF), sponsored by the Apache Incubator PMC. + +Incubation is required of all newly accepted projects until a further review +indicates that the infrastructure, communications, and decision making process +have stabilized in a manner consistent with other successful ASF projects. + +While incubation status is not necessarily a reflection of the completeness +or stability of the code, it does indicate that the project has yet to be +fully endorsed by the ASF. + +Some of the incubating project’s releases may not be fully compliant with ASF policy. +For example, releases may have incomplete or un-reviewed licensing conditions. +What follows is a list of known issues the project is currently aware of +(note that this list, by definition, is likely to be incomplete): + +If you are planning to incorporate this work into your product/project, please +be aware that you will need to conduct a thorough licensing review to determine +the overall implications of including this work. For the current status of this +project through the Apache Incubator visit: +https://incubator.apache.org/projects/resilientdb.html + diff --git a/Docker/Dockerfile b/Docker/Dockerfile index c68060dd21..62112d701c 100644 --- a/Docker/Dockerfile +++ b/Docker/Dockerfile @@ -1,56 +1,56 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -FROM ubuntu:20.04 - -ARG DEBIAN_FRONTEND=noninteractive - -# Update package lists and install required dependencies -RUN apt-get update && apt-get install -y \ - apt-transport-https \ - curl \ - gnupg \ - protobuf-compiler \ - rapidjson-dev \ - build-essential \ - openjdk-11-jdk \ - zip \ - unzip \ - clang-format - -# Install Bazel -RUN curl -fsSL https://bazel.build/bazel-release.pub.gpg | gpg --dearmor > bazel.gpg \ - && mv bazel.gpg /etc/apt/trusted.gpg.d/ \ - && echo "deb [arch=amd64] https://storage.googleapis.com/bazel-apt stable jdk1.8" | tee /etc/apt/sources.list.d/bazel.list \ - && curl https://bazel.build/bazel-release.pub.gpg | apt-key add - \ - && apt-get update && apt-get install -y bazel=6.0.0 \ - && rm /etc/apt/sources.list.d/bazel.list - -# Set the working directory -WORKDIR /app - -# Copy your project files to the container -COPY . /app - -# Build the project with Bazel -RUN bazel --version -RUN bazel build @com_github_bazelbuild_buildtools//buildifier:buildifier -RUN bazel build service/tools/kv/api_tools/kv_service_tools - -ENTRYPOINT ["./entrypoint.sh"] +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +FROM ubuntu:20.04 + +ARG DEBIAN_FRONTEND=noninteractive + +# Update package lists and install required dependencies +RUN apt-get update && apt-get install -y \ + apt-transport-https \ + curl \ + gnupg \ + protobuf-compiler \ + rapidjson-dev \ + build-essential \ + openjdk-11-jdk \ + zip \ + unzip \ + clang-format + +# Install Bazel +RUN curl -fsSL https://bazel.build/bazel-release.pub.gpg | gpg --dearmor > bazel.gpg \ + && mv bazel.gpg /etc/apt/trusted.gpg.d/ \ + && echo "deb [arch=amd64] https://storage.googleapis.com/bazel-apt stable jdk1.8" | tee /etc/apt/sources.list.d/bazel.list \ + && curl https://bazel.build/bazel-release.pub.gpg | apt-key add - \ + && apt-get update && apt-get install -y bazel=6.0.0 \ + && rm /etc/apt/sources.list.d/bazel.list + +# Set the working directory +WORKDIR /app + +# Copy your project files to the container +COPY . /app + +# Build the project with Bazel +RUN bazel --version +RUN bazel build @com_github_bazelbuild_buildtools//buildifier:buildifier +RUN bazel build service/tools/kv/api_tools/kv_service_tools + +ENTRYPOINT ["./entrypoint.sh"] diff --git a/Docker/Dockerfile_mac b/Docker/Dockerfile_mac index fb629b399d..39e93942df 100644 --- a/Docker/Dockerfile_mac +++ b/Docker/Dockerfile_mac @@ -1,53 +1,53 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -# Use a base image for ARM64 architecture -FROM arm64v8/ubuntu:20.04 - -ARG DEBIAN_FRONTEND=noninteractive - -# Update package lists and install required dependencies -RUN apt-get update && apt-get install -y \ - apt-transport-https \ - curl \ - gnupg \ - protobuf-compiler \ - rapidjson-dev \ - build-essential \ - openjdk-11-jdk \ - zip \ - unzip \ - clang-format - -# Install Bazelisk -RUN curl -Lo /usr/local/bin/bazel https://github.com/bazelbuild/bazelisk/releases/latest/download/bazelisk-linux-arm64 \ - && chmod +x /usr/local/bin/bazel - -# Set the working directory -WORKDIR /app - -# Copy your project files to the container -COPY . /app - -# Build the project with Bazel -RUN bazel --version -RUN bazel build @com_github_bazelbuild_buildtools//buildifier:buildifier -RUN bazel build service/tools/kv/api_tools/kv_service_tools - -ENTRYPOINT ["./entrypoint.sh"] +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +# Use a base image for ARM64 architecture +FROM arm64v8/ubuntu:20.04 + +ARG DEBIAN_FRONTEND=noninteractive + +# Update package lists and install required dependencies +RUN apt-get update && apt-get install -y \ + apt-transport-https \ + curl \ + gnupg \ + protobuf-compiler \ + rapidjson-dev \ + build-essential \ + openjdk-11-jdk \ + zip \ + unzip \ + clang-format + +# Install Bazelisk +RUN curl -Lo /usr/local/bin/bazel https://github.com/bazelbuild/bazelisk/releases/latest/download/bazelisk-linux-arm64 \ + && chmod +x /usr/local/bin/bazel + +# Set the working directory +WORKDIR /app + +# Copy your project files to the container +COPY . /app + +# Build the project with Bazel +RUN bazel --version +RUN bazel build @com_github_bazelbuild_buildtools//buildifier:buildifier +RUN bazel build service/tools/kv/api_tools/kv_service_tools + +ENTRYPOINT ["./entrypoint.sh"] diff --git a/INSTALL.sh b/INSTALL.sh index 9a5f742c6e..8cbade65b2 100755 --- a/INSTALL.sh +++ b/INSTALL.sh @@ -1,64 +1,64 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -#!/bin/bash - - -sudo apt update -sudo apt install apt-transport-https curl gnupg -y -sudo apt-get install protobuf-compiler -y -sudo apt-get install rapidjson-dev -y - -curl -fsSL https://bazel.build/bazel-release.pub.gpg | gpg --dearmor > bazel.gpg -sudo mv bazel.gpg /etc/apt/trusted.gpg.d/ -echo "deb [arch=amd64] https://storage.googleapis.com/bazel-apt stable jdk1.8" | sudo tee /etc/apt/sources.list.d/bazel.list -curl https://bazel.build/bazel-release.pub.gpg | sudo apt-key add - -sudo apt update && sudo apt install bazel=6.0.0 -y -sudo apt install clang-format -y -rm $PWD/.git/hooks/pre-push -ln -s $PWD/hooks/pre-push $PWD/.git/hooks/pre-push - -bazel --version -ret=$? - -if [[ $ret != "0" ]]; then - -sudo apt-get install build-essential openjdk-11-jdk zip unzip -y -rm bazel-6.0.0-dist.zip -rm -rf bazel_build -wget wget https://releases.bazel.build/6.0.0/release/bazel-6.0.0-dist.zip -mkdir -p bazel_build -mv bazel-6.0.0-dist.zip bazel_build/ -cd bazel_build - -unzip bazel-6.0.0-dist.zip - -export JAVA_HOME='/usr/lib/jvm/java-1.11.0-openjdk-arm64/' -env EXTRA_BAZEL_ARGS="--host_javabase=@local_jdk//:jdk" bash ./compile.sh -sudo cp output/bazel /usr/local/bin/ -cd .. -rm -rf bazel_build - -fi - -# install buildifier -bazel build @com_github_bazelbuild_buildtools//buildifier:buildifier - -sudo apt-get install python3.10-dev -y -sudo apt-get install python3-dev -y +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +#!/bin/bash + + +sudo apt update +sudo apt install apt-transport-https curl gnupg -y +sudo apt-get install protobuf-compiler -y +sudo apt-get install rapidjson-dev -y + +curl -fsSL https://bazel.build/bazel-release.pub.gpg | gpg --dearmor > bazel.gpg +sudo mv bazel.gpg /etc/apt/trusted.gpg.d/ +echo "deb [arch=amd64] https://storage.googleapis.com/bazel-apt stable jdk1.8" | sudo tee /etc/apt/sources.list.d/bazel.list +curl https://bazel.build/bazel-release.pub.gpg | sudo apt-key add - +sudo apt update && sudo apt install bazel=6.0.0 -y +sudo apt install clang-format -y +rm $PWD/.git/hooks/pre-push +ln -s $PWD/hooks/pre-push $PWD/.git/hooks/pre-push + +bazel --version +ret=$? + +if [[ $ret != "0" ]]; then + +sudo apt-get install build-essential openjdk-11-jdk zip unzip -y +rm bazel-6.0.0-dist.zip +rm -rf bazel_build +wget wget https://releases.bazel.build/6.0.0/release/bazel-6.0.0-dist.zip +mkdir -p bazel_build +mv bazel-6.0.0-dist.zip bazel_build/ +cd bazel_build + +unzip bazel-6.0.0-dist.zip + +export JAVA_HOME='/usr/lib/jvm/java-1.11.0-openjdk-arm64/' +env EXTRA_BAZEL_ARGS="--host_javabase=@local_jdk//:jdk" bash ./compile.sh +sudo cp output/bazel /usr/local/bin/ +cd .. +rm -rf bazel_build + +fi + +# install buildifier +bazel build @com_github_bazelbuild_buildtools//buildifier:buildifier + +sudo apt-get install python3.10-dev -y +sudo apt-get install python3-dev -y diff --git a/INSTALL/README.md b/INSTALL/README.md index 152601a92b..c13cad16ad 100755 --- a/INSTALL/README.md +++ b/INSTALL/README.md @@ -1,62 +1,62 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -# Prerequire -python3.10 - -pip - -``` -sudo apt update -sudo apt-get install python3.10-dev -y -sudo apt-get install python3-dev -y -sudo apt-get install python3-pip -y -``` - -# Install Protobuf -``` -cd protobuf -./install_protobuf.sh -``` - -# Install Bazel -``` -cd bazel -wget https://github.com/bazelbuild/bazelisk/releases/download/v1.8.1/bazelisk-darwin-amd64 -chmod +x bazelisk-darwin-amd64 -mkdir -p bin -mv bazelisk-darwin-amd64 bin/bazel - -bin/bazel --version -echo "export PATH="$PATH:$PWD/bin"" >> ~/.bashrc -. ~/.bashrc -``` -or -``` -cd bazel -./install_bazel.sh -echo "export PATH="$PATH:$PWD/bin"" >> ~/.bashrc -. ~/.bashrc -``` - - -test bazel -``` -bazel --version -``` +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +# Prerequire +python3.10 + +pip + +``` +sudo apt update +sudo apt-get install python3.10-dev -y +sudo apt-get install python3-dev -y +sudo apt-get install python3-pip -y +``` + +# Install Protobuf +``` +cd protobuf +./install_protobuf.sh +``` + +# Install Bazel +``` +cd bazel +wget https://github.com/bazelbuild/bazelisk/releases/download/v1.8.1/bazelisk-darwin-amd64 +chmod +x bazelisk-darwin-amd64 +mkdir -p bin +mv bazelisk-darwin-amd64 bin/bazel + +bin/bazel --version +echo "export PATH="$PATH:$PWD/bin"" >> ~/.bashrc +. ~/.bashrc +``` +or +``` +cd bazel +./install_bazel.sh +echo "export PATH="$PATH:$PWD/bin"" >> ~/.bashrc +. ~/.bashrc +``` + + +test bazel +``` +bazel --version +``` diff --git a/INSTALL/bazel/install_bazel.sh b/INSTALL/bazel/install_bazel.sh index 499de82097..80cb2b2735 100755 --- a/INSTALL/bazel/install_bazel.sh +++ b/INSTALL/bazel/install_bazel.sh @@ -1,27 +1,27 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -wget wget https://github.com/bazelbuild/bazelisk/releases/download/v1.8.1/bazelisk-linux-amd64 -chmod +x bazelisk-linux-amd64 -mkdir -p bin -mv bazelisk-linux-amd64 bin/bazel - -bin/bazel --version -echo "export PATH="$PATH:$PWD/bin"" >> ~/.bashrc -. ~/.bashrc +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +wget wget https://github.com/bazelbuild/bazelisk/releases/download/v1.8.1/bazelisk-linux-amd64 +chmod +x bazelisk-linux-amd64 +mkdir -p bin +mv bazelisk-linux-amd64 bin/bazel + +bin/bazel --version +echo "export PATH="$PATH:$PWD/bin"" >> ~/.bashrc +. ~/.bashrc diff --git a/INSTALL/protobuf/install_protobuf.sh b/INSTALL/protobuf/install_protobuf.sh index 66edc5ac72..1754293a04 100755 --- a/INSTALL/protobuf/install_protobuf.sh +++ b/INSTALL/protobuf/install_protobuf.sh @@ -1,20 +1,20 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -pip install protobuf +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +pip install protobuf diff --git a/LICENSE b/LICENSE index ad9b5c8b3a..4adfeb2467 100644 --- a/LICENSE +++ b/LICENSE @@ -1,235 +1,235 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - -================================================================ - -This product includes a number of dependencies with separate copyright notices -and license terms. Your use of these submodules is subject to the terms and -conditions of the following licenses. - -================================================================ -MIT licenses -================================================================ - -third_party/loc_script/src/index.js files from https://github.com/shadowmoose/GHA-LoC-Badge/blob/1.0.0/src/index.js - -MIT License - -Copyright (c) 2020 Mike - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +================================================================ + +This product includes a number of dependencies with separate copyright notices +and license terms. Your use of these submodules is subject to the terms and +conditions of the following licenses. + +================================================================ +MIT licenses +================================================================ + +third_party/loc_script/src/index.js files from https://github.com/shadowmoose/GHA-LoC-Badge/blob/1.0.0/src/index.js + +MIT License + +Copyright (c) 2020 Mike + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/NOTICE b/NOTICE index 6bb607f862..d849de00fb 100644 --- a/NOTICE +++ b/NOTICE @@ -1,6 +1,6 @@ -Apache ResilientDB (Incubating) -Copyright 2023-2025 The Apache Software Foundation - -This product includes software developed at -The Apache Software Foundation (http://www.apache.org/). - +Apache ResilientDB (Incubating) +Copyright 2023-2025 The Apache Software Foundation + +This product includes software developed at +The Apache Software Foundation (http://www.apache.org/). + diff --git a/README.md b/README.md index 664f009ad6..5e34844713 100644 --- a/README.md +++ b/README.md @@ -1,476 +1,476 @@ - - -![](https://img.shields.io/github/v/release/resilientdb/resilientdb) -![](https://img.shields.io/badge/language-c++-orange.svg) -![](https://img.shields.io/badge/platform-Ubuntu20.0+-lightgrey.svg) -![GitHub](https://img.shields.io/github/license/resilientdb/resilientdb) -![Generated Button](https://raw.githubusercontent.com/resilientdb/resilientdb/image-data/badge.svg) -![build](https://github.com/resilientdb/resilientdb/workflows/bazel-build%20CI/badge.svg) -![build](https://github.com/resilientdb/resilientdb/workflows/Unite%20Test/badge.svg) - - - -# ResilientDB: Global-Scale Sustainable Blockchain Fabric - -**[ResilientDB](https://resilientdb.com/)** is a **High Throughput Yielding Permissioned Blockchain Fabric** founded by **[ExpoLab](https://expolab.org/)** at **[UC Davis](https://www.ucdavis.edu/)** in 2018. ResilientDB advocates a **system-centric** design by adopting a **multi-threaded architecture** that encompasses **deep pipelines**. Further, ResilientDB **separates** the ordering of client transactions from their execution, which allows it to **process messages out-of-order**. - -# Downloads: -Download address for run-directly software package: https://downloads.apache.org/incubator/resilientdb/ - -### Quick Facts on ResilientDB -1. ResilientDB orders client transactions through a highly optimized implementation of the **[PBFT](https://pmg.csail.mit.edu/papers/osdi99.pdf)** [Castro and Liskov, 1998] protocol, which helps to achieve consensus among its replicas. ResilientDB also supports deploying other state-of-the-art consensus protocols *[release are planned]* such as **[GeoBFT](http://www.vldb.org/pvldb/vol13/p868-gupta.pdf)** [**[blog](https://blog.resilientdb.com/2023/03/07/GeoBFT.html), [released](https://github.com/resilientdb/resilientdb/releases/tag/nexres-v1.1.0)**], **[PoE](https://openproceedings.org/2021/conf/edbt/p111.pdf)**, **[RCC](https://arxiv.org/abs/1911.00837)**, **[RingBFT](https://openproceedings.org/2022/conf/edbt/paper-73.pdf)**, **[PoC](https://arxiv.org/abs/2302.02325)**, **[SpotLess](https://arxiv.org/abs/2302.02118)**, **[HotStuff](https://arxiv.org/abs/1803.05069)**, and **[DAG](https://arxiv.org/pdf/2105.11827.pdf)**. -2. ResilientDB requires deploying at least **3f+1** replicas, where **f (f > 0)** is the maximum number of arbitrary (or malicious) replicas. -3. ResilientDB supports primary-backup architecture, which designates one of the replicas as the **primary** (replica with identifier **0**). The primary replica initiates consensus on a client transaction, while backups agree to follow a non-malicious primary. -4. ResilientDB exposes a wide range of interfaces such as a **Key-Value** store, **Smart Contracts**, **UTXO**, and **Python SDK**. Following are some of the decentralized applications (DApps) built on top of ResilientDB: **[NFT Marketplace](https://nft.resilientdb.com/)** and **[Debitable](https://debitable.resilientdb.com/)**. -5. To persist blockchain, chain state, and metadata, ResilientDB provides durability through **LevelDB**. -6. ResilientDB provides access to a seamless **GUI display** for deployment and maintenance, and supports **Grafana** for plotting monitoring data. -7. **[Historial Facts]** The ResilientDB project was founded by **[Mohammad Sadoghi](https://expolab.org/)** along with his students ([Suyash Gupta](https://gupta-suyash.github.io/index.html) as the lead Architect, [Sajjad Rahnama](https://sajjadrahnama.com/) as the lead System Designer, and [Jelle Hellings](https://www.jhellings.nl/)) at **[UC Davis](https://www.ucdavis.edu/)** in 2018 and was open-sourced in late 2019. On September 30, 2021, we released ResilientDB v-3.0. In 2022, ResilientDB was completely re-written and re-architected ([Junchao Chen](https://github.com/cjcchen) as the lead Architect, [Dakai Kang](https://github.com/DakaiKang) as the lead Recovery Architect along with the entire [NexRes Team](https://expolab.resilientdb.com/)), paving the way for a new sustainable foundation, referred to as NexRes (Next Generation ResilientDB). Thus, on September 30, 2022, NexRes-v1.0.0 was born, marking a new beginning for **[ResilientDB](https://resilientdb.com/)**. On October 21, 2023, **[ResilientDB](https://cwiki.apache.org/confluence/display/INCUBATOR/ResilientDBProposal)** was officially accepted into **[Apache Incubation](https://incubator.apache.org/projects/resilientdb.html)**. - -
- - - -
- ---- - - -## Online Documentation: - -The latest ResilientDB documentation, including a programming guide, is available on our **[blog repository](https://blog.resilientdb.com/archive.html?tag=NexRes)**. This README file provides basic setup instructions. - -#### Table of Contents -1. Software Stack Architecture - - SDK, Interface/API, Platform, Execution, and Chain Layers - - Detailed API Documentation: **[Core](https://api.resilientdb.com/)** and **[SDK](https://sdk.resilientdb.com/)** -2. **SDK Layer:** **[Python SDK](https://blog.resilientdb.com/2023/02/01/UsingPythonSDK.html)** and **[Wallet - ResVault](https://blog.resilientdb.com/2023/09/21/ResVault.html)** -3. **Interface Layer:** **[Key-Value](https://blog.resilientdb.com/2022/09/28/GettingStartedNexRes.html)**, **[Solidity Smart Contract](https://blog.resilientdb.com/2023/01/15/GettingStartedSmartContract.html)**, **[Unspent Transaction Output (UTXO) Model](https://blog.resilientdb.com/2023/02/12/UtxoOnNexres.html)**, ResilientDB Database Connectivity (RDBC) API -4. **Platform Layer:** **[Consensus Manager Architecture (ordering, recovery, network, chain management)](https://blog.resilientdb.com/2022/09/27/What_Is_NexRes.html)** - - **[Recovery & Checkpoint Design](https://blog.resilientdb.com/2023/08/22/ViewChangeInNexRes.html)** -5. **Execution Layer:** Transaction Manager Design (Runtime) -6. **Chain Layer:** Chain State & Storage Manager Design (**[durability](https://blog.resilientdb.com/2023/02/15/NexResDurabilityLayer.html)**) -7. **[Installing & Deploying ResilientDB](https://blog.resilientdb.com/2022/09/28/GettingStartedNexRes.html)** - - Build Your First Application: **[KV Service](https://blog.resilientdb.com/2022/09/28/StartYourApplication.html)**, **[UTXO](https://blog.resilientdb.com/2023/02/12/GettingStartedOnUtxo.html)** - - Dashboard: **[Monitoring](https://blog.resilientdb.com/2022/12/06/NexResGrafanaDashboardInstallation.html)**, **[Deployment](https://blog.resilientdb.com/2022/12/06/DeployGrafanaDashboardOnOracleCloud.html)**, **[Data Pipeline](https://blog.resilientdb.com/2022/12/12/NexResGrafanaDashboardPipeline.html)** - - System Parameters & Configuration - - Continuous Integration & Testing - -
- -
- -## OS Requirements -Ubuntu 20+ - ---- - -## Project Structure - -``` -incubator-resilientdb/ -├── api/ # API layer and interfaces -├── benchmark/ # Performance benchmarking tools -│ └── protocols/ # Protocol-specific benchmarks -│ ├── pbft/ # PBFT protocol benchmarks -│ └── poe/ # PoE protocol benchmarks -├── chain/ # Blockchain chain management -│ ├── state/ # Chain state management -│ └── storage/ # Storage layer (LevelDB, etc.) -├── common/ # Common utilities and libraries -│ ├── crypto/ # Cryptographic functions -│ ├── lru/ # LRU cache implementation -│ ├── proto/ # Protocol buffer definitions -│ ├── test/ # Testing utilities -│ └── utils/ # General utilities -├── ecosystem/ # Ecosystem components (git subtrees) -│ ├── cache/ # Caching implementations -│ │ ├── resilient-node-cache/ # Node.js caching -│ │ └── resilient-python-cache/ # Python caching -│ ├── deployment/ # Deployment and infrastructure -│ │ ├── ansible/ # Ansible playbooks -│ │ └── orbit/ # Orbit deployment tool -│ ├── graphql/ # GraphQL service -│ ├── monitoring/ # Monitoring and observability -│ │ ├── reslens/ # ResLens monitoring tool -│ │ └── reslens-middleware/ # ResLens middleware -│ ├── sdk/ # Software Development Kits -│ │ ├── resdb-orm/ # Python ORM -│ │ ├── resvault-sdk/ # ResVault SDK -│ │ └── rust-sdk/ # Rust SDK -│ ├── smart-contract/ # Smart contract ecosystem -│ │ ├── rescontract/ # ResContract repository -│ │ ├── resilient-contract-kit/ # Contract development toolkit -│ │ └── smart-contract-graphql/ # Smart contract GraphQL service -│ └── tools/ # Development and operational tools -│ ├── create-resilient-app/ # App scaffolding tool -│ └── resvault/ # ResVault tool -├── executor/ # Transaction execution engine -│ ├── common/ # Common execution utilities -│ ├── contract/ # Smart contract execution -│ ├── kv/ # Key-value execution -│ └── utxo/ # UTXO execution -├── interface/ # Client interfaces and APIs -│ ├── common/ # Common interface utilities -│ ├── contract/ # Smart contract interface -│ ├── kv/ # Key-value interface -│ ├── rdbc/ # ResilientDB Database Connectivity -│ └── utxo/ # UTXO interface -├── monitoring/ # Core monitoring components -├── platform/ # Core platform components -│ ├── common/ # Common platform utilities -│ ├── config/ # Configuration management -│ ├── consensus/ # Consensus protocols -│ │ ├── checkpoint/ # Checkpoint management -│ │ ├── execution/ # Transaction execution -│ │ ├── ordering/ # Transaction ordering -│ │ └── recovery/ # Recovery mechanisms -│ ├── networkstrate/ # Network strategy layer -│ ├── proto/ # Protocol definitions -│ ├── rdbc/ # RDBC implementation -│ └── statistic/ # Statistics and metrics -├── proto/ # Protocol buffer definitions -│ ├── contract/ # Smart contract protos -│ ├── kv/ # Key-value protos -│ └── utxo/ # UTXO protos -├── scripts/ # Deployment and utility scripts -│ └── deploy/ # Deployment scripts -├── service/ # Service implementations -│ ├── contract/ # Smart contract service -│ ├── kv/ # Key-value service -│ ├── tools/ # Service tools -│ ├── utils/ # Service utilities -│ └── utxo/ # UTXO service -├── third_party/ # Third-party dependencies -└── tools/ # Development and build tools -``` - -**Note**: The `ecosystem/` directory contains git subtrees for ecosystem components. You can clone the repository without ecosystem components for a smaller, faster download. See [ecosystem/README.md](ecosystem/README.md) for details. - -## Build and Deploy ResilientDB - -Next, we show how to quickly build ResilientDB and deploy 4 replicas and 1 client proxy on your local machine. The proxy acts as an interface for all the clients. It batches client requests and forwards these batches to the replica designated as the leader. The 4 replicas participate in the PBFT consensus to order and execute these batches. Post execution, they return the response to the leader. - -Install dependencies: - - ./INSTALL.sh - -For non-root users, see [INSTALL/README.md](https://github.com/apache/incubator-resilientdb/blob/master/INSTALL/README.md) - -Run ResilientDB (Providing a Key-Value Service): - - ./service/tools/kv/server_tools/start_kv_service.sh - -- This script starts 4 replicas and 1 client. Each replica instantiates a key-value store. - -Build Interactive Tools: - - bazel build service/tools/kv/api_tools/kv_service_tools - -### Issues ### -If you cannot build the project successfully, try to reduce the bazel jobs [here]( -https://github.com/apache/incubator-resilientdb/blob/master/.bazelrc#L1). - -## Functions ## -ResilientDB supports two types of functions: version-based and non-version-based. -Version-based functions will leverage versions to protect each update, versions must be obtained before updating a key. - -***Note***: Version-based functions are not compatible with non-version-based functions. Do not use both in your applications. - -We show the functions below and show how to use [kv_service_tools](service/tools/kv/api_tools/kv_service_tools.cpp) to test the function. - -### Version-Based Functions ### -#### Get #### -Obtain the value of `key` with a specific version `v`. - - kv_service_tools --config config_file --cmd get_with_version --key key --version v - -| parameters | descriptions | -| ---- | ---- | -| config | the path of the client config which points to the db entrance | -| cmd | get_with_version | -| key | the key you want to obtain | -| version | the version you want to obtain. (If the `v` is 0, it will return the latest version | - - -Example: - - bazel-bin/service/tools/kv/api_tools/kv_service_tools --config service/tools/config/interface/service.config --cmd get_with_version --key key1 --version 0 - -Results: -> get key = key1, value = value: "v2" -> version: 2 - -#### Set #### -Set `value` to the key `key` based on version `v`. - - kv_service_tools --config config_file --cmd set_with_version --key key --version v --value value - -| parameters | descriptions | -| ---- | ---- | -| config | the path of the client config which points to the db entrance | -| cmd | set_with_version | -| key | the key you want to set | -| version | the version you have obtained. (If the version has been changed during the update, the transaction will be ignored) | -| value | the new value | - -Example: - - bazel-bin/service/tools/kv/api_tools/kv_service_tools --config service/tools/config/interface/service.config --cmd set_with_version --key key1 --version 0 --value v1 - -Results: -> set key = key1, value = v3, version = 2 done, ret = 0 -> -> current value = value: "v3" -> version: 3 - -#### Get Key History #### -Obtain the update history of key `key` within the versions [`v1`, `v2`]. - - kv_service_tools --config config_file --cmd get_history --key key --min_version v1 --max_version v2 - - -| parameters | descriptions | -| ---- | ---- | -| config | the path of the client config which points to the db entrance | -| cmd | get_history | -| key | the key you want to obtain | -| min_version | the minimum version you want to obtain | -| max_version | the maximum version you want to obtain | - -Example: - - bazel-bin/service/tools/kv/api_tools/kv_service_tools --config service/tools/config/interface/service.config --cmd get_history --key key1 --min_version 1 --max_version 2 - -Results: - -> get history key = key1, min version = 1, max version = 2
-> value =
-> item {
->   key: "key1"
->   value_info {
->    value: "v1"
->    version: 2
->  }
-> }
-> item {
->   key: "key1"
->   value_info {
->    value: "v0"
->    version: 1
->  }
-> } - -#### Get Top #### -Obtain the recent `top_number` history of the key `key`. - - kv_service_tools --config config_path --cmd get_top --key key --top top_number - -| parameters | descriptions | -| ---- | ---- | -| config | the path of the client config which points to the db entrance | -| cmd | get_top | -| key | the key you want to obtain | -| top | the number of the recent updates | - -Example: - - bazel-bin/service/tools/kv/api_tools/kv_service_tools --config service/tools/config/interface/service.config --cmd get_top --key key1 --top 1 - -Results: - ->key = key1, top 1
-> value =
-> item {
-> key: "key1"
->  value_info {
->    value: "v2"
->    version: 3
->  }
->} - -#### Get Key Range #### -Obtain the values of the keys in the ranges [`key1`, `key2`]. Do not use this function in your practice code - - kv_service_tools --config config_file --cmd get_key_range_with_version --min_key key1 --max_key key2 - -| parameters | descriptions | -| ---- | ---- | -| config | the path of the client config which points to the db entrance | -| cmd | get_key_range_with_version | -| min_key | the minimum key | -| max_key | the maximum key | - -Example: - - bazel-bin/service/tools/kv/api_tools/kv_service_tools --config service/tools/config/interface/service.config --cmd get_key_range_with_version --min_key key1 --max_key key3 - -Results: - ->min key = key1 max key = key2
-> getrange value =
-> item {
->   key: "key1"
->   value_info {
->    value: "v0"
->    version: 1
->   }
-> }
-> item {
->   key: "key2"
->   value_info {
->    value: "v1"
->    version: 1
->   }
->} - - -### Non-Version-Based Function ### -#### Set ##### -Set `value` to the key `key`. - - kv_service_tools --config config_file --cmd set --key key --value value - -| parameters | descriptions | -| ---- | ---- | -| config | the path of the client config which points to the db entrance | -| cmd | set | -| key | the key you want to set | -| value | the new value | - -Example: - - bazel-bin/service/tools/kv/api_tools/kv_service_tools --config service/tools/config/interface/service.config --cmd set --key key1 --value value1 - -Results: -> set key = key1, value = v1, done, ret = 0 - -#### Get #### -Obtain the value of `key`. - - kv_service_tools --config config_file --cmd get --key key - -| parameters | descriptions | -| ---- | ---- | -| config | the path of the client config which points to the db entrance | -| cmd | get | -| key | the key you want to obtain | - -Example: - - bazel-bin/service/tools/kv/api_tools/kv_service_tools --config service/tools/config/interface/service.config --cmd get --key key1 - -Results: -> get key = key1, value = "v2" - - -#### Get Key Range #### -Obtain the values of the keys in the ranges [`key1`, `key2`]. Do not use this function in your practice code - - kv_service_tools --config config_path --cmd get_key_range --min_key key1 --max_key key2 - -| parameters | descriptions | -| ---- | ---- | -| config | the path of the client config which points to the db entrance | -| cmd | get_key_range | -| min_key | the minimum key | -| max_key | the maximum key | - -Example: - - bazel-bin/service/tools/kv/api_tools/kv_service_tools --config service/tools/config/interface/service.config --cmd get_key_range --min_key key1 --max_key key3 - -Results: -> getrange min key = key1, max key = key3
-> value = [v3,v2,v1] - - -## Deployment Script - -We also provide access to a [deployment script](https://github.com/resilientdb/resilientdb/tree/master/scripts/deploy) that allows deployment on distinct machines. - -## Deploy via Docker - -1. **Install Docker** - Before getting started, make sure you have Docker installed on your system. If you don't have Docker already, you can download and install it from the official [Docker website](https://www.docker.com/products/docker-desktop/). - -2. **Pull the Latest ResilientDB Image** - Choose the appropriate [ResilientDB image](https://hub.docker.com/repository/docker/expolab/resdb/general) for your machine's architecture: - - - For amd architecture, run: - ```shell - docker pull expolab/resdb:amd64 - ``` - - - For Apple Silicon (M1/M2) architecture, run: - ```shell - docker pull expolab/resdb:arm64 - ``` - -3. **Run a Container with the Pulled Image** - Launch a Docker container using the ResilientDB image you just pulled: - - - For amd architecture, run: - ```shell - docker run -d --name myserver expolab/resdb:amd64 - ``` - - - For Apple Silicon (M1/M2) architecture, run: - ```shell - docker run -d --name myserver expolab/resdb:arm64 - ``` - -4. **Test with Set and Get Commands** - Exec into the running server: - ```shell - docker exec -it myserver bash - ``` - -5. **NOTE: If you encounter a Connection Refused error** - - Run the following command within the container: - ```shell - ./service/tools/kv/server_tools/start_kv_service.sh - ``` - - Verify the functionality of the service by performing set and get operations provided above [functions](README.md#functions). - - -## Custom Ports ## -When starting the service locally, current services are running on 10000 port-base with 5 services where the server config is located [here](https://github.com/apache/incubator-resilientdb/blob/master/service/tools/config/server/server.config) - -If you want to change the setting, you need to generate the certificates. - -Go the the workspace where the resilientdb repo is localted. - -Change the setting parameters here and run the script: - ```shell - ./service/tools/kv/server_tools/generate_config.sh - ``` - -Then re-run the start script: - ```shell - ./service/tools/kv/server_tools/start_kv_service.sh - ``` - - - -## Smart Contract ## -If you want to use smart contracts, please go to: -https://blog.resilientdb.com/2025/02/14/GettingStartedSmartContract.html + + +![](https://img.shields.io/github/v/release/resilientdb/resilientdb) +![](https://img.shields.io/badge/language-c++-orange.svg) +![](https://img.shields.io/badge/platform-Ubuntu20.0+-lightgrey.svg) +![GitHub](https://img.shields.io/github/license/resilientdb/resilientdb) +![Generated Button](https://raw.githubusercontent.com/resilientdb/resilientdb/image-data/badge.svg) +![build](https://github.com/resilientdb/resilientdb/workflows/bazel-build%20CI/badge.svg) +![build](https://github.com/resilientdb/resilientdb/workflows/Unite%20Test/badge.svg) + + + +# ResilientDB: Global-Scale Sustainable Blockchain Fabric + +**[ResilientDB](https://resilientdb.com/)** is a **High Throughput Yielding Permissioned Blockchain Fabric** founded by **[ExpoLab](https://expolab.org/)** at **[UC Davis](https://www.ucdavis.edu/)** in 2018. ResilientDB advocates a **system-centric** design by adopting a **multi-threaded architecture** that encompasses **deep pipelines**. Further, ResilientDB **separates** the ordering of client transactions from their execution, which allows it to **process messages out-of-order**. + +# Downloads: +Download address for run-directly software package: https://downloads.apache.org/incubator/resilientdb/ + +### Quick Facts on ResilientDB +1. ResilientDB orders client transactions through a highly optimized implementation of the **[PBFT](https://pmg.csail.mit.edu/papers/osdi99.pdf)** [Castro and Liskov, 1998] protocol, which helps to achieve consensus among its replicas. ResilientDB also supports deploying other state-of-the-art consensus protocols *[release are planned]* such as **[GeoBFT](http://www.vldb.org/pvldb/vol13/p868-gupta.pdf)** [**[blog](https://blog.resilientdb.com/2023/03/07/GeoBFT.html), [released](https://github.com/resilientdb/resilientdb/releases/tag/nexres-v1.1.0)**], **[PoE](https://openproceedings.org/2021/conf/edbt/p111.pdf)**, **[RCC](https://arxiv.org/abs/1911.00837)**, **[RingBFT](https://openproceedings.org/2022/conf/edbt/paper-73.pdf)**, **[PoC](https://arxiv.org/abs/2302.02325)**, **[SpotLess](https://arxiv.org/abs/2302.02118)**, **[HotStuff](https://arxiv.org/abs/1803.05069)**, and **[DAG](https://arxiv.org/pdf/2105.11827.pdf)**. +2. ResilientDB requires deploying at least **3f+1** replicas, where **f (f > 0)** is the maximum number of arbitrary (or malicious) replicas. +3. ResilientDB supports primary-backup architecture, which designates one of the replicas as the **primary** (replica with identifier **0**). The primary replica initiates consensus on a client transaction, while backups agree to follow a non-malicious primary. +4. ResilientDB exposes a wide range of interfaces such as a **Key-Value** store, **Smart Contracts**, **UTXO**, and **Python SDK**. Following are some of the decentralized applications (DApps) built on top of ResilientDB: **[NFT Marketplace](https://nft.resilientdb.com/)** and **[Debitable](https://debitable.resilientdb.com/)**. +5. To persist blockchain, chain state, and metadata, ResilientDB provides durability through **LevelDB**. +6. ResilientDB provides access to a seamless **GUI display** for deployment and maintenance, and supports **Grafana** for plotting monitoring data. +7. **[Historial Facts]** The ResilientDB project was founded by **[Mohammad Sadoghi](https://expolab.org/)** along with his students ([Suyash Gupta](https://gupta-suyash.github.io/index.html) as the lead Architect, [Sajjad Rahnama](https://sajjadrahnama.com/) as the lead System Designer, and [Jelle Hellings](https://www.jhellings.nl/)) at **[UC Davis](https://www.ucdavis.edu/)** in 2018 and was open-sourced in late 2019. On September 30, 2021, we released ResilientDB v-3.0. In 2022, ResilientDB was completely re-written and re-architected ([Junchao Chen](https://github.com/cjcchen) as the lead Architect, [Dakai Kang](https://github.com/DakaiKang) as the lead Recovery Architect along with the entire [NexRes Team](https://expolab.resilientdb.com/)), paving the way for a new sustainable foundation, referred to as NexRes (Next Generation ResilientDB). Thus, on September 30, 2022, NexRes-v1.0.0 was born, marking a new beginning for **[ResilientDB](https://resilientdb.com/)**. On October 21, 2023, **[ResilientDB](https://cwiki.apache.org/confluence/display/INCUBATOR/ResilientDBProposal)** was officially accepted into **[Apache Incubation](https://incubator.apache.org/projects/resilientdb.html)**. + +
+ + + +
+ +--- + + +## Online Documentation: + +The latest ResilientDB documentation, including a programming guide, is available on our **[blog repository](https://blog.resilientdb.com/archive.html?tag=NexRes)**. This README file provides basic setup instructions. + +#### Table of Contents +1. Software Stack Architecture + - SDK, Interface/API, Platform, Execution, and Chain Layers + - Detailed API Documentation: **[Core](https://api.resilientdb.com/)** and **[SDK](https://sdk.resilientdb.com/)** +2. **SDK Layer:** **[Python SDK](https://blog.resilientdb.com/2023/02/01/UsingPythonSDK.html)** and **[Wallet - ResVault](https://blog.resilientdb.com/2023/09/21/ResVault.html)** +3. **Interface Layer:** **[Key-Value](https://blog.resilientdb.com/2022/09/28/GettingStartedNexRes.html)**, **[Solidity Smart Contract](https://blog.resilientdb.com/2023/01/15/GettingStartedSmartContract.html)**, **[Unspent Transaction Output (UTXO) Model](https://blog.resilientdb.com/2023/02/12/UtxoOnNexres.html)**, ResilientDB Database Connectivity (RDBC) API +4. **Platform Layer:** **[Consensus Manager Architecture (ordering, recovery, network, chain management)](https://blog.resilientdb.com/2022/09/27/What_Is_NexRes.html)** + - **[Recovery & Checkpoint Design](https://blog.resilientdb.com/2023/08/22/ViewChangeInNexRes.html)** +5. **Execution Layer:** Transaction Manager Design (Runtime) +6. **Chain Layer:** Chain State & Storage Manager Design (**[durability](https://blog.resilientdb.com/2023/02/15/NexResDurabilityLayer.html)**) +7. **[Installing & Deploying ResilientDB](https://blog.resilientdb.com/2022/09/28/GettingStartedNexRes.html)** + - Build Your First Application: **[KV Service](https://blog.resilientdb.com/2022/09/28/StartYourApplication.html)**, **[UTXO](https://blog.resilientdb.com/2023/02/12/GettingStartedOnUtxo.html)** + - Dashboard: **[Monitoring](https://blog.resilientdb.com/2022/12/06/NexResGrafanaDashboardInstallation.html)**, **[Deployment](https://blog.resilientdb.com/2022/12/06/DeployGrafanaDashboardOnOracleCloud.html)**, **[Data Pipeline](https://blog.resilientdb.com/2022/12/12/NexResGrafanaDashboardPipeline.html)** + - System Parameters & Configuration + - Continuous Integration & Testing + +
+ +
+ +## OS Requirements +Ubuntu 20+ + +--- + +## Project Structure + +``` +incubator-resilientdb/ +├── api/ # API layer and interfaces +├── benchmark/ # Performance benchmarking tools +│ └── protocols/ # Protocol-specific benchmarks +│ ├── pbft/ # PBFT protocol benchmarks +│ └── poe/ # PoE protocol benchmarks +├── chain/ # Blockchain chain management +│ ├── state/ # Chain state management +│ └── storage/ # Storage layer (LevelDB, etc.) +├── common/ # Common utilities and libraries +│ ├── crypto/ # Cryptographic functions +│ ├── lru/ # LRU cache implementation +│ ├── proto/ # Protocol buffer definitions +│ ├── test/ # Testing utilities +│ └── utils/ # General utilities +├── ecosystem/ # Ecosystem components (git subtrees) +│ ├── cache/ # Caching implementations +│ │ ├── resilient-node-cache/ # Node.js caching +│ │ └── resilient-python-cache/ # Python caching +│ ├── deployment/ # Deployment and infrastructure +│ │ ├── ansible/ # Ansible playbooks +│ │ └── orbit/ # Orbit deployment tool +│ ├── graphql/ # GraphQL service +│ ├── monitoring/ # Monitoring and observability +│ │ ├── reslens/ # ResLens monitoring tool +│ │ └── reslens-middleware/ # ResLens middleware +│ ├── sdk/ # Software Development Kits +│ │ ├── resdb-orm/ # Python ORM +│ │ ├── resvault-sdk/ # ResVault SDK +│ │ └── rust-sdk/ # Rust SDK +│ ├── smart-contract/ # Smart contract ecosystem +│ │ ├── rescontract/ # ResContract repository +│ │ ├── resilient-contract-kit/ # Contract development toolkit +│ │ └── smart-contract-graphql/ # Smart contract GraphQL service +│ └── tools/ # Development and operational tools +│ ├── create-resilient-app/ # App scaffolding tool +│ └── resvault/ # ResVault tool +├── executor/ # Transaction execution engine +│ ├── common/ # Common execution utilities +│ ├── contract/ # Smart contract execution +│ ├── kv/ # Key-value execution +│ └── utxo/ # UTXO execution +├── interface/ # Client interfaces and APIs +│ ├── common/ # Common interface utilities +│ ├── contract/ # Smart contract interface +│ ├── kv/ # Key-value interface +│ ├── rdbc/ # ResilientDB Database Connectivity +│ └── utxo/ # UTXO interface +├── monitoring/ # Core monitoring components +├── platform/ # Core platform components +│ ├── common/ # Common platform utilities +│ ├── config/ # Configuration management +│ ├── consensus/ # Consensus protocols +│ │ ├── checkpoint/ # Checkpoint management +│ │ ├── execution/ # Transaction execution +│ │ ├── ordering/ # Transaction ordering +│ │ └── recovery/ # Recovery mechanisms +│ ├── networkstrate/ # Network strategy layer +│ ├── proto/ # Protocol definitions +│ ├── rdbc/ # RDBC implementation +│ └── statistic/ # Statistics and metrics +├── proto/ # Protocol buffer definitions +│ ├── contract/ # Smart contract protos +│ ├── kv/ # Key-value protos +│ └── utxo/ # UTXO protos +├── scripts/ # Deployment and utility scripts +│ └── deploy/ # Deployment scripts +├── service/ # Service implementations +│ ├── contract/ # Smart contract service +│ ├── kv/ # Key-value service +│ ├── tools/ # Service tools +│ ├── utils/ # Service utilities +│ └── utxo/ # UTXO service +├── third_party/ # Third-party dependencies +└── tools/ # Development and build tools +``` + +**Note**: The `ecosystem/` directory contains git subtrees for ecosystem components. You can clone the repository without ecosystem components for a smaller, faster download. See [ecosystem/README.md](ecosystem/README.md) for details. + +## Build and Deploy ResilientDB + +Next, we show how to quickly build ResilientDB and deploy 4 replicas and 1 client proxy on your local machine. The proxy acts as an interface for all the clients. It batches client requests and forwards these batches to the replica designated as the leader. The 4 replicas participate in the PBFT consensus to order and execute these batches. Post execution, they return the response to the leader. + +Install dependencies: + + ./INSTALL.sh + +For non-root users, see [INSTALL/README.md](https://github.com/apache/incubator-resilientdb/blob/master/INSTALL/README.md) + +Run ResilientDB (Providing a Key-Value Service): + + ./service/tools/kv/server_tools/start_kv_service.sh + +- This script starts 4 replicas and 1 client. Each replica instantiates a key-value store. + +Build Interactive Tools: + + bazel build service/tools/kv/api_tools/kv_service_tools + +### Issues ### +If you cannot build the project successfully, try to reduce the bazel jobs [here]( +https://github.com/apache/incubator-resilientdb/blob/master/.bazelrc#L1). + +## Functions ## +ResilientDB supports two types of functions: version-based and non-version-based. +Version-based functions will leverage versions to protect each update, versions must be obtained before updating a key. + +***Note***: Version-based functions are not compatible with non-version-based functions. Do not use both in your applications. + +We show the functions below and show how to use [kv_service_tools](service/tools/kv/api_tools/kv_service_tools.cpp) to test the function. + +### Version-Based Functions ### +#### Get #### +Obtain the value of `key` with a specific version `v`. + + kv_service_tools --config config_file --cmd get_with_version --key key --version v + +| parameters | descriptions | +| ---- | ---- | +| config | the path of the client config which points to the db entrance | +| cmd | get_with_version | +| key | the key you want to obtain | +| version | the version you want to obtain. (If the `v` is 0, it will return the latest version | + + +Example: + + bazel-bin/service/tools/kv/api_tools/kv_service_tools --config service/tools/config/interface/service.config --cmd get_with_version --key key1 --version 0 + +Results: +> get key = key1, value = value: "v2" +> version: 2 + +#### Set #### +Set `value` to the key `key` based on version `v`. + + kv_service_tools --config config_file --cmd set_with_version --key key --version v --value value + +| parameters | descriptions | +| ---- | ---- | +| config | the path of the client config which points to the db entrance | +| cmd | set_with_version | +| key | the key you want to set | +| version | the version you have obtained. (If the version has been changed during the update, the transaction will be ignored) | +| value | the new value | + +Example: + + bazel-bin/service/tools/kv/api_tools/kv_service_tools --config service/tools/config/interface/service.config --cmd set_with_version --key key1 --version 0 --value v1 + +Results: +> set key = key1, value = v3, version = 2 done, ret = 0 +> +> current value = value: "v3" +> version: 3 + +#### Get Key History #### +Obtain the update history of key `key` within the versions [`v1`, `v2`]. + + kv_service_tools --config config_file --cmd get_history --key key --min_version v1 --max_version v2 + + +| parameters | descriptions | +| ---- | ---- | +| config | the path of the client config which points to the db entrance | +| cmd | get_history | +| key | the key you want to obtain | +| min_version | the minimum version you want to obtain | +| max_version | the maximum version you want to obtain | + +Example: + + bazel-bin/service/tools/kv/api_tools/kv_service_tools --config service/tools/config/interface/service.config --cmd get_history --key key1 --min_version 1 --max_version 2 + +Results: + +> get history key = key1, min version = 1, max version = 2
+> value =
+> item {
+>   key: "key1"
+>   value_info {
+>    value: "v1"
+>    version: 2
+>  }
+> }
+> item {
+>   key: "key1"
+>   value_info {
+>    value: "v0"
+>    version: 1
+>  }
+> } + +#### Get Top #### +Obtain the recent `top_number` history of the key `key`. + + kv_service_tools --config config_path --cmd get_top --key key --top top_number + +| parameters | descriptions | +| ---- | ---- | +| config | the path of the client config which points to the db entrance | +| cmd | get_top | +| key | the key you want to obtain | +| top | the number of the recent updates | + +Example: + + bazel-bin/service/tools/kv/api_tools/kv_service_tools --config service/tools/config/interface/service.config --cmd get_top --key key1 --top 1 + +Results: + +>key = key1, top 1
+> value =
+> item {
+> key: "key1"
+>  value_info {
+>    value: "v2"
+>    version: 3
+>  }
+>} + +#### Get Key Range #### +Obtain the values of the keys in the ranges [`key1`, `key2`]. Do not use this function in your practice code + + kv_service_tools --config config_file --cmd get_key_range_with_version --min_key key1 --max_key key2 + +| parameters | descriptions | +| ---- | ---- | +| config | the path of the client config which points to the db entrance | +| cmd | get_key_range_with_version | +| min_key | the minimum key | +| max_key | the maximum key | + +Example: + + bazel-bin/service/tools/kv/api_tools/kv_service_tools --config service/tools/config/interface/service.config --cmd get_key_range_with_version --min_key key1 --max_key key3 + +Results: + +>min key = key1 max key = key2
+> getrange value =
+> item {
+>   key: "key1"
+>   value_info {
+>    value: "v0"
+>    version: 1
+>   }
+> }
+> item {
+>   key: "key2"
+>   value_info {
+>    value: "v1"
+>    version: 1
+>   }
+>} + + +### Non-Version-Based Function ### +#### Set ##### +Set `value` to the key `key`. + + kv_service_tools --config config_file --cmd set --key key --value value + +| parameters | descriptions | +| ---- | ---- | +| config | the path of the client config which points to the db entrance | +| cmd | set | +| key | the key you want to set | +| value | the new value | + +Example: + + bazel-bin/service/tools/kv/api_tools/kv_service_tools --config service/tools/config/interface/service.config --cmd set --key key1 --value value1 + +Results: +> set key = key1, value = v1, done, ret = 0 + +#### Get #### +Obtain the value of `key`. + + kv_service_tools --config config_file --cmd get --key key + +| parameters | descriptions | +| ---- | ---- | +| config | the path of the client config which points to the db entrance | +| cmd | get | +| key | the key you want to obtain | + +Example: + + bazel-bin/service/tools/kv/api_tools/kv_service_tools --config service/tools/config/interface/service.config --cmd get --key key1 + +Results: +> get key = key1, value = "v2" + + +#### Get Key Range #### +Obtain the values of the keys in the ranges [`key1`, `key2`]. Do not use this function in your practice code + + kv_service_tools --config config_path --cmd get_key_range --min_key key1 --max_key key2 + +| parameters | descriptions | +| ---- | ---- | +| config | the path of the client config which points to the db entrance | +| cmd | get_key_range | +| min_key | the minimum key | +| max_key | the maximum key | + +Example: + + bazel-bin/service/tools/kv/api_tools/kv_service_tools --config service/tools/config/interface/service.config --cmd get_key_range --min_key key1 --max_key key3 + +Results: +> getrange min key = key1, max key = key3
+> value = [v3,v2,v1] + + +## Deployment Script + +We also provide access to a [deployment script](https://github.com/resilientdb/resilientdb/tree/master/scripts/deploy) that allows deployment on distinct machines. + +## Deploy via Docker + +1. **Install Docker** + Before getting started, make sure you have Docker installed on your system. If you don't have Docker already, you can download and install it from the official [Docker website](https://www.docker.com/products/docker-desktop/). + +2. **Pull the Latest ResilientDB Image** + Choose the appropriate [ResilientDB image](https://hub.docker.com/repository/docker/expolab/resdb/general) for your machine's architecture: + + - For amd architecture, run: + ```shell + docker pull expolab/resdb:amd64 + ``` + + - For Apple Silicon (M1/M2) architecture, run: + ```shell + docker pull expolab/resdb:arm64 + ``` + +3. **Run a Container with the Pulled Image** + Launch a Docker container using the ResilientDB image you just pulled: + + - For amd architecture, run: + ```shell + docker run -d --name myserver expolab/resdb:amd64 + ``` + + - For Apple Silicon (M1/M2) architecture, run: + ```shell + docker run -d --name myserver expolab/resdb:arm64 + ``` + +4. **Test with Set and Get Commands** + Exec into the running server: + ```shell + docker exec -it myserver bash + ``` + +5. **NOTE: If you encounter a Connection Refused error** + + Run the following command within the container: + ```shell + ./service/tools/kv/server_tools/start_kv_service.sh + ``` + + Verify the functionality of the service by performing set and get operations provided above [functions](README.md#functions). + + +## Custom Ports ## +When starting the service locally, current services are running on 10000 port-base with 5 services where the server config is located [here](https://github.com/apache/incubator-resilientdb/blob/master/service/tools/config/server/server.config) + +If you want to change the setting, you need to generate the certificates. + +Go the the workspace where the resilientdb repo is localted. + +Change the setting parameters here and run the script: + ```shell + ./service/tools/kv/server_tools/generate_config.sh + ``` + +Then re-run the start script: + ```shell + ./service/tools/kv/server_tools/start_kv_service.sh + ``` + + + +## Smart Contract ## +If you want to use smart contracts, please go to: +https://blog.resilientdb.com/2025/02/14/GettingStartedSmartContract.html diff --git a/WORKSPACE b/WORKSPACE index e05017f5c8..09bae2ac9f 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -1,258 +1,258 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -workspace(name = "com_resdb_nexres") - -load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") - -http_archive( - name = "hedron_compile_commands", - #Replace the commit hash (4f28899228fb3ad0126897876f147ca15026151e) with the latest commit hash from the repo - url = "https://github.com/hedronvision/bazel-compile-commands-extractor/archive/4f28899228fb3ad0126897876f147ca15026151e.tar.gz", - strip_prefix = "bazel-compile-commands-extractor-4f28899228fb3ad0126897876f147ca15026151e", -) -load("@hedron_compile_commands//:workspace_setup.bzl", "hedron_compile_commands_setup") -hedron_compile_commands_setup() -load("@hedron_compile_commands//:workspace_setup_transitive.bzl", "hedron_compile_commands_setup_transitive") -hedron_compile_commands_setup_transitive() -load("@hedron_compile_commands//:workspace_setup_transitive_transitive.bzl", "hedron_compile_commands_setup_transitive_transitive") -hedron_compile_commands_setup_transitive_transitive() -load("@hedron_compile_commands//:workspace_setup_transitive_transitive_transitive.bzl", "hedron_compile_commands_setup_transitive_transitive_transitive") -hedron_compile_commands_setup_transitive_transitive_transitive() - -load("//:repositories.bzl", "nexres_repositories") - -nexres_repositories() - -http_archive( - name = "rules_foreign_cc", - sha256 = "69023642d5781c68911beda769f91fcbc8ca48711db935a75da7f6536b65047f", - strip_prefix = "rules_foreign_cc-0.6.0", - url = "https://github.com/bazelbuild/rules_foreign_cc/archive/0.6.0.tar.gz", -) - -load("@rules_foreign_cc//foreign_cc:repositories.bzl", "rules_foreign_cc_dependencies") - -rules_foreign_cc_dependencies() - -http_archive( - name = "rules_proto", - sha256 = "66bfdf8782796239d3875d37e7de19b1d94301e8972b3cbd2446b332429b4df1", - strip_prefix = "rules_proto-4.0.0", - urls = [ - "https://mirror.bazel.build/github.com/bazelbuild/rules_proto/archive/refs/tags/4.0.0.tar.gz", - "https://github.com/bazelbuild/rules_proto/archive/refs/tags/4.0.0.tar.gz", - ], -) - -load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains") - -rules_proto_dependencies() - -rules_proto_toolchains() - -http_archive( - name = "rules_python", - sha256 = "ffc7b877c95413c82bfd5482c017edcf759a6250d8b24e82f41f3c8b8d9e287e", - strip_prefix = "rules_python-0.19.0", - url = "https://github.com/bazelbuild/rules_python/releases/download/0.19.0/rules_python-0.19.0.tar.gz", -) - -load("@rules_python//python:pip.bzl", "pip_install") -load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains") - -rules_proto_dependencies() - -rules_proto_toolchains() - -load("@rules_proto_grpc//:repositories.bzl", "rules_proto_grpc_repos", "rules_proto_grpc_toolchains") - -rules_proto_grpc_toolchains() - -rules_proto_grpc_repos() - -bind( - name = "gtest", - actual = "@com_google_googletest//:gtest", -) - -bind( - name = "glog", - actual = "@com_github_google_glog//:glog", -) - -http_archive( - name = "com_github_google_glog", - sha256 = "21bc744fb7f2fa701ee8db339ded7dce4f975d0d55837a97be7d46e8382dea5a", - strip_prefix = "glog-0.5.0", - urls = ["https://github.com/google/glog/archive/v0.5.0.zip"], -) - -load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") - -git_repository( - name = "com_google_protobuf", - remote = "https://github.com/protocolbuffers/protobuf", - tag = "v3.10.0", -) - -load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps") - -protobuf_deps() - -all_content = """filegroup(name = "all_srcs", srcs = glob(["**"]), visibility = ["//visibility:public"])""" - -# buildifier is written in Go and hence needs rules_go to be built. -# See https://github.com/bazelbuild/rules_go for the up to date setup instructions. -http_archive( - name = "io_bazel_rules_go", - sha256 = "d6b2513456fe2229811da7eb67a444be7785f5323c6708b38d851d2b51e54d83", - urls = [ - "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.30.0/rules_go-v0.30.0.zip", - "https://github.com/bazelbuild/rules_go/releases/download/v0.30.0/rules_go-v0.30.0.zip", - ], -) - -load("@io_bazel_rules_go//go:deps.bzl", "go_rules_dependencies") - -go_rules_dependencies() - -load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains") - -go_register_toolchains(version = "1.19.5") - -http_archive( - name = "bazel_gazelle", - sha256 = "de69a09dc70417580aabf20a28619bb3ef60d038470c7cf8442fafcf627c21cb", - urls = [ - "https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.24.0/bazel-gazelle-v0.24.0.tar.gz", - "https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.24.0/bazel-gazelle-v0.24.0.tar.gz", - ], -) - -load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies") - -gazelle_dependencies() - -http_archive( - name = "com_github_bazelbuild_buildtools", - sha256 = "518b2ce90b1f8ad7c9a319ca84fd7de9a0979dd91e6d21648906ea68faa4f37a", - strip_prefix = "buildtools-5.0.1", - urls = [ - "https://github.com/bazelbuild/buildtools/archive/refs/tags/5.0.1.zip", - ], -) - -load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") -load("@com_github_nelhage_rules_boost//:boost/boost.bzl", "boost_deps") - -boost_deps() - -http_archive( - name = "net_zlib_zlib", - build_file = "@com_resdb_nexres//third_party:z.BUILD", - sha256 = "91844808532e5ce316b3c010929493c0244f3d37593afd6de04f71821d5136d9", - strip_prefix = "zlib-1.2.12", - urls = [ - "https://storage.googleapis.com/bazel-mirror/zlib.net/zlib-1.2.12.tar.gz", - ], -) - -http_archive( - name = "com_google_leveldb", - build_file = "@com_resdb_nexres//third_party:leveldb.BUILD", - sha256 = "a6fa7eebd11de709c46bf1501600ed98bf95439d6967963606cc964931ce906f", - strip_prefix = "leveldb-1.23", - url = "https://github.com/google/leveldb/archive/refs/tags/1.23.zip", -) - -bind( - name = "snappy", - actual = "@com_google_snappy//:snappy", -) - -http_archive( - name = "com_google_snappy", - build_file = "@com_resdb_nexres//third_party:snappy.BUILD", - sha256 = "e170ce0def2c71d0403f5cda61d6e2743373f9480124bcfcd0fa9b3299d428d9", - strip_prefix = "snappy-1.1.9", - url = "https://github.com/google/snappy/archive/refs/tags/1.1.9.zip", -) - -bind( - name = "zlib", - actual = "@com_zlib//:zlib", -) - -http_archive( - name = "com_zlib", - build_file = "@com_resdb_nexres//third_party:zlib.BUILD", - sha256 = "629380c90a77b964d896ed37163f5c3a34f6e6d897311f1df2a7016355c45eff", - strip_prefix = "zlib-1.2.11", - url = "https://github.com/madler/zlib/archive/v1.2.11.tar.gz", -) - -http_archive( - name = "pybind11_bazel", - strip_prefix = "pybind11_bazel-2.11.1.bzl.1", - urls = ["https://github.com/pybind/pybind11_bazel/archive/refs/tags/v2.11.1.bzl.1.zip"] -) - -http_archive( - name = "pybind11", - build_file = "@pybind11_bazel//:pybind11.BUILD", - sha256 = "8ff2fff22df038f5cd02cea8af56622bc67f5b64534f1b83b9f133b8366acff2", - strip_prefix = "pybind11-2.6.2", - urls = ["https://github.com/pybind/pybind11/archive/v2.6.2.tar.gz"], -) - -load("@pybind11_bazel//:python_configure.bzl", "python_configure") - -python_configure( - name = "local_config_python", - python_version = "3", -) - -http_archive( - name = "nlohmann_json", - build_file = "@com_resdb_nexres//third_party:json.BUILD", # see below - sha256 = "4cf0df69731494668bdd6460ed8cb269b68de9c19ad8c27abc24cd72605b2d5b", - strip_prefix = "json-3.9.1", - urls = ["https://github.com/nlohmann/json/archive/v3.9.1.tar.gz"], -) - -http_archive( - name = "com_crowcpp_crow", - build_file = "//third_party:crow.BUILD", - sha256 = "f95128a8976fae6f2922823e07da59edae277a460776572a556a4b663ff5ee4b", - strip_prefix = "Crow-1.0-5", - url = "https://github.com/CrowCpp/Crow/archive/refs/tags/v1.0+5.zip", -) - -bind( - name = "asio", - actual = "@com_chriskohlhoff_asio//:asio", -) - -http_archive( - name = "com_chriskohlhoff_asio", - build_file = "//third_party:asio.BUILD", - sha256 = "babcdfd2c744905a73d20de211b51367bda0d5200f11d654c4314b909d8c963c", - strip_prefix = "asio-asio-1-26-0", - url = "https://github.com/chriskohlhoff/asio/archive/refs/tags/asio-1-26-0.zip", -) +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +workspace(name = "com_resdb_nexres") + +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") + +http_archive( + name = "hedron_compile_commands", + #Replace the commit hash (4f28899228fb3ad0126897876f147ca15026151e) with the latest commit hash from the repo + url = "https://github.com/hedronvision/bazel-compile-commands-extractor/archive/4f28899228fb3ad0126897876f147ca15026151e.tar.gz", + strip_prefix = "bazel-compile-commands-extractor-4f28899228fb3ad0126897876f147ca15026151e", +) +load("@hedron_compile_commands//:workspace_setup.bzl", "hedron_compile_commands_setup") +hedron_compile_commands_setup() +load("@hedron_compile_commands//:workspace_setup_transitive.bzl", "hedron_compile_commands_setup_transitive") +hedron_compile_commands_setup_transitive() +load("@hedron_compile_commands//:workspace_setup_transitive_transitive.bzl", "hedron_compile_commands_setup_transitive_transitive") +hedron_compile_commands_setup_transitive_transitive() +load("@hedron_compile_commands//:workspace_setup_transitive_transitive_transitive.bzl", "hedron_compile_commands_setup_transitive_transitive_transitive") +hedron_compile_commands_setup_transitive_transitive_transitive() + +load("//:repositories.bzl", "nexres_repositories") + +nexres_repositories() + +http_archive( + name = "rules_foreign_cc", + sha256 = "69023642d5781c68911beda769f91fcbc8ca48711db935a75da7f6536b65047f", + strip_prefix = "rules_foreign_cc-0.6.0", + url = "https://github.com/bazelbuild/rules_foreign_cc/archive/0.6.0.tar.gz", +) + +load("@rules_foreign_cc//foreign_cc:repositories.bzl", "rules_foreign_cc_dependencies") + +rules_foreign_cc_dependencies() + +http_archive( + name = "rules_proto", + sha256 = "66bfdf8782796239d3875d37e7de19b1d94301e8972b3cbd2446b332429b4df1", + strip_prefix = "rules_proto-4.0.0", + urls = [ + "https://mirror.bazel.build/github.com/bazelbuild/rules_proto/archive/refs/tags/4.0.0.tar.gz", + "https://github.com/bazelbuild/rules_proto/archive/refs/tags/4.0.0.tar.gz", + ], +) + +load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains") + +rules_proto_dependencies() + +rules_proto_toolchains() + +http_archive( + name = "rules_python", + sha256 = "ffc7b877c95413c82bfd5482c017edcf759a6250d8b24e82f41f3c8b8d9e287e", + strip_prefix = "rules_python-0.19.0", + url = "https://github.com/bazelbuild/rules_python/releases/download/0.19.0/rules_python-0.19.0.tar.gz", +) + +load("@rules_python//python:pip.bzl", "pip_install") +load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains") + +rules_proto_dependencies() + +rules_proto_toolchains() + +load("@rules_proto_grpc//:repositories.bzl", "rules_proto_grpc_repos", "rules_proto_grpc_toolchains") + +rules_proto_grpc_toolchains() + +rules_proto_grpc_repos() + +bind( + name = "gtest", + actual = "@com_google_googletest//:gtest", +) + +bind( + name = "glog", + actual = "@com_github_google_glog//:glog", +) + +http_archive( + name = "com_github_google_glog", + sha256 = "21bc744fb7f2fa701ee8db339ded7dce4f975d0d55837a97be7d46e8382dea5a", + strip_prefix = "glog-0.5.0", + urls = ["https://github.com/google/glog/archive/v0.5.0.zip"], +) + +load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") + +git_repository( + name = "com_google_protobuf", + remote = "https://github.com/protocolbuffers/protobuf", + tag = "v3.10.0", +) + +load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps") + +protobuf_deps() + +all_content = """filegroup(name = "all_srcs", srcs = glob(["**"]), visibility = ["//visibility:public"])""" + +# buildifier is written in Go and hence needs rules_go to be built. +# See https://github.com/bazelbuild/rules_go for the up to date setup instructions. +http_archive( + name = "io_bazel_rules_go", + sha256 = "d6b2513456fe2229811da7eb67a444be7785f5323c6708b38d851d2b51e54d83", + urls = [ + "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.30.0/rules_go-v0.30.0.zip", + "https://github.com/bazelbuild/rules_go/releases/download/v0.30.0/rules_go-v0.30.0.zip", + ], +) + +load("@io_bazel_rules_go//go:deps.bzl", "go_rules_dependencies") + +go_rules_dependencies() + +load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains") + +go_register_toolchains(version = "1.19.5") + +http_archive( + name = "bazel_gazelle", + sha256 = "de69a09dc70417580aabf20a28619bb3ef60d038470c7cf8442fafcf627c21cb", + urls = [ + "https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.24.0/bazel-gazelle-v0.24.0.tar.gz", + "https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.24.0/bazel-gazelle-v0.24.0.tar.gz", + ], +) + +load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies") + +gazelle_dependencies() + +http_archive( + name = "com_github_bazelbuild_buildtools", + sha256 = "518b2ce90b1f8ad7c9a319ca84fd7de9a0979dd91e6d21648906ea68faa4f37a", + strip_prefix = "buildtools-5.0.1", + urls = [ + "https://github.com/bazelbuild/buildtools/archive/refs/tags/5.0.1.zip", + ], +) + +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") +load("@com_github_nelhage_rules_boost//:boost/boost.bzl", "boost_deps") + +boost_deps() + +http_archive( + name = "net_zlib_zlib", + build_file = "@com_resdb_nexres//third_party:z.BUILD", + sha256 = "91844808532e5ce316b3c010929493c0244f3d37593afd6de04f71821d5136d9", + strip_prefix = "zlib-1.2.12", + urls = [ + "https://storage.googleapis.com/bazel-mirror/zlib.net/zlib-1.2.12.tar.gz", + ], +) + +http_archive( + name = "com_google_leveldb", + build_file = "@com_resdb_nexres//third_party:leveldb.BUILD", + sha256 = "a6fa7eebd11de709c46bf1501600ed98bf95439d6967963606cc964931ce906f", + strip_prefix = "leveldb-1.23", + url = "https://github.com/google/leveldb/archive/refs/tags/1.23.zip", +) + +bind( + name = "snappy", + actual = "@com_google_snappy//:snappy", +) + +http_archive( + name = "com_google_snappy", + build_file = "@com_resdb_nexres//third_party:snappy.BUILD", + sha256 = "e170ce0def2c71d0403f5cda61d6e2743373f9480124bcfcd0fa9b3299d428d9", + strip_prefix = "snappy-1.1.9", + url = "https://github.com/google/snappy/archive/refs/tags/1.1.9.zip", +) + +bind( + name = "zlib", + actual = "@com_zlib//:zlib", +) + +http_archive( + name = "com_zlib", + build_file = "@com_resdb_nexres//third_party:zlib.BUILD", + sha256 = "629380c90a77b964d896ed37163f5c3a34f6e6d897311f1df2a7016355c45eff", + strip_prefix = "zlib-1.2.11", + url = "https://github.com/madler/zlib/archive/v1.2.11.tar.gz", +) + +http_archive( + name = "pybind11_bazel", + strip_prefix = "pybind11_bazel-2.11.1.bzl.1", + urls = ["https://github.com/pybind/pybind11_bazel/archive/refs/tags/v2.11.1.bzl.1.zip"] +) + +http_archive( + name = "pybind11", + build_file = "@pybind11_bazel//:pybind11.BUILD", + sha256 = "8ff2fff22df038f5cd02cea8af56622bc67f5b64534f1b83b9f133b8366acff2", + strip_prefix = "pybind11-2.6.2", + urls = ["https://github.com/pybind/pybind11/archive/v2.6.2.tar.gz"], +) + +load("@pybind11_bazel//:python_configure.bzl", "python_configure") + +python_configure( + name = "local_config_python", + python_version = "3", +) + +http_archive( + name = "nlohmann_json", + build_file = "@com_resdb_nexres//third_party:json.BUILD", # see below + sha256 = "4cf0df69731494668bdd6460ed8cb269b68de9c19ad8c27abc24cd72605b2d5b", + strip_prefix = "json-3.9.1", + urls = ["https://github.com/nlohmann/json/archive/v3.9.1.tar.gz"], +) + +http_archive( + name = "com_crowcpp_crow", + build_file = "//third_party:crow.BUILD", + sha256 = "f95128a8976fae6f2922823e07da59edae277a460776572a556a4b663ff5ee4b", + strip_prefix = "Crow-1.0-5", + url = "https://github.com/CrowCpp/Crow/archive/refs/tags/v1.0+5.zip", +) + +bind( + name = "asio", + actual = "@com_chriskohlhoff_asio//:asio", +) + +http_archive( + name = "com_chriskohlhoff_asio", + build_file = "//third_party:asio.BUILD", + sha256 = "babcdfd2c744905a73d20de211b51367bda0d5200f11d654c4314b909d8c963c", + strip_prefix = "asio-asio-1-26-0", + url = "https://github.com/chriskohlhoff/asio/archive/refs/tags/asio-1-26-0.zip", +) diff --git a/api/BUILD b/api/BUILD index 5bad893bae..e6e2356d84 100644 --- a/api/BUILD +++ b/api/BUILD @@ -1,38 +1,38 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -package(default_visibility = ["//visibility:public"]) - -cc_binary( - name = "pybind_kv.so", - srcs = ["pybind_kv_service.cpp"], - linkshared = 1, - linkstatic = 1, - deps = [ - "@//common/proto:signature_info_cc_proto", - "@//interface/kv:kv_client", - "@//platform/config:resdb_config_utils", - "@pybind11", - ], -) - -py_library( - name = "pybind_kv_so", - data = [":pybind_kv.so"], - imports = ["."], -) +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +package(default_visibility = ["//visibility:public"]) + +cc_binary( + name = "pybind_kv.so", + srcs = ["pybind_kv_service.cpp"], + linkshared = 1, + linkstatic = 1, + deps = [ + "@//common/proto:signature_info_cc_proto", + "@//interface/kv:kv_client", + "@//platform/config:resdb_config_utils", + "@pybind11", + ], +) + +py_library( + name = "pybind_kv_so", + data = [":pybind_kv.so"], + imports = ["."], +) diff --git a/api/README.md b/api/README.md index b4d6e74180..8a3ceebf54 100644 --- a/api/README.md +++ b/api/README.md @@ -1,66 +1,66 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -# ResilientDB kv-Service Python API(Get and Set Command) - -## Description -This API allows users to use kv-service of the ResilientDB in Python directly. - -## How to Run -1. Make sure to run `./INSTALL.sh` in advance. -1. cd to `incubator-resilientdb/api` folder. -2. Run command `bazel build :pybind_kv_so`. -3. From `kv_operation.py`, import `get_value` and `set_value` functions into your Python file to use it (Make sure to use the same Python version when running `bazel build` command and calling the functions). - -## Parameters -### `set_value`: -1. `key`: The key user wants to store in a key-value pair. Acceptable types are `str`, `int`, `float`. -2. `value`: The corresponding value to `key` in the key-value pair. Acceptable types are `str`, `int`, `float`. -3. config_path (optional): The path to the user's blockchain config file (IP addresses). If the user does not specify this parameter, the system will default to the address located in "ip.address.config." The acceptable type is `str`. -4. `return`: `True` if `value` has been set successfully; otherwise, `value` has not been set successfully. -### `get_value`: -1. `key`: The key user wants to get in a key-value pair. Acceptable types are `str`, `int`, `float`. -2. `return`: `\n` if the corresponding value of `key` is empty, otherwise is the corresponding value of `key`. - - -## Example -```angular2html -import sys -# Your path to ResilientDB api folder -sys.path.append("/home/ubuntu/Desktop/incubator-resilientdb/api") -from kv_operation import set_value, get_value - -set_value("test", "111222") -get_value("test") -``` - -If having set up the environment parameter, "sys.path" can be ignorred. -``` -export PYTHON_PATH="/home/ubuntu/Desktop/incubator-resilientdb/api":PYTHON_PATH -``` -```angular2html -from kv_operation import set_value, get_value - -set_value("test", "111222") -get_value("test") -``` - - - - +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +# ResilientDB kv-Service Python API(Get and Set Command) + +## Description +This API allows users to use kv-service of the ResilientDB in Python directly. + +## How to Run +1. Make sure to run `./INSTALL.sh` in advance. +1. cd to `incubator-resilientdb/api` folder. +2. Run command `bazel build :pybind_kv_so`. +3. From `kv_operation.py`, import `get_value` and `set_value` functions into your Python file to use it (Make sure to use the same Python version when running `bazel build` command and calling the functions). + +## Parameters +### `set_value`: +1. `key`: The key user wants to store in a key-value pair. Acceptable types are `str`, `int`, `float`. +2. `value`: The corresponding value to `key` in the key-value pair. Acceptable types are `str`, `int`, `float`. +3. config_path (optional): The path to the user's blockchain config file (IP addresses). If the user does not specify this parameter, the system will default to the address located in "ip.address.config." The acceptable type is `str`. +4. `return`: `True` if `value` has been set successfully; otherwise, `value` has not been set successfully. +### `get_value`: +1. `key`: The key user wants to get in a key-value pair. Acceptable types are `str`, `int`, `float`. +2. `return`: `\n` if the corresponding value of `key` is empty, otherwise is the corresponding value of `key`. + + +## Example +```angular2html +import sys +# Your path to ResilientDB api folder +sys.path.append("/home/ubuntu/Desktop/incubator-resilientdb/api") +from kv_operation import set_value, get_value + +set_value("test", "111222") +get_value("test") +``` + +If having set up the environment parameter, "sys.path" can be ignorred. +``` +export PYTHON_PATH="/home/ubuntu/Desktop/incubator-resilientdb/api":PYTHON_PATH +``` +```angular2html +from kv_operation import set_value, get_value + +set_value("test", "111222") +get_value("test") +``` + + + + diff --git a/api/kv_operation.py b/api/kv_operation.py index f18c846018..8ffd7e3b7d 100644 --- a/api/kv_operation.py +++ b/api/kv_operation.py @@ -1,46 +1,46 @@ -# - # Licensed to the Apache Software Foundation (ASF) under one - # or more contributor license agreements. See the NOTICE file - # distributed with this work for additional information - # regarding copyright ownership. The ASF licenses this file - # to you under the Apache License, Version 2.0 (the - # "License"); you may not use this file except in compliance - # with the License. You may obtain a copy of the License at - # - # http://www.apache.org/licenses/LICENSE-2.0 - # - # Unless required by applicable law or agreed to in writing, - # software distributed under the License is distributed on an - # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - # KIND, either express or implied. See the License for the - # specific language governing permissions and limitations - # under the License. - # - -import os -import sys -current_file_path = os.path.abspath(__file__) -current_dir = os.path.dirname(current_file_path) -parent_dir = os.path.dirname(current_dir) -new_path_dir = os.path.join(parent_dir, "bazel-out", "k8-fastbuild", "bin", "api") -sys.path.insert(0, new_path_dir) -import pybind_kv - - -def set_value(key: str or int or float, value: str or int or float, config_path: str = current_dir + "/ip_address.config") -> bool: - """ - :param key: The key you want to set your value to. - :param value: The key's corresponding value in key value pair. - :param config_path: Default is connect to the main chain, users can specify the path to connect to their local blockchain. - :return: True if value has been set successfully. - """ - return pybind_kv.set(str(key), str(value), os.path.abspath(config_path)) - - -def get_value(key: str or int or float, config_path: str = current_dir + "/ip_address.config") -> str: - """ - :param key: The key of the value you want to get in key value pair. - :param config_path: Default is connect to the main chain, users can specify the path to connect to their local blockchain. - :return: A string of the key's corresponding value. - """ - return pybind_kv.get(str(key), os.path.abspath(config_path)) +# + # Licensed to the Apache Software Foundation (ASF) under one + # or more contributor license agreements. See the NOTICE file + # distributed with this work for additional information + # regarding copyright ownership. The ASF licenses this file + # to you under the Apache License, Version 2.0 (the + # "License"); you may not use this file except in compliance + # with the License. You may obtain a copy of the License at + # + # http://www.apache.org/licenses/LICENSE-2.0 + # + # Unless required by applicable law or agreed to in writing, + # software distributed under the License is distributed on an + # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + # KIND, either express or implied. See the License for the + # specific language governing permissions and limitations + # under the License. + # + +import os +import sys +current_file_path = os.path.abspath(__file__) +current_dir = os.path.dirname(current_file_path) +parent_dir = os.path.dirname(current_dir) +new_path_dir = os.path.join(parent_dir, "bazel-out", "k8-fastbuild", "bin", "api") +sys.path.insert(0, new_path_dir) +import pybind_kv + + +def set_value(key: str or int or float, value: str or int or float, config_path: str = current_dir + "/ip_address.config") -> bool: + """ + :param key: The key you want to set your value to. + :param value: The key's corresponding value in key value pair. + :param config_path: Default is connect to the main chain, users can specify the path to connect to their local blockchain. + :return: True if value has been set successfully. + """ + return pybind_kv.set(str(key), str(value), os.path.abspath(config_path)) + + +def get_value(key: str or int or float, config_path: str = current_dir + "/ip_address.config") -> str: + """ + :param key: The key of the value you want to get in key value pair. + :param config_path: Default is connect to the main chain, users can specify the path to connect to their local blockchain. + :return: A string of the key's corresponding value. + """ + return pybind_kv.get(str(key), os.path.abspath(config_path)) diff --git a/api/pybind_kv_service.cpp b/api/pybind_kv_service.cpp index 013683fbd7..dc79201f34 100644 --- a/api/pybind_kv_service.cpp +++ b/api/pybind_kv_service.cpp @@ -1,66 +1,66 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#include -#include -#include -#include -#include -#include - -#include - -#include "common/proto/signature_info.pb.h" -#include "interface/kv/kv_client.h" -#include "platform/config/resdb_config_utils.h" - -using resdb::GenerateReplicaInfo; -using resdb::GenerateResDBConfig; -using resdb::KVClient; -using resdb::ReplicaInfo; -using resdb::ResDBConfig; - -std::string get(std::string key, std::string config_path) { - ResDBConfig config = GenerateResDBConfig(config_path); - config.SetClientTimeoutMs(100000); - KVClient client(config); - auto result_ptr = client.Get(key); - if (result_ptr) { - return *result_ptr; - } else { - return ""; - } -} - -bool set(std::string key, std::string value, std::string config_path) { - ResDBConfig config = GenerateResDBConfig(config_path); - config.SetClientTimeoutMs(100000); - KVClient client(config); - int result = client.Set(key, value); - if (result == 0) { - return true; - } else { - return false; - } -} - -PYBIND11_MODULE(pybind_kv, m) { - m.def("get", &get, "A function that gets a value from the key-value store"); - m.def("set", &set, "A function that sets a value in the key-value store"); -} +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#include +#include +#include +#include +#include +#include + +#include + +#include "common/proto/signature_info.pb.h" +#include "interface/kv/kv_client.h" +#include "platform/config/resdb_config_utils.h" + +using resdb::GenerateReplicaInfo; +using resdb::GenerateResDBConfig; +using resdb::KVClient; +using resdb::ReplicaInfo; +using resdb::ResDBConfig; + +std::string get(std::string key, std::string config_path) { + ResDBConfig config = GenerateResDBConfig(config_path); + config.SetClientTimeoutMs(100000); + KVClient client(config); + auto result_ptr = client.Get(key); + if (result_ptr) { + return *result_ptr; + } else { + return ""; + } +} + +bool set(std::string key, std::string value, std::string config_path) { + ResDBConfig config = GenerateResDBConfig(config_path); + config.SetClientTimeoutMs(100000); + KVClient client(config); + int result = client.Set(key, value); + if (result == 0) { + return true; + } else { + return false; + } +} + +PYBIND11_MODULE(pybind_kv, m) { + m.def("get", &get, "A function that gets a value from the key-value store"); + m.def("set", &set, "A function that sets a value in the key-value store"); +} diff --git a/benchmark/protocols/pbft/BUILD b/benchmark/protocols/pbft/BUILD index f99e820622..6ae943aa56 100644 --- a/benchmark/protocols/pbft/BUILD +++ b/benchmark/protocols/pbft/BUILD @@ -1,43 +1,43 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -package(default_visibility = ["//visibility:private"]) - -load("@bazel_skylib//rules:common_settings.bzl", "bool_flag") - -cc_binary( - name = "kv_server_performance", - srcs = ["kv_server_performance.cpp"], - deps = [ - "//chain/storage:memory_db", - "//executor/kv:kv_executor", - "//platform/config:resdb_config_utils", - "//platform/consensus/ordering/pbft:consensus_manager_pbft", - "//service/utils:server_factory", - ], -) - -cc_binary( - name = "kv_service_tools", - srcs = ["kv_service_tools.cpp"], - deps = [ - "//common/proto:signature_info_cc_proto", - "//interface/kv:kv_client", - "//platform/config:resdb_config_utils", - ], -) +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +package(default_visibility = ["//visibility:private"]) + +load("@bazel_skylib//rules:common_settings.bzl", "bool_flag") + +cc_binary( + name = "kv_server_performance", + srcs = ["kv_server_performance.cpp"], + deps = [ + "//chain/storage:memory_db", + "//executor/kv:kv_executor", + "//platform/config:resdb_config_utils", + "//platform/consensus/ordering/pbft:consensus_manager_pbft", + "//service/utils:server_factory", + ], +) + +cc_binary( + name = "kv_service_tools", + srcs = ["kv_service_tools.cpp"], + deps = [ + "//common/proto:signature_info_cc_proto", + "//interface/kv:kv_client", + "//platform/config:resdb_config_utils", + ], +) diff --git a/benchmark/protocols/pbft/kv_server_performance.cpp b/benchmark/protocols/pbft/kv_server_performance.cpp index 7a81f27c7b..0d06c04c6c 100644 --- a/benchmark/protocols/pbft/kv_server_performance.cpp +++ b/benchmark/protocols/pbft/kv_server_performance.cpp @@ -1,81 +1,81 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#include - -#include "chain/storage/memory_db.h" -#include "executor/kv/kv_executor.h" -#include "platform/config/resdb_config_utils.h" -#include "platform/consensus/ordering/pbft/consensus_manager_pbft.h" -#include "platform/networkstrate/service_network.h" -#include "platform/statistic/stats.h" -#include "proto/kv/kv.pb.h" - -using namespace resdb; -using namespace resdb::storage; - -void ShowUsage() { - printf(" [logging_dir]\n"); -} - -std::string GetRandomKey() { - int num1 = rand() % 10; - int num2 = rand() % 10; - return std::to_string(num1) + std::to_string(num2); -} - -int main(int argc, char** argv) { - if (argc < 3) { - ShowUsage(); - exit(0); - } - - // google::InitGoogleLogging(argv[0]); - // FLAGS_minloglevel = google::GLOG_WARNING; - - char* config_file = argv[1]; - char* private_key_file = argv[2]; - char* cert_file = argv[3]; - - if (argc >= 5) { - auto monitor_port = Stats::GetGlobalStats(5); - monitor_port->SetPrometheus(argv[4]); - } - - std::unique_ptr config = - GenerateResDBConfig(config_file, private_key_file, cert_file); - - config->RunningPerformance(true); - - auto performance_consens = std::make_unique( - *config, std::make_unique(std::make_unique())); - performance_consens->SetupPerformanceDataFunc([]() { - KVRequest request; - request.set_cmd(KVRequest::SET); - request.set_key(GetRandomKey()); - request.set_value("helloworld"); - std::string request_data; - request.SerializeToString(&request_data); - return request_data; - }); - - auto server = - std::make_unique(*config, std::move(performance_consens)); - server->Run(); -} +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#include + +#include "chain/storage/memory_db.h" +#include "executor/kv/kv_executor.h" +#include "platform/config/resdb_config_utils.h" +#include "platform/consensus/ordering/pbft/consensus_manager_pbft.h" +#include "platform/networkstrate/service_network.h" +#include "platform/statistic/stats.h" +#include "proto/kv/kv.pb.h" + +using namespace resdb; +using namespace resdb::storage; + +void ShowUsage() { + printf(" [logging_dir]\n"); +} + +std::string GetRandomKey() { + int num1 = rand() % 10; + int num2 = rand() % 10; + return std::to_string(num1) + std::to_string(num2); +} + +int main(int argc, char** argv) { + if (argc < 3) { + ShowUsage(); + exit(0); + } + + // google::InitGoogleLogging(argv[0]); + // FLAGS_minloglevel = google::GLOG_WARNING; + + char* config_file = argv[1]; + char* private_key_file = argv[2]; + char* cert_file = argv[3]; + + if (argc >= 5) { + auto monitor_port = Stats::GetGlobalStats(5); + monitor_port->SetPrometheus(argv[4]); + } + + std::unique_ptr config = + GenerateResDBConfig(config_file, private_key_file, cert_file); + + config->RunningPerformance(true); + + auto performance_consens = std::make_unique( + *config, std::make_unique(std::make_unique())); + performance_consens->SetupPerformanceDataFunc([]() { + KVRequest request; + request.set_cmd(KVRequest::SET); + request.set_key(GetRandomKey()); + request.set_value("helloworld"); + std::string request_data; + request.SerializeToString(&request_data); + return request_data; + }); + + auto server = + std::make_unique(*config, std::move(performance_consens)); + server->Run(); +} diff --git a/benchmark/protocols/pbft/kv_service_tools.cpp b/benchmark/protocols/pbft/kv_service_tools.cpp index 43627b34f4..c93d6f2e49 100644 --- a/benchmark/protocols/pbft/kv_service_tools.cpp +++ b/benchmark/protocols/pbft/kv_service_tools.cpp @@ -1,51 +1,51 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#include -#include -#include -#include - -#include - -#include "common/proto/signature_info.pb.h" -#include "interface/kv/kv_client.h" -#include "platform/config/resdb_config_utils.h" - -using resdb::GenerateReplicaInfo; -using resdb::GenerateResDBConfig; -using resdb::KVClient; -using resdb::ReplicaInfo; -using resdb::ResDBConfig; - -int main(int argc, char** argv) { - if (argc < 2) { - printf("\n"); - return 0; - } - std::string client_config_file = argv[1]; - ResDBConfig config = GenerateResDBConfig(client_config_file); - - config.SetClientTimeoutMs(100000); - - KVClient client(config); - - client.Set("start", "value"); - printf("start benchmark\n"); -} +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#include +#include +#include +#include + +#include + +#include "common/proto/signature_info.pb.h" +#include "interface/kv/kv_client.h" +#include "platform/config/resdb_config_utils.h" + +using resdb::GenerateReplicaInfo; +using resdb::GenerateResDBConfig; +using resdb::KVClient; +using resdb::ReplicaInfo; +using resdb::ResDBConfig; + +int main(int argc, char** argv) { + if (argc < 2) { + printf("\n"); + return 0; + } + std::string client_config_file = argv[1]; + ResDBConfig config = GenerateResDBConfig(client_config_file); + + config.SetClientTimeoutMs(100000); + + KVClient client(config); + + client.Set("start", "value"); + printf("start benchmark\n"); +} diff --git a/benchmark/protocols/poe/BUILD b/benchmark/protocols/poe/BUILD index 7f1cc05ec3..4c148b00c3 100644 --- a/benchmark/protocols/poe/BUILD +++ b/benchmark/protocols/poe/BUILD @@ -1,33 +1,33 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -package(default_visibility = ["//visibility:private"]) - -load("@bazel_skylib//rules:common_settings.bzl", "bool_flag") - -cc_binary( - name = "kv_server_performance", - srcs = ["kv_server_performance.cpp"], - deps = [ - "//chain/storage:memory_db", - "//executor/kv:kv_executor", - "//platform/config:resdb_config_utils", - "//platform/consensus/ordering/poe/framework:consensus", - "//service/utils:server_factory", - ], -) +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +package(default_visibility = ["//visibility:private"]) + +load("@bazel_skylib//rules:common_settings.bzl", "bool_flag") + +cc_binary( + name = "kv_server_performance", + srcs = ["kv_server_performance.cpp"], + deps = [ + "//chain/storage:memory_db", + "//executor/kv:kv_executor", + "//platform/config:resdb_config_utils", + "//platform/consensus/ordering/poe/framework:consensus", + "//service/utils:server_factory", + ], +) diff --git a/benchmark/protocols/poe/kv_server_performance.cpp b/benchmark/protocols/poe/kv_server_performance.cpp index 90a220a1fb..43c1aa0210 100644 --- a/benchmark/protocols/poe/kv_server_performance.cpp +++ b/benchmark/protocols/poe/kv_server_performance.cpp @@ -1,83 +1,83 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#include - -#include "chain/storage/memory_db.h" -#include "executor/kv/kv_executor.h" -#include "platform/config/resdb_config_utils.h" -#include "platform/consensus/ordering/poe/framework/consensus.h" -#include "platform/networkstrate/service_network.h" -#include "platform/statistic/stats.h" -#include "proto/kv/kv.pb.h" - -using namespace resdb; -using namespace resdb::poe; -using namespace resdb::storage; - -void ShowUsage() { - printf(" [logging_dir]\n"); -} - -std::string GetRandomKey() { - int num1 = rand() % 10; - int num2 = rand() % 10; - return std::to_string(num1) + std::to_string(num2); -} - -int main(int argc, char** argv) { - if (argc < 3) { - ShowUsage(); - exit(0); - } - - // google::InitGoogleLogging(argv[0]); - // FLAGS_minloglevel = google::GLOG_WARNING; - - char* config_file = argv[1]; - char* private_key_file = argv[2]; - char* cert_file = argv[3]; - - if (argc >= 5) { - auto monitor_port = Stats::GetGlobalStats(5); - monitor_port->SetPrometheus(argv[4]); - } - - std::unique_ptr config = - GenerateResDBConfig(config_file, private_key_file, cert_file); - - config->RunningPerformance(true); - ResConfigData config_data = config->GetConfigData(); - - auto performance_consens = std::make_unique( - *config, std::make_unique(std::make_unique())); - performance_consens->SetupPerformanceDataFunc([]() { - KVRequest request; - request.set_cmd(KVRequest::SET); - request.set_key(GetRandomKey()); - request.set_value("helloword"); - std::string request_data; - request.SerializeToString(&request_data); - return request_data; - }); - - auto server = - std::make_unique(*config, std::move(performance_consens)); - server->Run(); -} +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#include + +#include "chain/storage/memory_db.h" +#include "executor/kv/kv_executor.h" +#include "platform/config/resdb_config_utils.h" +#include "platform/consensus/ordering/poe/framework/consensus.h" +#include "platform/networkstrate/service_network.h" +#include "platform/statistic/stats.h" +#include "proto/kv/kv.pb.h" + +using namespace resdb; +using namespace resdb::poe; +using namespace resdb::storage; + +void ShowUsage() { + printf(" [logging_dir]\n"); +} + +std::string GetRandomKey() { + int num1 = rand() % 10; + int num2 = rand() % 10; + return std::to_string(num1) + std::to_string(num2); +} + +int main(int argc, char** argv) { + if (argc < 3) { + ShowUsage(); + exit(0); + } + + // google::InitGoogleLogging(argv[0]); + // FLAGS_minloglevel = google::GLOG_WARNING; + + char* config_file = argv[1]; + char* private_key_file = argv[2]; + char* cert_file = argv[3]; + + if (argc >= 5) { + auto monitor_port = Stats::GetGlobalStats(5); + monitor_port->SetPrometheus(argv[4]); + } + + std::unique_ptr config = + GenerateResDBConfig(config_file, private_key_file, cert_file); + + config->RunningPerformance(true); + ResConfigData config_data = config->GetConfigData(); + + auto performance_consens = std::make_unique( + *config, std::make_unique(std::make_unique())); + performance_consens->SetupPerformanceDataFunc([]() { + KVRequest request; + request.set_cmd(KVRequest::SET); + request.set_key(GetRandomKey()); + request.set_value("helloword"); + std::string request_data; + request.SerializeToString(&request_data); + return request_data; + }); + + auto server = + std::make_unique(*config, std::move(performance_consens)); + server->Run(); +} diff --git a/chain/state/BUILD b/chain/state/BUILD index f4bcde57f9..d980cd8ee8 100644 --- a/chain/state/BUILD +++ b/chain/state/BUILD @@ -1,38 +1,38 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -package(default_visibility = ["//visibility:public"]) - -cc_library( - name = "chain_state", - srcs = ["chain_state.cpp"], - hdrs = ["chain_state.h"], - deps = [ - "//common:comm", - "//platform/proto:resdb_cc_proto", - ], -) - -cc_test( - name = "chain_state_test", - srcs = ["chain_state_test.cpp"], - deps = [ - ":chain_state", - "//common/test:test_main", - ], -) +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +package(default_visibility = ["//visibility:public"]) + +cc_library( + name = "chain_state", + srcs = ["chain_state.cpp"], + hdrs = ["chain_state.h"], + deps = [ + "//common:comm", + "//platform/proto:resdb_cc_proto", + ], +) + +cc_test( + name = "chain_state_test", + srcs = ["chain_state_test.cpp"], + deps = [ + ":chain_state", + "//common/test:test_main", + ], +) diff --git a/chain/state/chain_state.cpp b/chain/state/chain_state.cpp index 18eaed71b5..700750d42b 100644 --- a/chain/state/chain_state.cpp +++ b/chain/state/chain_state.cpp @@ -1,44 +1,44 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#include "chain/state/chain_state.h" - -#include - -namespace resdb { - -ChainState::ChainState() : max_seq_(0) {} - -Request* ChainState::Get(uint64_t seq) { - std::unique_lock lk(mutex_); - if (data_.find(seq) == data_.end()) { - return nullptr; - } - return data_[seq].get(); -} - -void ChainState::Put(std::unique_ptr request) { - std::unique_lock lk(mutex_); - max_seq_ = request->seq(); - data_[max_seq_] = std::move(request); -} - -uint64_t ChainState::GetMaxSeq() { return max_seq_; } - -} // namespace resdb +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#include "chain/state/chain_state.h" + +#include + +namespace resdb { + +ChainState::ChainState() : max_seq_(0) {} + +Request* ChainState::Get(uint64_t seq) { + std::unique_lock lk(mutex_); + if (data_.find(seq) == data_.end()) { + return nullptr; + } + return data_[seq].get(); +} + +void ChainState::Put(std::unique_ptr request) { + std::unique_lock lk(mutex_); + max_seq_ = request->seq(); + data_[max_seq_] = std::move(request); +} + +uint64_t ChainState::GetMaxSeq() { return max_seq_; } + +} // namespace resdb diff --git a/chain/state/chain_state.h b/chain/state/chain_state.h index 697b1afcb6..c2699b6598 100644 --- a/chain/state/chain_state.h +++ b/chain/state/chain_state.h @@ -1,42 +1,42 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#pragma once - -#include -#include - -#include "platform/proto/resdb.pb.h" - -namespace resdb { - -class ChainState { - public: - ChainState(); - Request* Get(uint64_t seq); - void Put(std::unique_ptr request); - uint64_t GetMaxSeq(); - - private: - std::mutex mutex_; - std::unordered_map > data_; - std::atomic max_seq_; -}; - -} // namespace resdb +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#pragma once + +#include +#include + +#include "platform/proto/resdb.pb.h" + +namespace resdb { + +class ChainState { + public: + ChainState(); + Request* Get(uint64_t seq); + void Put(std::unique_ptr request); + uint64_t GetMaxSeq(); + + private: + std::mutex mutex_; + std::unordered_map > data_; + std::atomic max_seq_; +}; + +} // namespace resdb diff --git a/chain/state/chain_state_test.cpp b/chain/state/chain_state_test.cpp index 7fd3fbe195..068ce1a801 100644 --- a/chain/state/chain_state_test.cpp +++ b/chain/state/chain_state_test.cpp @@ -1,65 +1,65 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#include "chain/state/chain_state.h" - -#include -#include - -#include "common/test/test_macros.h" - -namespace resdb { -namespace { - -using ::resdb::testing::EqualsProto; -using ::testing::Pointee; - -TEST(ChainStateTest, GetEmptyValue) { - ChainState db; - EXPECT_EQ(db.Get(1), nullptr); -} - -TEST(ChainStateTest, GetValue) { - Request request; - request.set_seq(1); - request.set_data("test"); - - ChainState db; - db.Put(std::make_unique(request)); - EXPECT_THAT(db.Get(1), Pointee(EqualsProto(request))); -} - -TEST(ChainStateTest, GetSecondValue) { - Request request; - request.set_seq(1); - request.set_data("test"); - - ChainState db; - db.Put(std::make_unique(request)); - - request.set_seq(1); - request.set_data("test_1"); - db.Put(std::make_unique(request)); - - EXPECT_THAT(db.Get(1), Pointee(EqualsProto(request))); -} - -} // namespace - -} // namespace resdb +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#include "chain/state/chain_state.h" + +#include +#include + +#include "common/test/test_macros.h" + +namespace resdb { +namespace { + +using ::resdb::testing::EqualsProto; +using ::testing::Pointee; + +TEST(ChainStateTest, GetEmptyValue) { + ChainState db; + EXPECT_EQ(db.Get(1), nullptr); +} + +TEST(ChainStateTest, GetValue) { + Request request; + request.set_seq(1); + request.set_data("test"); + + ChainState db; + db.Put(std::make_unique(request)); + EXPECT_THAT(db.Get(1), Pointee(EqualsProto(request))); +} + +TEST(ChainStateTest, GetSecondValue) { + Request request; + request.set_seq(1); + request.set_data("test"); + + ChainState db; + db.Put(std::make_unique(request)); + + request.set_seq(1); + request.set_data("test_1"); + db.Put(std::make_unique(request)); + + EXPECT_THAT(db.Get(1), Pointee(EqualsProto(request))); +} + +} // namespace + +} // namespace resdb diff --git a/chain/storage/BUILD b/chain/storage/BUILD index a86c2a7ff4..68716f8afe 100644 --- a/chain/storage/BUILD +++ b/chain/storage/BUILD @@ -1,83 +1,83 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -package(default_visibility = ["//visibility:public"]) - -cc_library( - name = "storage", - hdrs = ["storage.h"], - deps = [ - ], -) - -cc_library( - name = "mock_storage", - hdrs = ["mock_storage.h"], - deps = [ - ":storage", - ], -) - -cc_library( - name = "memory_db", - srcs = ["memory_db.cpp"], - hdrs = ["memory_db.h"], - deps = [ - ":storage", - "//common:comm", - ], -) - -cc_library( - name = "leveldb", - srcs = ["leveldb.cpp"], - hdrs = ["leveldb.h"], - deps = [ - ":storage", - "//chain/storage/proto:kv_cc_proto", - "//chain/storage/proto:leveldb_config_cc_proto", - "//common:comm", - "//common/lru:lru_cache", - "//platform/statistic:stats", - "//third_party:leveldb", - ], -) - -cc_test( - name = "kv_storage_test", - srcs = ["kv_storage_test.cpp"], - deps = [ - ":leveldb", - ":memory_db", - "//common/test:test_main", - ], - timeout = "short", # Set the timeout to "short" - size = "small", # Set the size to "small" -) - -cc_test( - name = "leveldb_test", - srcs = ["leveldb_test.cpp"], - deps = [ - ":leveldb", - "//platform/statistic:stats", - "//common/test:test_main", - ], - timeout = "short", # Set the timeout to "short" - size = "small", # Set the size to "small" +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +package(default_visibility = ["//visibility:public"]) + +cc_library( + name = "storage", + hdrs = ["storage.h"], + deps = [ + ], +) + +cc_library( + name = "mock_storage", + hdrs = ["mock_storage.h"], + deps = [ + ":storage", + ], +) + +cc_library( + name = "memory_db", + srcs = ["memory_db.cpp"], + hdrs = ["memory_db.h"], + deps = [ + ":storage", + "//common:comm", + ], +) + +cc_library( + name = "leveldb", + srcs = ["leveldb.cpp"], + hdrs = ["leveldb.h"], + deps = [ + ":storage", + "//chain/storage/proto:kv_cc_proto", + "//chain/storage/proto:leveldb_config_cc_proto", + "//common:comm", + "//common/lru:lru_cache", + "//platform/statistic:stats", + "//third_party:leveldb", + ], +) + +cc_test( + name = "kv_storage_test", + srcs = ["kv_storage_test.cpp"], + deps = [ + ":leveldb", + ":memory_db", + "//common/test:test_main", + ], + timeout = "short", # Set the timeout to "short" + size = "small", # Set the size to "small" +) + +cc_test( + name = "leveldb_test", + srcs = ["leveldb_test.cpp"], + deps = [ + ":leveldb", + "//platform/statistic:stats", + "//common/test:test_main", + ], + timeout = "short", # Set the timeout to "short" + size = "small", # Set the size to "small" ) \ No newline at end of file diff --git a/chain/storage/kv_storage_test.cpp b/chain/storage/kv_storage_test.cpp index 2e55161f07..526125d008 100644 --- a/chain/storage/kv_storage_test.cpp +++ b/chain/storage/kv_storage_test.cpp @@ -1,237 +1,237 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#include -#include -#include - -#include - -#include "chain/storage/leveldb.h" -#include "chain/storage/memory_db.h" - -namespace resdb { -namespace storage { -namespace { - -enum StorageType { MEM = 0, LEVELDB = 1, LEVELDB_WITH_BLOCK_CACHE = 2 }; - -class KVStorageTest : public ::testing::TestWithParam { - protected: - KVStorageTest() { - StorageType t = GetParam(); - switch (t) { - case MEM: - storage = NewMemoryDB(); - break; - case LEVELDB: - Reset(); - storage = NewResLevelDB(path_); - break; - case LEVELDB_WITH_BLOCK_CACHE: - Reset(); - LevelDBInfo config; - config.set_enable_block_cache(true); - storage = NewResLevelDB(path_, config); - break; - } - } - - private: - void Reset() { std::filesystem::remove_all(path_.c_str()); } - - protected: - std::unique_ptr storage; - std::string path_ = "/tmp/leveldb_test"; -}; - -TEST_P(KVStorageTest, SetValue) { - EXPECT_EQ(storage->SetValue("test_key", "test_value"), 0); - EXPECT_EQ(storage->GetValue("test_key"), "test_value"); -} - -TEST_P(KVStorageTest, GetValue) { - EXPECT_EQ(storage->GetValue("test_key"), ""); -} - -TEST_P(KVStorageTest, GetEmptyValueWithVersion) { - EXPECT_EQ(storage->GetValueWithVersion("test_key", 0), - std::make_pair(std::string(""), 0)); -} - -TEST_P(KVStorageTest, SetValueWithVersion) { - EXPECT_EQ(storage->SetValueWithVersion("test_key", "test_value", 1), -2); - - EXPECT_EQ(storage->SetValueWithVersion("test_key", "test_value", 0), 0); - - EXPECT_EQ(storage->GetValueWithVersion("test_key", 0), - std::make_pair(std::string("test_value"), 1)); - EXPECT_EQ(storage->GetValueWithVersion("test_key", 1), - std::make_pair(std::string("test_value"), 1)); - - EXPECT_EQ(storage->SetValueWithVersion("test_key", "test_value_v2", 2), -2); - EXPECT_EQ(storage->SetValueWithVersion("test_key", "test_value_v2", 1), 0); - - EXPECT_EQ(storage->GetValueWithVersion("test_key", 0), - std::make_pair(std::string("test_value_v2"), 2)); - - EXPECT_EQ(storage->GetValueWithVersion("test_key", 1), - std::make_pair(std::string("test_value"), 1)); - - EXPECT_EQ(storage->GetValueWithVersion("test_key", 2), - std::make_pair(std::string("test_value_v2"), 2)); - - EXPECT_EQ(storage->GetValueWithVersion("test_key", 3), - std::make_pair(std::string("test_value_v2"), 2)); -} - -TEST_P(KVStorageTest, GetAllValueWithVersion) { - { - std::map > expected_list{ - std::make_pair("test_key", std::make_pair("test_value", 1))}; - - EXPECT_EQ(storage->SetValueWithVersion("test_key", "test_value", 0), 0); - EXPECT_EQ(storage->GetAllItems(), expected_list); - } - - { - std::map > expected_list{ - std::make_pair("test_key", std::make_pair("test_value_v2", 2))}; - EXPECT_EQ(storage->SetValueWithVersion("test_key", "test_value_v2", 1), 0); - EXPECT_EQ(storage->GetAllItems(), expected_list); - } - - { - std::map > expected_list{ - std::make_pair("test_key_v1", std::make_pair("test_value1", 1)), - std::make_pair("test_key", std::make_pair("test_value_v2", 2))}; - EXPECT_EQ(storage->SetValueWithVersion("test_key_v1", "test_value1", 0), 0); - EXPECT_EQ(storage->GetAllItems(), expected_list); - } -} - -TEST_P(KVStorageTest, GetKeyRange) { - EXPECT_EQ(storage->SetValueWithVersion("1", "value1", 0), 0); - EXPECT_EQ(storage->SetValueWithVersion("2", "value2", 0), 0); - EXPECT_EQ(storage->SetValueWithVersion("3", "value3", 0), 0); - EXPECT_EQ(storage->SetValueWithVersion("4", "value4", 0), 0); - - { - std::map > expected_list{ - std::make_pair("1", std::make_pair("value1", 1)), - std::make_pair("2", std::make_pair("value2", 1)), - std::make_pair("3", std::make_pair("value3", 1)), - std::make_pair("4", std::make_pair("value4", 1))}; - EXPECT_EQ(storage->GetKeyRange("1", "4"), expected_list); - } - - EXPECT_EQ(storage->SetValueWithVersion("3", "value3_1", 1), 0); - { - std::map > expected_list{ - std::make_pair("1", std::make_pair("value1", 1)), - std::make_pair("2", std::make_pair("value2", 1)), - std::make_pair("3", std::make_pair("value3_1", 2)), - std::make_pair("4", std::make_pair("value4", 1))}; - EXPECT_EQ(storage->GetKeyRange("1", "4"), expected_list); - } - { - std::map > expected_list{ - std::make_pair("1", std::make_pair("value1", 1)), - std::make_pair("2", std::make_pair("value2", 1)), - std::make_pair("3", std::make_pair("value3_1", 2)), - }; - EXPECT_EQ(storage->GetKeyRange("1", "3"), expected_list); - } - { - std::map > expected_list{ - std::make_pair("2", std::make_pair("value2", 1)), - std::make_pair("3", std::make_pair("value3_1", 2)), - std::make_pair("4", std::make_pair("value4", 1))}; - EXPECT_EQ(storage->GetKeyRange("2", "4"), expected_list); - } - { - std::map > expected_list{ - std::make_pair("1", std::make_pair("value1", 1)), - std::make_pair("2", std::make_pair("value2", 1)), - std::make_pair("3", std::make_pair("value3_1", 2)), - std::make_pair("4", std::make_pair("value4", 1))}; - EXPECT_EQ(storage->GetKeyRange("0", "5"), expected_list); - } - { - std::map > expected_list{ - std::make_pair("2", std::make_pair("value2", 1)), - std::make_pair("3", std::make_pair("value3_1", 2)), - }; - EXPECT_EQ(storage->GetKeyRange("2", "3"), expected_list); - } -} - -TEST_P(KVStorageTest, GetHistory) { - { - std::vector > expected_list{}; - EXPECT_EQ(storage->GetHistory("1", 1, 5), expected_list); - } - { - std::vector > expected_list{ - std::make_pair("value3", 3), std::make_pair("value2", 2), - std::make_pair("value1", 1)}; - - EXPECT_EQ(storage->SetValueWithVersion("1", "value1", 0), 0); - EXPECT_EQ(storage->SetValueWithVersion("1", "value2", 1), 0); - EXPECT_EQ(storage->SetValueWithVersion("1", "value3", 2), 0); - - EXPECT_EQ(storage->GetHistory("1", 1, 5), expected_list); - } - - { - std::vector > expected_list{ - std::make_pair("value5", 5), std::make_pair("value4", 4), - std::make_pair("value3", 3), std::make_pair("value2", 2), - std::make_pair("value1", 1)}; - - EXPECT_EQ(storage->SetValueWithVersion("1", "value4", 3), 0); - EXPECT_EQ(storage->SetValueWithVersion("1", "value5", 4), 0); - EXPECT_EQ(storage->SetValueWithVersion("1", "value6", 5), 0); - EXPECT_EQ(storage->SetValueWithVersion("1", "value7", 6), 0); - - EXPECT_EQ(storage->GetHistory("1", 1, 5), expected_list); - } - - { - std::vector > expected_list{ - std::make_pair("value7", 7), std::make_pair("value6", 6)}; - - EXPECT_EQ(storage->GetTopHistory("1", 2), expected_list); - } -} - -TEST_P(KVStorageTest, BlockCacheSpecificTest) { - if (GetParam() == LEVELDB_WITH_BLOCK_CACHE) { - std::cout << "Running BlockCacheSpecificTest for LEVELDB_WITH_BLOCK_CACHE" - << std::endl; - } -} - -INSTANTIATE_TEST_CASE_P(KVStorageTest, KVStorageTest, - ::testing::Values(MEM, LEVELDB, - LEVELDB_WITH_BLOCK_CACHE)); - -} // namespace -} // namespace storage -} // namespace resdb +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#include +#include +#include + +#include + +#include "chain/storage/leveldb.h" +#include "chain/storage/memory_db.h" + +namespace resdb { +namespace storage { +namespace { + +enum StorageType { MEM = 0, LEVELDB = 1, LEVELDB_WITH_BLOCK_CACHE = 2 }; + +class KVStorageTest : public ::testing::TestWithParam { + protected: + KVStorageTest() { + StorageType t = GetParam(); + switch (t) { + case MEM: + storage = NewMemoryDB(); + break; + case LEVELDB: + Reset(); + storage = NewResLevelDB(path_); + break; + case LEVELDB_WITH_BLOCK_CACHE: + Reset(); + LevelDBInfo config; + config.set_enable_block_cache(true); + storage = NewResLevelDB(path_, config); + break; + } + } + + private: + void Reset() { std::filesystem::remove_all(path_.c_str()); } + + protected: + std::unique_ptr storage; + std::string path_ = "/tmp/leveldb_test"; +}; + +TEST_P(KVStorageTest, SetValue) { + EXPECT_EQ(storage->SetValue("test_key", "test_value"), 0); + EXPECT_EQ(storage->GetValue("test_key"), "test_value"); +} + +TEST_P(KVStorageTest, GetValue) { + EXPECT_EQ(storage->GetValue("test_key"), ""); +} + +TEST_P(KVStorageTest, GetEmptyValueWithVersion) { + EXPECT_EQ(storage->GetValueWithVersion("test_key", 0), + std::make_pair(std::string(""), 0)); +} + +TEST_P(KVStorageTest, SetValueWithVersion) { + EXPECT_EQ(storage->SetValueWithVersion("test_key", "test_value", 1), -2); + + EXPECT_EQ(storage->SetValueWithVersion("test_key", "test_value", 0), 0); + + EXPECT_EQ(storage->GetValueWithVersion("test_key", 0), + std::make_pair(std::string("test_value"), 1)); + EXPECT_EQ(storage->GetValueWithVersion("test_key", 1), + std::make_pair(std::string("test_value"), 1)); + + EXPECT_EQ(storage->SetValueWithVersion("test_key", "test_value_v2", 2), -2); + EXPECT_EQ(storage->SetValueWithVersion("test_key", "test_value_v2", 1), 0); + + EXPECT_EQ(storage->GetValueWithVersion("test_key", 0), + std::make_pair(std::string("test_value_v2"), 2)); + + EXPECT_EQ(storage->GetValueWithVersion("test_key", 1), + std::make_pair(std::string("test_value"), 1)); + + EXPECT_EQ(storage->GetValueWithVersion("test_key", 2), + std::make_pair(std::string("test_value_v2"), 2)); + + EXPECT_EQ(storage->GetValueWithVersion("test_key", 3), + std::make_pair(std::string("test_value_v2"), 2)); +} + +TEST_P(KVStorageTest, GetAllValueWithVersion) { + { + std::map > expected_list{ + std::make_pair("test_key", std::make_pair("test_value", 1))}; + + EXPECT_EQ(storage->SetValueWithVersion("test_key", "test_value", 0), 0); + EXPECT_EQ(storage->GetAllItems(), expected_list); + } + + { + std::map > expected_list{ + std::make_pair("test_key", std::make_pair("test_value_v2", 2))}; + EXPECT_EQ(storage->SetValueWithVersion("test_key", "test_value_v2", 1), 0); + EXPECT_EQ(storage->GetAllItems(), expected_list); + } + + { + std::map > expected_list{ + std::make_pair("test_key_v1", std::make_pair("test_value1", 1)), + std::make_pair("test_key", std::make_pair("test_value_v2", 2))}; + EXPECT_EQ(storage->SetValueWithVersion("test_key_v1", "test_value1", 0), 0); + EXPECT_EQ(storage->GetAllItems(), expected_list); + } +} + +TEST_P(KVStorageTest, GetKeyRange) { + EXPECT_EQ(storage->SetValueWithVersion("1", "value1", 0), 0); + EXPECT_EQ(storage->SetValueWithVersion("2", "value2", 0), 0); + EXPECT_EQ(storage->SetValueWithVersion("3", "value3", 0), 0); + EXPECT_EQ(storage->SetValueWithVersion("4", "value4", 0), 0); + + { + std::map > expected_list{ + std::make_pair("1", std::make_pair("value1", 1)), + std::make_pair("2", std::make_pair("value2", 1)), + std::make_pair("3", std::make_pair("value3", 1)), + std::make_pair("4", std::make_pair("value4", 1))}; + EXPECT_EQ(storage->GetKeyRange("1", "4"), expected_list); + } + + EXPECT_EQ(storage->SetValueWithVersion("3", "value3_1", 1), 0); + { + std::map > expected_list{ + std::make_pair("1", std::make_pair("value1", 1)), + std::make_pair("2", std::make_pair("value2", 1)), + std::make_pair("3", std::make_pair("value3_1", 2)), + std::make_pair("4", std::make_pair("value4", 1))}; + EXPECT_EQ(storage->GetKeyRange("1", "4"), expected_list); + } + { + std::map > expected_list{ + std::make_pair("1", std::make_pair("value1", 1)), + std::make_pair("2", std::make_pair("value2", 1)), + std::make_pair("3", std::make_pair("value3_1", 2)), + }; + EXPECT_EQ(storage->GetKeyRange("1", "3"), expected_list); + } + { + std::map > expected_list{ + std::make_pair("2", std::make_pair("value2", 1)), + std::make_pair("3", std::make_pair("value3_1", 2)), + std::make_pair("4", std::make_pair("value4", 1))}; + EXPECT_EQ(storage->GetKeyRange("2", "4"), expected_list); + } + { + std::map > expected_list{ + std::make_pair("1", std::make_pair("value1", 1)), + std::make_pair("2", std::make_pair("value2", 1)), + std::make_pair("3", std::make_pair("value3_1", 2)), + std::make_pair("4", std::make_pair("value4", 1))}; + EXPECT_EQ(storage->GetKeyRange("0", "5"), expected_list); + } + { + std::map > expected_list{ + std::make_pair("2", std::make_pair("value2", 1)), + std::make_pair("3", std::make_pair("value3_1", 2)), + }; + EXPECT_EQ(storage->GetKeyRange("2", "3"), expected_list); + } +} + +TEST_P(KVStorageTest, GetHistory) { + { + std::vector > expected_list{}; + EXPECT_EQ(storage->GetHistory("1", 1, 5), expected_list); + } + { + std::vector > expected_list{ + std::make_pair("value3", 3), std::make_pair("value2", 2), + std::make_pair("value1", 1)}; + + EXPECT_EQ(storage->SetValueWithVersion("1", "value1", 0), 0); + EXPECT_EQ(storage->SetValueWithVersion("1", "value2", 1), 0); + EXPECT_EQ(storage->SetValueWithVersion("1", "value3", 2), 0); + + EXPECT_EQ(storage->GetHistory("1", 1, 5), expected_list); + } + + { + std::vector > expected_list{ + std::make_pair("value5", 5), std::make_pair("value4", 4), + std::make_pair("value3", 3), std::make_pair("value2", 2), + std::make_pair("value1", 1)}; + + EXPECT_EQ(storage->SetValueWithVersion("1", "value4", 3), 0); + EXPECT_EQ(storage->SetValueWithVersion("1", "value5", 4), 0); + EXPECT_EQ(storage->SetValueWithVersion("1", "value6", 5), 0); + EXPECT_EQ(storage->SetValueWithVersion("1", "value7", 6), 0); + + EXPECT_EQ(storage->GetHistory("1", 1, 5), expected_list); + } + + { + std::vector > expected_list{ + std::make_pair("value7", 7), std::make_pair("value6", 6)}; + + EXPECT_EQ(storage->GetTopHistory("1", 2), expected_list); + } +} + +TEST_P(KVStorageTest, BlockCacheSpecificTest) { + if (GetParam() == LEVELDB_WITH_BLOCK_CACHE) { + std::cout << "Running BlockCacheSpecificTest for LEVELDB_WITH_BLOCK_CACHE" + << std::endl; + } +} + +INSTANTIATE_TEST_CASE_P(KVStorageTest, KVStorageTest, + ::testing::Values(MEM, LEVELDB, + LEVELDB_WITH_BLOCK_CACHE)); + +} // namespace +} // namespace storage +} // namespace resdb diff --git a/chain/storage/leveldb.cpp b/chain/storage/leveldb.cpp index f6122b5ad9..f5e50e1a29 100644 --- a/chain/storage/leveldb.cpp +++ b/chain/storage/leveldb.cpp @@ -1,334 +1,334 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#include "chain/storage/leveldb.h" - -#include -#include - -#include - -#include "chain/storage/proto/kv.pb.h" -#include "leveldb/options.h" - -namespace resdb { -namespace storage { - -std::unique_ptr NewResLevelDB(const std::string& path, - std::optional config) { - if (config == std::nullopt) { - config = LevelDBInfo(); - } - (*config).set_path(path); - return std::make_unique(config); -} - -std::unique_ptr NewResLevelDB(std::optional config) { - return std::make_unique(config); -} - -ResLevelDB::ResLevelDB(std::optional config) { - std::string path = "/tmp/nexres-leveldb"; - if (config.has_value()) { - write_buffer_size_ = (*config).write_buffer_size_mb() << 20; - write_batch_size_ = (*config).write_batch_size(); - if (!(*config).path().empty()) { - LOG(ERROR) << "Custom path for ResLevelDB provided in config: " - << (*config).path(); - path = (*config).path(); - } - } - if ((*config).enable_block_cache()) { - uint32_t capacity = 1000; - if ((*config).has_block_cache_capacity()) { - capacity = (*config).block_cache_capacity(); - } - block_cache_ = - std::make_unique>(capacity); - LOG(ERROR) << "initialized block cache" << std::endl; - } - global_stats_ = Stats::GetGlobalStats(); - CreateDB(path); -} - -void ResLevelDB::CreateDB(const std::string& path) { - LOG(ERROR) << "ResLevelDB Create DB: path:" << path - << " write buffer size:" << write_buffer_size_ - << " batch size:" << write_batch_size_; - leveldb::Options options; - options.create_if_missing = true; - options.write_buffer_size = write_buffer_size_; - - leveldb::DB* db = nullptr; - leveldb::Status status = leveldb::DB::Open(options, path, &db); - if (status.ok()) { - db_ = std::unique_ptr(db); - } - assert(status.ok()); - LOG(ERROR) << "Successfully opened LevelDB"; -} - -ResLevelDB::~ResLevelDB() { - if (db_) { - db_.reset(); - } - if (block_cache_) { - block_cache_->Flush(); - } -} - -int ResLevelDB::SetValue(const std::string& key, const std::string& value) { - if (block_cache_) { - block_cache_->Put(key, value); - } - batch_.Put(key, value); - - if (batch_.ApproximateSize() >= write_batch_size_) { - leveldb::Status status = db_->Write(leveldb::WriteOptions(), &batch_); - if (status.ok()) { - batch_.Clear(); - UpdateMetrics(); - return 0; - } else { - LOG(ERROR) << "flush buffer fail:" << status.ToString(); - return -1; - } - } - return 0; -} - -std::string ResLevelDB::GetValue(const std::string& key) { - std::string value; - bool found_in_cache = false; - - if (block_cache_) { - value = block_cache_->Get(key); - found_in_cache = !value.empty(); - } - - if (!found_in_cache) { - leveldb::Status status = db_->Get(leveldb::ReadOptions(), key, &value); - if (!status.ok()) { - value.clear(); // Ensure value is empty if not found in DB - } - } - - UpdateMetrics(); - return value; -} - -std::string ResLevelDB::GetAllValues(void) { - std::string values = "["; - leveldb::Iterator* it = db_->NewIterator(leveldb::ReadOptions()); - bool first_iteration = true; - for (it->SeekToFirst(); it->Valid(); it->Next()) { - if (!first_iteration) values.append(","); - first_iteration = false; - values.append(it->value().ToString()); - } - values.append("]"); - - delete it; - return values; -} - -std::string ResLevelDB::GetRange(const std::string& min_key, - const std::string& max_key) { - std::string values = "["; - leveldb::Iterator* it = db_->NewIterator(leveldb::ReadOptions()); - bool first_iteration = true; - for (it->Seek(min_key); it->Valid() && it->key().ToString() <= max_key; - it->Next()) { - if (!first_iteration) values.append(","); - first_iteration = false; - values.append(it->value().ToString()); - } - values.append("]"); - - delete it; - return values; -} - -bool ResLevelDB::UpdateMetrics() { - if (block_cache_ == nullptr) { - return false; - } - std::string stats; - std::string approximate_size; - db_->GetProperty("leveldb.stats", &stats); - db_->GetProperty("leveldb.approximate-memory-usage", &approximate_size); - global_stats_->SetStorageEngineMetrics(block_cache_->GetCacheHitRatio(), - stats, approximate_size); - return true; -} - -bool ResLevelDB::Flush() { - leveldb::Status status = db_->Write(leveldb::WriteOptions(), &batch_); - if (status.ok()) { - batch_.Clear(); - return true; - } - LOG(ERROR) << "flush buffer fail:" << status.ToString(); - return false; -} - -int ResLevelDB::SetValueWithVersion(const std::string& key, - const std::string& value, int version) { - std::string value_str = GetValue(key); - ValueHistory history; - if (!history.ParseFromString(value_str)) { - LOG(ERROR) << "old_value parse fail"; - return -2; - } - - int last_v = 0; - if (history.value_size() > 0) { - last_v = history.value(history.value_size() - 1).version(); - } - - if (last_v != version) { - LOG(ERROR) << "version does not match:" << version - << " old version:" << last_v; - return -2; - } - - Value* new_value = history.add_value(); - new_value->set_value(value); - new_value->set_version(version + 1); - - history.SerializeToString(&value_str); - return SetValue(key, value_str); -} - -std::pair ResLevelDB::GetValueWithVersion( - const std::string& key, int version) { - std::string value_str = GetValue(key); - ValueHistory history; - if (!history.ParseFromString(value_str)) { - LOG(ERROR) << "old_value parse fail"; - return std::make_pair("", 0); - } - if (history.value_size() == 0) { - return std::make_pair("", 0); - } - if (version > 0) { - for (int i = history.value_size() - 1; i >= 0; --i) { - if (history.value(i).version() == version) { - return std::make_pair(history.value(i).value(), - history.value(i).version()); - } - if (history.value(i).version() < version) { - break; - } - } - } - int last_idx = history.value_size() - 1; - return std::make_pair(history.value(last_idx).value(), - history.value(last_idx).version()); -} - -// Return a map of > -std::map> ResLevelDB::GetAllItems() { - std::map> resp; - - leveldb::Iterator* it = db_->NewIterator(leveldb::ReadOptions()); - for (it->SeekToFirst(); it->Valid(); it->Next()) { - ValueHistory history; - if (!history.ParseFromString(it->value().ToString()) || - history.value_size() == 0) { - LOG(ERROR) << "old_value parse fail"; - continue; - } - const Value& value = history.value(history.value_size() - 1); - resp.insert(std::make_pair(it->key().ToString(), - std::make_pair(value.value(), value.version()))); - } - delete it; - - return resp; -} - -std::map> ResLevelDB::GetKeyRange( - const std::string& min_key, const std::string& max_key) { - std::map> resp; - - leveldb::Iterator* it = db_->NewIterator(leveldb::ReadOptions()); - for (it->Seek(min_key); it->Valid() && it->key().ToString() <= max_key; - it->Next()) { - ValueHistory history; - if (!history.ParseFromString(it->value().ToString()) || - history.value_size() == 0) { - LOG(ERROR) << "old_value parse fail"; - continue; - } - const Value& value = history.value(history.value_size() - 1); - resp.insert(std::make_pair(it->key().ToString(), - std::make_pair(value.value(), value.version()))); - } - delete it; - - return resp; -} - -// Return a list of -std::vector> ResLevelDB::GetHistory( - const std::string& key, int min_version, int max_version) { - std::vector> resp; - std::string value_str = GetValue(key); - ValueHistory history; - if (!history.ParseFromString(value_str)) { - LOG(ERROR) << "old_value parse fail"; - return resp; - } - - for (int i = history.value_size() - 1; i >= 0; --i) { - if (history.value(i).version() < min_version) { - break; - } - if (history.value(i).version() <= max_version) { - resp.push_back( - std::make_pair(history.value(i).value(), history.value(i).version())); - } - } - - return resp; -} - -// Return a list of -std::vector> ResLevelDB::GetTopHistory( - const std::string& key, int top_number) { - std::vector> resp; - std::string value_str = GetValue(key); - ValueHistory history; - if (!history.ParseFromString(value_str)) { - LOG(ERROR) << "old_value parse fail"; - return resp; - } - - for (int i = history.value_size() - 1; - i >= 0 && resp.size() < static_cast(top_number); --i) { - resp.push_back( - std::make_pair(history.value(i).value(), history.value(i).version())); - } - - return resp; -} - -} // namespace storage -} // namespace resdb +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#include "chain/storage/leveldb.h" + +#include +#include + +#include + +#include "chain/storage/proto/kv.pb.h" +#include "leveldb/options.h" + +namespace resdb { +namespace storage { + +std::unique_ptr NewResLevelDB(const std::string& path, + std::optional config) { + if (config == std::nullopt) { + config = LevelDBInfo(); + } + (*config).set_path(path); + return std::make_unique(config); +} + +std::unique_ptr NewResLevelDB(std::optional config) { + return std::make_unique(config); +} + +ResLevelDB::ResLevelDB(std::optional config) { + std::string path = "/tmp/nexres-leveldb"; + if (config.has_value()) { + write_buffer_size_ = (*config).write_buffer_size_mb() << 20; + write_batch_size_ = (*config).write_batch_size(); + if (!(*config).path().empty()) { + LOG(ERROR) << "Custom path for ResLevelDB provided in config: " + << (*config).path(); + path = (*config).path(); + } + } + if ((*config).enable_block_cache()) { + uint32_t capacity = 1000; + if ((*config).has_block_cache_capacity()) { + capacity = (*config).block_cache_capacity(); + } + block_cache_ = + std::make_unique>(capacity); + LOG(ERROR) << "initialized block cache" << std::endl; + } + global_stats_ = Stats::GetGlobalStats(); + CreateDB(path); +} + +void ResLevelDB::CreateDB(const std::string& path) { + LOG(ERROR) << "ResLevelDB Create DB: path:" << path + << " write buffer size:" << write_buffer_size_ + << " batch size:" << write_batch_size_; + leveldb::Options options; + options.create_if_missing = true; + options.write_buffer_size = write_buffer_size_; + + leveldb::DB* db = nullptr; + leveldb::Status status = leveldb::DB::Open(options, path, &db); + if (status.ok()) { + db_ = std::unique_ptr(db); + } + assert(status.ok()); + LOG(ERROR) << "Successfully opened LevelDB"; +} + +ResLevelDB::~ResLevelDB() { + if (db_) { + db_.reset(); + } + if (block_cache_) { + block_cache_->Flush(); + } +} + +int ResLevelDB::SetValue(const std::string& key, const std::string& value) { + if (block_cache_) { + block_cache_->Put(key, value); + } + batch_.Put(key, value); + + if (batch_.ApproximateSize() >= write_batch_size_) { + leveldb::Status status = db_->Write(leveldb::WriteOptions(), &batch_); + if (status.ok()) { + batch_.Clear(); + UpdateMetrics(); + return 0; + } else { + LOG(ERROR) << "flush buffer fail:" << status.ToString(); + return -1; + } + } + return 0; +} + +std::string ResLevelDB::GetValue(const std::string& key) { + std::string value; + bool found_in_cache = false; + + if (block_cache_) { + value = block_cache_->Get(key); + found_in_cache = !value.empty(); + } + + if (!found_in_cache) { + leveldb::Status status = db_->Get(leveldb::ReadOptions(), key, &value); + if (!status.ok()) { + value.clear(); // Ensure value is empty if not found in DB + } + } + + UpdateMetrics(); + return value; +} + +std::string ResLevelDB::GetAllValues(void) { + std::string values = "["; + leveldb::Iterator* it = db_->NewIterator(leveldb::ReadOptions()); + bool first_iteration = true; + for (it->SeekToFirst(); it->Valid(); it->Next()) { + if (!first_iteration) values.append(","); + first_iteration = false; + values.append(it->value().ToString()); + } + values.append("]"); + + delete it; + return values; +} + +std::string ResLevelDB::GetRange(const std::string& min_key, + const std::string& max_key) { + std::string values = "["; + leveldb::Iterator* it = db_->NewIterator(leveldb::ReadOptions()); + bool first_iteration = true; + for (it->Seek(min_key); it->Valid() && it->key().ToString() <= max_key; + it->Next()) { + if (!first_iteration) values.append(","); + first_iteration = false; + values.append(it->value().ToString()); + } + values.append("]"); + + delete it; + return values; +} + +bool ResLevelDB::UpdateMetrics() { + if (block_cache_ == nullptr) { + return false; + } + std::string stats; + std::string approximate_size; + db_->GetProperty("leveldb.stats", &stats); + db_->GetProperty("leveldb.approximate-memory-usage", &approximate_size); + global_stats_->SetStorageEngineMetrics(block_cache_->GetCacheHitRatio(), + stats, approximate_size); + return true; +} + +bool ResLevelDB::Flush() { + leveldb::Status status = db_->Write(leveldb::WriteOptions(), &batch_); + if (status.ok()) { + batch_.Clear(); + return true; + } + LOG(ERROR) << "flush buffer fail:" << status.ToString(); + return false; +} + +int ResLevelDB::SetValueWithVersion(const std::string& key, + const std::string& value, int version) { + std::string value_str = GetValue(key); + ValueHistory history; + if (!history.ParseFromString(value_str)) { + LOG(ERROR) << "old_value parse fail"; + return -2; + } + + int last_v = 0; + if (history.value_size() > 0) { + last_v = history.value(history.value_size() - 1).version(); + } + + if (last_v != version) { + LOG(ERROR) << "version does not match:" << version + << " old version:" << last_v; + return -2; + } + + Value* new_value = history.add_value(); + new_value->set_value(value); + new_value->set_version(version + 1); + + history.SerializeToString(&value_str); + return SetValue(key, value_str); +} + +std::pair ResLevelDB::GetValueWithVersion( + const std::string& key, int version) { + std::string value_str = GetValue(key); + ValueHistory history; + if (!history.ParseFromString(value_str)) { + LOG(ERROR) << "old_value parse fail"; + return std::make_pair("", 0); + } + if (history.value_size() == 0) { + return std::make_pair("", 0); + } + if (version > 0) { + for (int i = history.value_size() - 1; i >= 0; --i) { + if (history.value(i).version() == version) { + return std::make_pair(history.value(i).value(), + history.value(i).version()); + } + if (history.value(i).version() < version) { + break; + } + } + } + int last_idx = history.value_size() - 1; + return std::make_pair(history.value(last_idx).value(), + history.value(last_idx).version()); +} + +// Return a map of > +std::map> ResLevelDB::GetAllItems() { + std::map> resp; + + leveldb::Iterator* it = db_->NewIterator(leveldb::ReadOptions()); + for (it->SeekToFirst(); it->Valid(); it->Next()) { + ValueHistory history; + if (!history.ParseFromString(it->value().ToString()) || + history.value_size() == 0) { + LOG(ERROR) << "old_value parse fail"; + continue; + } + const Value& value = history.value(history.value_size() - 1); + resp.insert(std::make_pair(it->key().ToString(), + std::make_pair(value.value(), value.version()))); + } + delete it; + + return resp; +} + +std::map> ResLevelDB::GetKeyRange( + const std::string& min_key, const std::string& max_key) { + std::map> resp; + + leveldb::Iterator* it = db_->NewIterator(leveldb::ReadOptions()); + for (it->Seek(min_key); it->Valid() && it->key().ToString() <= max_key; + it->Next()) { + ValueHistory history; + if (!history.ParseFromString(it->value().ToString()) || + history.value_size() == 0) { + LOG(ERROR) << "old_value parse fail"; + continue; + } + const Value& value = history.value(history.value_size() - 1); + resp.insert(std::make_pair(it->key().ToString(), + std::make_pair(value.value(), value.version()))); + } + delete it; + + return resp; +} + +// Return a list of +std::vector> ResLevelDB::GetHistory( + const std::string& key, int min_version, int max_version) { + std::vector> resp; + std::string value_str = GetValue(key); + ValueHistory history; + if (!history.ParseFromString(value_str)) { + LOG(ERROR) << "old_value parse fail"; + return resp; + } + + for (int i = history.value_size() - 1; i >= 0; --i) { + if (history.value(i).version() < min_version) { + break; + } + if (history.value(i).version() <= max_version) { + resp.push_back( + std::make_pair(history.value(i).value(), history.value(i).version())); + } + } + + return resp; +} + +// Return a list of +std::vector> ResLevelDB::GetTopHistory( + const std::string& key, int top_number) { + std::vector> resp; + std::string value_str = GetValue(key); + ValueHistory history; + if (!history.ParseFromString(value_str)) { + LOG(ERROR) << "old_value parse fail"; + return resp; + } + + for (int i = history.value_size() - 1; + i >= 0 && resp.size() < static_cast(top_number); --i) { + resp.push_back( + std::make_pair(history.value(i).value(), history.value(i).version())); + } + + return resp; +} + +} // namespace storage +} // namespace resdb diff --git a/chain/storage/leveldb.h b/chain/storage/leveldb.h index 6103ec20b8..c215abbf14 100644 --- a/chain/storage/leveldb.h +++ b/chain/storage/leveldb.h @@ -1,89 +1,89 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#pragma once - -#include -#include -#include - -#include "chain/storage/proto/leveldb_config.pb.h" -#include "chain/storage/storage.h" -#include "common/lru/lru_cache.h" -#include "leveldb/db.h" -#include "leveldb/write_batch.h" -#include "platform/statistic/stats.h" - -namespace resdb { -namespace storage { - -std::unique_ptr NewResLevelDB( - const std::string& path, std::optional config = std::nullopt); -std::unique_ptr NewResLevelDB( - std::optional config = std::nullopt); - -class ResLevelDB : public Storage { - public: - ResLevelDB(std::optional config_data = std::nullopt); - - virtual ~ResLevelDB(); - int SetValue(const std::string& key, const std::string& value) override; - std::string GetValue(const std::string& key) override; - std::string GetAllValues(void) override; - std::string GetRange(const std::string& min_key, - const std::string& max_key) override; - - int SetValueWithVersion(const std::string& key, const std::string& value, - int version) override; - std::pair GetValueWithVersion(const std::string& key, - int version) override; - - // Return a map of > - std::map> GetAllItems() override; - std::map> GetKeyRange( - const std::string& min_key, const std::string& max_key) override; - - // Return a list of - std::vector> GetHistory(const std::string& key, - int min_version, - int max_version) override; - - std::vector> GetTopHistory( - const std::string& key, int top_number) override; - - bool UpdateMetrics(); - - bool Flush() override; - - private: - void CreateDB(const std::string& path); - - private: - std::unique_ptr db_ = nullptr; - ::leveldb::WriteBatch batch_; - unsigned int write_buffer_size_ = 64 << 20; - unsigned int write_batch_size_ = 1; - - protected: - Stats* global_stats_ = nullptr; - std::unique_ptr> block_cache_; -}; - -} // namespace storage -} // namespace resdb +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#pragma once + +#include +#include +#include + +#include "chain/storage/proto/leveldb_config.pb.h" +#include "chain/storage/storage.h" +#include "common/lru/lru_cache.h" +#include "leveldb/db.h" +#include "leveldb/write_batch.h" +#include "platform/statistic/stats.h" + +namespace resdb { +namespace storage { + +std::unique_ptr NewResLevelDB( + const std::string& path, std::optional config = std::nullopt); +std::unique_ptr NewResLevelDB( + std::optional config = std::nullopt); + +class ResLevelDB : public Storage { + public: + ResLevelDB(std::optional config_data = std::nullopt); + + virtual ~ResLevelDB(); + int SetValue(const std::string& key, const std::string& value) override; + std::string GetValue(const std::string& key) override; + std::string GetAllValues(void) override; + std::string GetRange(const std::string& min_key, + const std::string& max_key) override; + + int SetValueWithVersion(const std::string& key, const std::string& value, + int version) override; + std::pair GetValueWithVersion(const std::string& key, + int version) override; + + // Return a map of > + std::map> GetAllItems() override; + std::map> GetKeyRange( + const std::string& min_key, const std::string& max_key) override; + + // Return a list of + std::vector> GetHistory(const std::string& key, + int min_version, + int max_version) override; + + std::vector> GetTopHistory( + const std::string& key, int top_number) override; + + bool UpdateMetrics(); + + bool Flush() override; + + private: + void CreateDB(const std::string& path); + + private: + std::unique_ptr db_ = nullptr; + ::leveldb::WriteBatch batch_; + unsigned int write_buffer_size_ = 64 << 20; + unsigned int write_batch_size_ = 1; + + protected: + Stats* global_stats_ = nullptr; + std::unique_ptr> block_cache_; +}; + +} // namespace storage +} // namespace resdb diff --git a/chain/storage/leveldb_test.cpp b/chain/storage/leveldb_test.cpp index 87e36d81bd..cc02f35902 100644 --- a/chain/storage/leveldb_test.cpp +++ b/chain/storage/leveldb_test.cpp @@ -1,117 +1,117 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#include "chain/storage/leveldb.h" - -#include -#include -#include - -#include - -namespace resdb { -namespace storage { -namespace { - -enum class CacheConfig { DISABLED, ENABLED }; - -class TestableResLevelDB : public ResLevelDB { - public: - using ResLevelDB::block_cache_; - using ResLevelDB::global_stats_; - using ResLevelDB::ResLevelDB; -}; - -class LevelDBTest : public ::testing::TestWithParam { - protected: - LevelDBTest() { - LevelDBInfo config; - if (GetParam() == CacheConfig::ENABLED) { - config.set_enable_block_cache(true); - config.set_block_cache_capacity(1000); - } else { - Reset(); - } - storage = std::make_unique(config); - } - - protected: - std::unique_ptr storage; - std::string path_ = "/tmp/leveldb_test"; - - private: - void Reset() { std::filesystem::remove_all(path_.c_str()); } -}; - -TEST_P(LevelDBTest, BlockCacheEnabled) { - if (GetParam() == CacheConfig::ENABLED) { - EXPECT_TRUE(storage->block_cache_ != nullptr); - EXPECT_TRUE(storage->block_cache_->GetCapacity() == 1000); - } else { - EXPECT_TRUE(storage->block_cache_ == nullptr); - EXPECT_FALSE(storage->UpdateMetrics()); - } -} - -TEST_P(LevelDBTest, AddValueAndCheckCache) { - if (GetParam() == CacheConfig::ENABLED) { - // Add a value - std::string key = "test_key"; - std::string value = "test_value"; - EXPECT_EQ(storage->SetValue(key, value), 0); - - // Check if CacheHit is incremented in the Stats class - EXPECT_TRUE(storage->block_cache_->Get(key) == "test_value"); - EXPECT_EQ(storage->block_cache_->GetCacheHits(), 1); - } -} - -TEST_P(LevelDBTest, CacheEvictionPolicy) { - if (GetParam() == CacheConfig::ENABLED) { - // Insert 1000 values - for (int i = 1; i <= 1000; ++i) { - std::string key = "key_" + std::to_string(i); - std::string value = "value_" + std::to_string(i); - EXPECT_EQ(storage->SetValue(key, value), 0); - } - - // Insert the 1001st value - std::string key_1001 = "key_1001"; - std::string value_1001 = "value_1001"; - EXPECT_EQ(storage->SetValue(key_1001, value_1001), 0); - - // Check that the 1001st value is not present in the cache - EXPECT_TRUE(storage->GetValue("key_1") == "value_1"); - EXPECT_EQ(storage->block_cache_->GetCacheMisses(), 1); - - // Expect key_2 to be present in cache and hence a cache hit - EXPECT_TRUE(storage->GetValue("key_2") == "value_2"); - EXPECT_EQ(storage->block_cache_->GetCacheHits(), 1); - - EXPECT_TRUE(storage->UpdateMetrics()); - } -} - -INSTANTIATE_TEST_CASE_P(LevelDBTest, LevelDBTest, - ::testing::Values(CacheConfig::ENABLED, - CacheConfig::DISABLED)); - -} // namespace -} // namespace storage +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#include "chain/storage/leveldb.h" + +#include +#include +#include + +#include + +namespace resdb { +namespace storage { +namespace { + +enum class CacheConfig { DISABLED, ENABLED }; + +class TestableResLevelDB : public ResLevelDB { + public: + using ResLevelDB::block_cache_; + using ResLevelDB::global_stats_; + using ResLevelDB::ResLevelDB; +}; + +class LevelDBTest : public ::testing::TestWithParam { + protected: + LevelDBTest() { + LevelDBInfo config; + if (GetParam() == CacheConfig::ENABLED) { + config.set_enable_block_cache(true); + config.set_block_cache_capacity(1000); + } else { + Reset(); + } + storage = std::make_unique(config); + } + + protected: + std::unique_ptr storage; + std::string path_ = "/tmp/leveldb_test"; + + private: + void Reset() { std::filesystem::remove_all(path_.c_str()); } +}; + +TEST_P(LevelDBTest, BlockCacheEnabled) { + if (GetParam() == CacheConfig::ENABLED) { + EXPECT_TRUE(storage->block_cache_ != nullptr); + EXPECT_TRUE(storage->block_cache_->GetCapacity() == 1000); + } else { + EXPECT_TRUE(storage->block_cache_ == nullptr); + EXPECT_FALSE(storage->UpdateMetrics()); + } +} + +TEST_P(LevelDBTest, AddValueAndCheckCache) { + if (GetParam() == CacheConfig::ENABLED) { + // Add a value + std::string key = "test_key"; + std::string value = "test_value"; + EXPECT_EQ(storage->SetValue(key, value), 0); + + // Check if CacheHit is incremented in the Stats class + EXPECT_TRUE(storage->block_cache_->Get(key) == "test_value"); + EXPECT_EQ(storage->block_cache_->GetCacheHits(), 1); + } +} + +TEST_P(LevelDBTest, CacheEvictionPolicy) { + if (GetParam() == CacheConfig::ENABLED) { + // Insert 1000 values + for (int i = 1; i <= 1000; ++i) { + std::string key = "key_" + std::to_string(i); + std::string value = "value_" + std::to_string(i); + EXPECT_EQ(storage->SetValue(key, value), 0); + } + + // Insert the 1001st value + std::string key_1001 = "key_1001"; + std::string value_1001 = "value_1001"; + EXPECT_EQ(storage->SetValue(key_1001, value_1001), 0); + + // Check that the 1001st value is not present in the cache + EXPECT_TRUE(storage->GetValue("key_1") == "value_1"); + EXPECT_EQ(storage->block_cache_->GetCacheMisses(), 1); + + // Expect key_2 to be present in cache and hence a cache hit + EXPECT_TRUE(storage->GetValue("key_2") == "value_2"); + EXPECT_EQ(storage->block_cache_->GetCacheHits(), 1); + + EXPECT_TRUE(storage->UpdateMetrics()); + } +} + +INSTANTIATE_TEST_CASE_P(LevelDBTest, LevelDBTest, + ::testing::Values(CacheConfig::ENABLED, + CacheConfig::DISABLED)); + +} // namespace +} // namespace storage } // namespace resdb \ No newline at end of file diff --git a/chain/storage/memory_db.cpp b/chain/storage/memory_db.cpp index 2d5b872589..e743ee94e7 100644 --- a/chain/storage/memory_db.cpp +++ b/chain/storage/memory_db.cpp @@ -1,170 +1,170 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#include "chain/storage/memory_db.h" - -#include - -namespace resdb { -namespace storage { - -std::unique_ptr NewMemoryDB() { return std::make_unique(); } - -MemoryDB::MemoryDB() {} - -int MemoryDB::SetValue(const std::string& key, const std::string& value) { - kv_map_[key] = value; - return 0; -} - -std::string MemoryDB::GetAllValues(void) { - std::string values = "["; - bool first_iteration = true; - for (auto kv : kv_map_) { - if (!first_iteration) values.append(","); - first_iteration = false; - values.append(kv.second); - } - values.append("]"); - return values; -} - -std::string MemoryDB::GetRange(const std::string& min_key, - const std::string& max_key) { - std::string values = "["; - bool first_iteration = true; - for (auto kv : kv_map_) { - if (kv.first >= min_key && kv.first <= max_key) { - if (!first_iteration) values.append(","); - first_iteration = false; - values.append(kv.second); - } - } - values.append("]"); - return values; -} - -std::string MemoryDB::GetValue(const std::string& key) { - auto search = kv_map_.find(key); - if (search != kv_map_.end()) - return search->second; - else { - return ""; - } -} - -int MemoryDB::SetValueWithVersion(const std::string& key, - const std::string& value, int version) { - auto it = kv_map_with_v_.find(key); - if ((it == kv_map_with_v_.end() && version != 0) || - (it != kv_map_with_v_.end() && it->second.back().second != version)) { - LOG(ERROR) << " value version not match. key:" << key << " db version:" - << (it == kv_map_with_v_.end() ? 0 : it->second.back().second) - << " user version:" << version; - return -2; - } - kv_map_with_v_[key].push_back(std::make_pair(value, version + 1)); - return 0; -} - -std::pair MemoryDB::GetValueWithVersion( - const std::string& key, int version) { - auto search_it = kv_map_with_v_.find(key); - if (search_it != kv_map_with_v_.end() && search_it->second.size()) { - auto it = search_it->second.end(); - do { - --it; - if (it->second == version) { - return *it; - } - if (it->second < version) { - break; - } - } while (it != search_it->second.begin()); - it = --search_it->second.end(); - LOG(ERROR) << " key:" << key << " no version:" << version - << " return max:" << it->second; - return *it; - } - return std::make_pair("", 0); -} - -std::map> MemoryDB::GetAllItems() { - std::map> resp; - - for (const auto& it : kv_map_with_v_) { - resp.insert(std::make_pair(it.first, it.second.back())); - } - return resp; -} - -std::map> MemoryDB::GetKeyRange( - const std::string& min_key, const std::string& max_key) { - LOG(ERROR) << "min key:" << min_key << " max key:" << max_key; - std::map> resp; - for (const auto& it : kv_map_with_v_) { - if (it.first >= min_key && it.first <= max_key) { - resp.insert(std::make_pair(it.first, it.second.back())); - } - } - return resp; -} - -std::vector> MemoryDB::GetHistory( - const std::string& key, int min_version, int max_version) { - std::vector> resp; - auto search_it = kv_map_with_v_.find(key); - if (search_it == kv_map_with_v_.end()) { - return resp; - } - - auto it = search_it->second.end(); - do { - --it; - if (it->second < min_version) { - break; - } - if (it->second <= max_version) { - resp.push_back(*it); - } - } while (it != search_it->second.begin()); - return resp; -} - -std::vector> MemoryDB::GetTopHistory( - const std::string& key, int top_number) { - std::vector> resp; - auto search_it = kv_map_with_v_.find(key); - if (search_it == kv_map_with_v_.end()) { - return resp; - } - - auto it = search_it->second.end(); - do { - --it; - resp.push_back(*it); - if (resp.size() >= static_cast(top_number)) { - break; - } - } while (it != search_it->second.begin()); - return resp; -} - -} // namespace storage -} // namespace resdb +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#include "chain/storage/memory_db.h" + +#include + +namespace resdb { +namespace storage { + +std::unique_ptr NewMemoryDB() { return std::make_unique(); } + +MemoryDB::MemoryDB() {} + +int MemoryDB::SetValue(const std::string& key, const std::string& value) { + kv_map_[key] = value; + return 0; +} + +std::string MemoryDB::GetAllValues(void) { + std::string values = "["; + bool first_iteration = true; + for (auto kv : kv_map_) { + if (!first_iteration) values.append(","); + first_iteration = false; + values.append(kv.second); + } + values.append("]"); + return values; +} + +std::string MemoryDB::GetRange(const std::string& min_key, + const std::string& max_key) { + std::string values = "["; + bool first_iteration = true; + for (auto kv : kv_map_) { + if (kv.first >= min_key && kv.first <= max_key) { + if (!first_iteration) values.append(","); + first_iteration = false; + values.append(kv.second); + } + } + values.append("]"); + return values; +} + +std::string MemoryDB::GetValue(const std::string& key) { + auto search = kv_map_.find(key); + if (search != kv_map_.end()) + return search->second; + else { + return ""; + } +} + +int MemoryDB::SetValueWithVersion(const std::string& key, + const std::string& value, int version) { + auto it = kv_map_with_v_.find(key); + if ((it == kv_map_with_v_.end() && version != 0) || + (it != kv_map_with_v_.end() && it->second.back().second != version)) { + LOG(ERROR) << " value version not match. key:" << key << " db version:" + << (it == kv_map_with_v_.end() ? 0 : it->second.back().second) + << " user version:" << version; + return -2; + } + kv_map_with_v_[key].push_back(std::make_pair(value, version + 1)); + return 0; +} + +std::pair MemoryDB::GetValueWithVersion( + const std::string& key, int version) { + auto search_it = kv_map_with_v_.find(key); + if (search_it != kv_map_with_v_.end() && search_it->second.size()) { + auto it = search_it->second.end(); + do { + --it; + if (it->second == version) { + return *it; + } + if (it->second < version) { + break; + } + } while (it != search_it->second.begin()); + it = --search_it->second.end(); + LOG(ERROR) << " key:" << key << " no version:" << version + << " return max:" << it->second; + return *it; + } + return std::make_pair("", 0); +} + +std::map> MemoryDB::GetAllItems() { + std::map> resp; + + for (const auto& it : kv_map_with_v_) { + resp.insert(std::make_pair(it.first, it.second.back())); + } + return resp; +} + +std::map> MemoryDB::GetKeyRange( + const std::string& min_key, const std::string& max_key) { + LOG(ERROR) << "min key:" << min_key << " max key:" << max_key; + std::map> resp; + for (const auto& it : kv_map_with_v_) { + if (it.first >= min_key && it.first <= max_key) { + resp.insert(std::make_pair(it.first, it.second.back())); + } + } + return resp; +} + +std::vector> MemoryDB::GetHistory( + const std::string& key, int min_version, int max_version) { + std::vector> resp; + auto search_it = kv_map_with_v_.find(key); + if (search_it == kv_map_with_v_.end()) { + return resp; + } + + auto it = search_it->second.end(); + do { + --it; + if (it->second < min_version) { + break; + } + if (it->second <= max_version) { + resp.push_back(*it); + } + } while (it != search_it->second.begin()); + return resp; +} + +std::vector> MemoryDB::GetTopHistory( + const std::string& key, int top_number) { + std::vector> resp; + auto search_it = kv_map_with_v_.find(key); + if (search_it == kv_map_with_v_.end()) { + return resp; + } + + auto it = search_it->second.end(); + do { + --it; + resp.push_back(*it); + if (resp.size() >= static_cast(top_number)) { + break; + } + } while (it != search_it->second.begin()); + return resp; +} + +} // namespace storage +} // namespace resdb diff --git a/chain/storage/memory_db.h b/chain/storage/memory_db.h index 372f46474b..bf0643c728 100644 --- a/chain/storage/memory_db.h +++ b/chain/storage/memory_db.h @@ -1,88 +1,88 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#pragma once - -#include -#include -#include -#include - -#include "chain/storage/storage.h" - -namespace resdb { -namespace storage { - -// Key Value Storage supporting two types of interfaces: -// Non-version: -// It provides set and get function to set a value to a specific key -// Values will be set directly. -// Version: -// It provides set and get function to set a value to a specific key -// with a version. -// The version inside setting function is to support OCC verification. -// The version value should be obtained before setting -// and returned back when setting a new value. If the version is not -// the same as the old one, return failure. -// If the value of a specific version does not exist or providing -// version 0 as parameter when accessing get -// it returns the current value along its version. -// -// Note: Only one type of interface are allowed to be used. -// - -std::unique_ptr NewMemoryDB(); - -class MemoryDB : public Storage { - public: - MemoryDB(); - - int SetValue(const std::string& key, const std::string& value); - std::string GetValue(const std::string& key); - - std::string GetAllValues() override; - std::string GetRange(const std::string& min_key, - const std::string& max_key) override; - - int SetValueWithVersion(const std::string& key, const std::string& value, - int version) override; - std::pair GetValueWithVersion(const std::string& key, - int version) override; - - // Return a map of > - std::map> GetAllItems() override; - std::map> GetKeyRange( - const std::string& min_key, const std::string& max_key) override; - - // Return a list of - std::vector> GetHistory(const std::string& key, - int min_version, - int max_version) override; - - std::vector> GetTopHistory(const std::string& key, - int number) override; - - private: - std::unordered_map kv_map_; - std::unordered_map>> - kv_map_with_v_; -}; - -} // namespace storage -} // namespace resdb +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#pragma once + +#include +#include +#include +#include + +#include "chain/storage/storage.h" + +namespace resdb { +namespace storage { + +// Key Value Storage supporting two types of interfaces: +// Non-version: +// It provides set and get function to set a value to a specific key +// Values will be set directly. +// Version: +// It provides set and get function to set a value to a specific key +// with a version. +// The version inside setting function is to support OCC verification. +// The version value should be obtained before setting +// and returned back when setting a new value. If the version is not +// the same as the old one, return failure. +// If the value of a specific version does not exist or providing +// version 0 as parameter when accessing get +// it returns the current value along its version. +// +// Note: Only one type of interface are allowed to be used. +// + +std::unique_ptr NewMemoryDB(); + +class MemoryDB : public Storage { + public: + MemoryDB(); + + int SetValue(const std::string& key, const std::string& value); + std::string GetValue(const std::string& key); + + std::string GetAllValues() override; + std::string GetRange(const std::string& min_key, + const std::string& max_key) override; + + int SetValueWithVersion(const std::string& key, const std::string& value, + int version) override; + std::pair GetValueWithVersion(const std::string& key, + int version) override; + + // Return a map of > + std::map> GetAllItems() override; + std::map> GetKeyRange( + const std::string& min_key, const std::string& max_key) override; + + // Return a list of + std::vector> GetHistory(const std::string& key, + int min_version, + int max_version) override; + + std::vector> GetTopHistory(const std::string& key, + int number) override; + + private: + std::unordered_map kv_map_; + std::unordered_map>> + kv_map_with_v_; +}; + +} // namespace storage +} // namespace resdb diff --git a/chain/storage/mock_storage.h b/chain/storage/mock_storage.h index 963d92bbe6..367cbf3abf 100644 --- a/chain/storage/mock_storage.h +++ b/chain/storage/mock_storage.h @@ -1,56 +1,56 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#pragma once - -#include "chain/storage/storage.h" -#include "gmock/gmock.h" - -namespace resdb { - -class MockStorage : public Storage { - public: - MOCK_METHOD(int, SetValue, (const std::string& key, const std::string& value), - (override)); - MOCK_METHOD(std::string, GetValue, (const std::string& key), (override)); - MOCK_METHOD(std::string, GetAllValues, (), (override)); - MOCK_METHOD(std::string, GetRange, (const std::string&, const std::string&), - (override)); - - MOCK_METHOD(int, SetValueWithVersion, - (const std::string& key, const std::string& value, int version), - (override)); - - using ValueType = std::pair; - using ItemsType = std::map; - using ValuesType = std::vector; - - MOCK_METHOD(ValueType, GetValueWithVersion, - (const std::string& key, int version), (override)); - MOCK_METHOD(ItemsType, GetAllItems, (), (override)); - MOCK_METHOD(ItemsType, GetKeyRange, (const std::string&, const std::string&), - (override)); - MOCK_METHOD(ValuesType, GetHistory, (const std::string&, int, int), - (override)); - MOCK_METHOD(ValuesType, GetTopHistory, (const std::string&, int), (override)); - - MOCK_METHOD(bool, Flush, (), (override)); -}; - -} // namespace resdb +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#pragma once + +#include "chain/storage/storage.h" +#include "gmock/gmock.h" + +namespace resdb { + +class MockStorage : public Storage { + public: + MOCK_METHOD(int, SetValue, (const std::string& key, const std::string& value), + (override)); + MOCK_METHOD(std::string, GetValue, (const std::string& key), (override)); + MOCK_METHOD(std::string, GetAllValues, (), (override)); + MOCK_METHOD(std::string, GetRange, (const std::string&, const std::string&), + (override)); + + MOCK_METHOD(int, SetValueWithVersion, + (const std::string& key, const std::string& value, int version), + (override)); + + using ValueType = std::pair; + using ItemsType = std::map; + using ValuesType = std::vector; + + MOCK_METHOD(ValueType, GetValueWithVersion, + (const std::string& key, int version), (override)); + MOCK_METHOD(ItemsType, GetAllItems, (), (override)); + MOCK_METHOD(ItemsType, GetKeyRange, (const std::string&, const std::string&), + (override)); + MOCK_METHOD(ValuesType, GetHistory, (const std::string&, int, int), + (override)); + MOCK_METHOD(ValuesType, GetTopHistory, (const std::string&, int), (override)); + + MOCK_METHOD(bool, Flush, (), (override)); +}; + +} // namespace resdb diff --git a/chain/storage/proto/BUILD b/chain/storage/proto/BUILD index 0b1c7263f2..1652ea157a 100644 --- a/chain/storage/proto/BUILD +++ b/chain/storage/proto/BUILD @@ -1,44 +1,44 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -package(default_visibility = ["//visibility:public"]) - -load("@rules_cc//cc:defs.bzl", "cc_proto_library") -load("@rules_proto//proto:defs.bzl", "proto_library") - -proto_library( - name = "kv_proto", - srcs = ["kv.proto"], - visibility = ["//chain/storage:__subpackages__"], -) - -cc_proto_library( - name = "kv_cc_proto", - visibility = ["//chain/storage:__subpackages__"], - deps = [":kv_proto"], -) - -proto_library( - name = "leveldb_config_proto", - srcs = ["leveldb_config.proto"], -) - -cc_proto_library( - name = "leveldb_config_cc_proto", - deps = [":leveldb_config_proto"], -) +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +package(default_visibility = ["//visibility:public"]) + +load("@rules_cc//cc:defs.bzl", "cc_proto_library") +load("@rules_proto//proto:defs.bzl", "proto_library") + +proto_library( + name = "kv_proto", + srcs = ["kv.proto"], + visibility = ["//chain/storage:__subpackages__"], +) + +cc_proto_library( + name = "kv_cc_proto", + visibility = ["//chain/storage:__subpackages__"], + deps = [":kv_proto"], +) + +proto_library( + name = "leveldb_config_proto", + srcs = ["leveldb_config.proto"], +) + +cc_proto_library( + name = "leveldb_config_cc_proto", + deps = [":leveldb_config_proto"], +) diff --git a/chain/storage/proto/kv.proto b/chain/storage/proto/kv.proto index 8466b8dc7d..029b18ed83 100644 --- a/chain/storage/proto/kv.proto +++ b/chain/storage/proto/kv.proto @@ -1,32 +1,32 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -syntax = "proto3"; - -package resdb.storage; - -message Value { - bytes value = 1; - int32 version = 2; -} - -message ValueHistory { - repeated Value value = 1; -} - +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +syntax = "proto3"; + +package resdb.storage; + +message Value { + bytes value = 1; + int32 version = 2; +} + +message ValueHistory { + repeated Value value = 1; +} + diff --git a/chain/storage/proto/leveldb_config.proto b/chain/storage/proto/leveldb_config.proto index 28e5a18808..ecd953f362 100644 --- a/chain/storage/proto/leveldb_config.proto +++ b/chain/storage/proto/leveldb_config.proto @@ -1,30 +1,30 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -syntax = "proto3"; - -package resdb.storage; - -message LevelDBInfo { - uint32 write_buffer_size_mb = 2; - uint32 write_batch_size = 3; - string path = 4; - optional bool enable_block_cache = 5; - optional uint32 block_cache_capacity = 6; -} +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +syntax = "proto3"; + +package resdb.storage; + +message LevelDBInfo { + uint32 write_buffer_size_mb = 2; + uint32 write_batch_size = 3; + string path = 4; + optional bool enable_block_cache = 5; + optional uint32 block_cache_capacity = 6; +} diff --git a/chain/storage/setting/BUILD b/chain/storage/setting/BUILD index 25d11b4e8d..f9e7176e10 100644 --- a/chain/storage/setting/BUILD +++ b/chain/storage/setting/BUILD @@ -1,35 +1,35 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -package(default_visibility = ["//visibility:public"]) - -load("@bazel_skylib//rules:common_settings.bzl", "bool_flag") - -bool_flag( - name = "enable_leveldb", - build_setting_default = False, - visibility = ["//visibility:public"], -) - -config_setting( - name = "enable_leveldb_setting", - values = { - "define": "enable_leveldb=True", - }, - visibility = ["//visibility:public"], -) +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +package(default_visibility = ["//visibility:public"]) + +load("@bazel_skylib//rules:common_settings.bzl", "bool_flag") + +bool_flag( + name = "enable_leveldb", + build_setting_default = False, + visibility = ["//visibility:public"], +) + +config_setting( + name = "enable_leveldb_setting", + values = { + "define": "enable_leveldb=True", + }, + visibility = ["//visibility:public"], +) diff --git a/chain/storage/storage.h b/chain/storage/storage.h index 76e352de8e..4e91a53c4b 100644 --- a/chain/storage/storage.h +++ b/chain/storage/storage.h @@ -1,60 +1,60 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#pragma once - -#include -#include -#include - -namespace resdb { - -class Storage { - public: - Storage() = default; - virtual ~Storage() = default; - - virtual int SetValue(const std::string& key, const std::string& value) = 0; - virtual std::string GetValue(const std::string& key) = 0; - virtual std::string GetAllValues() = 0; - virtual std::string GetRange(const std::string& min_key, - const std::string& max_key) = 0; - - virtual int SetValueWithVersion(const std::string& key, - const std::string& value, int version) = 0; - virtual std::pair GetValueWithVersion( - const std::string& key, int version) = 0; - - // Return a map of > - virtual std::map> GetAllItems() = 0; - virtual std::map> GetKeyRange( - const std::string& min_key, const std::string& max_key) = 0; - - // Return a list of from a key - // The version list is sorted by the version value in descending order - virtual std::vector> GetHistory( - const std::string& key, int min_version, int max_version) = 0; - - virtual std::vector> GetTopHistory( - const std::string& key, int number) = 0; - - virtual bool Flush() { return true; }; -}; - -} // namespace resdb +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#pragma once + +#include +#include +#include + +namespace resdb { + +class Storage { + public: + Storage() = default; + virtual ~Storage() = default; + + virtual int SetValue(const std::string& key, const std::string& value) = 0; + virtual std::string GetValue(const std::string& key) = 0; + virtual std::string GetAllValues() = 0; + virtual std::string GetRange(const std::string& min_key, + const std::string& max_key) = 0; + + virtual int SetValueWithVersion(const std::string& key, + const std::string& value, int version) = 0; + virtual std::pair GetValueWithVersion( + const std::string& key, int version) = 0; + + // Return a map of > + virtual std::map> GetAllItems() = 0; + virtual std::map> GetKeyRange( + const std::string& min_key, const std::string& max_key) = 0; + + // Return a list of from a key + // The version list is sorted by the version value in descending order + virtual std::vector> GetHistory( + const std::string& key, int min_version, int max_version) = 0; + + virtual std::vector> GetTopHistory( + const std::string& key, int number) = 0; + + virtual bool Flush() { return true; }; +}; + +} // namespace resdb diff --git a/common/BUILD b/common/BUILD index c5982dd142..f893d66a24 100644 --- a/common/BUILD +++ b/common/BUILD @@ -1,85 +1,85 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -package(default_visibility = ["//visibility:public"]) - -cc_library( - name = "absl", - deps = [ - "@com_google_absl//absl/status", - "@com_google_absl//absl/status:statusor", - ], -) - -cc_library( - name = "asio", - deps = [ - "@boost//:asio", - ], -) - -cc_library( - name = "beast", - deps = [ - "@boost//:beast", - ], -) - -cc_library( - name = "boost_lockfree", - deps = [ - "@boost//:lockfree", - ], -) - -cc_library( - name = "glog", - deps = [ - "@com_github_google_glog//:glog", - ], -) - -cc_library( - name = "pybind", - deps = [ - "@pybind11", - ], -) - -cc_library( - name = "json", - deps = [ - "@nlohmann_json//:json", - ], -) - -cc_library( - name = "boost_comm", - deps = [ - "@boost//:algorithm", - "@boost//:optional", - ], -) - -cc_library( - name = "comm", - deps = [ - ":absl", - ":glog", - ], -) +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +package(default_visibility = ["//visibility:public"]) + +cc_library( + name = "absl", + deps = [ + "@com_google_absl//absl/status", + "@com_google_absl//absl/status:statusor", + ], +) + +cc_library( + name = "asio", + deps = [ + "@boost//:asio", + ], +) + +cc_library( + name = "beast", + deps = [ + "@boost//:beast", + ], +) + +cc_library( + name = "boost_lockfree", + deps = [ + "@boost//:lockfree", + ], +) + +cc_library( + name = "glog", + deps = [ + "@com_github_google_glog//:glog", + ], +) + +cc_library( + name = "pybind", + deps = [ + "@pybind11", + ], +) + +cc_library( + name = "json", + deps = [ + "@nlohmann_json//:json", + ], +) + +cc_library( + name = "boost_comm", + deps = [ + "@boost//:algorithm", + "@boost//:optional", + ], +) + +cc_library( + name = "comm", + deps = [ + ":absl", + ":glog", + ], +) diff --git a/common/crypto/BUILD b/common/crypto/BUILD index e559690311..a5a74b3014 100644 --- a/common/crypto/BUILD +++ b/common/crypto/BUILD @@ -1,104 +1,104 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -package(default_visibility = ["//visibility:public"]) - -cc_library( - name = "key_generator", - srcs = ["key_generator.cpp"], - hdrs = ["key_generator.h"], - deps = [ - "//:cryptopp_lib", - "//common:comm", - "//common/proto:signature_info_cc_proto", - ], -) - -cc_library( - name = "hash", - srcs = ["hash.cpp"], - hdrs = ["hash.h"], - deps = [ - "//:cryptopp_lib", - "//common:comm", - ], -) - -cc_test( - name = "hash_test", - srcs = ["hash_test.cpp"], - deps = [ - ":hash", - "//common/test:test_main", - ], -) - -cc_library( - name = "signature_utils", - srcs = ["signature_utils.cpp"], - hdrs = ["signature_utils.h"], - deps = [ - "//:cryptopp_lib", - "//common:comm", - "//common/proto:signature_info_cc_proto", - ], -) - -cc_library( - name = "signature_verifier_interface", - srcs = ["signature_verifier_interface.cpp"], - hdrs = ["signature_verifier_interface.h"], - deps = [ - "//common:comm", - "//common/proto:signature_info_cc_proto", - ], -) - -cc_library( - name = "signature_verifier", - srcs = ["signature_verifier.cpp"], - hdrs = ["signature_verifier.h"], - deps = [ - ":signature_utils", - ":signature_verifier_interface", - "//:cryptopp_lib", - "//common:comm", - "//common/proto:signature_info_cc_proto", - ], -) - -cc_library( - name = "mock_signature_verifier", - testonly = True, - hdrs = ["mock_signature_verifier.h"], - deps = [ - ":signature_verifier", - ], -) - -cc_test( - name = "signature_verifier_test", - srcs = ["signature_verifier_test.cpp"], - deps = [ - ":key_generator", - ":signature_verifier", - "//:cryptopp_lib", - "//common/test:test_main", - ], -) +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +package(default_visibility = ["//visibility:public"]) + +cc_library( + name = "key_generator", + srcs = ["key_generator.cpp"], + hdrs = ["key_generator.h"], + deps = [ + "//:cryptopp_lib", + "//common:comm", + "//common/proto:signature_info_cc_proto", + ], +) + +cc_library( + name = "hash", + srcs = ["hash.cpp"], + hdrs = ["hash.h"], + deps = [ + "//:cryptopp_lib", + "//common:comm", + ], +) + +cc_test( + name = "hash_test", + srcs = ["hash_test.cpp"], + deps = [ + ":hash", + "//common/test:test_main", + ], +) + +cc_library( + name = "signature_utils", + srcs = ["signature_utils.cpp"], + hdrs = ["signature_utils.h"], + deps = [ + "//:cryptopp_lib", + "//common:comm", + "//common/proto:signature_info_cc_proto", + ], +) + +cc_library( + name = "signature_verifier_interface", + srcs = ["signature_verifier_interface.cpp"], + hdrs = ["signature_verifier_interface.h"], + deps = [ + "//common:comm", + "//common/proto:signature_info_cc_proto", + ], +) + +cc_library( + name = "signature_verifier", + srcs = ["signature_verifier.cpp"], + hdrs = ["signature_verifier.h"], + deps = [ + ":signature_utils", + ":signature_verifier_interface", + "//:cryptopp_lib", + "//common:comm", + "//common/proto:signature_info_cc_proto", + ], +) + +cc_library( + name = "mock_signature_verifier", + testonly = True, + hdrs = ["mock_signature_verifier.h"], + deps = [ + ":signature_verifier", + ], +) + +cc_test( + name = "signature_verifier_test", + srcs = ["signature_verifier_test.cpp"], + deps = [ + ":key_generator", + ":signature_verifier", + "//:cryptopp_lib", + "//common/test:test_main", + ], +) diff --git a/common/crypto/hash.cpp b/common/crypto/hash.cpp index b96a2b81d2..7764f7f066 100644 --- a/common/crypto/hash.cpp +++ b/common/crypto/hash.cpp @@ -1,48 +1,48 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#include "common/crypto/hash.h" - -#include -#include -#include - -namespace resdb { -namespace utils { -// Funtion to calculate hash of a string. -std::string CalculateSHA256Hash(const std::string& str) { - CryptoPP::byte const* pData = (CryptoPP::byte*)str.data(); - unsigned int nDataLen = str.size(); - CryptoPP::byte aDigest[CryptoPP::SHA256::DIGESTSIZE]; - - CryptoPP::SHA256().CalculateDigest(aDigest, pData, nDataLen); - return std::string((char*)aDigest, CryptoPP::SHA256::DIGESTSIZE); -} - -std::string CalculateRIPEMD160Hash(const std::string& str) { - CryptoPP::byte const* pData = (CryptoPP::byte*)str.data(); - unsigned int nDataLen = str.size(); - CryptoPP::byte aDigest[CryptoPP::RIPEMD160::DIGESTSIZE]; - - CryptoPP::RIPEMD160().CalculateDigest(aDigest, pData, nDataLen); - return std::string((char*)aDigest, CryptoPP::RIPEMD160::DIGESTSIZE); -} - -} // namespace utils -} // namespace resdb +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#include "common/crypto/hash.h" + +#include +#include +#include + +namespace resdb { +namespace utils { +// Funtion to calculate hash of a string. +std::string CalculateSHA256Hash(const std::string& str) { + CryptoPP::byte const* pData = (CryptoPP::byte*)str.data(); + unsigned int nDataLen = str.size(); + CryptoPP::byte aDigest[CryptoPP::SHA256::DIGESTSIZE]; + + CryptoPP::SHA256().CalculateDigest(aDigest, pData, nDataLen); + return std::string((char*)aDigest, CryptoPP::SHA256::DIGESTSIZE); +} + +std::string CalculateRIPEMD160Hash(const std::string& str) { + CryptoPP::byte const* pData = (CryptoPP::byte*)str.data(); + unsigned int nDataLen = str.size(); + CryptoPP::byte aDigest[CryptoPP::RIPEMD160::DIGESTSIZE]; + + CryptoPP::RIPEMD160().CalculateDigest(aDigest, pData, nDataLen); + return std::string((char*)aDigest, CryptoPP::RIPEMD160::DIGESTSIZE); +} + +} // namespace utils +} // namespace resdb diff --git a/common/crypto/hash.h b/common/crypto/hash.h index 5136bfd555..a7a454bece 100644 --- a/common/crypto/hash.h +++ b/common/crypto/hash.h @@ -1,31 +1,31 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#pragma once - -#include - -namespace resdb { -namespace utils { - -std::string CalculateSHA256Hash(const std::string& str); -std::string CalculateRIPEMD160Hash(const std::string& str); - -} // namespace utils -} // namespace resdb +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#pragma once + +#include + +namespace resdb { +namespace utils { + +std::string CalculateSHA256Hash(const std::string& str); +std::string CalculateRIPEMD160Hash(const std::string& str); + +} // namespace utils +} // namespace resdb diff --git a/common/crypto/hash_test.cpp b/common/crypto/hash_test.cpp index 8cb32022c4..910a60899e 100644 --- a/common/crypto/hash_test.cpp +++ b/common/crypto/hash_test.cpp @@ -1,50 +1,50 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#include "common/crypto/hash.h" - -#include -#include - -#include "common/test/test_macros.h" - -namespace resdb { -namespace utils { -namespace { - -using ::resdb::testing::EqualsProto; - -TEST(SignatureVerifyTest, CalculateSHA256) { - std::string expected_str = - "\x9F\x86\xD0\x81\x88L}e\x9A/" - "\xEA\xA0\xC5Z\xD0\x15\xA3\xBFO\x1B+\v\x82,\xD1]l\x15\xB0\xF0\n\b"; - EXPECT_EQ(CalculateSHA256Hash("test"), expected_str); -} - -TEST(SignatureVerifyTest, CalculateRIPEMD160) { - std::string expected_str = - "^R\xFE\xE4~k\a\x5" - "e\xF7" - "CrF\x8C\xDCi\x9D\xE8\x91\a"; - EXPECT_EQ(CalculateRIPEMD160Hash("test"), expected_str); -} - -} // namespace -} // namespace utils -} // namespace resdb +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#include "common/crypto/hash.h" + +#include +#include + +#include "common/test/test_macros.h" + +namespace resdb { +namespace utils { +namespace { + +using ::resdb::testing::EqualsProto; + +TEST(SignatureVerifyTest, CalculateSHA256) { + std::string expected_str = + "\x9F\x86\xD0\x81\x88L}e\x9A/" + "\xEA\xA0\xC5Z\xD0\x15\xA3\xBFO\x1B+\v\x82,\xD1]l\x15\xB0\xF0\n\b"; + EXPECT_EQ(CalculateSHA256Hash("test"), expected_str); +} + +TEST(SignatureVerifyTest, CalculateRIPEMD160) { + std::string expected_str = + "^R\xFE\xE4~k\a\x5" + "e\xF7" + "CrF\x8C\xDCi\x9D\xE8\x91\a"; + EXPECT_EQ(CalculateRIPEMD160Hash("test"), expected_str); +} + +} // namespace +} // namespace utils +} // namespace resdb diff --git a/common/crypto/key_generator.cpp b/common/crypto/key_generator.cpp index 5a60923fdc..7f08dc8a39 100644 --- a/common/crypto/key_generator.cpp +++ b/common/crypto/key_generator.cpp @@ -1,156 +1,156 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#include "common/crypto/key_generator.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -//#include -//#include - -namespace resdb { - -namespace { - -//============================================================================== -// Return a KeyPairHex for each node. This function is used by the nodes to -// obtain their keyPair -SecretKey RsaGenerateHexKeyPair(unsigned int key_size) { - SecretKey key_pair; - // PGP Random Pool-like generator - CryptoPP::AutoSeededRandomPool rng; - - // generate keys - CryptoPP::RSA::PrivateKey private_key; - private_key.GenerateRandomWithKeySize(rng, key_size); - CryptoPP::RSA::PublicKey public_key(private_key); - - // save keys - public_key.Save(CryptoPP::HexEncoder( - new CryptoPP::StringSink(*key_pair.mutable_public_key())) - .Ref()); - private_key.Save(CryptoPP::HexEncoder(new CryptoPP::StringSink( - *key_pair.mutable_private_key())) - .Ref()); - - return key_pair; -} - -// Initialize the signer and the keys for ED25519 -SecretKey ED25519GenerateKeys() { - CryptoPP::ed25519::Signer signer; - SecretKey key_pair; - CryptoPP::AutoSeededRandomPool prng; - // Initilize signer; - signer.AccessPrivateKey().GenerateRandom(prng); - - const CryptoPP::ed25519PrivateKey &private_key = - dynamic_cast(signer.GetPrivateKey()); - - key_pair.mutable_private_key()->assign( - (char *)private_key.GetPrivateKeyBytePtr(), - CryptoPP::ed25519PrivateKey::SECRET_KEYLENGTH); - key_pair.mutable_public_key()->assign( - (char *)private_key.GetPublicKeyBytePtr(), - CryptoPP::ed25519PrivateKey::PUBLIC_KEYLENGTH); - return key_pair; -} - -// CMAC-AES key generator -// Return a keyPairHex where just the priv key is set -SecretKey CmacGenerateHexKey(unsigned int key_size) { - SecretKey key_pair; - std::string private_key; - CryptoPP::AutoSeededRandomPool prng; - // int keySize = 16 ; // AES::DEFAULT_KEYLENGTH - CryptoPP::SecByteBlock key(key_size); - prng.GenerateBlock( - key.data(), key.size()); // Key is a SecByteBlock that contains the key. - - CryptoPP::StringSource ss(key.data(), key.size(), true, - new CryptoPP::HexEncoder(new CryptoPP::StringSink( - private_key)) // HexEncoder - ); // StringSource - key_pair.set_private_key(private_key); - key_pair.set_public_key(private_key); - return key_pair; -} - -SecretKey ECDSAGenerateKeys() { - CryptoPP::AutoSeededRandomPool prng; - CryptoPP::ECDSA::PrivateKey privateKey; - CryptoPP::DL_GroupParameters_EC params( - CryptoPP::ASN1::secp256k1()); - privateKey.Initialize(prng, params); - - CryptoPP::ECDSA::PublicKey publicKey; - privateKey.MakePublicKey(publicKey); - - SecretKey key_pair; - - // save keys - publicKey.Save(CryptoPP::HexEncoder( - new CryptoPP::StringSink(*key_pair.mutable_public_key())) - .Ref()); - privateKey.Save(CryptoPP::HexEncoder( - new CryptoPP::StringSink(*key_pair.mutable_private_key())) - .Ref()); - return key_pair; -} - -} // namespace - -SecretKey KeyGenerator::GeneratorKeys(SignatureInfo::HashType type) { - SecretKey key; - switch (type) { - case SignatureInfo::RSA: - key = RsaGenerateHexKeyPair(3072); - break; - case SignatureInfo::ED25519: { - key = ED25519GenerateKeys(); - break; - } - case SignatureInfo::CMAC_AES: { - key = CmacGenerateHexKey(16); - break; - } - case SignatureInfo::ECDSA: { - key = ECDSAGenerateKeys(); - break; - } - default: - break; - } - key.set_hash_type(type); - return key; -} - -} // namespace resdb +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#include "common/crypto/key_generator.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +//#include +//#include + +namespace resdb { + +namespace { + +//============================================================================== +// Return a KeyPairHex for each node. This function is used by the nodes to +// obtain their keyPair +SecretKey RsaGenerateHexKeyPair(unsigned int key_size) { + SecretKey key_pair; + // PGP Random Pool-like generator + CryptoPP::AutoSeededRandomPool rng; + + // generate keys + CryptoPP::RSA::PrivateKey private_key; + private_key.GenerateRandomWithKeySize(rng, key_size); + CryptoPP::RSA::PublicKey public_key(private_key); + + // save keys + public_key.Save(CryptoPP::HexEncoder( + new CryptoPP::StringSink(*key_pair.mutable_public_key())) + .Ref()); + private_key.Save(CryptoPP::HexEncoder(new CryptoPP::StringSink( + *key_pair.mutable_private_key())) + .Ref()); + + return key_pair; +} + +// Initialize the signer and the keys for ED25519 +SecretKey ED25519GenerateKeys() { + CryptoPP::ed25519::Signer signer; + SecretKey key_pair; + CryptoPP::AutoSeededRandomPool prng; + // Initilize signer; + signer.AccessPrivateKey().GenerateRandom(prng); + + const CryptoPP::ed25519PrivateKey &private_key = + dynamic_cast(signer.GetPrivateKey()); + + key_pair.mutable_private_key()->assign( + (char *)private_key.GetPrivateKeyBytePtr(), + CryptoPP::ed25519PrivateKey::SECRET_KEYLENGTH); + key_pair.mutable_public_key()->assign( + (char *)private_key.GetPublicKeyBytePtr(), + CryptoPP::ed25519PrivateKey::PUBLIC_KEYLENGTH); + return key_pair; +} + +// CMAC-AES key generator +// Return a keyPairHex where just the priv key is set +SecretKey CmacGenerateHexKey(unsigned int key_size) { + SecretKey key_pair; + std::string private_key; + CryptoPP::AutoSeededRandomPool prng; + // int keySize = 16 ; // AES::DEFAULT_KEYLENGTH + CryptoPP::SecByteBlock key(key_size); + prng.GenerateBlock( + key.data(), key.size()); // Key is a SecByteBlock that contains the key. + + CryptoPP::StringSource ss(key.data(), key.size(), true, + new CryptoPP::HexEncoder(new CryptoPP::StringSink( + private_key)) // HexEncoder + ); // StringSource + key_pair.set_private_key(private_key); + key_pair.set_public_key(private_key); + return key_pair; +} + +SecretKey ECDSAGenerateKeys() { + CryptoPP::AutoSeededRandomPool prng; + CryptoPP::ECDSA::PrivateKey privateKey; + CryptoPP::DL_GroupParameters_EC params( + CryptoPP::ASN1::secp256k1()); + privateKey.Initialize(prng, params); + + CryptoPP::ECDSA::PublicKey publicKey; + privateKey.MakePublicKey(publicKey); + + SecretKey key_pair; + + // save keys + publicKey.Save(CryptoPP::HexEncoder( + new CryptoPP::StringSink(*key_pair.mutable_public_key())) + .Ref()); + privateKey.Save(CryptoPP::HexEncoder( + new CryptoPP::StringSink(*key_pair.mutable_private_key())) + .Ref()); + return key_pair; +} + +} // namespace + +SecretKey KeyGenerator::GeneratorKeys(SignatureInfo::HashType type) { + SecretKey key; + switch (type) { + case SignatureInfo::RSA: + key = RsaGenerateHexKeyPair(3072); + break; + case SignatureInfo::ED25519: { + key = ED25519GenerateKeys(); + break; + } + case SignatureInfo::CMAC_AES: { + key = CmacGenerateHexKey(16); + break; + } + case SignatureInfo::ECDSA: { + key = ECDSAGenerateKeys(); + break; + } + default: + break; + } + key.set_hash_type(type); + return key; +} + +} // namespace resdb diff --git a/common/crypto/key_generator.h b/common/crypto/key_generator.h index fcbe0f59e7..5a71b7fd82 100644 --- a/common/crypto/key_generator.h +++ b/common/crypto/key_generator.h @@ -1,31 +1,31 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#pragma once - -#include "common/proto/signature_info.pb.h" - -namespace resdb { - -class KeyGenerator { - public: - static SecretKey GeneratorKeys(SignatureInfo::HashType type); -}; - -} // namespace resdb +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#pragma once + +#include "common/proto/signature_info.pb.h" + +namespace resdb { + +class KeyGenerator { + public: + static SecretKey GeneratorKeys(SignatureInfo::HashType type); +}; + +} // namespace resdb diff --git a/common/crypto/mock_signature_verifier.h b/common/crypto/mock_signature_verifier.h index e22d3586ce..7d35c98fc9 100644 --- a/common/crypto/mock_signature_verifier.h +++ b/common/crypto/mock_signature_verifier.h @@ -1,35 +1,35 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#pragma once - -#include "common/crypto/signature_verifier.h" - -namespace resdb { - -class MockSignatureVerifier : public SignatureVerifier { - public: - MockSignatureVerifier() : SignatureVerifier(KeyInfo(), CertificateInfo()) {} - MOCK_METHOD(absl::StatusOr, SignMessage, (const std::string&), - (override)); - MOCK_METHOD(bool, VerifyMessage, - (const std::string&, const SignatureInfo& sign), (override)); -}; - -} // namespace resdb +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#pragma once + +#include "common/crypto/signature_verifier.h" + +namespace resdb { + +class MockSignatureVerifier : public SignatureVerifier { + public: + MockSignatureVerifier() : SignatureVerifier(KeyInfo(), CertificateInfo()) {} + MOCK_METHOD(absl::StatusOr, SignMessage, (const std::string&), + (override)); + MOCK_METHOD(bool, VerifyMessage, + (const std::string&, const SignatureInfo& sign), (override)); +}; + +} // namespace resdb diff --git a/common/crypto/signature_utils.cpp b/common/crypto/signature_utils.cpp index 4df11022be..ec713872ba 100644 --- a/common/crypto/signature_utils.cpp +++ b/common/crypto/signature_utils.cpp @@ -1,147 +1,147 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#include "common/crypto/signature_utils.h" - -#include -#include -#include -#include -#include -#include -#include - -namespace resdb { -namespace utils { - -bool RsaVerifyString(const std::string& message, const std::string& public_key, - const std::string& signature) { - try { - // decode and load public key (using pipeline) - CryptoPP::RSA::PublicKey rsa_public_key; - rsa_public_key.Load( - CryptoPP::StringSource(public_key, true, new CryptoPP::HexDecoder()) - .Ref()); - - // decode signature - std::string decoded_signature; - CryptoPP::StringSource ss( - signature, true, - new CryptoPP::HexDecoder(new CryptoPP::StringSink(decoded_signature))); - - // verify message - bool result = false; - CryptoPP::RSASS::Verifier verifier( - rsa_public_key); - CryptoPP::StringSource ss2( - decoded_signature + message, true, - new CryptoPP::SignatureVerificationFilter( - verifier, - new CryptoPP::ArraySink((CryptoPP::byte*)&result, sizeof(result)))); - - return result; - } catch (...) { - LOG(ERROR) << "key not valid"; - return false; - } -} - -bool ECDSAVerifyString(const std::string& message, - const std::string& public_key, - const std::string& signature) { - std::string decoded; - std::string output; - CryptoPP::StringSource( - signature, true, - new CryptoPP::HexDecoder(new CryptoPP::StringSink(decoded)) // StringSink - ); // StringSource - - CryptoPP::ECDSA::PublicKey dsa_public_key; - dsa_public_key.Load( - CryptoPP::StringSource(public_key, true, new CryptoPP::HexDecoder()) - .Ref()); - CryptoPP::ECDSA::Verifier verifier( - dsa_public_key); - - bool valid = true; - CryptoPP::StringSource( - decoded + message, true, - new CryptoPP::SignatureVerificationFilter( - verifier, - new CryptoPP::ArraySink((CryptoPP::byte*)&valid, sizeof(valid)))); - if (!valid) { - LOG(ERROR) << "signature invalid. signature len:" << signature.size() - << " message len:" << message.size(); - } - return valid; -} - -std::string RsaSignString(const std::string& private_key, - const std::string& message) { - // decode and load private key (using pipeline) - CryptoPP::RSA::PrivateKey rsa_private_key; - rsa_private_key.Load( - CryptoPP::StringSource(private_key, true, new CryptoPP::HexDecoder()) - .Ref()); - - // sign message - std::string signature; - CryptoPP::RSASS::Signer signer( - rsa_private_key); - CryptoPP::AutoSeededRandomPool rng; - CryptoPP::StringSource ss( - message, true, - new CryptoPP::SignerFilter( - rng, signer, - new CryptoPP::HexEncoder(new CryptoPP::StringSink(signature)))); - return signature; -} - -std::string ECDSASignString(const std::string& private_key, - const std::string& message) { - try { - CryptoPP::ECDSA::PrivateKey privateKey; - privateKey.Load( - CryptoPP::StringSource(private_key, true, new CryptoPP::HexDecoder()) - .Ref()); - CryptoPP::AutoSeededRandomPool prng; - std::string signature; - - CryptoPP::StringSource ss1( - message, true /*pump all*/, - new CryptoPP::SignerFilter( - prng, - CryptoPP::ECDSA::Signer( - privateKey), - new CryptoPP::StringSink(signature))); - - std::string output; - CryptoPP::StringSource(signature, true, - new CryptoPP::HexEncoder( - new CryptoPP::StringSink(output)) // HexEncoder - ); // StringSource - return output; - } catch (...) { - LOG(ERROR) << "sign error"; - return ""; - } -} - -} // namespace utils -} // namespace resdb +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#include "common/crypto/signature_utils.h" + +#include +#include +#include +#include +#include +#include +#include + +namespace resdb { +namespace utils { + +bool RsaVerifyString(const std::string& message, const std::string& public_key, + const std::string& signature) { + try { + // decode and load public key (using pipeline) + CryptoPP::RSA::PublicKey rsa_public_key; + rsa_public_key.Load( + CryptoPP::StringSource(public_key, true, new CryptoPP::HexDecoder()) + .Ref()); + + // decode signature + std::string decoded_signature; + CryptoPP::StringSource ss( + signature, true, + new CryptoPP::HexDecoder(new CryptoPP::StringSink(decoded_signature))); + + // verify message + bool result = false; + CryptoPP::RSASS::Verifier verifier( + rsa_public_key); + CryptoPP::StringSource ss2( + decoded_signature + message, true, + new CryptoPP::SignatureVerificationFilter( + verifier, + new CryptoPP::ArraySink((CryptoPP::byte*)&result, sizeof(result)))); + + return result; + } catch (...) { + LOG(ERROR) << "key not valid"; + return false; + } +} + +bool ECDSAVerifyString(const std::string& message, + const std::string& public_key, + const std::string& signature) { + std::string decoded; + std::string output; + CryptoPP::StringSource( + signature, true, + new CryptoPP::HexDecoder(new CryptoPP::StringSink(decoded)) // StringSink + ); // StringSource + + CryptoPP::ECDSA::PublicKey dsa_public_key; + dsa_public_key.Load( + CryptoPP::StringSource(public_key, true, new CryptoPP::HexDecoder()) + .Ref()); + CryptoPP::ECDSA::Verifier verifier( + dsa_public_key); + + bool valid = true; + CryptoPP::StringSource( + decoded + message, true, + new CryptoPP::SignatureVerificationFilter( + verifier, + new CryptoPP::ArraySink((CryptoPP::byte*)&valid, sizeof(valid)))); + if (!valid) { + LOG(ERROR) << "signature invalid. signature len:" << signature.size() + << " message len:" << message.size(); + } + return valid; +} + +std::string RsaSignString(const std::string& private_key, + const std::string& message) { + // decode and load private key (using pipeline) + CryptoPP::RSA::PrivateKey rsa_private_key; + rsa_private_key.Load( + CryptoPP::StringSource(private_key, true, new CryptoPP::HexDecoder()) + .Ref()); + + // sign message + std::string signature; + CryptoPP::RSASS::Signer signer( + rsa_private_key); + CryptoPP::AutoSeededRandomPool rng; + CryptoPP::StringSource ss( + message, true, + new CryptoPP::SignerFilter( + rng, signer, + new CryptoPP::HexEncoder(new CryptoPP::StringSink(signature)))); + return signature; +} + +std::string ECDSASignString(const std::string& private_key, + const std::string& message) { + try { + CryptoPP::ECDSA::PrivateKey privateKey; + privateKey.Load( + CryptoPP::StringSource(private_key, true, new CryptoPP::HexDecoder()) + .Ref()); + CryptoPP::AutoSeededRandomPool prng; + std::string signature; + + CryptoPP::StringSource ss1( + message, true /*pump all*/, + new CryptoPP::SignerFilter( + prng, + CryptoPP::ECDSA::Signer( + privateKey), + new CryptoPP::StringSink(signature))); + + std::string output; + CryptoPP::StringSource(signature, true, + new CryptoPP::HexEncoder( + new CryptoPP::StringSink(output)) // HexEncoder + ); // StringSource + return output; + } catch (...) { + LOG(ERROR) << "sign error"; + return ""; + } +} + +} // namespace utils +} // namespace resdb diff --git a/common/crypto/signature_utils.h b/common/crypto/signature_utils.h index 927cbbd38f..5c876dfdd7 100644 --- a/common/crypto/signature_utils.h +++ b/common/crypto/signature_utils.h @@ -1,40 +1,40 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#pragma once - -#include - -namespace resdb { -namespace utils { - -bool RsaVerifyString(const std::string& message, const std::string& public_key, - const std::string& signature); -bool ECDSAVerifyString(const std::string& message, - const std::string& public_key, - const std::string& signature); - -std::string RsaSignString(const std::string& private_key, - const std::string& message); - -std::string ECDSASignString(const std::string& private_key, - const std::string& message); - -} // namespace utils -} // namespace resdb +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#pragma once + +#include + +namespace resdb { +namespace utils { + +bool RsaVerifyString(const std::string& message, const std::string& public_key, + const std::string& signature); +bool ECDSAVerifyString(const std::string& message, + const std::string& public_key, + const std::string& signature); + +std::string RsaSignString(const std::string& private_key, + const std::string& message); + +std::string ECDSASignString(const std::string& private_key, + const std::string& message); + +} // namespace utils +} // namespace resdb diff --git a/common/crypto/signature_verifier.cpp b/common/crypto/signature_verifier.cpp index cf2046e25a..bfb15da252 100644 --- a/common/crypto/signature_verifier.cpp +++ b/common/crypto/signature_verifier.cpp @@ -1,279 +1,279 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#include "common/crypto/signature_verifier.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "common/crypto/signature_utils.h" - -namespace resdb { - -namespace { - -// ================== for verify ==================================== -bool ED25519verifyString(const std::string& message, - const std::string& public_key, - const std::string& signature) { - CryptoPP::byte byteKey[CryptoPP::ed25519PrivateKey::PUBLIC_KEYLENGTH]; - if (public_key.size() != CryptoPP::ed25519PrivateKey::PUBLIC_KEYLENGTH) { - LOG(ERROR) << "public key len invalid:" << public_key.size(); - return false; - } - memcpy(byteKey, public_key.c_str(), public_key.size()); - auto verifier = CryptoPP::ed25519::Verifier(byteKey); - - bool valid = true; - CryptoPP::StringSource( - signature + message, true, - new CryptoPP::SignatureVerificationFilter( - verifier, - new CryptoPP::ArraySink((CryptoPP::byte*)&valid, sizeof(valid)))); - if (!valid) { - LOG(ERROR) << "signature invalid. signature len:" << signature.size() - << " message len:" << message.size(); - } - return valid; -} - -bool CmacVerifyString(const std::string& message, const std::string& public_key, - const std::string& signature) { - bool res = false; - // KEY TRANSFORMATION - // https://stackoverflow.com/questions/26145776/string-to-secbyteblock-conversion - CryptoPP::SecByteBlock privKey((const unsigned char*)(public_key.data()), - public_key.size()); - CryptoPP::CMAC cmac(privKey.data(), privKey.size()); - const int flags = CryptoPP::HashVerificationFilter::HASH_AT_END | - CryptoPP::HashVerificationFilter::PUT_RESULT; - - // MESSAGE VERIFICATION - CryptoPP::StringSource ss3( - message + signature, true, - new CryptoPP::HashVerificationFilter( - cmac, new CryptoPP::ArraySink((CryptoPP::byte*)&res, sizeof(res)), - flags)); // StringSource - return res; -} - -// ================== for sign ==================================== - -std::string ED25519signString(const std::string& message, - CryptoPP::ed25519::Signer* signer) { - CryptoPP::AutoSeededRandomPool prng; - std::string signature; - CryptoPP::StringSource( - message, true, - new CryptoPP::SignerFilter(CryptoPP::NullRNG(), *signer, - new CryptoPP::StringSink(signature))); - return signature; -} - -// CMAC-AES Signature generator -// Return a token, mac, to verify the a message. -std::string CmacSignString(const std::string& private_key, - const std::string& message) { - std::string mac = ""; - - // KEY TRANSFORMATION. - // https://stackoverflow.com/questions/26145776/string-to-secbyteblock-conversion - - CryptoPP::SecByteBlock mac_private_key( - (const unsigned char*)(private_key.data()), private_key.size()); - - CryptoPP::CMAC cmac(mac_private_key.data(), - mac_private_key.size()); - - CryptoPP::StringSource ss1( - message, true, - new CryptoPP::HashFilter(cmac, new CryptoPP::StringSink(mac))); - return mac; -} - -} // namespace - -SignatureVerifier::SignatureVerifier(const KeyInfo& private_key, - const CertificateInfo& certificate_info) { - private_key_ = private_key; - if (private_key_.key().empty()) { - LOG(ERROR) << "private invalid"; - } - - node_id_ = certificate_info.node_id(); - admin_public_key_ = certificate_info.admin_public_key(); - AddPublicKey(certificate_info.public_key(), false); - if (private_key_.hash_type() == SignatureInfo::ED25519) { - CryptoPP::byte byteKey[CryptoPP::ed25519PrivateKey::SECRET_KEYLENGTH]; - if (private_key_.key().size() != - CryptoPP::ed25519PrivateKey::SECRET_KEYLENGTH) { - return; - } - memcpy(byteKey, private_key_.key().c_str(), private_key_.key().size()); - signer_ = std::make_unique(byteKey); - } -} - -bool SignatureVerifier::AddPublicKey(const CertificateKey& public_key, - bool need_verify) { - std::unique_lock lk(mutex_); - if (need_verify && - !VerifyKey(public_key.public_key_info(), public_key.certificate())) { - return false; - } - // LOG(ERROR) << "add public key from:" - // << public_key.public_key_info().node_id(); - keys_[public_key.public_key_info().node_id()] = public_key; - return true; -} - -absl::StatusOr SignatureVerifier::GetPublicKey(int64_t node_id) const { - std::shared_lock lk(mutex_); - auto it = keys_.find(node_id); - if (it == keys_.end()) { - return absl::InvalidArgumentError("Public key not exist."); - } - return it->second.public_key_info().key(); -} - -std::vector SignatureVerifier::GetAllPublicKeys() const { - std::shared_lock lk(mutex_); - std::vector keys; - for (auto key : keys_) { - keys.push_back(key.second); - } - return keys; -} - -size_t SignatureVerifier::GetPublicKeysSize() const { - std::shared_lock lk(mutex_); - return keys_.size(); -} - -// Funtion to calculate hash of a string. -std::string SignatureVerifier::CalculateHash(const std::string& str) { - CryptoPP::byte const* pData = (CryptoPP::byte*)str.data(); - unsigned int nDataLen = str.size(); - CryptoPP::byte aDigest[CryptoPP::SHA256::DIGESTSIZE]; - - CryptoPP::SHA256().CalculateDigest(aDigest, pData, nDataLen); - return std::string((char*)aDigest, CryptoPP::SHA256::DIGESTSIZE); -} - -absl::StatusOr SignatureVerifier::SignMessage( - const std::string& message) { - SignatureInfo info; - info.set_node_id(node_id_); - switch (private_key_.hash_type()) { - case SignatureInfo::RSA: - info.set_signature(utils::RsaSignString(private_key_.key(), message)); - break; - case SignatureInfo::ED25519: - info.set_signature(ED25519signString(message, signer_.get())); - break; - case SignatureInfo::CMAC_AES: - info.set_signature(CmacSignString(private_key_.key(), message)); - break; - case SignatureInfo::ECDSA: - info.set_signature(utils::ECDSASignString(private_key_.key(), message)); - break; - default: - break; - } - return info; -} - -bool SignatureVerifier::VerifyMessage(const google::protobuf::Message& message, - const SignatureInfo& sign) { - std::string str; - if (!message.SerializeToString(&str)) { - return false; - } - return VerifyMessage(str, sign); -} - -bool SignatureVerifier::VerifyMessage(const std::string& message, - const SignatureInfo& info) { - if (info.signature().empty()) { - LOG(ERROR) << " signature is empty"; - return false; - } - auto public_key = GetPublicKey(info.node_id()); - if (!public_key.ok()) { - LOG(ERROR) << "key not found:" << info.node_id(); - return false; - } - return VerifyMessage(message, *public_key, info.signature()); -} - -absl::StatusOr SignatureVerifier::SignCertificateKeyInfo( - const CertificateKeyInfo& info) { - std::string str; - if (!info.SerializeToString(&str)) { - return absl::InvalidArgumentError("Serialize fail"); - } - return SignatureVerifier::SignMessage(str); -} - -bool SignatureVerifier::VerifyKey(const CertificateKeyInfo& info, - const SignatureInfo& sign) { - std::string str; - if (!info.SerializeToString(&str)) { - return false; - } - return VerifyMessage(str, admin_public_key_, sign.signature()); -} - -bool SignatureVerifier::VerifyMessage(const std::string& message, - const KeyInfo& public_key, - const std::string& signature) { - if (public_key.key().empty() || signature.empty()) { - LOG(ERROR) << "public is empty, size(" << public_key.key().size() - << ") or signature is empty, size(" << signature.size() << ")"; - return false; - } - // LOG(ERROR) << "public key hash type:" << public_key.hash_type() - // << " key size:" << public_key.key().size() - // << " sig size:" << signature.size() - // << " msg size:" << message.size(); - switch (public_key.hash_type()) { - case SignatureInfo::RSA: - return utils::RsaVerifyString(message, public_key.key(), signature); - case SignatureInfo::ED25519: - return ED25519verifyString(message, public_key.key(), signature); - case SignatureInfo::CMAC_AES: - return CmacVerifyString(message, public_key.key(), signature); - case SignatureInfo::ECDSA: - return utils::ECDSAVerifyString(message, public_key.key(), signature); - default: - return true; - } -} - -} // namespace resdb +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#include "common/crypto/signature_verifier.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "common/crypto/signature_utils.h" + +namespace resdb { + +namespace { + +// ================== for verify ==================================== +bool ED25519verifyString(const std::string& message, + const std::string& public_key, + const std::string& signature) { + CryptoPP::byte byteKey[CryptoPP::ed25519PrivateKey::PUBLIC_KEYLENGTH]; + if (public_key.size() != CryptoPP::ed25519PrivateKey::PUBLIC_KEYLENGTH) { + LOG(ERROR) << "public key len invalid:" << public_key.size(); + return false; + } + memcpy(byteKey, public_key.c_str(), public_key.size()); + auto verifier = CryptoPP::ed25519::Verifier(byteKey); + + bool valid = true; + CryptoPP::StringSource( + signature + message, true, + new CryptoPP::SignatureVerificationFilter( + verifier, + new CryptoPP::ArraySink((CryptoPP::byte*)&valid, sizeof(valid)))); + if (!valid) { + LOG(ERROR) << "signature invalid. signature len:" << signature.size() + << " message len:" << message.size(); + } + return valid; +} + +bool CmacVerifyString(const std::string& message, const std::string& public_key, + const std::string& signature) { + bool res = false; + // KEY TRANSFORMATION + // https://stackoverflow.com/questions/26145776/string-to-secbyteblock-conversion + CryptoPP::SecByteBlock privKey((const unsigned char*)(public_key.data()), + public_key.size()); + CryptoPP::CMAC cmac(privKey.data(), privKey.size()); + const int flags = CryptoPP::HashVerificationFilter::HASH_AT_END | + CryptoPP::HashVerificationFilter::PUT_RESULT; + + // MESSAGE VERIFICATION + CryptoPP::StringSource ss3( + message + signature, true, + new CryptoPP::HashVerificationFilter( + cmac, new CryptoPP::ArraySink((CryptoPP::byte*)&res, sizeof(res)), + flags)); // StringSource + return res; +} + +// ================== for sign ==================================== + +std::string ED25519signString(const std::string& message, + CryptoPP::ed25519::Signer* signer) { + CryptoPP::AutoSeededRandomPool prng; + std::string signature; + CryptoPP::StringSource( + message, true, + new CryptoPP::SignerFilter(CryptoPP::NullRNG(), *signer, + new CryptoPP::StringSink(signature))); + return signature; +} + +// CMAC-AES Signature generator +// Return a token, mac, to verify the a message. +std::string CmacSignString(const std::string& private_key, + const std::string& message) { + std::string mac = ""; + + // KEY TRANSFORMATION. + // https://stackoverflow.com/questions/26145776/string-to-secbyteblock-conversion + + CryptoPP::SecByteBlock mac_private_key( + (const unsigned char*)(private_key.data()), private_key.size()); + + CryptoPP::CMAC cmac(mac_private_key.data(), + mac_private_key.size()); + + CryptoPP::StringSource ss1( + message, true, + new CryptoPP::HashFilter(cmac, new CryptoPP::StringSink(mac))); + return mac; +} + +} // namespace + +SignatureVerifier::SignatureVerifier(const KeyInfo& private_key, + const CertificateInfo& certificate_info) { + private_key_ = private_key; + if (private_key_.key().empty()) { + LOG(ERROR) << "private invalid"; + } + + node_id_ = certificate_info.node_id(); + admin_public_key_ = certificate_info.admin_public_key(); + AddPublicKey(certificate_info.public_key(), false); + if (private_key_.hash_type() == SignatureInfo::ED25519) { + CryptoPP::byte byteKey[CryptoPP::ed25519PrivateKey::SECRET_KEYLENGTH]; + if (private_key_.key().size() != + CryptoPP::ed25519PrivateKey::SECRET_KEYLENGTH) { + return; + } + memcpy(byteKey, private_key_.key().c_str(), private_key_.key().size()); + signer_ = std::make_unique(byteKey); + } +} + +bool SignatureVerifier::AddPublicKey(const CertificateKey& public_key, + bool need_verify) { + std::unique_lock lk(mutex_); + if (need_verify && + !VerifyKey(public_key.public_key_info(), public_key.certificate())) { + return false; + } + // LOG(ERROR) << "add public key from:" + // << public_key.public_key_info().node_id(); + keys_[public_key.public_key_info().node_id()] = public_key; + return true; +} + +absl::StatusOr SignatureVerifier::GetPublicKey(int64_t node_id) const { + std::shared_lock lk(mutex_); + auto it = keys_.find(node_id); + if (it == keys_.end()) { + return absl::InvalidArgumentError("Public key not exist."); + } + return it->second.public_key_info().key(); +} + +std::vector SignatureVerifier::GetAllPublicKeys() const { + std::shared_lock lk(mutex_); + std::vector keys; + for (auto key : keys_) { + keys.push_back(key.second); + } + return keys; +} + +size_t SignatureVerifier::GetPublicKeysSize() const { + std::shared_lock lk(mutex_); + return keys_.size(); +} + +// Funtion to calculate hash of a string. +std::string SignatureVerifier::CalculateHash(const std::string& str) { + CryptoPP::byte const* pData = (CryptoPP::byte*)str.data(); + unsigned int nDataLen = str.size(); + CryptoPP::byte aDigest[CryptoPP::SHA256::DIGESTSIZE]; + + CryptoPP::SHA256().CalculateDigest(aDigest, pData, nDataLen); + return std::string((char*)aDigest, CryptoPP::SHA256::DIGESTSIZE); +} + +absl::StatusOr SignatureVerifier::SignMessage( + const std::string& message) { + SignatureInfo info; + info.set_node_id(node_id_); + switch (private_key_.hash_type()) { + case SignatureInfo::RSA: + info.set_signature(utils::RsaSignString(private_key_.key(), message)); + break; + case SignatureInfo::ED25519: + info.set_signature(ED25519signString(message, signer_.get())); + break; + case SignatureInfo::CMAC_AES: + info.set_signature(CmacSignString(private_key_.key(), message)); + break; + case SignatureInfo::ECDSA: + info.set_signature(utils::ECDSASignString(private_key_.key(), message)); + break; + default: + break; + } + return info; +} + +bool SignatureVerifier::VerifyMessage(const google::protobuf::Message& message, + const SignatureInfo& sign) { + std::string str; + if (!message.SerializeToString(&str)) { + return false; + } + return VerifyMessage(str, sign); +} + +bool SignatureVerifier::VerifyMessage(const std::string& message, + const SignatureInfo& info) { + if (info.signature().empty()) { + LOG(ERROR) << " signature is empty"; + return false; + } + auto public_key = GetPublicKey(info.node_id()); + if (!public_key.ok()) { + LOG(ERROR) << "key not found:" << info.node_id(); + return false; + } + return VerifyMessage(message, *public_key, info.signature()); +} + +absl::StatusOr SignatureVerifier::SignCertificateKeyInfo( + const CertificateKeyInfo& info) { + std::string str; + if (!info.SerializeToString(&str)) { + return absl::InvalidArgumentError("Serialize fail"); + } + return SignatureVerifier::SignMessage(str); +} + +bool SignatureVerifier::VerifyKey(const CertificateKeyInfo& info, + const SignatureInfo& sign) { + std::string str; + if (!info.SerializeToString(&str)) { + return false; + } + return VerifyMessage(str, admin_public_key_, sign.signature()); +} + +bool SignatureVerifier::VerifyMessage(const std::string& message, + const KeyInfo& public_key, + const std::string& signature) { + if (public_key.key().empty() || signature.empty()) { + LOG(ERROR) << "public is empty, size(" << public_key.key().size() + << ") or signature is empty, size(" << signature.size() << ")"; + return false; + } + // LOG(ERROR) << "public key hash type:" << public_key.hash_type() + // << " key size:" << public_key.key().size() + // << " sig size:" << signature.size() + // << " msg size:" << message.size(); + switch (public_key.hash_type()) { + case SignatureInfo::RSA: + return utils::RsaVerifyString(message, public_key.key(), signature); + case SignatureInfo::ED25519: + return ED25519verifyString(message, public_key.key(), signature); + case SignatureInfo::CMAC_AES: + return CmacVerifyString(message, public_key.key(), signature); + case SignatureInfo::ECDSA: + return utils::ECDSAVerifyString(message, public_key.key(), signature); + default: + return true; + } +} + +} // namespace resdb diff --git a/common/crypto/signature_verifier.h b/common/crypto/signature_verifier.h index 2a8e312cdb..fc216823e0 100644 --- a/common/crypto/signature_verifier.h +++ b/common/crypto/signature_verifier.h @@ -1,83 +1,83 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#pragma once - -#include -#include - -#include -#include - -#include "absl/status/statusor.h" -#include "common/crypto/signature_verifier_interface.h" -#include "common/proto/signature_info.pb.h" - -namespace resdb { - -// SignatureVerifier used to sign signatures using private_key, -// and verify signatures using the public keys of the senders identified -// by their node_id. -class SignatureVerifier : public SignatureVerifierInterface { - public: - SignatureVerifier(const KeyInfo& private_key, - const CertificateInfo& certificate_info); - virtual ~SignatureVerifier() = default; - - // Set the public key that contains the public key, node id, - // and its certificate. - bool AddPublicKey(const CertificateKey& pub_key, bool need_verify = true); - - // Get the public key of node id. KeyInfo contains the key and its hash type. - absl::StatusOr GetPublicKey(int64_t node_id) const; - // Get all the public keys. - std::vector GetAllPublicKeys() const; - // Get the number of public keys it contains. - size_t GetPublicKeysSize() const; - - // Sign messages using the private key. - virtual absl::StatusOr SignMessage(const std::string& message); - absl::StatusOr SignCertificateKeyInfo( - const CertificateKeyInfo& info); - - // Verify messages using the public key from the sender. - virtual bool VerifyMessage(const std::string& message, - const SignatureInfo& sign); - bool VerifyMessage(const google::protobuf::Message& message, - const SignatureInfo& sign); - bool VerifyKey(const CertificateKeyInfo& info, const SignatureInfo& sign); - - static std::string CalculateHash(const std::string& str); - - static bool VerifyMessage(const std::string& message, - const KeyInfo& public_key, - const std::string& signature); - - private: - std::map keys_; - // GUARDED_BY(mutex_); // public keys of nodes, including the public key and - // its encrpt type. - KeyInfo private_key_; // public-private keys of self. - KeyInfo admin_public_key_; // public key of admin. - int64_t node_id_; // id of current node. - std::unique_ptr signer_; - mutable std::shared_mutex mutex_; -}; - -} // namespace resdb +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#pragma once + +#include +#include + +#include +#include + +#include "absl/status/statusor.h" +#include "common/crypto/signature_verifier_interface.h" +#include "common/proto/signature_info.pb.h" + +namespace resdb { + +// SignatureVerifier used to sign signatures using private_key, +// and verify signatures using the public keys of the senders identified +// by their node_id. +class SignatureVerifier : public SignatureVerifierInterface { + public: + SignatureVerifier(const KeyInfo& private_key, + const CertificateInfo& certificate_info); + virtual ~SignatureVerifier() = default; + + // Set the public key that contains the public key, node id, + // and its certificate. + bool AddPublicKey(const CertificateKey& pub_key, bool need_verify = true); + + // Get the public key of node id. KeyInfo contains the key and its hash type. + absl::StatusOr GetPublicKey(int64_t node_id) const; + // Get all the public keys. + std::vector GetAllPublicKeys() const; + // Get the number of public keys it contains. + size_t GetPublicKeysSize() const; + + // Sign messages using the private key. + virtual absl::StatusOr SignMessage(const std::string& message); + absl::StatusOr SignCertificateKeyInfo( + const CertificateKeyInfo& info); + + // Verify messages using the public key from the sender. + virtual bool VerifyMessage(const std::string& message, + const SignatureInfo& sign); + bool VerifyMessage(const google::protobuf::Message& message, + const SignatureInfo& sign); + bool VerifyKey(const CertificateKeyInfo& info, const SignatureInfo& sign); + + static std::string CalculateHash(const std::string& str); + + static bool VerifyMessage(const std::string& message, + const KeyInfo& public_key, + const std::string& signature); + + private: + std::map keys_; + // GUARDED_BY(mutex_); // public keys of nodes, including the public key and + // its encrpt type. + KeyInfo private_key_; // public-private keys of self. + KeyInfo admin_public_key_; // public key of admin. + int64_t node_id_; // id of current node. + std::unique_ptr signer_; + mutable std::shared_mutex mutex_; +}; + +} // namespace resdb diff --git a/common/crypto/signature_verifier_interface.cpp b/common/crypto/signature_verifier_interface.cpp index 865eccffce..fcd9d8839f 100644 --- a/common/crypto/signature_verifier_interface.cpp +++ b/common/crypto/signature_verifier_interface.cpp @@ -1,29 +1,29 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#include "common/crypto/signature_verifier_interface.h" - -namespace resdb { - -absl::StatusOr SignatureVerifierInterface::SignMessage( - const std::string& message) { - return SignatureInfo(); -} - -} // namespace resdb +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#include "common/crypto/signature_verifier_interface.h" + +namespace resdb { + +absl::StatusOr SignatureVerifierInterface::SignMessage( + const std::string& message) { + return SignatureInfo(); +} + +} // namespace resdb diff --git a/common/crypto/signature_verifier_interface.h b/common/crypto/signature_verifier_interface.h index 197387fc3b..108c8ee490 100644 --- a/common/crypto/signature_verifier_interface.h +++ b/common/crypto/signature_verifier_interface.h @@ -1,37 +1,37 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#pragma once - -#include "absl/status/statusor.h" -#include "common/proto/signature_info.pb.h" - -namespace resdb { - -// SignatureVerifier base class, provide an interface for communication. -class SignatureVerifierInterface { - public: - SignatureVerifierInterface() = default; - virtual ~SignatureVerifierInterface() = default; - - // Sign messages using the private key. - virtual absl::StatusOr SignMessage(const std::string& message); -}; - -} // namespace resdb +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#pragma once + +#include "absl/status/statusor.h" +#include "common/proto/signature_info.pb.h" + +namespace resdb { + +// SignatureVerifier base class, provide an interface for communication. +class SignatureVerifierInterface { + public: + SignatureVerifierInterface() = default; + virtual ~SignatureVerifierInterface() = default; + + // Sign messages using the private key. + virtual absl::StatusOr SignMessage(const std::string& message); +}; + +} // namespace resdb diff --git a/common/crypto/signature_verifier_test.cpp b/common/crypto/signature_verifier_test.cpp index 3bdecc8daf..bde9a3a08d 100644 --- a/common/crypto/signature_verifier_test.cpp +++ b/common/crypto/signature_verifier_test.cpp @@ -1,160 +1,160 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#include "common/crypto/signature_verifier.h" - -#include -#include -#include - -#include "common/crypto/key_generator.h" -#include "common/test/test_macros.h" - -namespace resdb { -namespace { - -using ::resdb::testing::EqualsProto; - -TEST(SignatureVerifyTest, CalculateHash) { - std::string expected_str = - "\x9F\x86\xD0\x81\x88L}e\x9A/" - "\xEA\xA0\xC5Z\xD0\x15\xA3\xBFO\x1B+\v\x82,\xD1]l\x15\xB0\xF0\n\b"; - EXPECT_EQ(SignatureVerifier::CalculateHash("test"), expected_str); -} - -KeyInfo GetKeyInfo(SecretKey key) { - KeyInfo info; - info.set_key(key.private_key()); - info.set_hash_type(key.hash_type()); - return info; -} - -class SignatureVerifyPTest - : public ::testing::TestWithParam { - public: - SignatureVerifyPTest() { - admin_key_ = KeyGenerator ::GeneratorKeys(SignatureInfo::RSA); - admin_verifier_ = std::make_unique( - GetKeyInfo(admin_key_), GetCertInfo(0)); - } - - CertificateInfo GetCertInfo(int64_t node_id) { - CertificateInfo cert_info; - cert_info.set_node_id(node_id); - - cert_info.mutable_admin_public_key()->set_key(admin_key_.public_key()); - cert_info.mutable_admin_public_key()->set_hash_type(admin_key_.hash_type()); - - return cert_info; - } - - CertificateKey GetPublicKeyInfo(SecretKey key, int64_t node_id) { - CertificateKey cert_key; - cert_key.mutable_public_key_info()->mutable_key()->set_key( - key.public_key()); - cert_key.mutable_public_key_info()->mutable_key()->set_hash_type( - key.hash_type()); - cert_key.mutable_public_key_info()->set_node_id(node_id); - - auto resp_info = - admin_verifier_->SignCertificateKeyInfo(cert_key.public_key_info()); - assert(resp_info.ok()); - *cert_key.mutable_certificate() = *resp_info; - return cert_key; - } - - private: - SecretKey admin_key_; - std::unique_ptr admin_verifier_; -}; - -TEST_P(SignatureVerifyPTest, SignAndVerify) { - SignatureInfo::HashType type = GetParam(); - absl::StatusOr s_info; - std::string message = "test_message"; - SecretKey my_key = KeyGenerator ::GeneratorKeys(type); - int64_t my_node_id = 1, your_node_id = 2; - { - SignatureVerifier verifier(GetKeyInfo(my_key), GetCertInfo(my_node_id)); - s_info = verifier.SignMessage(message); - EXPECT_TRUE(s_info.ok()); - EXPECT_EQ(s_info->node_id(), my_node_id); - } - { - SecretKey your_key = KeyGenerator ::GeneratorKeys(type); - SignatureVerifier verifier(GetKeyInfo(your_key), GetCertInfo(your_node_id)); - verifier.AddPublicKey(GetPublicKeyInfo(my_key, my_node_id)); - EXPECT_TRUE(verifier.VerifyMessage(message, *s_info)); - } -} - -TEST_P(SignatureVerifyPTest, KeyNotFound) { - SignatureInfo::HashType type = GetParam(); - - absl::StatusOr s_info; - std::string message = "test_message"; - SecretKey my_key = KeyGenerator ::GeneratorKeys(type); - int64_t my_node_id = 1, your_node_id = 2; - - { - SignatureVerifier verifier(GetKeyInfo(my_key), GetCertInfo(my_node_id)); - s_info = verifier.SignMessage(message); - EXPECT_TRUE(s_info.ok()); - EXPECT_EQ(s_info->node_id(), my_node_id); - } - - { - SecretKey your_key = KeyGenerator ::GeneratorKeys(type); - SignatureVerifier verifier(GetKeyInfo(your_key), GetCertInfo(your_node_id)); - EXPECT_FALSE(verifier.VerifyMessage(message, *s_info)); - } -} - -TEST_P(SignatureVerifyPTest, KeyNotMatch) { - SignatureInfo::HashType type = GetParam(); - - absl::StatusOr s_info; - std::string message = "test_message"; - SecretKey my_key = KeyGenerator ::GeneratorKeys(type); - SecretKey your_key = KeyGenerator ::GeneratorKeys(type); - int64_t my_node_id = 1, your_node_id = 2; - - { - SignatureVerifier verifier(GetKeyInfo(my_key), GetCertInfo(my_node_id)); - s_info = verifier.SignMessage(message); - EXPECT_TRUE(s_info.ok()); - EXPECT_EQ(s_info->node_id(), my_node_id); - } - - { - SignatureVerifier verifier(GetKeyInfo(your_key), GetCertInfo(your_node_id)); - verifier.AddPublicKey(GetPublicKeyInfo(your_key, my_node_id)); - EXPECT_FALSE(verifier.VerifyMessage(message, *s_info)); - } -} - -INSTANTIATE_TEST_SUITE_P(SignatureVerifyPTest, SignatureVerifyPTest, - ::testing::Values(SignatureInfo::RSA, - SignatureInfo::ED25519, - SignatureInfo::CMAC_AES, - SignatureInfo::ECDSA)); - -} // namespace - -} // namespace resdb +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#include "common/crypto/signature_verifier.h" + +#include +#include +#include + +#include "common/crypto/key_generator.h" +#include "common/test/test_macros.h" + +namespace resdb { +namespace { + +using ::resdb::testing::EqualsProto; + +TEST(SignatureVerifyTest, CalculateHash) { + std::string expected_str = + "\x9F\x86\xD0\x81\x88L}e\x9A/" + "\xEA\xA0\xC5Z\xD0\x15\xA3\xBFO\x1B+\v\x82,\xD1]l\x15\xB0\xF0\n\b"; + EXPECT_EQ(SignatureVerifier::CalculateHash("test"), expected_str); +} + +KeyInfo GetKeyInfo(SecretKey key) { + KeyInfo info; + info.set_key(key.private_key()); + info.set_hash_type(key.hash_type()); + return info; +} + +class SignatureVerifyPTest + : public ::testing::TestWithParam { + public: + SignatureVerifyPTest() { + admin_key_ = KeyGenerator ::GeneratorKeys(SignatureInfo::RSA); + admin_verifier_ = std::make_unique( + GetKeyInfo(admin_key_), GetCertInfo(0)); + } + + CertificateInfo GetCertInfo(int64_t node_id) { + CertificateInfo cert_info; + cert_info.set_node_id(node_id); + + cert_info.mutable_admin_public_key()->set_key(admin_key_.public_key()); + cert_info.mutable_admin_public_key()->set_hash_type(admin_key_.hash_type()); + + return cert_info; + } + + CertificateKey GetPublicKeyInfo(SecretKey key, int64_t node_id) { + CertificateKey cert_key; + cert_key.mutable_public_key_info()->mutable_key()->set_key( + key.public_key()); + cert_key.mutable_public_key_info()->mutable_key()->set_hash_type( + key.hash_type()); + cert_key.mutable_public_key_info()->set_node_id(node_id); + + auto resp_info = + admin_verifier_->SignCertificateKeyInfo(cert_key.public_key_info()); + assert(resp_info.ok()); + *cert_key.mutable_certificate() = *resp_info; + return cert_key; + } + + private: + SecretKey admin_key_; + std::unique_ptr admin_verifier_; +}; + +TEST_P(SignatureVerifyPTest, SignAndVerify) { + SignatureInfo::HashType type = GetParam(); + absl::StatusOr s_info; + std::string message = "test_message"; + SecretKey my_key = KeyGenerator ::GeneratorKeys(type); + int64_t my_node_id = 1, your_node_id = 2; + { + SignatureVerifier verifier(GetKeyInfo(my_key), GetCertInfo(my_node_id)); + s_info = verifier.SignMessage(message); + EXPECT_TRUE(s_info.ok()); + EXPECT_EQ(s_info->node_id(), my_node_id); + } + { + SecretKey your_key = KeyGenerator ::GeneratorKeys(type); + SignatureVerifier verifier(GetKeyInfo(your_key), GetCertInfo(your_node_id)); + verifier.AddPublicKey(GetPublicKeyInfo(my_key, my_node_id)); + EXPECT_TRUE(verifier.VerifyMessage(message, *s_info)); + } +} + +TEST_P(SignatureVerifyPTest, KeyNotFound) { + SignatureInfo::HashType type = GetParam(); + + absl::StatusOr s_info; + std::string message = "test_message"; + SecretKey my_key = KeyGenerator ::GeneratorKeys(type); + int64_t my_node_id = 1, your_node_id = 2; + + { + SignatureVerifier verifier(GetKeyInfo(my_key), GetCertInfo(my_node_id)); + s_info = verifier.SignMessage(message); + EXPECT_TRUE(s_info.ok()); + EXPECT_EQ(s_info->node_id(), my_node_id); + } + + { + SecretKey your_key = KeyGenerator ::GeneratorKeys(type); + SignatureVerifier verifier(GetKeyInfo(your_key), GetCertInfo(your_node_id)); + EXPECT_FALSE(verifier.VerifyMessage(message, *s_info)); + } +} + +TEST_P(SignatureVerifyPTest, KeyNotMatch) { + SignatureInfo::HashType type = GetParam(); + + absl::StatusOr s_info; + std::string message = "test_message"; + SecretKey my_key = KeyGenerator ::GeneratorKeys(type); + SecretKey your_key = KeyGenerator ::GeneratorKeys(type); + int64_t my_node_id = 1, your_node_id = 2; + + { + SignatureVerifier verifier(GetKeyInfo(my_key), GetCertInfo(my_node_id)); + s_info = verifier.SignMessage(message); + EXPECT_TRUE(s_info.ok()); + EXPECT_EQ(s_info->node_id(), my_node_id); + } + + { + SignatureVerifier verifier(GetKeyInfo(your_key), GetCertInfo(your_node_id)); + verifier.AddPublicKey(GetPublicKeyInfo(your_key, my_node_id)); + EXPECT_FALSE(verifier.VerifyMessage(message, *s_info)); + } +} + +INSTANTIATE_TEST_SUITE_P(SignatureVerifyPTest, SignatureVerifyPTest, + ::testing::Values(SignatureInfo::RSA, + SignatureInfo::ED25519, + SignatureInfo::CMAC_AES, + SignatureInfo::ECDSA)); + +} // namespace + +} // namespace resdb diff --git a/common/lru/BUILD b/common/lru/BUILD index ad72bd98af..b983c5a7a6 100644 --- a/common/lru/BUILD +++ b/common/lru/BUILD @@ -1,36 +1,36 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -package(default_visibility = ["//visibility:public"]) - -cc_library( - name = "lru_cache", - srcs = ["lru_cache.cpp"], - hdrs = ["lru_cache.h"], -) - -cc_test( - name = "lru_cache_test", - srcs = ["lru_cache_test.cpp"], - deps = [ - "//common/lru:lru_cache", - "//common/test:test_main", - ], - timeout = "short", # Set the timeout to "short" - size = "small", # Set the size to "small" +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +package(default_visibility = ["//visibility:public"]) + +cc_library( + name = "lru_cache", + srcs = ["lru_cache.cpp"], + hdrs = ["lru_cache.h"], +) + +cc_test( + name = "lru_cache_test", + srcs = ["lru_cache_test.cpp"], + deps = [ + "//common/lru:lru_cache", + "//common/test:test_main", + ], + timeout = "short", # Set the timeout to "short" + size = "small", # Set the size to "small" ) \ No newline at end of file diff --git a/common/lru/lru_cache.cpp b/common/lru/lru_cache.cpp index 75033d4602..32b51b2fb9 100644 --- a/common/lru/lru_cache.cpp +++ b/common/lru/lru_cache.cpp @@ -1,122 +1,122 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#include "lru_cache.h" - -#include "string" - -namespace resdb { - -template -LRUCache::LRUCache(int capacity) { - capacity_ = capacity; - cache_hits_ = 0; - cache_misses_ = 0; -} - -template -LRUCache::~LRUCache() { - lookup_.clear(); - key_list_.clear(); - rlookup_.clear(); -} - -template -ValueType LRUCache::Get(KeyType key) { - if (lookup_.find(key) == lookup_.end()) { - cache_misses_++; - return ValueType(); - } - - // Move accessed key to front of key list. This marks the key as used - key_list_.splice(key_list_.begin(), key_list_, rlookup_[key]); - - cache_hits_++; - return lookup_[key]; -} - -template -void LRUCache::Put(KeyType key, ValueType value) { - if (lookup_.find(key) == lookup_.end()) { - if (key_list_.size() == capacity_) { - KeyType lru_key = key_list_.back(); - key_list_.pop_back(); - lookup_.erase(lru_key); - rlookup_.erase(lru_key); - } - key_list_.push_front(key); - rlookup_[key] = key_list_.begin(); - } else { - key_list_.splice(key_list_.begin(), key_list_, rlookup_[key]); - } - lookup_[key] = value; // Set the lookup_ here -} - -template -void LRUCache::SetCapacity(int new_capacity) { - if (new_capacity < capacity_) { - while (key_list_.size() > new_capacity) { - KeyType lru_key = key_list_.back(); - key_list_.pop_back(); - lookup_.erase(lru_key); - rlookup_.erase(lru_key); - } - } - capacity_ = new_capacity; -} - -template -int LRUCache::GetCapacity() { - return capacity_; -} - -template -void LRUCache::Flush() { - lookup_.clear(); - key_list_.clear(); - rlookup_.clear(); - cache_hits_ = 0; - cache_misses_ = 0; -} - -template -int LRUCache::GetCacheHits() const { - return cache_hits_; -} - -template -int LRUCache::GetCacheMisses() const { - return cache_misses_; -} - -template -double LRUCache::GetCacheHitRatio() const { - int total_accesses = cache_hits_ + cache_misses_; - if (total_accesses == 0) { - return 0.0; - } - return static_cast(cache_hits_) / total_accesses; -} - -template class LRUCache; -template class LRUCache; -template class LRUCache; -template class LRUCache; - +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#include "lru_cache.h" + +#include "string" + +namespace resdb { + +template +LRUCache::LRUCache(int capacity) { + capacity_ = capacity; + cache_hits_ = 0; + cache_misses_ = 0; +} + +template +LRUCache::~LRUCache() { + lookup_.clear(); + key_list_.clear(); + rlookup_.clear(); +} + +template +ValueType LRUCache::Get(KeyType key) { + if (lookup_.find(key) == lookup_.end()) { + cache_misses_++; + return ValueType(); + } + + // Move accessed key to front of key list. This marks the key as used + key_list_.splice(key_list_.begin(), key_list_, rlookup_[key]); + + cache_hits_++; + return lookup_[key]; +} + +template +void LRUCache::Put(KeyType key, ValueType value) { + if (lookup_.find(key) == lookup_.end()) { + if (key_list_.size() == capacity_) { + KeyType lru_key = key_list_.back(); + key_list_.pop_back(); + lookup_.erase(lru_key); + rlookup_.erase(lru_key); + } + key_list_.push_front(key); + rlookup_[key] = key_list_.begin(); + } else { + key_list_.splice(key_list_.begin(), key_list_, rlookup_[key]); + } + lookup_[key] = value; // Set the lookup_ here +} + +template +void LRUCache::SetCapacity(int new_capacity) { + if (new_capacity < capacity_) { + while (key_list_.size() > new_capacity) { + KeyType lru_key = key_list_.back(); + key_list_.pop_back(); + lookup_.erase(lru_key); + rlookup_.erase(lru_key); + } + } + capacity_ = new_capacity; +} + +template +int LRUCache::GetCapacity() { + return capacity_; +} + +template +void LRUCache::Flush() { + lookup_.clear(); + key_list_.clear(); + rlookup_.clear(); + cache_hits_ = 0; + cache_misses_ = 0; +} + +template +int LRUCache::GetCacheHits() const { + return cache_hits_; +} + +template +int LRUCache::GetCacheMisses() const { + return cache_misses_; +} + +template +double LRUCache::GetCacheHitRatio() const { + int total_accesses = cache_hits_ + cache_misses_; + if (total_accesses == 0) { + return 0.0; + } + return static_cast(cache_hits_) / total_accesses; +} + +template class LRUCache; +template class LRUCache; +template class LRUCache; +template class LRUCache; + } // namespace resdb \ No newline at end of file diff --git a/common/lru/lru_cache.h b/common/lru/lru_cache.h index aa4a17dc98..085334a819 100644 --- a/common/lru/lru_cache.h +++ b/common/lru/lru_cache.h @@ -1,51 +1,51 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#include -#include - -namespace resdb { - -template -class LRUCache { - public: - LRUCache(int capacity); - ~LRUCache(); - - ValueType Get(KeyType key); - void Put(KeyType key, ValueType value); - int GetCapacity(); - void SetCapacity(int new_capacity); - void Flush(); - int GetCacheHits() const; - int GetCacheMisses() const; - double GetCacheHitRatio() const; - - private: - int capacity_; - int cache_hits_; - int cache_misses_; - std::list key_list_; // Doubly linked list to store keys - std::unordered_map - lookup_; // Hash map for key-value pairs - std::unordered_map::iterator> - rlookup_; // Hash map for key-iterator pairs -}; - -} // namespace resdb +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#include +#include + +namespace resdb { + +template +class LRUCache { + public: + LRUCache(int capacity); + ~LRUCache(); + + ValueType Get(KeyType key); + void Put(KeyType key, ValueType value); + int GetCapacity(); + void SetCapacity(int new_capacity); + void Flush(); + int GetCacheHits() const; + int GetCacheMisses() const; + double GetCacheHitRatio() const; + + private: + int capacity_; + int cache_hits_; + int cache_misses_; + std::list key_list_; // Doubly linked list to store keys + std::unordered_map + lookup_; // Hash map for key-value pairs + std::unordered_map::iterator> + rlookup_; // Hash map for key-iterator pairs +}; + +} // namespace resdb diff --git a/common/lru/lru_cache_test.cpp b/common/lru/lru_cache_test.cpp index aad569f0a2..97ac5d6e5c 100644 --- a/common/lru/lru_cache_test.cpp +++ b/common/lru/lru_cache_test.cpp @@ -1,94 +1,94 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#include "common/lru/lru_cache.h" - -#include - -namespace resdb { -namespace { - -class LRUCacheTest : public ::testing::Test { - protected: - LRUCache cache_{3}; -}; - -TEST_F(LRUCacheTest, TestPutAndGet) { - cache_.Put(1, 100); - EXPECT_EQ(cache_.Get(1), 100); - EXPECT_EQ(cache_.GetCacheHits(), 1); - EXPECT_EQ(cache_.GetCacheMisses(), 0); -} - -TEST_F(LRUCacheTest, TestUpdateValue) { - cache_.Put(1, 100); - cache_.Put(1, 200); - EXPECT_EQ(cache_.Get(1), 200); - EXPECT_EQ(cache_.GetCacheHits(), 1); - EXPECT_EQ(cache_.GetCacheMisses(), 0); -} - -TEST_F(LRUCacheTest, TestEviction) { - cache_.Put(1, 100); - cache_.Put(2, 200); - cache_.Put(3, 300); - cache_.Put(4, 400); // This should evict key 1 - - EXPECT_EQ(cache_.Get(1), 0); // Key 1 should be evicted - EXPECT_EQ(cache_.Get(2), 200); - EXPECT_EQ(cache_.Get(3), 300); - EXPECT_EQ(cache_.Get(4), 400); - - EXPECT_EQ(cache_.GetCacheHits(), 3); - EXPECT_EQ(cache_.GetCacheMisses(), 1); -} - -TEST_F(LRUCacheTest, TestUsageOrder) { - cache_.Put(1, 100); - cache_.Put(2, 200); - cache_.Put(3, 300); - - // Access key 1 to update its usage order - EXPECT_EQ(cache_.Get(1), 100); - - // Add a new key, which should evict key 2 (least recently used) - cache_.Put(4, 400); - - EXPECT_EQ(cache_.Get(1), 100); - EXPECT_EQ(cache_.Get(2), 0); // Key 2 should be evicted - EXPECT_EQ(cache_.Get(3), 300); - EXPECT_EQ(cache_.Get(4), 400); - - EXPECT_EQ(cache_.GetCacheHits(), 4); - EXPECT_EQ(cache_.GetCacheMisses(), 1); -} - -TEST_F(LRUCacheTest, TestFlush) { - cache_.Put(1, 100); - cache_.Put(2, 200); - cache_.Flush(); - - EXPECT_EQ(cache_.Get(1), 0); - EXPECT_EQ(cache_.Get(2), 0); - EXPECT_EQ(cache_.GetCacheHits(), 0); - EXPECT_EQ(cache_.GetCacheMisses(), 2); -} - -} // namespace -} // namespace resdb +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#include "common/lru/lru_cache.h" + +#include + +namespace resdb { +namespace { + +class LRUCacheTest : public ::testing::Test { + protected: + LRUCache cache_{3}; +}; + +TEST_F(LRUCacheTest, TestPutAndGet) { + cache_.Put(1, 100); + EXPECT_EQ(cache_.Get(1), 100); + EXPECT_EQ(cache_.GetCacheHits(), 1); + EXPECT_EQ(cache_.GetCacheMisses(), 0); +} + +TEST_F(LRUCacheTest, TestUpdateValue) { + cache_.Put(1, 100); + cache_.Put(1, 200); + EXPECT_EQ(cache_.Get(1), 200); + EXPECT_EQ(cache_.GetCacheHits(), 1); + EXPECT_EQ(cache_.GetCacheMisses(), 0); +} + +TEST_F(LRUCacheTest, TestEviction) { + cache_.Put(1, 100); + cache_.Put(2, 200); + cache_.Put(3, 300); + cache_.Put(4, 400); // This should evict key 1 + + EXPECT_EQ(cache_.Get(1), 0); // Key 1 should be evicted + EXPECT_EQ(cache_.Get(2), 200); + EXPECT_EQ(cache_.Get(3), 300); + EXPECT_EQ(cache_.Get(4), 400); + + EXPECT_EQ(cache_.GetCacheHits(), 3); + EXPECT_EQ(cache_.GetCacheMisses(), 1); +} + +TEST_F(LRUCacheTest, TestUsageOrder) { + cache_.Put(1, 100); + cache_.Put(2, 200); + cache_.Put(3, 300); + + // Access key 1 to update its usage order + EXPECT_EQ(cache_.Get(1), 100); + + // Add a new key, which should evict key 2 (least recently used) + cache_.Put(4, 400); + + EXPECT_EQ(cache_.Get(1), 100); + EXPECT_EQ(cache_.Get(2), 0); // Key 2 should be evicted + EXPECT_EQ(cache_.Get(3), 300); + EXPECT_EQ(cache_.Get(4), 400); + + EXPECT_EQ(cache_.GetCacheHits(), 4); + EXPECT_EQ(cache_.GetCacheMisses(), 1); +} + +TEST_F(LRUCacheTest, TestFlush) { + cache_.Put(1, 100); + cache_.Put(2, 200); + cache_.Flush(); + + EXPECT_EQ(cache_.Get(1), 0); + EXPECT_EQ(cache_.Get(2), 0); + EXPECT_EQ(cache_.GetCacheHits(), 0); + EXPECT_EQ(cache_.GetCacheMisses(), 2); +} + +} // namespace +} // namespace resdb diff --git a/common/proto/BUILD b/common/proto/BUILD index 2122cef4b9..5145912eb3 100644 --- a/common/proto/BUILD +++ b/common/proto/BUILD @@ -1,38 +1,38 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -package(default_visibility = ["//visibility:public"]) - -load("@rules_cc//cc:defs.bzl", "cc_proto_library") -load("@rules_proto//proto:defs.bzl", "proto_library") -load("@rules_proto_grpc//python:defs.bzl", "python_proto_library") - -proto_library( - name = "signature_info_proto", - srcs = ["signature_info.proto"], -) - -cc_proto_library( - name = "signature_info_cc_proto", - deps = [":signature_info_proto"], -) - -python_proto_library( - name = "signature_info_py_proto", - protos = [":signature_info_proto"], -) +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +package(default_visibility = ["//visibility:public"]) + +load("@rules_cc//cc:defs.bzl", "cc_proto_library") +load("@rules_proto//proto:defs.bzl", "proto_library") +load("@rules_proto_grpc//python:defs.bzl", "python_proto_library") + +proto_library( + name = "signature_info_proto", + srcs = ["signature_info.proto"], +) + +cc_proto_library( + name = "signature_info_cc_proto", + deps = [":signature_info_proto"], +) + +python_proto_library( + name = "signature_info_py_proto", + protos = [":signature_info_proto"], +) diff --git a/common/proto/signature_info.proto b/common/proto/signature_info.proto index cc1cfc4255..4fb921d023 100644 --- a/common/proto/signature_info.proto +++ b/common/proto/signature_info.proto @@ -1,80 +1,80 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -syntax = "proto3"; - -package resdb; - -message SignatureInfo { - enum HashType{ - NONE = 0; - RSA = 1; - ED25519 = 2; - CMAC_AES = 3; - ECDSA = 4; - }; - - HashType hash_type = 1; - int64 node_id = 2; - bytes signature = 3; -}; - -message SecretKey { - bytes public_key = 1; - bytes private_key = 2; - SignatureInfo.HashType hash_type = 3; -}; - -message KeyInfo { - bytes key = 1; - SignatureInfo.HashType hash_type = 2; -} - -message CertificateKeyInfo { - enum Type { - REPLICA = 0; - CLIENT = 1; - } - KeyInfo key = 1; - int64 node_id = 2; - Type type = 3; - string ip = 4; - int32 port = 5; - // the ip:port the replica uses, if it is a client node, can be ignored. -} - -message CertificateKey { - CertificateKeyInfo public_key_info = 1; // the public key of current node. - SignatureInfo certificate = 2; // the certificate of `public_key_info`. -} - -// CertificateInfo is published from the adminisotr and will be written to a cert file. -message CertificateInfo { - KeyInfo admin_public_key = 1; // the public key owned by the administor. - CertificateKey public_key = 3; // public key info with certificate. - int64 node_id = 4; -}; - -// Used to construct SignatureVerifier. -message SignatureKeyInfo { - KeyInfo admin_public_key = 1; // the public key owned by the administor. - KeyInfo private_key = 2; // the private key from the user, used to sign messages. - int64 node_id = 3; // the unique id of the replica or client. -} - +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +syntax = "proto3"; + +package resdb; + +message SignatureInfo { + enum HashType{ + NONE = 0; + RSA = 1; + ED25519 = 2; + CMAC_AES = 3; + ECDSA = 4; + }; + + HashType hash_type = 1; + int64 node_id = 2; + bytes signature = 3; +}; + +message SecretKey { + bytes public_key = 1; + bytes private_key = 2; + SignatureInfo.HashType hash_type = 3; +}; + +message KeyInfo { + bytes key = 1; + SignatureInfo.HashType hash_type = 2; +} + +message CertificateKeyInfo { + enum Type { + REPLICA = 0; + CLIENT = 1; + } + KeyInfo key = 1; + int64 node_id = 2; + Type type = 3; + string ip = 4; + int32 port = 5; + // the ip:port the replica uses, if it is a client node, can be ignored. +} + +message CertificateKey { + CertificateKeyInfo public_key_info = 1; // the public key of current node. + SignatureInfo certificate = 2; // the certificate of `public_key_info`. +} + +// CertificateInfo is published from the adminisotr and will be written to a cert file. +message CertificateInfo { + KeyInfo admin_public_key = 1; // the public key owned by the administor. + CertificateKey public_key = 3; // public key info with certificate. + int64 node_id = 4; +}; + +// Used to construct SignatureVerifier. +message SignatureKeyInfo { + KeyInfo admin_public_key = 1; // the public key owned by the administor. + KeyInfo private_key = 2; // the private key from the user, used to sign messages. + int64 node_id = 3; // the unique id of the replica or client. +} + diff --git a/common/test/BUILD b/common/test/BUILD index e6bd3d6151..08e8595926 100644 --- a/common/test/BUILD +++ b/common/test/BUILD @@ -1,62 +1,62 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -package(default_visibility = ["//visibility:public"]) - -cc_library( - name = "test", - hdrs = [ - "test_macros.h", - ], - deps = [ - "//common:comm", - "@com_google_googletest//:gtest", - "@com_google_protobuf//:protobuf", - ], -) - -cc_library( - name = "test_main", - defines = ["TEST_MODE"], - deps = [ - ":test", - "@com_google_googletest//:gtest_main", - ], -) - -proto_library( - name = "test_proto", - srcs = ["test.proto"], - visibility = ["//visibility:private"], -) - -cc_proto_library( - name = "test_cc_proto", - visibility = ["//visibility:private"], - deps = [":test_proto"], -) - -cc_test( - name = "json_test", - srcs = ["json_test.cpp"], - deps = [ - ":test_cc_proto", - ":test_main", - ], -) +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +package(default_visibility = ["//visibility:public"]) + +cc_library( + name = "test", + hdrs = [ + "test_macros.h", + ], + deps = [ + "//common:comm", + "@com_google_googletest//:gtest", + "@com_google_protobuf//:protobuf", + ], +) + +cc_library( + name = "test_main", + defines = ["TEST_MODE"], + deps = [ + ":test", + "@com_google_googletest//:gtest_main", + ], +) + +proto_library( + name = "test_proto", + srcs = ["test.proto"], + visibility = ["//visibility:private"], +) + +cc_proto_library( + name = "test_cc_proto", + visibility = ["//visibility:private"], + deps = [":test_proto"], +) + +cc_test( + name = "json_test", + srcs = ["json_test.cpp"], + deps = [ + ":test_cc_proto", + ":test_main", + ], +) diff --git a/common/test/json_test.cpp b/common/test/json_test.cpp index 4fcaeed502..f48cda41d7 100644 --- a/common/test/json_test.cpp +++ b/common/test/json_test.cpp @@ -1,55 +1,55 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#include - -#include "common/test/test.pb.h" -#include "common/test/test_macros.h" - -namespace resdb { -namespace testing { -namespace { - -using ::resdb::testing::EqualsProto; - -TEST(SignatureVerifyTest, ParseFromJson) { - resdb::test::JsonMessage json_msg; - - json_msg.set_id(1); - json_msg.set_data("data"); - json_msg.mutable_sub_msg()->set_id(2); - json_msg.mutable_sub_msg()->set_data("sub_data"); - - std::string json = - "{ \ - \"id\": 1, \ - \"data\": \"data\", \ - \"sub_msg\":{ \ - \"id\": 2, \ - \"data\":\"sub_data\" \ - } \ - }"; - - EXPECT_THAT(ParseFromText(json), - EqualsProto(json_msg)); -} - -} // namespace -} // namespace testing -} // namespace resdb +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#include + +#include "common/test/test.pb.h" +#include "common/test/test_macros.h" + +namespace resdb { +namespace testing { +namespace { + +using ::resdb::testing::EqualsProto; + +TEST(SignatureVerifyTest, ParseFromJson) { + resdb::test::JsonMessage json_msg; + + json_msg.set_id(1); + json_msg.set_data("data"); + json_msg.mutable_sub_msg()->set_id(2); + json_msg.mutable_sub_msg()->set_data("sub_data"); + + std::string json = + "{ \ + \"id\": 1, \ + \"data\": \"data\", \ + \"sub_msg\":{ \ + \"id\": 2, \ + \"data\":\"sub_data\" \ + } \ + }"; + + EXPECT_THAT(ParseFromText(json), + EqualsProto(json_msg)); +} + +} // namespace +} // namespace testing +} // namespace resdb diff --git a/common/test/test.proto b/common/test/test.proto index 2e8320c004..85080ebae9 100644 --- a/common/test/test.proto +++ b/common/test/test.proto @@ -1,34 +1,34 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -syntax = "proto3"; - -package resdb.test; - -message JsonSubMessage { - int64 id = 1; - string data = 2; -}; - -message JsonMessage { - int64 id = 1; - string data = 2; - JsonMessage sub_msg = 3; -}; - +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +syntax = "proto3"; + +package resdb.test; + +message JsonSubMessage { + int64 id = 1; + string data = 2; +}; + +message JsonMessage { + int64 id = 1; + string data = 2; + JsonMessage sub_msg = 3; +}; + diff --git a/common/test/test_macros.h b/common/test/test_macros.h index 5e510f2a2b..75d8b75f20 100644 --- a/common/test/test_macros.h +++ b/common/test/test_macros.h @@ -1,47 +1,47 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#pragma once -#include -#include -#include - -#include "gmock/gmock.h" - -namespace resdb { -namespace testing { - -MATCHER_P(EqualsProto, replica, "") { - return ::google::protobuf::util::MessageDifferencer::Equals(arg, replica); -} - -template -T ParseFromText(const std::string& json_str) { - T message; - google::protobuf::util::JsonParseOptions options; - auto st = - google::protobuf::util::JsonStringToMessage(json_str, &message, options); - if (!st.ok()) { - LOG(ERROR) << st.message(); - } - return message; -} - -} // namespace testing -} // namespace resdb +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#pragma once +#include +#include +#include + +#include "gmock/gmock.h" + +namespace resdb { +namespace testing { + +MATCHER_P(EqualsProto, replica, "") { + return ::google::protobuf::util::MessageDifferencer::Equals(arg, replica); +} + +template +T ParseFromText(const std::string& json_str) { + T message; + google::protobuf::util::JsonParseOptions options; + auto st = + google::protobuf::util::JsonStringToMessage(json_str, &message, options); + if (!st.ok()) { + LOG(ERROR) << st.message(); + } + return message; +} + +} // namespace testing +} // namespace resdb diff --git a/common/utils/BUILD b/common/utils/BUILD index 44d5e69b3a..f48afb2060 100644 --- a/common/utils/BUILD +++ b/common/utils/BUILD @@ -1,25 +1,25 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -package(default_visibility = ["//visibility:public"]) - -cc_library( - name = "utils", - srcs = ["utils.cpp"], - hdrs = ["utils.h"], -) +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +package(default_visibility = ["//visibility:public"]) + +cc_library( + name = "utils", + srcs = ["utils.cpp"], + hdrs = ["utils.h"], +) diff --git a/common/utils/utils.cpp b/common/utils/utils.cpp index c512412046..5d5396c8fc 100644 --- a/common/utils/utils.cpp +++ b/common/utils/utils.cpp @@ -1,36 +1,36 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#include "common/utils/utils.h" - -#include -#include - -namespace resdb { - -#define CPU_FREQ 2.2 -#define TIME_ENABLE true - -uint64_t GetCurrentTime() { - struct timeval tv; - gettimeofday(&tv, nullptr); - return (uint64_t)(tv.tv_sec) * 1000000 + tv.tv_usec; -} - -} // namespace resdb +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#include "common/utils/utils.h" + +#include +#include + +namespace resdb { + +#define CPU_FREQ 2.2 +#define TIME_ENABLE true + +uint64_t GetCurrentTime() { + struct timeval tv; + gettimeofday(&tv, nullptr); + return (uint64_t)(tv.tv_sec) * 1000000 + tv.tv_usec; +} + +} // namespace resdb diff --git a/common/utils/utils.h b/common/utils/utils.h index 2a17286a8d..7284e67a3f 100644 --- a/common/utils/utils.h +++ b/common/utils/utils.h @@ -1,28 +1,28 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#pragma once - -#include - -namespace resdb { - -uint64_t GetCurrentTime(); - -} // namespace resdb +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#pragma once + +#include + +namespace resdb { + +uint64_t GetCurrentTime(); + +} // namespace resdb diff --git a/dev/.rat-excludes b/dev/.rat-excludes index 44cf521de0..67bdca048b 100644 --- a/dev/.rat-excludes +++ b/dev/.rat-excludes @@ -1,26 +1,26 @@ -.bazelrc -.bazelversion -.clang-format -.licenserc.yaml -repositories.bzl -.gitignore -.git -DISCLAIMER-WIP -CNAME -WORKSPACE -build -.*\.conf -.*\.config -.*\.pub -.*\.pri -Doxyfile -header -.*\.sol -ecosystem/.*\.rat-excludes -ecosystem/.*\.gitignore -ecosystem/.*\.bazelrc -ecosystem/.*\.gitattributes -ecosystem/.*\.npmrc -ecosystem/.*\.prettierrc -ecosystem/.*\.prettierignore -ecosystem/.*\.licenserc.yaml +.bazelrc +.bazelversion +.clang-format +.licenserc.yaml +repositories.bzl +.gitignore +.git +DISCLAIMER-WIP +CNAME +WORKSPACE +build +.*\.conf +.*\.config +.*\.pub +.*\.pri +Doxyfile +header +.*\.sol +ecosystem/.*\.rat-excludes +ecosystem/.*\.gitignore +ecosystem/.*\.bazelrc +ecosystem/.*\.gitattributes +ecosystem/.*\.npmrc +ecosystem/.*\.prettierrc +ecosystem/.*\.prettierignore +ecosystem/.*\.licenserc.yaml diff --git a/dev/check-license b/dev/check-license index e929e68bf9..752800943e 100755 --- a/dev/check-license +++ b/dev/check-license @@ -1,86 +1,86 @@ -#!/usr/bin/env bash - -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - - -acquire_rat_jar () { - - URL="https://repo.maven.apache.org/maven2/org/apache/rat/apache-rat/${RAT_VERSION}/apache-rat-${RAT_VERSION}.jar" - - JAR="$rat_jar" - - # Download rat launch jar if it hasn't been downloaded yet - if [ ! -f "$JAR" ]; then - # Download - printf "Attempting to fetch rat\n" - JAR_DL="${JAR}.part" - if [ $(command -v curl) ]; then - curl -L --silent "${URL}" > "$JAR_DL" && mv "$JAR_DL" "$JAR" - elif [ $(command -v wget) ]; then - wget --quiet ${URL} -O "$JAR_DL" && mv "$JAR_DL" "$JAR" - else - printf "You do not have curl or wget installed, please install rat manually.\n" - exit -1 - fi - fi - - unzip -tq "$JAR" &> /dev/null - if [ $? -ne 0 ]; then - # We failed to download - rm "$JAR" - printf "Our attempt to download rat locally to ${JAR} failed. Please install rat manually.\n" - exit -1 - fi -} - -# Go to the Spark project root directory -FWDIR="$(cd "`dirname "$0"`"/..; pwd)" -cd "$FWDIR" - -if test -x "$JAVA_HOME/bin/java"; then - declare java_cmd="$JAVA_HOME/bin/java" -else - declare java_cmd=java -fi - -export RAT_VERSION=0.16.1 -export rat_jar="$FWDIR"/lib/apache-rat-${RAT_VERSION}.jar -mkdir -p "$FWDIR"/lib - -[[ -f "$rat_jar" ]] || acquire_rat_jar || { - echo "Download failed. Obtain the rat jar manually and place it at $rat_jar" - exit 1 -} - -mkdir -p build -$java_cmd -jar "$rat_jar" --scan-hidden-directories -E "$FWDIR"/dev/.rat-excludes -d "$FWDIR" > build/rat-results.txt - -if [ $? -ne 0 ]; then - echo "RAT exited abnormally" - exit 1 -fi - -ERRORS="$(cat build/rat-results.txt | grep -e "??")" - -if test ! -z "$ERRORS"; then - echo "Could not find Apache license headers in the following files:" - echo "$ERRORS" - exit 1 -else - echo -e "RAT checks passed." -fi +#!/usr/bin/env bash + +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + + +acquire_rat_jar () { + + URL="https://repo.maven.apache.org/maven2/org/apache/rat/apache-rat/${RAT_VERSION}/apache-rat-${RAT_VERSION}.jar" + + JAR="$rat_jar" + + # Download rat launch jar if it hasn't been downloaded yet + if [ ! -f "$JAR" ]; then + # Download + printf "Attempting to fetch rat\n" + JAR_DL="${JAR}.part" + if [ $(command -v curl) ]; then + curl -L --silent "${URL}" > "$JAR_DL" && mv "$JAR_DL" "$JAR" + elif [ $(command -v wget) ]; then + wget --quiet ${URL} -O "$JAR_DL" && mv "$JAR_DL" "$JAR" + else + printf "You do not have curl or wget installed, please install rat manually.\n" + exit -1 + fi + fi + + unzip -tq "$JAR" &> /dev/null + if [ $? -ne 0 ]; then + # We failed to download + rm "$JAR" + printf "Our attempt to download rat locally to ${JAR} failed. Please install rat manually.\n" + exit -1 + fi +} + +# Go to the Spark project root directory +FWDIR="$(cd "`dirname "$0"`"/..; pwd)" +cd "$FWDIR" + +if test -x "$JAVA_HOME/bin/java"; then + declare java_cmd="$JAVA_HOME/bin/java" +else + declare java_cmd=java +fi + +export RAT_VERSION=0.16.1 +export rat_jar="$FWDIR"/lib/apache-rat-${RAT_VERSION}.jar +mkdir -p "$FWDIR"/lib + +[[ -f "$rat_jar" ]] || acquire_rat_jar || { + echo "Download failed. Obtain the rat jar manually and place it at $rat_jar" + exit 1 +} + +mkdir -p build +$java_cmd -jar "$rat_jar" --scan-hidden-directories -E "$FWDIR"/dev/.rat-excludes -d "$FWDIR" > build/rat-results.txt + +if [ $? -ne 0 ]; then + echo "RAT exited abnormally" + exit 1 +fi + +ERRORS="$(cat build/rat-results.txt | grep -e "??")" + +if test ! -z "$ERRORS"; then + echo "Could not find Apache license headers in the following files:" + echo "$ERRORS" + exit 1 +else + echo -e "RAT checks passed." +fi diff --git a/documents/doxygen/.gitignore b/documents/doxygen/.gitignore index 6789717874..fb1fc1eb04 100644 --- a/documents/doxygen/.gitignore +++ b/documents/doxygen/.gitignore @@ -1,2 +1,2 @@ -html/ -latex/ +html/ +latex/ diff --git a/documents/doxygen/Doxyfile b/documents/doxygen/Doxyfile index efc895d603..f94d118564 100644 --- a/documents/doxygen/Doxyfile +++ b/documents/doxygen/Doxyfile @@ -1,2799 +1,2799 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -# Doxyfile 1.9.6 - -# This file describes the settings to be used by the documentation system -# doxygen (www.doxygen.org) for a project. -# -# All text after a double hash (##) is considered a comment and is placed in -# front of the TAG it is preceding. -# -# All text after a single hash (#) is considered a comment and will be ignored. -# The format is: -# TAG = value [value, ...] -# For lists, items can also be appended using: -# TAG += value [value, ...] -# Values that contain spaces should be placed between quotes (\" \"). -# -# Note: -# -# Use doxygen to compare the used configuration file with the template -# configuration file: -# doxygen -x [configFile] -# Use doxygen to compare the used configuration file with the template -# configuration file without replacing the environment variables or CMake type -# replacement variables: -# doxygen -x_noenv [configFile] - -#--------------------------------------------------------------------------- -# Project related configuration options -#--------------------------------------------------------------------------- - -# This tag specifies the encoding used for all characters in the configuration -# file that follow. The default is UTF-8 which is also the encoding used for all -# text before the first occurrence of this tag. Doxygen uses libiconv (or the -# iconv built into libc) for the transcoding. See -# https://www.gnu.org/software/libiconv/ for the list of possible encodings. -# The default value is: UTF-8. - -DOXYFILE_ENCODING = UTF-8 - -# The PROJECT_NAME tag is a single word (or a sequence of words surrounded by -# double-quotes, unless you are using Doxywizard) that should identify the -# project for which the documentation is generated. This name is used in the -# title of most generated pages and in a few other places. -# The default value is: My Project. - -PROJECT_NAME = ResilientDB - -# The PROJECT_NUMBER tag can be used to enter a project or revision number. This -# could be handy for archiving the generated documentation or if some version -# control system is used. - -PROJECT_NUMBER = v1.3.1 - -# Using the PROJECT_BRIEF tag one can provide an optional one line description -# for a project that appears at the top of each page and should give viewer a -# quick idea about the purpose of the project. Keep the description short. - -PROJECT_BRIEF = ResilientDB - -# With the PROJECT_LOGO tag one can specify a logo or an icon that is included -# in the documentation. The maximum height of the logo should not exceed 55 -# pixels and the maximum width should not exceed 200 pixels. Doxygen will copy -# the logo to the output directory. - -PROJECT_LOGO = logo.png - -# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path -# into which the generated documentation will be written. If a relative path is -# entered, it will be relative to the location where doxygen was started. If -# left blank the current directory will be used. - -OUTPUT_DIRECTORY = - -# If the CREATE_SUBDIRS tag is set to YES then doxygen will create up to 4096 -# sub-directories (in 2 levels) under the output directory of each output format -# and will distribute the generated files over these directories. Enabling this -# option can be useful when feeding doxygen a huge amount of source files, where -# putting all generated files in the same directory would otherwise causes -# performance problems for the file system. Adapt CREATE_SUBDIRS_LEVEL to -# control the number of sub-directories. -# The default value is: NO. - -CREATE_SUBDIRS = YES - -# Controls the number of sub-directories that will be created when -# CREATE_SUBDIRS tag is set to YES. Level 0 represents 16 directories, and every -# level increment doubles the number of directories, resulting in 4096 -# directories at level 8 which is the default and also the maximum value. The -# sub-directories are organized in 2 levels, the first level always has a fixed -# number of 16 directories. -# Minimum value: 0, maximum value: 8, default value: 8. -# This tag requires that the tag CREATE_SUBDIRS is set to YES. - -CREATE_SUBDIRS_LEVEL = 8 - -# If the ALLOW_UNICODE_NAMES tag is set to YES, doxygen will allow non-ASCII -# characters to appear in the names of generated files. If set to NO, non-ASCII -# characters will be escaped, for example _xE3_x81_x84 will be used for Unicode -# U+3044. -# The default value is: NO. - -ALLOW_UNICODE_NAMES = NO - -# The OUTPUT_LANGUAGE tag is used to specify the language in which all -# documentation generated by doxygen is written. Doxygen will use this -# information to generate all constant output in the proper language. -# Possible values are: Afrikaans, Arabic, Armenian, Brazilian, Bulgarian, -# Catalan, Chinese, Chinese-Traditional, Croatian, Czech, Danish, Dutch, English -# (United States), Esperanto, Farsi (Persian), Finnish, French, German, Greek, -# Hindi, Hungarian, Indonesian, Italian, Japanese, Japanese-en (Japanese with -# English messages), Korean, Korean-en (Korean with English messages), Latvian, -# Lithuanian, Macedonian, Norwegian, Persian (Farsi), Polish, Portuguese, -# Romanian, Russian, Serbian, Serbian-Cyrillic, Slovak, Slovene, Spanish, -# Swedish, Turkish, Ukrainian and Vietnamese. -# The default value is: English. - -OUTPUT_LANGUAGE = English - -# If the BRIEF_MEMBER_DESC tag is set to YES, doxygen will include brief member -# descriptions after the members that are listed in the file and class -# documentation (similar to Javadoc). Set to NO to disable this. -# The default value is: YES. - -BRIEF_MEMBER_DESC = YES - -# If the REPEAT_BRIEF tag is set to YES, doxygen will prepend the brief -# description of a member or function before the detailed description -# -# Note: If both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the -# brief descriptions will be completely suppressed. -# The default value is: YES. - -REPEAT_BRIEF = YES - -# This tag implements a quasi-intelligent brief description abbreviator that is -# used to form the text in various listings. Each string in this list, if found -# as the leading text of the brief description, will be stripped from the text -# and the result, after processing the whole list, is used as the annotated -# text. Otherwise, the brief description is used as-is. If left blank, the -# following values are used ($name is automatically replaced with the name of -# the entity):The $name class, The $name widget, The $name file, is, provides, -# specifies, contains, represents, a, an and the. - -ABBREVIATE_BRIEF = "The $name class" \ - "The $name widget" \ - "The $name file" \ - is \ - provides \ - specifies \ - contains \ - represents \ - a \ - an \ - the - -# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then -# doxygen will generate a detailed section even if there is only a brief -# description. -# The default value is: NO. - -ALWAYS_DETAILED_SEC = NO - -# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all -# inherited members of a class in the documentation of that class as if those -# members were ordinary class members. Constructors, destructors and assignment -# operators of the base classes will not be shown. -# The default value is: NO. - -INLINE_INHERITED_MEMB = NO - -# If the FULL_PATH_NAMES tag is set to YES, doxygen will prepend the full path -# before files name in the file list and in the header files. If set to NO the -# shortest path that makes the file name unique will be used -# The default value is: YES. - -FULL_PATH_NAMES = YES - -# The STRIP_FROM_PATH tag can be used to strip a user-defined part of the path. -# Stripping is only done if one of the specified strings matches the left-hand -# part of the path. The tag can be used to show relative paths in the file list. -# If left blank the directory from which doxygen is run is used as the path to -# strip. -# -# Note that you can specify absolute paths here, but also relative paths, which -# will be relative from the directory where doxygen is started. -# This tag requires that the tag FULL_PATH_NAMES is set to YES. - -STRIP_FROM_PATH = - -# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of the -# path mentioned in the documentation of a class, which tells the reader which -# header file to include in order to use a class. If left blank only the name of -# the header file containing the class definition is used. Otherwise one should -# specify the list of include paths that are normally passed to the compiler -# using the -I flag. - -STRIP_FROM_INC_PATH = - -# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter (but -# less readable) file names. This can be useful is your file systems doesn't -# support long names like on DOS, Mac, or CD-ROM. -# The default value is: NO. - -SHORT_NAMES = NO - -# If the JAVADOC_AUTOBRIEF tag is set to YES then doxygen will interpret the -# first line (until the first dot) of a Javadoc-style comment as the brief -# description. If set to NO, the Javadoc-style will behave just like regular Qt- -# style comments (thus requiring an explicit @brief command for a brief -# description.) -# The default value is: NO. - -JAVADOC_AUTOBRIEF = YES - -# If the JAVADOC_BANNER tag is set to YES then doxygen will interpret a line -# such as -# /*************** -# as being the beginning of a Javadoc-style comment "banner". If set to NO, the -# Javadoc-style will behave just like regular comments and it will not be -# interpreted by doxygen. -# The default value is: NO. - -JAVADOC_BANNER = NO - -# If the QT_AUTOBRIEF tag is set to YES then doxygen will interpret the first -# line (until the first dot) of a Qt-style comment as the brief description. If -# set to NO, the Qt-style will behave just like regular Qt-style comments (thus -# requiring an explicit \brief command for a brief description.) -# The default value is: NO. - -QT_AUTOBRIEF = NO - -# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make doxygen treat a -# multi-line C++ special comment block (i.e. a block of //! or /// comments) as -# a brief description. This used to be the default behavior. The new default is -# to treat a multi-line C++ comment block as a detailed description. Set this -# tag to YES if you prefer the old behavior instead. -# -# Note that setting this tag to YES also means that rational rose comments are -# not recognized any more. -# The default value is: NO. - -MULTILINE_CPP_IS_BRIEF = NO - -# By default Python docstrings are displayed as preformatted text and doxygen's -# special commands cannot be used. By setting PYTHON_DOCSTRING to NO the -# doxygen's special commands can be used and the contents of the docstring -# documentation blocks is shown as doxygen documentation. -# The default value is: YES. - -PYTHON_DOCSTRING = YES - -# If the INHERIT_DOCS tag is set to YES then an undocumented member inherits the -# documentation from any documented member that it re-implements. -# The default value is: YES. - -INHERIT_DOCS = YES - -# If the SEPARATE_MEMBER_PAGES tag is set to YES then doxygen will produce a new -# page for each member. If set to NO, the documentation of a member will be part -# of the file/class/namespace that contains it. -# The default value is: NO. - -SEPARATE_MEMBER_PAGES = NO - -# The TAB_SIZE tag can be used to set the number of spaces in a tab. Doxygen -# uses this value to replace tabs by spaces in code fragments. -# Minimum value: 1, maximum value: 16, default value: 4. - -TAB_SIZE = 4 - -# This tag can be used to specify a number of aliases that act as commands in -# the documentation. An alias has the form: -# name=value -# For example adding -# "sideeffect=@par Side Effects:^^" -# will allow you to put the command \sideeffect (or @sideeffect) in the -# documentation, which will result in a user-defined paragraph with heading -# "Side Effects:". Note that you cannot put \n's in the value part of an alias -# to insert newlines (in the resulting output). You can put ^^ in the value part -# of an alias to insert a newline as if a physical newline was in the original -# file. When you need a literal { or } or , in the value part of an alias you -# have to escape them by means of a backslash (\), this can lead to conflicts -# with the commands \{ and \} for these it is advised to use the version @{ and -# @} or use a double escape (\\{ and \\}) - -ALIASES = - -# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources -# only. Doxygen will then generate output that is more tailored for C. For -# instance, some of the names that are used will be different. The list of all -# members will be omitted, etc. -# The default value is: NO. - -OPTIMIZE_OUTPUT_FOR_C = NO - -# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java or -# Python sources only. Doxygen will then generate output that is more tailored -# for that language. For instance, namespaces will be presented as packages, -# qualified scopes will look different, etc. -# The default value is: NO. - -OPTIMIZE_OUTPUT_JAVA = NO - -# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran -# sources. Doxygen will then generate output that is tailored for Fortran. -# The default value is: NO. - -OPTIMIZE_FOR_FORTRAN = NO - -# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL -# sources. Doxygen will then generate output that is tailored for VHDL. -# The default value is: NO. - -OPTIMIZE_OUTPUT_VHDL = NO - -# Set the OPTIMIZE_OUTPUT_SLICE tag to YES if your project consists of Slice -# sources only. Doxygen will then generate output that is more tailored for that -# language. For instance, namespaces will be presented as modules, types will be -# separated into more groups, etc. -# The default value is: NO. - -OPTIMIZE_OUTPUT_SLICE = NO - -# Doxygen selects the parser to use depending on the extension of the files it -# parses. With this tag you can assign which parser to use for a given -# extension. Doxygen has a built-in mapping, but you can override or extend it -# using this tag. The format is ext=language, where ext is a file extension, and -# language is one of the parsers supported by doxygen: IDL, Java, JavaScript, -# Csharp (C#), C, C++, Lex, D, PHP, md (Markdown), Objective-C, Python, Slice, -# VHDL, Fortran (fixed format Fortran: FortranFixed, free formatted Fortran: -# FortranFree, unknown formatted Fortran: Fortran. In the later case the parser -# tries to guess whether the code is fixed or free formatted code, this is the -# default for Fortran type files). For instance to make doxygen treat .inc files -# as Fortran files (default is PHP), and .f files as C (default is Fortran), -# use: inc=Fortran f=C. -# -# Note: For files without extension you can use no_extension as a placeholder. -# -# Note that for custom extensions you also need to set FILE_PATTERNS otherwise -# the files are not read by doxygen. When specifying no_extension you should add -# * to the FILE_PATTERNS. -# -# Note see also the list of default file extension mappings. - -EXTENSION_MAPPING = - -# If the MARKDOWN_SUPPORT tag is enabled then doxygen pre-processes all comments -# according to the Markdown format, which allows for more readable -# documentation. See https://daringfireball.net/projects/markdown/ for details. -# The output of markdown processing is further processed by doxygen, so you can -# mix doxygen, HTML, and XML commands with Markdown formatting. Disable only in -# case of backward compatibilities issues. -# The default value is: YES. - -MARKDOWN_SUPPORT = YES - -# When the TOC_INCLUDE_HEADINGS tag is set to a non-zero value, all headings up -# to that level are automatically included in the table of contents, even if -# they do not have an id attribute. -# Note: This feature currently applies only to Markdown headings. -# Minimum value: 0, maximum value: 99, default value: 5. -# This tag requires that the tag MARKDOWN_SUPPORT is set to YES. - -TOC_INCLUDE_HEADINGS = 5 - -# When enabled doxygen tries to link words that correspond to documented -# classes, or namespaces to their corresponding documentation. Such a link can -# be prevented in individual cases by putting a % sign in front of the word or -# globally by setting AUTOLINK_SUPPORT to NO. -# The default value is: YES. - -AUTOLINK_SUPPORT = YES - -# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want -# to include (a tag file for) the STL sources as input, then you should set this -# tag to YES in order to let doxygen match functions declarations and -# definitions whose arguments contain STL classes (e.g. func(std::string); -# versus func(std::string) {}). This also make the inheritance and collaboration -# diagrams that involve STL classes more complete and accurate. -# The default value is: NO. - -BUILTIN_STL_SUPPORT = NO - -# If you use Microsoft's C++/CLI language, you should set this option to YES to -# enable parsing support. -# The default value is: NO. - -CPP_CLI_SUPPORT = NO - -# Set the SIP_SUPPORT tag to YES if your project consists of sip (see: -# https://www.riverbankcomputing.com/software/sip/intro) sources only. Doxygen -# will parse them like normal C++ but will assume all classes use public instead -# of private inheritance when no explicit protection keyword is present. -# The default value is: NO. - -SIP_SUPPORT = NO - -# For Microsoft's IDL there are propget and propput attributes to indicate -# getter and setter methods for a property. Setting this option to YES will make -# doxygen to replace the get and set methods by a property in the documentation. -# This will only work if the methods are indeed getting or setting a simple -# type. If this is not the case, or you want to show the methods anyway, you -# should set this option to NO. -# The default value is: YES. - -IDL_PROPERTY_SUPPORT = YES - -# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC -# tag is set to YES then doxygen will reuse the documentation of the first -# member in the group (if any) for the other members of the group. By default -# all members of a group must be documented explicitly. -# The default value is: NO. - -DISTRIBUTE_GROUP_DOC = NO - -# If one adds a struct or class to a group and this option is enabled, then also -# any nested class or struct is added to the same group. By default this option -# is disabled and one has to add nested compounds explicitly via \ingroup. -# The default value is: NO. - -GROUP_NESTED_COMPOUNDS = NO - -# Set the SUBGROUPING tag to YES to allow class member groups of the same type -# (for instance a group of public functions) to be put as a subgroup of that -# type (e.g. under the Public Functions section). Set it to NO to prevent -# subgrouping. Alternatively, this can be done per class using the -# \nosubgrouping command. -# The default value is: YES. - -SUBGROUPING = YES - -# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and unions -# are shown inside the group in which they are included (e.g. using \ingroup) -# instead of on a separate page (for HTML and Man pages) or section (for LaTeX -# and RTF). -# -# Note that this feature does not work in combination with -# SEPARATE_MEMBER_PAGES. -# The default value is: NO. - -INLINE_GROUPED_CLASSES = NO - -# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and unions -# with only public data fields or simple typedef fields will be shown inline in -# the documentation of the scope in which they are defined (i.e. file, -# namespace, or group documentation), provided this scope is documented. If set -# to NO, structs, classes, and unions are shown on a separate page (for HTML and -# Man pages) or section (for LaTeX and RTF). -# The default value is: NO. - -INLINE_SIMPLE_STRUCTS = NO - -# When TYPEDEF_HIDES_STRUCT tag is enabled, a typedef of a struct, union, or -# enum is documented as struct, union, or enum with the name of the typedef. So -# typedef struct TypeS {} TypeT, will appear in the documentation as a struct -# with name TypeT. When disabled the typedef will appear as a member of a file, -# namespace, or class. And the struct will be named TypeS. This can typically be -# useful for C code in case the coding convention dictates that all compound -# types are typedef'ed and only the typedef is referenced, never the tag name. -# The default value is: NO. - -TYPEDEF_HIDES_STRUCT = NO - -# The size of the symbol lookup cache can be set using LOOKUP_CACHE_SIZE. This -# cache is used to resolve symbols given their name and scope. Since this can be -# an expensive process and often the same symbol appears multiple times in the -# code, doxygen keeps a cache of pre-resolved symbols. If the cache is too small -# doxygen will become slower. If the cache is too large, memory is wasted. The -# cache size is given by this formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range -# is 0..9, the default is 0, corresponding to a cache size of 2^16=65536 -# symbols. At the end of a run doxygen will report the cache usage and suggest -# the optimal cache size from a speed point of view. -# Minimum value: 0, maximum value: 9, default value: 0. - -LOOKUP_CACHE_SIZE = 0 - -# The NUM_PROC_THREADS specifies the number of threads doxygen is allowed to use -# during processing. When set to 0 doxygen will based this on the number of -# cores available in the system. You can set it explicitly to a value larger -# than 0 to get more control over the balance between CPU load and processing -# speed. At this moment only the input processing can be done using multiple -# threads. Since this is still an experimental feature the default is set to 1, -# which effectively disables parallel processing. Please report any issues you -# encounter. Generating dot graphs in parallel is controlled by the -# DOT_NUM_THREADS setting. -# Minimum value: 0, maximum value: 32, default value: 1. - -NUM_PROC_THREADS = 1 - -#--------------------------------------------------------------------------- -# Build related configuration options -#--------------------------------------------------------------------------- - -# If the EXTRACT_ALL tag is set to YES, doxygen will assume all entities in -# documentation are documented, even if no documentation was available. Private -# class members and static file members will be hidden unless the -# EXTRACT_PRIVATE respectively EXTRACT_STATIC tags are set to YES. -# Note: This will also disable the warnings about undocumented members that are -# normally produced when WARNINGS is set to YES. -# The default value is: NO. - -EXTRACT_ALL = YES - -# If the EXTRACT_PRIVATE tag is set to YES, all private members of a class will -# be included in the documentation. -# The default value is: NO. - -EXTRACT_PRIVATE = NO - -# If the EXTRACT_PRIV_VIRTUAL tag is set to YES, documented private virtual -# methods of a class will be included in the documentation. -# The default value is: NO. - -EXTRACT_PRIV_VIRTUAL = NO - -# If the EXTRACT_PACKAGE tag is set to YES, all members with package or internal -# scope will be included in the documentation. -# The default value is: NO. - -EXTRACT_PACKAGE = NO - -# If the EXTRACT_STATIC tag is set to YES, all static members of a file will be -# included in the documentation. -# The default value is: NO. - -EXTRACT_STATIC = NO - -# If the EXTRACT_LOCAL_CLASSES tag is set to YES, classes (and structs) defined -# locally in source files will be included in the documentation. If set to NO, -# only classes defined in header files are included. Does not have any effect -# for Java sources. -# The default value is: YES. - -EXTRACT_LOCAL_CLASSES = YES - -# This flag is only useful for Objective-C code. If set to YES, local methods, -# which are defined in the implementation section but not in the interface are -# included in the documentation. If set to NO, only methods in the interface are -# included. -# The default value is: NO. - -EXTRACT_LOCAL_METHODS = NO - -# If this flag is set to YES, the members of anonymous namespaces will be -# extracted and appear in the documentation as a namespace called -# 'anonymous_namespace{file}', where file will be replaced with the base name of -# the file that contains the anonymous namespace. By default anonymous namespace -# are hidden. -# The default value is: NO. - -EXTRACT_ANON_NSPACES = NO - -# If this flag is set to YES, the name of an unnamed parameter in a declaration -# will be determined by the corresponding definition. By default unnamed -# parameters remain unnamed in the output. -# The default value is: YES. - -RESOLVE_UNNAMED_PARAMS = YES - -# If the HIDE_UNDOC_MEMBERS tag is set to YES, doxygen will hide all -# undocumented members inside documented classes or files. If set to NO these -# members will be included in the various overviews, but no documentation -# section is generated. This option has no effect if EXTRACT_ALL is enabled. -# The default value is: NO. - -HIDE_UNDOC_MEMBERS = NO - -# If the HIDE_UNDOC_CLASSES tag is set to YES, doxygen will hide all -# undocumented classes that are normally visible in the class hierarchy. If set -# to NO, these classes will be included in the various overviews. This option -# will also hide undocumented C++ concepts if enabled. This option has no effect -# if EXTRACT_ALL is enabled. -# The default value is: NO. - -HIDE_UNDOC_CLASSES = NO - -# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, doxygen will hide all friend -# declarations. If set to NO, these declarations will be included in the -# documentation. -# The default value is: NO. - -HIDE_FRIEND_COMPOUNDS = NO - -# If the HIDE_IN_BODY_DOCS tag is set to YES, doxygen will hide any -# documentation blocks found inside the body of a function. If set to NO, these -# blocks will be appended to the function's detailed documentation block. -# The default value is: NO. - -HIDE_IN_BODY_DOCS = NO - -# The INTERNAL_DOCS tag determines if documentation that is typed after a -# \internal command is included. If the tag is set to NO then the documentation -# will be excluded. Set it to YES to include the internal documentation. -# The default value is: NO. - -INTERNAL_DOCS = NO - -# With the correct setting of option CASE_SENSE_NAMES doxygen will better be -# able to match the capabilities of the underlying filesystem. In case the -# filesystem is case sensitive (i.e. it supports files in the same directory -# whose names only differ in casing), the option must be set to YES to properly -# deal with such files in case they appear in the input. For filesystems that -# are not case sensitive the option should be set to NO to properly deal with -# output files written for symbols that only differ in casing, such as for two -# classes, one named CLASS and the other named Class, and to also support -# references to files without having to specify the exact matching casing. On -# Windows (including Cygwin) and MacOS, users should typically set this option -# to NO, whereas on Linux or other Unix flavors it should typically be set to -# YES. -# Possible values are: SYSTEM, NO and YES. -# The default value is: SYSTEM. - -CASE_SENSE_NAMES = SYSTEM - -# If the HIDE_SCOPE_NAMES tag is set to NO then doxygen will show members with -# their full class and namespace scopes in the documentation. If set to YES, the -# scope will be hidden. -# The default value is: NO. - -HIDE_SCOPE_NAMES = NO - -# If the HIDE_COMPOUND_REFERENCE tag is set to NO (default) then doxygen will -# append additional text to a page's title, such as Class Reference. If set to -# YES the compound reference will be hidden. -# The default value is: NO. - -HIDE_COMPOUND_REFERENCE= NO - -# If the SHOW_HEADERFILE tag is set to YES then the documentation for a class -# will show which file needs to be included to use the class. -# The default value is: YES. - -SHOW_HEADERFILE = YES - -# If the SHOW_INCLUDE_FILES tag is set to YES then doxygen will put a list of -# the files that are included by a file in the documentation of that file. -# The default value is: YES. - -SHOW_INCLUDE_FILES = YES - -# If the SHOW_GROUPED_MEMB_INC tag is set to YES then Doxygen will add for each -# grouped member an include statement to the documentation, telling the reader -# which file to include in order to use the member. -# The default value is: NO. - -SHOW_GROUPED_MEMB_INC = NO - -# If the FORCE_LOCAL_INCLUDES tag is set to YES then doxygen will list include -# files with double quotes in the documentation rather than with sharp brackets. -# The default value is: NO. - -FORCE_LOCAL_INCLUDES = NO - -# If the INLINE_INFO tag is set to YES then a tag [inline] is inserted in the -# documentation for inline members. -# The default value is: YES. - -INLINE_INFO = YES - -# If the SORT_MEMBER_DOCS tag is set to YES then doxygen will sort the -# (detailed) documentation of file and class members alphabetically by member -# name. If set to NO, the members will appear in declaration order. -# The default value is: YES. - -SORT_MEMBER_DOCS = YES - -# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the brief -# descriptions of file, namespace and class members alphabetically by member -# name. If set to NO, the members will appear in declaration order. Note that -# this will also influence the order of the classes in the class list. -# The default value is: NO. - -SORT_BRIEF_DOCS = NO - -# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen will sort the -# (brief and detailed) documentation of class members so that constructors and -# destructors are listed first. If set to NO the constructors will appear in the -# respective orders defined by SORT_BRIEF_DOCS and SORT_MEMBER_DOCS. -# Note: If SORT_BRIEF_DOCS is set to NO this option is ignored for sorting brief -# member documentation. -# Note: If SORT_MEMBER_DOCS is set to NO this option is ignored for sorting -# detailed member documentation. -# The default value is: NO. - -SORT_MEMBERS_CTORS_1ST = NO - -# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the hierarchy -# of group names into alphabetical order. If set to NO the group names will -# appear in their defined order. -# The default value is: NO. - -SORT_GROUP_NAMES = NO - -# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be sorted by -# fully-qualified names, including namespaces. If set to NO, the class list will -# be sorted only by class name, not including the namespace part. -# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. -# Note: This option applies only to the class list, not to the alphabetical -# list. -# The default value is: NO. - -SORT_BY_SCOPE_NAME = NO - -# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to do proper -# type resolution of all parameters of a function it will reject a match between -# the prototype and the implementation of a member function even if there is -# only one candidate or it is obvious which candidate to choose by doing a -# simple string match. By disabling STRICT_PROTO_MATCHING doxygen will still -# accept a match between prototype and implementation in such cases. -# The default value is: NO. - -STRICT_PROTO_MATCHING = NO - -# The GENERATE_TODOLIST tag can be used to enable (YES) or disable (NO) the todo -# list. This list is created by putting \todo commands in the documentation. -# The default value is: YES. - -GENERATE_TODOLIST = YES - -# The GENERATE_TESTLIST tag can be used to enable (YES) or disable (NO) the test -# list. This list is created by putting \test commands in the documentation. -# The default value is: YES. - -GENERATE_TESTLIST = YES - -# The GENERATE_BUGLIST tag can be used to enable (YES) or disable (NO) the bug -# list. This list is created by putting \bug commands in the documentation. -# The default value is: YES. - -GENERATE_BUGLIST = YES - -# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or disable (NO) -# the deprecated list. This list is created by putting \deprecated commands in -# the documentation. -# The default value is: YES. - -GENERATE_DEPRECATEDLIST= YES - -# The ENABLED_SECTIONS tag can be used to enable conditional documentation -# sections, marked by \if ... \endif and \cond -# ... \endcond blocks. - -ENABLED_SECTIONS = - -# The MAX_INITIALIZER_LINES tag determines the maximum number of lines that the -# initial value of a variable or macro / define can have for it to appear in the -# documentation. If the initializer consists of more lines than specified here -# it will be hidden. Use a value of 0 to hide initializers completely. The -# appearance of the value of individual variables and macros / defines can be -# controlled using \showinitializer or \hideinitializer command in the -# documentation regardless of this setting. -# Minimum value: 0, maximum value: 10000, default value: 30. - -MAX_INITIALIZER_LINES = 30 - -# Set the SHOW_USED_FILES tag to NO to disable the list of files generated at -# the bottom of the documentation of classes and structs. If set to YES, the -# list will mention the files that were used to generate the documentation. -# The default value is: YES. - -SHOW_USED_FILES = NO - -# Set the SHOW_FILES tag to NO to disable the generation of the Files page. This -# will remove the Files entry from the Quick Index and from the Folder Tree View -# (if specified). -# The default value is: YES. - -SHOW_FILES = YES - -# Set the SHOW_NAMESPACES tag to NO to disable the generation of the Namespaces -# page. This will remove the Namespaces entry from the Quick Index and from the -# Folder Tree View (if specified). -# The default value is: YES. - -SHOW_NAMESPACES = YES - -# The FILE_VERSION_FILTER tag can be used to specify a program or script that -# doxygen should invoke to get the current version for each file (typically from -# the version control system). Doxygen will invoke the program by executing (via -# popen()) the command command input-file, where command is the value of the -# FILE_VERSION_FILTER tag, and input-file is the name of an input file provided -# by doxygen. Whatever the program writes to standard output is used as the file -# version. For an example see the documentation. - -FILE_VERSION_FILTER = - -# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed -# by doxygen. The layout file controls the global structure of the generated -# output files in an output format independent way. To create the layout file -# that represents doxygen's defaults, run doxygen with the -l option. You can -# optionally specify a file name after the option, if omitted DoxygenLayout.xml -# will be used as the name of the layout file. See also section "Changing the -# layout of pages" for information. -# -# Note that if you run doxygen from a directory containing a file called -# DoxygenLayout.xml, doxygen will parse it automatically even if the LAYOUT_FILE -# tag is left empty. - -LAYOUT_FILE = DoxygenLayout.xml - -# The CITE_BIB_FILES tag can be used to specify one or more bib files containing -# the reference definitions. This must be a list of .bib files. The .bib -# extension is automatically appended if omitted. This requires the bibtex tool -# to be installed. See also https://en.wikipedia.org/wiki/BibTeX for more info. -# For LaTeX the style of the bibliography can be controlled using -# LATEX_BIB_STYLE. To use this feature you need bibtex and perl available in the -# search path. See also \cite for info how to create references. - -CITE_BIB_FILES = - -#--------------------------------------------------------------------------- -# Configuration options related to warning and progress messages -#--------------------------------------------------------------------------- - -# The QUIET tag can be used to turn on/off the messages that are generated to -# standard output by doxygen. If QUIET is set to YES this implies that the -# messages are off. -# The default value is: NO. - -QUIET = NO - -# The WARNINGS tag can be used to turn on/off the warning messages that are -# generated to standard error (stderr) by doxygen. If WARNINGS is set to YES -# this implies that the warnings are on. -# -# Tip: Turn warnings on while writing the documentation. -# The default value is: YES. - -WARNINGS = YES - -# If the WARN_IF_UNDOCUMENTED tag is set to YES then doxygen will generate -# warnings for undocumented members. If EXTRACT_ALL is set to YES then this flag -# will automatically be disabled. -# The default value is: YES. - -WARN_IF_UNDOCUMENTED = YES - -# If the WARN_IF_DOC_ERROR tag is set to YES, doxygen will generate warnings for -# potential errors in the documentation, such as documenting some parameters in -# a documented function twice, or documenting parameters that don't exist or -# using markup commands wrongly. -# The default value is: YES. - -WARN_IF_DOC_ERROR = YES - -# If WARN_IF_INCOMPLETE_DOC is set to YES, doxygen will warn about incomplete -# function parameter documentation. If set to NO, doxygen will accept that some -# parameters have no documentation without warning. -# The default value is: YES. - -WARN_IF_INCOMPLETE_DOC = YES - -# This WARN_NO_PARAMDOC option can be enabled to get warnings for functions that -# are documented, but have no documentation for their parameters or return -# value. If set to NO, doxygen will only warn about wrong parameter -# documentation, but not about the absence of documentation. If EXTRACT_ALL is -# set to YES then this flag will automatically be disabled. See also -# WARN_IF_INCOMPLETE_DOC -# The default value is: NO. - -WARN_NO_PARAMDOC = NO - -# If WARN_IF_UNDOC_ENUM_VAL option is set to YES, doxygen will warn about -# undocumented enumeration values. If set to NO, doxygen will accept -# undocumented enumeration values. If EXTRACT_ALL is set to YES then this flag -# will automatically be disabled. -# The default value is: NO. - -WARN_IF_UNDOC_ENUM_VAL = NO - -# If the WARN_AS_ERROR tag is set to YES then doxygen will immediately stop when -# a warning is encountered. If the WARN_AS_ERROR tag is set to FAIL_ON_WARNINGS -# then doxygen will continue running as if WARN_AS_ERROR tag is set to NO, but -# at the end of the doxygen process doxygen will return with a non-zero status. -# Possible values are: NO, YES and FAIL_ON_WARNINGS. -# The default value is: NO. - -WARN_AS_ERROR = NO - -# The WARN_FORMAT tag determines the format of the warning messages that doxygen -# can produce. The string should contain the $file, $line, and $text tags, which -# will be replaced by the file and line number from which the warning originated -# and the warning text. Optionally the format may contain $version, which will -# be replaced by the version of the file (if it could be obtained via -# FILE_VERSION_FILTER) -# See also: WARN_LINE_FORMAT -# The default value is: $file:$line: $text. - -WARN_FORMAT = "$file:$line: $text" - -# In the $text part of the WARN_FORMAT command it is possible that a reference -# to a more specific place is given. To make it easier to jump to this place -# (outside of doxygen) the user can define a custom "cut" / "paste" string. -# Example: -# WARN_LINE_FORMAT = "'vi $file +$line'" -# See also: WARN_FORMAT -# The default value is: at line $line of file $file. - -WARN_LINE_FORMAT = "at line $line of file $file" - -# The WARN_LOGFILE tag can be used to specify a file to which warning and error -# messages should be written. If left blank the output is written to standard -# error (stderr). In case the file specified cannot be opened for writing the -# warning and error messages are written to standard error. When as file - is -# specified the warning and error messages are written to standard output -# (stdout). - -WARN_LOGFILE = - -#--------------------------------------------------------------------------- -# Configuration options related to the input files -#--------------------------------------------------------------------------- - -# The INPUT tag is used to specify the files and/or directories that contain -# documented source files. You may enter file names like myfile.cpp or -# directories like /usr/src/myproject. Separate the files or directories with -# spaces. See also FILE_PATTERNS and EXTENSION_MAPPING -# Note: If this tag is empty the current directory is searched. - -INPUT = ../../ - -# This tag can be used to specify the character encoding of the source files -# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses -# libiconv (or the iconv built into libc) for the transcoding. See the libiconv -# documentation (see: -# https://www.gnu.org/software/libiconv/) for the list of possible encodings. -# See also: INPUT_FILE_ENCODING -# The default value is: UTF-8. - -INPUT_ENCODING = UTF-8 - -# This tag can be used to specify the character encoding of the source files -# that doxygen parses The INPUT_FILE_ENCODING tag can be used to specify -# character encoding on a per file pattern basis. Doxygen will compare the file -# name with each pattern and apply the encoding instead of the default -# INPUT_ENCODING) if there is a match. The character encodings are a list of the -# form: pattern=encoding (like *.php=ISO-8859-1). See cfg_input_encoding -# "INPUT_ENCODING" for further information on supported encodings. - -INPUT_FILE_ENCODING = - -# If the value of the INPUT tag contains directories, you can use the -# FILE_PATTERNS tag to specify one or more wildcard patterns (like *.cpp and -# *.h) to filter out the source-files in the directories. -# -# Note that for custom extensions or not directly supported extensions you also -# need to set EXTENSION_MAPPING for the extension otherwise the files are not -# read by doxygen. -# -# Note the list of default checked file patterns might differ from the list of -# default file extension mappings. -# -# If left blank the following patterns are tested:*.c, *.cc, *.cxx, *.cpp, -# *.c++, *.java, *.ii, *.ixx, *.ipp, *.i++, *.inl, *.idl, *.ddl, *.odl, *.h, -# *.hh, *.hxx, *.hpp, *.h++, *.l, *.cs, *.d, *.php, *.php4, *.php5, *.phtml, -# *.inc, *.m, *.markdown, *.md, *.mm, *.dox (to be provided as doxygen C -# comment), *.py, *.pyw, *.f90, *.f95, *.f03, *.f08, *.f18, *.f, *.for, *.vhd, -# *.vhdl, *.ucf, *.qsf and *.ice. - -FILE_PATTERNS = *.c \ - *.cc \ - *.cxx \ - *.cpp \ - *.c++ \ - *.java \ - *.ii \ - *.ixx \ - *.ipp \ - *.i++ \ - *.inl \ - *.idl \ - *.ddl \ - *.odl \ - *.h \ - *.hh \ - *.hxx \ - *.hpp \ - *.h++ \ - *.l \ - *.cs \ - *.d \ - *.php \ - *.php4 \ - *.php5 \ - *.phtml \ - *.inc \ - *.m \ - *.markdown \ - *.md \ - *.mm \ - *.dox \ - *.py \ - *.pyw \ - *.f90 \ - *.f95 \ - *.f03 \ - *.f08 \ - *.f18 \ - *.f \ - *.for \ - *.vhd \ - *.vhdl \ - *.ucf \ - *.qsf \ - *.ice - -# The RECURSIVE tag can be used to specify whether or not subdirectories should -# be searched for input files as well. -# The default value is: NO. - -RECURSIVE = YES - -# The EXCLUDE tag can be used to specify files and/or directories that should be -# excluded from the INPUT source files. This way you can easily exclude a -# subdirectory from a directory tree whose root is specified with the INPUT tag. -# -# Note that relative paths are relative to the directory from which doxygen is -# run. - -EXCLUDE = - -# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or -# directories that are symbolic links (a Unix file system feature) are excluded -# from the input. -# The default value is: NO. - -EXCLUDE_SYMLINKS = NO - -# If the value of the INPUT tag contains directories, you can use the -# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude -# certain files from those directories. -# -# Note that the wildcards are matched against the file with absolute path, so to -# exclude all test directories for example use the pattern */test/* - -EXCLUDE_PATTERNS = - -# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names -# (namespaces, classes, functions, etc.) that should be excluded from the -# output. The symbol name can be a fully qualified name, a word, or if the -# wildcard * is used, a substring. Examples: ANamespace, AClass, -# ANamespace::AClass, ANamespace::*Test -# -# Note that the wildcards are matched against the file with absolute path, so to -# exclude all test directories use the pattern */test/* - -EXCLUDE_SYMBOLS = - -# The EXAMPLE_PATH tag can be used to specify one or more files or directories -# that contain example code fragments that are included (see the \include -# command). - -EXAMPLE_PATH = - -# If the value of the EXAMPLE_PATH tag contains directories, you can use the -# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp and -# *.h) to filter out the source-files in the directories. If left blank all -# files are included. - -EXAMPLE_PATTERNS = * - -# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be -# searched for input files to be used with the \include or \dontinclude commands -# irrespective of the value of the RECURSIVE tag. -# The default value is: NO. - -EXAMPLE_RECURSIVE = NO - -# The IMAGE_PATH tag can be used to specify one or more files or directories -# that contain images that are to be included in the documentation (see the -# \image command). - -IMAGE_PATH = - -# The INPUT_FILTER tag can be used to specify a program that doxygen should -# invoke to filter for each input file. Doxygen will invoke the filter program -# by executing (via popen()) the command: -# -# -# -# where is the value of the INPUT_FILTER tag, and is the -# name of an input file. Doxygen will then use the output that the filter -# program writes to standard output. If FILTER_PATTERNS is specified, this tag -# will be ignored. -# -# Note that the filter must not add or remove lines; it is applied before the -# code is scanned, but not when the output code is generated. If lines are added -# or removed, the anchors will not be placed correctly. -# -# Note that doxygen will use the data processed and written to standard output -# for further processing, therefore nothing else, like debug statements or used -# commands (so in case of a Windows batch file always use @echo OFF), should be -# written to standard output. -# -# Note that for custom extensions or not directly supported extensions you also -# need to set EXTENSION_MAPPING for the extension otherwise the files are not -# properly processed by doxygen. - -INPUT_FILTER = - -# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern -# basis. Doxygen will compare the file name with each pattern and apply the -# filter if there is a match. The filters are a list of the form: pattern=filter -# (like *.cpp=my_cpp_filter). See INPUT_FILTER for further information on how -# filters are used. If the FILTER_PATTERNS tag is empty or if none of the -# patterns match the file name, INPUT_FILTER is applied. -# -# Note that for custom extensions or not directly supported extensions you also -# need to set EXTENSION_MAPPING for the extension otherwise the files are not -# properly processed by doxygen. - -FILTER_PATTERNS = - -# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using -# INPUT_FILTER) will also be used to filter the input files that are used for -# producing the source files to browse (i.e. when SOURCE_BROWSER is set to YES). -# The default value is: NO. - -FILTER_SOURCE_FILES = NO - -# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file -# pattern. A pattern will override the setting for FILTER_PATTERN (if any) and -# it is also possible to disable source filtering for a specific pattern using -# *.ext= (so without naming a filter). -# This tag requires that the tag FILTER_SOURCE_FILES is set to YES. - -FILTER_SOURCE_PATTERNS = - -# If the USE_MDFILE_AS_MAINPAGE tag refers to the name of a markdown file that -# is part of the input, its contents will be placed on the main page -# (index.html). This can be useful if you have a project on for instance GitHub -# and want to reuse the introduction page also for the doxygen output. - -USE_MDFILE_AS_MAINPAGE = - -# The Fortran standard specifies that for fixed formatted Fortran code all -# characters from position 72 are to be considered as comment. A common -# extension is to allow longer lines before the automatic comment starts. The -# setting FORTRAN_COMMENT_AFTER will also make it possible that longer lines can -# be processed before the automatic comment starts. -# Minimum value: 7, maximum value: 10000, default value: 72. - -FORTRAN_COMMENT_AFTER = 72 - -#--------------------------------------------------------------------------- -# Configuration options related to source browsing -#--------------------------------------------------------------------------- - -# If the SOURCE_BROWSER tag is set to YES then a list of source files will be -# generated. Documented entities will be cross-referenced with these sources. -# -# Note: To get rid of all source code in the generated output, make sure that -# also VERBATIM_HEADERS is set to NO. -# The default value is: NO. - -SOURCE_BROWSER = YES - -# Setting the INLINE_SOURCES tag to YES will include the body of functions, -# classes and enums directly into the documentation. -# The default value is: NO. - -INLINE_SOURCES = NO - -# Setting the STRIP_CODE_COMMENTS tag to YES will instruct doxygen to hide any -# special comment blocks from generated source code fragments. Normal C, C++ and -# Fortran comments will always remain visible. -# The default value is: YES. - -STRIP_CODE_COMMENTS = YES - -# If the REFERENCED_BY_RELATION tag is set to YES then for each documented -# entity all documented functions referencing it will be listed. -# The default value is: NO. - -REFERENCED_BY_RELATION = NO - -# If the REFERENCES_RELATION tag is set to YES then for each documented function -# all documented entities called/used by that function will be listed. -# The default value is: NO. - -REFERENCES_RELATION = NO - -# If the REFERENCES_LINK_SOURCE tag is set to YES and SOURCE_BROWSER tag is set -# to YES then the hyperlinks from functions in REFERENCES_RELATION and -# REFERENCED_BY_RELATION lists will link to the source code. Otherwise they will -# link to the documentation. -# The default value is: YES. - -REFERENCES_LINK_SOURCE = YES - -# If SOURCE_TOOLTIPS is enabled (the default) then hovering a hyperlink in the -# source code will show a tooltip with additional information such as prototype, -# brief description and links to the definition and documentation. Since this -# will make the HTML file larger and loading of large files a bit slower, you -# can opt to disable this feature. -# The default value is: YES. -# This tag requires that the tag SOURCE_BROWSER is set to YES. - -SOURCE_TOOLTIPS = YES - -# If the USE_HTAGS tag is set to YES then the references to source code will -# point to the HTML generated by the htags(1) tool instead of doxygen built-in -# source browser. The htags tool is part of GNU's global source tagging system -# (see https://www.gnu.org/software/global/global.html). You will need version -# 4.8.6 or higher. -# -# To use it do the following: -# - Install the latest version of global -# - Enable SOURCE_BROWSER and USE_HTAGS in the configuration file -# - Make sure the INPUT points to the root of the source tree -# - Run doxygen as normal -# -# Doxygen will invoke htags (and that will in turn invoke gtags), so these -# tools must be available from the command line (i.e. in the search path). -# -# The result: instead of the source browser generated by doxygen, the links to -# source code will now point to the output of htags. -# The default value is: NO. -# This tag requires that the tag SOURCE_BROWSER is set to YES. - -USE_HTAGS = NO - -# If the VERBATIM_HEADERS tag is set the YES then doxygen will generate a -# verbatim copy of the header file for each class for which an include is -# specified. Set to NO to disable this. -# See also: Section \class. -# The default value is: YES. - -VERBATIM_HEADERS = YES - -# If the CLANG_ASSISTED_PARSING tag is set to YES then doxygen will use the -# clang parser (see: -# http://clang.llvm.org/) for more accurate parsing at the cost of reduced -# performance. This can be particularly helpful with template rich C++ code for -# which doxygen's built-in parser lacks the necessary type information. -# Note: The availability of this option depends on whether or not doxygen was -# generated with the -Duse_libclang=ON option for CMake. -# The default value is: NO. - -CLANG_ASSISTED_PARSING = NO - -# If the CLANG_ASSISTED_PARSING tag is set to YES and the CLANG_ADD_INC_PATHS -# tag is set to YES then doxygen will add the directory of each input to the -# include path. -# The default value is: YES. -# This tag requires that the tag CLANG_ASSISTED_PARSING is set to YES. - -CLANG_ADD_INC_PATHS = YES - -# If clang assisted parsing is enabled you can provide the compiler with command -# line options that you would normally use when invoking the compiler. Note that -# the include paths will already be set by doxygen for the files and directories -# specified with INPUT and INCLUDE_PATH. -# This tag requires that the tag CLANG_ASSISTED_PARSING is set to YES. - -CLANG_OPTIONS = - -# If clang assisted parsing is enabled you can provide the clang parser with the -# path to the directory containing a file called compile_commands.json. This -# file is the compilation database (see: -# http://clang.llvm.org/docs/HowToSetupToolingForLLVM.html) containing the -# options used when the source files were built. This is equivalent to -# specifying the -p option to a clang tool, such as clang-check. These options -# will then be passed to the parser. Any options specified with CLANG_OPTIONS -# will be added as well. -# Note: The availability of this option depends on whether or not doxygen was -# generated with the -Duse_libclang=ON option for CMake. - -CLANG_DATABASE_PATH = - -#--------------------------------------------------------------------------- -# Configuration options related to the alphabetical class index -#--------------------------------------------------------------------------- - -# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index of all -# compounds will be generated. Enable this if the project contains a lot of -# classes, structs, unions or interfaces. -# The default value is: YES. - -ALPHABETICAL_INDEX = YES - -# The IGNORE_PREFIX tag can be used to specify a prefix (or a list of prefixes) -# that should be ignored while generating the index headers. The IGNORE_PREFIX -# tag works for classes, function and member names. The entity will be placed in -# the alphabetical list under the first letter of the entity name that remains -# after removing the prefix. -# This tag requires that the tag ALPHABETICAL_INDEX is set to YES. - -IGNORE_PREFIX = - -#--------------------------------------------------------------------------- -# Configuration options related to the HTML output -#--------------------------------------------------------------------------- - -# If the GENERATE_HTML tag is set to YES, doxygen will generate HTML output -# The default value is: YES. - -GENERATE_HTML = YES - -# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. If a -# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of -# it. -# The default directory is: html. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_OUTPUT = html - -# The HTML_FILE_EXTENSION tag can be used to specify the file extension for each -# generated HTML page (for example: .htm, .php, .asp). -# The default value is: .html. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_FILE_EXTENSION = .html - -# The HTML_HEADER tag can be used to specify a user-defined HTML header file for -# each generated HTML page. If the tag is left blank doxygen will generate a -# standard header. -# -# To get valid HTML the header file that includes any scripts and style sheets -# that doxygen needs, which is dependent on the configuration options used (e.g. -# the setting GENERATE_TREEVIEW). It is highly recommended to start with a -# default header using -# doxygen -w html new_header.html new_footer.html new_stylesheet.css -# YourConfigFile -# and then modify the file new_header.html. See also section "Doxygen usage" -# for information on how to generate the default header that doxygen normally -# uses. -# Note: The header is subject to change so you typically have to regenerate the -# default header when upgrading to a newer version of doxygen. For a description -# of the possible markers and block names see the documentation. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_HEADER = header - -# The HTML_FOOTER tag can be used to specify a user-defined HTML footer for each -# generated HTML page. If the tag is left blank doxygen will generate a standard -# footer. See HTML_HEADER for more information on how to generate a default -# footer and what special commands can be used inside the footer. See also -# section "Doxygen usage" for information on how to generate the default footer -# that doxygen normally uses. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_FOOTER = - -# The HTML_STYLESHEET tag can be used to specify a user-defined cascading style -# sheet that is used by each HTML page. It can be used to fine-tune the look of -# the HTML output. If left blank doxygen will generate a default style sheet. -# See also section "Doxygen usage" for information on how to generate the style -# sheet that doxygen normally uses. -# Note: It is recommended to use HTML_EXTRA_STYLESHEET instead of this tag, as -# it is more robust and this tag (HTML_STYLESHEET) will in the future become -# obsolete. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_STYLESHEET = - -# The HTML_EXTRA_STYLESHEET tag can be used to specify additional user-defined -# cascading style sheets that are included after the standard style sheets -# created by doxygen. Using this option one can overrule certain style aspects. -# This is preferred over using HTML_STYLESHEET since it does not replace the -# standard style sheet and is therefore more robust against future updates. -# Doxygen will copy the style sheet files to the output directory. -# Note: The order of the extra style sheet files is of importance (e.g. the last -# style sheet in the list overrules the setting of the previous ones in the -# list). -# Note: Since the styling of scrollbars can currently not be overruled in -# Webkit/Chromium, the styling will be left out of the default doxygen.css if -# one or more extra stylesheets have been specified. So if scrollbar -# customization is desired it has to be added explicitly. For an example see the -# documentation. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_EXTRA_STYLESHEET = doxygen_html_style.css - -# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or -# other source files which should be copied to the HTML output directory. Note -# that these files will be copied to the base HTML output directory. Use the -# $relpath^ marker in the HTML_HEADER and/or HTML_FOOTER files to load these -# files. In the HTML_STYLESHEET file, use the file name only. Also note that the -# files will be copied as-is; there are no commands or markers available. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_EXTRA_FILES = - -# The HTML_COLORSTYLE tag can be used to specify if the generated HTML output -# should be rendered with a dark or light theme. -# Possible values are: LIGHT always generate light mode output, DARK always -# generate dark mode output, AUTO_LIGHT automatically set the mode according to -# the user preference, use light mode if no preference is set (the default), -# AUTO_DARK automatically set the mode according to the user preference, use -# dark mode if no preference is set and TOGGLE allow to user to switch between -# light and dark mode via a button. -# The default value is: AUTO_LIGHT. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_COLORSTYLE = DARK - -# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen -# will adjust the colors in the style sheet and background images according to -# this color. Hue is specified as an angle on a color-wheel, see -# https://en.wikipedia.org/wiki/Hue for more information. For instance the value -# 0 represents red, 60 is yellow, 120 is green, 180 is cyan, 240 is blue, 300 -# purple, and 360 is red again. -# Minimum value: 0, maximum value: 359, default value: 220. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_COLORSTYLE_HUE = 220 - -# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of the colors -# in the HTML output. For a value of 0 the output will use gray-scales only. A -# value of 255 will produce the most vivid colors. -# Minimum value: 0, maximum value: 255, default value: 100. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_COLORSTYLE_SAT = 100 - -# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to the -# luminance component of the colors in the HTML output. Values below 100 -# gradually make the output lighter, whereas values above 100 make the output -# darker. The value divided by 100 is the actual gamma applied, so 80 represents -# a gamma of 0.8, The value 220 represents a gamma of 2.2, and 100 does not -# change the gamma. -# Minimum value: 40, maximum value: 240, default value: 80. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_COLORSTYLE_GAMMA = 80 - -# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML -# page will contain the date and time when the page was generated. Setting this -# to YES can help to show when doxygen was last run and thus if the -# documentation is up to date. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_TIMESTAMP = NO - -# If the HTML_DYNAMIC_MENUS tag is set to YES then the generated HTML -# documentation will contain a main index with vertical navigation menus that -# are dynamically created via JavaScript. If disabled, the navigation index will -# consists of multiple levels of tabs that are statically embedded in every HTML -# page. Disable this option to support browsers that do not have JavaScript, -# like the Qt help browser. -# The default value is: YES. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_DYNAMIC_MENUS = YES - -# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML -# documentation will contain sections that can be hidden and shown after the -# page has loaded. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_DYNAMIC_SECTIONS = NO - -# With HTML_INDEX_NUM_ENTRIES one can control the preferred number of entries -# shown in the various tree structured indices initially; the user can expand -# and collapse entries dynamically later on. Doxygen will expand the tree to -# such a level that at most the specified number of entries are visible (unless -# a fully collapsed tree already exceeds this amount). So setting the number of -# entries 1 will produce a full collapsed tree by default. 0 is a special value -# representing an infinite number of entries and will result in a full expanded -# tree by default. -# Minimum value: 0, maximum value: 9999, default value: 100. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_INDEX_NUM_ENTRIES = 100 - -# If the GENERATE_DOCSET tag is set to YES, additional index files will be -# generated that can be used as input for Apple's Xcode 3 integrated development -# environment (see: -# https://developer.apple.com/xcode/), introduced with OSX 10.5 (Leopard). To -# create a documentation set, doxygen will generate a Makefile in the HTML -# output directory. Running make will produce the docset in that directory and -# running make install will install the docset in -# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find it at -# startup. See https://developer.apple.com/library/archive/featuredarticles/Doxy -# genXcode/_index.html for more information. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. - -GENERATE_DOCSET = NO - -# This tag determines the name of the docset feed. A documentation feed provides -# an umbrella under which multiple documentation sets from a single provider -# (such as a company or product suite) can be grouped. -# The default value is: Doxygen generated docs. -# This tag requires that the tag GENERATE_DOCSET is set to YES. - -DOCSET_FEEDNAME = "Doxygen generated docs" - -# This tag determines the URL of the docset feed. A documentation feed provides -# an umbrella under which multiple documentation sets from a single provider -# (such as a company or product suite) can be grouped. -# This tag requires that the tag GENERATE_DOCSET is set to YES. - -DOCSET_FEEDURL = - -# This tag specifies a string that should uniquely identify the documentation -# set bundle. This should be a reverse domain-name style string, e.g. -# com.mycompany.MyDocSet. Doxygen will append .docset to the name. -# The default value is: org.doxygen.Project. -# This tag requires that the tag GENERATE_DOCSET is set to YES. - -DOCSET_BUNDLE_ID = org.doxygen.Project - -# The DOCSET_PUBLISHER_ID tag specifies a string that should uniquely identify -# the documentation publisher. This should be a reverse domain-name style -# string, e.g. com.mycompany.MyDocSet.documentation. -# The default value is: org.doxygen.Publisher. -# This tag requires that the tag GENERATE_DOCSET is set to YES. - -DOCSET_PUBLISHER_ID = org.doxygen.Publisher - -# The DOCSET_PUBLISHER_NAME tag identifies the documentation publisher. -# The default value is: Publisher. -# This tag requires that the tag GENERATE_DOCSET is set to YES. - -DOCSET_PUBLISHER_NAME = Publisher - -# If the GENERATE_HTMLHELP tag is set to YES then doxygen generates three -# additional HTML index files: index.hhp, index.hhc, and index.hhk. The -# index.hhp is a project file that can be read by Microsoft's HTML Help Workshop -# on Windows. In the beginning of 2021 Microsoft took the original page, with -# a.o. the download links, offline the HTML help workshop was already many years -# in maintenance mode). You can download the HTML help workshop from the web -# archives at Installation executable (see: -# http://web.archive.org/web/20160201063255/http://download.microsoft.com/downlo -# ad/0/A/9/0A939EF6-E31C-430F-A3DF-DFAE7960D564/htmlhelp.exe). -# -# The HTML Help Workshop contains a compiler that can convert all HTML output -# generated by doxygen into a single compiled HTML file (.chm). Compiled HTML -# files are now used as the Windows 98 help format, and will replace the old -# Windows help format (.hlp) on all Windows platforms in the future. Compressed -# HTML files also contain an index, a table of contents, and you can search for -# words in the documentation. The HTML workshop also contains a viewer for -# compressed HTML files. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. - -GENERATE_HTMLHELP = NO - -# The CHM_FILE tag can be used to specify the file name of the resulting .chm -# file. You can add a path in front of the file if the result should not be -# written to the html output directory. -# This tag requires that the tag GENERATE_HTMLHELP is set to YES. - -CHM_FILE = - -# The HHC_LOCATION tag can be used to specify the location (absolute path -# including file name) of the HTML help compiler (hhc.exe). If non-empty, -# doxygen will try to run the HTML help compiler on the generated index.hhp. -# The file has to be specified with full path. -# This tag requires that the tag GENERATE_HTMLHELP is set to YES. - -HHC_LOCATION = - -# The GENERATE_CHI flag controls if a separate .chi index file is generated -# (YES) or that it should be included in the main .chm file (NO). -# The default value is: NO. -# This tag requires that the tag GENERATE_HTMLHELP is set to YES. - -GENERATE_CHI = NO - -# The CHM_INDEX_ENCODING is used to encode HtmlHelp index (hhk), content (hhc) -# and project file content. -# This tag requires that the tag GENERATE_HTMLHELP is set to YES. - -CHM_INDEX_ENCODING = - -# The BINARY_TOC flag controls whether a binary table of contents is generated -# (YES) or a normal table of contents (NO) in the .chm file. Furthermore it -# enables the Previous and Next buttons. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTMLHELP is set to YES. - -BINARY_TOC = NO - -# The TOC_EXPAND flag can be set to YES to add extra items for group members to -# the table of contents of the HTML help documentation and to the tree view. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTMLHELP is set to YES. - -TOC_EXPAND = NO - -# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and -# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated that -# can be used as input for Qt's qhelpgenerator to generate a Qt Compressed Help -# (.qch) of the generated HTML documentation. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. - -GENERATE_QHP = NO - -# If the QHG_LOCATION tag is specified, the QCH_FILE tag can be used to specify -# the file name of the resulting .qch file. The path specified is relative to -# the HTML output folder. -# This tag requires that the tag GENERATE_QHP is set to YES. - -QCH_FILE = - -# The QHP_NAMESPACE tag specifies the namespace to use when generating Qt Help -# Project output. For more information please see Qt Help Project / Namespace -# (see: -# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#namespace). -# The default value is: org.doxygen.Project. -# This tag requires that the tag GENERATE_QHP is set to YES. - -QHP_NAMESPACE = org.doxygen.Project - -# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating Qt -# Help Project output. For more information please see Qt Help Project / Virtual -# Folders (see: -# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#virtual-folders). -# The default value is: doc. -# This tag requires that the tag GENERATE_QHP is set to YES. - -QHP_VIRTUAL_FOLDER = doc - -# If the QHP_CUST_FILTER_NAME tag is set, it specifies the name of a custom -# filter to add. For more information please see Qt Help Project / Custom -# Filters (see: -# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#custom-filters). -# This tag requires that the tag GENERATE_QHP is set to YES. - -QHP_CUST_FILTER_NAME = - -# The QHP_CUST_FILTER_ATTRS tag specifies the list of the attributes of the -# custom filter to add. For more information please see Qt Help Project / Custom -# Filters (see: -# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#custom-filters). -# This tag requires that the tag GENERATE_QHP is set to YES. - -QHP_CUST_FILTER_ATTRS = - -# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this -# project's filter section matches. Qt Help Project / Filter Attributes (see: -# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#filter-attributes). -# This tag requires that the tag GENERATE_QHP is set to YES. - -QHP_SECT_FILTER_ATTRS = - -# The QHG_LOCATION tag can be used to specify the location (absolute path -# including file name) of Qt's qhelpgenerator. If non-empty doxygen will try to -# run qhelpgenerator on the generated .qhp file. -# This tag requires that the tag GENERATE_QHP is set to YES. - -QHG_LOCATION = - -# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files will be -# generated, together with the HTML files, they form an Eclipse help plugin. To -# install this plugin and make it available under the help contents menu in -# Eclipse, the contents of the directory containing the HTML and XML files needs -# to be copied into the plugins directory of eclipse. The name of the directory -# within the plugins directory should be the same as the ECLIPSE_DOC_ID value. -# After copying Eclipse needs to be restarted before the help appears. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. - -GENERATE_ECLIPSEHELP = NO - -# A unique identifier for the Eclipse help plugin. When installing the plugin -# the directory name containing the HTML and XML files should also have this -# name. Each documentation set should have its own identifier. -# The default value is: org.doxygen.Project. -# This tag requires that the tag GENERATE_ECLIPSEHELP is set to YES. - -ECLIPSE_DOC_ID = org.doxygen.Project - -# If you want full control over the layout of the generated HTML pages it might -# be necessary to disable the index and replace it with your own. The -# DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) at top -# of each HTML page. A value of NO enables the index and the value YES disables -# it. Since the tabs in the index contain the same information as the navigation -# tree, you can set this option to YES if you also set GENERATE_TREEVIEW to YES. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. - -DISABLE_INDEX = YES - -# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index -# structure should be generated to display hierarchical information. If the tag -# value is set to YES, a side panel will be generated containing a tree-like -# index structure (just like the one that is generated for HTML Help). For this -# to work a browser that supports JavaScript, DHTML, CSS and frames is required -# (i.e. any modern browser). Windows users are probably better off using the -# HTML help feature. Via custom style sheets (see HTML_EXTRA_STYLESHEET) one can -# further fine tune the look of the index (see "Fine-tuning the output"). As an -# example, the default style sheet generated by doxygen has an example that -# shows how to put an image at the root of the tree instead of the PROJECT_NAME. -# Since the tree basically has the same information as the tab index, you could -# consider setting DISABLE_INDEX to YES when enabling this option. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. - -GENERATE_TREEVIEW = YES - -# When both GENERATE_TREEVIEW and DISABLE_INDEX are set to YES, then the -# FULL_SIDEBAR option determines if the side bar is limited to only the treeview -# area (value NO) or if it should extend to the full height of the window (value -# YES). Setting this to YES gives a layout similar to -# https://docs.readthedocs.io with more room for contents, but less room for the -# project logo, title, and description. If either GENERATE_TREEVIEW or -# DISABLE_INDEX is set to NO, this option has no effect. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. - -FULL_SIDEBAR = NO - -# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values that -# doxygen will group on one line in the generated HTML documentation. -# -# Note that a value of 0 will completely suppress the enum values from appearing -# in the overview section. -# Minimum value: 0, maximum value: 20, default value: 4. -# This tag requires that the tag GENERATE_HTML is set to YES. - -ENUM_VALUES_PER_LINE = 4 - -# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be used -# to set the initial width (in pixels) of the frame in which the tree is shown. -# Minimum value: 0, maximum value: 1500, default value: 250. -# This tag requires that the tag GENERATE_HTML is set to YES. - -TREEVIEW_WIDTH = 250 - -# If the EXT_LINKS_IN_WINDOW option is set to YES, doxygen will open links to -# external symbols imported via tag files in a separate window. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. - -EXT_LINKS_IN_WINDOW = NO - -# If the OBFUSCATE_EMAILS tag is set to YES, doxygen will obfuscate email -# addresses. -# The default value is: YES. -# This tag requires that the tag GENERATE_HTML is set to YES. - -OBFUSCATE_EMAILS = YES - -# If the HTML_FORMULA_FORMAT option is set to svg, doxygen will use the pdf2svg -# tool (see https://github.com/dawbarton/pdf2svg) or inkscape (see -# https://inkscape.org) to generate formulas as SVG images instead of PNGs for -# the HTML output. These images will generally look nicer at scaled resolutions. -# Possible values are: png (the default) and svg (looks nicer but requires the -# pdf2svg or inkscape tool). -# The default value is: png. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_FORMULA_FORMAT = png - -# Use this tag to change the font size of LaTeX formulas included as images in -# the HTML documentation. When you change the font size after a successful -# doxygen run you need to manually remove any form_*.png images from the HTML -# output directory to force them to be regenerated. -# Minimum value: 8, maximum value: 50, default value: 10. -# This tag requires that the tag GENERATE_HTML is set to YES. - -FORMULA_FONTSIZE = 10 - -# The FORMULA_MACROFILE can contain LaTeX \newcommand and \renewcommand commands -# to create new LaTeX commands to be used in formulas as building blocks. See -# the section "Including formulas" for details. - -FORMULA_MACROFILE = - -# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax (see -# https://www.mathjax.org) which uses client side JavaScript for the rendering -# instead of using pre-rendered bitmaps. Use this if you do not have LaTeX -# installed or if you want to formulas look prettier in the HTML output. When -# enabled you may also need to install MathJax separately and configure the path -# to it using the MATHJAX_RELPATH option. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. - -USE_MATHJAX = NO - -# With MATHJAX_VERSION it is possible to specify the MathJax version to be used. -# Note that the different versions of MathJax have different requirements with -# regards to the different settings, so it is possible that also other MathJax -# settings have to be changed when switching between the different MathJax -# versions. -# Possible values are: MathJax_2 and MathJax_3. -# The default value is: MathJax_2. -# This tag requires that the tag USE_MATHJAX is set to YES. - -MATHJAX_VERSION = MathJax_2 - -# When MathJax is enabled you can set the default output format to be used for -# the MathJax output. For more details about the output format see MathJax -# version 2 (see: -# http://docs.mathjax.org/en/v2.7-latest/output.html) and MathJax version 3 -# (see: -# http://docs.mathjax.org/en/latest/web/components/output.html). -# Possible values are: HTML-CSS (which is slower, but has the best -# compatibility. This is the name for Mathjax version 2, for MathJax version 3 -# this will be translated into chtml), NativeMML (i.e. MathML. Only supported -# for NathJax 2. For MathJax version 3 chtml will be used instead.), chtml (This -# is the name for Mathjax version 3, for MathJax version 2 this will be -# translated into HTML-CSS) and SVG. -# The default value is: HTML-CSS. -# This tag requires that the tag USE_MATHJAX is set to YES. - -MATHJAX_FORMAT = HTML-CSS - -# When MathJax is enabled you need to specify the location relative to the HTML -# output directory using the MATHJAX_RELPATH option. The destination directory -# should contain the MathJax.js script. For instance, if the mathjax directory -# is located at the same level as the HTML output directory, then -# MATHJAX_RELPATH should be ../mathjax. The default value points to the MathJax -# Content Delivery Network so you can quickly see the result without installing -# MathJax. However, it is strongly recommended to install a local copy of -# MathJax from https://www.mathjax.org before deployment. The default value is: -# - in case of MathJax version 2: https://cdn.jsdelivr.net/npm/mathjax@2 -# - in case of MathJax version 3: https://cdn.jsdelivr.net/npm/mathjax@3 -# This tag requires that the tag USE_MATHJAX is set to YES. - -MATHJAX_RELPATH = - -# The MATHJAX_EXTENSIONS tag can be used to specify one or more MathJax -# extension names that should be enabled during MathJax rendering. For example -# for MathJax version 2 (see https://docs.mathjax.org/en/v2.7-latest/tex.html -# #tex-and-latex-extensions): -# MATHJAX_EXTENSIONS = TeX/AMSmath TeX/AMSsymbols -# For example for MathJax version 3 (see -# http://docs.mathjax.org/en/latest/input/tex/extensions/index.html): -# MATHJAX_EXTENSIONS = ams -# This tag requires that the tag USE_MATHJAX is set to YES. - -MATHJAX_EXTENSIONS = - -# The MATHJAX_CODEFILE tag can be used to specify a file with javascript pieces -# of code that will be used on startup of the MathJax code. See the MathJax site -# (see: -# http://docs.mathjax.org/en/v2.7-latest/output.html) for more details. For an -# example see the documentation. -# This tag requires that the tag USE_MATHJAX is set to YES. - -MATHJAX_CODEFILE = - -# When the SEARCHENGINE tag is enabled doxygen will generate a search box for -# the HTML output. The underlying search engine uses javascript and DHTML and -# should work on any modern browser. Note that when using HTML help -# (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets (GENERATE_DOCSET) -# there is already a search function so this one should typically be disabled. -# For large projects the javascript based search engine can be slow, then -# enabling SERVER_BASED_SEARCH may provide a better solution. It is possible to -# search using the keyboard; to jump to the search box use + S -# (what the is depends on the OS and browser, but it is typically -# , /