Skip to content

Commit 2f09d44

Browse files
committed
Fix packing bytes
1 parent 915e15f commit 2f09d44

1 file changed

Lines changed: 24 additions & 3 deletions

File tree

rocketpool/watchtower/submit-rewards-tree-stateless.go

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"sync"
1212
"time"
1313

14+
"github.com/ethereum/go-ethereum/accounts/abi"
1415
"github.com/ethereum/go-ethereum/accounts/abi/bind"
1516
"github.com/ethereum/go-ethereum/common"
1617
"github.com/ethereum/go-ethereum/core/types"
@@ -508,7 +509,27 @@ func (t *submitRewardsTree_Stateless) getSnapshotEnd(endTime time.Time, state *s
508509

509510
// Check whether the rewards tree for the current interval been submitted by the node
510511
func (t *submitRewardsTree_Stateless) hasSubmittedTree(nodeAddress common.Address, index *big.Int) (bool, error) {
511-
indexBuffer := make([]byte, 32)
512-
index.FillBytes(indexBuffer)
513-
return t.rp.RocketStorage.GetBool(nil, crypto.Keccak256Hash([]byte("rewards.snapshot.submitted.node"), nodeAddress.Bytes(), indexBuffer))
512+
stringArgument, err := abi.NewType("string", "string", nil)
513+
if err != nil {
514+
return false, err
515+
}
516+
addressArgument, err := abi.NewType("address", "address", nil)
517+
if err != nil {
518+
return false, err
519+
}
520+
uint256Argument, err := abi.NewType("uint256", "uint256", nil)
521+
if err != nil {
522+
return false, err
523+
}
524+
525+
arguments := abi.Arguments{
526+
{Type: stringArgument}, {Type: addressArgument}, {Type: uint256Argument},
527+
}
528+
529+
packedBytes, err := arguments.Pack("rewards.snapshot.submitted.node", nodeAddress, index)
530+
if err != nil {
531+
return false, err
532+
}
533+
534+
return t.rp.RocketStorage.GetBool(nil, crypto.Keccak256Hash(packedBytes))
514535
}

0 commit comments

Comments
 (0)