Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into ab/sqlite
Browse files Browse the repository at this point in the history
  • Loading branch information
imabdulbasit committed Nov 20, 2024
2 parents 561d24b + 2822f98 commit c7190ad
Show file tree
Hide file tree
Showing 12 changed files with 145 additions and 136 deletions.
20 changes: 0 additions & 20 deletions .github/workflows/benchmark-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,13 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Fix submodule permissions check
run: |
git config --global --add safe.directory '*'
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1

- name: Install just command runner
run: |
sudo snap install --edge --classic just
just --version
- name: Checkout Repository
uses: actions/checkout@v4
with:
submodules: recursive

- name: Enable Rust Caching
uses: Swatinem/rust-cache@v2
Expand Down Expand Up @@ -76,17 +67,8 @@ jobs:
build-arm:
runs-on: buildjet-16vcpu-ubuntu-2204-arm
steps:
- name: Fix submodule permissions check
run: |
git config --global --add safe.directory '*'
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1

- name: Checkout Repository
uses: actions/checkout@v4
with:
submodules: recursive

- name: Enable Rust Caching
uses: Swatinem/rust-cache@v2
Expand Down Expand Up @@ -144,8 +126,6 @@ jobs:
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
submodules: recursive

- name: Download executables AMD
uses: actions/download-artifact@v4
Expand Down
35 changes: 35 additions & 0 deletions .github/workflows/build-without-lockfile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Build without committed Cargo.lock

on:
push:
branches:
- main
- release-*
tags:
# YYYYMMDD
- "20[0-9][0-9][0-1][0-9][0-3][0-9]*"
schedule:
- cron: "0 0 * * 1"
pull_request:
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build-ignore-lockfile:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Enable Rust Caching
uses: Swatinem/rust-cache@v2
with:
prefix-key: v1-rust

- name: Build without committed Cargo.lock
run: |
cargo generate-lockfile
cargo check --all-features --all-targets
20 changes: 0 additions & 20 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,13 @@ jobs:
steps:
- uses: rui314/setup-mold@v1

- name: Fix submodule permissions check
run: |
git config --global --add safe.directory '*'
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1

- name: Install just command runner
run: |
sudo snap install --edge --classic just
just --version
- name: Checkout Repository
uses: actions/checkout@v4
with:
submodules: recursive

- name: Enable Rust Caching
uses: Swatinem/rust-cache@v2
Expand Down Expand Up @@ -101,17 +92,8 @@ jobs:
steps:
- uses: rui314/setup-mold@v1

- name: Fix submodule permissions check
run: |
git config --global --add safe.directory '*'
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1

- name: Checkout Repository
uses: actions/checkout@v4
with:
submodules: recursive

- name: Enable Rust Caching
uses: Swatinem/rust-cache@v2
Expand Down Expand Up @@ -186,8 +168,6 @@ jobs:
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
submodules: recursive

- name: Download executables AMD
uses: actions/download-artifact@v4
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/build_static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,6 @@ jobs:
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
submodules: recursive

- name: Download executables AMD
uses: actions/download-artifact@v4
Expand Down
5 changes: 0 additions & 5 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@ jobs:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly

- uses: dtolnay/rust-toolchain@nightly

- name: Enable Rust Caching
Expand Down
9 changes: 1 addition & 8 deletions .github/workflows/slowtest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,14 @@ jobs:
slow-tests-sqlite:
runs-on: ubuntu-latest
steps:
- name: Fix submodule permissions check
run: |
git config --global --add safe.directory '*'
# These tests need the `anvil` binary provided by foundry
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly

- uses: taiki-e/install-action@nextest

- name: Checkout Repository
uses: actions/checkout@v4
with:
submodules: recursive

- name: Configure Environment
run: PATH="$PWD/target/release:$PATH"
Expand Down
29 changes: 1 addition & 28 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ jobs:
- uses: rui314/setup-mold@v1

- uses: actions/checkout@v4
with:
submodules: recursive

- name: Install nextest
uses: taiki-e/install-action@nextest

Expand Down Expand Up @@ -83,8 +82,6 @@ jobs:
- uses: rui314/setup-mold@v1

- uses: actions/checkout@v4
with:
submodules: recursive

- name: Enable Rust Caching
uses: Swatinem/rust-cache@v2
Expand Down Expand Up @@ -131,18 +128,10 @@ jobs:
needs: build-test-artifacts-postgres
runs-on: ubuntu-latest
steps:
- name: Fix submodule permissions check
run: |
git config --global --add safe.directory '*'
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly

- uses: actions/checkout@v4
with:
submodules: recursive

- name: Install nextest
uses: taiki-e/install-action@nextest
Expand Down Expand Up @@ -206,18 +195,7 @@ jobs:
- name: Configure PATH
run: PATH="$PWD/target/debug:$PATH"

- name: Fix submodule permissions check
run: |
git config --global --add safe.directory '*'
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly

- uses: actions/checkout@v4
with:
submodules: recursive

- uses: taiki-e/install-action@nextest

Expand Down Expand Up @@ -256,15 +234,10 @@ jobs:
needs: build-test-bins
runs-on: ubuntu-latest
steps:
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1

- name: Install Nix
uses: cachix/install-nix-action@V27

- uses: actions/checkout@v4
with:
submodules: recursive

- name: Download archive
uses: actions/download-artifact@v4
Expand Down
34 changes: 0 additions & 34 deletions contracts/.github/workflows/test.yml

This file was deleted.

8 changes: 8 additions & 0 deletions sequencer/api/node.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[route.stake_table_current]
PATH = ["stake-table/current"]
DOC = "Get the stake table for the current epoch"

[route.stake_table]
PATH = ["stake-table/:epoch_number"]
":epoch_number" = "Integer"
DOC = "Get the stake table for the given epoch"
46 changes: 44 additions & 2 deletions sequencer/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use async_lock::RwLock;
use async_once_cell::Lazy;
use async_trait::async_trait;
use committable::{Commitment, Committable};
use data_source::{CatchupDataSource, SubmitDataSource};
use data_source::{CatchupDataSource, StakeTableDataSource, SubmitDataSource};
use derivative::Derivative;
use espresso_types::{
retain_accounts, v0::traits::SequencerPersistence, v0_3::ChainConfig, AccountQueryData,
Expand All @@ -25,9 +25,14 @@ use hotshot_types::{
event::Event,
light_client::StateSignatureRequestBody,
network::NetworkConfig,
traits::{network::ConnectedNetwork, node_implementation::Versions, ValidatedState as _},
traits::{
network::ConnectedNetwork,
node_implementation::{NodeType, Versions},
ValidatedState as _,
},
utils::{View, ViewInner},
};
use hotshot_types::{stake_table::StakeTableEntry, traits::election::Membership};
use jf_merkle_tree::MerkleTreeScheme;
use std::sync::Arc;

Expand Down Expand Up @@ -156,6 +161,43 @@ impl<N: ConnectedNetwork<PubKey>, D: Send + Sync, V: Versions, P: SequencerPersi
}
}

impl<N: ConnectedNetwork<PubKey>, D: Sync, V: Versions, P: SequencerPersistence>
StakeTableDataSource<SeqTypes> for StorageState<N, P, D, V>
{
/// Get the stake table for a given epoch or the current epoch if not provided
async fn get_stake_table(
&self,
epoch: Option<<SeqTypes as NodeType>::Epoch>,
) -> Vec<StakeTableEntry<<SeqTypes as NodeType>::SignatureKey>> {
self.as_ref().get_stake_table(epoch).await
}
}

impl<N: ConnectedNetwork<PubKey>, V: Versions, P: SequencerPersistence>
StakeTableDataSource<SeqTypes> for ApiState<N, P, V>
{
/// Get the stake table for a given epoch or the current epoch if not provided
async fn get_stake_table(
&self,
epoch: Option<<SeqTypes as NodeType>::Epoch>,
) -> Vec<StakeTableEntry<<SeqTypes as NodeType>::SignatureKey>> {
// Get the epoch from the argument or the current epoch if not provided
let epoch = if let Some(epoch) = epoch {
epoch
} else {
self.consensus().await.read().await.cur_epoch().await
};

self.consensus()
.await
.read()
.await
.memberships
.quorum_membership
.stake_table(epoch)
}
}

impl<N: ConnectedNetwork<PubKey>, V: Versions, P: SequencerPersistence> SubmitDataSource<N, P>
for ApiState<N, P, V>
{
Expand Down
Loading

0 comments on commit c7190ad

Please sign in to comment.