Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

SDK Instruction constructor implicitly uses bincode serializer #5970

Closed
jstarry opened this issue Sep 19, 2019 · 1 comment · Fixed by #15686
Closed

SDK Instruction constructor implicitly uses bincode serializer #5970

jstarry opened this issue Sep 19, 2019 · 1 comment · Fixed by #15686
Assignees
Milestone

Comments

@jstarry
Copy link
Contributor

jstarry commented Sep 19, 2019

Problem

There is an implicit bincode serialization in the Instruction constructor which is not desirable for creating BPF program instructions because they can't use bincode.

use bincode::serialize;

impl Instruction {
    pub fn new<T: Serialize>(program_id: Pubkey, data: &T, accounts: Vec<AccountMeta>) -> Self {
        let data = serialize(data).unwrap();
        Self {
            program_id,
            data,
            accounts,
        }
    }
}

Proposed Solution

Probably just rename Instruction::new to indicate that only native program instructions should be created with this method.

@mvines mvines added this to the Cloud Nine v0.20.0 milestone Sep 23, 2019
@jackcmay
Copy link
Contributor

bincode is usable by BPF programs but it bloats the binary and is computationally expensive. BPF programs may use this to create instructions in the future so the real solution is to settle on a suitable serialization solution. That solution might be some kind of wrapper that hides actual serialization implementation from the user while keeping it in sync with the consumer.

@mvines mvines modified the milestones: Supertubes v0.22.0, v0.23.0 Nov 25, 2019
@mvines mvines modified the milestones: Tofino v0.23.0, Rincon v0.24.0 Jan 26, 2020
@mvines mvines modified the milestones: Rincon v0.24.0, v0.25.0 Feb 20, 2020
@mvines mvines modified the milestones: v1.1.0, v1.2.0 Mar 16, 2020
@mvines mvines modified the milestones: v1.2.0, The Future! Apr 21, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 30, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants