Skip to content

Commit

Permalink
fix: add 30s timeout to context used to execute operations onchain (#132
Browse files Browse the repository at this point in the history
)

Previously, when executing an operation, the timelock-worker called
`bind.WaitMinted` with a context without an associated timeout. This
meant that when there was a problem with the RPC or the network itself,
the executer goroutine would get stuck waiting indefinitely for the call
to return. And because all operations are called sequentially, the
timelock effectively stopped working.

With the added timeout, the context aborts the network call and the
operation fails. The internal logic of the scheduler will take care of
retrying a few minutes later.
  • Loading branch information
gustavogama-cll authored Feb 4, 2025
1 parent cab80c2 commit 895c0e4
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/timelock/operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"crypto/ecdsa"
"fmt"
"math/big"
"time"

"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
Expand All @@ -20,6 +21,9 @@ import (
// - The operation is ready to be executed
// Otherwise the operation will throw an info log and wait for a future tick.
func (tw *Worker) execute(ctx context.Context, op []*contracts.RBACTimelockCallScheduled) {
ctx, cancel := context.WithTimeout(ctx, 30*time.Second)
defer cancel()

if isReady(ctx, tw.contract, op[0].Id) {
tw.logger.Debugf("execute operation %x", op[0].Id)

Expand Down

0 comments on commit 895c0e4

Please sign in to comment.