feat(core): retain raw packet payload on-chain for retrieval by packet hash#207
Draft
jinoosss wants to merge 2 commits into
Draft
feat(core): retain raw packet payload on-chain for retrieval by packet hash#207jinoosss wants to merge 2 commits into
jinoosss wants to merge 2 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Large packet payloads overflow the event size limit: the
packet_dataattribute emitted on
PacketSendis truncated by downstream event consumers(indexers/relayers), which then fail to parse the event. A real
TokenOrder/Batchpayload routinely exceeds the limit because each ABI fieldis padded to a 32-byte word, so the truncation is hit in normal operation, not
just edge cases.
This change retains the raw packet payload (
packet.Data) in the core store,keyed by the packet commitment hash, and exposes a getter so off-chain
consumers can fetch the full payload by hash instead of reading it from the
(truncated) event attribute. The
packet_hashalready emitted in every packetevent is the lookup key, so no new correlation data is needed.
Design
CommitPacketHash). It is globally uniqueper packet and is already emitted as the
packet_hashevent attribute, so aconsumer reads the intact
packet_hashand queries the payload directly.Storeexposes onlyGet/Set/Removeprimitives over a dedicated bptree (
SetPacketData,GetPacketData,RemovePacketData); it makes no lifecycle decisions, consistent with thestore's existing "store and retrieve only — protocol logic lives in the impl"
contract.
SendPacketwrites the payload right afterCommitPacket.markPacketAcknowledgedremoves it. Acknowledgement and timeout both funnelthrough
markPacketAcknowledged, so this is the single retire point — thepayload lives exactly while the packet is in flight, bounding state growth.
SetPacketDataandGetPacketDataclone the byteslice, so stored state cannot be mutated through the caller's reference or
across a realm boundary.
Public query
core.GetPacketData(packetHash) (string, error)returns the payload as a0x-prefixed hex string — the same encoding as thepacket_dataeventattribute — so existing parsers work unchanged. It returns an error once the
packet has been retired (acknowledged/timed out) or if it was never sent from
this chain.
Off-chain usage:
Changes
core/store.gno—packetDatabptree field +SetPacketData/GetPacketData/RemovePacketDataprimitives (realm-guarded, cloned).core/types.gno—IStoregains the three primitives;ICoregainsGetPacketData.core/v1/packet.gno—SendPacketstores the payload;markPacketAcknowledgedremoves it (shared ack/timeout cleanup).
core/v1/getters.gno— implGetPacketDatapassthrough.core/getters.gno— publicGetPacketDataquery returning0x-hex.core/errors.gno—ErrPacketDataNotFound.