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/default/models/transactions.rs b/processor/src/processors/default/models/transactions.rs index 28d72f19..39dd7fff 100644 --- a/processor/src/processors/default/models/transactions.rs +++ b/processor/src/processors/default/models/transactions.rs @@ -303,22 +303,34 @@ impl Transaction { wsc_detail, ) }, - TxnData::BlockEpilogue(_) => ( - Self::from_transaction_info_with_data( - transaction_info, - None, - None, + TxnData::BlockEpilogue(_) => { + // Block epilogue txns carry write-set changes (e.g. block gas + // limit / BlockResource updates). Skipping them silently drops + // those rows from write_set_changes, move_resources, and + // move_modules on the parquet default processor. + let (wsc, wsc_detail) = WriteSetChangeModel::from_write_set_changes( + &transaction_info.changes, txn_version, - transaction_type, - 0, block_height, - epoch, block_timestamp, - txn_size_info, - ), - vec![], - vec![], - ), + ); + ( + Self::from_transaction_info_with_data( + transaction_info, + None, + None, + txn_version, + transaction_type, + 0, + block_height, + epoch, + block_timestamp, + txn_size_info, + ), + wsc, + wsc_detail, + ) + }, } } @@ -409,3 +421,75 @@ impl From for ParquetTransaction { } } } + +#[cfg(test)] +mod tests { + use super::*; + use aptos_indexer_processor_sdk::aptos_protos::{ + transaction::v1::{ + transaction::{TransactionType, TxnData}, + write_set_change::{Change, Type as WriteSetChangeTypeEnum}, + BlockEpilogueTransaction, MoveStructTag, Transaction as TransactionPB, TransactionInfo, + WriteResource, WriteSetChange as WriteSetChangePB, + }, + util::timestamp::Timestamp, + }; + + fn epilogue_txn_with_write_resource(address: &str) -> TransactionPB { + TransactionPB { + timestamp: Some(Timestamp { + seconds: 1_700_000_000, + nanos: 0, + }), + version: 7_250_088_688, + info: Some(TransactionInfo { + hash: vec![0u8; 32], + state_change_hash: vec![0u8; 32], + event_root_hash: vec![0u8; 32], + state_checkpoint_hash: None, + gas_used: 0, + success: true, + vm_status: String::new(), + accumulator_root_hash: vec![0u8; 32], + changes: vec![WriteSetChangePB { + r#type: WriteSetChangeTypeEnum::WriteResource as i32, + change: Some(Change::WriteResource(WriteResource { + address: address.to_string(), + state_key_hash: vec![0u8; 32], + r#type: Some(MoveStructTag { + address: "0x1".to_string(), + module: "block".to_string(), + name: "BlockResource".to_string(), + generic_type_params: vec![], + }), + type_str: "0x1::block::BlockResource".to_string(), + data: r#"{"epoch_interval":"1","height":"1"}"#.to_string(), + })), + }], + }), + epoch: 1, + block_height: 1, + r#type: TransactionType::BlockEpilogue as i32, + size_info: None, + txn_data: Some(TxnData::BlockEpilogue(BlockEpilogueTransaction { + block_end_info: None, + })), + } + } + + #[test] + fn block_epilogue_indexes_write_set_changes() { + let txn = epilogue_txn_with_write_resource("0x1"); + let (parsed, write_set_changes, wsc_details) = TransactionModel::from_transaction(&txn); + + assert_eq!(parsed.num_write_set_changes, 1); + assert_eq!(write_set_changes.len(), 1); + assert_eq!(wsc_details.len(), 1); + assert_eq!( + write_set_changes[0].resource_address, + "0x0000000000000000000000000000000000000000000000000000000000000001" + ); + assert_eq!(write_set_changes[0].change_type, "write_resource"); + assert!(matches!(wsc_details[0], WriteSetChangeDetail::Resource(_))); + } +} 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.