Conversation
🦋 Changeset detectedLatest commit: 9a26456 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 |
packages/batch-submitter/src/batch-submitter/batch-submitter.ts
Outdated
Show resolved
Hide resolved
packages/batch-submitter/src/batch-submitter/batch-submitter.ts
Outdated
Show resolved
Hide resolved
packages/batch-submitter/src/batch-submitter/batch-submitter.ts
Outdated
Show resolved
Hide resolved
packages/batch-submitter/src/batch-submitter/batch-submitter.ts
Outdated
Show resolved
Hide resolved
| if (!wasBatchTruncated && !this._shouldSubmitBatch(batchSizeInBytes)) { | ||
| return | ||
| } | ||
| this.bsMetrics.numTxPerBatch.observe(endBlock - startBlock) |
There was a problem hiding this comment.
Shouldn't this only be getting measured after the batch is successfully appended?
There was a problem hiding this comment.
that was my original plan, but when we get the transaction receipt we no longer have access to the endBlock and startBlock variables.
passing it through seems heavy for observing this value, and so did using the abi to parse the logs from the receipt. adding this here felt like a decent tradeoff since at this point logically we should be submitting the batch. let me know if you think differently though!
There was a problem hiding this comment.
Given that we have seen many errors related to submission of batches, I worry this will give us false data.
Couldn't this be on line 265?
There was a problem hiding this comment.
^that function may be called multiple times to retry for gas and thus also push the metric multiple times; i'll look into retrieving this value from the logs or elsewhere
There was a problem hiding this comment.
We could check for the receipt, have an in-memory check to indicate it only runs upon 100% inclusion, etc.
Also, you just made me think that batchSubmissionRetriesCount may be a useful metric as well. Ideally we're getting transactions included immediately.
There was a problem hiding this comment.
i played around with the logs and there isn't a light weight to parse, so ruling that out for now. i think we could potentially filter for numTxPerBatch that are observed alongside a submission timestamp metric, so we know which ones actually make it through?
i'll think about the retries count metrics - might be easier to observe when it attempts to submit and when it actually does, which we can deduce from this metric vs the actual submission timestamp 👀
| private _registerMetrics(metrics: Metrics): BatchSubmitterMetrics { | ||
| metrics.registry.clear() | ||
|
|
||
| return { |
There was a problem hiding this comment.
@snario i'm not familiar yet with how registries work, but i have a feeling that the failing integration test might be due to registering the same metric so i added this line - is this standard practice or a hack? i could also only reset these specific metrics i'm registering here
There was a problem hiding this comment.
I don't think we should ever be registering the same metrics within the same process. It either indicates we ought to be mocking out metrics in the test or using different processes to test the behaviour of multiple batch submitters.
There was a problem hiding this comment.
i think it actually may be when we initialize both transaction and state batch submitters here:
optimism/packages/batch-submitter/src/exec/run-batch-submitter.ts
Lines 167 to 213 in ae1ac05
packages/batch-submitter/src/batch-submitter/batch-submitter.ts
Outdated
Show resolved
Hide resolved
| protected chainContract: Contract | ||
| protected l2ChainId: number | ||
| protected syncing: boolean | ||
| protected lastBatchSubmissionTimestamp: number = 0 |
There was a problem hiding this comment.
Could setting this to 0 potentially lead to edge cases as opposed to explicitly leaving it undefined until we have fetched this information?
There was a problem hiding this comment.
^i think undefined might leave more edge cases since we're trying to do a subtraction!
There was a problem hiding this comment.
Right I guess it's just a matter of how we prefer to treat "un-fetched data". If we just treat it as 0 then we check for 0 in the code, otherwise we check for undefined. TypeScript has some typing around undefined values being potentially operated on, which is why I recommended undefined, but I'm not super opionated.
|
|
||
| afterEach(() => { | ||
| sinon.restore() | ||
| testMetrics.registry.clear() |
There was a problem hiding this comment.
I think we should just be mocking the library.
There was a problem hiding this comment.
didn't find a library around this and the graph's use was much cleaner than ours so didn't need to do this 😭 i've moved this temporarily into the constructor; i will make a note of this in my bs refactor doc, let's observe if this surfaces any problems when we have dashboards running?
snario
left a comment
There was a problem hiding this comment.
Conditional approval but I left a few last things I think ought to be revised
* add ethBalance gauge * add rest of bs metrics * add changeset
Description
Adds key metrics to the batch submitter so we can monitor them on a dashboard.
Additional context
See issue for metric list
Metadata