Drozdziak1/p2w client error logging and docker caching (#268)
* p2w-client: Fix silent logs, restore program log printing For some time now, p2w-client error reporting would fail to show daemon mode errors. The logs would only mention resends without ever showing failed attempts. with solana-program 1.10.31 came a newer, inferior program log reporting which only says "N program logs" instead of saying what they are. This changeset prints errors verbatim using formatted debug "{:#?}" syntax. * Docker: Improve p2w-attest/solana-devnet caching This commit speeds up caching in two ways: 1. By severing the dependency on bridge-client in Dockerfile.p2w-attest - mainly because of unnecessary `cargo install` builds which even with target dir caching can take ~1 minute. The bridge/token-bridge client binaries are not useful to p2w-client anyway. 2. By attaching cargo-install commands to a target dir cache via the --target-dir option in cargo
This commit is contained in:
parent
5c48dacee0
commit
aa7be4d1be
|
@ -12,7 +12,8 @@ COPY solana /usr/src/solana
|
||||||
WORKDIR /usr/src/solana/pyth2wormhole
|
WORKDIR /usr/src/solana/pyth2wormhole
|
||||||
|
|
||||||
RUN --mount=type=cache,target=/root/.cache \
|
RUN --mount=type=cache,target=/root/.cache \
|
||||||
cargo install --version =2.0.12 --locked spl-token-cli
|
--mount=type=cache,target=target \
|
||||||
|
cargo install --version =2.0.12 --locked spl-token-cli --target-dir target
|
||||||
|
|
||||||
|
|
||||||
RUN solana config set --keypair "/usr/src/solana/keys/solana-devnet.json"
|
RUN solana config set --keypair "/usr/src/solana/keys/solana-devnet.json"
|
||||||
|
@ -25,5 +26,5 @@ RUN --mount=type=cache,target=/root/.cache \
|
||||||
--mount=type=cache,target=/usr/local/cargo/registry,id=cargo_registry \
|
--mount=type=cache,target=/usr/local/cargo/registry,id=cargo_registry \
|
||||||
--mount=type=cache,target=target,id=cargo_registry \
|
--mount=type=cache,target=target,id=cargo_registry \
|
||||||
set -xe && \
|
set -xe && \
|
||||||
cargo install bridge_client --git https://github.com/wormhole-foundation/wormhole --tag $WORMHOLE_TAG --locked --root /usr/local && \
|
cargo install bridge_client --git https://github.com/wormhole-foundation/wormhole --tag $WORMHOLE_TAG --locked --root /usr/local --target-dir target && \
|
||||||
cargo install token_bridge_client --git https://github.com/wormhole-foundation/wormhole --tag $WORMHOLE_TAG --locked --root /usr/local
|
cargo install token_bridge_client --git https://github.com/wormhole-foundation/wormhole --tag $WORMHOLE_TAG --locked --root /usr/local --target-dir target
|
||||||
|
|
|
@ -70,7 +70,7 @@ pub const SEQNO_PREFIX: &'static str = "Program log: Sequence: ";
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> Result<(), ErrBox> {
|
async fn main() -> Result<(), ErrBox> {
|
||||||
let cli = Cli::parse();
|
let cli = Cli::parse();
|
||||||
init_logging(cli.log_level);
|
init_logging();
|
||||||
|
|
||||||
// All other CLI actions make rpc requests, this one's meant to be
|
// All other CLI actions make rpc requests, this one's meant to be
|
||||||
// off-chain explicitly
|
// off-chain explicitly
|
||||||
|
@ -295,7 +295,8 @@ async fn handle_attest(
|
||||||
// join_all. We filter out errors and report them
|
// join_all. We filter out errors and report them
|
||||||
let errors: Vec<_> = results
|
let errors: Vec<_> = results
|
||||||
.iter()
|
.iter()
|
||||||
.filter_map(|r| r.as_ref().err().map(|e| e.to_string()))
|
.enumerate()
|
||||||
|
.filter_map(|(idx, r)| r.as_ref().err().map(|e| format!("Error {}: {:#?}\n", idx + 1, e)))
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
if !errors.is_empty() {
|
if !errors.is_empty() {
|
||||||
|
@ -415,13 +416,13 @@ async fn attestation_sched_job(
|
||||||
let group_name4err_msg = batch.group_name.clone();
|
let group_name4err_msg = batch.group_name.clone();
|
||||||
|
|
||||||
// We never get to error reporting in daemon mode, attach a map_err
|
// We never get to error reporting in daemon mode, attach a map_err
|
||||||
let job_with_err_msg = job.map_err(move |e| async move {
|
let job_with_err_msg = job.map_err(move |e| {
|
||||||
warn!(
|
warn!(
|
||||||
"Batch {}/{}, group {:?} ERR: {}",
|
"Batch {}/{}, group {:?} ERR: {:#?}",
|
||||||
batch_no4err_msg,
|
batch_no4err_msg,
|
||||||
batch_count4err_msg,
|
batch_count4err_msg,
|
||||||
group_name4err_msg,
|
group_name4err_msg,
|
||||||
e.to_string()
|
e
|
||||||
);
|
);
|
||||||
e
|
e
|
||||||
});
|
});
|
||||||
|
@ -533,15 +534,11 @@ async fn attestation_job(
|
||||||
Result::<(), ErrBoxSend>::Ok(())
|
Result::<(), ErrBoxSend>::Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn init_logging(verbosity: u32) {
|
fn init_logging() {
|
||||||
use LevelFilter::*;
|
if std::env::var("RUST_LOG").is_ok() {
|
||||||
let filter = match verbosity {
|
env_logger::init()
|
||||||
0..=1 => Error,
|
} else {
|
||||||
2 => Warn,
|
// Default to info if RUST_LOG not set
|
||||||
3 => Info,
|
env_logger::builder().filter_level(LevelFilter::Info).init();
|
||||||
4 => Debug,
|
}
|
||||||
_other => Trace,
|
|
||||||
};
|
|
||||||
|
|
||||||
env_logger::builder().filter_level(filter).init();
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +1,24 @@
|
||||||
FROM bridge-client
|
#syntax=docker/dockerfile:1.2@sha256:e2a8561e419ab1ba6b2fe6cbdf49fd92b95912df1cf7d313c3e2230a333fdbcc
|
||||||
|
FROM ghcr.io/certusone/solana:1.10.31@sha256:d31e8db926a1d3fbaa9d9211d9979023692614b7b64912651aba0383e8c01bad AS solana
|
||||||
|
|
||||||
RUN apt-get install -y python3
|
RUN apt-get update && apt-get install -yq python3 libudev-dev ncat
|
||||||
|
RUN curl -fsSL https://deb.nodesource.com/setup_16.x | bash - && apt-get install -y nodejs
|
||||||
|
|
||||||
ADD third_party/pyth/pyth_utils.py /usr/src/pyth/pyth_utils.py
|
ADD third_party/pyth/pyth_utils.py /usr/src/pyth/pyth_utils.py
|
||||||
ADD third_party/pyth/p2w_autoattest.py /usr/src/pyth/p2w_autoattest.py
|
ADD third_party/pyth/p2w_autoattest.py /usr/src/pyth/p2w_autoattest.py
|
||||||
ADD third_party/pyth/p2w-sdk/rust /usr/src/third_party/pyth/p2w-sdk/rust
|
ADD third_party/pyth/p2w-sdk/rust /usr/src/third_party/pyth/p2w-sdk/rust
|
||||||
|
|
||||||
|
ADD solana /usr/src/solana
|
||||||
|
|
||||||
|
WORKDIR /usr/src/solana/pyth2wormhole
|
||||||
|
|
||||||
|
ENV EMITTER_ADDRESS="11111111111111111111111111111115"
|
||||||
|
ENV BRIDGE_ADDRESS="Bridge1p5gheXUvJ6jGWGeCsgPKgnE3YgdGKRVCMY9o"
|
||||||
|
|
||||||
RUN --mount=type=cache,target=/root/.cache \
|
RUN --mount=type=cache,target=/root/.cache \
|
||||||
--mount=type=cache,target=target \
|
--mount=type=cache,target=target \
|
||||||
--mount=type=cache,target=pyth2wormhole/target \
|
|
||||||
cargo build --package pyth2wormhole-client && \
|
|
||||||
cargo test --package pyth2wormhole-client && \
|
cargo test --package pyth2wormhole-client && \
|
||||||
|
cargo build --package pyth2wormhole-client && \
|
||||||
mv target/debug/pyth2wormhole-client /usr/local/bin/pyth2wormhole-client && \
|
mv target/debug/pyth2wormhole-client /usr/local/bin/pyth2wormhole-client && \
|
||||||
chmod a+rx /usr/src/pyth/*.py
|
chmod a+rx /usr/src/pyth/*.py
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue