-
Notifications
You must be signed in to change notification settings - Fork 15
updates current docs to reflect recent changes to our contracts and the coprocessor now that they're tied together #436
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,14 @@ | ||
| # Authorization & Processors | ||
|
|
||
| The **Authorization** and **Processor** contracts are foundational pieces of the **Valence Protocol**, as they enable on-chain (and cross-chain) execution of **Valence Programs** and enforce access control to the program's **Subroutines** via **Authorizations**. | ||
| The Authorization and Processor contracts are foundational pieces of the Valence Protocol, as they enable execution of Valence Programs and enforce access control to the program's Subroutines via Authorizations. | ||
|
|
||
| This section explains the rationale for these contracts and shares insights into their technical implementation, as well as how end-users can interact with **Valence Programs** via **Authorizations**. | ||
| This section explains the rationale for these contracts and shares insights into their technical implementation, as well as how end-users can interact with Valence Programs via Authorizations. | ||
|
|
||
| ## Rationale | ||
|
|
||
| - To have a general purpose set of smart contracts that provide users with a single point of entry to interact with the Valence Program, which can have libraries and accounts deployed on multiple chains. | ||
| - To have all the user authorizations for multiple domains in a single place, making it very easy to control the application. | ||
| - To have a single address (Processor) that will execute the messages for all the contracts in a domain using execution queues. | ||
| - To only tick a single contract (Processor) that will go through the queues to route and execute the messages. | ||
| - To provide users with a single point of entry to interact with the Valence Program through controlled access to library functions. | ||
| - To centralize user authorizations and permissions, making it easy to control application access. | ||
| - To have a single address (Processor) that will execute the authorized messages. On CosmWasm this uses execution queues and permissionless ticks; on EVM the Lite Processor executes immediately (no queues). | ||
| - To create, edit, or remove different application permissions with ease. | ||
|
|
||
| Note: Programs can optionally include libraries and accounts deployed across multiple domains for certain multi-chain scenarios. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 20 additions & 2 deletions
22
docs/src/authorizations_processors/authorization_contract.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,23 @@ | ||
| # Authorization Contract | ||
|
|
||
| The Authorization contract will be a single contract deployed on the main domain and that will define the authorizations of the top-level application, which can include libraries in different domains (chains). For each domain, there will be one Processor in charge of executing the functions on the libraries. The Authorization contract will connect to all of the Processor contracts using a connector (e.g. Polytone Note, Hyperlane Mailbox…) and will route the message batches to be executed to the right domain. At the same time, for each external domain, we will have a proxy contract (e.g. Polytone Proxy, Hyperlane Mailbox...) in the main domain which will receive the callbacks sent from the processor on the external domain with the `ExecutionResult` of the `MessageBatch`. | ||
| The Authorization contract serves as the authority and message routing hub for Valence Programs. It supports two distinct authorization mechanisms: standard authorizations for traditional access control and ZK authorizations for zero-knowledge proof–based execution. | ||
|
|
||
| The contract will be instantiated once at the very beginning and will be used during the entire top-level application lifetime. Users will never interact with the individual Smart Contracts of each program, but with the Authorization contract directly. | ||
| A Valence Program has one Authorization contract and one Processor contract per domain. The Authorization contract defines authorizations that control access to library functions within the program. The contract validates user permissions and routes authorized messages to the associated Processor contract for execution. | ||
|
|
||
| ## Standard Authorizations | ||
|
|
||
| Standard authorizations use a label-based system with different authorization modes. | ||
|
|
||
| - CosmWasm: Permissionless authorizations allow anyone to execute (default Medium priority). Permissioned authorizations are enforced with per‑label TokenFactory tokens. With call limit, one token is consumed (burned on success, refunded on failure) per execution; without call limit, holding one token suffices. Tokens use `factory/{authorization_contract}/{label}` and enable on-chain transferability. | ||
| - EVM: Permissioned access is enforced per label with address allowlists and function‑level constraints. For each label, the contract stores an array of AuthorizationData entries containing the target contract address and either the function selector or a call hash. No tokens are minted; authorization is purely address/function based. | ||
|
|
||
| For standard message execution, the contract validates sender permissions and authorization state, ensures the message(s) align with the label’s subroutine configuration, routes the message to the Processor, and processes callbacks. On CosmWasm, token mint/burn/refund applies for call‑limited flows. | ||
|
|
||
| ## ZK Authorizations | ||
|
|
||
| ZK authorizations enable proof‑based execution via a registry‑keyed configuration. Each registry stores allowed execution addresses, a verification key, a verification route (for a VerificationRouter), optional last‑block validation for replay prevention, and a metadata hash linking the VK to the program. | ||
|
|
||
| - EVM: Users call `executeZKMessage(bytes inputs, bytes proof, bytes payload)`. The Authorization verifies sender allowance, optional replay protection, then routes to the `VerificationRouter.verify(route, vk, proof, inputs, payload)`. On success, it injects the current `executionId` into SendMsgs/InsertMsgs and forwards to the Processor. | ||
| - CosmWasm: Users call `ExecuteZkAuthorization { label, inputs, proof, payload }`. The Authorization verifies sender allowance and optional last‑block execution checks, uses the configured verification route, and forwards the decoded Processor message. | ||
|
|
||
| Note: CosmWasm cross‑domain routing uses Polytone (CosmWasm↔CosmWasm). EVM cross‑domain routing uses Hyperlane mailboxes. Both environments support callbacks to the Authorization for execution results. | ||
22 changes: 17 additions & 5 deletions
22
docs/src/authorizations_processors/authorization_instantiation.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,23 @@ | ||
| # Instantiation | ||
|
|
||
| When the contract is instantiated, it will be provided the following information: | ||
| Instantiation parameters vary slightly between CosmWasm and EVM. | ||
|
|
||
| - Processor contract on main domain. | ||
| ## CosmWasm | ||
|
|
||
| - Owner of the contract. | ||
| The Authorization contract is instantiated with: | ||
|
|
||
| - List of subowners (if any). Users that can execute the same actions as the owner except adding/removing other subowners. | ||
| - Processor contract address on the main domain | ||
| - Owner address | ||
| - Optional list of sub‑owners (second‑tier owners who can perform all actions except sub‑owner management) | ||
|
|
||
| Once the Authorization contract is deployed, we can already start adding and executing authorizations on the domain that the Authorization contract was deployed on. To execute functions on other domains, the owner will have to add external domains to the Authorization contract with all the information required for the Authorization contract to route the messages to that domain. | ||
| Once deployed, authorizations can be created and executed on the main domain. To execute on other domains, the owner adds external domains with connector details (Polytone for CosmWasm domains; Hyperlane + encoder info for EVM domains). | ||
|
|
||
| ## EVM | ||
|
|
||
| `constructor(address owner, address processor, bool storeCallbacks)` | ||
|
|
||
| - `owner`: the contract owner (Ownable) | ||
| - `processor`: the Processor contract address | ||
| - `storeCallbacks`: whether to persist processor callbacks on‑chain (otherwise only events are emitted) | ||
|
|
||
| EVM does not use sub‑owners; instead, the owner can add or remove admin addresses that are permitted to perform privileged updates. Cross‑domain routing is handled via Hyperlane mailboxes (set during Processor deployment), not at Authorization instantiation time. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
docs/src/authorizations_processors/authorization_user_actions.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,15 @@ | ||
| # User Actions | ||
|
|
||
| ## CosmWasm | ||
|
|
||
| - `send_msgs(label, vec[ProcessorMessage])`: users can run an authorization with a specific label. If the authorization is `Permissioned (without limit)`, the Authorization contract will check if their account is allowed to execute by checking that the account holds the token in its wallet. If the authorization is `Permissioned (with limit)` the account must attach the authorization token to the contract execution. Along with the authorization label, the user will provide an array of encoded messages, together with the message type (e.g. `CosmwasmExecuteMsg`, `EvmCall`, etc.) and any other parameters for that specific ProcessorMessage (e.g. for a `CosmwasmMigrateMsg` we need to also pass a code_id). The contract will then check that the messages match those defined in the authorization, that the messages appear in correct order, and that any applied parameter restrictions are correct. | ||
|
|
||
| If all checks are correct, the contract will route the messages to the correct Processor with an `execution_id` for the processor to callback with. This `execution_id` is unique for the entire application. | ||
| If execution of all actions is confirmed via a callback, the authorization token is burned. If execution fails, the token is sent back. | ||
| Here is an example flowchart of how a user interacts with the Authorization contract to execute functions on an external CosmWasm domain that is connected to the main domain with Polytone: | ||
|
|
||
|  | ||
|
|
||
| ## EVM | ||
|
|
||
| - `sendProcessorMessage(string label, bytes message)`: users submit an ABI‑encoded `ProcessorMessage` (as defined in `IProcessorMessageTypes`) with the target label. The contract verifies the sender against the label’s allowlist and validates the messages against the subroutine’s function set (contract address + function selector or call hash). For SendMsgs/InsertMsgs, the Authorization injects the current `executionId` before forwarding to the Processor. There is no tokenization on EVM; authorization is address/function constrained. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This sentence is quite long and lists several properties of a ZK authorization registry. For better readability, consider formatting this as a bulleted list.