diff --git a/doc/nativesc/contracts/ForgerStakesV2.json b/doc/nativesc/contracts/ForgerStakesV2.json
index 1e14e20..86a4607 100644
--- a/doc/nativesc/contracts/ForgerStakesV2.json
+++ b/doc/nativesc/contracts/ForgerStakesV2.json
@@ -47,13 +47,13 @@
"anonymous": false,
"inputs": [
{
- "indexed": false,
+ "indexed": true,
"internalType": "address",
"name": "sender",
"type": "address"
},
{
- "indexed": true,
+ "indexed": false,
"internalType": "bytes32",
"name": "signPubKey",
"type": "bytes32"
@@ -648,13 +648,33 @@
},
{
"internalType": "bytes32",
- "name": "signature1",
+ "name": "sign1_1",
+ "type": "bytes32"
+ },
+ {
+ "internalType": "bytes32",
+ "name": "sign1_2",
+ "type": "bytes32"
+ },
+ {
+ "internalType": "bytes32",
+ "name": "sign2_1",
"type": "bytes32"
},
{
"internalType": "bytes32",
- "name": "signature2",
+ "name": "sign2_2",
"type": "bytes32"
+ },
+ {
+ "internalType": "bytes32",
+ "name": "sign2_3",
+ "type": "bytes32"
+ },
+ {
+ "internalType": "bytes1",
+ "name": "sign2_4",
+ "type": "bytes1"
}
],
"name": "updateForger",
diff --git a/doc/nativesc/contracts/ForgerStakesV2.md b/doc/nativesc/contracts/ForgerStakesV2.md
index 74f18a5..cd4f183 100644
--- a/doc/nativesc/contracts/ForgerStakesV2.md
+++ b/doc/nativesc/contracts/ForgerStakesV2.md
@@ -19,12 +19,13 @@ This native smart contract manages the forger stakes from EON 1.4.0 version.
address rewardAddress, bytes32 sign1_1, bytes32 sign1_2,
bytes32 sign2_1, bytes32 sign2_2, bytes32 sign2_3, bytes1 sign2_4) external payable;
- Registers a new forger.
+ Register a new forger.
rewardShare can range in [0..1000] and can be 0 if and only if rewardAddress == 0x000..00.
Vrf key and signatures are split in two or more separate parameters, being longer than 32 bytes.
sign1_x are the 25519 signature chunks and sign2_x are the Vfr signature chunks.
- The message to sign is a string concatenation of signPubKey+vrfKey+rewardShare+rewardAddress, where rewardAddress
- is represented in the Eip55 checksum format.
+ The message to sign is the first 31 bytes of Keccak256 hash of a string formed by the concatenation
+ of signPubKey+vrfKey+rewardShare+rewardAddress. rewardAddress is represented in the Eip55
+ checksum format and hex strings are lowercase with no prefix.
The method accepts WEI value: the sent value will be converted to the initial stake assigned to the forger.
The initial stake amount must be >= min threshold (10 Zen)
@@ -59,11 +60,13 @@ This native smart contract manages the forger stakes from EON 1.4.0 version.
Returns the total stake amount, at the end of one or more consensus epochs, assigned to a specific forger.
vrf, signKey and delegator are optional: if all are null, the total stake amount will be returned. If only
delegator is null, all the stakes assigned to the forger will be summed.
- Be aware that following convention applies when we talk about 'null' values: for bytes parameters, as addresses of key etc., a byte array of the expected length with all 0 values is interpreted as null, eg "0x0000000000000000000000000000000000000000" for addresses. For consensusEpochStart and maxNumOfEpoch, it is 0.
If vrf and signKey are null, but delegator is defined, the method will fail.
consensusEpochStart and maxNumOfEpoch are optional: if both null, the data at the current consensus epoch is returned.
+ Be aware that following convention applies when we talk about 'null' values: for bytes parameters, as addresses or keys etc., a byte array of the expected length with all 0 values is interpreted as null, eg "0x0000000000000000000000000000000000000000" for addresses.
+ For consensusEpochStart and maxNumOfEpoch, it is 0.
Returned array contains also elements with 0 value. Returned values are ordered by epoch, and the array length may
- be < maxNumOfEpoch if the current consensus epoch is < (consensusEpochStart + maxNumOfEpoch - 1).
+ be < maxNumOfEpoch if the current consensus epoch is < (consensusEpochStart + maxNumOfEpoch).
+
- rewardsReceived
@@ -113,6 +116,7 @@ This native smart contract manages the forger stakes from EON 1.4.0 version.
Returns the paginated list of stakes delegated to a specific forger, grouped by delegator address.
Each element of the list is the total amount delegated by a specific address. The data structure has the following format:
+ The returned array length may be less than pageSize even if there are still additional elements because stakes with 0 amount are filtered out.
struct StakeDataDelegator {
address delegator;
@@ -127,6 +131,8 @@ This native smart contract manages the forger stakes from EON 1.4.0 version.
Returns the paginated list of stakes delegated by a specific address, grouped by forger.
Each element of the list is the total amount delegated to a specific forger. The data structure has the following format:
+ The returned array length may be less than pageSize even if there are still additional elements because stakes with 0 amount are filtered out.
+
struct StakeDataForger {
bytes32 signPubKey;
diff --git a/doc/nativesc/contracts/ForgerStakesV2.sol b/doc/nativesc/contracts/ForgerStakesV2.sol
index 85092d7..1b89a70 100644
--- a/doc/nativesc/contracts/ForgerStakesV2.sol
+++ b/doc/nativesc/contracts/ForgerStakesV2.sol
@@ -10,8 +10,8 @@ interface ForgerStakesV2 {
// Event declaration
// Up to 3 parameters can be indexed.
// Indexed parameters help you filter the logs by the indexed parameter
- event RegisterForger(address sender, bytes32 indexed signPubKey, bytes32 indexed vrf1, bytes1 indexed vrf2, uint256 value, uint32 rewardShare, address reward_address);
- event UpdateForger(address indexed sender, bytes32 signPubKey, bytes32 indexed vrf1, bytes1 indexed vrf2, uint32 rewardShare, address reward_address);
+ event RegisterForger(address indexed sender, bytes32 signPubKey, bytes32 indexed vrf1, bytes1 indexed vrf2, uint256 value, uint32 rewardShare, address reward_address);
+ event UpdateForger(address indexed sender, bytes32 signPubKey, bytes32 indexed vrf1, bytes1 indexed vrf2, uint32 rewardShare, address reward_address);
event DelegateForgerStake(address indexed sender, bytes32 signPubKey, bytes32 indexed vrf1, bytes1 indexed vrf2, uint256 value);
event WithdrawForgerStake(address indexed sender, bytes32 signPubKey, bytes32 indexed vrf1, bytes1 indexed vrf2, uint256 value);
event ActivateStakeV2();
@@ -45,8 +45,9 @@ interface ForgerStakesV2 {
rewardShare can range in [0..1000] and can be 0 if and only if rewardAddress == 0x000..00.
Vrf key and signatures are split in two or more separate parameters, being longer than 32 bytes.
sign1_x are the 25519 signature chunks and sign2_x are the Vfr signature chunks.
- The message to sign is a string concatenation of signPubKey+vrfKey+rewardShare+rewardAddress, where rewardAddress
- is represented in the Eip55 checksum format.
+ The message to sign is the first 31 bytes of Keccak256 hash of a string formed by the concatenation
+ of signPubKey+vrfKey+rewardShare+rewardAddress. rewardAddress is represented in the Eip55
+ checksum format and hex strings are lowercase with no prefix.
The method accepts WEI value: the sent value will be converted to the initial stake assigned to the forger.
The initial stake amount must be >= min threshold (10 Zen)
*/
@@ -54,13 +55,14 @@ interface ForgerStakesV2 {
address rewardAddress, bytes32 sign1_1, bytes32 sign1_2,
bytes32 sign2_1, bytes32 sign2_2, bytes32 sign2_3, bytes1 sign2_4) external payable;
-
/*
Updates an existing forger.
A forger can be updated just once and only if rewardAddress == 0x000..00 and rewardShare == 0.
- Vrf key is split in two separate parameters, being longer than 32 bytes.
+ See above the registerForger command for the parameters meaning.
*/
- function updateForger(bytes32 signPubKey, bytes32 vrf1, bytes1 vrf2, uint32 rewardShare, address rewardAddress, bytes32 signature1, bytes32 signature2) external;
+ function updateForger(bytes32 signPubKey, bytes32 vrf1, bytes1 vrf2, uint32 rewardShare,
+ address rewardAddress, bytes32 sign1_1, bytes32 sign1_2,
+ bytes32 sign2_1, bytes32 sign2_2, bytes32 sign2_3, bytes1 sign2_4) external;
/*
Delegate a stake to a previously registered forger.
@@ -80,21 +82,19 @@ interface ForgerStakesV2 {
Returns the total stake amount, at the end of one or more consensus epochs, assigned to a specific forger.
vrf, signKey and delegator are optional: if all are null, the total stake amount will be returned. If only
delegator is null, all the stakes assigned to the forger will be summed.
- Be aware that following convention apply when we talk about 'null' values: for bytes parameters, as addresses of key etc., a byte array of the expected length with all 0 values is interpreted as null, eg "0x0000000000000000000000000000000000000000" for addresses.
- For consensusEpochStart and maxNumOfEpoch, it is 0.
If vrf and signKey are null, but delegator is defined, the method will fail.
consensusEpochStart and maxNumOfEpoch are optional: if both null, the data at the current consensus epoch is returned.
+ Be aware that following convention applies when we talk about 'null' values: for bytes parameters, as addresses or keys etc., a byte array of the expected length with all 0 values is interpreted as null, eg "0x0000000000000000000000000000000000000000" for addresses.
+ For consensusEpochStart and maxNumOfEpoch, it is 0.
Returned array contains also elements with 0 value. Returned values are ordered by epoch, and the array length may
- be < maxNumOfEpoch if the current consensus epoch is < (consensusEpochStart + maxNumOfEpoch) or if the forger was
- registered after consensusEpochStart.
+ be < maxNumOfEpoch if the current consensus epoch is < (consensusEpochStart + maxNumOfEpoch).
*/
function stakeTotal(bytes32 signPubKey, bytes32 vrf1, bytes1 vrf2, address delegator, uint32 consensusEpochStart, uint32 maxNumOfEpoch) external view returns (uint256[] memory listOfStakes);
/*
Return total sum paid to the forger reward_address at the end of one or more consensus epochs.
Returned array contains also elements with 0 value. Returned values are ordered by epoch, and the array length may
- be < maxNumOfEpoch if the current consensus epoch is < (consensusEpochStart + maxNumOfEpoch) or if the forger was
- registered after consensusEpochStart.
+ be < maxNumOfEpoch if the current consensus epoch is < (consensusEpochStart + maxNumOfEpoch).
*/
function rewardsReceived(bytes32 signPubKey, bytes32 vrf1, bytes1 vrf2, uint32 consensusEpochStart, uint32 maxNumOfEpoch) external view returns (uint256[] memory listOfRewards);
@@ -121,6 +121,7 @@ interface ForgerStakesV2 {
Returns the paginated list of stakes delegated to a specific forger, grouped by delegator address.
Each element of the list is the total amount delegated by a specific address.
nextIndex will contain the index of the next element not returned yet. If no element is still present, next will be -1.
+ The returned array length may be less than pageSize even if there are still additional elements because stakes with 0 amount are filtered out.
*/
function getPagedForgersStakesByForger(bytes32 signPubKey, bytes32 vrf1, bytes1 vrf2, int32 startIndex, int32 pageSize) external view returns (int32 nextIndex, StakeDataDelegator[] memory listOfDelegatorStakes);
@@ -128,6 +129,7 @@ interface ForgerStakesV2 {
Returns the paginated list of stakes delegated by a specific address, grouped by forger.
Each element of the list is the total amount delegated to a specific forger.
nextIndex will contain the index of the next element not returned yet. If no element is still present, next will be -1.
+ The returned array length may be less than pageSize even if there are still additional elements because stakes with 0 amount are filtered out.
*/
function getPagedForgersStakesByDelegator(address delegator, int32 startIndex, int32 pageSize) external view returns (int32 nextIndex, StakeDataForger[] memory listOfForgerStakes);
diff --git a/doc/nativesc/index.md b/doc/nativesc/index.md
index 440e794..505d565 100644
--- a/doc/nativesc/index.md
+++ b/doc/nativesc/index.md
@@ -6,7 +6,7 @@ They can be invoked as any standard smart contract with rpc method calls or (sta
Below a detailed list:
[WithdrawalRequests](/doc/nativesc/contracts/WithdrawalRequests.md)
-[ForgerStakesV2](/doc/nativesc/contracts/ForgerStakes.md)
+[ForgerStakesV2](/doc/nativesc/contracts/ForgerStakesV2.md)
[McAddrOwnerships](/doc/nativesc/contracts/McAddrOwnership.md)
[CertKeyRotation](/doc/nativesc/contracts/CertKeyRotation.md)
diff --git a/node/src/main/java/io/horizen/eon/EonForkConfigurator.java b/node/src/main/java/io/horizen/eon/EonForkConfigurator.java
index 4e6fb27..6922be6 100644
--- a/node/src/main/java/io/horizen/eon/EonForkConfigurator.java
+++ b/node/src/main/java/io/horizen/eon/EonForkConfigurator.java
@@ -19,6 +19,7 @@ public EonForkConfigurator(Optional sidechainId) {
optionalSidechainForks.addAll(new F3Fork(sidechainId).getPairs());
optionalSidechainForks.addAll(new F4Fork(sidechainId).getPairs());
optionalSidechainForks.addAll(new F5Fork(sidechainId).getPairs());
+ optionalSidechainForks.addAll(new F6Fork(sidechainId).getPairs());
mandatorySidechainFork1 = new SidechainForkConsensusEpoch(0, 0, 0);
}
diff --git a/node/src/main/java/io/horizen/eon/forks/F6Fork.java b/node/src/main/java/io/horizen/eon/forks/F6Fork.java
new file mode 100644
index 0000000..997d8c0
--- /dev/null
+++ b/node/src/main/java/io/horizen/eon/forks/F6Fork.java
@@ -0,0 +1,52 @@
+package io.horizen.eon.forks;
+
+import io.horizen.account.fork.Version1_3_0Fork;
+import io.horizen.account.fork.Version1_4_0Fork;
+import io.horizen.fork.OptionalSidechainFork;
+import io.horizen.fork.SidechainForkConsensusEpoch;
+import io.horizen.utils.Pair;
+
+import java.util.List;
+import java.util.Optional;
+
+/**
+ * EON fork 6 (introduced in Version 1.4.0)
+ * New on-chain delegated staking reward mechanism, new handling of rewards from mainchain
+ */
+public class F6Fork extends EONFork {
+ public F6Fork(Optional sidechainId) {
+ super(sidechainId);
+ }
+
+ @Override
+ protected int getActivationRegtest() {
+ return 7;
+ }
+ @Override
+ protected int getActivationTestnetPregobi() {return 2180;} //estimated start at TUE 21 May 2024 16:31 Milano time
+
+ @Override
+ protected int getActivationTestnetGobi() {
+ return 10000000; //TBD
+ }
+ @Override
+ protected int getActivationTestnet() { return 2180; //not used
+ }
+ @Override
+ protected int getActivationMainnet() {
+ return 10000000; //TBD
+ }
+
+ @Override
+ public List> getPairs() {
+ return List.of(
+ new Pair<>(
+ new SidechainForkConsensusEpoch(
+ getActivationRegtest(),
+ getActivationTestnet(sidechainId),
+ getActivationMainnet()),
+ new Version1_4_0Fork(true)
+ )
+ );
+ }
+}
\ No newline at end of file