Skip to content

Start implementing bootstore: Replicated storage required for rack unlock #1656

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 28 commits into from
Sep 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
e635e68
wip
andrewjstone Aug 26, 2022
96b7092
wip
andrewjstone Aug 26, 2022
456bc9d
very wip
andrewjstone Aug 27, 2022
9a47e27
wip
andrewjstone Aug 27, 2022
0247102
wip
andrewjstone Aug 28, 2022
32728d2
wip
andrewjstone Aug 28, 2022
e89f3fd
back to a crate
andrewjstone Aug 28, 2022
0b6b45d
wip
andrewjstone Aug 28, 2022
df245ff
wip
andrewjstone Aug 29, 2022
f166607
randomize db names
andrewjstone Aug 29, 2022
b817d51
wip
andrewjstone Aug 29, 2022
5f4f9a8
verify prepare share digest matches commit
andrewjstone Aug 30, 2022
96d4ee0
wip
andrewjstone Aug 30, 2022
28e2eed
start adding node and messages
andrewjstone Aug 31, 2022
2d2d86b
more node stuff
andrewjstone Aug 31, 2022
1c6d140
remove server
andrewjstone Aug 31, 2022
b89a28f
fix typo
andrewjstone Aug 31, 2022
e3a9855
Return NodeResponse from Node::handle
andrewjstone Sep 1, 2022
07e043e
Use a result directly in `NodeResposne
andrewjstone Sep 1, 2022
10058ed
Remove key_share_commits table
andrewjstone Sep 1, 2022
a9ac17c
Use :memory: db for tests
andrewjstone Sep 1, 2022
815f8e1
Use bcs instead of json for serialization
andrewjstone Sep 1, 2022
181ce37
Remove boostore from workspace default-members until further along
andrewjstone Sep 1, 2022
452dcec
fix unused variable/code warnings
andrewjstone Sep 1, 2022
83700cc
cleanup logs in tests
andrewjstone Sep 2, 2022
9c624d0
debug kill -9 shenanigans
andrewjstone Sep 6, 2022
37869f4
remove buildomat debugging tools
andrewjstone Sep 6, 2022
1b63704
Fix build by relying on pq-sys dep
andrewjstone Sep 6, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[workspace]
members = [
"bootstore",
"common",
"ddm-admin-client",
"deploy",
Expand Down
34 changes: 34 additions & 0 deletions bootstore/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[package]
name = "bootstore"
description = "Storage required for rack unlock"
version = "0.1.0"
edition = "2021"
license = "MPL-2.0"

[build-dependencies.omicron-rpaths]
path = "../rpaths"

[dependencies]
bcs = "0.1.3"
derive_more = "0.99.17"
diesel = { version = "2.0.0-rc.1", features = ["sqlite", "uuid"] }
p256 = "0.9.0"
# See omicron-rpaths for more about the "pq-sys" dependency.
# We don't actually need `pq-sys` here, other than to satisfy
# `[build-dependencies.omicron-rpaths]`, which are needed by `omicron-test-
# utils`. Unfortunately, it doesn't appear possible to put the `pq-sys` dep
# only in `[dev-dependencies]`.
pq-sys = "*"
rand = { version = "0.8.5", features = ["getrandom"] }
serde = { version = "1.0", features = [ "derive" ] }
sha3 = "0.10.1"
slog = { version = "2.5", features = [ "max_level_trace", "release_max_level_debug" ] }
sprockets-common = { git = "http://github.com/oxidecomputer/sprockets", rev = "0361fd13ff19cda6696242fe40f1325fca30d3d1" }
sprockets-host = { git = "http://github.com/oxidecomputer/sprockets", rev = "0361fd13ff19cda6696242fe40f1325fca30d3d1" }
thiserror = "1.0"
uuid = { version = "1.1.0", features = [ "serde", "v4" ] }
vsss-rs = { version = "2.0.0", default-features = false, features = ["std"] }

[dev-dependencies]
bincode = "1.3.3"
omicron-test-utils = { path = "../test-utils" }
10 changes: 10 additions & 0 deletions bootstore/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

// See omicron-rpaths for documentation.
// NOTE: This file MUST be kept in sync with the other build.rs files in this
// repository.
fn main() {
omicron_rpaths::configure_default_omicron_rpaths();
}
137 changes: 137 additions & 0 deletions bootstore/src/db/macros.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

//! Macros used to create ToSql and FromSql impls required by Diesel

/// Shamelessly stolen from buildomat/common/src/db.rs
/// Thanks @jmc
macro_rules! bcs_new_type {
($name:ident, $mytype:ty) => {
#[derive(
Clone, Debug, FromSqlRow, diesel::expression::AsExpression,
)]
#[diesel(sql_type = diesel::sql_types::Binary)]
pub struct $name(pub $mytype);

impl ToSql<diesel::sql_types::Binary, diesel::sqlite::Sqlite> for $name
where
Vec<u8>: ToSql<diesel::sql_types::Binary, diesel::sqlite::Sqlite>,
{
fn to_sql(
&self,
out: &mut diesel::serialize::Output<diesel::sqlite::Sqlite>,
) -> diesel::serialize::Result {
out.set_value(bcs::to_bytes(&self.0)?);
Ok(diesel::serialize::IsNull::No)
}
}

impl<DB> FromSql<diesel::sql_types::Binary, DB> for $name
where
DB: diesel::backend::Backend,
Vec<u8>: FromSql<diesel::sql_types::Binary, DB>,
{
fn from_sql(
bytes: diesel::backend::RawValue<DB>,
) -> diesel::deserialize::Result<Self> {
Ok($name(bcs::from_bytes(&Vec::<u8>::from_sql(bytes)?)?))
}
}

impl From<$name> for $mytype {
fn from(t: $name) -> Self {
t.0
}
}

impl From<$mytype> for $name {
fn from(t: $mytype) -> $name {
$name(t)
}
}

impl std::ops::Deref for $name {
type Target = $mytype;

fn deref(&self) -> &Self::Target {
&self.0
}
}
};
}

macro_rules! array_new_type {
($name:ident, $len:expr) => {
#[derive(
PartialEq,
Clone,
Debug,
FromSqlRow,
diesel::expression::AsExpression,
)]
#[diesel(sql_type = diesel::sql_types::Binary)]
pub struct $name(pub [u8; $len]);

impl ToSql<diesel::sql_types::Binary, diesel::sqlite::Sqlite> for $name
where
Vec<u8>: ToSql<diesel::sql_types::Binary, diesel::sqlite::Sqlite>,
{
fn to_sql(
&self,
out: &mut diesel::serialize::Output<diesel::sqlite::Sqlite>,
) -> diesel::serialize::Result {
let mut copy = vec![0; $len];
copy.copy_from_slice(&self.0[..]);
out.set_value(copy);
Ok(diesel::serialize::IsNull::No)
}
}

impl<DB> FromSql<diesel::sql_types::Binary, DB> for $name
where
DB: diesel::backend::Backend,
Vec<u8>: FromSql<diesel::sql_types::Binary, DB>,
{
fn from_sql(
bytes: diesel::backend::RawValue<DB>,
) -> diesel::deserialize::Result<Self> {
let read_bytes = Vec::<u8>::from_sql(bytes)?;
if read_bytes.len() != $len {
return Err(format!(
"Invalid length. Expected: {}, Actual: {}",
$len,
read_bytes.len()
)
.into());
}
let mut out = [0u8; $len];
out.copy_from_slice(&read_bytes[..]);
Ok($name(out))
}
}

impl From<$name> for [u8; $len] {
fn from(t: $name) -> Self {
t.0
}
}

impl From<[u8; $len]> for $name {
fn from(t: [u8; $len]) -> $name {
$name(t)
}
}

impl std::ops::Deref for $name {
type Target = [u8; $len];

fn deref(&self) -> &Self::Target {
&self.0
}
}
};
}

pub(crate) use array_new_type;
pub(crate) use bcs_new_type;
Loading