Skip to content

Conversation

Riateche
Copy link
Contributor

@Riateche Riateche commented Feb 27, 2025

Summary

  • Support LeEcdsa payload in Solana contract
  • Track EVM addresses in Solana contract for ECDSA verification

Rationale

Consumers asked for it.

How has this been tested?

  • Current tests cover my changes
  • Added new tests
  • Manually tested the code

Copy link

vercel bot commented Feb 27, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
api-reference ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 4, 2025 1:36pm
proposals ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 4, 2025 1:36pm
staking ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 4, 2025 1:36pm
3 Skipped Deployments
Name Status Preview Comments Updated (UTC)
component-library ⬜️ Ignored (Inspect) Visit Preview Mar 4, 2025 1:36pm
entropy-debugger ⬜️ Ignored (Inspect) Visit Preview Mar 4, 2025 1:36pm
insights ⬜️ Ignored (Inspect) Visit Preview Mar 4, 2025 1:36pm


[dependencies]
pyth-lazer-protocol = "0.5.0"
pyth-lazer-protocol = { path = "../../../../sdk/rust/protocol", version = "0.6.0" }
Copy link
Contributor

Choose a reason for hiding this comment

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

Are you gonna change this back to getting protocol from registry before merging?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We should leave it like this. It will use the local version when working within the workspace, and the published version will use the published dependency.

let message = LeEcdsaMessage::deserialize_slice(&message_data)
.map_err(|_| ProgramError::InvalidInstructionData)?;

let pubkey = secp256k1_recover(
Copy link
Contributor

Choose a reason for hiding this comment

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

does this function validate the signature too?

Copy link
Collaborator

Choose a reason for hiding this comment

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

it's walking backwards. it gives you the address that has generated the given signature. Then we should check it matches one of our trusted signers.

return Err(ProgramError::AccountDataTooSmall.into());
}
if trusted_signers.len() > MAX_NUM_TRUSTED_SIGNERS {
return Err(ProgramError::InvalidInstructionData.into());
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's better to have more detailed error messages. I remember when I was debugging an error on mainnet it was really hard to figure out where exactly an error was happening because a single error message can be thrown in multiple places.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree. Let's handle it as a separate task though.

pub const MAX_NUM_TRUSTED_SIGNERS: usize = 2;
pub const SPACE_FOR_TRUSTED_SIGNERS: usize = 5;
pub const EXTRA_SPACE: usize = 100;
pub const SPACE_FOR_TRUSTED_ECDSA_SIGNERS: usize = 2;
Copy link
Collaborator

Choose a reason for hiding this comment

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

would it be ok for us to be more flexible here? like allow 5 trusted signers for this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We don't have enough space for 5 signers in the currently allocated space.

let message = LeEcdsaMessage::deserialize_slice(&message_data)
.map_err(|_| ProgramError::InvalidInstructionData)?;

let pubkey = secp256k1_recover(
Copy link
Collaborator

Choose a reason for hiding this comment

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

it's walking backwards. it gives you the address that has generated the given signature. Then we should check it matches one of our trusted signers.

@Riateche Riateche force-pushed the lazer-solana-ecdsa branch from 5903931 to 85bedd0 Compare March 4, 2025 13:32
@Riateche Riateche merged commit 2efd545 into main Mar 4, 2025
10 checks passed
@Riateche Riateche deleted the lazer-solana-ecdsa branch March 4, 2025 13:45
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.

3 participants