only validate each commit once #7

Merged
artur merged 1 commits from validate-each-commit-once-only into main 2025-03-19 03:55:52 +00:00
Owner

validate.sh checks all the parent commits back from the HEAD commit of the current branch (for example, branch "main").
But when there are merge commits and other stuff, many commits have multiple parents. validate.sh goes backwards up all the possible commit sequences that eventually lead back to the root commit of the repository. The "graph" of all commits and their parents gets big very quickly, and common commit hashes appear many time when traversing all paths in the graph.

validate.sh validates every commit every time it finds it, which wastes a lot of time re-validating the same commits again and again.

The code in this PR makes validate.sh remember commits that it has already validated, and not validate those again. It still traverses all the paths in the commit "graph", so that takes a bit of compute power, but at least it does not waste effort validating the same commit multiple times.

Note: a different approach would be to just follow the commit chain of the current branch back to the root commit, and not also follow the other paths that go through old PRs etc. That would require more refactoring.

`validate.sh` checks all the parent commits back from the HEAD commit of the current branch (for example, branch "main"). But when there are merge commits and other stuff, many commits have multiple parents. `validate.sh` goes backwards up all the possible commit sequences that eventually lead back to the root commit of the repository. The "graph" of all commits and their parents gets big very quickly, and common commit hashes appear many time when traversing all paths in the graph. `validate.sh` validates every commit every time it finds it, which wastes a lot of time re-validating the same commits again and again. The code in this PR makes `validate.sh` remember commits that it has already validated, and not validate those again. It still traverses all the paths in the commit "graph", so that takes a bit of compute power, but at least it does not waste effort validating the same commit multiple times. Note: a different approach would be to just follow the commit chain of the current branch back to the root commit, and not also follow the other paths that go through old PRs etc. That would require more refactoring.
phil added 1 commit 2025-03-18 08:13:40 +00:00
only validate each commit once
All checks were successful
Validate Trusted Timestamps Actions Demo / Validate (push) Successful in 2m8s
2976a241af
Author
Owner

A run of this locally:

$ time ../GitTrustedTimestamps/hooks/validate.sh
Checking repository integrity...
Repository integrity OK

Validating timestamps. This may take a while...

Commit 5994c3c7c0c09d70cf0949e23e3a094e7cf1d49a, which timestamps commit 3a51e6ef7d715151d484750993b5c802725755c9 at Tue 04 Feb 2025 04:54:15 PM +0545, contains 2 valid timestamp tokens.

Commit 9b8b241dbe40ff84cd25823d9053c849ac6b28ca, which timestamps commit 316187712fa9c3bd7106525dfb16507c825e5eb6 at Wed 05 Feb 2025 01:28:07 PM +0545, contains 2 valid timestamp tokens.

Commit a50db36196e84eb5abe38e17b36f2c22d12a727e, which timestamps commit f5f168a183e5df7ff74b7c7c765d06edc6ce32d6 at Wed 05 Feb 2025 01:30:36 PM +0545, contains 2 valid timestamp tokens.

Commit 5ea3a2017f28d41e28aa7a366dc946da931ae18c, which timestamps commit 5b8d47eedb09eb08d46303fce4ec86d6f6db20b2 at Fri 07 Feb 2025 11:02:26 AM +0545, contains 2 valid timestamp tokens.

Commit 2d748415e006913c295530e37ba0a29f0ab7b326, which timestamps commit a06e3b87cd987c51499797bd953dc513703041ec at Thu 13 Feb 2025 03:40:26 PM +0545, contains 2 valid timestamp tokens.

Commit 6c593e3e6a78ba01b3b751849d68d54109f8b314, which timestamps commit c01e10906ade17fe729d485c2019508cb6d2d244 at Mon 17 Feb 2025 09:23:41 AM +0545, contains 2 valid timestamp tokens.

Commit f04f4e6ef90e37ed2563fb425072ecab41a7a26f, which timestamps commit 3b499f1cdfce01192a5aadc94092234eb9ffe366 at Mon 17 Feb 2025 09:29:28 AM +0545, contains 2 valid timestamp tokens.

Commit 99440e6f761935446cd86756abd5667a18be13d2, which timestamps commit 61437e135267f5a8dde45c0313ebc22da185e6cb at Mon 24 Feb 2025 10:08:36 AM +0545, contains 2 valid timestamp tokens.

Commit 3af208fba66798bef32f9b8e42c4c8fb83a5a3f9, which timestamps commit 6dd9a878af45c7b71cb30ecd1322e2136dda90e6 at Thu 06 Mar 2025 11:15:41 AM +0545, contains 2 valid timestamp tokens.

Commit 147d07ea34be8c47e02589c04c8abeb3a0cb9052, which timestamps commit 19813747ce50b6ff9769a0d51eb12ce62f02a880 at Thu 06 Mar 2025 11:19:36 AM +0545, contains 2 valid timestamp tokens.

Commit fdf0c72865fc0c46410d3d119591fdc23490afa7, which timestamps commit 871f3e35215e51e34192afc4586a146ed88bd102 at Thu 06 Mar 2025 11:25:06 AM +0545, contains 2 valid timestamp tokens.

Commit ceacb4567608fc19abddc237c65ffab97117eeb2, which timestamps commit 35531cf91a5ae6e10d5a9e6ac6f6e3aeb3837c43 at Tue 11 Mar 2025 10:45:37 AM +0545, contains 2 valid timestamp tokens.

Commit 91293ebefbe635cc2bd4a41ff30bff38e064c0f5, which timestamps commit 7344aff8dd17c0913ecb96112e5e26b1738c8d50 at Mon 17 Mar 2025 10:03:16 AM +0545, contains 2 valid timestamp tokens.

Commit f1ecdcc90f948e3d4fc153b1328c054413497833, which timestamps commit aa7cee78f21525d6c5c5bf790f782d8108f97fce at Mon 17 Mar 2025 10:06:33 AM +0545, contains 2 valid timestamp tokens.

Commit fbb6dca2c3aef5a087fc285e1e49a30def8d2421, which timestamps commit 826c113f782ac08bd1902c82e2c3c16fa1f2fa29 at Mon 17 Mar 2025 06:49:38 PM +0545, contains 2 valid timestamp tokens.

Validation OK: All timestamped commits in the commit history of ccb85560b13c4e720beeda9907d2face4f5b1195 contain at least one valid timestamp.

real	8m13.557s
user	6m17.066s
sys	2m22.869s
A run of this locally: ``` $ time ../GitTrustedTimestamps/hooks/validate.sh Checking repository integrity... Repository integrity OK Validating timestamps. This may take a while... Commit 5994c3c7c0c09d70cf0949e23e3a094e7cf1d49a, which timestamps commit 3a51e6ef7d715151d484750993b5c802725755c9 at Tue 04 Feb 2025 04:54:15 PM +0545, contains 2 valid timestamp tokens. Commit 9b8b241dbe40ff84cd25823d9053c849ac6b28ca, which timestamps commit 316187712fa9c3bd7106525dfb16507c825e5eb6 at Wed 05 Feb 2025 01:28:07 PM +0545, contains 2 valid timestamp tokens. Commit a50db36196e84eb5abe38e17b36f2c22d12a727e, which timestamps commit f5f168a183e5df7ff74b7c7c765d06edc6ce32d6 at Wed 05 Feb 2025 01:30:36 PM +0545, contains 2 valid timestamp tokens. Commit 5ea3a2017f28d41e28aa7a366dc946da931ae18c, which timestamps commit 5b8d47eedb09eb08d46303fce4ec86d6f6db20b2 at Fri 07 Feb 2025 11:02:26 AM +0545, contains 2 valid timestamp tokens. Commit 2d748415e006913c295530e37ba0a29f0ab7b326, which timestamps commit a06e3b87cd987c51499797bd953dc513703041ec at Thu 13 Feb 2025 03:40:26 PM +0545, contains 2 valid timestamp tokens. Commit 6c593e3e6a78ba01b3b751849d68d54109f8b314, which timestamps commit c01e10906ade17fe729d485c2019508cb6d2d244 at Mon 17 Feb 2025 09:23:41 AM +0545, contains 2 valid timestamp tokens. Commit f04f4e6ef90e37ed2563fb425072ecab41a7a26f, which timestamps commit 3b499f1cdfce01192a5aadc94092234eb9ffe366 at Mon 17 Feb 2025 09:29:28 AM +0545, contains 2 valid timestamp tokens. Commit 99440e6f761935446cd86756abd5667a18be13d2, which timestamps commit 61437e135267f5a8dde45c0313ebc22da185e6cb at Mon 24 Feb 2025 10:08:36 AM +0545, contains 2 valid timestamp tokens. Commit 3af208fba66798bef32f9b8e42c4c8fb83a5a3f9, which timestamps commit 6dd9a878af45c7b71cb30ecd1322e2136dda90e6 at Thu 06 Mar 2025 11:15:41 AM +0545, contains 2 valid timestamp tokens. Commit 147d07ea34be8c47e02589c04c8abeb3a0cb9052, which timestamps commit 19813747ce50b6ff9769a0d51eb12ce62f02a880 at Thu 06 Mar 2025 11:19:36 AM +0545, contains 2 valid timestamp tokens. Commit fdf0c72865fc0c46410d3d119591fdc23490afa7, which timestamps commit 871f3e35215e51e34192afc4586a146ed88bd102 at Thu 06 Mar 2025 11:25:06 AM +0545, contains 2 valid timestamp tokens. Commit ceacb4567608fc19abddc237c65ffab97117eeb2, which timestamps commit 35531cf91a5ae6e10d5a9e6ac6f6e3aeb3837c43 at Tue 11 Mar 2025 10:45:37 AM +0545, contains 2 valid timestamp tokens. Commit 91293ebefbe635cc2bd4a41ff30bff38e064c0f5, which timestamps commit 7344aff8dd17c0913ecb96112e5e26b1738c8d50 at Mon 17 Mar 2025 10:03:16 AM +0545, contains 2 valid timestamp tokens. Commit f1ecdcc90f948e3d4fc153b1328c054413497833, which timestamps commit aa7cee78f21525d6c5c5bf790f782d8108f97fce at Mon 17 Mar 2025 10:06:33 AM +0545, contains 2 valid timestamp tokens. Commit fbb6dca2c3aef5a087fc285e1e49a30def8d2421, which timestamps commit 826c113f782ac08bd1902c82e2c3c16fa1f2fa29 at Mon 17 Mar 2025 06:49:38 PM +0545, contains 2 valid timestamp tokens. Validation OK: All timestamped commits in the commit history of ccb85560b13c4e720beeda9907d2face4f5b1195 contain at least one valid timestamp. real 8m13.557s user 6m17.066s sys 2m22.869s ```
Author
Owner

Without this change, the local run time for me is:

real	86m47.900s

10 times longer

Without this change, the local run time for me is: ``` real 86m47.900s ``` 10 times longer
Author
Owner

I need to do the timestamp validation thing for PRs in this repo - I will sort that out in a while.

I need to do the timestamp validation thing for PRs in this repo - I will sort that out in a while.
artur approved these changes 2025-03-19 03:55:40 +00:00
artur merged commit ac5e6a6a89 into main 2025-03-19 03:55:52 +00:00
Sign in to join this conversation.
No Reviewers
No Label
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: JankariTechUG/GitTrustedTimestamps#7
No description provided.