rpcpool / yellowstone-faithful

Project Yellowstone Old Faithful is the project to make all of Solana's history accessible, content addressable and available via a variety of means.
https://old-faithful.net/
GNU Affero General Public License v3.0
54 stars 10 forks source link

App crashes intermittently on some instructions parsed (`encoding=jsonParsed`) #98

Open EugeneButusov opened 1 month ago

EugeneButusov commented 1 month ago

Problem

When doing a call of getBlock with encoding set to jsonParsed for, for example, block 258768009, application crashes with the following trace:

thread '<unnamed>' panicked at src/lib.rs:62:60:
called `Result::unwrap()` on an `Err` value: short buffer: required 32 bytes, but only 4 bytes available
stack backtrace:
   0: rust_begin_unwind
             at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/std/src/panicking.rs:647:5
   1: core::panicking::panic_fmt
             at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/core/src/panicking.rs:72:14
   2: core::result::unwrap_failed
             at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/core/src/result.rs:1649:5
   3: parse_instruction
   4: _cgo_3af86e38bd62_Cfunc_parse_instruction
             at /tmp/go-build/cgo-gcc-prolog:67:11
   5: runtime.asmcgocall
             at /usr/local/go/src/runtime/asm_amd64.s:918
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
fatal runtime error: failed to initiate panic, error 5
SIGABRT: abort
PC=0x78acfb6969fc m=20 sigcode=18446744073709551610
signal arrived during cgo execution

After adding some more extra logs, it seems it crashes when trying to decode ExtendLookupTable instruction.

Due to the extended logs, we can get for the instruction which fails the following confusing line:

[rust] static_account_keys_len: 196

however, it has only four accounts required for this operation. Here is unparsed instruction:

{
  "accounts":[
    1,
    0,
    0,
    2
  ],

 "data":"3HZrKkPNSUj99xoS7QLmCjhA5iMdWYdSVXLeXZc9AH19faRmpeNrwWiYSKw4e27YTnmZmw7r9bJNv3cg9tWvCc9vvEDnt4LpVpqc9n6sw5VW6GGaDxs6FNfqAJc5kjwKxSTAAj7PKyygtxfoKgwWw2CWrjbNbC1s9ZvFRBhSVpx2iHD1CoErDJ4XBb61AWn4fxkUJm4TnXEAQLScF23GKVWn7TBwChqN6PamXHQy7MYy46bLXqFpbTA3YDJJaJvYkKfL1VujLp5MhrP1kkik2h6XfEfRsbnpottL5uj5A8bE8W6aQ5NgLu5p5J1uxTuE5wJTHG7xBHCNXqGn9qRwwKvHE46sodEzkuEgCGj5WC3ZoMxT69dojjdqm3VUso9tqy1y15GHcnEh8q7QXkDY5NXDrA3dwtW4EqbYLbbXbLcPBQZAV5UpXG8gyzfN5hzMD46YW",
  "programIdIndex":3,
  "stackHeight":null
}

The transaction signature from that block is 61KrK26PQohM8Qt1GR6WBRUXkLoWvFhUSnm3Q14EEMMHPsAo4iTrkx8EwZt2y7tQXVsgHyMmjzJiMncTjfE85LMa.

This is not the only case, sometimes it crashes on another blocks, this is only as an example. Possibly, for some instructions layout is read not correctly.

gagliardetto commented 1 month ago

hi @EugeneButusov

thanks for the bug report! I'll take a look

gagliardetto commented 1 week ago

There was an issue with length encoding when going between golang and rust.

Will be fixed in the next release.