Skip to content

Commit 12a4c59

Browse files
authored
Merge pull request #993 from rocket-pool/edge-case-find-event
Fix edge case when finding rewards events
2 parents 67c81b6 + 3febfe7 commit 12a4c59

3 files changed

Lines changed: 7 additions & 5 deletions

File tree

shared/services/rewards/generator-impl-v11.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,10 +220,11 @@ func (r *treeGeneratorImpl_v11) generateTree(rp RewardsExecutionClient, networkN
220220

221221
// Quickly calculates an approximate of the staker's share of the smoothing pool balance without processing Beacon performance
222222
// Used for approximate returns in the rETH ratio update
223-
func (r *treeGeneratorImpl_v11) approximateStakerShareOfSmoothingPool(rp RewardsExecutionClient, networkName string, bc RewardsBeaconClient) (*big.Int, error) {
223+
func (r *treeGeneratorImpl_v11) approximateStakerShareOfSmoothingPool(rp RewardsExecutionClient, networkName string, previousRewardsPoolAddresses []common.Address, bc RewardsBeaconClient) (*big.Int, error) {
224224
r.log.Printlnf("%s Approximating tree using Ruleset v%d.", r.logPrefix, r.rewardsFile.RulesetVersion)
225225

226226
r.rp = rp
227+
r.previousRewardsPoolAddresses = previousRewardsPoolAddresses
227228
r.bc = bc
228229
r.validNetworkCache = map[uint64]bool{
229230
0: true,

shared/services/rewards/generator-impl-v9-v10.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,10 +192,11 @@ func (r *treeGeneratorImpl_v9_v10) generateTree(rp RewardsExecutionClient, netwo
192192

193193
// Quickly calculates an approximate of the staker's share of the smoothing pool balance without processing Beacon performance
194194
// Used for approximate returns in the rETH ratio update
195-
func (r *treeGeneratorImpl_v9_v10) approximateStakerShareOfSmoothingPool(rp RewardsExecutionClient, networkName string, bc RewardsBeaconClient) (*big.Int, error) {
195+
func (r *treeGeneratorImpl_v9_v10) approximateStakerShareOfSmoothingPool(rp RewardsExecutionClient, networkName string, previousRewardsPoolAddresses []common.Address, bc RewardsBeaconClient) (*big.Int, error) {
196196
r.log.Printlnf("%s Approximating tree using Ruleset v%d.", r.logPrefix, r.rewardsFile.RulesetVersion)
197197

198198
r.rp = rp
199+
r.previousRewardsPoolAddresses = previousRewardsPoolAddresses
199200
r.bc = bc
200201
r.validNetworkCache = map[uint64]bool{
201202
0: true,

shared/services/rewards/generator.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ type SnapshotEnd struct {
107107

108108
type treeGeneratorImpl interface {
109109
generateTree(rp RewardsExecutionClient, networkName string, previousRewardsPoolAddresses []common.Address, bc RewardsBeaconClient) (*GenerateTreeResult, error)
110-
approximateStakerShareOfSmoothingPool(rp RewardsExecutionClient, networkName string, bc RewardsBeaconClient) (*big.Int, error)
110+
approximateStakerShareOfSmoothingPool(rp RewardsExecutionClient, networkName string, previousRewardsPoolAddresses []common.Address, bc RewardsBeaconClient) (*big.Int, error)
111111
getRulesetVersion() uint64
112112
// Returns the primary artifact cid for consensus, all cids of all files in a map, and any potential errors
113113
saveFiles(smartnode *config.SmartnodeConfig, treeResult *GenerateTreeResult, nodeTrusted bool) (cid.Cid, map[string]cid.Cid, error)
@@ -239,7 +239,7 @@ func (t *TreeGenerator) GenerateTree() (*GenerateTreeResult, error) {
239239
}
240240

241241
func (t *TreeGenerator) ApproximateStakerShareOfSmoothingPool() (*big.Int, error) {
242-
return t.approximatorImpl.approximateStakerShareOfSmoothingPool(t.rp, fmt.Sprint(t.cfg.Smartnode.Network.Value), t.bc)
242+
return t.approximatorImpl.approximateStakerShareOfSmoothingPool(t.rp, fmt.Sprint(t.cfg.Smartnode.Network.Value), t.cfg.Smartnode.GetPreviousRewardsPoolAddresses(), t.bc)
243243
}
244244

245245
func (t *TreeGenerator) GetGeneratorRulesetVersion() uint64 {
@@ -270,7 +270,7 @@ func (t *TreeGenerator) ApproximateStakerShareOfSmoothingPoolWithRuleset(ruleset
270270
return nil, fmt.Errorf("ruleset v%d does not exist", ruleset)
271271
}
272272

273-
return info.generator.approximateStakerShareOfSmoothingPool(t.rp, fmt.Sprint(t.cfg.Smartnode.Network.Value), t.bc)
273+
return info.generator.approximateStakerShareOfSmoothingPool(t.rp, fmt.Sprint(t.cfg.Smartnode.Network.Value), t.cfg.Smartnode.GetPreviousRewardsPoolAddresses(), t.bc)
274274
}
275275

276276
func (t *TreeGenerator) SaveFiles(treeResult *GenerateTreeResult, nodeTrusted bool) (cid.Cid, map[string]cid.Cid, error) {

0 commit comments

Comments
 (0)