Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[token22] Avoid the use of extend_from_slice when appending instructions #7489

Merged
merged 1 commit into from
Nov 13, 2024

Conversation

samkim-crypto
Copy link
Contributor

@samkim-crypto samkim-crypto commented Nov 12, 2024

Problem

In the confidential mint and burn extension, the vector of proof instructions are appended to the token instruction using the extend_from_slice method, which requires the underlying element type of the slice to implement the Clone trait. Though minimal, it is better to use the extend function that subsumes the input vector since extend does not require the underlying element type to be implement any trait.

This is relevant when building the token22 program for wasm target. The Instruction type implements Clone for non-wasm targets, but does not seem to implement it for wasm targets (https://github.com/anza-xyz/agave/blob/master/sdk/instruction/src/lib.rs#L108).

Summary of Changes

Replace extend_from_slice with extend.

@samkim-crypto samkim-crypto marked this pull request as ready for review November 13, 2024 02:49
Copy link
Contributor

@joncinque joncinque left a comment

Choose a reason for hiding this comment

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

This is relevant when building the token22 program for wasm target. The Instruction type implements Clone for non-wasm targets, but does not seem to implement it for wasm targets (https://github.com/anza-xyz/agave/blob/master/sdk/instruction/src/lib.rs#L108).

Bah, this looks like it was a bug introduced in anza-xyz/agave#1658 -- there's no reason we shouldn't derive those for the wasm build. I'll put a fix in there. In the meantime, this change looks good!

@samkim-crypto samkim-crypto merged commit 2d795f1 into solana-labs:master Nov 13, 2024
35 checks passed
joncinque added a commit to joncinque/solana that referenced this pull request Nov 13, 2024
#### Problem

As noticed in
solana-labs/solana-program-library#7489, the
wasm build for `Instruction` doesn't contain `Clone`. This is because we
missed the derivations for the wasm version of `Instruction` in
anza-xyz#1658.

#### Summary of changes

Looking back through that PR, I noticed that we only missed those
additional derives on `Instruction`, so just fix those in `Instruction`.

Since this is fixing a small regression for wasm builds, I think we
should backport the change to v2.1.
mergify bot pushed a commit to anza-xyz/agave that referenced this pull request Nov 13, 2024
#### Problem

As noticed in
solana-labs/solana-program-library#7489, the
wasm build for `Instruction` doesn't contain `Clone`. This is because we
missed the derivations for the wasm version of `Instruction` in
#1658.

#### Summary of changes

Looking back through that PR, I noticed that we only missed those
additional derives on `Instruction`, so just fix those in `Instruction`.

Since this is fixing a small regression for wasm builds, I think we
should backport the change to v2.1.
mergify bot pushed a commit to anza-xyz/agave that referenced this pull request Nov 13, 2024
#### Problem

As noticed in
solana-labs/solana-program-library#7489, the
wasm build for `Instruction` doesn't contain `Clone`. This is because we
missed the derivations for the wasm version of `Instruction` in
#1658.

#### Summary of changes

Looking back through that PR, I noticed that we only missed those
additional derives on `Instruction`, so just fix those in `Instruction`.

Since this is fixing a small regression for wasm builds, I think we
should backport the change to v2.1.

(cherry picked from commit d3bce9f)
joncinque added a commit to anza-xyz/agave that referenced this pull request Nov 18, 2024
… (#3610)

instruction: Derive everything for wasm build (#3606)

#### Problem

As noticed in
solana-labs/solana-program-library#7489, the
wasm build for `Instruction` doesn't contain `Clone`. This is because we
missed the derivations for the wasm version of `Instruction` in
#1658.

#### Summary of changes

Looking back through that PR, I noticed that we only missed those
additional derives on `Instruction`, so just fix those in `Instruction`.

Since this is fixing a small regression for wasm builds, I think we
should backport the change to v2.1.

(cherry picked from commit d3bce9f)

Co-authored-by: Jon C <[email protected]>
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