-
Notifications
You must be signed in to change notification settings - Fork 2
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
authenticated calls using arbitrary cpi [poc and draft] #38
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
.anchor/ | ||
/target | ||
**/.DS_Store | ||
node_modules/ | ||
test-ledger/ |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
[package] | ||
name = "callable-test-2" | ||
version = "0.1.0" | ||
description = "Created with Anchor" | ||
edition = "2021" | ||
|
||
[lib] | ||
crate-type = ["cdylib", "lib"] | ||
name = "callable_test_2" | ||
|
||
[features] | ||
default = [] | ||
cpi = ["no-entrypoint"] | ||
no-entrypoint = [] | ||
no-idl = [] | ||
no-log-ix-name = [] | ||
idl-build = ["anchor-lang/idl-build"] | ||
|
||
[dependencies] | ||
anchor-lang = "0.30.0" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[target.bpfel-unknown-unknown.dependencies.std] | ||
features = [] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
use anchor_lang::prelude::*; | ||
|
||
declare_id!("B7apRShjWeCk2j64MFurBzjpnh5YYuNieMVkMZA7joVv"); | ||
|
||
// NOTE: will be removed, wanted to check if discriminator for on_call will be the same | ||
#[program] | ||
pub mod callable_test_2 { | ||
use super::*; | ||
|
||
pub fn on_call(ctx: Context<OnCall>, sender: Pubkey, data: Vec<u8>) -> Result<()> { | ||
Check warning on line 10 in programs/callable-test-2/src/lib.rs GitHub Actions / clippy[clippy] programs/callable-test-2/src/lib.rs#L10
Raw output
Check warning on line 10 in programs/callable-test-2/src/lib.rs GitHub Actions / clippy[clippy] programs/callable-test-2/src/lib.rs#L10
Raw output
Check warning on line 10 in programs/callable-test-2/src/lib.rs GitHub Actions / clippy[clippy] programs/callable-test-2/src/lib.rs#L10
Raw output
|
||
|
||
Ok(()) | ||
} | ||
} | ||
|
||
#[derive(Accounts)] | ||
pub struct Initialize {} | ||
|
||
#[derive(Accounts)] | ||
pub struct OnCall {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
[package] | ||
name = "callable-test" | ||
version = "0.1.0" | ||
description = "Created with Anchor" | ||
edition = "2021" | ||
|
||
[lib] | ||
crate-type = ["cdylib", "lib"] | ||
name = "callable_test" | ||
|
||
[features] | ||
default = [] | ||
cpi = ["no-entrypoint"] | ||
no-entrypoint = [] | ||
no-idl = [] | ||
no-log-ix-name = [] | ||
idl-build = ["anchor-lang/idl-build"] | ||
|
||
[dependencies] | ||
anchor-lang = { version = "=0.30.0" } |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[target.bpfel-unknown-unknown.dependencies.std] | ||
features = [] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
use anchor_lang::prelude::*; | ||
|
||
declare_id!("HhLWiKkriQSSZmu1Pfa2tkQD87HosDSFUqeuZKeEc88m"); | ||
|
||
#[program] | ||
pub mod callable_test { | ||
use super::*; | ||
|
||
pub fn on_call(ctx: Context<OnCall>, sender: Pubkey, data: Vec<u8>) -> Result<()> { | ||
Check warning on line 9 in programs/callable-test/src/lib.rs GitHub Actions / clippy[clippy] programs/callable-test/src/lib.rs#L9
Raw output
Check warning on line 9 in programs/callable-test/src/lib.rs GitHub Actions / clippy[clippy] programs/callable-test/src/lib.rs#L9
Raw output
Check warning on line 9 in programs/callable-test/src/lib.rs GitHub Actions / clippy[clippy] programs/callable-test/src/lib.rs#L9
Raw output
|
||
// Perform custom logic here based on the received data | ||
|
||
Ok(()) | ||
} | ||
} | ||
|
||
#[derive(Accounts)] | ||
pub struct OnCall {} | ||
|
||
|
||
#[account] | ||
pub struct StorageAccount { | ||
pub last_sender: Pubkey, | ||
pub last_data: Vec<u8>, // Store the last used data | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think it is a set of data that could be potentially represented during the call on ZetaChain using a standard?
A bit like the idea of the Bitcoin memo standard.
User provide a generate bytes input, following a standard, this input is decoded to represent the full call on Solana.
This could be a generic field that we would need to other chain, it seems there will be lot of considerations to have as well for TON smart contract calls
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was not refering to data, but accounts. Accounts that solana programs interact with have to be determined before the call, that is how state is changed with stateless solana programs - state is maintained in accounts that program interacts with, not the program itself (difference with solidity where smart contracts contain state as well). Also important, program can not access those accounts when it executes transaction, the only way is that account need to be passed with instruction, basically preloaded before execution happens.
For example, if someone wants to have
on_call(data)
in their solana program, i would expect they want to somehow store that data, or modify existing data etc, but in order for program to access any state, account containing the state has to be sent inside instruction - in case of making generic calls toon_call
not sure how we can pass any account there, maybe something generic, but not sure.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but this is a piece of information that could be passed in the gateway on ZetaChain?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe it would have to be in call to gateway execute function already and then passed to on_call. But still not sure what we should send there.
@brewmaster012 what do you think about this, could you please check when you get a chance?