Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: transaction's input truncate function #12236

Merged
merged 1 commit into from
Nov 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion crates/rpc/rpc-types-compat/src/transaction/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,9 @@ impl TransactionCompat for () {
WithOtherFields::default()
}

fn otterscan_api_truncate_input(_tx: &mut Self::Transaction) {}
fn otterscan_api_truncate_input(tx: &mut Self::Transaction) {
tx.input = tx.input.slice(..4);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is actually dangerous and incorrect in the other implementations as well, we need to check that the input slice actually as at least 4 items

Copy link
Contributor Author

@nadtech-hub nadtech-hub Nov 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is double-check in case of otterscan. input may contain arbitrary data so truncating will return smth nonse

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, but this check should be in the impl instead, can do that separately, though

}

fn tx_type(_tx: &Self::Transaction) -> u8 {
0
Expand Down
Loading