diff --git a/Dockerfile b/Dockerfile index a7e266e6..57df1080 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,13 +2,25 @@ # Stage 1: Build the binary -FROM rust:slim-bullseye as builder +FROM rust:slim-bookworm AS builder WORKDIR /app COPY --link . /app -RUN for i in 1 2 3; do apt-get update && apt-get install --fix-missing -y cmake curl clang git pkg-config libssl-dev libdw-dev libpq-dev lld && break || sleep 10; done +RUN apt-get update \ + && apt-get install --no-install-recommends --fix-missing -y \ + cmake \ + curl \ + clang \ + make \ + git \ + pkg-config \ + libssl-dev \ + libdw-dev \ + libpq-dev \ + lld \ + && rm -rf /var/lib/apt/lists/* ENV CARGO_NET_GIT_FETCH_WITH_CLI true # TODO: Fix this with real processors. RUN cargo build --locked --release -p processor && ls -lah target/release/ @@ -24,19 +36,19 @@ ENV GIT_SHA ${GIT_SHA} # Stage 2: Create the final image -FROM debian:bullseye-slim +FROM debian:bookworm-slim COPY --from=builder /usr/local/bin/processor /usr/local/bin RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ --mount=type=cache,target=/var/lib/apt,sharing=locked \ apt-get update && apt-get install --no-install-recommends --fix-missing -y \ - libssl1.1 \ + libssl3 \ ca-certificates \ net-tools \ tcpdump \ iproute2 \ - netcat \ + netcat-openbsd \ libdw-dev \ libpq-dev \ curl diff --git a/Dockerfile.address-reputation-api b/Dockerfile.address-reputation-api index 5be4c111..488d8ed5 100644 --- a/Dockerfile.address-reputation-api +++ b/Dockerfile.address-reputation-api @@ -2,13 +2,25 @@ # Stage 1: Build the binary -FROM rust:slim-bullseye as builder +FROM rust:slim-bookworm AS builder WORKDIR /app COPY --link . /app -RUN for i in 1 2 3; do apt-get update && apt-get install --fix-missing -y cmake curl clang git pkg-config libssl-dev libdw-dev libpq-dev lld && break || sleep 10; done +RUN apt-get update \ + && apt-get install --no-install-recommends --fix-missing -y \ + cmake \ + curl \ + clang \ + make \ + git \ + pkg-config \ + libssl-dev \ + libdw-dev \ + libpq-dev \ + lld \ + && rm -rf /var/lib/apt/lists/* ENV CARGO_NET_GIT_FETCH_WITH_CLI true RUN cargo build --locked --release -p address-reputation-api && ls -lah target/release/ RUN cp target/release/address-reputation-api /usr/local/bin @@ -23,19 +35,19 @@ ENV GIT_SHA ${GIT_SHA} # Stage 2: Create the final image -FROM debian:bullseye-slim +FROM debian:bookworm-slim COPY --from=builder /usr/local/bin/address-reputation-api /usr/local/bin RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ --mount=type=cache,target=/var/lib/apt,sharing=locked \ apt-get update && apt-get install --no-install-recommends --fix-missing -y \ - libssl1.1 \ + libssl3 \ ca-certificates \ net-tools \ tcpdump \ iproute2 \ - netcat \ + netcat-openbsd \ libdw-dev \ libpq-dev \ curl diff --git a/processor/src/processors/user_transaction/models/signature_utils/account_signature_utils.rs b/processor/src/processors/user_transaction/models/signature_utils/account_signature_utils.rs index d8f03168..8cf2df69 100644 --- a/processor/src/processors/user_transaction/models/signature_utils/account_signature_utils.rs +++ b/processor/src/processors/user_transaction/models/signature_utils/account_signature_utils.rs @@ -210,9 +210,10 @@ pub fn get_public_key_indices_from_multi_key_signature(s: &MultiKeySignature) -> s.signatures.iter().map(|key| key.index as usize).collect() } +/// Parameter order matches the other `parse_*` helpers: type string, then sender. pub fn parse_abstraction_signature( - sender: &String, account_signature_type: &str, + sender: &String, transaction_version: i64, transaction_block_height: i64, is_sender_primary: bool, @@ -238,3 +239,69 @@ pub fn parse_abstraction_signature( multi_sig_index: 0, } } + +#[cfg(test)] +mod tests { + use super::*; + use aptos_indexer_processor_sdk::aptos_protos::transaction::v1::AbstractionSignature; + use chrono::DateTime; + + fn abstraction_account_signature() -> AccountSignature { + AccountSignature { + r#type: AccountSignatureTypeEnum::Abstraction as i32, + signature: Some(AccountSignatureEnum::Abstraction(AbstractionSignature { + function_info: "0x1::account_abstraction::authenticate".to_string(), + signature: vec![0x11, 0x22], + })), + } + } + + #[test] + fn from_account_signature_abstraction_keeps_signer_and_type() { + let sender = "0xabc".to_string(); + let parsed = from_account_signature( + &abstraction_account_signature(), + &sender, + 99, + 3, + true, + 0, + None, + DateTime::from_timestamp(1, 0).unwrap().naive_utc(), + ); + + assert_eq!(parsed.len(), 1); + assert_eq!( + parsed[0].signer, + "0x0000000000000000000000000000000000000000000000000000000000000abc" + ); + assert_eq!(parsed[0].account_signature_type, "abstraction_signature"); + assert!(parsed[0].is_sender_primary); + assert_eq!(parsed[0].transaction_version, 99); + } + + #[test] + fn from_account_signature_abstraction_honors_override_address() { + let sender = "0x1".to_string(); + let fee_payer = "0xdef".to_string(); + let parsed = from_account_signature( + &abstraction_account_signature(), + &sender, + 1, + 1, + false, + 2, + Some(&fee_payer), + DateTime::from_timestamp(1, 0).unwrap().naive_utc(), + ); + + assert_eq!(parsed.len(), 1); + assert_eq!( + parsed[0].signer, + "0x0000000000000000000000000000000000000000000000000000000000000def" + ); + assert_eq!(parsed[0].account_signature_type, "abstraction_signature"); + assert!(!parsed[0].is_sender_primary); + assert_eq!(parsed[0].multi_agent_index, 2); + } +} diff --git a/scripts/rust_lint.sh b/scripts/rust_lint.sh index 261c1aa9..32a48f2b 100755 --- a/scripts/rust_lint.sh +++ b/scripts/rust_lint.sh @@ -25,7 +25,10 @@ fi set -e set -x -cargo +nightly xclippy +# Run clippy on the pinned STABLE toolchain (from rust-toolchain.toml), NOT +# nightly. Latest nightly makes Infallible an alias of !, which breaks +# allocative (impl Allocative for both). Stable clippy matches the build toolchain. +cargo xclippy # We require the nightly build of cargo fmt # to provide stricter rust formatting.