Skip to content

Conversation

@CryptoPascal31
Copy link

@CryptoPascal31 CryptoPascal31 commented Dec 10, 2023

Following my discussion with @jmcardon,

The proposal is to change the execution environment of User guards from SysOnly to ReadOnly.

This would be an amazing feature, that would definitively "unleash the power of Kadena"

Would like to have the feeling of the team about this. Maybe there are some pitfalls I didn't catch ?

https://github.com/kadena-io/KIPs/blob/06223ea13461aac38702abeefb1e872b2be9cc68/kip-0027.md


@CryptoPascal31 CryptoPascal31 changed the title KIP-0027: Make User Guards ReadOnly KIP-0027: Make User Guards SysOnly to ReadOnly Dec 11, 2023
@jmcardon
Copy link
Member

So in looking @ this KIP, the only thing I wonder about is: Aren't all of these cases doable via a capability guard that enforces these invariants? That is, take this example:

(module balance-checker GOV
  (defcap GOV ()
    (enforce fail "No-Upgrade"))
    
  (defcap HAS_MINIMUM_BALANCE (target-account:string min-balance:decimal) 
      (let ((bal (coin.get-balance target-account)))
      (enforce (>= bal min-balance) "No"))
  ) 

  (defun has-minimum-balance:bool (target-account:string min-balance:decimal)
    (let ((bal (coin.get-balance target-account)))
      (enforce (>= bal min-balance) "No"))
  )

  (defun get-guard:guard (target-account:string min-balance:decimal)
    (create-capability-guard (HAS_MINIMUM_BALANCE target-account min-balance))
  )
  
  (defun my-create-account (target-account:string min-balance:decimal)
    (with-capability (HAS_MINIMUM_BALANCE target-account min-balance)
        (coin.create-account "alice" (balance-checker.get-guard "alice-savings" 1000.0))
  )
)

(coin.create-account "alice" (balance-checker.get-guard "alice-savings" 1000.0))

@CryptoPascal31
Copy link
Author

CryptoPascal31 commented Jan 18, 2024

So in looking @ this KIP, the only thing I wonder about is: Aren't all of these cases doable via a capability guard that enforces these invariants? That is, take this example:

@jmcardon Your example doesn't work. Or at least is incomplete ... Where do you acquire the cap ? to unlock the guard. 😉

More generally, using a cap guard, you always REQUIRE to have a caller module to acquire the cap...

Sometimes, it's not very convenient: eg: Alice want's to access her funds by doing a simple (coin.transfer ) at the top level.

But often having a caller module is not possible: eg

  • namespace rotation
  • module deployment
  • pact continuation

The firsts two are necessary to implement namespaces / modules managed by DAO or stuffs like evolved mutli-sigs.
The third is a typical case for a Marmalade buyer.

@jmcardon
Copy link
Member

This was implemented and merged already

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants