Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
114 commits
Select commit Hold shift + click to select a range
12453b8
Add random sampling lib
Apr 1, 2025
17b3e0b
Add random sampling storage
Apr 1, 2025
6317af4
Add random sampling logic contract
Apr 1, 2025
3e4361e
Add submitProof
Apr 2, 2025
98321b3
Adapt node score data structures
Apr 2, 2025
72d745f
review updates
Apr 2, 2025
18be0da
review updates
Apr 2, 2025
26a3a40
Fix migration and add structure for isNodeDelegator lookup
Mihajlo-Pavlovic Apr 3, 2025
ec212e7
Fix removeDelegator function
Mihajlo-Pavlovic Apr 3, 2025
99bd455
Optimize removeDelegator
Mihajlo-Pavlovic Apr 3, 2025
c7596e1
Fix renaming newAddresses
Mihajlo-Pavlovic Apr 3, 2025
59252c7
Remove unneded code
Mihajlo-Pavlovic Apr 3, 2025
6e198ab
Add delegatorsInfo interaction to Staking.sol
Mihajlo-Pavlovic Apr 3, 2025
ad8e57a
Add tests
Mihajlo-Pavlovic Apr 3, 2025
1b6efc7
Rename nodeDelegators -> nodeDelegatorAddresses
Mihajlo-Pavlovic Apr 3, 2025
ae715c4
Add logic for returning delegator to nodeDelegtors when it cancels st…
Mihajlo-Pavlovic Apr 3, 2025
48b89ac
delegators score
Apr 3, 2025
61844bf
uncomment code
Apr 3, 2025
75305de
Merge pull request #364 from OriginTrail/feature/delegator-info-cotract
Mihajlo-Pavlovic Apr 3, 2025
dc03507
fix delegators score function
Apr 3, 2025
3c06b70
Add abis
Apr 3, 2025
fcc11a7
change computeMerkleRoot to internal
Apr 3, 2025
b13a39d
Add isActiveProofPeriodStillValid and abis
Apr 3, 2025
0f4b78e
Update Challenge struct
Apr 3, 2025
ad09adc
Update proofingPeriodDurationInBlocks data type
Apr 3, 2025
da94a6f
Add ProofPeriodStatus struct
Apr 3, 2025
bd2a5bc
Add getActiveProofPeriodStatus
Apr 3, 2025
67aaf41
fix nodeAskFactor prefix in rewards calculation
Apr 4, 2025
af46384
fix getting kcStorage and epochStorage
Apr 4, 2025
a36c993
fix activeProofPeriodStartBlock calculation in updateAndGetActiveProo…
Apr 4, 2025
465f0ad
Add deployment scripts
Apr 4, 2025
9186742
Add development params
Apr 4, 2025
16314f8
fix knowledgeCollectionId calculation
Apr 4, 2025
abc2658
Allow only active KCs to be included in a challenge
Apr 4, 2025
0d03706
Add max stake limiter
Apr 4, 2025
c85fbbb
fix getHistoricalProofPeriodStartBlock
Apr 4, 2025
19d7c98
Gas optimizations in _generateChallenge
Apr 4, 2025
b7c7826
Add initial RS integration tests
Apr 4, 2025
afc85fc
Add delay when setting new getActiveProofingPeriodDurationInBlocks
Apr 8, 2025
72c1798
Update RS deployment script and parameters.json
Apr 8, 2025
b7a70e6
Update abi
Apr 8, 2025
2fcf70a
update tests with latest changes
Apr 9, 2025
afbd608
fix merkle root calculation and reorg code
Apr 9, 2025
d4a5106
fix submitProof chunk data type
Apr 9, 2025
954e055
Fix division by zero in _calculateAndStoreDelegatorScores
Apr 10, 2025
c6bd0fd
Add storage contract address to Challenge struct
Apr 10, 2025
1f7b199
fix activeProofPeriodStartBlock calculation
Apr 10, 2025
5d847b1
Add Should submit a valid proof successfully test
Apr 10, 2025
0b978a7
Swap returns with reverts
Apr 10, 2025
9165967
Update kc-helpers
Apr 10, 2025
d5bd58b
Reorg tests, add new and update old
Apr 10, 2025
85f8f43
Add 'Should fail to submit invalid proof (wrong chunk/proof)' test
Apr 11, 2025
4a9f6b6
Fix division by zero in _generateChallenge
Apr 11, 2025
f08c8f5
Add 'Should fail challenge creation if no active Knowledge Collection…
Apr 11, 2025
7805526
Add errors for testing
Apr 11, 2025
53a6c73
pass leafHash instead of chunk
Apr 11, 2025
a240fb3
Revert to argument initial data type
Apr 14, 2025
fa880eb
Fix nodeAskScaled overflow issue
Apr 14, 2025
b37f1fb
Add division by zero checks in storage
Apr 14, 2025
c44e452
Merge branch 'main' into feature/random-sampling
Apr 15, 2025
4179496
Gas optimizations
Apr 15, 2025
5144fe3
Fix blockhash bug and add requires
Apr 15, 2025
a5d2b68
Merge branch 'main' into feature/random-sampling
Apr 16, 2025
6dc4eb1
Update setup helpers
Apr 16, 2025
894879e
Update Staking version test
Apr 16, 2025
f156972
Add new and reorg old tests
Apr 16, 2025
0dbd057
Adapt RS deployments for all networks
Apr 16, 2025
db506c3
remove comment
Apr 16, 2025
f3fc305
Add more proof submission tests
Apr 17, 2025
0f598b5
Update assertion tools and bump version
Apr 17, 2025
9086d67
Add DelegatorsInfo events
Apr 17, 2025
2df2c7c
new contract addresses
Apr 18, 2025
dbc6d28
Remove migrator deployment
Apr 18, 2025
dfeedfa
update readme
Apr 18, 2025
858afe1
change migrate to public
Apr 18, 2025
be4c63d
add onlyHub to initialize in RandomSampling.sol
Apr 18, 2025
7facf3e
use ContractStatus instead of HubDependent
Apr 18, 2025
3ecd97a
bump version number
Apr 22, 2025
262ba06
revert to old version
Apr 22, 2025
7eba96d
Add claimRewards function
Apr 29, 2025
825f177
Add claimRewards tests
Apr 29, 2025
f63cdc5
Add TRAC fees added to stakingStorage check
Apr 29, 2025
ac88323
Add delegatorScore > 0 check
Apr 30, 2025
c0dd343
change revert to require
Apr 30, 2025
cc6a4f6
Merge pull request #369 from OriginTrail/feature/rs-rewards-claiming
zsculac Apr 30, 2025
3eeb7a8
v8.0.12 testnet release new deployments
Apr 30, 2025
d3f4e69
Update to new staking
May 5, 2025
718f809
extract constant in Ask.sol
May 7, 2025
f9a27fe
new Ask abi
May 7, 2025
8132725
fix staking on gnosis and base testnet
May 7, 2025
9069d5f
fix same challenge submitted multiple times
May 7, 2025
27d0c76
change public to external
May 8, 2025
c9af784
RandomSampling submitProof bugfix deployments
May 8, 2025
fe9bbab
Unit tests for random sampling and random sampling storage
FilipJoksimovic29 May 12, 2025
69bfe26
integration test added to git actions
FilipJoksimovic29 May 13, 2025
843e93c
added impersonation of hub instead of fake workaround
FilipJoksimovic29 May 13, 2025
0081c6c
Update test.yml
FilipJoksimovic29 May 19, 2025
a2058f1
Rename test.yml to random-sampling-test-actions.yml
FilipJoksimovic29 May 19, 2025
abb735a
Added events emit checks
FilipJoksimovic29 May 21, 2025
a0ea7c8
Make getDelegatorEpochRewardsAmount public
May 22, 2025
ab3d18e
make calculateNodeScore public
May 22, 2025
01b7235
Add more metrics to RandomSamplingStorage
May 22, 2025
3567dd5
new deployments
May 22, 2025
bbdcffb
Adapt scoring logic
May 22, 2025
d2e66e3
Merge pull request #374 from OriginTrail/delegators-scoring
branarakic May 22, 2025
1dcc248
Merge pull request #371 from OriginTrail/feature/random-sampling-unit…
branarakic May 22, 2025
29b91ce
Add allNodesEpochScore > 0 require to getDelegatorEpochRewardsAmount
May 22, 2025
5f8e536
Improved active KC search algorithm
Jun 3, 2025
e4498cc
Merge pull request #378 from OriginTrail/improvement/active-kc-bfs-al…
zsculac Jun 3, 2025
e6ad2f4
update deployments
Jun 3, 2025
d77e4a5
change recursion for iterative bfs
Jun 4, 2025
e1cc925
update comments
Jun 4, 2025
18c4b18
Merge pull request #379 from OriginTrail/improvement/active-kc-bfs-al…
zsculac Jun 4, 2025
23bb36c
new deployments
Jun 4, 2025
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
38 changes: 38 additions & 0 deletions .github/workflows/random-sampling-test-actions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Random Sampling Tests

on:
pull_request:
branches:
- '*'
push:
branches:
- '*'
workflow_dispatch:

jobs:
test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Run Random Sampling Tests
run: |
echo "Running RandomSamplingStorage tests..."
npx hardhat test test/unit/RandomSamplingStorage.test.ts
echo "Running RandomSampling tests..."
npx hardhat test test/unit/RandomSampling.test.ts
echo "Running RandomSamplingIntegration tests..."
npx hardhat test test/integration/RandomSampling.test.ts
env:
REPORT_GAS: true
COVERAGE: true
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ npm install
```

## NPM Scripts

This project utilizes a variety of NPM scripts to run various tasks and processes. The scripts are defined in the package.json file and are designed to be used with the Hardhat CLI, leveraging Hardhat plugins for additional functionality. Here's a brief description of the scripts:

- `clean`: Removes the cache and artifacts folders generated by Hardhat.
Expand All @@ -65,6 +66,7 @@ npm run compile
```

## Additional Hardhat tasks

Hardhat has plenty of other useful commands, extended by the installed plugins. Here's a brief description of the most useful tasks:

- `decode`: Decodes encoded ABI data (e.g. input data of transaction).
Expand All @@ -79,14 +81,17 @@ npx hardhat decode --data <bytes-data>
```

Usage example of `encode_data` task. Here we want to call ProofManagerV1 function called setReq, and this function can be called only through `forwardCall` in HubController and encoding arguments for this function can be done by using this task:

```sh
npx hardhat encode_data --contract-name ProofManagerV1 --function-name setReq 1 true
```

Alternatively, encoded data can be produced from Remix by copying prepared calldata from ProofManagerV1 setReq call.

## Contracts deployment on parachains

Update environment use NEUROWEB_DEVNET/NEUROWEB_TESTNET/NEUROWEB_MAINNET

```dotenv
RPC_NEUROWEB_DEVNET='<https_endpoint>'
EVM_PRIVATE_KEY_NEUROWEB_DEVNET='<0x_ethereum_private_key>'
Expand All @@ -96,47 +101,69 @@ ACCOUNT_WITH_NEURO_URI_NEUROWEB_DEVNET='<substrate_account_uri>'
<br/>

OriginTrail Parachain Devnet

```sh
npm run deploy:neuroweb_devnet
```

<br/>

OriginTrail Parachain Testnet

```sh
npm run deploy:neuroweb_testnet
```

<br/>

OriginTrail Parachain Mainnet

```sh
npm run deploy:neuroweb_mainnet
```

<br/>

Gnosis Chiado Dev

```sh
npm run deploy:gnosis_chiado_dev
```

<br/>

Gnosis Chiado Test

```sh
npm run deploy:gnosis_chiado_test
```

<br/>

Gnosis Mainnet

```sh
npm run deploy:gnosis_mainnet
```

<br/>

Base Sepolia Test

```sh
npm run deploy:base_sepolia_test
```

<br/>

Base Mainnet

```sh
npm run deploy:base_mainnet
```

<br/>

### Redeploy contract

In order to redeploy desired contract, set `deployed` to `false` in `deployments/<network>_contracts.json`.
13 changes: 13 additions & 0 deletions abi/Ask.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,19 @@
"name": "ZeroAddressHub",
"type": "error"
},
{
"inputs": [],
"name": "ASK_SCALING_FACTOR",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "askStorage",
Expand Down
Loading