nautechsystems/nautilus_trader · error
Failed to decode SetFeeProtocol event data: {e}
Error message
Failed to decode SetFeeProtocol event data: {e} What it means
Thrown by parse_fee_protocol_update_event_hypersync when the data is long enough (>=128 bytes) but alloy's SolType::abi_decode for SetFeeProtocolEventData still fails. This means the byte content does not decode into four uint8-ish parameters per the event ABI — wrong encoding, extra unaligned bytes, or wrong event type.
Source
Thrown at crates/adapters/blockchain/src/exchanges/parsing/uniswap_v3/fee_protocol_update.rs:76
log: &HypersyncLog,
) -> anyhow::Result<FeeProtocolUpdateEvent> {
validate_event_signature_hash(
"SetFeeProtocolEvent",
FEE_PROTOCOL_UPDATE_EVENT_SIGNATURE_HASH,
log,
)?;
if let Some(data) = &log.data {
let data_bytes = data.as_ref();
// Validate the data contains 4 parameters of 32 bytes each
if data_bytes.len() < 4 * 32 {
anyhow::bail!("SetFeeProtocol event data is too short");
}
let decoded = match <SetFeeProtocolEventData as SolType>::abi_decode(data_bytes) {
Ok(decoded) => decoded,
Err(e) => anyhow::bail!("Failed to decode SetFeeProtocol event data: {e}"),
};
let pool_address = Address::from_slice(
log.address
.clone()
.expect("Contract address should be set in logs")
.as_ref(),
);
let pool_identifier = PoolIdentifier::Address(Ustr::from(&pool_address.to_string()));
Ok(FeeProtocolUpdateEvent::new(
dex,
pool_identifier,
extract_block_number(log)?,
extract_transaction_hash(log)?,
extract_transaction_index(log)?,
extract_log_index(log)?,
u32::from(decoded.fee_protocol0_new),View on GitHub (pinned to 18893faf8b)
Solutions
- Log the underlying error {e} to see expected vs actual encoded sizes and fix the payload accordingly.
- Verify data length is exactly 128 bytes; strip any trailing bytes before decoding.
- Confirm the hypersync log filter matches the exact SetFeeProtocol event signature (name plus indexed parameter types).
- Regenerate the SolStruct (SetFeeProtocolEventData) from the verified ABI to ensure parameter order/types are correct.
- Cross-check with the RPC parser (parse_fee_protocol_update_event_rpc) on the same log to isolate hypersync-specific data issues.
Example fix
// before
Err(e) => anyhow::bail!("Failed to decode SetFeeProtocol event data: {e}"),
// after
Err(e) => anyhow::bail!(
"Failed to decode SetFeeProtocol event data (len={}): {e}",
data_bytes.len()
), Defensive patterns
Strategy: validation
Validate before calling
fn is_decodeable_set_fee_protocol(data: &[u8]) -> bool {
data.len() == 128
&& <SetFeeProtocolEventData as SolType>::abi_decode(data).is_ok()
} Try / catch
match parse_fee_protocol_update_event_hypersync(dex, &log) {
Ok(event) => handle(event),
Err(e) if e.to_string().contains("Failed to decode SetFeeProtocol") => {
tracing::debug!(raw = ?log.data, "undecodeable SetFeeProtocol data: {e}");
}
Err(e) => return Err(e),
} Prevention
- Use the full event signature (not a prefix) when building topic filters
- Keep SetFeeProtocolEventData regenerated from the canonical pool ABI
- Log the inner decode error to distinguish length vs content problems
- Cross-validate hypersync parses against the RPC parser for the same logs
When it happens
Trigger: abi_decode returns Err on a 128+ byte payload for a log whose topic matched SetFeeProtocol — e.g. data belongs to a different event, trailing bytes, or a provider returned a non-canonical encoding.
Common situations: Topic hash collision or alias filtering by signature with a different full signature; decoding logs from a fork/custom pool; corrupted or hand-built log data in tests (test_parse_fee_protocol_update_event_hypersync, test_hypersync_rpc_match).
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- SetFeeProtocol event data is too short
- Flash event data is too short
- Failed to decode flash event data: {e}
- Missing tickLower in topic2 when parsing burn event
- Missing data in SetFeeProtocol event log
AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08).
Data as JSON: /api/errors/f6fdab0f853e902c.
Report an issue: GitHub.