Commit 5ecdd804 authored by mergify[bot]'s avatar mergify[bot] Committed by GitHub

Merge branch 'develop' into fix/geth-types

parents 17962ca9 1aca58c4
---
'@eth-optimism/contracts-bedrock': patch
---
Initial release
......@@ -226,32 +226,33 @@ func UserDeposits(receipts []*types.Receipt, depositContractAddr common.Address)
return out, errs
}
func BatchesFromEVMTransactions(config *rollup.Config, txLists []types.Transactions) ([]*BatchData, error) {
func BatchesFromEVMTransactions(config *rollup.Config, txLists []types.Transactions) ([]*BatchData, []error) {
var out []*BatchData
var errs []error
l1Signer := config.L1Signer()
for _, txs := range txLists {
for _, tx := range txs {
for i, txs := range txLists {
for j, tx := range txs {
if to := tx.To(); to != nil && *to == config.BatchInboxAddress {
seqDataSubmitter, err := l1Signer.Sender(tx) // optimization: only derive sender if To is correct
if err != nil {
// TODO: log error
errs = append(errs, fmt.Errorf("invalid signature: tx list: %d, tx: %d, err: %w", i, j, err))
continue // bad signature, ignore
}
// some random L1 user might have sent a transaction to our batch inbox, ignore them
if seqDataSubmitter != config.BatchSenderAddress {
// TODO: log/record metric
errs = append(errs, fmt.Errorf("unauthorized batch submitter: tx list: %d, tx: %d", i, j))
continue // not an authorized batch submitter, ignore
}
batches, err := DecodeBatches(config, bytes.NewReader(tx.Data()))
if err != nil {
// TODO: log/record metric
errs = append(errs, fmt.Errorf("invalid batch: tx list: %d, tx: %d, err: %w", i, j, err))
continue
}
out = append(out, batches...)
}
}
}
return out, nil
return out, errs
}
func FilterBatches(config *rollup.Config, epoch rollup.Epoch, minL2Time uint64, maxL2Time uint64, batches []*BatchData) (out []*BatchData) {
......
......@@ -198,10 +198,14 @@ func (d *outputImpl) insertEpoch(ctx context.Context, l2Head eth.L2BlockRef, l2S
if err != nil {
return l2Head, l2SafeHead, false, fmt.Errorf("failed to fetch transactions from %s: %v", l1Input, err)
}
batches, err := derive.BatchesFromEVMTransactions(&d.Config, transactions)
if err != nil {
return l2Head, l2SafeHead, false, fmt.Errorf("failed to fetch create batches from transactions: %w", err)
batches, errs := derive.BatchesFromEVMTransactions(&d.Config, transactions)
// Some input to derive.BatchesFromEVMTransactions may be invalid and produce errors.
// We log the errors, but keep going as this process is designed to be resilient to these errors
// and we have defaults in case no valid (or partial) batches were submitted.
for i, err := range errs {
d.log.Error("Failed to decode batch", "err_idx", i, "err", err)
}
// Make batches contiguous
minL2Time := uint64(l2Info.Timestamp) + d.Config.BlockTime
maxL2Time := l1Info.Time() + d.Config.MaxSequencerDrift
......
[default]
src = 'contracts'
# We need to build seperate artifacts for forge and hh, because they each expect a different
# structure for the artifacts directory.
out = 'forge-artifacts'
optimizer = true
optimizer_runs = 999999
......@@ -14,4 +12,5 @@ remappings = [
'forge-std/=node_modules/forge-std/src',
'ds-test/=node_modules/ds-test/src'
]
extra_output = ['devdoc', 'userdoc', 'metadata', 'storageLayout']
bytecode_hash = "none"
......@@ -25,13 +25,12 @@
},
"scripts": {
"build:forge": "forge build",
"build": "yarn hardhat compile",
"test:hh": "yarn hardhat test",
"test": "yarn test:forge",
"test:forge": "forge test",
"build": "hardhat compile && tsc && hardhat typechain",
"build:ts": "tsc",
"test": "forge test",
"gas-snapshot": "forge snapshot",
"slither": "slither .",
"clean": "rm -rf ./artifacts ./forge-artifacts ./cache ./coverage ./tsconfig.tsbuildinfo",
"clean": "rm -rf ./dist ./artifacts ./forge-artifacts ./cache ./coverage ./tsconfig.tsbuildinfo",
"lint:ts:check": "eslint .",
"lint:contracts:check": "yarn solhint -f table 'contracts/**/*.sol'",
"lint:check": "yarn lint:contracts:check && yarn lint:ts:check",
......
export * from './utils'
export * from './generateProofs'
export * from './constants'
......@@ -2,7 +2,7 @@ import { task, types } from 'hardhat/config'
import { Contract, providers, utils, Wallet, Event } from 'ethers'
import dotenv from 'dotenv'
import { DepositTx } from '../helpers/index'
import { DepositTx } from '../src'
dotenv.config()
......
import { expect } from 'chai'
import { BigNumber } from 'ethers'
import { DepositTx, SourceHashDomain } from '../helpers'
import { DepositTx, SourceHashDomain } from '../src'
describe('Helpers', () => {
describe('DepositTx', () => {
......
{
"extends": "../../tsconfig.json",
"include": ["./scripts/", "./helpers/"],
"compilerOptions": {
"rootDir": ".",
"rootDir": "./src",
"outDir": "./dist"
}
},
"exclude": ["hardhat.config.ts", "deploy", "tasks", "test"],
"include": [
"src/**/*"
]
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment