-
Notifications
You must be signed in to change notification settings - Fork 8
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
Fixes initialisation process on the web frontend #166
Changes from 4 commits
48a71a4
cda589a
958f702
e7b7d1e
80a7b52
930019f
6c7f680
3e3105d
e40e1ea
5e97a5f
3a6ab20
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ import Modal from 'components/modal/Modal'; | |
import StatusTimeline from './components/StatusTimeline'; | ||
import Loading from 'pages/Loading'; | ||
import Action from './components/Action'; | ||
import { NodeStatus } from 'types/node'; | ||
import { InternalDKGInfo, NodeStatus } from 'types/node'; | ||
import useGetResults from './components/utils/useGetResults'; | ||
import UserIDTable from './components/UserIDTable'; | ||
import DKGStatusTable from './components/DKGStatusTable'; | ||
|
@@ -42,7 +42,7 @@ const ElectionShow: FC = () => { | |
|
||
const [nodeProxyAddresses, setNodeProxyAddresses] = useState<Map<string, string>>(new Map()); | ||
const [nodeToSetup, setNodeToSetup] = useState<[string, string]>(null); | ||
// The status of each node | ||
// The status of each node. Key is the node's address. | ||
const [DKGStatuses, setDKGStatuses] = useState<Map<string, NodeStatus>>(new Map()); | ||
|
||
const [nodeLoading, setNodeLoading] = useState<Map<string, boolean>>(null); | ||
|
@@ -51,6 +51,33 @@ const ElectionShow: FC = () => { | |
const ongoingItem = 'ongoingAction' + electionID; | ||
const nodeToSetupItem = 'nodeToSetup' + electionID; | ||
|
||
// called by a DKG row | ||
const notifyDKGState = (node: string, info: InternalDKGInfo) => { | ||
console.log('DKG node updated:', info); | ||
switch (info.getStatus()) { | ||
case NodeStatus.Failed: | ||
console.log('DKG node failed'); | ||
setOngoingAction(OngoingAction.None); | ||
break; | ||
case NodeStatus.Setup: | ||
setOngoingAction(OngoingAction.None); | ||
setStatus(Status.Setup); | ||
break; | ||
} | ||
|
||
const newDKGStatuses = new Map(DKGStatuses); | ||
newDKGStatuses.set(node, info.getStatus()); | ||
setDKGStatuses(newDKGStatuses); | ||
console.log('dkg statuses:', DKGStatuses); | ||
}; | ||
|
||
// called by a DKG row | ||
const notifyLoading = (node: string, l: boolean) => { | ||
const newLoading = new Map(nodeLoading); | ||
newLoading.set(node, l); | ||
setNodeLoading(newLoading); | ||
}; | ||
|
||
// Fetch result when available after a status change | ||
useEffect(() => { | ||
if (status === Status.ResultAvailable && isResultAvailable) { | ||
|
@@ -76,6 +103,7 @@ const ElectionShow: FC = () => { | |
const storedOngoingAction = JSON.parse(window.localStorage.getItem(ongoingItem)); | ||
|
||
if (storedOngoingAction !== null) { | ||
console.log('stored ongoing action:', storedOngoingAction); | ||
setOngoingAction(storedOngoingAction); | ||
} | ||
|
||
|
@@ -141,14 +169,20 @@ const ElectionShow: FC = () => { | |
|
||
nkcr marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// TODO: can be modified such that if the majority of the node are | ||
// initialized than the election status can still be set to initialized | ||
if (statuses.includes(NodeStatus.NotInitialized)) return; | ||
if (statuses.includes(NodeStatus.NotInitialized)) { | ||
setOngoingAction(OngoingAction.None); | ||
setStatus(Status.Initial); | ||
return; | ||
} | ||
|
||
if (statuses.includes(NodeStatus.Setup)) { | ||
setOngoingAction(OngoingAction.None); | ||
setStatus(Status.Setup); | ||
return; | ||
} | ||
|
||
if (statuses.includes(NodeStatus.Unreachable)) return; | ||
if (statuses.includes(NodeStatus.Failed)) return; | ||
|
||
setStatus(Status.Initialized); | ||
|
||
|
@@ -220,8 +254,6 @@ const ElectionShow: FC = () => { | |
setOngoingAction={setOngoingAction} | ||
nodeToSetup={nodeToSetup} | ||
setNodeToSetup={setNodeToSetup} | ||
DKGStatuses={DKGStatuses} | ||
setDKGStatuses={setDKGStatuses} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (I can't suggest changes on lines that were not modified). But line 225 and 239, it would be great to add: |
||
/> | ||
)} | ||
</div> | ||
|
@@ -240,14 +272,14 @@ const ElectionShow: FC = () => { | |
<DKGStatusTable | ||
roster={roster} | ||
electionId={electionId} | ||
loading={nodeLoading} | ||
setLoading={setNodeLoading} | ||
nodeProxyAddresses={nodeProxyAddresses} | ||
setNodeProxyAddresses={setNodeProxyAddresses} | ||
DKGStatuses={DKGStatuses} | ||
setDKGStatuses={setDKGStatuses} | ||
setTextModalError={setTextModalError} | ||
setShowModalError={setShowModalError} | ||
ongoingAction={ongoingAction} | ||
notifyDKGState={notifyDKGState} | ||
nodeToSetup={nodeToSetup} | ||
notifyLoading={notifyLoading} | ||
/> | ||
</div> | ||
</div> | ||
|
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.
If I understand correctly, this is unsafe, because while we only start
Stream
once, we could still receive multipletypes.Start
message. If so, this will be called multiple times.I believe we have the same issue in dela.
Concretely, the impact on this line is minimal, but I'm concerned about the multiple starts in parallel 🤔 am I missing something ? do we have a test that verifies that we'll ignore the second start (on the same stream) if one is already running ?
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.
That can technically happen if other nodes participating in the setup decide to act badly and send start messages.