KIP | Title | Author | Status | Type | Category | Created |
---|---|---|---|---|---|---|
0019 |
Coin-v6 and fungible-v3 |
Robert Soeldner (robert@kadena.io) |
Draft |
Standard |
2023-05-02 |
The next iteration of the coin contract proposes three main changes to enhance the maintainability and security of the contract.
Firstly, the rotate
function, which is responsible rotating an account guard in a contract that implements the fungible-v2
interface,
will be removed. In the case of fungible tokens that also implement the fungible-xchain
interface, this will result "correct by construction" cross-chain transactions by avoiding the risk of locking funds sent to the receiving account.
Secondly, the constants and some functions within the contracts will be reorganized to increase maintainability (see Rationale). This is intended to make the codebase more structured and easier to maintain, reducing the chances of errors and improving the overall quality of the contract.
Finally, verification related code of the coin contract will be modified to allow for formal verification. This will enable rigorous proves of the contract's code to ensure its correctness and reliability. By incorporating these changes, the new iteration of the coin contract aims to provide a more secure and efficient platform for the exchange of cryptocurrencies.
The presence of the rotate
function in the current implementation of the contract undermines the
integrity of cross-chain transfers. Specifically, executing the rotate function before the
completion of a cross-chain transfer can result in the locking of funds.
Moreover, the utilization of our formal verification system can significantly enhance the security of the contract. Therefore, necessary changes to allow the verification of the contract are introduced.
The KIP process has a time constraint of 1.5 months, which will end on June 30th AoE, during which participants are expected to share their feedback.
Date | Event |
---|---|
2023-05-02 | Publication of initial document |
2023-06-30 | Deadline of KIP-0019 |
Changes within fungible-v3.pact
:
- Model annotation for the schema
account-details
: Add new invariant expressing positive balance (>= balance 0.0
). - Model annotation for defun
get-balance
: Add new property that!= account ""
and>= result 0.0
. - Model annotation for defun
details
: Add property that the account is not empty!= account ""
. - Model annotation for defun
enforce-unit
: Add property that the amount is not negative>= amount 0.0
. - Model annotation for defun
create-account
: Add property that the account is not empty!= account ""
.
Changes within coin-v6.pact
:
- Change the
fungible-v2
interface tofungible-v3
. - Bless old coin contract (coin v5).
- Move constants (
COIN_CHARSET
,MINIMUM_PRECISION
,MINIMUM_ACCOUNT_LENGTH
,MAXIMUM_ACCOUNT_LENGTH
, andVALID_CHAIN_IDS
) to a different section. - Move utility functions (
enforce-unit
, andvalidate-account
) to a different section. - Replace
enforce (!= sender ...
byvalidate-account
in defunDEBIT
andCREDIT
. - Remove defcap
ROTATE
- Add additional
enforce
to express that gas consumtion must be greater than zero (enforce (> total 0.0)
) within defunredeem-gas
. - Enforce the refund unit
enforce-unit refund
within defunredeem-gas
. - Add
validate-account
to defunget-balance
. - Add
validate-account
to defundetails
. - Within
fund-tx
enforce a valid miner within thedefpact
step. - Add invariant
>= balance 0.0
for theallocation-schema
.
N/A