-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* update pact for pact-4.4 * set up initial gas environment * wip fix tests * fix rosetta gas bound * update pin to latest master * Fix spcae mistake in ns.pact * get started on pactinprocapi test * wip tests to pre/post fork conditions in define-keyset * all tests pre-post fork * update pin with latest master * Remove now nonexistent flag * initial rewrite * remove unnecessary flag * parser fixes * kludgy first implementation * WIP repl tests * Add initial coverage, get code working * latest pact master * bless old contract * add ns-v2.yaml * hook up repl tests to pact tests for ns (v1 and v2) * undo checkpointer change * move stale logic out of contract defn * Principal namespaces: use hashes, rework upgrade methodology (#1534) * slp: move files around for better diff, get gas payer working * don't use registry for principal namespaces * remove dupe validate * fix mainnet genesis yaml * use previous install in repl * move to hashes of principals * prefix namespaces with "n" * move to 160 bit hex namespaces * use "n_" prefix * update comment Co-authored-by: Stuart Popejoy <[email protected]> * add typecheck for principal type + test * add (wip) test for failed upgrade + comments * purge pact history * add weird test for upgrades * stuarts comments Co-authored-by: Jose <[email protected]> Co-authored-by: Edmund Noble <[email protected]> Co-authored-by: Edmund Noble <[email protected]> Co-authored-by: Stuart Popejoy <[email protected]> Co-authored-by: Stuart Popejoy <[email protected]>
- Loading branch information
1 parent
87dc1c0
commit b1ebd0b
Showing
9 changed files
with
352 additions
and
33 deletions.
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
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
codeFile: ../../namespaces/ns.pact | ||
codeFile: ../../namespaces/v1/ns.pact | ||
data: | ||
ns-admin-keyset: | ||
keys: | ||
|
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
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
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
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,92 @@ | ||
|
||
(define-keyset 'ns-admin-keyset (read-keyset 'ns-admin-keyset)) | ||
(define-keyset 'ns-operate-keyset (read-keyset 'ns-genesis-keyset)) | ||
|
||
(module ns GOVERNANCE | ||
"Administers definition of new namespaces in Chainweb." | ||
|
||
(defschema reg-entry | ||
admin-guard:guard | ||
active:bool) | ||
|
||
(deftable registry:{reg-entry}) | ||
|
||
(defcap GOVERNANCE () | ||
(enforce-keyset 'ns-admin-keyset)) | ||
|
||
(defcap OPERATE () | ||
(enforce-keyset 'ns-operate-keyset)) | ||
|
||
(defconst GUARD_SUCCESS (create-user-guard (success))) | ||
(defconst GUARD_FAILURE (create-user-guard (failure))) | ||
|
||
(defun success () | ||
true) | ||
(defun failure () | ||
(enforce false "Disabled")) | ||
|
||
(defun validate-name (name) | ||
(enforce (!= "" name) "Empty name not allowed") | ||
(enforce (< (length name) 64) "Name must be less than 64 characters long") | ||
(enforce (is-charset CHARSET_LATIN1 name) | ||
"Name must be in latin1 charset")) | ||
|
||
(defun validate:bool | ||
( ns-name:string | ||
ns-admin:guard | ||
) | ||
" Manages namespace install for Chainweb. Requires active row in registry \ | ||
\ for NS-NAME with guard matching NS-ADMIN." | ||
|
||
(validate-name ns-name) | ||
|
||
(with-default-read registry ns-name | ||
{ 'admin-guard : ns-admin | ||
, 'active : false } | ||
{ 'admin-guard := ag | ||
, 'active := is-active } | ||
|
||
(enforce is-active "Inactive or unregistered namespace") | ||
(enforce (= ns-admin ag) "Admin guard must match guard in registry") | ||
|
||
true)) | ||
|
||
(defun write-registry:string | ||
( ns-name:string | ||
guard:guard | ||
active:bool | ||
) | ||
" Write entry with GUARD and ACTIVE into registry for NAME. \ | ||
\ Guarded by operate keyset. " | ||
|
||
(with-capability (OPERATE) | ||
|
||
(validate-name ns-name) | ||
|
||
(write registry ns-name | ||
{ 'admin-guard: guard | ||
, 'active: active }) | ||
|
||
"Register entry written")) | ||
|
||
(defun query:object{reg-entry} | ||
( ns-name:string ) | ||
(read registry ns-name)) | ||
|
||
) | ||
|
||
(create-table registry) | ||
|
||
(write-registry "kadena" | ||
(keyset-ref-guard 'ns-operate-keyset) true) | ||
(write-registry "user" GUARD_FAILURE true) | ||
(write-registry "free" GUARD_FAILURE true) | ||
|
||
(define-namespace "kadena" | ||
(keyset-ref-guard 'ns-operate-keyset) | ||
(keyset-ref-guard 'ns-operate-keyset)) | ||
|
||
(define-namespace "user" GUARD_SUCCESS GUARD_FAILURE) | ||
(define-namespace "free" GUARD_SUCCESS GUARD_FAILURE) | ||
;;rotate to real operate keyset | ||
(define-keyset 'ns-operate-keyset (read-keyset 'ns-operate-keyset)) |
Oops, something went wrong.