Skip to content

Implement evictions #196

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

Merged
merged 60 commits into from
Mar 21, 2024
Merged

Implement evictions #196

merged 60 commits into from
Mar 21, 2024

Conversation

JoshOrndorff
Copy link
Contributor

@JoshOrndorff JoshOrndorff commented Mar 19, 2024

Solves #98. Second try at evictions after #52.

"Normally" UTXOs are consumed in a process called "redemption" where the transacting user supplies some kind of signature or other proof that satisfies the UTXO's Verifier. An eviction is a (new alternative) way to forcefully consume input data without satisfying the verifier. In some usecases this is desirable. For example incentivizing cleaning up old state. Or to make governance decisions enforceable.

Implementation

The changes revolve around this new enum:

/// An input can be consumed in two way. It can be redeemed normally (probably with some signature, or proof) or it 
/// can be evicted. This enum is isomorphic to `Option<Vec<u8>>` but has more meaningful names.
#[derive(Serialize, Deserialize, Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)]
pub enum RedemptionStrategy {
    /// The input is being consumed in the normal way with a signature or other proof provided by the spender.
    Redemption(Vec<u8>),
    /// The input is being forcefully evicted without satisfying its Verifier.
    Eviction,
}

This does not mean that any transaction can evict arbitrary storage. The ConstraintChecker will be informed about which inputs were evicted and it will enforce that evictions are only allowed in specific contexts (such as removing old votes after an election has been tallied).

Relationship with Peeks

Currently (both before and after this PR) all peeks are evictions. Peeks are evictions in the sense that anyone can peek at any data without needing to satisfy its verifier.

Now that I am focusing on evictions, it is clear that there are cases where it would be nice to require a redemption to peek at a UTXO. For example, this would make #186 much more parallelizable. I'll make a followup issue for this, but I don't see it as priority for now.

Must my Chain Allow Evictions?

No. In some chains, especially those serving communities strongly value property rights, evictions may never be desirable, and that is totally fine. It is straightforward to build a Tuxedo chain that has no eviction paths. But as a framework Tuxedo also supports chains that want to support evictions

@JoshOrndorff JoshOrndorff changed the base branch from main to joshy-constraint-checker-beef-up March 19, 2024 16:13
@JoshOrndorff JoshOrndorff marked this pull request as ready for review March 19, 2024 17:07
@JoshOrndorff JoshOrndorff requested review from muraca and coax1d March 20, 2024 14:37
Base automatically changed from joshy-constraint-checker-beef-up to main March 20, 2024 18:07
Copy link

Coverage after merging joshy-evictions into main will be

61.56%

Coverage Report
FileStmtsBranchesFuncsLinesUncovered Lines
tuxedo-core/aggregator/src
   lib.rs99.14%100%100%99.11%201, 22, 84
tuxedo-core/no_bound/src
   clone_no_bound.rs36.63%100%30%37.36%24, 32–39, 56, 59–72, 74–87, 89, 91–95, 98–99
   debug_no_bound.rs32.73%100%30%33%101–105, 108–109, 24, 32–42, 58, 60–78, 80–95, 97–99
   default_no_bound.rs19.11%100%16.67%19.31%100–122, 124–131, 133, 136–147, 151–157, 32–39, 51, 54–80, 83–88, 91–99
   lib.rs100%100%100%100%
tuxedo-core/src
   constraint_checker.rs47.71%100%47.83%47.67%118–126, 132–137, 139–148, 150, 198–202, 205–210, 213–214
   dynamic_typing.rs83.33%100%70.59%88.37%
   executive.rs92.17%100%93.60%92%127, 153, 193, 225, 254, 265, 316, 343, 394–399, 401, 411–412, 417–418, 420, 423–424, 427, 429–430, 433–434, 436, 440–461, 463, 467–468, 470–471, 473, 476–493, 55, 98
   genesis.rs43.69%100%42.86%43.75%102–103, 106, 158–160, 169, 36–49, 60, 62–65, 67–68, 70–72, 75–79, 81–83, 85–96, 98–99
   inherents.rs17.11%100%25%15.63%122–124, 151–158, 165–179, 185–203, 205–235, 56–58, 65–70, 72–80, 83, 85
   types.rs59.11%100%42.86%65.43%158, 160, 200–205, 82–86, 88–91, 93–99
   utxo_set.rs90.91%100%100%88.89%39–40
   verifier.rs42.86%100%32.50%48.61%106–108, 43–44, 46, 48–49, 54, 71, 78–80, 82–84
tuxedo-core/src/verifier
   htlc.rs77.96%100%44.93%85.71%107, 109, 115, 40, 42, 55, 57, 74–78, 91
   multi_signature.rs87.50%100%68.29%91.16%100–105, 45, 71
   simple_signature.rs76.87%100%58.33%82.88%65, 67, 78–82
tuxedo-parachain-core/register_validate_block/src
   lib.rs0%100%0%0%100–119, 12, 120–125, 128, 13, 130–131, 14–16, 18, 29–35, 38–46, 50, 54–56, 59–61, 64–66, 84–99
tuxedo-parachain-core/src
   collation_api.rs0%100%0%0%19–40
   lib.rs48.65%100%53.85%45.83%85–90, 94–96
   relay_state_snapshot.rs0%100%0%0%112, 128–140, 147–155, 157, 173–188, 193–202, 204–211, 223, 225, 227–233, 235–240, 242, 245–250, 252–257, 259–271, 274–286, 292–298, 303–310, 316–323, 330–337, 346–354, 362–370, 378–383, 389–394, 41, 54, 82
   tests.rs100%100%100%100%
tuxedo-template-runtime/src
   genesis.rs84.81%100%88.89%84.56%23–45
   lib.rs5.87%100%14.63%3.67%100–104, 130, 135–137, 141–143, 205, 207, 209, 211, 213, 215, 217, 219, 222, 224, 227, 233, 242–249, 254, 263–284, 287–314, 317–436, 63–68, 99
wallet/src
   amoeba.rs0%100%0%0%100–106, 109–110, 112–118, 120–127, 19–48, 51–52, 54–99
   cli.rs0%100%0%0%100, 115, 119, 125, 128, 133, 144, 150, 17, 20, 22, 31, 36, 41, 48, 65, 77
   keystore.rs0%100%0%0%30–33, 38–45, 47–48, 51, 53–59, 65–73, 76–78, 80–82, 85–91, 93–94
   main.rs0%100%0%0%100–193, 196–203, 206–209, 211–213, 216–218, 220, 222, 225–231, 234–247, 250–253, 255–266, 268, 27–99
   money.rs0%100%0%0%100, 106–113, 115, 119–124, 128, 131, 133, 136–139, 141–142, 146, 150–153, 155, 160–166, 168–172, 175–176, 180–185, 187–188, 191–202, 204, 206, 22–23, 25–40, 43, 47–60, 63–69, 72–90, 94–99
   output_filter.rs100%100%100%100%
   rpc.rs0%100%0%0%16–21, 24–26, 28–44, 47–53, 55–58, 60–61
   sync.rs0%100%0%0%103–106, 113–114, 116, 119–122, 127–129, 132–133, 136–141, 143–145, 148, 150–151, 156–159, 162–163, 170–174, 176–182, 185–187, 189–190, 193–194, 199–202, 205, 207–208, 213–216, 219, 221–222, 225–231, 233–234, 237–238, 241–242, 245–246, 250–256, 259–263, 266, 268, 271, 273, 277, 279–280, 283–284, 287–294, 296–297, 300–301, 303, 305–306, 310–312, 314–315, 317–318, 320–321, 324–326, 328–329, 331–332, 334–335, 339, 341–342, 346, 348–353, 356–357, 360–362, 365, 368–371, 373, 376–379, 382, 385–386, 389–390, 395–400, 402, 404, 409–412, 415–416, 419–424, 426, 429–430, 434–435, 437, 439–441, 443–446, 449–450, 46–50, 54, 57–58, 61, 63–77, 82–86, 88–89, 94–99
   timestamp.rs0%100%0%0%12–17, 20–27
wardrobe/amoeba/src
   lib.rs60.49%100%26.83%71.90%130, 148, 164, 194, 210, 83, 99
   tests.rs100%100%100%100%
wardrobe/kitties/src
   lib.rs47.80%100%26.52%57.19%100, 102–103, 107–109, 117–119, 121–123, 127–129, 133–134, 137&nda

@JoshOrndorff JoshOrndorff merged commit a78f99a into main Mar 21, 2024
@JoshOrndorff JoshOrndorff deleted the joshy-evictions branch March 21, 2024 14:38
This was referenced Apr 16, 2024
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.

1 participant