diff --git a/.cargo/config.toml b/.cargo/config.toml deleted file mode 100644 index 622c2064..00000000 --- a/.cargo/config.toml +++ /dev/null @@ -1,5 +0,0 @@ -# [target.x86_64-unknown-linux-gnu] -# linker = "x86_64-unknown-linux-gnu-gcc" - -[build] -rustflags = ["-C", "force-frame-pointers=yes", "-C", "force-unwind-tables=yes"] diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..8e5d587f --- /dev/null +++ b/.editorconfig @@ -0,0 +1,32 @@ +# EditorConfig helps developers define and maintain consistent +# coding styles between different editors and IDEs +# editorconfig.org + +root = true + +[*] +charset = utf-8 +end_of_line = lf +indent_size = 4 +indent_style = space +insert_final_newline = true +max_line_length = 100 +trim_trailing_whitespace = true + +[*.md] +indent_size = unset +max_line_length = 150 + +[{*.yml,*.yaml,*.toml}] +indent_size = 2 +max_line_length = 150 + +# Ignore paths +[{.git/**/*,**/*.lock,LICENSE}] +charset = unset +end_of_line = unset +indent_size = unset +indent_style = unset +insert_final_newline = unset +max_line_length = unset +trim_trailing_whitespace = unset diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000..65c435f1 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,30 @@ +# Documentation for all configuration options: +# https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file + +version: 2 +updates: + - package-ecosystem: "cargo" + directory: "/" + schedule: + interval: "weekly" + day: "sunday" + commit-message: + prefix: "fix" + prefix-development: "chore" + include: "scope" + groups: + cargo-minor-and-patch-dependencies: + update-types: + - "minor" + - "patch" + + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "monthly" + commit-message: + prefix: "chore" + include: "scope" + groups: + github-actions-all: + patterns: ["*"] diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml deleted file mode 100644 index 059ca7c1..00000000 --- a/.github/workflows/check.yml +++ /dev/null @@ -1,11 +0,0 @@ -name: check.sh -run-name: Check.sh started by ${{ github.actor }} -on: [push] -jobs: - check-sh: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - run: rustup component add rustfmt - - run: rustup component add clippy - - run: ./check.sh diff --git a/.github/workflows/code.yml b/.github/workflows/code.yml new file mode 100644 index 00000000..246e106b --- /dev/null +++ b/.github/workflows/code.yml @@ -0,0 +1,168 @@ +name: Code + +on: + # Run workflow on every PR. + pull_request: + # Run workflow on the main branch after every merge. + # This is important to fill the GitHub Actions cache in a way that PRs can see it. + push: + branches: + - main + # Run workflow on the main branch every Sunday. + schedule: + - cron: "14 3 * * 0" + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +env: + CARGO_TERM_COLOR: always + CLICOLOR_FORCE: 1 + # Incremental compilation is useful as part of an edit-build-test-edit cycle, as it lets the + # compiler avoid recompiling code that hasn't changed. The setting does not improve the current + # compilation but instead saves additional information to speed up future compilations (see + # https://doc.rust-lang.org/cargo/reference/profiles.html#incremental). Thus, this is only useful + # in CI if the result is cached, which we only do on the `main` branch. + CARGO_INCREMENTAL: ${{ github.ref == 'refs/heads/main' && '1' || '0' }} + # Allow more retries for network requests in cargo (downloading crates) and + # rustup (installing toolchains). This should help to reduce flaky CI failures + # from transient network timeouts or other issues. + CARGO_NET_RETRY: 10 + RUSTUP_MAX_RETRIES: 10 + # Don't emit giant backtraces in the CI logs. + RUST_BACKTRACE: short + RUSTDOCFLAGS: -D warnings + +jobs: + diff: + runs-on: ubuntu-latest + permissions: + contents: read + pull-requests: read + steps: + - uses: actions/checkout@v4 + - name: Detect Changes + uses: dorny/paths-filter@v3.0.2 + id: diff + with: + filters: | + - 'crates/**' + - 'Cargo.toml' + - 'Cargo.lock' + - 'rust-toolchain' + - 'deny.toml' + - '.github/workflows/code.yml' + + dependencies: + name: Check dependencies + needs: diff + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: EmbarkStudios/cargo-deny-action@v1.6.3 + with: + # do not check advisories on PRs to prevent sudden failure due to new announcement + command: check bans licenses sources + + dependencies-schedule: + name: Check dependencies (including vulnerabilities) + needs: diff + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: EmbarkStudios/cargo-deny-action@v1.6.3 + + test-coverage: + name: Run all Rust tests and report coverage + needs: diff + runs-on: ubuntu-latest + permissions: + contents: read + pull-requests: write + env: + RUSTC_BOOTSTRAP: 1 + steps: + - uses: actions/checkout@v4 + - uses: Swatinem/rust-cache@v2.7.3 + with: + save-if: ${{ github.ref == 'refs/heads/main' && 'true' || 'false' }} + - run: cargo install cargo-tarpaulin@0.30.0 + - name: Run tests and record coverage + run: cargo tarpaulin + shell: bash + - name: Upload coverage report + uses: actions/upload-artifact@v4 + with: + name: Coverage report + path: tarpaulin-report.html + - name: Code-coverage report + uses: irongut/CodeCoverageSummary@v1.3.0 + with: + filename: cobertura.xml + badge: true + fail_below_min: false + format: markdown + hide_branch_rate: false + hide_complexity: true + indicators: true + output: both + thresholds: "50 75" + - name: Add coverage PR comment + uses: marocchino/sticky-pull-request-comment@v2 + if: ${{ github.event_name == 'pull_request' && github.actor != 'dependabot[bot]' }} + with: + path: code-coverage-results.md + + lint: + name: Lint Rust code + needs: diff + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: Swatinem/rust-cache@v2.7.3 + with: + save-if: ${{ github.ref == 'refs/heads/main' && 'true' || 'false' }} + - run: cargo install cargo-sort@1.0.9 + + - name: Check formatting with rustfmt + run: > + cargo fmt --all -- --check + --config group_imports=StdExternalCrate,imports_granularity=Crate,imports_layout=HorizontalVertical + - name: Check sorting of dependencies + run: cargo sort -w -c + - name: Lint using clippy (w/o tests) + run: cargo clippy --all-features --no-deps -- -D warnings + - name: Lint using clippy (w/ tests) + run: cargo clippy --all-features --tests --no-deps -- -D warnings + - name: Check documentation + run: cargo doc --no-deps --workspace + + build: + name: Build Rust code + needs: diff + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: Swatinem/rust-cache@v2.7.3 + with: + save-if: ${{ github.ref == 'refs/heads/main' && 'true' || 'false' }} + - name: Build Rust code + run: cargo build --verbose + + check-all: + name: Check if all code checks succeeded + if: always() + needs: + - diff + - dependencies + - test-coverage + - lint + - build + runs-on: ubuntu-latest + steps: + - name: Decide whether all needed jobs succeeded + uses: re-actors/alls-green@v1.2.2 + with: + allowed-skips: ${{ toJSON(needs) }} + jobs: ${{ toJSON(needs) }} diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 00000000..ec8dd8c5 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,60 @@ +name: Lint + +on: [pull_request] + +permissions: + contents: read + +jobs: + pr-title: + runs-on: ubuntu-latest + name: Check PR title format + permissions: + contents: read + pull-requests: read + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Check PR title + uses: amannn/action-semantic-pull-request@v5.5.2 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + editorconfig: + runs-on: ubuntu-latest + name: Check editorconfig + steps: + - uses: actions/checkout@v4 + - run: pip install editorconfig-checker=="2.7.3" + - run: ec + + typos: + runs-on: ubuntu-latest + name: Check spelling + steps: + - uses: actions/checkout@v4 + - uses: crate-ci/typos@v1.21.0 + + license-headers: + runs-on: ubuntu-latest + name: Check license headers + steps: + - uses: actions/checkout@v4 + - run: cargo install licensesnip@1.5.0 + - run: licensesnip check + + check-all: + name: Check if all lint jobs succeeded + if: always() + needs: + - pr-title + - editorconfig + - typos + - license-headers + runs-on: ubuntu-latest + steps: + - name: Decide whether all needed jobs succeeded + uses: re-actors/alls-green@v1.2.2 + with: + jobs: ${{ toJSON(needs) }} diff --git a/.github/workflows/releases.yml b/.github/workflows/releases.yml new file mode 100644 index 00000000..eb277898 --- /dev/null +++ b/.github/workflows/releases.yml @@ -0,0 +1,77 @@ +name: Release + +on: + push: + tags: + - "v[0-9]+.[0-9]+.[0-9]+" + +permissions: + contents: write + +jobs: + release: + name: Release + runs-on: ${{ matrix.os }} + + strategy: + matrix: + include: + - build: linux + os: ubuntu-latest + target: x86_64-unknown-linux-musl + + - build: macos + os: macos-latest + target: aarch64-apple-darwin + + - build: windows-gnu + os: windows-latest + target: x86_64-pc-windows-msvc + + steps: + - name: Clone the repository + uses: actions/checkout@v4 + + - name: Install Rust + uses: dtolnay/rust-toolchain@stable + with: + targets: ${{ matrix.target }} + + - name: Get the release version from the tag + shell: bash + run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV + + - name: Build the binaries + uses: actions-rs/cargo@v1 + with: + use-cross: true + command: build + args: --verbose --release --target ${{ matrix.target }} + + - name: Build archive + shell: bash + run: | + binary_name="mysticeti" + + dirname="$binary_name-${{ matrix.target }}" + mkdir "$dirname" + if [ "${{ matrix.os }}" = "windows-latest" ]; then + mv "target/${{ matrix.target }}/release/$binary_name.exe" "$dirname" + else + mv "target/${{ matrix.target }}/release/$binary_name" "$dirname" + fi + + if [ "${{ matrix.os }}" = "windows-latest" ]; then + 7z a "$dirname.zip" "$dirname" + echo "ASSET=$dirname.zip" >> $GITHUB_ENV + else + tar -czf "$dirname.tar.gz" "$dirname" + echo "ASSET=$dirname.tar.gz" >> $GITHUB_ENV + fi + + - name: Upload the binaries + uses: softprops/action-gh-release@v2.0.5 + with: + generate_release_notes: true + files: | + ${{ env.ASSET }} diff --git a/.github/workflows/updates.yml b/.github/workflows/updates.yml new file mode 100644 index 00000000..74b6fa4a --- /dev/null +++ b/.github/workflows/updates.yml @@ -0,0 +1,52 @@ +name: Updates + +on: + # every month + schedule: + - cron: "14 3 1 * *" + # on demand + workflow_dispatch: + +jobs: + pre-commit: + name: "Update pre-commit hooks and run them on all files" + runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: "3.12" + - run: rustup update stable + - run: pip install pre-commit + - name: Run pre-commit autoupdate + run: > + pre-commit autoupdate + --repo https://github.com/pre-commit/pre-commit-hooks + --repo https://github.com/editorconfig-checker/editorconfig-checker.python + --repo https://github.com/crate-ci/typos + --repo https://github.com/EmbarkStudios/cargo-deny + - run: pre-commit run --all-files + - uses: peter-evans/create-pull-request@v6.0.5 + if: ${{ success() }} + with: + token: ${{ secrets.GITHUB_TOKEN }} + branch: chore/update-pre-commit-hooks + title: "chore: update pre-commit hooks" + commit-message: "chore: update pre-commit hooks" + body: Update pre-commit hooks to latest version. + - uses: peter-evans/create-pull-request@v6.0.5 + if: ${{ failure() }} + with: + token: ${{ secrets.GITHUB_TOKEN }} + branch: chore/update-pre-commit-hooks + title: "chore: update pre-commit hooks" + commit-message: "chore: update pre-commit hooks" + body: | + Update pre-commit hooks to latest version. + + **Warning**: Some checks did not succeed. Please check the [action output][run] before merging this PR. + + [run]: https://github.com/asonnino/mysticeti/actions/runs/${{ github.run_id }} diff --git a/.gitignore b/.gitignore index baaf304a..04adf76e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,17 @@ -/target -.vscode/ +# Generated by Cargo +# will have compiled files and executables +debug/ +target/ + +# These are backup files generated by rustfmt +**/*.rs.bk + +# MSVC Windows builds of rustc generate these, which store debugging information +*.pdb + +# Generated by Tarpaulin +tarpaulin-report.html +cobertura.xml + +# Generated by macOS .DS_Store -genesis/ -.idea/ -dryrun-* -local-testbed* -*.log.ansi -results/ diff --git a/.licensesnip b/.licensesnip new file mode 100644 index 00000000..a0b64339 --- /dev/null +++ b/.licensesnip @@ -0,0 +1,2 @@ +Copyright (c) Mysten Labs, Inc. +SPDX-License-Identifier: Apache-2.0 \ No newline at end of file diff --git a/.pre-commit-config.yml b/.pre-commit-config.yml new file mode 100644 index 00000000..664b3a49 --- /dev/null +++ b/.pre-commit-config.yml @@ -0,0 +1,81 @@ +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.6.0 + hooks: + - id: check-merge-conflict + - id: check-yaml + - id: trailing-whitespace + - id: check-symlinks + - id: end-of-file-fixer + - id: mixed-line-ending + - id: trailing-whitespace + - repo: https://github.com/editorconfig-checker/editorconfig-checker.python + rev: "2.7.3" + hooks: + - id: editorconfig-checker + alias: ec + - repo: https://github.com/notken12/licensesnip + rev: 19b1186 + hooks: + - id: licensesnip + args: [] + pass_filenames: false + - repo: https://github.com/crate-ci/typos + rev: v1.21.0 + hooks: + - id: typos + pass_filenames: false + - repo: https://github.com/DevinR528/cargo-sort + rev: v1.0.9 + hooks: + - id: cargo-sort + args: ["--workspace"] + - repo: https://github.com/EmbarkStudios/cargo-deny + rev: 0.14.23 + hooks: + - id: cargo-deny + - repo: local + hooks: + - id: cargo-fmt + name: cargo-fmt + entry: cargo fmt + args: + - "--" + - "--config" + - "group_imports=StdExternalCrate,imports_granularity=Crate,imports_layout=HorizontalVertical" + language: rust + types: [rust] + pass_filenames: false + - id: cargo-check + name: cargo-check + entry: cargo check + language: rust + files: ^(crates/|Cargo\.(toml|lock)$) + pass_filenames: false + - id: cargo-test + name: cargo-test + entry: cargo test + language: rust + files: ^(crates/|Cargo\.(toml|lock)$) + pass_filenames: false + - id: clippy-with-tests + name: clippy-with-tests + entry: cargo clippy + args: ["--all-features", "--tests", "--", "-D", "warnings"] + language: rust + files: ^(crates/|Cargo\.(toml|lock)$) + pass_filenames: false + - id: clippy + name: clippy + entry: cargo clippy + args: ["--all-features", "--", "-D", "warnings"] + language: rust + files: ^(crates/|Cargo\.(toml|lock)$) + pass_filenames: false + - id: cargo-doc + name: cargo-doc + entry: env RUSTDOCFLAGS="-D warnings" cargo doc + args: ["--workspace", "--no-deps"] + language: rust + files: ^(crates/|Cargo\.(toml|lock)$) + pass_filenames: false diff --git a/Cargo.toml b/Cargo.toml index 1c52f7e3..67d5e60b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,9 +1,9 @@ [workspace] members = [ - "mysticeti-core", - "mysticeti", - "third-party/minibytes", - "orchestrator" + "crates/mysticeti", + "crates/mysticeti-core", + "crates/orchestrator", + "crates/third-party/minibytes", ] resolver = "2" diff --git a/mysticeti-core/Cargo.toml b/crates/mysticeti-core/Cargo.toml similarity index 100% rename from mysticeti-core/Cargo.toml rename to crates/mysticeti-core/Cargo.toml diff --git a/mysticeti-core/src/block_handler.rs b/crates/mysticeti-core/src/block_handler.rs similarity index 100% rename from mysticeti-core/src/block_handler.rs rename to crates/mysticeti-core/src/block_handler.rs diff --git a/mysticeti-core/src/block_manager.rs b/crates/mysticeti-core/src/block_manager.rs similarity index 100% rename from mysticeti-core/src/block_manager.rs rename to crates/mysticeti-core/src/block_manager.rs diff --git a/mysticeti-core/src/block_store.rs b/crates/mysticeti-core/src/block_store.rs similarity index 100% rename from mysticeti-core/src/block_store.rs rename to crates/mysticeti-core/src/block_store.rs diff --git a/mysticeti-core/src/committee.rs b/crates/mysticeti-core/src/committee.rs similarity index 100% rename from mysticeti-core/src/committee.rs rename to crates/mysticeti-core/src/committee.rs diff --git a/mysticeti-core/src/config.rs b/crates/mysticeti-core/src/config.rs similarity index 100% rename from mysticeti-core/src/config.rs rename to crates/mysticeti-core/src/config.rs diff --git a/mysticeti-core/src/consensus/base_committer.rs b/crates/mysticeti-core/src/consensus/base_committer.rs similarity index 100% rename from mysticeti-core/src/consensus/base_committer.rs rename to crates/mysticeti-core/src/consensus/base_committer.rs diff --git a/mysticeti-core/src/consensus/linearizer.rs b/crates/mysticeti-core/src/consensus/linearizer.rs similarity index 100% rename from mysticeti-core/src/consensus/linearizer.rs rename to crates/mysticeti-core/src/consensus/linearizer.rs diff --git a/mysticeti-core/src/consensus/mod.rs b/crates/mysticeti-core/src/consensus/mod.rs similarity index 100% rename from mysticeti-core/src/consensus/mod.rs rename to crates/mysticeti-core/src/consensus/mod.rs diff --git a/mysticeti-core/src/consensus/tests/base_committer_tests.rs b/crates/mysticeti-core/src/consensus/tests/base_committer_tests.rs similarity index 100% rename from mysticeti-core/src/consensus/tests/base_committer_tests.rs rename to crates/mysticeti-core/src/consensus/tests/base_committer_tests.rs diff --git a/mysticeti-core/src/consensus/tests/mod.rs b/crates/mysticeti-core/src/consensus/tests/mod.rs similarity index 100% rename from mysticeti-core/src/consensus/tests/mod.rs rename to crates/mysticeti-core/src/consensus/tests/mod.rs diff --git a/mysticeti-core/src/consensus/tests/multi_committer_tests.rs b/crates/mysticeti-core/src/consensus/tests/multi_committer_tests.rs similarity index 100% rename from mysticeti-core/src/consensus/tests/multi_committer_tests.rs rename to crates/mysticeti-core/src/consensus/tests/multi_committer_tests.rs diff --git a/mysticeti-core/src/consensus/tests/pipelined_committer_tests.rs b/crates/mysticeti-core/src/consensus/tests/pipelined_committer_tests.rs similarity index 100% rename from mysticeti-core/src/consensus/tests/pipelined_committer_tests.rs rename to crates/mysticeti-core/src/consensus/tests/pipelined_committer_tests.rs diff --git a/mysticeti-core/src/consensus/universal_committer.rs b/crates/mysticeti-core/src/consensus/universal_committer.rs similarity index 100% rename from mysticeti-core/src/consensus/universal_committer.rs rename to crates/mysticeti-core/src/consensus/universal_committer.rs diff --git a/mysticeti-core/src/core.rs b/crates/mysticeti-core/src/core.rs similarity index 100% rename from mysticeti-core/src/core.rs rename to crates/mysticeti-core/src/core.rs diff --git a/mysticeti-core/src/core_thread/mod.rs b/crates/mysticeti-core/src/core_thread/mod.rs similarity index 100% rename from mysticeti-core/src/core_thread/mod.rs rename to crates/mysticeti-core/src/core_thread/mod.rs diff --git a/mysticeti-core/src/core_thread/simulated.rs b/crates/mysticeti-core/src/core_thread/simulated.rs similarity index 100% rename from mysticeti-core/src/core_thread/simulated.rs rename to crates/mysticeti-core/src/core_thread/simulated.rs diff --git a/mysticeti-core/src/core_thread/spawned.rs b/crates/mysticeti-core/src/core_thread/spawned.rs similarity index 100% rename from mysticeti-core/src/core_thread/spawned.rs rename to crates/mysticeti-core/src/core_thread/spawned.rs diff --git a/mysticeti-core/src/crypto.rs b/crates/mysticeti-core/src/crypto.rs similarity index 100% rename from mysticeti-core/src/crypto.rs rename to crates/mysticeti-core/src/crypto.rs diff --git a/mysticeti-core/src/data.rs b/crates/mysticeti-core/src/data.rs similarity index 100% rename from mysticeti-core/src/data.rs rename to crates/mysticeti-core/src/data.rs diff --git a/mysticeti-core/src/epoch_close.rs b/crates/mysticeti-core/src/epoch_close.rs similarity index 100% rename from mysticeti-core/src/epoch_close.rs rename to crates/mysticeti-core/src/epoch_close.rs diff --git a/mysticeti-core/src/finalization_interpreter.rs b/crates/mysticeti-core/src/finalization_interpreter.rs similarity index 100% rename from mysticeti-core/src/finalization_interpreter.rs rename to crates/mysticeti-core/src/finalization_interpreter.rs diff --git a/mysticeti-core/src/future_simulator.rs b/crates/mysticeti-core/src/future_simulator.rs similarity index 100% rename from mysticeti-core/src/future_simulator.rs rename to crates/mysticeti-core/src/future_simulator.rs diff --git a/mysticeti-core/src/lib.rs b/crates/mysticeti-core/src/lib.rs similarity index 100% rename from mysticeti-core/src/lib.rs rename to crates/mysticeti-core/src/lib.rs diff --git a/mysticeti-core/src/lock.rs b/crates/mysticeti-core/src/lock.rs similarity index 100% rename from mysticeti-core/src/lock.rs rename to crates/mysticeti-core/src/lock.rs diff --git a/mysticeti-core/src/log.rs b/crates/mysticeti-core/src/log.rs similarity index 100% rename from mysticeti-core/src/log.rs rename to crates/mysticeti-core/src/log.rs diff --git a/mysticeti-core/src/metrics.rs b/crates/mysticeti-core/src/metrics.rs similarity index 100% rename from mysticeti-core/src/metrics.rs rename to crates/mysticeti-core/src/metrics.rs diff --git a/mysticeti-core/src/net_sync.rs b/crates/mysticeti-core/src/net_sync.rs similarity index 100% rename from mysticeti-core/src/net_sync.rs rename to crates/mysticeti-core/src/net_sync.rs diff --git a/mysticeti-core/src/network.rs b/crates/mysticeti-core/src/network.rs similarity index 100% rename from mysticeti-core/src/network.rs rename to crates/mysticeti-core/src/network.rs diff --git a/mysticeti-core/src/prometheus.rs b/crates/mysticeti-core/src/prometheus.rs similarity index 100% rename from mysticeti-core/src/prometheus.rs rename to crates/mysticeti-core/src/prometheus.rs diff --git a/mysticeti-core/src/range_map.rs b/crates/mysticeti-core/src/range_map.rs similarity index 100% rename from mysticeti-core/src/range_map.rs rename to crates/mysticeti-core/src/range_map.rs diff --git a/mysticeti-core/src/runtime/mod.rs b/crates/mysticeti-core/src/runtime/mod.rs similarity index 100% rename from mysticeti-core/src/runtime/mod.rs rename to crates/mysticeti-core/src/runtime/mod.rs diff --git a/mysticeti-core/src/runtime/simulated.rs b/crates/mysticeti-core/src/runtime/simulated.rs similarity index 100% rename from mysticeti-core/src/runtime/simulated.rs rename to crates/mysticeti-core/src/runtime/simulated.rs diff --git a/mysticeti-core/src/runtime/tokio.rs b/crates/mysticeti-core/src/runtime/tokio.rs similarity index 100% rename from mysticeti-core/src/runtime/tokio.rs rename to crates/mysticeti-core/src/runtime/tokio.rs diff --git a/mysticeti-core/src/serde.rs b/crates/mysticeti-core/src/serde.rs similarity index 100% rename from mysticeti-core/src/serde.rs rename to crates/mysticeti-core/src/serde.rs diff --git a/mysticeti-core/src/simulated_network.rs b/crates/mysticeti-core/src/simulated_network.rs similarity index 100% rename from mysticeti-core/src/simulated_network.rs rename to crates/mysticeti-core/src/simulated_network.rs diff --git a/mysticeti-core/src/simulator.rs b/crates/mysticeti-core/src/simulator.rs similarity index 100% rename from mysticeti-core/src/simulator.rs rename to crates/mysticeti-core/src/simulator.rs diff --git a/mysticeti-core/src/simulator_tracing.rs b/crates/mysticeti-core/src/simulator_tracing.rs similarity index 100% rename from mysticeti-core/src/simulator_tracing.rs rename to crates/mysticeti-core/src/simulator_tracing.rs diff --git a/mysticeti-core/src/stat.rs b/crates/mysticeti-core/src/stat.rs similarity index 100% rename from mysticeti-core/src/stat.rs rename to crates/mysticeti-core/src/stat.rs diff --git a/mysticeti-core/src/state.rs b/crates/mysticeti-core/src/state.rs similarity index 100% rename from mysticeti-core/src/state.rs rename to crates/mysticeti-core/src/state.rs diff --git a/mysticeti-core/src/syncer.rs b/crates/mysticeti-core/src/syncer.rs similarity index 100% rename from mysticeti-core/src/syncer.rs rename to crates/mysticeti-core/src/syncer.rs diff --git a/mysticeti-core/src/synchronizer.rs b/crates/mysticeti-core/src/synchronizer.rs similarity index 100% rename from mysticeti-core/src/synchronizer.rs rename to crates/mysticeti-core/src/synchronizer.rs diff --git a/mysticeti-core/src/test_util.rs b/crates/mysticeti-core/src/test_util.rs similarity index 100% rename from mysticeti-core/src/test_util.rs rename to crates/mysticeti-core/src/test_util.rs diff --git a/mysticeti-core/src/threshold_clock.rs b/crates/mysticeti-core/src/threshold_clock.rs similarity index 100% rename from mysticeti-core/src/threshold_clock.rs rename to crates/mysticeti-core/src/threshold_clock.rs diff --git a/mysticeti-core/src/transactions_generator.rs b/crates/mysticeti-core/src/transactions_generator.rs similarity index 100% rename from mysticeti-core/src/transactions_generator.rs rename to crates/mysticeti-core/src/transactions_generator.rs diff --git a/mysticeti-core/src/types.rs b/crates/mysticeti-core/src/types.rs similarity index 100% rename from mysticeti-core/src/types.rs rename to crates/mysticeti-core/src/types.rs diff --git a/mysticeti-core/src/validator.rs b/crates/mysticeti-core/src/validator.rs similarity index 100% rename from mysticeti-core/src/validator.rs rename to crates/mysticeti-core/src/validator.rs diff --git a/mysticeti-core/src/wal.rs b/crates/mysticeti-core/src/wal.rs similarity index 100% rename from mysticeti-core/src/wal.rs rename to crates/mysticeti-core/src/wal.rs diff --git a/mysticeti/Cargo.toml b/crates/mysticeti/Cargo.toml similarity index 100% rename from mysticeti/Cargo.toml rename to crates/mysticeti/Cargo.toml diff --git a/mysticeti/src/main.rs b/crates/mysticeti/src/main.rs similarity index 100% rename from mysticeti/src/main.rs rename to crates/mysticeti/src/main.rs diff --git a/orchestrator/Cargo.toml b/crates/orchestrator/Cargo.toml similarity index 100% rename from orchestrator/Cargo.toml rename to crates/orchestrator/Cargo.toml diff --git a/orchestrator/assets/flamegraph.sh b/crates/orchestrator/assets/flamegraph.sh similarity index 100% rename from orchestrator/assets/flamegraph.sh rename to crates/orchestrator/assets/flamegraph.sh diff --git a/orchestrator/assets/grafana-dashboard.json b/crates/orchestrator/assets/grafana-dashboard.json similarity index 100% rename from orchestrator/assets/grafana-dashboard.json rename to crates/orchestrator/assets/grafana-dashboard.json diff --git a/orchestrator/assets/install_node_exporter.sh b/crates/orchestrator/assets/install_node_exporter.sh similarity index 100% rename from orchestrator/assets/install_node_exporter.sh rename to crates/orchestrator/assets/install_node_exporter.sh diff --git a/orchestrator/assets/node-config.json b/crates/orchestrator/assets/node-config.json similarity index 100% rename from orchestrator/assets/node-config.json rename to crates/orchestrator/assets/node-config.json diff --git a/orchestrator/assets/plot.py b/crates/orchestrator/assets/plot.py similarity index 100% rename from orchestrator/assets/plot.py rename to crates/orchestrator/assets/plot.py diff --git a/orchestrator/assets/settings.json b/crates/orchestrator/assets/settings.json similarity index 100% rename from orchestrator/assets/settings.json rename to crates/orchestrator/assets/settings.json diff --git a/orchestrator/readme.md b/crates/orchestrator/readme.md similarity index 100% rename from orchestrator/readme.md rename to crates/orchestrator/readme.md diff --git a/orchestrator/src/benchmark.rs b/crates/orchestrator/src/benchmark.rs similarity index 100% rename from orchestrator/src/benchmark.rs rename to crates/orchestrator/src/benchmark.rs diff --git a/orchestrator/src/client/aws.rs b/crates/orchestrator/src/client/aws.rs similarity index 100% rename from orchestrator/src/client/aws.rs rename to crates/orchestrator/src/client/aws.rs diff --git a/orchestrator/src/client/mod.rs b/crates/orchestrator/src/client/mod.rs similarity index 100% rename from orchestrator/src/client/mod.rs rename to crates/orchestrator/src/client/mod.rs diff --git a/orchestrator/src/client/vultr.rs b/crates/orchestrator/src/client/vultr.rs similarity index 100% rename from orchestrator/src/client/vultr.rs rename to crates/orchestrator/src/client/vultr.rs diff --git a/orchestrator/src/display.rs b/crates/orchestrator/src/display.rs similarity index 100% rename from orchestrator/src/display.rs rename to crates/orchestrator/src/display.rs diff --git a/orchestrator/src/error.rs b/crates/orchestrator/src/error.rs similarity index 100% rename from orchestrator/src/error.rs rename to crates/orchestrator/src/error.rs diff --git a/orchestrator/src/faults.rs b/crates/orchestrator/src/faults.rs similarity index 100% rename from orchestrator/src/faults.rs rename to crates/orchestrator/src/faults.rs diff --git a/orchestrator/src/logs.rs b/crates/orchestrator/src/logs.rs similarity index 100% rename from orchestrator/src/logs.rs rename to crates/orchestrator/src/logs.rs diff --git a/orchestrator/src/main.rs b/crates/orchestrator/src/main.rs similarity index 100% rename from orchestrator/src/main.rs rename to crates/orchestrator/src/main.rs diff --git a/orchestrator/src/measurement.rs b/crates/orchestrator/src/measurement.rs similarity index 100% rename from orchestrator/src/measurement.rs rename to crates/orchestrator/src/measurement.rs diff --git a/orchestrator/src/monitor.rs b/crates/orchestrator/src/monitor.rs similarity index 100% rename from orchestrator/src/monitor.rs rename to crates/orchestrator/src/monitor.rs diff --git a/orchestrator/src/orchestrator.rs b/crates/orchestrator/src/orchestrator.rs similarity index 100% rename from orchestrator/src/orchestrator.rs rename to crates/orchestrator/src/orchestrator.rs diff --git a/orchestrator/src/protocol/mod.rs b/crates/orchestrator/src/protocol/mod.rs similarity index 100% rename from orchestrator/src/protocol/mod.rs rename to crates/orchestrator/src/protocol/mod.rs diff --git a/orchestrator/src/protocol/mysticeti.rs b/crates/orchestrator/src/protocol/mysticeti.rs similarity index 100% rename from orchestrator/src/protocol/mysticeti.rs rename to crates/orchestrator/src/protocol/mysticeti.rs diff --git a/orchestrator/src/settings.rs b/crates/orchestrator/src/settings.rs similarity index 100% rename from orchestrator/src/settings.rs rename to crates/orchestrator/src/settings.rs diff --git a/orchestrator/src/ssh.rs b/crates/orchestrator/src/ssh.rs similarity index 100% rename from orchestrator/src/ssh.rs rename to crates/orchestrator/src/ssh.rs diff --git a/orchestrator/src/testbed.rs b/crates/orchestrator/src/testbed.rs similarity index 100% rename from orchestrator/src/testbed.rs rename to crates/orchestrator/src/testbed.rs diff --git a/third-party/minibytes/Cargo.toml b/crates/third-party/minibytes/Cargo.toml similarity index 100% rename from third-party/minibytes/Cargo.toml rename to crates/third-party/minibytes/Cargo.toml diff --git a/third-party/minibytes/LICENSE b/crates/third-party/minibytes/LICENSE similarity index 100% rename from third-party/minibytes/LICENSE rename to crates/third-party/minibytes/LICENSE diff --git a/third-party/minibytes/benches/bytes.rs b/crates/third-party/minibytes/benches/bytes.rs similarity index 100% rename from third-party/minibytes/benches/bytes.rs rename to crates/third-party/minibytes/benches/bytes.rs diff --git a/third-party/minibytes/src/bytes.rs b/crates/third-party/minibytes/src/bytes.rs similarity index 100% rename from third-party/minibytes/src/bytes.rs rename to crates/third-party/minibytes/src/bytes.rs diff --git a/third-party/minibytes/src/impls.rs b/crates/third-party/minibytes/src/impls.rs similarity index 100% rename from third-party/minibytes/src/impls.rs rename to crates/third-party/minibytes/src/impls.rs diff --git a/third-party/minibytes/src/lib.rs b/crates/third-party/minibytes/src/lib.rs similarity index 100% rename from third-party/minibytes/src/lib.rs rename to crates/third-party/minibytes/src/lib.rs diff --git a/third-party/minibytes/src/owners.rs b/crates/third-party/minibytes/src/owners.rs similarity index 100% rename from third-party/minibytes/src/owners.rs rename to crates/third-party/minibytes/src/owners.rs diff --git a/third-party/minibytes/src/serde.rs b/crates/third-party/minibytes/src/serde.rs similarity index 100% rename from third-party/minibytes/src/serde.rs rename to crates/third-party/minibytes/src/serde.rs diff --git a/third-party/minibytes/src/tests.rs b/crates/third-party/minibytes/src/tests.rs similarity index 100% rename from third-party/minibytes/src/tests.rs rename to crates/third-party/minibytes/src/tests.rs diff --git a/third-party/minibytes/src/text.rs b/crates/third-party/minibytes/src/text.rs similarity index 100% rename from third-party/minibytes/src/text.rs rename to crates/third-party/minibytes/src/text.rs diff --git a/docs/consensus-proof.txt b/docs/consensus-proof.txt deleted file mode 100644 index aa58f536..00000000 --- a/docs/consensus-proof.txt +++ /dev/null @@ -1,161 +0,0 @@ -The proof of safety and liveness for Mysticeti Consensus - -Brief description of scheme: -- Validators have stake that is stable throughout the epoch. -- Quorums are formed when validators with >2/3 stake support a decision. -- The protocol proceeds in rounds 0, 1, 2, -- Each round correct validators create a single block for that round, - referenced as (validator, round, digest). -- A block contains an ordered list of references to previous blocks, - and none to current or future round blocks. We call these blocks "included". -- A block contains at least a quorum of references to blocks - from the previoud round. -- A correct block starts with a reference to the previous block from the - creator validator. -- The system is initialized with blocks for round 0 from all - validators. -- A block also contains contents, which are playloads to be sequenced, - but otherwise play no role in the agreement protocol. - -Definition of block support - -A block A is supported by another (causally future) block B if A is the first -block from the (validator, round) of A that is in the causal history of B. The -concept of "first" is defined in relation to the order of included blocks in -the history of B, and defined recursivelly as follows: - -B supports all blocks supported in its included blocks in order. For each included -block X, B supports in order the blocks supported by the included block (X), and the -block X itself. If an included block supports a past block that conflicts with an -earlier supported block, the earlier remains supported and the later ignored. This -implements a depth first, right-to-left in includes, support collection. - -As a result two lemmas hold: -Lemma 1. A block only supports a single block from a given (authority, round). -Lemma 2. A correct node will only ever support in any of its blocks at most a single - (authority, round) block. -Lemma 3. Only a single block at a (val, round) will ever gather a quorum of support. - -Proofs: - -Lemma 1: -By the definition of support for a block only a single (val, round) block can be -supported from a future block. - -Lemma 2: -since a correct validator includes its last block first in any subsequent -block, the subsequent block initially supports all previously supported blocks, and -any additional blocks included supporting conflicting blocks, will not overwrite -this "earlier" support. Thus a validator will never change which (val, round) block -is supported once one is supported. - - -Lemma 3: -By quorum intersection, if two blocks A and A' with the same (val, round) -gather support, they intersect at at least one correct node. This means that the -correct node in one block supports A and in another block support A', which by -Lemma 2 means A = A'. - -Block Certified Support - -A block B certifies a casually included block A if the subgraph connecting A to B -contains 2f+1 blocks from distinct authorities that support A. Note that in this -calculation equivocating blocks may support different blocks, and yet they are -counted towards supporting each of the different blocks (not only the first is -counted as when we define block support.) - -The following lemmas hold: - -Lemma 4: -only a single block from an authority & round will be certified across -any future blocks. - -Lemma 5: -if a block B certifies a block A, any block C that includes B will -also certify A. - -Proofs: - -Lemma 4: A block can certify at most one (authority, round) block (Lemma 1). -Therefore, consider two blocks that certify different blocks for the same -authority round. They each contain in their history 2f+1 support for the -respective equivocating blocks they support. However this stake must intersect -on a correct node. A correct by lemma 2 will not support two different blocks -and therefore there is a contradiction that proves the lemma. - -Lemma 5: The block C contains the full history of block B, which contains -2f+1 support for block A, and therefore block C also certifies block A. - -Period, Leader rounds & Decision rounds - -The period (p > 1) is the number of rounds between leaders. Rounds with leaders are -p * k (for k = 1, 2, 3, ...) ie non-zero rounds divisible by the period. During these -rounds a validator is deterministically chosen by all nodes to act as a leader. The -round preceeding the leader round (ie p*(k+1) -1, for k = 1, 2, 3, 4) are called -decision rounds, since we decide based on blocks on these rounds whether to commit -a leader (retrospectively for round p*k) or not. We call these the leader for k and -the decision round for k. - -After a node passes a decision round for k (it has a quorum of blocks for -round p*(k+1) - 1, (recall that a quorum of blocks is needed before passing to the next round)), -it checks whether there is a quorum of certified support for a block (call "X") from -the leader at the leader round k (ie round k*p). If so the block ("X") is committed. - -When a leader at k is committed, the node goes back and checks for each leader Lk round -after the last commit: If the leader Lk is in the causal graph of the committed leader, and -and the decision round for Lk contains at least one block certifying the leader Lk -we first commit leader Lk. This continues until the last leader (that does have support) -is committed. - -Lemma 6a: -If at round x, 2f+1 blocks from distinct authorities certify a block A at a previous round -then any block in the next round will contain at least 1 block that certifies A at round x. - -Lemma 6b: -If at a round x, 2f+1 blocks from distinct authorities certify a block A at a previous -round, then all blocks at future rounds > x will certify that block. - -Lemma 7: -If some correct node commits a leader at round k, then all correct nodes will commit the -leader at round k before committing any later leaders. - -Theorem 8 (safety): -All correct nodes commit a consistent sequence of leaders (ie the commit of one is -a prefix/substring of the commit of another.) - -Theorem 9 (liveness): -All correct nodes eventually commit all leaders up to the end of the epoch. - -Lemma 10: -The full causal history of the final block to be committed will be included in the -commit. - -Proofs: - -Lemma 6a: -A block at round x+1 needs to link to 2f+1 blocks at round x. By quorum intersection -one of the 2f+1 blocks included must intersect with 1 honest block from the 2f+1 blocks -that certify A. - -Lemma 6b: A block at round x+1 at least one block that certifies A, by lemma 6a. -By lemma 5 since this included block certifies A all blocks at round x+1 will -also certify A. The argument applies recursivelly for round x+1, which also has 2f+1 -certified blocks for A, and so on for ever. - -Lemma 7: For the sake of contradiction, assume that if some correct node commits a leader -at round k, then there exists another correct node X that commits leader at round >k -without first committing the leader at round k. -Consider the immediately next leader k' (>k) committed by X. In X's view, either (i) the -committed leader k' does not contain the leader at round k in its causal graph, or (ii) none -of the blocks in the decision round for k certify the leader Lk. -(i) is a contradiction due to Lemma 6 and the fact that a block can not certify another block -without containing it in its causal graph. (ii) is also a contradiction because by definition -f+1 correct nodes certify Lk in its corresponding decision round. - -Theorem 8 (safety): consider two correct nodes with sequences that are not consistent. -Then consider the first leader on which they diverge in their commits. By lemma 7 if -one of them has committed the leader all other ones, will first commit this leader, -which means the committed leader where they diverge is the same. Leading to a -contradiction, proving the theorem. - -Theorem 9 (liveness): USE TIMEOUTS! \ No newline at end of file diff --git a/docs/epoch-change.txt b/docs/epoch-change.txt deleted file mode 100644 index 6fe3fe97..00000000 --- a/docs/epoch-change.txt +++ /dev/null @@ -1,56 +0,0 @@ -Owned-object-only transaction: -A block B is said to certify a transaction tx if the causal history of B -contains 2f+1 votes for tx. However, the block carries an overriding bit, -called epoch-change-bit, which when set to 1 (default set to 0), indicates that -the block does not certify any transaction, regardless of the causal history. -A validator can execute the transaction (asynchronously) as soon -as it sees 2f+1 votes for it. - -A transaction is considered final if in any view of the DAG, 2f+1 authorities -have published blocks which certify the transaction. - -Epoch Change -1. Epoch Change begins at a pre-determined commit, for example, when enough -ready messages from the new committee are sequenced. -2. Validator stops acquiring locks and casting votes. The epoch-change-bit in -validator's blocks is now set to 1 for all future rounds. Similar to steady -state, the validator's block references sufficient blocks (n-f) from previous -round including its own. -3. Once blocks from 2f+1 authorities, containing the epoch-change-bit, are -sequenced, epoch is considered closed. -4. Any continuing validators reset their object locks, and revert execution of -transactions for which no certifying block has been committed. - -Safety: -Finalised transactions are never reverted. -- All owned-object-only transactions have at least one certificate sequenced -before the epoch close. - -Proof. -It is sufficient to prove that all owned-object-only transactions -that are considered final (i.e. having certifying blocks from 2f+1 authorities) -have one certifying block sequenced in the current epoch. -(Additionally, note that no conflicting transaction can have a certifying block -by quorum intersection.) -For contradiction sake, assume that the epoch closed before any certifying -block for a finalised transaction tx could be sequenced. For the epoch to -close, 2f+1 nodes published a block with the epoch-change-bit set to 1. For the -transaction to be finalized, 2f+1 nodes published a block which certifies the -transaction. -By quorum intersection, one correct node published a block B1 certifying -transaction tx and block B2 with epoch-change-bit set to 1 such that B1 is not -present in the causal history of B2. Because a certifying block cannot have the -epoch-change-bit set to 1, B1 is necessarily published in an earlier round than -that of B2. B1 is therefore contained in the causal history of B2, which is a -contradiction. - -Liveness: -Epoch change process terminates for all correct validators eventually. - -Proof. -Inherited from liveness of underlying BA. - -When does a validator shut down sync? -A correct validator should not shut down sync as soon as it considers the epoch -closed. We instead wait for f+1 validators to have considered the epoch closed, -and then stop the sync. \ No newline at end of file diff --git a/docs/spec.txt b/docs/spec.txt deleted file mode 100644 index 29650c67..00000000 --- a/docs/spec.txt +++ /dev/null @@ -1,171 +0,0 @@ -Mysticeti: design decisions & latest architecture - -Objective: Have a single simple DAG based broadcast structure, allowing validators to: -(1) share transactions once, and disseminate them to all, (2) share votes on transactions -as part of a consistent broadcast based protocol, once per node (3) share potential -conflicting transactions and (4) allow agreement on consecutive commit sets of transactions. -Thus the design combines and integrates the Sui fast path & the narwhal-based consensus path -in Sui. - -The scaling logic is as follows: Mysticeti is used for transport of transactions and votes, -however the logic by which a validator votes or rejects a transaction is external to the -mysticeti component. As a result, we can shard transactions by txid and use multiple mysticeti -instances to broadcast the transactions and votes relating to them. All of the instances -vote according to a common set of object locks, for owned objects. For shared objects -commits between instances been to be used in lock step to create a common sequence. - -Issues we are trying to mitigate: - -- Mass of redundant transaction sends: currently each validator receives the transaction -3 times. One to sign it, one as a certificate, and then again as part of consensus. We want to -only share transaction bodies once. - -- Mass of signatures and verifications: currently for each transaction clients / full nodes -need to create certiicates, involving each validator signing each signature, and checking a -certificate which is either BLS (expensive) or linear in the number of validators. We want to -drmatically reduce the cost of signature creation and certification, and decouple it from the -number of transactions (couple it with latency instead). - -- Separate consistent broadcast and consensus leads to the need to maintain separate protocols -separate network, with different retry / sync / connection management sub systems. Integrating -these too deeply is hard to maintain as complexity increases; keeing modules separate means that -they are poorly coordinated and compete with each other for resources. - -- The choice of which validator places a certificate into consensus has become complex, due -to the longer delay between expecting a transaction and seeing it, as well as the fact that all -validators are given the certificate in Sui. A model by which one validator is responsible for -puting a transaction into the system, with a very short delay to observe correct inclusion is -simpler and better. - -The DAG creation and invariants: - -A mysticeti block contains: -- A creator authority, a round number and a digest (acts as a reference for the block) -- Base statements: transaction payloads, or transaction votes. -- Included references: references that the block depends on, which need to be processed - before this block is processed. -- A signature from the creator over all the data. - -Some key invariants hold to ensure the validtiy of a block: all included references are -of a lower round; at least >2/3 stake from round r - 1 are included in a block at round r -(lower round references may also be included). -The authority is known and the signature valid over all data in the block. A correct -block should contain votes only on transactions included previously in this block, or -any included blocks (transitivelly). - -DAG processing: Certification - -As a node receives blocks it processesed them in causal order ensuring included references -are processed before each block refering to them. A the base statements of each block are -processed by accumulating votes, positive and negative, for each seen transaction. When >2/3 -positive votes are seen the transaction is considered certififed; A correct node can also -reject a transaction with an optional conflicting transaction. Correct nodes never change -their votes (between accept and conflict). - -As blocks are processed by a validator are included in the next block of the validator as -references. Any transactions or votes presented by the validator are also included in the -next block as base statements. A process of reference compression allows a validator to only -include the causally latest reference allowing others to infer previous ones. - -End of epoch: once a node decides to reach the end of epoch, it needs to vote on all -transactions that were sequenced in its own history. By default it rejects all transactions -that it may not accept. Then for all certified transactions it continues to run the -protocol until they are sequenced, or until >2/3 close epoch transactions are seen. When all -transactions certified locally are sequenced it sends its end-of-epoch transaction. - -DAG processing: Consensus - -We determine a period, ie every how many rounds we elect a leader ( so if period is 3, we elect -at rounds 0, 3, 6, ...). We consider that a block "votes" for another block if the other -block is included in its history. Only the first block from an (authority, round) included -direcly or indirecly is "voted" for. When a block votes for a past block we consider the -creator authority or the authority that included it in a block votes for it. - -We call every round period * k - 1 (for k = 1, 2, 3, ...) a decision round. We look at how many -votes blocks at round period * (k -1) have. If a block has received votes from >2/3 validators -by stake in the history of a block we consider it certified. If the leader block for k is certified -by >2/3 blocks in the decision round for k we commit it. - -When a leader at round k is committed, we consider all leaders between the last committed leader -and the leader at k. If the leader k' < k is certified by at least one block in its decision round -within the causal history of k, we commit it first, and then consider the next one. - -From commits to executions: - -As soon as a transaction is certified, and only contains owned objects, it may be executed by the -validator. The validator then includes in its block sufficient evidence to ensure all will eventually -execute. This is also sufficient evidence to ensure that eventually it will be sequenced. - -If a certified transaction contains shared objects, the certificate needs to be included in a commit -at the time of the commit it is assigned a version number of each shared object, and then it may be -executed. - -A validator may not vote to close the epoch unless all transactions that it has observed as certified -are executed and sequenced in a causal order. However, a validator may vote to reject transactions after -some time, to allow for the epoch to close. - - -Sync & Net protocol: - -All communications -are done as a request / response (there is no push as in Sui/NW) and we try to unify the -sync and common paths as much as possible. In the common case all nodes send a request to all -other nodes for their blocks after a certain round number, and may request any block -on a need by need basis that is inlcuded in a block from the party that created it or included it. - -We follow a 2-level sync protocol. Each commit of the consensus makes a commit -set of blocks, and we can request to sync up to a commit set by round number. Commit -sets are shared between validators so one can request them from others. For the very latest -blocks we maintain a sussinct structure of blocks not in a commit set, and exchange it to -allow another node to send the missing blocks, or request more blocks. - -TODO Things we need to co-design: -- sync recovery -- persistance points -- safe close -- high perf interface to other parts -- network design -- crash recovery -- batch async client api to interact with system - -Key APIs: - -Core-Mysticeti API - -This is the interface that the validator code uses to "talk to" the mysticeti logic that runs -on the validator. - -- BroadcastTransaction(transactions: Vec) : put a number of transactions into the - broadcast channel, so that other validators can vote on them. A validator should only place a - transaction in the channel if it is ready to vote for it positivelly. -- BroadcastVotes(votes: Vec<(TransactionId, Votes)>) : place a number of positive or negative - votes from itself associated with specific transactions into the broadcast channel. Other - validators will receive the votes and tally them to make certificates. -- ProcessBlocks( blocks: Vec) : the core asks mysticeti to process a number - of blocks from other validators. -- Shutdown : asks the mysticeti logic to close the channel, after it has sent or sequenced all - data it has committed to send or sequence. - -Read APIs allow the core to determine: -- Blocks missing. -- Transactions received requiring votes -- Transactions that have been certified. -- Blocks committed and commit sets of transactions. - -Validator-Validator API - -This is the networked interface that mysticeti logic on a validator uses to "talk to" the -mysticeti logic on a different validator. It all takes the form of RPC request / response, but -some responses are streamed and use a long poll. - -- Subscribe at round number: request a validator at a round number, and the Validator - will send its own blocks after that round number, for a specified number of blocks. -- Subscribe by hash: requrest a blocks from a validator using a set of hashes. These blocks - may be created by others but the validator has included them. -- Get commit blocks by round number: request all blocks between two committed rounds, by - round numbers for start and end. - -Note that there are not push APIs. All APIs are unreliable, in that they may fail -without internal re-transmission. The reliability of the protocol is not based on a -per message reliable transmission, but rather on a repetition of the overall protocol -loop. \ No newline at end of file diff --git a/licensesnip.config.jsonc b/licensesnip.config.jsonc new file mode 100644 index 00000000..454f2984 --- /dev/null +++ b/licensesnip.config.jsonc @@ -0,0 +1,8 @@ +{ + "use_gitignore": true, + "file_types": { + "move": { + "before_line": "// " + } + } +} diff --git a/rust-toolchain b/rust-toolchain index 698c6ba7..6d31674c 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1,3 @@ -1.72.1 \ No newline at end of file +[toolchain] +channel = "1.78" +components = ["clippy", "rustfmt"] diff --git a/check.sh b/scripts/check.sh similarity index 100% rename from check.sh rename to scripts/check.sh diff --git a/dryrun.sh b/scripts/dryrun.sh similarity index 100% rename from dryrun.sh rename to scripts/dryrun.sh diff --git a/tarpaulin.toml b/tarpaulin.toml new file mode 100644 index 00000000..50b9d057 --- /dev/null +++ b/tarpaulin.toml @@ -0,0 +1,12 @@ +[default] +workspace = true +skip-clean = true +run-types = ["Bins", "Doctests", "Examples", "Lib", "Tests"] +out = ["Html", "Xml"] +# Don't include test and benchmark code in the coverage result. +exclude-files = [ + "crates/**/benches/**/*", + "crates/**/tests/**/*", + "crates/**/test_utils/**/*", +] +args = ["--include-ignored"]