Skip to content

Commit ff9d2f6

Browse files
authored
Merge pull request #1580 from Phala-Network/prb-v3.2
prb v3.2
2 parents 99e7a2c + 8ec772e commit ff9d2f6

29 files changed

+3701
-2337
lines changed

Cargo.lock

Lines changed: 40 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/phaxt/src/rpc.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,18 @@ impl<'a, T: Config> ExtraRpcClient<'a, T> {
7070
pub async fn system_sync_state(&self) -> Result<SyncState, Error> {
7171
self.client.request("system_syncState", rpc_params![]).await
7272
}
73+
74+
/// Fetch next nonce for an Account
75+
///
76+
/// Return account nonce adjusted for extrinsics currently in transaction pool
77+
pub async fn system_account_next_index(&self, account_id: &T::AccountId) -> Result<u64, Error>
78+
where
79+
T::AccountId: Serialize,
80+
{
81+
self.client
82+
.request("system_accountNextIndex", rpc_params![&account_id])
83+
.await
84+
}
7385
}
7486

7587
impl<'a, T: Config> ExtraRpcClient<'a, T>

frontend/apps/prb3-monitor/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"next": "13.3.1",
2222
"react": "18.2.0",
2323
"react-dom": "18.2.0",
24-
"react-icons": "^4.8.0",
24+
"react-icons": "^5.0.1",
2525
"styletron-engine-atomic": "^1.5.0",
2626
"styletron-react": "^6.1.0",
2727
"swr": "^2.1.4",

frontend/apps/prb3-monitor/src/pages/status/tx.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ export default function WorkerStatusPage() {
138138
<div className={css({height: '100%', margin: '0 20px 20px'})}>
139139
<StatefulDataTable
140140
initialSortIndex={0}
141-
initialSortDirection="ASC"
141+
initialSortDirection="DESC"
142142
resizableColumnWidths
143143
columns={columns}
144144
rows={data?.txs || []}

frontend/apps/prb3-monitor/src/pages/status/worker.js

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React, {useCallback, useMemo} from 'react';
22
import {styled, useStyletron} from 'baseui';
33
import {StatefulDataTable, CategoricalColumn, NumericalColumn, StringColumn, COLUMNS} from 'baseui/data-table';
44
import {MobileHeader} from 'baseui/mobile-header';
5-
import {TbAnalyze, TbCloudUpload, TbRefresh} from 'react-icons/tb';
5+
import {TbAnalyze, TbCloudUpload, TbRefresh, TbCloudCheck} from 'react-icons/tb';
66
import Head from 'next/head';
77
import {useAtomValue} from 'jotai';
88
import {currentFetcherAtom, currentWmAtom} from '@/state';
@@ -195,6 +195,34 @@ export default function WorkerStatusPage() {
195195
</span>
196196
),
197197
},
198+
199+
{
200+
label: 'Take Checkpoint',
201+
onClick: async ({selection}) => {
202+
if (!confirm('Are you sure?')) {
203+
return;
204+
}
205+
try {
206+
await rawFetcher({
207+
url: '/workers/take_checkpoint',
208+
method: 'PUT',
209+
data: {ids: selection.map((i) => i.id)},
210+
});
211+
toaster.positive('Requested, check worker status for progress.');
212+
} catch (e) {
213+
console.error(e);
214+
toaster.negative(e.toString());
215+
} finally {
216+
await mutate();
217+
}
218+
},
219+
renderIcon: () => (
220+
<span className={css({display: 'flex', alignItems: 'center', fontSize: '12px', lineHeight: '0'})}>
221+
<TbCloudCheck className={css({marginRight: '3px'})} size={16} />
222+
Take Checkpoint
223+
</span>
224+
),
225+
},
198226
];
199227
}, [css, mutate, rawFetcher]);
200228
const rowActions = useMemo(() => {
@@ -254,6 +282,34 @@ export default function WorkerStatusPage() {
254282
</span>
255283
),
256284
},
285+
286+
{
287+
label: 'Take Checkpoint',
288+
onClick: async ({row}) => {
289+
if (!confirm('Are you sure?')) {
290+
return;
291+
}
292+
try {
293+
await rawFetcher({
294+
url: '/workers/take_checkpoint',
295+
method: 'PUT',
296+
data: {ids: [row.id]},
297+
});
298+
toaster.positive('Requested, check worker status for progress.');
299+
} catch (e) {
300+
console.error(e);
301+
toaster.negative(e.toString());
302+
} finally {
303+
await mutate();
304+
}
305+
},
306+
renderIcon: () => (
307+
<span className={css({display: 'flex', alignItems: 'center', fontSize: '15px', lineHeight: '0'})}>
308+
<TbCloudCheck className={css({marginRight: '3px'})} size={16} />
309+
Take Checkpoint
310+
</span>
311+
),
312+
},
257313
];
258314
}, [css, mutate, rawFetcher]);
259315

standalone/pherry/src/authority.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,21 @@ pub async fn get_authority_with_proof_at(
8181
})
8282
}
8383

84-
pub async fn verify(api: &RelaychainApi, header: &Header, mut justifications: &[u8]) -> Result<()> {
84+
pub async fn verify(api: &RelaychainApi, header: &Header, justifications: &[u8]) -> Result<()> {
8585
if header.number == 0 {
8686
return Ok(());
8787
}
8888
let prev_header = get_header_at(api, Some(header.number - 1)).await?.0;
8989
let auth_set = get_authority_with_proof_at(api, &prev_header).await?;
90+
verify_with_prev_authority_set(
91+
auth_set.authority_set.id,
92+
&auth_set.authority_set.list,
93+
header,
94+
justifications
95+
)
96+
}
97+
98+
pub fn verify_with_prev_authority_set(set_id: u64, authorities: &AuthorityList, header: &Header, mut justifications: &[u8]) -> Result<()> {
9099
let justification: GrandpaJustification<UnsigedBlock> =
91100
Decode::decode(&mut justifications).context("Failed to decode justification")?;
92101
if (
@@ -97,11 +106,11 @@ pub async fn verify(api: &RelaychainApi, header: &Header, mut justifications: &[
97106
bail!("Invalid commit target in grandpa justification");
98107
}
99108
justification
100-
.verify(auth_set.authority_set.id, &auth_set.authority_set.list)
109+
.verify(set_id, authorities)
101110
.context("Failed to verify justification")?;
102111
info!(
103112
"Verified grandpa justification at block {}, auth_id={}",
104-
header.number, auth_set.authority_set.id
113+
header.number, set_id
105114
);
106115
Ok(())
107-
}
116+
}

0 commit comments

Comments
 (0)