-
Notifications
You must be signed in to change notification settings - Fork 33
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
Fix anvil behavior in CI #1955
Comments
To fix the anvil behavior in CI, modify the func WaitForConfirmation(ctx context.Context, client ConfirmationClient, transaction *types.Transaction, timeout time.Duration) {
// if tx is nil , we should panic here so we can see the call context
_ = transaction.Hash()
const debugTimeout = time.Second * 5
start := time.Now()
logIfShould := func(locker *sync.Once, template string, args ...interface{}) {
if time.Since(start) > debugTimeout {
locker.Do(func() {
logger.Debugf(template, args...)
})
}
}
txConfirmedCtx, cancel := context.WithCancel(ctx)
var logWaitOnce, logFetchErrOnce, logErrOnce sync.Once
wait.UntilWithContext(txConfirmedCtx, func(ctx context.Context) {
tx, isPending, err := client.TransactionByHash(txConfirmedCtx, transaction.Hash())
logIfShould(&logWaitOnce, "waiting for tx %s", transaction.Hash())
// Log the state of the transaction
logger.Infof("Transaction state: isPending=%v, err=%v", isPending, err)
if err != nil && !errors.Is(err, ethereum.NotFound) {
receipt, receiptErr := client.TransactionReceipt(ctx, transaction.Hash())
if err != nil {
err = multierror.Append(err, receiptErr)
}
if receipt != nil {
if receipt.Status == types.ReceiptStatusFailed {
rawJSON, _ := transaction.MarshalJSON()
logger.Errorf("transaction %s with body %s reverted", transaction, string(rawJSON))
}
cancel()
return
}
}
if err != nil {
logIfShould(&logFetchErrOnce, "could not fetch transaction: %v", err)
}
if !isPending && tx != nil {
receipt, err := client.TransactionReceipt(ctx, tx.Hash())
if err != nil {
if receipt.Status == types.ReceiptStatusFailed {
rawJSON, _ := transaction.MarshalJSON()
logger.Errorf("transaction %s with body %s reverted", transaction, string(rawJSON))
}
}
cancel()
} else if !isPending || time.Since(start) > debugTimeout {
err := client.SendTransaction(ctx, transaction)
if err != nil {
ogErr := err
call, err := util.TxToCall(transaction)
if err != nil {
logger.Errorf("could not convert tx to call: %v", err)
return
}
realNonce, err := client.NonceAt(ctx, call.From, nil)
if err != nil {
logger.Errorf("could not get nonce: %v", err)
return
}
logIfShould(&logErrOnce, "could not send transaction (from %s, account nonce %d, tx nonce: %d, tx hash: %s): %v", call.From, realNonce, transaction.Nonce(), transaction.Hash(), ogErr)
}
}
}, timeout)
} This will help identify where the process is hanging by providing more detailed logs. Additionally, ensure that the CI environment has the necessary resources and configurations to run the tests reliably. References/ethergo/backends/anvil/anvil.go |
Currently the RFQ
TestIntegrationSuite
tests work locally, but do not work in CI. After inspecting the runtime with upterm it seems that anvil hangs on the base implementation forWaitForConfirmation
- need to figure out why this is.The text was updated successfully, but these errors were encountered: