From f30fb324ff4e42d50e11e0169f4f88e6b9261854 Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Tue, 28 Nov 2023 11:51:24 +0300 Subject: [PATCH] [#55] policy: Swap signature check order While implementing the changes for FrostFS ID it became obvious, that committee signature check can be rather costly (`getCommittee` call + multiaddress construction + checking witness). In real scenarious it will mostly fail, so it makes sense do it last. Signed-off-by: Evgenii Stratonikov --- policy/policy_contract.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/policy/policy_contract.go b/policy/policy_contract.go index 86d5e41..c485771 100644 --- a/policy/policy_contract.go +++ b/policy/policy_contract.go @@ -47,14 +47,13 @@ func _deploy(data any, isUpdate bool) { } func checkAuthorization(ctx storage.Context) { - if runtime.CheckWitness(common.AlphabetAddress()) { - return - } - admin := getAdmin(ctx) if admin != nil && runtime.CheckWitness(admin) { return } + if runtime.CheckWitness(common.AlphabetAddress()) { + return + } panic(ErrNotAutorized) }