feat(test-fill): Optimistic grouping flag - #3390
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## forks/amsterdam #3390 +/- ##
===================================================
- Coverage 93.53% 91.33% -2.21%
===================================================
Files 624 624
Lines 37074 37074
Branches 3394 3394
===================================================
- Hits 34679 33863 -816
- Misses 1645 2758 +1113
+ Partials 750 453 -297
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| config = MockConfig(use_pre_alloc_groups=True) | ||
|
|
||
| # Mock the file system operations | ||
| group_hash = AllocGroupHash.from_hash("test_hash") |
There was a problem hiding this comment.
For reviewers: Maybe from_hash is not the best name for this function. It's supposed to mean "calculate the AllocGroupHash from sha56'ing the input, string or bytes, and then truncate".
danceratopz
left a comment
There was a problem hiding this comment.
Thanks a lot for cleaning up the types here Mario 🙏
This looks good to me, just a few comments below. But I think we should align on a release strategy before merge.
If you're busy, I can PR the changes below; as you like.
| pre_hash: AllocGroupHash | ||
| """Hash of the pre-allocation group this test belongs to.""" | ||
|
|
||
| post_state_diff: Alloc | None = None |
There was a problem hiding this comment.
This change will break loading v20.0.0/v20.0.1. It would be nice to be stricter with these fields going forward, although adding an empty Alloc has little value.
From our side, this is currently only relevant for the generic test flow, I can fix that by pinning the EELS branch until the next release.
For client infra: The easiest solution to avoid breaking their infra would be to build and release v20.0.2 immediately after merging this and telling clients to update.
There was a problem hiding this comment.
I think we can do Alloc | None = None and then eventually remove the None once we've made enough releases with this field populated. Thanks for spotting this, I'll rollback the change!
There was a problem hiding this comment.
After some checking I've discovered that the pre-alloc groups in v20.0.0/v20.0.1 are broken anyway due to a bug introduced in #2140: They contain the "builder" variant and therefore do not include the genesis header in them, and the only way to ingest them is to load them using the builder's model and then build them internally, which is fine for consume, but if anyone wants to use them out-of-the-box it's very inconvenient.
It's possible to include a ton of workarounds in this PR to try to load the broken variants but I feel we are just digging ourselves in a deeper tech debt hole. I suggest we merge this PR with the strict models and then make the v20.1.0 release, stating that there are breaking changes in the format.
cc @danceratopz
There was a problem hiding this comment.
hasher still breaks by default with engine_x when ran as:
hasher compare <fill-a> <fill-b>
due to the presence of blockchain_tests_engine_x/pre_alloc/*.json. As we're touching hasher here anyway, we could consider excluding pre_alloc/. But very happy to do this as a follow-up!
There was a problem hiding this comment.
Very nice idea, I'll give it a go while time boxing it 👍
| "groups, phase 2 generates all supported fixture formats." | ||
| ), | ||
| ) | ||
| test_group.addoption( |
There was a problem hiding this comment.
We could consider adding a pytester test for invoking fill with this to pin the behavior down.
| "testCount": 88, | ||
| "preAccountCount": 174, |
There was a problem hiding this comment.
These never got written to the JSON (pre-existing issue); they're only tracked internally in the in-memory PreAllocGroup. We should remove them here (consumers can use len(testIds) and len(pre).
| "testCount": 88, | |
| "preAccountCount": 174, |
There was a problem hiding this comment.
It's a bug, see #3390 (comment). Along with the genesis header, they are missing from v20.0.0/1.
| - **`testCount`**: Number of tests in this pre-allocation group | ||
| - **`preAccountCount`**: Number of accounts in the pre-allocation group |
There was a problem hiding this comment.
They can be removed here, too.
| - **`testCount`**: Number of tests in this pre-allocation group | |
| - **`preAccountCount`**: Number of accounts in the pre-allocation group |
81629c4 to
e20e161
Compare
Description
Makes pre-allocation group packing optional, and replaces the untyped string hashes used across the pre-alloc group and fixture index machinery with fixed-size types.
--disable-optimistic-pre-alloc-groupingNew
fillflag. Phase 1 skips the packing pass so groups stay fine-grained, and phase 2 then resolves a test's group by recomputing its hash directly instead of looking it up in the packed index. Packing stays the default.Typed group hashes
AllocGroupHash(8-byte truncated sha256) replaces thestr/inthashes that were assembled by hand in several places.Environment.__hash__is replaced byEnvironment.canonical_json(), so the grouping pre-image is an explicit canonical JSON encoding rather than a process-stable__hash__whose value was persisted as a folder name.PreAllocGroupBuildercarries its owngroup_hash, andGroupPreAlloc.get_pre_alloc_grouping_hash()lets an allocation report the group it belongs to.GroupIndexEntry/GroupIndexEntriesare pydantic models; the test → group index is read and written through them instead of hand-rolled JSON.Engine X fixtures
pre_hashis set when the fixture is constructed, from the allocation's own group hash, rather than patched onto the model afterwards.postStateDiffwas never populated:post_stateis not a field ofBlockchainEngineXFixture, so the filler'shasattr(fixture, "post_state")guard never fired. It is now computed inBlockchainTest.make_hive_fixturethrough the newAlloc.calculate_diff()(moved out offiller.py) and is a required field.Fixture index
TestCaseBase.fixture_hashandIndexFile.root_hashareHashinstead ofHexNumber;hasherandcompare_fixturesfollow.FixtureCollectorwrites index entries throughTestCaseIndexFileinstead of an ad-hoc dict.HashableItem.from_folderno longer strips the first two characters of a hash unconditionally, which mis-parsed unprefixedgeneratedTestHashvalues into 31 bytes.Compatibility
Group hashes change, so existing
pre_allocfolders must be regenerated. Engine X fixtures and.meta/index.jsonfiles written by earlier versions no longer validate, sincepostStateDiffandfixture_hashare now required.Related Issues or PRs
N/A.
Checklist
just static<type>(<area>): <title>, where<type>and<area>come from an appropriateC-<type>, respectivelyA-<area>, label. The title should match the target squash commit message.Cute Animal Picture