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

Incorporate second round of feedback from lightblocks #12

Merged
merged 3 commits into from
Feb 15, 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
18 changes: 13 additions & 5 deletions avssync.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func NewAvsSync(

func (a *AvsSync) Start() {
a.logger.Infof("Starting avs sync with sleepBeforeFirstSyncDuration=%s, syncInterval=%s, operators=%v, quorums=%v, fetchQuorumsDynamically=%v, readerTimeoutDuration=%s, writerTimeoutDuration=%s",
a.sleepBeforeFirstSyncDuration, a.syncInterval, a.operators, a.quorums, a.fetchQuorumsDynamically, a.readerTimeoutDuration, a.writerTimeoutDuration)
a.sleepBeforeFirstSyncDuration, a.syncInterval, a.operators, convertQuorumsBytesToInts(a.quorums), a.fetchQuorumsDynamically, a.readerTimeoutDuration, a.writerTimeoutDuration)

// ticker doesn't tick immediately, so we send a first updateStakes here
// see https://github.com/golang/go/issues/17601
Expand Down Expand Up @@ -91,7 +91,7 @@ func (a *AvsSync) updateStakes() error {
if len(a.operators) == 0 {
a.logger.Info("Updating stakes of entire operator set")
a.maybeUpdateQuorumSet()
a.logger.Infof("Current quorum set: %v", a.quorums)
a.logger.Infof("Current quorum set: %v", convertQuorumsBytesToInts(a.quorums))

// we update one quorum at a time, just to make sure we don't run into any gas limit issues
// in case there are a lot of operators in a given quorum
Expand Down Expand Up @@ -135,7 +135,7 @@ func (a *AvsSync) maybeUpdateQuorumSet() {

func (a *AvsSync) tryNTimesUpdateStakesOfEntireOperatorSetForQuorum(quorum byte, retryNTimes int) {
for i := 0; i < retryNTimes; i++ {
a.logger.Debug("tryNTimesUpdateStakesOfEntireOperatorSetForQuorum", "quorum", quorum, "retryNTimes", retryNTimes, "try", i+1)
a.logger.Debug("tryNTimesUpdateStakesOfEntireOperatorSetForQuorum", "quorum", int(quorum), "retryNTimes", retryNTimes, "try", i+1)

timeoutCtx, cancel := context.WithTimeout(context.Background(), a.readerTimeoutDuration)
defer cancel()
Expand All @@ -149,15 +149,23 @@ func (a *AvsSync) tryNTimesUpdateStakesOfEntireOperatorSetForQuorum(quorum byte,
sort.Slice(operators, func(i, j int) bool {
return operators[i].Big().Cmp(operators[j].Big()) < 0
})
a.logger.Infof("Updating stakes of operators in quorum %d: %v", quorum, operators)
a.logger.Infof("Updating stakes of operators in quorum %d: %v", int(quorum), operators)
timeoutCtx, cancel = context.WithTimeout(context.Background(), a.writerTimeoutDuration)
defer cancel()
_, err = a.avsWriter.UpdateStakesOfEntireOperatorSetForQuorums(timeoutCtx, [][]common.Address{operators}, []byte{quorum})
if err != nil {
a.logger.Error("Error updating stakes of entire operator set for quorum", "err", err, "quorum", quorum)
a.logger.Error("Error updating stakes of entire operator set for quorum", "err", err, "quorum", int(quorum))
continue
}
return
}
a.logger.Error("Giving up after retrying", "retryNTimes", retryNTimes)
}

func convertQuorumsBytesToInts(quorums []byte) []int {
var quorumsInts []int
for _, quorum := range quorums {
quorumsInts = append(quorumsInts, int(quorum))
}
return quorumsInts
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/Layr-Labs/avs-sync
go 1.21.2

require (
github.com/Layr-Labs/eigensdk-go v0.1.1-0.20240207213853-8a666597e0f1
github.com/Layr-Labs/eigensdk-go v0.1.1
github.com/ethereum/go-ethereum v1.13.12
github.com/testcontainers/testcontainers-go v0.26.0
github.com/urfave/cli v1.22.14
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03
github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
github.com/DataDog/zstd v1.4.5 h1:EndNeuB0l9syBZhut0wns3gV1hL8zX8LIu6ZiVHWLIQ=
github.com/DataDog/zstd v1.4.5/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo=
github.com/Layr-Labs/eigensdk-go v0.1.1-0.20240207213853-8a666597e0f1 h1:OKkL+wllNIELDSgYr6mJQZKZ/H7lH40Szk6ZpdQmjLE=
github.com/Layr-Labs/eigensdk-go v0.1.1-0.20240207213853-8a666597e0f1/go.mod h1:H+IrmttU+eytGEblC7J9gmvBV425UcPPvEVO4JkHALE=
github.com/Layr-Labs/eigensdk-go v0.1.1 h1:AjUoieoAtaGxuxOHj6nB2xxuBTrghlYJl3AguICI9kc=
github.com/Layr-Labs/eigensdk-go v0.1.1/go.mod h1:c/yA0hmP2pJILySQLerQnDPcJ5Z3mtyH0hhjQGw3Xrc=
github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow=
github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM=
github.com/Microsoft/hcsshim v0.11.4 h1:68vKo2VN8DE9AdN4tnkWnmdhqdbpUFM8OF3Airm7fz8=
Expand Down
1 change: 1 addition & 0 deletions integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,7 @@ func depositErc20IntoStrategyForOperator(
txMgr := txmgr.NewSimpleTxManager(ethHttpClient, logger, signerFn, ecdsaAddr)
elWriter, err := elcontracts.BuildELChainWriter(
delegationManagerAddr,
common.Address{}, // avsDirectory not needed so we just pass an empty address
ethHttpClient,
logger,
noopMetrics,
Expand Down

Large diffs are not rendered by default.

Loading