Skip to content

Commit

Permalink
Merge branch 'proof-fix-and-parantheses' of github.com:OriginTrail/dk…
Browse files Browse the repository at this point in the history
…g-evm-module into proof-fix-and-parantheses
  • Loading branch information
u-hubar committed Feb 12, 2024
2 parents 0a5d9a6 + 94ef671 commit a026725
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 21 deletions.
6 changes: 6 additions & 0 deletions abi/ProofManagerV1.json
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,12 @@
"internalType": "uint72",
"name": "identityId",
"type": "uint72"
},
{
"indexed": false,
"internalType": "uint96",
"name": "reward",
"type": "uint96"
}
],
"name": "ProofSubmitted",
Expand Down
6 changes: 6 additions & 0 deletions abi/ProofManagerV1U1.json
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,12 @@
"internalType": "uint72",
"name": "identityId",
"type": "uint72"
},
{
"indexed": false,
"internalType": "uint96",
"name": "reward",
"type": "uint96"
}
],
"name": "ProofSubmitted",
Expand Down
6 changes: 6 additions & 0 deletions abi/StakingV2.json
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,12 @@
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "bytes32",
"name": "agreementId",
"type": "bytes32"
},
{
"indexed": true,
"internalType": "uint72",
Expand Down
19 changes: 11 additions & 8 deletions contracts/v1/ProofManagerV1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,12 @@ contract ProofManagerV1 is Named, Versioned, ContractStatus, Initializable {
bytes keyword,
uint8 hashFunctionId,
uint16 epoch,
uint72 indexed identityId
uint72 indexed identityId,
uint96 reward
);

string private constant _NAME = "ProofManagerV1";
string private constant _VERSION = "1.0.2";
string private constant _VERSION = "1.0.3";

bool[4] public reqs = [false, false, false, false];

Expand Down Expand Up @@ -191,20 +192,22 @@ contract ProofManagerV1 is Named, Versioned, ContractStatus, Initializable {
challenge
);
}

uint96 reward = sasProxy.getAgreementTokenAmount(agreementId) /
((r0 - sasProxy.getAgreementRewardedNodesNumber(agreementId, args.epoch)) +
(sasProxy.getAgreementEpochsNumber(agreementId) - (args.epoch + 1)) *
r0);

emit ProofSubmitted(
args.assetContract,
args.tokenId,
args.keyword,
args.hashFunctionId,
args.epoch,
identityId
identityId,
reward
);

uint96 reward = sasProxy.getAgreementTokenAmount(agreementId) /
((r0 - sasProxy.getAgreementRewardedNodesNumber(agreementId, args.epoch)) +
(sasProxy.getAgreementEpochsNumber(agreementId) - (args.epoch + 1)) *
r0);

stakingContract.addReward(agreementId, identityId, reward);
sasProxy.setAgreementTokenAmount(agreementId, sasProxy.getAgreementTokenAmount(agreementId) - reward);
sasProxy.incrementAgreementRewardedNodesNumber(agreementId, args.epoch);
Expand Down
19 changes: 11 additions & 8 deletions contracts/v1/ProofManagerV1U1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,12 @@ contract ProofManagerV1U1 is Named, Versioned, ContractStatus, Initializable {
uint8 hashFunctionId,
uint16 epoch,
uint256 stateIndex,
uint72 indexed identityId
uint72 indexed identityId,
uint96 reward
);

string private constant _NAME = "ProofManagerV1U1";
string private constant _VERSION = "1.0.2";
string private constant _VERSION = "1.0.3";

bool[4] public reqs = [false, false, false, false];

Expand Down Expand Up @@ -200,21 +201,23 @@ contract ProofManagerV1U1 is Named, Versioned, ContractStatus, Initializable {
challenge
);
}

uint96 reward = sasProxy.getAgreementTokenAmount(agreementId) /
((r0 - sasProxy.getAgreementRewardedNodesNumber(agreementId, args.epoch)) +
(sasProxy.getAgreementEpochsNumber(agreementId) - (args.epoch + 1)) *
r0);

emit ProofSubmitted(
args.assetContract,
args.tokenId,
args.keyword,
args.hashFunctionId,
args.epoch,
latestFinalizedStateIndex,
identityId
identityId,
reward
);

uint96 reward = sasProxy.getAgreementTokenAmount(agreementId) /
((r0 - sasProxy.getAgreementRewardedNodesNumber(agreementId, args.epoch)) +
(sasProxy.getAgreementEpochsNumber(agreementId) - (args.epoch + 1)) *
r0);

stakingContract.addReward(agreementId, identityId, reward);
sasProxy.setAgreementTokenAmount(agreementId, sasProxy.getAgreementTokenAmount(agreementId) - reward);
sasProxy.incrementAgreementRewardedNodesNumber(agreementId, args.epoch);
Expand Down
10 changes: 9 additions & 1 deletion contracts/v2/Staking.sol
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ contract StakingV2 is Named, Versioned, ContractStatus, Initializable {
uint256 newTotalSupply
);
event RewardCollected(
bytes32 indexed agreementId,
uint72 indexed identityId,
bytes nodeId,
address serviceAgreementAddress,
Expand Down Expand Up @@ -238,7 +239,14 @@ contract StakingV2 is Named, Versioned, ContractStatus, Initializable {
sasAddress = sasProxy.agreementV1U1StorageAddress();
}
emit StakeIncreased(identityId, ps.getNodeId(identityId), sasAddress, oldStake, oldStake + delegatorsReward);
emit RewardCollected(identityId, ps.getNodeId(identityId), sasAddress, operatorFee, delegatorsReward);
emit RewardCollected(
agreementId,
identityId,
ps.getNodeId(identityId),
sasAddress,
operatorFee,
delegatorsReward
);
}

// solhint-disable-next-line no-empty-blocks
Expand Down
4 changes: 2 additions & 2 deletions test/v1/unit/ProofManagerV1.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,8 @@ describe('@v1 @unit ProofManagerV1 contract', function () {
expect(await ProofManagerV1.name()).to.equal('ProofManagerV1');
});

it('The contract is version "1.0.2"', async () => {
expect(await ProofManagerV1.version()).to.equal('1.0.2');
it('The contract is version "1.0.3"', async () => {
expect(await ProofManagerV1.version()).to.equal('1.0.3');
});

it('Create a new asset, teleport to the proof phase and check if window is open, expect true', async () => {
Expand Down
4 changes: 2 additions & 2 deletions test/v1/unit/ProofManagerV1U1.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,8 @@ describe('@v1 @unit ProofManagerV1U1 contract', function () {
expect(await ProofManagerV1U1.name()).to.equal('ProofManagerV1U1');
});

it('The contract is version "1.0.2"', async () => {
expect(await ProofManagerV1U1.version()).to.equal('1.0.2');
it('The contract is version "1.0.3"', async () => {
expect(await ProofManagerV1U1.version()).to.equal('1.0.3');
});

it('Create a new asset, update and finalize update, teleport to the proof phase and check if window is open, expect true', async () => {
Expand Down

0 comments on commit a026725

Please sign in to comment.