feat(chainspec): add TempoFeatures bitfield and require_feature! macro#2887
Draft
feat(chainspec): add TempoFeatures bitfield and require_feature! macro#2887
Conversation
Adds independent feature flags as a layer on top of the existing TempoHardfork enum. Each feature is a single bit with explicit dependency requirements via a DAG. Existing hardforks map to feature sets for backward compatibility. Also adds require_feature! macro for ergonomic feature gating in precompile dispatch arms. Co-authored-by: Zygis <zygis@tempo.xyz> Co-authored-by: Georgios <georgios@tempo.xyz> Amp-Thread-ID: https://ampcode.com/threads/T-019c9ad6-7f63-70b7-8ba2-bd1433803493 Co-authored-by: Amp <amp@ampcode.com>
📊 Tempo Precompiles CoverageprecompilesCoverage: 20839/21903 lines (95.14%) File details
contractsCoverage: 209/383 lines (54.57%) File details
Total: 21048/22286 lines (94.44%) |
Covers: cycle detection, hardfork dependency consistency, high-bit usage, feature count, display formatting, and base feature independence. Amp-Thread-ID: https://ampcode.com/threads/T-019c9ad6-7f63-70b7-8ba2-bd1433803493 Co-authored-by: Amp <amp@ampcode.com>
…has()
Drops the u128 bitflags in favor of a Vec<u64>-backed TempoFeatures
with no upper bound on feature count. Adds TempoHardfork::has() for
ergonomic feature checks in handler/consensus code:
if spec.has(TempoFeature::REPLAY_HASH_V2) { ... }
Tests include handler migration patterns and multi-feature gating.
Amp-Thread-ID: https://ampcode.com/threads/T-019c9ad6-7f63-70b7-8ba2-bd1433803493
Co-authored-by: Amp <amp@ampcode.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
TempoFeature/TempoFeatures— a growable bitset-based feature flag system layered on top of the existingTempoHardforkenum. Each protocol change gets its own numeric ID with explicit dependency requirements via a DAG (requires()/can_activate()). No upper bound on feature count.Also adds:
spec.has(TempoFeature::REPLAY_HASH_V2)for ergonomic feature checks in handler/consensus coderequire_feature!macro for precompile dispatch gatingDesign decisions:
TempoFeaturesis aVec<u64>-backed bitset — grows dynamically, no capTempoHardfork::has()derives features from the hardfork for backward compatChainSpecstays static, features will live inCfgEnv(already per-block) when on-chain activation landsrequires()DAG, validated withcan_activate()Migration path for existing code:
Phased rollout:
TempoFeatures+spec.has()+require_feature!macrospec.is_tN()callsitesTempoFeaturesfield toCfgEnv, compute per-block from on-chain stateFeatureRegistryprecompile for validator signaling + 80% threshold activationPrompted by: zygis