Skip to content

Commit

Permalink
Merge branch 'main' into p2p-peer-fetching-compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
cam-schultz authored Nov 26, 2024
2 parents e0d59da + a236757 commit 7f04068
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 33 deletions.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

43 changes: 20 additions & 23 deletions contracts/validator-manager/PoSValidatorManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -289,11 +289,7 @@ abstract contract PoSValidatorManager is
revert UnauthorizedOwner(_msgSender());
}

if (rewardRecipient == _msgSender()) {
delete $._rewardRecipients[validationID];
} else {
$._rewardRecipients[validationID] = rewardRecipient;
}
$._rewardRecipients[validationID] = rewardRecipient;
}

function changeDelegatorRewardRecipient(
Expand All @@ -310,11 +306,7 @@ abstract contract PoSValidatorManager is
revert UnauthorizedOwner(_msgSender());
}

if (rewardRecipient == _msgSender()) {
delete $._delegatorRewardRecipients[delegationID];
} else {
$._delegatorRewardRecipients[delegationID] = rewardRecipient;
}
$._delegatorRewardRecipients[delegationID] = rewardRecipient;
}

/**
Expand Down Expand Up @@ -365,12 +357,14 @@ abstract contract PoSValidatorManager is
stakingEndTime: validator.endedAt,
uptimeSeconds: uptimeSeconds
});
$._redeemableValidatorRewards[validationID] += reward;

if (rewardRecipient != address(0)) {
$._rewardRecipients[validationID] = rewardRecipient;
if (rewardRecipient == address(0)) {
rewardRecipient = $._posValidatorInfo[validationID].owner;
}

$._redeemableValidatorRewards[validationID] += reward;
$._rewardRecipients[validationID] = rewardRecipient;

return (reward > 0);
}

Expand All @@ -389,13 +383,12 @@ abstract contract PoSValidatorManager is
}

address owner = $._posValidatorInfo[validationID].owner;

address rewardRecipient = $._rewardRecipients[validationID];
delete $._rewardRecipients[validationID];

// the reward-recipient should always be set, but just in case it isn't, we won't burn the reward
if (rewardRecipient == address(0)) {
rewardRecipient = owner;
} else {
delete $._rewardRecipients[validationID];
}

// The validator can either be Completed or Invalidated here. We only grant rewards for Completed.
Expand Down Expand Up @@ -479,10 +472,14 @@ abstract contract PoSValidatorManager is
uint64 weight = valueToWeight(lockedValue);
bytes32 validationID = _initializeValidatorRegistration(registrationInput, weight);

$._posValidatorInfo[validationID].owner = _msgSender();
address owner = _msgSender();

$._posValidatorInfo[validationID].owner = owner;
$._posValidatorInfo[validationID].delegationFeeBips = delegationFeeBips;
$._posValidatorInfo[validationID].minStakeDuration = minStakeDuration;
$._posValidatorInfo[validationID].uptimeSeconds = 0;
$._rewardRecipients[validationID] = owner;

return validationID;
}

Expand Down Expand Up @@ -799,12 +796,13 @@ abstract contract PoSValidatorManager is
uptimeSeconds: $._posValidatorInfo[delegator.validationID].uptimeSeconds
});

$._redeemableDelegatorRewards[delegationID] = reward;

if (rewardRecipient != address(0)) {
$._delegatorRewardRecipients[delegationID] = rewardRecipient;
if (rewardRecipient == address(0)) {
rewardRecipient = delegator.owner;
}

$._redeemableDelegatorRewards[delegationID] = reward;
$._delegatorRewardRecipients[delegationID] = rewardRecipient;

return reward;
}

Expand Down Expand Up @@ -892,11 +890,10 @@ abstract contract PoSValidatorManager is
delete $._delegatorStakes[delegationID];

address rewardRecipient = $._delegatorRewardRecipients[delegationID];
delete $._delegatorRewardRecipients[delegationID];

if (rewardRecipient == address(0)) {
rewardRecipient = delegator.owner;
} else {
delete $._delegatorRewardRecipients[delegationID];
}

(uint256 delegationRewards, uint256 validatorFees) =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ interface IPoSValidatorManager is IValidatorManager {

/**
* @notice See {IPoSValidatorManager-initializeEndValidation} for details of the first three parameters
* @param recipientAddress The address to receive the rewards
* @param recipientAddress The address to receive the rewards. If the 0-address is provided, the rewards will be sent to the validator.
*/
function initializeEndValidation(
bytes32 validationID,
Expand Down Expand Up @@ -226,7 +226,7 @@ interface IPoSValidatorManager is IValidatorManager {

/**
* @notice See {IPoSValidatorManager-initializeEndDelegation} for details of the first three parameters
* @param recipientAddress The address to receive the rewards.
* @param recipientAddress The address to receive the rewards. If the 0-address is provided, the rewards will be sent to the delegator.
*/
function initializeEndDelegation(
bytes32 delegationID,
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ require (
github.com/ava-labs/subnet-evm v0.6.12
github.com/ethereum/go-ethereum v1.13.14
github.com/onsi/ginkgo/v2 v2.22.0
github.com/onsi/gomega v1.35.1
github.com/onsi/gomega v1.36.0
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.20.5
github.com/spf13/cobra v1.8.1
github.com/stretchr/testify v1.9.0
github.com/stretchr/testify v1.10.0
go.uber.org/zap v1.27.0
golang.org/x/tools v0.27.0
google.golang.org/protobuf v1.35.2
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -497,8 +497,8 @@ github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7J
github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY=
github.com/onsi/gomega v1.19.0/go.mod h1:LY+I3pBVzYsTBU1AnDwOSxaYi9WoWiqgwooUqq9yPro=
github.com/onsi/gomega v1.35.1 h1:Cwbd75ZBPxFSuZ6T+rN/WCb/gOc6YgFBXLlZLhC7Ds4=
github.com/onsi/gomega v1.35.1/go.mod h1:PvZbdDc8J6XJEpDK4HCuRBm8a6Fzp9/DmhC9C7yFlog=
github.com/onsi/gomega v1.36.0 h1:Pb12RlruUtj4XUuPUqeEWc6j5DkVVVA49Uf6YLfC95Y=
github.com/onsi/gomega v1.36.0/go.mod h1:PvZbdDc8J6XJEpDK4HCuRBm8a6Fzp9/DmhC9C7yFlog=
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
github.com/pelletier/go-toml/v2 v2.0.8 h1:0ctb6s9mE31h0/lhu+J6OPmVeDxJn+kYnJc2jZR9tGQ=
github.com/pelletier/go-toml/v2 v2.0.8/go.mod h1:vuYfssBdrU2XDZ9bYydBu6t+6a6PYNcZljzZR9VXg+4=
Expand Down Expand Up @@ -578,8 +578,8 @@ github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1F
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/subosito/gotenv v1.4.2 h1:X1TuBLAMDFbaTAChgCBLu3DU3UPyELpnF2jjJ2cz/S8=
github.com/subosito/gotenv v1.4.2/go.mod h1:ayKnFf/c6rvx/2iiLrJUk1e6plDbT3edrFNGqEflhK0=
github.com/supranational/blst v0.3.13 h1:AYeSxdOMacwu7FBmpfloBz5pbFXDmJL33RuwnKtmTjk=
Expand Down

0 comments on commit 7f04068

Please # to comment.