Skip to content

Commit

Permalink
updates to reserve-auditor backend to build on MacOS (#45)
Browse files Browse the repository at this point in the history
* uprev toolchain, mobilecoin submodule, and dependencies to build on apple silicon
* cargo fmt fixes
* fix rust-toolchain file format
* use curve25519-dalek version 4.1.1
* canonicalize PartialOrd for EthAddr
* sort Cargo.toml to pass lint
* clean up commented out statements
* use expect() instead of unwrap()
  • Loading branch information
holtzman authored Feb 29, 2024
1 parent 100c458 commit 708f418
Show file tree
Hide file tree
Showing 13 changed files with 1,069 additions and 625 deletions.
1,606 changes: 1,023 additions & 583 deletions Cargo.lock

Large diffs are not rendered by default.

36 changes: 14 additions & 22 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,17 @@ members = ["api"]
exclude = ["./mobilecoin"]

[dependencies]

chrono = { version = "0.4", features = ["serde"] }
clap = { version = "3.2", features = ["derive", "env"] }
# Override diesel dependency with our fork, to statically link SQLite.
diesel = { version = "1.4", features = ["sqlite-bundled", "r2d2", "chrono"] }
diesel_migrations = { version = "1.4", features = ["sqlite"] }
displaydoc = "0.2"
grpcio = "0.13.0"
hex = "0.4"
hostname = "0.3.1"
lazy_static = "1.4"
mc-account-keys = { path = "mobilecoin/account-keys" }
mc-api = { path = "mobilecoin/api" }
mc-blockchain-types = { path = "mobilecoin/blockchain/types" }
Expand All @@ -30,17 +41,6 @@ mc-util-parse = { path = "mobilecoin/util/parse" }
mc-util-serial = { path = "mobilecoin/util/serial" }
mc-util-uri = { path = "mobilecoin/util/uri" }
mc-watcher = { path = "mobilecoin/watcher" }

chrono = { version = "0.4", features = ["serde"] }
clap = { version = "3.2", features = ["derive", "env"] }
# Override diesel dependency with our fork, to statically link SQLite.
diesel = { version = "1.4", features = ["sqlite-bundled", "r2d2", "chrono"] }
diesel_migrations = { version = "1.4", features = ["sqlite"] }
displaydoc = "0.2"
grpcio = "0.12.1"
hex = "0.4"
hostname = "0.3.1"
lazy_static = "1.4"
prost = { version = "0.10", default-features = false, features = [
"prost-derive",
] }
Expand Down Expand Up @@ -100,28 +100,20 @@ lto = "thin"
# Fork and rename to use "OG" dalek-cryptography with latest dependencies.
bulletproofs-og = { git = "https://github.com/mobilecoinfoundation/bulletproofs.git", rev = "9abfdc054d9ba65f1e185ea1e6eff3947ce879dc" }

curve25519-dalek = { git = "https://github.com/dalek-cryptography/curve25519-dalek", rev = "99c0520aa79401b69fb51d38172cd58c6a256cfb" }

# Fix issues with recent nightlies, bump curve25519-dalek version
ed25519-dalek = { git = "https://github.com/dalek-cryptography/ed25519-dalek.git", rev = "2931c688eb11341a1145e257bc41d8ecbe36277c" }

# mbedtls patched to allow certificate verification with a profile
mbedtls = { git = "https://github.com/mobilecoinfoundation/rust-mbedtls.git", rev = "98d3af413c1e23ea89cc5f41ab4dddb1944405af" }
mbedtls-sys-auto = { git = "https://github.com/mobilecoinfoundation/rust-mbedtls.git", rev = "98d3af413c1e23ea89cc5f41ab4dddb1944405af" }
mbedtls = { git = "https://github.com/mobilecoinfoundation/rust-mbedtls.git", rev = "f82523478a1dd813ca381c190175355d249a8123" }
mbedtls-sys-auto = { git = "https://github.com/mobilecoinfoundation/rust-mbedtls.git", rev = "f82523478a1dd813ca381c190175355d249a8123" }

# Override lmdb-rkv for a necessary bugfix (see https://github.com/mozilla/lmdb-rs/pull/80)
lmdb-rkv = { git = "https://github.com/mozilla/lmdb-rs", rev = "df1c2f5" }

# Fork and rename to use "OG" dalek-cryptography.
schnorrkel-og = { git = "https://github.com/mobilecoinfoundation/schnorrkel.git", rev = "b76d8c3a50671b08af0874b25b2543d3302d794d" }
schnorrkel-og = { git = "https://github.com/mobilecoinfoundation/schnorrkel.git", rev = "049bf9d30f3bbe072e2ad1b5eefdf0f3c851215e" }

# Fixes the following:
# * Allow enabling `serde/std` without also requiring `serde_cbor/std` to be enabled.
# See: https://github.com/pyfisch/cbor/pull/198
serde_cbor = { git = "https://github.com/mobilecoinofficial/cbor", rev = "4c886a7c1d523aae1ec4aa7386f402cb2f4341b5" }

# Fix issues with recent nightlies, bump curve25519-dalek version
x25519-dalek = { git = "https://github.com/mobilecoinfoundation/x25519-dalek.git", rev = "4fbaa3343301c62cfdbc3023c9f485257e6b718a" }

# Override diesel dependency with our fork, to statically link SQLite.
diesel = { git = "https://github.com/mobilecoinofficial/diesel", rev = "026f6379715d27c8be48396e5ca9059f4a263198" }
10 changes: 5 additions & 5 deletions api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ edition = "2021"
links = "mc-reserve-auditor-api"

[dependencies]

futures = "0.3"
grpcio = "0.13.0"
mc-api = { path = "../mobilecoin/api" }
mc-util-serial = { path = "../mobilecoin/util/serial" }
mc-util-uri = { path = "../mobilecoin/util/uri" }

futures = "0.3"
grpcio = "0.12.1"
protobuf = "2.27.1"

[build-dependencies]
mc-util-build-grpc = { path = "../mobilecoin/util/build/grpc" }
mc-util-build-script = { path = "../mobilecoin/util/build/script" }

cargo-emit = "0.2.1"
mc-util-build-grpc = { path = "../mobilecoin/util/build/grpc" }
mc-util-build-script = { path = "../mobilecoin/util/build/script" }
2 changes: 1 addition & 1 deletion mobilecoin
Submodule mobilecoin updated 858 files
2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1 +1 @@
nightly-2023-01-04
nightly-2023-10-01
6 changes: 5 additions & 1 deletion src/convert/gnosis_safe_deposit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ impl From<&DbGnosisSafeDeposit> for ProtoGnosisSafeDeposit {
dst.set_token_addr(src.token_addr().to_string());
dst.set_amount(src.amount());
dst.set_expected_mc_mint_tx_nonce_hex(src.expected_mc_mint_tx_nonce_hex().to_string());
dst.set_execution_date(src.execution_date().timestamp_nanos() as u64);
dst.set_execution_date(
src.execution_date()
.timestamp_nanos_opt()
.expect("Invalid execution_date stored in database") as u64,
);
dst
}
}
Expand Down
6 changes: 5 additions & 1 deletion src/convert/gnosis_safe_withdrawal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ impl TryFrom<&DbGnosisSafeWithdrawal> for ProtoGnosisSafeWithdrawal {
dst.set_to_addr(src.to_addr().to_string());
dst.set_amount(src.amount());
dst.set_mc_tx_out_pub_key((&src.mc_tx_out_public_key()?).into());
dst.set_execution_date(src.execution_date().timestamp_nanos() as u64);
dst.set_execution_date(
src.execution_date()
.timestamp_nanos_opt()
.expect("Invalid execution_date stored in database") as u64,
);
Ok(dst)
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/db/models/burn_tx_out.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ impl BurnTxOut {

/// Get block timestamp.
pub fn block_timestamp(&self) -> Option<DateTime<Utc>> {
self.block_timestamp.map(|ts| DateTime::from_utc(ts, Utc))
self.block_timestamp
.map(|ts| DateTime::from_naive_utc_and_offset(ts, Utc))
}

/// Get token id.
Expand Down
2 changes: 1 addition & 1 deletion src/db/models/gnosis_safe_deposit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ impl GnosisSafeDeposit {

/// Get execution date.
pub fn execution_date(&self) -> DateTime<Utc> {
DateTime::from_utc(self.execution_date, Utc)
DateTime::from_naive_utc_and_offset(self.execution_date, Utc)
}

/// Get ethereum transaction value.
Expand Down
2 changes: 1 addition & 1 deletion src/db/models/gnosis_safe_withdrawal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ impl GnosisSafeWithdrawal {

/// Get execution date.
pub fn execution_date(&self) -> DateTime<Utc> {
DateTime::from_utc(self.execution_date, Utc)
DateTime::from_naive_utc_and_offset(self.execution_date, Utc)
}

/// Get ethereum transaction value.
Expand Down
3 changes: 2 additions & 1 deletion src/db/models/mint_config_tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ impl MintConfigTx {

/// Get block timestamp.
pub fn block_timestamp(&self) -> Option<DateTime<Utc>> {
self.block_timestamp.map(|ts| DateTime::from_utc(ts, Utc))
self.block_timestamp
.map(|ts| DateTime::from_naive_utc_and_offset(ts, Utc))
}

/// Get token id.
Expand Down
3 changes: 2 additions & 1 deletion src/db/models/mint_tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ impl MintTx {

/// Get block timestamp.
pub fn block_timestamp(&self) -> Option<DateTime<Utc>> {
self.block_timestamp.map(|ts| DateTime::from_utc(ts, Utc))
self.block_timestamp
.map(|ts| DateTime::from_naive_utc_and_offset(ts, Utc))
}

/// Get token id.
Expand Down
13 changes: 7 additions & 6 deletions src/gnosis/eth_data_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use mc_util_from_random::{CryptoRng, FromRandom, RngCore};
use serde::{Deserialize, Serialize};
use serde_with::{DeserializeFromStr, SerializeDisplay};
use std::{
cmp::Ordering,
fmt,
hash::{Hash, Hasher},
str::FromStr,
Expand Down Expand Up @@ -134,15 +135,15 @@ impl PartialEq for EthAddr {

impl Eq for EthAddr {}

impl PartialOrd for EthAddr {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
self.0.to_lowercase().partial_cmp(&other.0.to_lowercase())
impl Ord for EthAddr {
fn cmp(&self, other: &Self) -> Ordering {
self.0.to_lowercase().cmp(&other.0.to_lowercase())
}
}

impl Ord for EthAddr {
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
self.0.to_lowercase().cmp(&other.0.to_lowercase())
impl PartialOrd for EthAddr {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(self.cmp(other))
}
}

Expand Down

0 comments on commit 708f418

Please sign in to comment.