Engine v2 is now available

Phillip Ho

All new Engine deployments from the thirdweb dashboard will be on v2.

For existing cloud-hosted Engines, please request a version upgrade in the dashboard. (We're making upgrades self-service very soon!)

What's new?

The worker architecture in Engine v2 was redesigned with maximum onchain throughput in mind. Users should see:

  • Higher onchain throughput: Batches of transactions for a single backend wallet are now fully parallelized. The entire batch will often be sent in the next block, resulting in up to 700x more transactions sent per second, depending on the chain.
  • Lower time to send: Slow polling and DB locks are removed. Transactions are processed from the queue as soon as they arrive, resulting in a median of 300ms from Engine receiving a transaction to sending it.

Benchmarks

Engine v2 is capable of sending hundreds of transactions per second to a chain's RPC. However the total transactions from a single wallet that a block will accept depends on the chain. Here are some numbers we've seen on a single 1 vCPU / 1 GB memory host:

  • B3 testnet: 1500 txs per block
  • Base testnet: 65 txs per block
  • Polygon testnet: 85 txs per block
  • Arbitrum testnet: 100 txs per block

Note: transactions mined per second ~= # transactions per a block / block time

Any breaking changes?

Publicly documented interfaces have no breaking changes. There is no expected changes required from users.

How we got here

Engine development started 1.5 years ago to power onchain transactions internal to thirdweb. After chatting with other teams, we recognized most teams were spending engineering weeks solving similar problems. Engine was open-sourced in Q2 2023 and we've been iterating on it since.

Engine v1 was designed to send batches of transactions without waiting for previous ones to be mined. This already introduced a lot of challenges around nonce management (see Sending more than one transaction at a time is easy, right?). We've since uncovered dozens of edge cases from internal testing and customer reports across a multitude of chains, contract types, and use cases.

As Engine expanded in scope, so did web3 use cases. We started seeing apps and games use Engine in ways that demanded higher throughput and lower latency. We looked at bottlenecks: DB locks, short polling, batching logic, coupling of dependencies. Leveraging learnings in the past year, we started on v2 to address these bottlenecks.

Engine v2 moves performance-critical and atomic operations from Postgres to Redis queues. This change allows for faster reads and writes to DB leading to less blocking behavior, lower latency, and fewer scaling issues. The code is better organized, typesafe, and built on the thirdweb v5 SDK (which comes with added performance gains).

In v2 transactions no longer block on RPC responses, saving 50-200ms per transaction (very noticeable at scale!). While this change introduced even more nonce edge cases to handle, the performance tradeoff is worth it. Engine v2 employs multiple patterns and workers to track and self-heal nonces.

What's next

We feel confident Engine v2 handles the throughput needs of the vast majority of web3 use cases today.

The next challenge is to improve observability and debuggability around queues and transactions. We plan to expose API metrics, queue latency metrics, realtime nonce details, transaction logs, and more. Our roadmap also includes options to replay failed transactions, reset nonces, and more.

Keep your eyes peeled on the Engine dashboard for updates as we roll them out!


thirdweb is hiring!

The small team at thirdweb is on a mission to build the most intuitive and complete web3 platform. Our products empower over 70,000 developers each month including Shopify, AWS, Coinbase, Rarible, Animoca Brands, and InfiniGods.

See our open roles. We’d love to work with you!