Skip to content

Commit 8f68e87

Browse files
committed
add events for slashing node rewards
1 parent 9d75a95 commit 8f68e87

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

contracts/FlowIDTableStaking.cdc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ access(all) contract FlowIDTableStaking {
3838
/// Epoch
3939
access(all) event NewEpoch(totalStaked: UFix64, totalRewardPayout: UFix64, newEpochCounter: UInt64)
4040
access(all) event EpochTotalRewardsPaid(total: UFix64, fromFees: UFix64, minted: UFix64, feesBurned: UFix64, epochCounterForRewards: UInt64)
41+
access(all) event NodeRewardsSetToSlash(nodeSlashPercentages: {String: UFix64})
4142

4243
/// Node
4344
access(all) event NewNodeCreated(nodeID: String, role: UInt8, amountCommitted: UFix64)
@@ -52,6 +53,7 @@ access(all) contract FlowIDTableStaking {
5253
access(all) event RewardTokensWithdrawn(nodeID: String, amount: UFix64)
5354
access(all) event NetworkingAddressUpdated(nodeID: String, newAddress: String)
5455
access(all) event NodeWeightChanged(nodeID: String, newWeight: UInt64)
56+
access(all) event NodeRewardsSlashed(nodeID: String, percentageSlashed: UFix64)
5557

5658
/// Delegator
5759
access(all) event NewDelegatorCreated(nodeID: String, delegatorID: UInt32)
@@ -945,6 +947,8 @@ access(all) contract FlowIDTableStaking {
945947
message: "Percentage value to decrease rewards payout should be between 0 and 1"
946948
)
947949
}
950+
951+
emit NodeRewardsSetToSlash(nodeSlashPercentages: nodeIDs)
948952
FlowIDTableStaking.account.storage.load<{String: UFix64}>(from: /storage/idTableNonOperationalNodesList)
949953
FlowIDTableStaking.account.storage.save<{String: UFix64}>(nodeIDs, to: /storage/idTableNonOperationalNodesList)
950954
}
@@ -1338,6 +1342,8 @@ access(all) contract FlowIDTableStaking {
13381342
// Its delegator's rewards are also decreased to the same percentage
13391343
let rewardDecreaseToPercentage = nonOperationalNodes[nodeID]!
13401344

1345+
emit NodeRewardsSlashed(nodeID: nodeID, percentageSlashed: 1.0 - rewardDecreaseToPercentage)
1346+
13411347
sumStakeFromNonOperationalStakers = sumStakeFromNonOperationalStakers + nodeRecord.tokensStaked.balance
13421348

13431349
// Calculate the normal reward amount, then the rewards left after the decrease

lib/go/contracts/internal/assets/assets.go

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)