From 7a2097938691293cc5caf3d09a935163544bab4b Mon Sep 17 00:00:00 2001 From: Gustavo Gama Date: Sat, 1 Feb 2025 02:28:18 -0300 Subject: [PATCH] fix: add 30s timeout to context used to execute operations onchain 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. --- pkg/timelock/operations.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/timelock/operations.go b/pkg/timelock/operations.go index e30c826..a4c57a3 100644 --- a/pkg/timelock/operations.go +++ b/pkg/timelock/operations.go @@ -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" @@ -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)