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

Timestamp Inherent #100

Merged
merged 134 commits into from
Oct 13, 2023
Merged

Timestamp Inherent #100

merged 134 commits into from
Oct 13, 2023

Conversation

JoshOrndorff
Copy link
Contributor

@JoshOrndorff JoshOrndorff commented Sep 27, 2023

Closes #90

This main purpose of this PR is to blaze a path for how inherents can be used in Tuxedo.

As a concrete starting point we introduce the timestamp inherent which is ubiquitous in FRAME runtimes.

  • Minimal Tuxedo piece to accept inherent extrinsic
  • Install Piece in Runtime
  • Convert inherent data to extrinsic
  • Scrape parent block for input utxo
  • Insert extrinsic into block
  • Check inherent on importing node
  • Voluntary cleanup of old timestamps
  • Tests for the piece
  • SetTimestamp forbidden in pool (so it must be inherent)
  • Modularized design for arbitrary future inherents (eg parachain)
  • Aggregation macro
  • Move to creation and checking logic from template to executive
  • Enforce that inherents are first when executing
  • Tests for inherent ordering
  • Move configuration constants into the piece's configuration
  • (Deferred to followup) Rework relationship between constraint checkers and inherent hooks.
  • (Deferred until Accumulators for intra-block book-keeping #105 lands) Ensure exactly one time stamp per block.
  • (Deferred until Custom GenesisBlockBuilder #107 is implemented) Remove the special case for initializing timestamp in the first block.

@JoshOrndorff

This comment was marked as outdated.

@JoshOrndorff

This comment was marked as outdated.

@JoshOrndorff

This comment was marked as outdated.

Joshy Orndorff added 4 commits September 28, 2023 22:38
This has nothing to do with the `StateVersion` enum.
They don't fully make sense yet because I haven't expanded the storage to differentiate best time from any other noted time. That will be next.
@Off-Narrative-Labs Off-Narrative-Labs deleted a comment from github-actions bot Oct 12, 2023
Copy link
Collaborator

@muraca muraca left a comment

Choose a reason for hiding this comment

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

New changes with single-output design are generally good, let's wait for the tests to see if I missed anything

/// as check the verifier information in some unique way.
/// This full ConstraintChecker should only be implemented if the piece logic cannot be expressed with
/// the SimpleConstraintChecker. For example, if you need to enforce the verifier is a particular type
/// or contains a certain value. Another reason would be if you need to implement an inherent.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I was thinking maybe we could add an InherentConstraintChecker trait instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah. This is a good idea. It would simplify a lot of things. This is roughly what I had in mind when I put (Deferred to followup) Rework relationship between constraint checkers and inherent hooks. as one of the checklist items in the PR description.

wardrobe/timestamp/src/lib.rs Outdated Show resolved Hide resolved
wardrobe/timestamp/src/lib.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@coax1d coax1d left a comment

Choose a reason for hiding this comment

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

This was a big one but nice job figuring out how to do this!

tuxedo-core/aggregator/src/lib.rs Show resolved Hide resolved
tuxedo-core/src/executive.rs Outdated Show resolved Hide resolved
tuxedo-core/src/executive.rs Outdated Show resolved Hide resolved
tuxedo-core/src/executive.rs Outdated Show resolved Hide resolved
tuxedo-core/src/executive.rs Show resolved Hide resolved
wardrobe/timestamp/src/lib.rs Outdated Show resolved Hide resolved
wardrobe/timestamp/src/lib.rs Outdated Show resolved Hide resolved
wardrobe/timestamp/src/lib.rs Show resolved Hide resolved
wardrobe/timestamp/src/lib.rs Show resolved Hide resolved
wardrobe/timestamp/src/lib.rs Outdated Show resolved Hide resolved
Signed-off-by: muraca <mmuraca247@gmail.com>
Signed-off-by: muraca <mmuraca247@gmail.com>
Signed-off-by: muraca <mmuraca247@gmail.com>
@Off-Narrative-Labs Off-Narrative-Labs deleted a comment from github-actions bot Oct 13, 2023
@Off-Narrative-Labs Off-Narrative-Labs deleted a comment from github-actions bot Oct 13, 2023
@Off-Narrative-Labs Off-Narrative-Labs deleted a comment from github-actions bot Oct 13, 2023
@Off-Narrative-Labs Off-Narrative-Labs deleted a comment from github-actions bot Oct 13, 2023
@Off-Narrative-Labs Off-Narrative-Labs deleted a comment from github-actions bot Oct 13, 2023
Joshy Orndorff and others added 2 commits October 13, 2023 10:54
Signed-off-by: muraca <mmuraca247@gmail.com>
@Off-Narrative-Labs Off-Narrative-Labs deleted a comment from github-actions bot Oct 13, 2023
@Off-Narrative-Labs Off-Narrative-Labs deleted a comment from github-actions bot Oct 13, 2023
@Off-Narrative-Labs Off-Narrative-Labs deleted a comment from github-actions bot Oct 13, 2023
@Off-Narrative-Labs Off-Narrative-Labs deleted a comment from github-actions bot Oct 13, 2023
@github-actions
Copy link

Coverage after merging timestamp into main

63.73%

Coverage Report
FileStmtsBranchesFuncsLinesUncovered Lines
tuxedo-core/aggregator/src
   lib.rs99.24%100%100%99.21%117, 21
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.rs50%100%47.37%50.75%110, 71–91, 93–95
   dynamic_typing.rs84.03%100%72.73%88.37%57, 59
   executive.rs91.52%100%92.68%91.38%116, 142, 175, 207, 220–228, 236, 247, 298, 325, 376–381, 383, 393–394, 399–400, 403, 405–406, 409–410, 412, 416–437, 439, 443–444, 446–447, 449, 452–469, 54
   inherents.rs0%100%0%0%151–152, 157–171, 173–199, 203–208, 210–219, 221, 56–58, 63–68, 70–78, 81, 83
   types.rs64.09%100%51.11%68.38%100–102, 13, 145, 147, 15, 177, 37, 39, 54–61, 89, 91–94, 96–99
   utxo_set.rs90.91%100%100%88.89%39–40
   verifier.rs85.93%100%68.35%90.38%108, 142, 28, 30, 46, 48, 60, 62, 78
tuxedo-template-runtime/src
   lib.rs29.22%100%19.74%30.82%101–106, 108, 195, 197, 200, 205–207, 211–213, 223–225, 227, 229, 231, 233, 235, 237, 239, 241, 244, 246, 251–252, 260–281, 284–311, 314–425, 65–70
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%110, 117, 14, 17, 19, 32, 39, 50, 61, 83, 94, 99
   keystore.rs0%100%0%0%32–34, 39–46, 48–49, 52, 54–60, 66–74, 77–79, 81–83, 86–92, 94–95
   main.rs0%100%0%0%100, 102–103, 106–118, 121, 123–127, 130–134, 136–145, 147–148, 152–162, 165–166, 168, 171–172, 179–185, 187–190, 192–193, 196–203, 206–209, 211–213, 216–218, 220, 222, 225–238, 241–244, 246–257, 259, 34–43, 46, 49, 53, 56–62, 65, 67–69, 74–77, 79, 81, 83–84, 87–88, 90, 92–94, 99
   money.rs0%100%0%0%100–101, 105, 109–112, 114, 119–125, 127–131, 134–135, 139–144, 146–147, 22–28, 31–49, 53–59, 65–72, 74, 78–83, 87, 90, 92, 95–98
   output_filter.rs100%100%100%100%
   rpc.rs0%100%0%0%10–15, 18–20, 22–38
   sync.rs0%100%0%0%100–101, 107–111, 115, 118–119, 122, 124–138, 143–147, 149–150, 155–160, 164–167, 174–175, 177, 180–183, 188–190, 193–194, 197–202, 204–206, 209, 211–212, 217–220, 223–224, 231–235, 237–243, 246–248, 250–251, 254–255, 260–263, 266, 268–269, 274–277, 280, 282–283, 286–292, 294–295, 298–299, 302–303, 306–307, 311–317, 320–324, 327–329, 332–340, 342, 346, 348–349, 352–353, 356–363, 365–366, 369–370, 372, 374–375, 379–381, 383–384, 386–387, 389–390, 393–395, 397–398, 400–401, 403–404, 408, 410–411, 415, 417–422, 425–426, 429–431, 434, 437–440, 442, 445–448, 451, 454–455, 458–459, 46, 464–469, 47, 471, 473, 478–479, 48, 480–481, 484–485, 488–489, 49, 490–493, 495, 498–499, 50, 503–504, 506, 508–509, 51, 510, 512–515, 518–519, 52–56, 58–66, 68, 70–76, 78, 80, 82, 84–86, 91–94, 96
wardrobe/amoeba/src
   lib.rs58.17%100%26.83%69.64%124, 142–144, 182–184, 27, 83–85
   tests.rs100%100%100%100%
wardrobe/kitties/src
   lib.rs53.16%100%29.66%63.74%102, 105, 107, 109, 111, 113, 115, 117, 119, 121, 123, 125, 127, 129, 131, 133, 135, 137, 139, 268, 300, 303, 363, 38–40, 42, 44, 50, 52, 58, 60, 66–68, 71, 75, 77, 99
   tests.rs99.61%100%98.25%99.78%
wardrobe/money/src
   lib.rs39.86%100%14.58%52%140, 22–24, 32–35, 39, 47, 52–54, 62, 65, 68, 70, 72, 76, 79, 82
   tests.rs100%100%100%100%
wardrobe/poe/src
   lib.rs0%100%0%0%100–102, 110–119, 123–124, 130–132, 137–146, 150–154, 156–157, 170–172, 177–183, 40–41, 54–55, 58, 60, 62, 64, 68, 86–88, 93–99
wardrobe/runtime_upgrade/src
   lib.rs0%100%0%0%103–105, 107–113, 117–121, 32–33, 35, 43, 71–74, 80–89, 91–99
wardrobe/timestamp/src
   cleanup_tests.rs100%100%100%100%
   first_block_special_case_tests.rs100%100%100%100%
   lib.rs39.37%100%26.32%42.08%140–143, 159, 193, 221–223, 232–245, 247, 250–267, 270–281, 283–293, 295, 298–302, 304, 313–314, 316, 319–323, 332, 334, 374
   update_timestamp_tests.rs100%100%100%100%

@JoshOrndorff JoshOrndorff merged commit c9b8c45 into main Oct 13, 2023
6 checks passed
@JoshOrndorff JoshOrndorff mentioned this pull request Nov 20, 2023
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.

Timestamp Inherent
4 participants