-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
acf5c20
commit 362ea8c
Showing
4 changed files
with
57 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
The AllowList allows a precompile to enforce permissions on addresses. The AllowList is not a contract itself, but a helper structure providing a control mechanism for wrapping contracts. It provides an AllowListConfig to the precompile so that it can take an initial configuration from genesis/upgrade. | ||
|
||
Precompiles using an Allow List have two roles: Admin, Manager and Enabled. For each role, a list of addresses can be defined. | ||
|
||
- Enabled addresses can perform the permissioned behavior (issuing transactions, deploying contracts, etc.), but cannot modify other roles. | ||
-Manager addresses can use the precompile, and can change enabled addresses | ||
- Admin addresses have the same rights, but can also add/remove other Admin, Manager and Enabled addresses. | ||
|
||
AllowList adds adminAddresses and enabledAddresses fields to precompile contract configurations. For instance, txAllowList precompile contract configuration looks like this: | ||
|
||
```json | ||
"txAllowListConfig": { | ||
"blockTimestamp": 0, | ||
"adminAddresses": ["0x8db97C7cEcE249c2b98bDC0226Cc4C2A57BF52FC","0x0000...", "... and more"], | ||
"enabledAddresses": ["... and even more"] | ||
} | ||
``` | ||
|
||
AllowList configuration affects only the related precompile. For instance, the admin address in txAllowList does not affect admin addresses in other activated precompiles. | ||
|
||
# Interacting with the AllowList from Solidity | ||
|
||
The AllowList Solidity interface is defined below. AllowList is not an actual contract but just an interface. It's not callable by itself. This is used by other precompiles. | ||
|
||
```solidity | ||
pragma solidity ^0.8.0; | ||
interface IAllowList { | ||
// Set [addr] to have the admin role over the precompile contract. | ||
function setAdmin(address addr) external; | ||
// Set [addr] to be enabled on the precompile contract. | ||
function setEnabled(address addr) external; | ||
// Set [addr] to have the manager role over the precompile contract. | ||
function setManager(address addr) external; | ||
// Set [addr] to have no role for the precompile contract. | ||
function setNone(address addr) external; | ||
// Read the status of [addr]. | ||
function readAllowList(address addr) external view returns (uint256 role); | ||
} | ||
``` | ||
|
||
`readAllowList(addr)` will return a `uint256` with a value of `0`, `1`, `2` or `3`, corresponding to the roles None, Enabled, Admin and Manager respectively. |
This file contains 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 |
---|---|---|
|
@@ -3,4 +3,4 @@ title: 🗺️ Recap Precompiles | |
description: TBD | ||
updated: 2024-05-31 | ||
authors: [ashucoder9] | ||
--- | ||
--- |
10 changes: 10 additions & 0 deletions
10
content/course/teleporter-token-bridge/08-recap-precompiles/02-allowlist.mdx
This file contains 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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
title: 📕 Allowlist | ||
description: TBD | ||
updated: 2024-05-31 | ||
authors: [ashucoder9] | ||
--- | ||
|
||
import AllowList from "@/content/common/evm-precompiles/allowlist.mdx"; | ||
|
||
<AllowList /> |
File renamed without changes.