Skip to content

Commit

Permalink
fix: fix SVM scraper dispatch and delivery bugs (#5071)
Browse files Browse the repository at this point in the history
### Description

Context here
https://discord.com/channels/935678348330434570/1320897742779977849

Fixes two bugs, adding tests for them:
- Txs that had reverted with an error are no longer considered valid in
the scraper's log meta population codepath. We ran into an instance
where two attempted process txs landed in the same block. We'd get two
potentially matching txs in the same block when indexing the process,
which causes issues
- Versioned txs were not supported. We ran into a versioned dispatch tx
for the first time
(https://eclipsescan.xyz/tx/Ku7gtQzEztksncHMHYkXq8PNst5rZsznrXMDmVqoQjc7SR4PsXz33qjNMckNcHriCxuhZJGZequo8moNsRP9GZK).
The list of accounts wasn't populated correctly because some were
dynamic (from an address lookup table). This caused us to think that the
Mailbox wasn't being used in a tx, when it was. The solution here is to
ensure the list is ordered correctly and has all the accounts, including
the dynamic ones.

### Drive-by changes

<!--
Are there any minor or drive-by changes also included?
-->

### Related issues

<!--
- Fixes #[issue number here]
-->

### Backward compatibility

<!--
Are these changes backward compatible? Are there any infrastructure
implications, e.g. changes that would prohibit deploying older commits
using this infra tooling?

Yes/No
-->

### Testing

<!--
What kind of testing have these changes undergone?

None/Manual/Unit Tests
-->
  • Loading branch information
tkporter authored Dec 26, 2024
1 parent 9852172 commit 18310b8
Show file tree
Hide file tree
Showing 6 changed files with 4,243 additions and 4 deletions.
27 changes: 26 additions & 1 deletion rust/main/chains/hyperlane-sealevel/src/log_meta_composer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,11 @@ fn filter_by_validity(
tx: UiTransaction,
meta: UiTransactionStatusMeta,
) -> Option<(H512, Vec<String>, Vec<UiCompiledInstruction>)> {
// If the transaction has an error, we skip it
if meta.err.is_some() {
return None;
}

let Some(transaction_hash) = tx
.signatures
.first()
Expand All @@ -238,9 +243,29 @@ fn filter_by_validity(
return None;
};

// Orders the account keys in line with the behavior of compiled instructions.
let account_keys = match &meta.loaded_addresses {
OptionSerializer::Some(addresses) => {
// If there are loaded addresses, we have a versioned transaction
// that may include dynamically loaded addresses (e.g. from a lookup table).
// The order of these is [static, dynamic writeable, dynamic readonly] and
// follows the iter ordering of https://docs.rs/solana-sdk/latest/solana_sdk/message/struct.AccountKeys.html.
[
message.account_keys,
addresses.writable.clone(),
addresses.readonly.clone(),
]
.concat()
}
OptionSerializer::None | OptionSerializer::Skip => {
// There are only static addresses in the transaction.
message.account_keys
}
};

let instructions = instructions(message.instructions, meta);

Some((transaction_hash, message.account_keys, instructions))
Some((transaction_hash, account_keys, instructions))
}

fn filter_by_encoding(
Expand Down
Loading

0 comments on commit 18310b8

Please sign in to comment.