From fa14df14faa1405b273017ccf60477d44064f3f4 Mon Sep 17 00:00:00 2001 From: Ceyhun Onur Date: Mon, 30 Jan 2023 15:34:25 +0300 Subject: [PATCH 1/4] fix allow list comments --- precompile/allow_list.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/precompile/allow_list.go b/precompile/allow_list.go index e411b5eba4..1e66202e12 100644 --- a/precompile/allow_list.go +++ b/precompile/allow_list.go @@ -23,9 +23,12 @@ const ( ) var ( - AllowListNoRole AllowListRole = AllowListRole(common.BigToHash(big.NewInt(0))) // No role assigned - this is equivalent to common.Hash{} and deletes the key from the DB when set - AllowListEnabled AllowListRole = AllowListRole(common.BigToHash(big.NewInt(1))) // Deployers are allowed to create new contracts - AllowListAdmin AllowListRole = AllowListRole(common.BigToHash(big.NewInt(2))) // Admin - allowed to modify both the admin and deployer list as well as deploy contracts + // No role assigned - this is equivalent to common.Hash{} and deletes the key from the DB when set + AllowListNoRole AllowListRole = AllowListRole(common.BigToHash(big.NewInt(0))) + // Enabled - allowed to use state-changing precompile functions precompiles without modifying status of other admins or enableds + AllowListEnabled AllowListRole = AllowListRole(common.BigToHash(big.NewInt(1))) + // Admin - allowed to modify both the admin and enabled list as well as use state-changing precompile functions + AllowListAdmin AllowListRole = AllowListRole(common.BigToHash(big.NewInt(2))) // AllowList function signatures setAdminSignature = CalculateFunctionSelector("setAdmin(address)") From a4bf02f2207e773b7daeaad28ec8244b56bc6e46 Mon Sep 17 00:00:00 2001 From: Ceyhun Onur Date: Mon, 30 Jan 2023 15:36:14 +0300 Subject: [PATCH 2/4] cleaner sentences --- precompile/allow_list.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/precompile/allow_list.go b/precompile/allow_list.go index 1e66202e12..4cc6178f8d 100644 --- a/precompile/allow_list.go +++ b/precompile/allow_list.go @@ -25,9 +25,9 @@ const ( var ( // No role assigned - this is equivalent to common.Hash{} and deletes the key from the DB when set AllowListNoRole AllowListRole = AllowListRole(common.BigToHash(big.NewInt(0))) - // Enabled - allowed to use state-changing precompile functions precompiles without modifying status of other admins or enableds + // Enabled - allowed to use state-changing precompile functions without modifying status of other admins or enableds AllowListEnabled AllowListRole = AllowListRole(common.BigToHash(big.NewInt(1))) - // Admin - allowed to modify both the admin and enabled list as well as use state-changing precompile functions + // Admin - allowed to modify both the admin and enabled list, as well as to use state-changing precompile functions AllowListAdmin AllowListRole = AllowListRole(common.BigToHash(big.NewInt(2))) // AllowList function signatures From e93a98a60b913f87eaaa660b2dcbb86d5fd273cb Mon Sep 17 00:00:00 2001 From: Ceyhun Onur Date: Mon, 30 Jan 2023 20:35:25 +0300 Subject: [PATCH 3/4] use preallocated big nums --- precompile/allow_list.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/precompile/allow_list.go b/precompile/allow_list.go index 4cc6178f8d..58974c4c89 100644 --- a/precompile/allow_list.go +++ b/precompile/allow_list.go @@ -6,7 +6,6 @@ package precompile import ( "errors" "fmt" - "math/big" "github.com/ava-labs/subnet-evm/vmerrs" "github.com/ethereum/go-ethereum/common" @@ -24,11 +23,11 @@ const ( var ( // No role assigned - this is equivalent to common.Hash{} and deletes the key from the DB when set - AllowListNoRole AllowListRole = AllowListRole(common.BigToHash(big.NewInt(0))) + AllowListNoRole AllowListRole = AllowListRole(common.BigToHash(common.Big0)) // Enabled - allowed to use state-changing precompile functions without modifying status of other admins or enableds - AllowListEnabled AllowListRole = AllowListRole(common.BigToHash(big.NewInt(1))) + AllowListEnabled AllowListRole = AllowListRole(common.BigToHash(common.Big1)) // Admin - allowed to modify both the admin and enabled list, as well as to use state-changing precompile functions - AllowListAdmin AllowListRole = AllowListRole(common.BigToHash(big.NewInt(2))) + AllowListAdmin AllowListRole = AllowListRole(common.BigToHash(common.Big2)) // AllowList function signatures setAdminSignature = CalculateFunctionSelector("setAdmin(address)") From 19260c57e221bc62cb9208760cf83c95d4748f4f Mon Sep 17 00:00:00 2001 From: Ceyhun Onur Date: Mon, 30 Jan 2023 22:37:12 +0300 Subject: [PATCH 4/4] infer allow list role type --- precompile/allow_list.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/precompile/allow_list.go b/precompile/allow_list.go index 58974c4c89..5914718ae7 100644 --- a/precompile/allow_list.go +++ b/precompile/allow_list.go @@ -23,11 +23,11 @@ const ( var ( // No role assigned - this is equivalent to common.Hash{} and deletes the key from the DB when set - AllowListNoRole AllowListRole = AllowListRole(common.BigToHash(common.Big0)) + AllowListNoRole = AllowListRole(common.BigToHash(common.Big0)) // Enabled - allowed to use state-changing precompile functions without modifying status of other admins or enableds - AllowListEnabled AllowListRole = AllowListRole(common.BigToHash(common.Big1)) + AllowListEnabled = AllowListRole(common.BigToHash(common.Big1)) // Admin - allowed to modify both the admin and enabled list, as well as to use state-changing precompile functions - AllowListAdmin AllowListRole = AllowListRole(common.BigToHash(common.Big2)) + AllowListAdmin = AllowListRole(common.BigToHash(common.Big2)) // AllowList function signatures setAdminSignature = CalculateFunctionSelector("setAdmin(address)")