Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: rfc 0250_Covenants #3574

Merged
merged 1 commit into from
Nov 17, 2021
Merged

Conversation

sdbondi
Copy link
Member

@sdbondi sdbondi commented Nov 16, 2021

Description

Adds RFC for covenants on Tari

Rendered

Motivation and Context

Allows sidechain checkpointing transactions and many other use-cases.

@sdbondi sdbondi force-pushed the rfc-covenants branch 10 times, most recently from 3223b5f to c767e92 Compare November 16, 2021 12:59
Copy link
Collaborator

@SWvheerden SWvheerden left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good, like the direction this is going in. Made a few clarification comments


Modifications to the existing protocol and consensus are as follows:

- the covenant is recorded in the transaction [UTXO],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is not really a thing such as a transaction, there are inputs and outputs, and kernels that are grouped together + some header info.
Is this recorder, in the input, output, kernel, or the header (such show the offset and script offset is stored)

### Transaction input and output changes

A `covenant` field would need to be added to the `TransactionOutput` and `TransactionInput` structs
and committed to in their hashes.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and signatures

Comment on lines +157 to +159
Commitment(PedersonCommitment),
// byte code: 0x04
// data size: 64 bytes
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cant we reduce this to 32 bytes by just looking at the hash of a commitment, or output for that matter?
This is stored on the block chain and sent over the wire, we want this to be as small as possible.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that's the general direction I think is good, I think I included this as an "incase we need it" but agree with what you've said

args: [Fields, VarInt]
```

##### filter_relative_height(height)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This command can be done as is with TariScript? If we check if the input is valid to be spent, that is completely covered by TariScript. If we want to check if the input has a set height then its a completely different thing,

Copy link
Member Author

@sdbondi sdbondi Nov 17, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's mostly to support running one covenant if spent within 100 blocks and another after

xor(
     and(filter_relative_height(100), A),
     and(not(filter_relative_height(100)), B)   
)

Comment on lines +388 to +396
Spend within 10 blocks or burn

```
not(filter_relative_height(10))
```

Note, this covenant may be valid when submitted to the mempool, but invalid by the time it is put in a block for
the miner.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good example of something you might want to do with this, but this is something I would argue we should rather do with TariScript.

The difference being:
TariScript: Controlling when you may spend your already mined UTXO
Convenants: Controlling to what you may spend your UTXO.

And here they focus on the rules relating to the input and output respectively and I think we should stick to these as far as possible to simplify things.

Copy link
Member Author

@sdbondi sdbondi Nov 17, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I'm 50/50 on needing that covenant because it means we have to revalidate before assembling the block. This isn't the best example. The positive 50% is thinking that it seems useful to be able to either run covenant A or B depending on maturity. This allows spending to outputs a certain way before 100 blocks and another way after.

Maybe something like a vault which allows you access to funds while locked in the vault (say for 100 blocks) but ensures that the covenant protects the funds for those 100 blocks (by allowing you to burn the funds if an attacker pwned your private keys, discouraging the attacker because you can ensure that no one gets the funds). I didn't manage to come up with an example of that covenant but I think it's possible.

Copy link
Collaborator

@stringhandler stringhandler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work. The RFC is really well written.

I think there are probably better examples, but I think these can and will be updated as the implementation is done and more real-world scenarios are clear.

@aviator-app aviator-app bot merged commit d073f50 into tari-project:development Nov 17, 2021
@sdbondi sdbondi deleted the rfc-covenants branch November 17, 2021 10:09
sdbondi added a commit to sdbondi/tari that referenced this pull request Nov 17, 2021
* development:
  feat: improve wallet connectivity status for console wallet (tari-project#3577)
  v0.21.1
  feat: add error codes to LibWallet for CipherSeed errors (tari-project#3578)
  ci: split cucumber job into two (tari-project#3583)
  feat(wallet): import utxo’s as EncumberedToBeReceived rather than Unspent (tari-project#3575)
  docs: rfc 0250_Covenants (tari-project#3574)
sdbondi added a commit to sdbondi/tari that referenced this pull request Nov 18, 2021
* development: (32 commits)
  feat: add atomic swap refund transaction handling (tari-project#3573)
  feat: improve wallet connectivity status for console wallet (tari-project#3577)
  v0.21.1
  feat: add error codes to LibWallet for CipherSeed errors (tari-project#3578)
  ci: split cucumber job into two (tari-project#3583)
  feat(wallet): import utxo’s as EncumberedToBeReceived rather than Unspent (tari-project#3575)
  docs: rfc 0250_Covenants (tari-project#3574)
  feat: get fee for transactions for stratum transcoder (tari-project#3571)
  test: make monerod stagenet usage resilient (tari-project#3572)
  feat: add atomic swap htlc sending and claiming (tari-project#3552)
  feat: implement prometheus metrics for base node (tari-project#3563)
  feat: implement multiple read single write for sqlite (tari-project#3568)
  feat: trigger time lock balance update when block received (tari-project#3567)
  test: reduce cucumber ci to critical only (tari-project#3566)
  test: fix cucumber console wallet startup (tari-project#3564)
  chore: add node id/public key to log mdc (tari-project#3559)
  fix: avoid implicit using of the time crate (tari-project#3562)
  feat: one-click installer - cli edition (tari-project#3534)
  ci: add workflow dispatch to libwallet build action (tari-project#3556)
  fix: stop leak of value of recovered output (tari-project#3558)
  ...
sdbondi added a commit to sdbondi/tari that referenced this pull request Nov 23, 2021
* development: (46 commits)
  refactor: remove tari_common dependency from tari_comms (tari-project#3580)
  feat: language detection for mnemonic seed words (tari-project#3590)
  chore: minor clippy fixes (tari-project#3576)
  fix: be more permissive of responses for the incorrect request_id (tari-project#3588)
  feat: track ping failures and disconnect (tari-project#3597)
  chore: upgrade tokio deps tari-project#3581 (tari-project#3595)
  feat: standardize output hash for unblinded output, transaction output and transaction input (tari-project#3592)
  fix: allow bullet proof value only rewinding off one-sided transaction (tari-project#3587)
  refactor: update miningcore repository links (tari-project#3593)
  refactor: clean up unwraps in wallet_ffi (tari-project#3585)
  fix: update daily test start times and seed phrase (tari-project#3584)
  fix: allow bullet proof value only rewinding in atomic swaps (tari-project#3586)
  v0.21.2
  feat: add atomic swap refund transaction handling (tari-project#3573)
  feat: improve wallet connectivity status for console wallet (tari-project#3577)
  v0.21.1
  feat: add error codes to LibWallet for CipherSeed errors (tari-project#3578)
  ci: split cucumber job into two (tari-project#3583)
  feat(wallet): import utxo’s as EncumberedToBeReceived rather than Unspent (tari-project#3575)
  docs: rfc 0250_Covenants (tari-project#3574)
  ...
@sdbondi sdbondi restored the rfc-covenants branch February 3, 2022 05:27
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.

3 participants