Expand description

All structures and related functions representing a Rule Set on-chain.

Key types include the main RuleSetV1 type which keeps the the map of operations to Rules, as well as RuleSetHeader and RuleSetRevisionMapV1 types used to manage data within the RuleSet PDA.

Each time a RuleSet is updated, a new revision is added to the PDA, and previous revisions never deleted. The revision map is needed so that during RuleSet validation the desired revision can be selected by the user.

Because the RuleSets and the revision map are variable size, a fixed size header is stored at the beginning of the RuleSet PDA that allows new RuleSets and updated revision maps to be added to the PDA without moving the previous revision RuleSets and without losing the revision map’s location.

Also note there is a 1-byte version preceding each RuleSet revision and the revision map. This is not included in the data struct itself to give flexibility to update RuleSets and the revision map data structs and even change serialization format.

RuleSet PDA data layout

| Header  | RuleSet version | RuleSet Revision 0 | RuleSet version | RuleSet Revision 1 | RuleSet version | RuleSet Revision 2 | ... | RuleSetRevisionMap version | RuleSetRevisionMap |
|---------|-----------------|--------------------|-----------------|--------------------|-----------------|--------------------|-----|----------------------------|--------------------|
| 9 bytes | 1 byte          | variable bytes     | 1 byte          | variable bytes     | 1 byte          | variable bytes     | ... | 1 byte                     | variable bytes     |

Structs

  • An account containing frequency state.
  • Header used to keep track of where RuleSets are stored in the PDA. This header is meant to be stored at the beginning of the PDA and never be versioned so that it always has the same serialized size. See top-level module for description of PDA memory layout.
  • Revision map used to keep track of where individual RuleSet revisions are stored in the PDA. See top-level module for description of PDA memory layout.
  • The struct containing all Rule Set data, most importantly the map of operations to Rules. See top-level module for description of PDA memory layout.

Enums

  • Operators that can be used to compare against an Amount rule.
  • The key at the beginning of the serialized account that identifies the account type. NOTE: This is not used for the RuleSet account, which uses msgpack instead of Borsh for SerDes.
  • The struct containing every type of Rule and its associated data.
  • Enum representation of Rule failure conditions

Constants

Traits

  • A trait implementing generic functions required by all accounts on Solana.