Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove hints from hook data #68

Merged
merged 1 commit into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion src/contracts/slasher/Slasher.sol
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ contract Slasher is BaseSlasher, ISlasher {
operator,
slashedAmount,
captureTimestamp,
abi.encode(ISlasher.DelegatorData({hints: hints, slashableStake: slashableStake_, stakeAt: stakeAt}))
abi.encode(ISlasher.DelegatorData({slashableStake: slashableStake_, stakeAt: stakeAt}))
);

_vaultOnSlash(slashedAmount, captureTimestamp);
Expand Down
7 changes: 1 addition & 6 deletions src/contracts/slasher/VetoSlasher.sol
Original file line number Diff line number Diff line change
Expand Up @@ -177,12 +177,7 @@ contract VetoSlasher is BaseSlasher, IVetoSlasher {
slashedAmount,
request.captureTimestamp,
abi.encode(
IVetoSlasher.DelegatorData({
hints: hints,
slashableStake: slashableStake_,
stakeAt: stakeAt,
slashIndex: slashIndex
})
IVetoSlasher.DelegatorData({slashableStake: slashableStake_, stakeAt: stakeAt, slashIndex: slashIndex})
)
);

Expand Down
2 changes: 0 additions & 2 deletions src/interfaces/slasher/ISlasher.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,10 @@ interface ISlasher is IBaseSlasher {

/**
* @notice Extra data for the delegator.
* @param hints hints for the slash
* @param slashableStake amount of the slashable stake before the slash (cache)
* @param stakeAt amount of the stake at the capture time (cache)
*/
struct DelegatorData {
bytes hints;
uint256 slashableStake;
uint256 stakeAt;
}
Expand Down
2 changes: 0 additions & 2 deletions src/interfaces/slasher/IVetoSlasher.sol
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,11 @@ interface IVetoSlasher is IBaseSlasher {

/**
* @notice Extra data for the delegator.
* @param hints hints for the slash execution
* @param slashableStake amount of the slashable stake before the slash (cache)
* @param stakeAt amount of the stake at the capture time (cache)
* @param slashIndex index of the slash request
*/
struct DelegatorData {
bytes hints;
uint256 slashableStake;
uint256 stakeAt;
uint256 slashIndex;
Expand Down
4 changes: 0 additions & 4 deletions test/delegator/FullRestakeDelegator.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -1064,7 +1064,6 @@ contract FullRestakeDelegatorTest is Test {

SimpleFullRestakeDelegatorHook(hook).setData(
0,
"",
slasher.slashableStake(network.subnetwork(0), alice, uint48(blockTimestamp - 1), ""),
delegator.stakeAt(network.subnetwork(0), alice, uint48(blockTimestamp - 1), ""),
0
Expand All @@ -1076,7 +1075,6 @@ contract FullRestakeDelegatorTest is Test {

SimpleFullRestakeDelegatorHook(hook).setData(
0,
"",
slasher.slashableStake(network.subnetwork(0), alice, uint48(blockTimestamp - 1), ""),
delegator.stakeAt(network.subnetwork(0), alice, uint48(blockTimestamp - 1), ""),
0
Expand Down Expand Up @@ -1178,7 +1176,6 @@ contract FullRestakeDelegatorTest is Test {

SimpleFullRestakeDelegatorHook(hook).setData(
0,
"",
slasher.slashableStake(network.subnetwork(0), alice, uint48(blockTimestamp - 1), ""),
delegator.stakeAt(network.subnetwork(0), alice, uint48(blockTimestamp - 1), ""),
0
Expand All @@ -1195,7 +1192,6 @@ contract FullRestakeDelegatorTest is Test {

SimpleFullRestakeDelegatorHook(hook).setData(
0,
"",
slasher.slashableStake(network.subnetwork(0), alice, uint48(blockTimestamp - 1), ""),
delegator.stakeAt(network.subnetwork(0), alice, uint48(blockTimestamp - 1), ""),
0
Expand Down
4 changes: 0 additions & 4 deletions test/delegator/NetworkRestakeDelegator.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -1272,7 +1272,6 @@ contract NetworkRestakeDelegatorTest is Test {

SimpleNetworkRestakeDelegatorHook(hook).setData(
0,
"",
slasher.slashableStake(network.subnetwork(0), alice, uint48(blockTimestamp - 1), ""),
delegator.stakeAt(network.subnetwork(0), alice, uint48(blockTimestamp - 1), ""),
0
Expand Down Expand Up @@ -1309,7 +1308,6 @@ contract NetworkRestakeDelegatorTest is Test {

SimpleNetworkRestakeDelegatorHook(hook).setData(
0,
hints,
slasher.slashableStake(network.subnetwork(0), alice, uint48(blockTimestamp - 1), ""),
delegator.stakeAt(network.subnetwork(0), alice, uint48(blockTimestamp - 1), ""),
0
Expand Down Expand Up @@ -1413,7 +1411,6 @@ contract NetworkRestakeDelegatorTest is Test {

SimpleNetworkRestakeDelegatorHook(hook).setData(
0,
"",
slasher.slashableStake(network.subnetwork(0), alice, uint48(blockTimestamp - 1), ""),
delegator.stakeAt(network.subnetwork(0), alice, uint48(blockTimestamp - 1), ""),
0
Expand All @@ -1430,7 +1427,6 @@ contract NetworkRestakeDelegatorTest is Test {

SimpleNetworkRestakeDelegatorHook(hook).setData(
0,
"",
slasher.slashableStake(network.subnetwork(0), alice, uint48(blockTimestamp - 1), ""),
delegator.stakeAt(network.subnetwork(0), alice, uint48(blockTimestamp - 1), ""),
0
Expand Down
12 changes: 1 addition & 11 deletions test/mocks/SimpleFullRestakeDelegatorHook.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,12 @@ contract SimpleFullRestakeDelegatorHook is IDelegatorHook {
uint256 counter3;

uint256 slasherType;
bytes hints;
uint256 slashableStake;
uint256 stakeAt;
uint256 slashIndex;

function setData(
uint64 slasherType_,
bytes memory hints_,
uint256 slashableStake_,
uint256 stakeAt_,
uint256 slashIndex_
) external {
function setData(uint64 slasherType_, uint256 slashableStake_, uint256 stakeAt_, uint256 slashIndex_) external {
slasherType = slasherType_;
hints = hints_;
slashableStake = slashableStake_;
stakeAt = stakeAt_;
slashIndex = slashIndex_;
Expand All @@ -41,14 +33,12 @@ contract SimpleFullRestakeDelegatorHook is IDelegatorHook {
ISlasher.DelegatorData memory delegatorData =
abi.decode(generalDelegatorData.data, (ISlasher.DelegatorData));

assert(keccak256(delegatorData.hints) == keccak256(hints));
assert(delegatorData.slashableStake == slashableStake);
assert(delegatorData.stakeAt == stakeAt);
} else if (generalDelegatorData.slasherType == 1) {
IVetoSlasher.DelegatorData memory delegatorData =
abi.decode(generalDelegatorData.data, (IVetoSlasher.DelegatorData));

assert(keccak256(delegatorData.hints) == keccak256(hints));
assert(delegatorData.slashableStake == slashableStake);
assert(delegatorData.stakeAt == stakeAt);
assert(delegatorData.slashIndex == slashIndex);
Expand Down
12 changes: 1 addition & 11 deletions test/mocks/SimpleNetworkRestakeDelegatorHook.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,12 @@ contract SimpleNetworkRestakeDelegatorHook is IDelegatorHook {
uint256 counter3;

uint256 slasherType;
bytes hints;
uint256 slashableStake;
uint256 stakeAt;
uint256 slashIndex;

function setData(
uint64 slasherType_,
bytes memory hints_,
uint256 slashableStake_,
uint256 stakeAt_,
uint256 slashIndex_
) external {
function setData(uint64 slasherType_, uint256 slashableStake_, uint256 stakeAt_, uint256 slashIndex_) external {
slasherType = slasherType_;
hints = hints_;
slashableStake = slashableStake_;
stakeAt = stakeAt_;
slashIndex = slashIndex_;
Expand All @@ -41,14 +33,12 @@ contract SimpleNetworkRestakeDelegatorHook is IDelegatorHook {
ISlasher.DelegatorData memory delegatorData =
abi.decode(generalDelegatorData.data, (ISlasher.DelegatorData));

assert(keccak256(delegatorData.hints) == keccak256(hints));
assert(delegatorData.slashableStake == slashableStake);
assert(delegatorData.stakeAt == stakeAt);
} else if (generalDelegatorData.slasherType == 1) {
IVetoSlasher.DelegatorData memory delegatorData =
abi.decode(generalDelegatorData.data, (IVetoSlasher.DelegatorData));

assert(keccak256(delegatorData.hints) == keccak256(hints));
assert(delegatorData.slashableStake == slashableStake);
assert(delegatorData.stakeAt == stakeAt);
assert(delegatorData.slashIndex == slashIndex);
Expand Down
Loading