Skip to content

Commit

Permalink
fix(chain): peerId is required for bootstrap
Browse files Browse the repository at this point in the history
Add a new field for peerID in the chain config form when it is running as bootstrap node.

When `Is this node running as a bootstrap peer?` is selected, peerId is now required.

JIRA: https://smartcontract-it.atlassian.net/browse/OPCORE-948
  • Loading branch information
graham-chainlink committed Sep 12, 2024
1 parent f55d4fd commit 9d33674
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 87 deletions.
5 changes: 5 additions & 0 deletions .changeset/cyan-kids-boil.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@smartcontractkit/operator-ui': minor
---

Peer ID field is required when Node is running as bootstrap peer
8 changes: 8 additions & 0 deletions src/components/Form/ChainConfigurationForm.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ describe('ChainConfigurationForm', () => {
expect(await findByTestId('ocr1Multiaddr-helper-text')).toHaveTextContent(
'Required',
)

expect(await findByTestId('ocr1P2PPeerID-helper-text')).toHaveTextContent(
'Required',
)
})

it('validates OCR2 input', async () => {
Expand Down Expand Up @@ -180,5 +184,9 @@ describe('ChainConfigurationForm', () => {
expect(await findByTestId('ocr2Multiaddr-helper-text')).toHaveTextContent(
'Required',
)

expect(await findByTestId('ocr2P2PPeerID-helper-text')).toHaveTextContent(
'Required',
)
})
})
147 changes: 69 additions & 78 deletions src/components/Form/ChainConfigurationForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ const ValidationSchema = Yup.object().shape({
})
.nullable(),
ocr1P2PPeerID: Yup.string()
.when(['ocr1Enabled', 'ocr1IsBootstrap'], {
is: (enabled: boolean, isBootstrap: boolean) => enabled && !isBootstrap,
.when(['ocr1Enabled'], {
is: (enabled: boolean) => enabled,
then: Yup.string().required('Required').nullable(),
})
.nullable(),
Expand All @@ -82,8 +82,8 @@ const ValidationSchema = Yup.object().shape({
})
.nullable(),
ocr2P2PPeerID: Yup.string()
.when(['ocr2Enabled', 'ocr2IsBootstrap'], {
is: (enabled: boolean, isBootstrap: boolean) => enabled && !isBootstrap,
.when(['ocr2Enabled'], {
is: (enabled: boolean) => enabled,
then: Yup.string().required('Required').nullable(),
})
.nullable(),
Expand Down Expand Up @@ -361,6 +361,28 @@ export const ChainConfigurationForm = withStyles(styles)(
/>
</Grid>

<Grid item xs={12} md={6}>
<Field
component={TextField}
id="ocr1P2PPeerID"
name="ocr1P2PPeerID"
label="Peer ID"
select
required
fullWidth
helperText="The Peer ID used for this chain"
FormHelperTextProps={{
'data-testid': 'ocr1P2PPeerID-helper-text',
}}
>
{p2pKeys.map((key) => (
<MenuItem key={key.peerID} value={key.peerID}>
{key.peerID}
</MenuItem>
))}
</Field>
</Grid>

{values.ocr1IsBootstrap ? (
<Grid item xs={12}>
<Field
Expand All @@ -377,55 +399,27 @@ export const ChainConfigurationForm = withStyles(styles)(
/>
</Grid>
) : (
<>
<Grid item xs={12} md={6}>
<Field
component={TextField}
id="ocr1P2PPeerID"
name="ocr1P2PPeerID"
label="Peer ID"
select
required
fullWidth
helperText="The Peer ID used for this chain"
FormHelperTextProps={{
'data-testid': 'ocr1P2PPeerID-helper-text',
}}
>
{p2pKeys.map((key) => (
<MenuItem
key={key.peerID}
value={key.peerID}
>
{key.peerID}
</MenuItem>
))}
</Field>
</Grid>

<Grid item xs={12} md={6}>
<Field
component={TextField}
id="ocr1KeyBundleID"
name="ocr1KeyBundleID"
label="Key Bundle ID"
select
required
fullWidth
helperText="The OCR Key Bundle ID used for this chain"
FormHelperTextProps={{
'data-testid':
'ocr1KeyBundleID-helper-text',
}}
>
{ocrKeys.map((key) => (
<MenuItem key={key.id} value={key.id}>
{key.id}
</MenuItem>
))}
</Field>
</Grid>
</>
<Grid item xs={12} md={6}>
<Field
component={TextField}
id="ocr1KeyBundleID"
name="ocr1KeyBundleID"
label="Key Bundle ID"
select
required
fullWidth
helperText="The OCR Key Bundle ID used for this chain"
FormHelperTextProps={{
'data-testid': 'ocr1KeyBundleID-helper-text',
}}
>
{ocrKeys.map((key) => (
<MenuItem key={key.id} value={key.id}>
{key.id}
</MenuItem>
))}
</Field>
</Grid>
)}
</>
</Grid>
Expand Down Expand Up @@ -459,6 +453,28 @@ export const ChainConfigurationForm = withStyles(styles)(
/>
</Grid>

<Grid item xs={12} md={6}>
<Field
component={TextField}
id="ocr2P2PPeerID"
name="ocr2P2PPeerID"
label="Peer ID"
select
required
fullWidth
helperText="The Peer ID used for this chain"
FormHelperTextProps={{
'data-testid': 'ocr2P2PPeerID-helper-text',
}}
>
{p2pKeys.map((key) => (
<MenuItem key={key.peerID} value={key.peerID}>
{key.peerID}
</MenuItem>
))}
</Field>
</Grid>

{values.ocr2IsBootstrap ? (
<Grid item xs={12}>
<Field
Expand All @@ -476,31 +492,6 @@ export const ChainConfigurationForm = withStyles(styles)(
</Grid>
) : (
<>
<Grid item xs={12} md={6}>
<Field
component={TextField}
id="ocr2P2PPeerID"
name="ocr2P2PPeerID"
label="Peer ID"
select
required
fullWidth
helperText="The Peer ID used for this chain"
FormHelperTextProps={{
'data-testid': 'ocr2P2PPeerID-helper-text',
}}
>
{p2pKeys.map((key) => (
<MenuItem
key={key.peerID}
value={key.peerID}
>
{key.peerID}
</MenuItem>
))}
</Field>
</Grid>

<Grid item xs={12} md={6}>
<Field
component={TextField}
Expand Down
24 changes: 15 additions & 9 deletions src/screens/FeedsManager/SupportedChainsCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,16 @@ const renderBootstrap = (
| FeedsManager_ChainConfigFields['ocr2JobConfig']
| FeedsManager_ChainConfigFields['ocr1JobConfig'],
) => (
<Grid item xs={12} sm={1} md={5}>
<DetailsCardItemTitle title="Multiaddr" />
<DetailsCardItemValue value={cfg.multiaddr} />
</Grid>
<>
<Grid item xs={12} md={5}>
<DetailsCardItemTitle title="Multiaddr" />
<DetailsCardItemValue value={cfg.multiaddr} />
</Grid>
<Grid item xs={12} md={5}>
<DetailsCardItemTitle title="P2P Peer ID" />
<DetailsCardItemValue value={cfg.p2pPeerID} />
</Grid>
</>
)

const renderOracle = (
Expand All @@ -158,11 +164,11 @@ const renderOracle = (
| FeedsManager_ChainConfigFields['ocr1JobConfig'],
) => (
<>
<Grid item xs={12} sm={1} md={5}>
<Grid item xs={12} md={5}>
<DetailsCardItemTitle title="P2P Peer ID" />
<DetailsCardItemValue value={cfg.p2pPeerID} />
</Grid>
<Grid item xs={12} sm={1} md={5}>
<Grid item xs={12} md={5}>
<DetailsCardItemTitle title="OCR Key ID" />
<DetailsCardItemValue value={cfg.keyBundleID} />
</Grid>
Expand Down Expand Up @@ -196,7 +202,7 @@ const FluxMonitorJobTypeRow = withStyles(styles)(
}

return (
<Grid item xs={12} sm={1} md={12}>
<Grid item xs={12} md={12}>
<div className={classes.jobTypeContainer}>
<DetailsCardItemTitle title="Job Type" />
<DetailsCardItemValue value="Flux Monitor" />
Expand All @@ -218,7 +224,7 @@ const OCRJobTypeRow = withStyles(styles)(

return (
<>
<Grid item xs={12} sm={1} md={2}>
<Grid item xs={12} md={2}>
<div className={classes.jobTypeContainer}>
<DetailsCardItemTitle title="Job Type" />
<DetailsCardItemValue
Expand All @@ -245,7 +251,7 @@ const OCR2JobTypeRow = withStyles(styles)(

return (
<>
<Grid item xs={12} sm={1} md={2}>
<Grid item xs={12} md={2}>
<div className={classes.jobTypeContainer}>
<DetailsCardItemTitle title="Job Type" />
<DetailsCardItemValue
Expand Down

0 comments on commit 9d33674

Please sign in to comment.