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

The function of **ProcessPendingMonitoredTxs** maybe have a bug in some chance #81

Open
lyh169 opened this issue Oct 9, 2024 · 0 comments

Comments

@lyh169
Copy link

lyh169 commented Oct 9, 2024

System information

cdk-erigon version: v2.0.0-beta17
OS & Version: Linux & v0.0.9

Expected behaviour

I think the function of ProcessPendingMonitoredTxs have a issue in some chance, because only when result.Status == types.MonitoredTxStatusMined || result.Status == types.MonitoredTxStatusFailed , it will break, in other case it will halt to waiting tx.
It should

if result.Status == types.MonitoredTxStatusMined || result.Status == types.MonitoredTxStatusFailed ||
      result.Status == MonitoredTxStatusSafe || result.Status == MonitoredTxStatusFinalized {
      break
}

I run the node the logs as follow, when the tx is mined and safe , but the waiting for monitored tx is only support types.MonitoredTxStatusMined and types.MonitoredTxStatusFailed, but no hvae safe, so it will waiting tx long times.

2024-10-09T11:07:17.347+0800	INFO	ethtxmanager/ethtxmanager.go:750	mined	{"pid": 26882, "monitoredTxId": "0x0ea6203a3b062d8bb277495770ad86560349445fed88ce5bd77a7eb8e8e8b65e", "createdAt": "2024-10-09T11:07:15.738+0800", "from": "0x70997970C51812dc3A010C7d01b50e0d17dc79C8", "to": "0xB7f8BC63BbcaD18155201308C8f3540b07f84F5e"}
2024-10-09T11:07:17.347+0800	INFO	ethtxmanager/ethtxmanager.go:520	safe	{"pid": 26882, "monitoredTxId": "0x0ea6203a3b062d8bb277495770ad86560349445fed88ce5bd77a7eb8e8e8b65e", "createdAt": "2024-10-09T11:07:15.738+0800", "from": "0x70997970C51812dc3A010C7d01b50e0d17dc79C8", "to": "0xB7f8BC63BbcaD18155201308C8f3540b07f84F5e"}
2024-10-09T11:07:17.745+0800	INFO	ethtxmanager/ethtxmanager.go:1010	waiting for monitored tx to get confirmed, status: safe	{"pid": 26882, "monitoredTxId": "0x0ea6203a3b062d8bb277495770ad86560349445fed88ce5bd77a7eb8e8e8b65e"}
2024-10-09T11:07:18.748+0800	INFO	ethtxmanager/ethtxmanager.go:1010	waiting for monitored tx to get confirmed, status: safe	{"pid": 26882, "monitoredTxId": "0x0ea6203a3b062d8bb277495770ad86560349445fed88ce5bd77a7eb8e8e8b65e"}
2024-10-09T11:07:19.233+0800	INFO	l1_sync/l1_syncer_sequential.go:150	Syncing FromBlock: 19308, ToBlock: 19380, MaximumBlock: 19380 Progress: Percent: 99.6	{"pid": 26882}
func (c *Client) ProcessPendingMonitoredTxs(ctx context.Context, resultHandler ResultHandler) {
	statusesFilter := []types.MonitoredTxStatus{
		types.MonitoredTxStatusCreated,
		types.MonitoredTxStatusSent,
		types.MonitoredTxStatusFailed,
		types.MonitoredTxStatusMined,
	}
	// keep running until there are pending monitored txs
	for {
                .........
		for _, result := range results {
			mTxResultLogger := CreateMonitoredTxResultLogger(result)
                      .........

			// if the result is either not confirmed or failed, it means we need to wait until it gets confirmed of failed.
			for {
				// wait before refreshing the result info
				time.Sleep(time.Second)

				// refresh the result info
				result, err := c.Result(ctx, result.ID)
				if err != nil {
					mTxResultLogger.Errorf("failed to get monitored tx result, err: %v", err)
					continue
				}

				// if the result status is confirmed or failed, breaks the wait loop
				if result.Status == types.MonitoredTxStatusMined || result.Status == types.MonitoredTxStatusFailed ||
                                      result.Status == MonitoredTxStatusSafe || result.Status == MonitoredTxStatusFinalized {
					break
				}

				mTxResultLogger.Infof("waiting for monitored tx to get confirmed, status: %v", result.Status.String())
			}
		}
	}
}

Actual behaviour

func (c *Client) ProcessPendingMonitoredTxs(ctx context.Context, resultHandler ResultHandler) {
	statusesFilter := []types.MonitoredTxStatus{
		types.MonitoredTxStatusCreated,
		types.MonitoredTxStatusSent,
		types.MonitoredTxStatusFailed,
		types.MonitoredTxStatusMined,
	}
	// keep running until there are pending monitored txs
	for {
                .........
		for _, result := range results {
			mTxResultLogger := CreateMonitoredTxResultLogger(result)
                      .........

			// if the result is either not confirmed or failed, it means we need to wait until it gets confirmed of failed.
			for {
				// wait before refreshing the result info
				time.Sleep(time.Second)

				// refresh the result info
				result, err := c.Result(ctx, result.ID)
				if err != nil {
					mTxResultLogger.Errorf("failed to get monitored tx result, err: %v", err)
					continue
				}

				// if the result status is confirmed or failed, breaks the wait loop
				if result.Status == types.MonitoredTxStatusMined || result.Status == types.MonitoredTxStatusFailed {
					break
				}

				mTxResultLogger.Infof("waiting for monitored tx to get confirmed, status: %v", result.Status.String())
			}
		}
	}
}

Steps to reproduce the behaviour

Backtrace

[backtrace]

When submitting logs: please submit them as text and not screenshots.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant