feat: add Teleportr service#2233
Conversation
🦋 Changeset detectedLatest commit: 2910a3c The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Codecov Report
@@ Coverage Diff @@
## develop #2233 +/- ##
========================================
Coverage 73.04% 73.04%
========================================
Files 86 86
Lines 2846 2846
Branches 486 486
========================================
Hits 2079 2079
Misses 767 767
Flags with carried forward coverage won't be shown. Click here to find out more. Continue to review full report at Codecov.
|
8841d49 to
3fd27ab
Compare
| "blockNumber", receipt.BlockNumber, | ||
| "blockTimestamp", blockTimestamp) | ||
|
|
||
| err = d.cfg.Database.UpsertDisbursement( |
There was a problem hiding this comment.
If a disbursement fails to be marked as successful, what happens?
There was a problem hiding this comment.
it would show up in the db as confirmed but not disbursed, and would require manual intervention to add the disbursement. the best way to get around this IMO is to add a database that tracks txhash => (startId, endId) and then we can recover after startups or in GetBatchBlockRange. this is a little more involved though, as we would need a call back from within the txmgr before it publishes, but it's definitely the safer route
There was a problem hiding this comment.
ah, actually we can just do the tracking in the SendTransaction iface method 😎
| // are missing a disbursement for this deposit even though the contract | ||
| // beleves it was disbursed. | ||
| case deposit.ID < startID: | ||
| log.Warn("Filtering deposit with missing disbursement", |
There was a problem hiding this comment.
Should have a metric for this as well.
| // provided URL. If the dial doesn't complete within dial.DefaultTimeout seconds, | ||
| // this method will return an error. | ||
| func L2EthClientWithTimeout(ctx context.Context, url string, disableHTTP2 bool) ( | ||
| func DialL2EthClientWithTimeout(ctx context.Context, url string, disableHTTP2 bool) ( |
There was a problem hiding this comment.
Is there any reason as to why we are using the l2geth deps here? I feel like we could use the upstream stuff for things like rpc or utils, especially now that the http2 fix is in: 6f2ea19
There was a problem hiding this comment.
yes, upstream doesn't expose the L2 metadata https://github.com/ethereum-optimism/optimism/blob/develop/go/batch-submitter/drivers/sequencer/batch.go#L53L54
There was a problem hiding this comment.
fwiw we do use upstream for L2 in this driver since we don't need to access any non-standard info
| // stateRootSize is the size in bytes of a state root. | ||
| const stateRootSize = 32 | ||
|
|
||
| var bigOne = new(big.Int).SetUint64(1) //nolint:unused |
There was a problem hiding this comment.
Did you mean to leave this even though its unused?
There was a problem hiding this comment.
good catch, was left over from copying in from the BSS driver as a template.
| BlockNumber: event.Raw.BlockNumber, | ||
| BlockTimestamp: time.Unix(int64(header.Time), 0), | ||
| Address: event.Emitter, | ||
| Amount: event.Amount, |
There was a problem hiding this comment.
There have been hacks in the past where a bridge uses tx.Value instead of a value emitted from an event which could cause problems if the tx calls a loop, it would count the value multiple times. I believe we are safe from this kind of attack but perhaps its good to add a unit test to the contract tests before this goes into production
ops/docker-compose.yml
Outdated
| ENABLE_GAS_REPORT: 1 | ||
| NO_NETWORK: 1 | ||
|
|
||
| teleportr_postgres: |
There was a problem hiding this comment.
Are you planning on adding integration tests for teleportr? Eventually the docker compose setup will become unwieldy for local development using too many resources and we don't have a good way to define sets of integration tests that bring up parts of the stack to specifically test. I think adding teleportr is fine now fwiw
There was a problem hiding this comment.
Oh I see that teleportr has replicas: 0 but the postgres does not
There was a problem hiding this comment.
good catch, yes i'm planning to add itests but will do so in a follow up. this pr will just have the bulk of the teleportr service
3fd27ab to
abb86d2
Compare
This avoids having l2geth as a dependency for other projects building on bss-core. Speicifically this avoids having to copy l2geth into docker builds.
Less casting.
Currently the teleportr database supports a LatestDeposit method, which returns the highest block number observed, if any. The intent was to use this as the starting point for syncing, however, this isn't super useful as there may be long periods of inactivity that we have already scanned. Instead, we now store the last processed block in a separate table, and pass the end of the ingestion block range as argument to UpsertDeposits. The list of deposits and last processed block are written atomically to avoid consistency issues. The value can be retrieved using the LastProcessedBlock getter.
51a677f to
04405d4
Compare
04405d4 to
3017f2a
Compare
|
Pushed a small change to record success/failures for every database operation |
3017f2a to
1480c92
Compare
1480c92 to
2910a3c
Compare
## Overview Small cleanup to the `RollupNodeService::start` function. --------- Co-authored-by: refcell <abigger87@gmail.com>
Description
This PR adds the Teleportr service implemented as a
bss-coredriver. The general principal is the same the batch submitter, except here we are pulling data from L1 and posting to L2. There are however some notable differences:Driver.GetBatchBlockRange, and overwrites deposits with the same deposit ID to handle reorgs up to theNumDepositConfirmationswindow.EstimateGasinside theDriver.UpdateGasPricecallback to set a proper L2 fee rate. Note that this also differs from the prior approach where the fees were linearly scaled between a min and max configuration. This eliminates the need for adding the additional configuration arguments and needing to further modify the bss-core interface to support the old methodology, seeing as we can start using EIP-1559 for Teleportr L2 txs in the near future.ClearPendingTxssince L2Geth doesn't have a mempool where prior transactions can be stuck.TODO:
Figure out how to deploy Teleportr contracts on itests and address manager(bumped to follow up)Add itests(bumped to followup)Blocked by:
Metadata