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

Allow setting constants via manifest #1030

Merged
merged 6 commits into from
Oct 12, 2023
Merged

Conversation

preston-evans98
Copy link
Member

@preston-evans98 preston-evans98 commented Oct 12, 2023

Description

This PR adds the #[config_constant] attribute, which sets a constant from the manifest file. This functionality will be used in several places, but is blocking for the soft-confirmations workflow (where we need to set the inbox_delay for forced transactions per-rollup instead of hard-coding it).

#[config_constant]
pub const TEST_ARRAY_OF_U8: [u8; 32];

fn main() {
 // The value is filled from `constants.json`, allowing this assertion to pass
 assert_eq!(TEST_ARRAY_OF_U8, [255;32])
}

This macro is exported from sov_modules_api::macros.

N.B.: This PR only implements basic types (numeric types, strings, booleans, and arrays). Support for more complex types is left unimplemented for now.

Testing

A new test has been added using trybuild to ensure that valid values are produced for the covered types.

Docs

A doc comment has been added

@codecov
Copy link

codecov bot commented Oct 12, 2023

Codecov Report

Merging #1030 (2e90d22) into nightly (0890fd1) will decrease coverage by 0.1%.
The diff coverage is 64.9%.

Files Coverage Δ
module-system/sov-modules-macros/src/lib.rs 100.0% <100.0%> (ø)
...le-system/sov-modules-macros/src/make_constants.rs 100.0% <100.0%> (ø)
module-system/sov-modules-macros/src/manifest.rs 64.0% <58.3%> (-0.1%) ⬇️

... and 2 files with indirect coverage changes

Copy link
Contributor

@vlopes11 vlopes11 left a comment

Choose a reason for hiding this comment

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

Looks good! It's a nice improvement to have tests over the functionality.

A couple of non-blocking comments & suggestions

module-system/sov-modules-macros/src/manifest.rs Outdated Show resolved Hide resolved
module-system/sov-modules-macros/src/manifest.rs Outdated Show resolved Hide resolved
module-system/sov-modules-macros/src/lib.rs Show resolved Hide resolved
@preston-evans98 preston-evans98 added this pull request to the merge queue Oct 12, 2023
Merged via the queue into nightly with commit 484a0e3 Oct 12, 2023
13 checks passed
@preston-evans98 preston-evans98 deleted the preston/consts branch October 12, 2023 21:17
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