Skip to content

solana: keep a zero DataSlice offset when converting from proto - #2499

Draft
cawthorne wants to merge 1 commit into
mainfrom
fix/solana-dataslice-zero-offset
Draft

cawthorne wants to merge 1 commit into
mainfrom
fix/solana-dataslice-zero-offset

Conversation

@cawthorne

Copy link
Copy Markdown
Contributor

ConvertDataSliceFromProto converted Offset and Length with ptrUint64, which returns nil for 0. A DataSlice{Offset: 0, Length: N} therefore reached solana-go with a nil offset and was sent to the RPC node as "offset": null, which getAccountInfo rejects:

Invalid params: invalid type: null, expected usize.

Any GetAccountInfoWithOpts call that slices from the start of an account fails this way, through the relayer and the CRE Solana write/read capability. Found while reading Data Feeds accounts from a CRE workflow on Solana devnet; the workaround so far was to start every slice at offset 1.

Offset and length are both required by the RPC when a data slice is set, and 0 is a valid offset, so they are now passed through unchanged. The other ptrUint64 call sites are optional fields and are not touched.

Test: TestConvertDataSliceFromProto_ZeroOffset fails on main (nil offset) and passes with the change.

ConvertDataSliceFromProto mapped 0 to nil through ptrUint64. A dataSlice
starting at offset 0 was then sent to the RPC node as offset: null, which
getAccountInfo rejects ("invalid type: null, expected usize"), so any
read of the first bytes of an account failed. Offset and length are both
required when a dataSlice is set, so pass them through unchanged.
@github-actions

Copy link
Copy Markdown
Contributor

📊 API Diff Results

No changes detected for module github.com/smartcontractkit/chainlink-common

View full report

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant