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

feat(opsim): create depositTx subscriber #45

Merged
merged 1 commit into from
Jul 15, 2024

Conversation

jakim929
Copy link
Contributor

@jakim929 jakim929 commented Jul 11, 2024

  • SubscribeDepositTx creates a subscription to depositTransactions given a chain api and the deposit contract address. under the hood it transforms the event log subscription
  • adds chainapi package, which is the interface that chains should expose to opsim
  • adds some testutils MockChain which can be overridden with methods for testing

this is not used anywhere right now, but will be used in a separate PR once we figure out how to get bridge contracts deployed on the L1

it will be used like below


func (opSim *OpSimulator) StartDepositProcessor(ctx context.Context) error {
	depositTxCh := make(chan *types.DepositTx)

	sub, err := SubscribeDepositTx(ctx, opSim.l1Chain, depositContractAddr, depositTxCh)

	if err != nil {
		return fmt.Errorf("failed to start deposit processor: %w", err)
	}

	go func() {
		for {
			select {
			case dep := <-depositTxCh:
				if err := opSim.l2Chain.EthSendTransaction(ctx, types.NewTx(dep)); err != nil {
					opSim.log.Error("failed to submit deposit tx: %w", err)
				}
			case <-ctx.Done():
				sub.Unsubscribe()
				close(depositTxCh)
				return
			}
		}
	}()

	return nil
}

@jakim929
Copy link
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @jakim929 and the rest of your teammates on Graphite Graphite

@jakim929 jakim929 force-pushed the 07-11-feat_opsim_handle_deposit_transactions branch 3 times, most recently from 59f7f36 to 72c59f1 Compare July 12, 2024 15:11
@jakim929 jakim929 changed the title feat(opsim): handle deposit transactions feat(opsim): create depositTx listener Jul 12, 2024
@jakim929 jakim929 changed the title feat(opsim): create depositTx listener feat(opsim): create depositTx subscriber Jul 12, 2024
@jakim929 jakim929 force-pushed the 07-11-feat_opsim_handle_deposit_transactions branch from 72c59f1 to 431eb31 Compare July 12, 2024 15:17
@jakim929 jakim929 marked this pull request as ready for review July 12, 2024 15:19
@jakim929 jakim929 requested a review from a team as a code owner July 12, 2024 15:19
@jakim929 jakim929 force-pushed the 07-11-feat_opsim_handle_deposit_transactions branch 3 times, most recently from 2fe00da to 34a5dd5 Compare July 12, 2024 16:46
Copy link
Contributor

@tremarkley tremarkley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this all looks great to me, but I would probably wait on a review from @nitaliano or @hamdiallam before merging

opsimulator/deposits.go Outdated Show resolved Hide resolved
@jakim929 jakim929 force-pushed the 07-11-feat_opsim_handle_deposit_transactions branch 2 times, most recently from 1cd7fad to 2cb7605 Compare July 15, 2024 15:14
@jakim929 jakim929 requested review from hamdiallam and nitaliano July 15, 2024 17:18
anvil/anvil.go Outdated Show resolved Hide resolved
Copy link
Contributor

@nitaliano nitaliano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice!

@jakim929 jakim929 force-pushed the 07-11-feat_opsim_handle_deposit_transactions branch 2 times, most recently from 73c6076 to b737d0a Compare July 15, 2024 21:14
@jakim929 jakim929 force-pushed the 07-11-feat_opsim_handle_deposit_transactions branch from b737d0a to 0af1aa3 Compare July 15, 2024 21:16
@jakim929 jakim929 merged commit 13f6a3e into main Jul 15, 2024
3 checks passed
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

Successfully merging this pull request may close these issues.

3 participants