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 preset overrides #4601
Allow preset overrides #4601
Conversation
this.timeout(30_000); | ||
|
||
it("Should correctly override preset", async () => { | ||
await exec(`${tsNodeBinary} ${path.join(__dirname, scriptNames.ok)}`); |
Check warning
Code scanning / CodeQL
Shell command built from environment values
}); | ||
|
||
it("Should throw trying to override preset in the wrong order", async () => { | ||
await expect(exec(`${tsNodeBinary} ${path.join(__dirname, scriptNames.error)}`)).to.be.rejectedWith( |
Check warning
Code scanning / CodeQL
Shell command built from environment values
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you change this test to instead be split into two different files that does the same thing (one pass, one fail)?
Wanting to prevent an exec
here if possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've tried to do it, but params/src/index.ts
gets imported during test setup and freezes preset, so if I call setCustomPreset
from the same thread - it fails
setCustomPreset(PresetName.minimal, {SLOTS_PER_EPOCH: 2}); | ||
|
||
// 2. Import from any other @lodestar/params paths | ||
import {expect} from "chai"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just use node:assert equals to keep the scripts simple https://nodejs.org/api/assert.html#assertequalactual-expected-message
export function setCustomPreset(presetName: PresetName, overrides: Partial<BeaconPreset>): void { | ||
setActivePreset(presetName); | ||
userOverrides = overrides; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not extend setActivePreset() function above?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good idea. and make overrides
optional.
@daniildxb I pushed some updates here, hoping to get this merged asap |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this LGTM
Can someone else also give sanity check @ChainSafe/lodestar
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thanks for the contribution ❤️
Motivation
This PR allows users to override preset values (i.e. for use in ephemerals)
Description
Adds
setCustomPreset(presetName: PresetName, overrides: Partial<BeaconPreset>)
method that allows users to pass preset base and override objectCloses #4598
Steps to test or reproduce
Added e2e test to params package to verify it works