Skip to content

Commit

Permalink
chore: bump sqlx version due to security alert
Browse files Browse the repository at this point in the history
also had to bump tempfile for it to work
  • Loading branch information
marcospb19-cw committed Sep 4, 2024
1 parent 6f290bc commit 2f27025
Show file tree
Hide file tree
Showing 8 changed files with 123 additions and 131 deletions.
200 changes: 102 additions & 98 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ tracing-serde = "=0.1.3"
# storage
redis = "=0.26.0"
rocksdb = { version = "=0.22.0", features = ["multi-threaded-cf"] }
sqlx = { version = "=0.7.4", features = [
sqlx = { version = "=0.8.2", features = [
"runtime-tokio",
"postgres",
"bigdecimal",
Expand Down Expand Up @@ -141,7 +141,7 @@ console-subscriber = { git = "https://github.com/tokio-rs/console.git", rev = "8
binary_macros = "=1.0.0"
fancy-duration = "=0.9.2"
stringreader = "=0.1.1"
tempfile = "=3.10.0"
tempfile = "=3.10.1"

# ------------------------------------------------------------------------------
# Build dependencies
Expand Down
6 changes: 2 additions & 4 deletions src/eth/primitives/address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ use ethers_core::types::NameOrAddress;
use fake::Dummy;
use fake::Faker;
use hex_literal::hex;
use sqlx::database::HasArguments;
use sqlx::database::HasValueRef;
use sqlx::encode::IsNull;
use sqlx::error::BoxDynError;
use sqlx::postgres::PgHasArrayType;
Expand Down Expand Up @@ -115,7 +113,7 @@ impl TryFrom<Vec<u8>> for Address {
// sqlx traits
// -----------------------------------------------------------------------------
impl<'r> sqlx::Decode<'r, sqlx::Postgres> for Address {
fn decode(value: <sqlx::Postgres as HasValueRef<'r>>::ValueRef) -> Result<Self, BoxDynError> {
fn decode(value: <sqlx::Postgres as sqlx::Database>::ValueRef<'r>) -> Result<Self, BoxDynError> {
let value = <[u8; 20] as Decode<sqlx::Postgres>>::decode(value)?;
Ok(value.into())
}
Expand All @@ -140,7 +138,7 @@ impl AsRef<[u8]> for Address {
}

impl<'q> sqlx::Encode<'q, sqlx::Postgres> for Address {
fn encode_by_ref(&self, buf: &mut <sqlx::Postgres as HasArguments<'q>>::ArgumentBuffer) -> IsNull {
fn encode_by_ref(&self, buf: &mut <sqlx::Postgres as sqlx::Database>::ArgumentBuffer<'q>) -> Result<IsNull, sqlx::error::BoxDynError> {
self.0 .0.encode(buf)
}
}
Expand Down
6 changes: 2 additions & 4 deletions src/eth/primitives/block_number.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ use ethereum_types::U64;
use ethers_core::utils::keccak256;
use fake::Dummy;
use fake::Faker;
use sqlx::database::HasArguments;
use sqlx::database::HasValueRef;
use sqlx::encode::IsNull;
use sqlx::error::BoxDynError;
use sqlx::postgres::PgHasArrayType;
Expand Down Expand Up @@ -182,7 +180,7 @@ impl From<BlockNumber> for [u8; 8] {
// sqlx traits
// -----------------------------------------------------------------------------
impl<'r> sqlx::Decode<'r, sqlx::Postgres> for BlockNumber {
fn decode(value: <sqlx::Postgres as HasValueRef<'r>>::ValueRef) -> Result<Self, BoxDynError> {
fn decode(value: <sqlx::Postgres as sqlx::Database>::ValueRef<'r>) -> Result<Self, BoxDynError> {
let value = <BigDecimal as sqlx::Decode<sqlx::Postgres>>::decode(value)?;
Ok(value.try_into()?)
}
Expand All @@ -195,7 +193,7 @@ impl sqlx::Type<sqlx::Postgres> for BlockNumber {
}

impl<'q> sqlx::Encode<'q, sqlx::Postgres> for BlockNumber {
fn encode_by_ref(&self, buf: &mut <sqlx::Postgres as HasArguments<'q>>::ArgumentBuffer) -> IsNull {
fn encode_by_ref(&self, buf: &mut <sqlx::Postgres as sqlx::Database>::ArgumentBuffer<'q>) -> Result<IsNull, sqlx::error::BoxDynError> {
BigDecimal::from(u64::from(*self)).encode(buf)
}
}
Expand Down
9 changes: 4 additions & 5 deletions src/eth/primitives/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ use display_json::DebugAsJson;
use ethereum_types::H256;
use fake::Dummy;
use fake::Faker;
use sqlx::database::HasValueRef;
use sqlx::error::BoxDynError;
use sqlx::encode::IsNull;
use sqlx::postgres::PgHasArrayType;

use crate::gen_newtype_from;
Expand Down Expand Up @@ -84,21 +83,21 @@ impl FromStr for Hash {
// sqlx traits
// -----------------------------------------------------------------------------
impl<'r> sqlx::Decode<'r, sqlx::Postgres> for Hash {
fn decode(value: <sqlx::Postgres as HasValueRef<'r>>::ValueRef) -> Result<Self, BoxDynError> {
fn decode(value: <sqlx::Postgres as sqlx::Database>::ValueRef<'r>) -> Result<Self, sqlx::error::BoxDynError> {
let value = <[u8; 32] as sqlx::Decode<sqlx::Postgres>>::decode(value)?;
Ok(value.into())
}
}

impl<'q> sqlx::Encode<'q, sqlx::Postgres> for Hash {
fn encode(self, buf: &mut <sqlx::Postgres as sqlx::database::HasArguments<'q>>::ArgumentBuffer) -> sqlx::encode::IsNull
fn encode(self, buf: &mut <sqlx::Postgres as sqlx::Database>::ArgumentBuffer<'q>) -> Result<IsNull, sqlx::error::BoxDynError>
where
Self: Sized,
{
<&[u8; 32] as sqlx::Encode<sqlx::Postgres>>::encode(self.0.as_fixed_bytes(), buf)
}

fn encode_by_ref(&self, buf: &mut <sqlx::Postgres as sqlx::database::HasArguments<'q>>::ArgumentBuffer) -> sqlx::encode::IsNull {
fn encode_by_ref(&self, buf: &mut <sqlx::Postgres as sqlx::Database>::ArgumentBuffer<'q>) -> Result<IsNull, sqlx::error::BoxDynError> {
<&[u8; 32] as sqlx::Encode<sqlx::Postgres>>::encode(self.0.as_fixed_bytes(), buf)
}
}
Expand Down
8 changes: 3 additions & 5 deletions src/eth/primitives/slot_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ use ethereum_types::U256;
use ethers_core::utils::keccak256;
use fake::Dummy;
use fake::Faker;
use sqlx::database::HasArguments;
use sqlx::database::HasValueRef;
use sqlx::encode::IsNull;
use sqlx::error::BoxDynError;
use sqlx::postgres::PgHasArrayType;
Expand Down Expand Up @@ -129,7 +127,7 @@ impl From<SlotIndex> for ethereum_types::U256 {
// sqlx traits
// -----------------------------------------------------------------------------
impl<'r> sqlx::Decode<'r, sqlx::Postgres> for SlotIndex {
fn decode(value: <sqlx::Postgres as HasValueRef<'r>>::ValueRef) -> Result<Self, BoxDynError> {
fn decode(value: <sqlx::Postgres as sqlx::Database>::ValueRef<'r>) -> Result<Self, BoxDynError> {
let value = <[u8; 32] as Decode<sqlx::Postgres>>::decode(value)?;
Ok(value.into())
}
Expand All @@ -142,11 +140,11 @@ impl sqlx::Type<sqlx::Postgres> for SlotIndex {
}

impl<'q> sqlx::Encode<'q, sqlx::Postgres> for SlotIndex {
fn encode_by_ref(&self, buf: &mut <sqlx::Postgres as HasArguments<'q>>::ArgumentBuffer) -> IsNull {
fn encode_by_ref(&self, buf: &mut <sqlx::Postgres as sqlx::Database>::ArgumentBuffer<'q>) -> Result<IsNull, sqlx::error::BoxDynError> {
<[u8; 32] as sqlx::Encode<sqlx::Postgres>>::encode((*self).into(), buf)
}

fn encode(self, buf: &mut <sqlx::Postgres as HasArguments<'q>>::ArgumentBuffer) -> IsNull
fn encode(self, buf: &mut <sqlx::Postgres as sqlx::Database>::ArgumentBuffer<'q>) -> Result<IsNull, sqlx::error::BoxDynError>
where
Self: Sized,
{
Expand Down
9 changes: 3 additions & 6 deletions src/eth/primitives/slot_value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@ use display_json::DebugAsJson;
use ethereum_types::U256;
use fake::Dummy;
use fake::Faker;
use sqlx::database::HasArguments;
use sqlx::database::HasValueRef;
use sqlx::encode::IsNull;
use sqlx::error::BoxDynError;
use sqlx::postgres::PgHasArrayType;
use sqlx::Decode;

Expand Down Expand Up @@ -110,7 +107,7 @@ impl FromStr for SlotValue {
// sqlx traits
// -----------------------------------------------------------------------------
impl<'r> sqlx::Decode<'r, sqlx::Postgres> for SlotValue {
fn decode(value: <sqlx::Postgres as HasValueRef<'r>>::ValueRef) -> Result<Self, BoxDynError> {
fn decode(value: <sqlx::Postgres as sqlx::Database>::ValueRef<'r>) -> Result<Self, sqlx::error::BoxDynError> {
let value = <[u8; 32] as Decode<sqlx::Postgres>>::decode(value)?;
Ok(value.into())
}
Expand All @@ -123,11 +120,11 @@ impl sqlx::Type<sqlx::Postgres> for SlotValue {
}

impl<'q> sqlx::Encode<'q, sqlx::Postgres> for SlotValue {
fn encode_by_ref(&self, buf: &mut <sqlx::Postgres as HasArguments<'q>>::ArgumentBuffer) -> IsNull {
fn encode_by_ref(&self, buf: &mut <sqlx::Postgres as sqlx::Database>::ArgumentBuffer<'q>) -> Result<IsNull, sqlx::error::BoxDynError> {
<[u8; 32] as sqlx::Encode<sqlx::Postgres>>::encode((*self).into(), buf)
}

fn encode(self, buf: &mut <sqlx::Postgres as HasArguments<'q>>::ArgumentBuffer) -> IsNull
fn encode(self, buf: &mut <sqlx::Postgres as sqlx::Database>::ArgumentBuffer<'q>) -> Result<IsNull, sqlx::error::BoxDynError>
where
Self: Sized,
{
Expand Down
12 changes: 5 additions & 7 deletions src/eth/primitives/wei.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ use ethabi::Token;
use ethereum_types::U256;
use fake::Dummy;
use fake::Faker;
use sqlx::database::HasArguments;
use sqlx::database::HasValueRef;
use sqlx::encode::IsNull;
use sqlx::error::BoxDynError;
use sqlx::postgres::PgHasArrayType;
Expand Down Expand Up @@ -79,7 +77,7 @@ impl TryFrom<BigDecimal> for Wei {
// sqlx traits
// -----------------------------------------------------------------------------
impl<'r> sqlx::Decode<'r, sqlx::Postgres> for Wei {
fn decode(value: <sqlx::Postgres as HasValueRef<'r>>::ValueRef) -> Result<Self, BoxDynError> {
fn decode(value: <sqlx::Postgres as sqlx::Database>::ValueRef<'r>) -> Result<Self, BoxDynError> {
let value = <BigDecimal as Decode<sqlx::Postgres>>::decode(value)?;
Ok(value.try_into()?)
}
Expand All @@ -92,25 +90,25 @@ impl sqlx::Type<sqlx::Postgres> for Wei {
}

impl<'q> sqlx::Encode<'q, sqlx::Postgres> for Wei {
fn encode_by_ref(&self, buf: &mut <sqlx::Postgres as HasArguments<'q>>::ArgumentBuffer) -> IsNull {
fn encode_by_ref(&self, buf: &mut <sqlx::Postgres as sqlx::Database>::ArgumentBuffer<'q>) -> Result<IsNull, sqlx::error::BoxDynError> {
match BigDecimal::try_from(*self) {
Ok(res) => res.encode(buf),
Err(e) => {
tracing::error!(reason = ?e, "failed to encode gas");
IsNull::Yes
Ok(IsNull::Yes)
}
}
}

fn encode(self, buf: &mut <sqlx::Postgres as HasArguments<'q>>::ArgumentBuffer) -> IsNull
fn encode(self, buf: &mut <sqlx::Postgres as sqlx::Database>::ArgumentBuffer<'q>) -> Result<IsNull, sqlx::error::BoxDynError>
where
Self: Sized,
{
match BigDecimal::try_from(self) {
Ok(res) => res.encode(buf),
Err(e) => {
tracing::error!(reason = ?e, "failed to encode gas");
IsNull::Yes
Ok(IsNull::Yes)
}
}
}
Expand Down

0 comments on commit 2f27025

Please sign in to comment.