File tree Expand file tree Collapse file tree 4 files changed +49
-1
lines changed Expand file tree Collapse file tree 4 files changed +49
-1
lines changed Original file line number Diff line number Diff line change 1+ // SPDX-License-Identifier: MIT
2+ pragma solidity ^ 0.8.0 ;
3+
4+ //implements aggregrator staking for future node
5+ //if aggregrator and validator are seperate entities
6+ //we use this contract else for testnet
7+ //Single entity acts as task creator,aggregrator and validator
8+
9+ import "./BaseTask.sol " ;
10+
11+ contract AggrgrationAndValidation is BaseTask {
12+ address aggregratorAddress;
13+
14+ function stakeAsAggregrator (uint taskID ) public payable {
15+ require (tasks[taskID].isActive, "Task is not active " );
16+ require (
17+ aggregratorAddress == address (0 ),
18+ "Aggregator already assigned "
19+ );
20+ require (
21+ msg .value >= AGGREGATOR_STAKE,
22+ "Insufficient stake for aggregator "
23+ );
24+ Task storage task = tasks[taskID];
25+
26+ task.stakes[msg .sender ] = msg .value ;
27+ task.totalstaked += msg .value ;
28+ aggregratorAddress = msg .sender ;
29+
30+
31+ }
32+
33+ //add aggregration logic for blockchain layer
34+ }
Original file line number Diff line number Diff line change 11//// SPDX-License-Identifier: MIT
22pragma solidity ^ 0.8.0 ;
33
4+ //defines constants and base task struct
5+
46abstract contract BaseTask {
57 struct Task {
68 uint id;
Original file line number Diff line number Diff line change 33pragma solidity ^ 0.8.0 ;
44
55import "./TaskManagement.sol " ;
6+
7+ //implements a role based stacking mechanism
8+ /*Task Creator stakes at least CREATOR_STAKE while creating the task.
9+ Trainer Nodes stake TRAINER_STAKE when joining as trainers.
10+ Aggregator stakes AGGREGATOR_STAKE during the aggregation phase.
11+ */
12+
613/*
714To-Do
815*Trainer can unstake to asign trainer to different task
Original file line number Diff line number Diff line change 11// SPDX-License-Identifier: MIT
22pragma solidity ^ 0.8.0 ;
33
4+ //ensure the task creater stakes the required amount
5+
6+
47import "./BaseTask.sol " ;
58
69contract TaskManagement is BaseTask {
7- function createTask (uint reward ) public payable {
10+ function createTask (uint reward ) public payable isCreatorRole (reward) {
811 require (msg .value == reward, "reward must be deposited " );
912
1013 Task storage newTask = tasks[taskCounter];
1114 newTask.id = taskCounter;
1215 newTask.creator = msg .sender ;
1316 newTask.reward = reward;
17+ newTask.totalstaked += CREATOR_STAKE; //can be more than required
1418 newTask.isActive = true ; //should be set for specific time eventually
1519
1620 emit TaskCreated ((taskCounter), msg .sender , reward);
@@ -31,6 +35,7 @@ contract TaskManagement is BaseTask {
3135 msg .value == reward + CREATOR_STAKE,
3236 "Reward and stake must be deposited "
3337 );
38+ _;
3439 }
3540
3641 modifier onlyActiveTask (uint taskId ) {
You can’t perform that action at this time.
0 commit comments