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

added timestamp to wallet #152

Merged
merged 4 commits into from
Dec 11, 2023
Merged

added timestamp to wallet #152

merged 4 commits into from
Dec 11, 2023

Conversation

muraca
Copy link
Collaborator

@muraca muraca commented Nov 23, 2023

This is useful to check that #151 is working as expected.

@muraca muraca requested a review from JoshOrndorff November 23, 2023 17:27
Copy link

Coverage after merging wallet-timestamp into main will be

64.13%

Coverage Report
FileStmtsBranchesFuncsLinesUncovered Lines
tuxedo-core/aggregator/src
   lib.rs99.29%100%100%99.26%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.rs55.29%100%52.63%56.06%71–91
   dynamic_typing.rs84.75%100%72.73%89.41%
   executive.rs91.49%100%92.68%91.34%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
   genesis.rs45%100%42.86%45.16%100, 152–154, 163, 36–49, 60, 62–65, 67–68, 70–72, 75–79, 81–83, 85–97
   inherents.rs7.62%100%12.50%6.74%120–122, 158, 164–178, 180–203, 212–217, 219–223, 226–228, 230, 56–58, 63–68, 70–78, 81, 83
   types.rs71.35%100%54.35%76.98%86, 88–91, 93–99
   utxo_set.rs90.91%100%100%88.89%39–40
   verifier.rs88.01%100%71.60%92.28%120
tuxedo-template-runtime/src
   genesis.rs84.62%100%88.89%84.35%23–45
   lib.rs4.72%100%13.64%2.86%100–101, 124, 127, 132–134, 138–140, 153, 155, 157, 159, 161, 163, 165, 167, 170, 172, 177, 186–207, 210–237, 240–351, 60–65, 96–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%106, 111, 122, 128, 14, 17, 19, 28, 33, 38, 45, 56, 68, 91
   keystore.rs0%100%0%0%31–33, 38–45, 47–48, 51, 53–59, 65–73, 76–78, 80–82, 85–91, 93–94
   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, 175–176, 178, 180, 182–185, 187–189, 191, 195–202, 205–208, 210–212, 215–217, 219, 221, 224–230, 233–246, 249–252, 254–259, 26, 260–265, 267, 27–30, 33, 36–38, 40–41, 44, 46, 48–49, 53, 56–62, 65, 67–69, 73–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%16–21, 24–26, 28–44, 47–53, 55–58, 60–61
   sync.rs0%100%0%0%100–103, 107–110, 117–118, 120, 123–126, 131–133, 136–137, 140–145, 147–149, 152, 154–155, 160–163, 166–167, 174–178, 180–186, 189–191, 193–194, 197–198, 203–206, 209, 211–212, 217–220, 223, 225–226, 229–235, 237–238, 241–242, 245–246, 249–250, 254–260, 263–267, 270, 272, 274–282, 284, 288–290, 292, 296, 298–299, 302–303, 306–313, 315–316, 319–320, 322, 324–325, 329–331, 333–334, 336–337, 339–340, 343–345, 347–348, 350–351, 353–354, 358, 360–361, 365, 367–372, 375–376, 379–381, 384, 387–390, 392, 395–398, 401, 404–405, 408–409, 414–419, 421, 423, 428–431, 434–435, 438–443, 445, 448–449, 453–454, 456, 458–460, 462–465, 468–469, 471–478, 50–54, 58, 61–62, 65, 67–81, 86–90, 92–93, 98–99
wardrobe/amoeba/src
   lib.rs59.06%100%26.83%71.30%121, 139, 178, 81
   tests.rs100%100%100%100%
wardrobe/kitties/src
   lib.rs48.13%100%26.45%57.50%100, 102–103, 106–109, 117–119, 121–123, 127–129, 133–134, 137–139, 143–145, 150–152, 154–155, 159–161, 172–192, 211–212, 215–222, 225, 228, 230, 232, 234, 236, 238, 240, 242, 244, 246, 248, 250, 252, 254, 256, 258, 260, 262, 391, 40–42, 423, 426, 44–48, 486, 49–51, 56–58, 60–62, 65–68, 77–79, 81–83, 86–89, 98–99
   tests.rs99.61%100%98.25%99.78%
wardrobe/money/src
   lib.rs50%100%22.45%62.39%102–103, 106–113, 116, 119, 121, 123, 127, 130, 133, 191, 22–24, 33–35, 37–38, 41–44, 47, 51, 60–62, 64–66, 69–71
   tests.rs100%100%100%100%
wardrobe/poe/src
   lib.rs0%100%0%0%100, 108–112, 116–117, 121–122, 128, 134–139, 141–143, 147–151, 153–154, 167, 173–179, 39, 52, 55, 57, 59, 61,

Signed-off-by: muraca <mmuraca247@gmail.com>
Copy link
Contributor

@JoshOrndorff JoshOrndorff left a comment

Choose a reason for hiding this comment

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

Overall good. Made a couple little suggestions. Take them or leave them.

Comment on lines 269 to 273
// For now the wallet only supports simple coins and timestamp
match output.payload.type_id {
Coin::<0>::TYPE_ID => {
let amount = output.payload.extract::<Coin<0>>()?.0;

Copy link
Contributor

Choose a reason for hiding this comment

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

This may be a good time to make the filtering we do here paramaterizeable like the verifier filter is above. Or at least make a follow up issue for it.

Comment on lines 470 to 478

pub(crate) fn get_timestamp(db: &Db) -> anyhow::Result<u64> {
let timestamp_tree = db.open_tree(TIMESTAMP)?;
let timestamp = timestamp_tree
.get([0])?
.ok_or_else(|| anyhow!("Could not find timestamp in database."))?;
u64::decode(&mut &timestamp[..])
.map_err(|_| anyhow!("Could not decode timestamp from database."))
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Ideally this would go in a separate timestamp module. My idea is that logic associated with each piece (like how this is associated with the timestamp piece) will live in a dedicated file. That should make it easy to make chain-specific wallets by either including or not including that part of the wallet.

wallet/src/main.rs Show resolved Hide resolved
Signed-off-by: muraca <mmuraca247@gmail.com>
introduced fn `apply_transaction` for pieces

Signed-off-by: muraca <mmuraca247@gmail.com>
Comment on lines +266 to 274
match output.payload.type_id {
Coin::<0>::TYPE_ID => {
crate::money::apply_transaction(db, tx_hash, index as u32, output)?;
}
Timestamp::TYPE_ID => {
crate::timestamp::apply_transaction(db, output)?;
}
_ => return Err(anyhow!("{:?}", ())),
_ => continue,
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@JoshOrndorff I like this approach better, please check it out.

Signed-off-by: muraca <mmuraca247@gmail.com>
Copy link
Contributor

@JoshOrndorff JoshOrndorff left a comment

Choose a reason for hiding this comment

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

Thanks for improving the wallet structure!

@muraca muraca merged commit 94a8709 into main Dec 11, 2023
5 of 6 checks passed
@muraca muraca deleted the wallet-timestamp branch December 11, 2023 17:22
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