Skip to content

program: Add optional buffer to Write instruction#8

Merged
febo merged 5 commits intomainfrom
febo/buffer-on-write
Mar 31, 2025
Merged

program: Add optional buffer to Write instruction#8
febo merged 5 commits intomainfrom
febo/buffer-on-write

Conversation

@febo
Copy link
Contributor

@febo febo commented Mar 28, 2025

Problem

Currently, the Write instruction only accepts the data to write as instruction data. This limits each write to the maximum transaction size.

Solution

Add an optional buffer account to allow passing more data for a single write. This is useful when writing to PDA accounts controlled by multisigs, since the process of writing the data to a buffer can be done by a separate keypair.

@lorisleiva lorisleiva marked this pull request as ready for review March 29, 2025 11:30
Copy link
Member

@lorisleiva lorisleiva left a comment

Choose a reason for hiding this comment

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

Thanks Febo! I've done the JS side. Let me know if you're happy with it and LGTM. 💪

@febo
Copy link
Contributor Author

febo commented Mar 30, 2025

Thanks Febo! I've done the JS side. Let me know if you're happy with it and LGTM. 💪

Nice! Something that just occurred to me. Perhaps the offset should be optional and only used when writing from the instruction data. If you are writing from a buffer, most likely the buffer has all the data so the offset will be always 0.

@lorisleiva
Copy link
Member

Perhaps the offset should be optional

I think I prefer having it required to explicitly hint that you are going to override data from the provided offset. Otherwise users providing multiple write instructions using instruction data might wrongly assume it'll be appended when in actual fact, the first part of the buffer will keep being written to.

@febo
Copy link
Contributor Author

febo commented Mar 31, 2025

Perhaps the offset should be optional

I think I prefer having it required to explicitly hint that you are going to override data from the provided offset. Otherwise users providing multiple write instructions using instruction data might wrongly assume it'll be appended when in actual fact, the first part of the buffer will keep being written to.

I was thinking making both offset and data optional at the same time. So if you specify the data you need to inform the offset. When you use a buffer, then there is no need specify an offset.

@febo
Copy link
Contributor Author

febo commented Mar 31, 2025

Perhaps the offset should be optional

I think I prefer having it required to explicitly hint that you are going to override data from the provided offset. Otherwise users providing multiple write instructions using instruction data might wrongly assume it'll be appended when in actual fact, the first part of the buffer will keep being written to.

I was thinking making both offset and data optional at the same time. So if you specify the data you need to inform the offset. When you use a buffer, then there is no need specify an offset.

Spoke offline, better to keep the offset explicit so when overriding the whole data the offset must be 0.

@febo febo merged commit 3b662b9 into main Mar 31, 2025
7 checks passed
@febo febo deleted the febo/buffer-on-write branch March 31, 2025 16:58
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.

2 participants