coral-xyz / anchor

⚓ Solana Sealevel Framework
https://anchor-lang.com
Apache License 2.0
3.63k stars 1.33k forks source link

examples: Timelock program #91

Open armaniferrante opened 3 years ago

armaniferrante commented 3 years ago

A useful example would be a timelock program that executes an arbitrary transaction at a specified point in time in the future.

jon-chuang commented 3 years ago

This is interesting! Should it use sysvar::clock()?

armaniferrante commented 3 years ago

Yes the clock sysvar should be used.

jon-chuang commented 3 years ago

I don't think this can work in the runtime as implemented - the team mentioned the need for a sort of system-level cronjob.

armaniferrante commented 3 years ago

Correct. One would need to trigger the program externally with a permissionless transaction. Even so, this is still very usefull. For example, one compelling use case is for one to compose a multisig program with a timelock program to perform program upgrades.

jon-chuang commented 3 years ago

Looking at the multisig program, I was wondering if it could be generalized to a weighted threshold sig program, where the weight of each signature lives on an account controlled by a separate program - that for instance being a governance token.

So you point the generic program to the weighted address = weight + sig file. I guess similarly, multisig has to be deployed per set of sigs, since the authorisation model is that a particular program must sign off. I wonder if this inefficiency can be circumvented.

jon-chuang commented 3 years ago

Hi @armaniferrante , I've recently shown how multisig program taken to its generic conclusion is equivalent to a pupeteer which can also schedule transactions at arbitrary times or recur them indefinitely.

You can take a look here: https://github.com/solana-labs/solana/issues/17218

WrRaThY commented 3 years ago

@jon-chuang - do you have any implementation of this? I will need something like that in my program ;)

eydelrivero commented 3 years ago

I'm interested in this use case but... how a "permissionless transaction" work to externally trigger the program? Can the program itself pay for the transaction using balance from a pda account? Or is the external party required to sign and pay for the transaction?