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

Implement the calculate spower offchain feature #944

Merged
merged 102 commits into from
Jun 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
102 commits
Select commit Hold shift + click to select a range
f9e6a37
1. Add WorkReportsToProcess queue which will be processed by the offc…
wuhaixian1984 May 17, 2024
70c55dc
Fix the build warnings
wuhaixian1984 May 17, 2024
8f60da5
Initial check in to implement the market::update_replicas extrinsic call
wuhaixian1984 May 23, 2024
9054268
1. Refactor the UpdatedFilesToProcess data structure, to record the u…
wuhaixian1984 May 27, 2024
599a220
1. Add new events for pallet_market and pallet_swork for the update_r…
wuhaixian1984 May 28, 2024
16cf42a
1. Put the file info details inside the UpdatedFileToProcess structur…
wuhaixian1984 May 30, 2024
d30a270
1. Implement the swork::update_spower extrinsic call
wuhaixian1984 May 30, 2024
250a08e
1. Refactor the market::update_replicas arguments, events, and db de…
wuhaixian1984 Jun 1, 2024
617d342
Refactor the market.UpdatedFilesToProcess data structure
wuhaixian1984 Jun 3, 2024
1c16e5f
Update the UPDATE_OFFSET from 200 to 100, which means the partial_upd…
wuhaixian1984 Jun 4, 2024
8b41b01
1. Refactor the storage item and update_replicas process logic, don't…
wuhaixian1984 Jun 6, 2024
4e96583
Change the swork::update_spower call arguments type from BTreeMap to …
wuhaixian1984 Jun 14, 2024
30a5c53
Upgrade spec_version from 21 to 22
wuhaixian1984 Jun 14, 2024
794b0b5
1. Make the market::update_replicas charge no fee as this is a freque…
wuhaixian1984 Jun 27, 2024
d049b1b
Update pallet_market's test cases to accomodate the latest logic
wuhaixian1984 Jun 27, 2024
37f9e06
1. Fix bug in update_illegal_file_replicas_count() method, need to us…
wuhaixian1984 Jun 27, 2024
ef3aecc
Update pallet_swork's test cases to accomodate the latest logic
wuhaixian1984 Jun 27, 2024
a96d513
Ignore any log file check-in
wuhaixian1984 Jun 27, 2024
7cd54b6
Auto updated substrate references
May 17, 2024
e641b7b
Auto updated substrate references
May 17, 2024
174ba68
Auto updated substrate references
May 19, 2024
a4a15b5
Auto updated substrate references
May 20, 2024
eb3cc51
Auto updated substrate references
May 20, 2024
3307965
Auto updated substrate references
May 21, 2024
5afa3dd
Auto updated substrate references
May 21, 2024
1185b39
Auto updated substrate references
May 22, 2024
0752e8a
Auto updated substrate references
May 22, 2024
6608116
Auto updated substrate references
May 22, 2024
b636f1d
Auto updated substrate references
May 23, 2024
e0fe370
Auto updated substrate references
May 23, 2024
e040df2
Auto updated substrate references
May 23, 2024
06adc52
Auto updated substrate references
May 24, 2024
1137afc
Auto updated substrate references
May 24, 2024
ca4aa01
Auto updated substrate references
May 24, 2024
5823b54
Auto updated substrate references
May 25, 2024
242f283
Auto updated substrate references
May 27, 2024
ebbbbe8
Auto updated substrate references
May 27, 2024
ce63ce8
Auto updated substrate references
May 28, 2024
1cbb684
Auto updated substrate references
May 28, 2024
db42e8d
Auto updated substrate references
May 28, 2024
7c6139c
Auto updated substrate references
May 29, 2024
98761ec
Auto updated substrate references
May 29, 2024
e125def
Auto updated substrate references
May 29, 2024
4aeae46
Auto updated substrate references
May 30, 2024
75734db
Auto updated substrate references
May 30, 2024
3e95657
Auto updated substrate references
May 31, 2024
f797dfb
Auto updated substrate references
May 31, 2024
ba5abd7
Auto updated substrate references
May 31, 2024
ab2eeaa
Auto updated substrate references
Jun 3, 2024
1faffa2
Auto updated substrate references
Jun 3, 2024
55138b7
Auto updated substrate references
Jun 3, 2024
477229c
Auto updated substrate references
Jun 4, 2024
e17b537
Auto updated substrate references
Jun 4, 2024
99ca6fd
Auto updated substrate references
Jun 5, 2024
629f17c
Auto updated substrate references
Jun 5, 2024
36eab47
Auto updated substrate references
Jun 5, 2024
42b221e
Auto updated substrate references
Jun 6, 2024
3fdf39e
Auto updated substrate references
Jun 6, 2024
1d55b53
Auto updated substrate references
Jun 7, 2024
73b1e16
Auto updated substrate references
Jun 7, 2024
18224f7
Auto updated substrate references
Jun 7, 2024
94fe0b1
Auto updated substrate references
Jun 8, 2024
bc930ce
Auto updated substrate references
Jun 10, 2024
e9d8332
Auto updated substrate references
Jun 10, 2024
9dcb49b
Auto updated substrate references
Jun 11, 2024
c8a4813
Auto updated substrate references
Jun 12, 2024
10b9f73
Auto updated substrate references
Jun 12, 2024
ef5f0d3
Auto updated substrate references
Jun 13, 2024
b9e0bfa
Auto updated substrate references
Jun 13, 2024
50d93fd
Auto updated substrate references
Jun 13, 2024
eed4039
Auto updated substrate references
Jun 14, 2024
960171d
Auto updated substrate references
Jun 14, 2024
252f754
Auto updated substrate references
Jun 17, 2024
847197f
Auto updated substrate references
Jun 17, 2024
32707aa
Auto updated substrate references
Jun 18, 2024
d03d1da
Auto updated substrate references
Jun 18, 2024
ad21a49
Auto updated substrate references
Jun 18, 2024
c1f5027
Auto updated substrate references
Jun 19, 2024
f099dca
Auto updated substrate references
Jun 19, 2024
7fcd50c
Auto updated substrate references
Jun 20, 2024
4d3a7d0
Auto updated substrate references
Jun 21, 2024
e207155
Auto updated substrate references
Jun 21, 2024
10eb0e3
Auto updated substrate references
Jun 22, 2024
ff33b05
Auto updated substrate references
Jun 23, 2024
4f7fcf4
Auto updated substrate references
Jun 24, 2024
9ea7703
Auto updated substrate references
Jun 24, 2024
d7f2d37
Auto updated substrate references
Jun 25, 2024
de7c327
Auto updated substrate references
Jun 25, 2024
0dd8e17
Auto updated substrate references
Jun 26, 2024
b5a8abd
Auto updated substrate references
Jun 26, 2024
dda9161
Auto updated substrate references
Jun 27, 2024
e9706da
Auto updated substrate references
Jun 27, 2024
b826935
1. Add WorkReportsToProcess queue which will be processed by the offc…
wuhaixian1984 May 17, 2024
579d19e
Initial check in to implement the market::update_replicas extrinsic call
wuhaixian1984 May 23, 2024
beb668f
1. Add new events for pallet_market and pallet_swork for the update_r…
wuhaixian1984 May 28, 2024
77818db
1. Implement the swork::update_spower extrinsic call
wuhaixian1984 May 30, 2024
cea8403
Fix rebase from mainnet merge errors
wuhaixian1984 Jun 28, 2024
e65f77a
Upgrade revision from 22 to 23
wuhaixian1984 Jun 29, 2024
0325126
Merge the polkadot-sdk from mainnet
wuhaixian1984 Jun 29, 2024
6e05661
Merge branch 'mainnet' into brian/calculate-spower-offchain
wuhaixian1984 Jun 29, 2024
e642db9
Add back the comments
wuhaixian1984 Jun 29, 2024
bff2821
Remove unused code
wuhaixian1984 Jun 29, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,6 @@

## Integration test
db/

# logs
*.log
583 changes: 364 additions & 219 deletions cstrml/market/src/lib.rs

Large diffs are not rendered by default.

39 changes: 37 additions & 2 deletions cstrml/market/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ pub const MERCHANT: AccountId32 = AccountId32::new([5u8; 32]);
pub const DAVE: AccountId32 = AccountId32::new([6u8; 32]);
pub const FERDIE: AccountId32 = AccountId32::new([7u8; 32]);
pub const ZIKUN: AccountId32 = AccountId32::new([8u8; 32]);
pub const SPOWER: AccountId32 = AccountId32::new([9u8; 32]);

#[derive(Debug, PartialEq, Eq, Clone, Encode, Decode, Default)]
pub struct MockMerchantLedger {
Expand Down Expand Up @@ -301,8 +302,42 @@ pub fn init_swork_setup() {
}

// fake for report_works
pub fn add_who_into_replica(cid: &MerkleRoot, reported_size: u64, who: AccountId, owner: AccountId, anchor: SworkerAnchor, created_at: Option<u32>, _maybe_members: Option<BTreeSet<AccountId>>) -> u64 {
Market::upsert_replica(&who, owner, cid, reported_size, &anchor, created_at.unwrap_or(TryInto::<u32>::try_into(System::block_number()).ok().unwrap())).0
pub fn add_who_into_replica(
cid: &MerkleRoot,
reported_size: u64,
who: AccountId,
owner: AccountId,
anchor: SworkerAnchor,
report_slot: ReportSlot,
report_block: BlockNumber,
valid_at: BlockNumber) {

assert_ok!(Market::update_replicas(
Origin::signed(SPOWER.clone()),
vec![(cid.clone(),
reported_size,
vec![(who.clone(), owner.clone(), anchor.clone(), report_slot, report_block, valid_at, true)]
)],
400));
}

pub fn delete_replica(
cid: &MerkleRoot,
reported_size: u64,
who: AccountId,
owner: AccountId,
anchor: SworkerAnchor,
report_slot: ReportSlot,
report_block: BlockNumber,
valid_at: BlockNumber) {

assert_ok!(Market::update_replicas(
Origin::signed(SPOWER.clone()),
vec![(cid.clone(),
reported_size,
vec![(who.clone(), owner.clone(), anchor.clone(), report_slot, report_block, valid_at, false)]
)],
400));
}

pub fn legal_work_report_with_added_files() -> ReportWorksInfo {
Expand Down
Loading
Loading