warning: The program is not properly tested yet. Kindly only use it for the testing purpose. Refrain from using the code for production purpose in any way.
Cordelia is an experimental Solana multi-sig program which lets you create multi-sig instances and execute transactions containing arbitrary instructions using CPI calls. We have taken inspiration from Squads MPL program.
Rather than a normal M-of-N owner scheme, Cordelia is created using Strata model. The owners of the multi-sig can be divided into different groups (known as Stratum) and threshold can be set separately for every stratum. To successfully execute any transaction, owners from every stratum have to vote in number atleast equal to stratum's threshold count.
Program Address: 2h4ZQdRQESZETBWh6mC9pgLGca8ytMR5GcCqMsUACyyY (deployed on both mainnet and devnet)
-
Multi-sig has
stratafield which is a vector ofStratum. The first element ofstratavector is a baseStratumand must have at least 1 owner. EveryStratumcan have separate owners and threshold and an individualPubkeycan only be a member of a single stratum.multi_sigaccount is seeded using the creator's key and a unique name chosen at the time of creation (can be of maximum 25 characters). -
Transactions are seeded using
transaction_countfield saved inmulti_sigwhich is incremented after every transaction creation.transactionhas two vector fields:acceptedandrejectedwhose length is equal to the length ofstratafield inmulti_sigand save the number of accepted or rejected votes for a particular transaction in the form ofu16. Transaction has aversionfield and becomes outdated if any change is made tostrataafter its creation if it is still pending acceptance. -
TxData is an account seeded with the
Pubkeyoftransactionand saves the instructions in the form of vector. Instructions are saved in a custom format known asInstructionDatawhich further haskeysfield which savesAccountMetaneeded for instruction in a custom type:InstructionAccount. -
Vote Record is a PDA seeded with the
Pubkeyof transaction and owner. It ensures that an owner can only vote once for each transaction.
-
Multi-sig can be created using
create_multisiginstruction by passing the list of owners and threshold as vector ofStratum. -
A transaction can be added to multi-sig using
create_transactioninstruction and increments the field intransaction_countinmulti_sig. -
TxData for a transaction can be created using either of the two instructions:
create_tx_datafor legacy transactions andcreate_versioned_tx_datafor Version transactions. Increate_tx_datainstruction, accounts needed for the instruction are passed as an argument whereas increate_versioned_tx_data, accounts are passed inremaining_accountsarray in a specified format. -
More accounts can be inserted into instructions saved in TxData account by using
add_tx_datawhich accepts two arguments - vector ofInstructionAccountand index of the instuction where accounts are to be inserted. The data in TxData can be finalized and transaction can be sent to vote usingfinalize_tx_datainstruction. -
vote_transactioninstruction is used to vote for a transaction and the vote is expressed in the form ofboolargument wheretruemeans accept andfalsemeans reject. If the number of rejected votes become more such that it is no longer possible to reach the threshold, the transaction's status is set toRejectedand no further interaction with the transaction is allowed. -
accept_transactioninstruction is used to mark the transaction's status asAcceptedif the transaction satisfies threshold requirement of every Stratum. The transaction can only be executed if the status is set toAccepted. -
The transaction can finally be executed using
execute_transactionwhich signs the transaction using PDA authority seeded withmulti_sigkey andb"authority". -
To make the internal changes, two special instructions are used:
change_multi_sigandchange_multi_sig_realloc. Both are used for different purposes as follows:
Change Multi Sig: To make changes which doesn't require a change in the size of multi_sig account. It accepts the type of change in the form of enum which can have four values: RemoveOwner, ChangeM (for threshold), ActivateStratum and DeactivateStratum.
Change Multi Sig Realloc: To make changes which requires a change in the size of multi_sig account. It accepts the type of change in the form of enum which can have two values: AddOwner and AddStratum.
At this moment the constraints are set manually to avoid overflow but will be set programmatically after the proper testing:
- Max number of Stratums: 256
- Max number of owners in Stratum: 1220
- Max number of transactions in Multi-sig: u32::MAX