From 2f9edf73ca20077a62f7988d1d78708fc1552e38 Mon Sep 17 00:00:00 2001 From: HAOYUatHZ <37070449+HAOYUatHZ@users.noreply.github.com> Date: Tue, 1 Aug 2023 13:52:31 +0800 Subject: [PATCH] feat(rollup): add circuits capacity checker (#321) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * add proof for predeployed storages * reverse inneeded code * update for mainbranch merging * add pertx storage trace * dummy tx proof * add txstorage trace * add coinbase storage as trace * enable (sync) tracing by default * basic * init cgo framework * fix break loop * integrate the right zkevm version (#323) * finish rust codes * use dylib (#325) * flip * ? * use cdylib * revert * fix * apply_tx * rename * fixing types fixing types fixing types * clean up * ExecutionResults (#328) * filling * filling * more * clean up * filling * coinbase * add * MPTWitness * ExecutionResults WIP * L1fee L1fee * sender * to * Failed & ReturnValue * createdAcc & after * remove MPTWitness * txStorageTrace * add FeeRecipient * add StorageTrace * fix FFI types * better logger * cargo fmt * fix * add build tags * update Makefile * fix library * improve ld path * correctly deal with circuit_capacity_checker returned result * fix return value * update cargo (#333) * update cargo * update * update go * refactor * raname `circuits capacity checker` to `circuit capacity checker` * some refactorings * [Fix] storage proof generation in capacity checker (#348) * make per-tx storage and deletion proof work * format * fix misplaced markdeletion --------- Co-authored-by: HAOYUatHZ * docker (#363) * update Dockerfile * build: update go version to 1.19 * update * fix * fix * try * simplify * revert go version update l2geth Dockerfiles * fix * fix coinbase * fix (#369) * format * Update version.go * address comments * Capacity refactor (#374) * init * id * support multiple instances * fix id * fix conflicts * refactor to use same codes (#379) * re-init * WIP * WIP * refactor * go * minor * fix storage proof of l1gas price oracle * move 1 * move 2 * move 3 * move 4 * move 5 move 5 * move 6 move 6 * move 7 * move 8 * move 9 * move 10 * clean up clean up --------- Co-authored-by: Ho Vei * finish basic * minor * config capacity check in block_validator (#380) * init * done ref * fix tests fix tests fix tests fix tests * add more comments * apply_block * improve logs * cargo fmt * Capacity big refactor (#383) * CreateTraceEnv * WIP * draft more fix * for test * fortet * clean up * add more comments * goimports -local github.com/scroll-tech/go-ethereum -w . * fix typos * attempt 1 * attempt 2 * attempt 3 * gogogo * clean up * fix * fix * rename * minor * fix * minor * minor * improve doc * use dedicated `checkCircuitCapacity` flag (#394) * refactor * fix * add lock * [feat] capacity checking: upgrade libzkp (#395) * upgrade * upgrade libzkp * write RowConsumption (#396) * write RowConsumption * name alignments * revert some formatting * add lock to CircuitCapacityChecker in BlockValidator * remove mutex pointer * improve github workflow * improve * store row consumption in mining (#397) * prepare * finish * add more logs * mark `ApplyBlock` as ready * update libzkp (#401) * fix * Capacity detail (#402) * fix(block-validation): consider skipping in ValidateL1Messages (#405) * fix(block-validation): consider skipping in ValidateL1Messages * fix(block): consider skipping in L1MessageCount * fix l1 validation tests * fix NumL1Messages * fix impl.go return types fix * better error handling (#407) * add add * add * add * add * add * cargo fmt * add * update * add * WIP * minor * gogogo * gogogo * fix * fix * fix * cargo clippy * improve * improve * creation lock (#408) * creation lock * update * Debug log (#409) * add more logs * more * more * fix * improve * Update cmd/utils/flags.go Co-authored-by: Péter Garamvölgyi * refactor worker.commit() * avoid re-calculate * txpool ccc err handling (#411) * more explicit error comments * add more logs * fix unnecessary commit * add more logs * fix `ineffassign` * add more comments * log id for `NewCircuitCapacityChecker` (#414) add log to `NewCircuitCapacityChecker` * Persist skip info for block where all L1 msgs are skipped (#415) persist skip info for block where all L1 msgs are skipped * Update version.go --------- Co-authored-by: Ho Vei Co-authored-by: Zhang Zhuo Co-authored-by: Péter Garamvölgyi --- .github/workflows/l2geth_ci.yml | 21 +- Dockerfile | 32 +- Dockerfile.alltools | 2 +- Makefile | 13 +- accounts/abi/bind/backends/simulated.go | 2 +- build/ci.go | 10 +- cmd/utils/flags.go | 15 +- consensus/clique/clique_test.go | 6 +- consensus/clique/snapshot_test.go | 2 +- consensus/errors.go | 3 +- core/bench_test.go | 4 +- core/block_validator.go | 103 +- core/block_validator_test.go | 8 +- core/blockchain.go | 19 +- core/blockchain_repair_test.go | 8 +- core/blockchain_sethead_test.go | 2 +- core/blockchain_snapshot_test.go | 24 +- core/blockchain_test.go | 140 +- core/chain_makers_test.go | 2 +- core/dao_test.go | 12 +- core/genesis_test.go | 2 +- core/rawdb/accessors_row_consumption.go | 6 +- core/rawdb/accessors_row_consumption_test.go | 7 +- core/state_processor_test.go | 8 +- core/trace.go | 493 ++ core/types/block.go | 43 +- core/types/gen_row_consumption_json.go | 38 +- core/types/l2trace.go | 9 + core/types/row_consumption.go | 20 +- eth/backend.go | 2 +- eth/ethconfig/config.go | 3 + eth/gasprice/gasprice_test.go | 2 +- eth/handler_eth_test.go | 4 +- eth/handler_test.go | 2 +- eth/protocols/eth/handler_test.go | 2 +- eth/tracers/api_blocktrace.go | 467 +- eth/tracers/api_test.go | 2 +- light/odr_test.go | 2 +- light/trie_test.go | 2 +- light/txpool_test.go | 2 +- miner/miner_test.go | 2 +- miner/worker.go | 172 +- miner/worker_test.go | 10 +- params/version.go | 2 +- rollup/circuitcapacitychecker/impl.go | 141 + .../circuitcapacitychecker/libzkp/.gitignore | 3 + .../circuitcapacitychecker/libzkp/Cargo.lock | 4504 +++++++++++++++++ .../circuitcapacitychecker/libzkp/Cargo.toml | 39 + rollup/circuitcapacitychecker/libzkp/Makefile | 10 + rollup/circuitcapacitychecker/libzkp/libzkp.h | 6 + .../libzkp/rust-toolchain | 1 + .../circuitcapacitychecker/libzkp/src/lib.rs | 190 + rollup/circuitcapacitychecker/mock.go | 28 + rollup/circuitcapacitychecker/types.go | 19 + tests/block_test_util.go | 2 +- tests/fuzzers/les/les-fuzzer.go | 2 +- 56 files changed, 5986 insertions(+), 689 deletions(-) create mode 100644 core/trace.go create mode 100644 rollup/circuitcapacitychecker/impl.go create mode 100644 rollup/circuitcapacitychecker/libzkp/.gitignore create mode 100644 rollup/circuitcapacitychecker/libzkp/Cargo.lock create mode 100644 rollup/circuitcapacitychecker/libzkp/Cargo.toml create mode 100644 rollup/circuitcapacitychecker/libzkp/Makefile create mode 100644 rollup/circuitcapacitychecker/libzkp/libzkp.h create mode 100644 rollup/circuitcapacitychecker/libzkp/rust-toolchain create mode 100644 rollup/circuitcapacitychecker/libzkp/src/lib.rs create mode 100644 rollup/circuitcapacitychecker/mock.go create mode 100644 rollup/circuitcapacitychecker/types.go diff --git a/.github/workflows/l2geth_ci.yml b/.github/workflows/l2geth_ci.yml index e840ecf9ae..1d9f5ca334 100644 --- a/.github/workflows/l2geth_ci.yml +++ b/.github/workflows/l2geth_ci.yml @@ -13,7 +13,7 @@ on: - ready_for_review name: CI jobs: - build: + build-mock-ccc-geth: # build geth with mock circuit capacity checker if: github.event.pull_request.draft == false runs-on: ubuntu-latest steps: @@ -23,6 +23,25 @@ jobs: go-version: 1.18.x - name: Checkout code uses: actions/checkout@v2 + - name: Build + run: | + make nccc_geth + build-geth: # build geth with circuit capacity checker + if: github.event_name == 'push' # will only be triggered when pushing to main & staging & develop & alpha + runs-on: ubuntu-latest + steps: + - name: Install Go + uses: actions/setup-go@v2 + with: + go-version: 1.19.x + - name: Install rust + uses: actions-rs/toolchain@v1 + with: + toolchain: nightly-2022-12-10 + override: true + components: rustfmt, clippy + - name: Checkout code + uses: actions/checkout@v2 - name: Build run: | make geth diff --git a/Dockerfile b/Dockerfile index ec46f60773..55d89c9d98 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,19 +3,39 @@ ARG COMMIT="" ARG VERSION="" ARG BUILDNUM="" -# Build Geth in a stock Go builder container -FROM golang:1.18-alpine as builder +# Build libzkp dependency +FROM scrolltech/go-rust-builder:go-1.19-rust-nightly-2022-12-10 as chef +WORKDIR app -RUN apk add --no-cache gcc musl-dev linux-headers git +FROM chef as planner +COPY ./rollup/circuitcapacitychecker/libzkp/ . +RUN cargo chef prepare --recipe-path recipe.json + +FROM chef as zkp-builder +COPY ./rollup/circuitcapacitychecker/libzkp/rust-toolchain ./ +COPY --from=planner /app/recipe.json recipe.json +RUN cargo chef cook --release --recipe-path recipe.json + +COPY ./rollup/circuitcapacitychecker/libzkp . +RUN cargo build --release +RUN find ./ | grep libzktrie.so | xargs -I{} cp {} /app/target/release/ + +# Build Geth in a stock Go builder container +FROM scrolltech/go-rust-builder:go-1.19-rust-nightly-2022-12-10 as builder ADD . /go-ethereum -RUN cd /go-ethereum && go run build/ci.go install ./cmd/geth +COPY --from=zkp-builder /app/target/release/libzkp.so /usr/local/lib/ +COPY --from=zkp-builder /app/target/release/libzktrie.so /usr/local/lib/ +ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib/ +RUN cd /go-ethereum && env GO111MODULE=on go run build/ci.go install -buildtags circuit_capacity_checker ./cmd/geth # Pull Geth into a second stage deploy alpine container -FROM alpine:latest +FROM ubuntu:20.04 -RUN apk add --no-cache ca-certificates COPY --from=builder /go-ethereum/build/bin/geth /usr/local/bin/ +COPY --from=zkp-builder /app/target/release/libzkp.so /usr/local/lib/ +COPY --from=zkp-builder /app/target/release/libzktrie.so /usr/local/lib/ +ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib/ EXPOSE 8545 8546 30303 30303/udp ENTRYPOINT ["geth"] diff --git a/Dockerfile.alltools b/Dockerfile.alltools index 683f87a55e..1cd9ad9ad4 100644 --- a/Dockerfile.alltools +++ b/Dockerfile.alltools @@ -4,7 +4,7 @@ ARG VERSION="" ARG BUILDNUM="" # Build Geth in a stock Go builder container -FROM golang:1.18-alpine as builder +FROM golang:1.19-alpine as builder RUN apk add --no-cache gcc musl-dev linux-headers git diff --git a/Makefile b/Makefile index 235da0595f..1a38368d51 100644 --- a/Makefile +++ b/Makefile @@ -2,17 +2,26 @@ # with Go source code. If you know what GOPATH is then you probably # don't need to bother with make. -.PHONY: geth android ios evm all test clean +.PHONY: geth android ios evm all test clean libzkp GOBIN = ./build/bin GO ?= latest GORUN = env GO111MODULE=on go run -geth: + +libzkp: + cd $(PWD)/rollup/circuitcapacitychecker/libzkp && make libzkp + +nccc_geth: ## geth without circuit capacity checker $(GORUN) build/ci.go install ./cmd/geth @echo "Done building." @echo "Run \"$(GOBIN)/geth\" to launch geth." +geth: libzkp + $(GORUN) build/ci.go install -buildtags circuit_capacity_checker ./cmd/geth + @echo "Done building." + @echo "Run \"$(GOBIN)/geth\" to launch geth." + all: $(GORUN) build/ci.go install diff --git a/accounts/abi/bind/backends/simulated.go b/accounts/abi/bind/backends/simulated.go index 2f4a9216ab..52b581965e 100644 --- a/accounts/abi/bind/backends/simulated.go +++ b/accounts/abi/bind/backends/simulated.go @@ -79,7 +79,7 @@ type SimulatedBackend struct { func NewSimulatedBackendWithDatabase(database ethdb.Database, alloc core.GenesisAlloc, gasLimit uint64) *SimulatedBackend { genesis := core.Genesis{Config: params.AllEthashProtocolChanges, GasLimit: gasLimit, Alloc: alloc} genesis.MustCommit(database) - blockchain, _ := core.NewBlockChain(database, nil, genesis.Config, ethash.NewFaker(), vm.Config{}, nil, nil) + blockchain, _ := core.NewBlockChain(database, nil, genesis.Config, ethash.NewFaker(), vm.Config{}, nil, nil, false) backend := &SimulatedBackend{ database: database, diff --git a/build/ci.go b/build/ci.go index a7a15ac0af..54cbf6e1f3 100644 --- a/build/ci.go +++ b/build/ci.go @@ -199,9 +199,10 @@ func main() { func doInstall(cmdline []string) { var ( - dlgo = flag.Bool("dlgo", false, "Download Go and build with it") - arch = flag.String("arch", "", "Architecture to cross build for") - cc = flag.String("cc", "", "C compiler to cross build with") + dlgo = flag.Bool("dlgo", false, "Download Go and build with it") + arch = flag.String("arch", "", "Architecture to cross build for") + cc = flag.String("cc", "", "C compiler to cross build with") + buildtags = flag.String("buildtags", "", "Tags for go build") ) flag.CommandLine.Parse(cmdline) @@ -215,6 +216,9 @@ func doInstall(cmdline []string) { // Configure the build. env := build.Env() gobuild := tc.Go("build", buildFlags(env)...) + if len(*buildtags) != 0 { + gobuild.Args = append(gobuild.Args, "-tags", *buildtags) + } // arm64 CI builders are memory-constrained and can't handle concurrent builds, // better disable it. This check isn't the best, it should probably diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 4c444436ea..e68c71de6c 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -812,6 +812,12 @@ var ( Name: "l1.sync.startblock", Usage: "L1 block height to start syncing from. Should be set to the L1 message queue deployment block number.", } + + // Circuit capacity check settings + CircuitCapacityCheckEnabledFlag = cli.BoolFlag{ + Name: "ccc", + Usage: "Enable circuit capacity check during block validation", + } ) // MakeDataDir retrieves the currently requested data directory, terminating @@ -1493,6 +1499,12 @@ func setWhitelist(ctx *cli.Context, cfg *ethconfig.Config) { } } +func setCircuitCapacityCheck(ctx *cli.Context, cfg *ethconfig.Config) { + if ctx.GlobalIsSet(CircuitCapacityCheckEnabledFlag.Name) { + cfg.CheckCircuitCapacity = ctx.GlobalBool(CircuitCapacityCheckEnabledFlag.Name) + } +} + // CheckExclusive verifies that only a single instance of the provided flags was // set by the user. Each flag might optionally be followed by a string type to // specialize it further. @@ -1558,6 +1570,7 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) { setMiner(ctx, &cfg.Miner) setWhitelist(ctx, cfg) setLes(ctx, cfg) + setCircuitCapacityCheck(ctx, cfg) // Cap the cache allowance and tune the garbage collector mem, err := gopsutil.VirtualMemory() @@ -2006,7 +2019,7 @@ func MakeChain(ctx *cli.Context, stack *node.Node) (chain *core.BlockChain, chai // TODO(rjl493456442) disable snapshot generation/wiping if the chain is read only. // Disable transaction indexing/unindexing by default. - chain, err = core.NewBlockChain(chainDb, cache, config, engine, vmcfg, nil, nil) + chain, err = core.NewBlockChain(chainDb, cache, config, engine, vmcfg, nil, nil, false) if err != nil { Fatalf("Can't create BlockChain: %v", err) } diff --git a/consensus/clique/clique_test.go b/consensus/clique/clique_test.go index 4faa936501..7f0d9a278d 100644 --- a/consensus/clique/clique_test.go +++ b/consensus/clique/clique_test.go @@ -55,7 +55,7 @@ func TestReimportMirroredState(t *testing.T) { genesis := genspec.MustCommit(db) // Generate a batch of blocks, each properly signed - chain, _ := core.NewBlockChain(db, nil, params.AllCliqueProtocolChanges, engine, vm.Config{}, nil, nil) + chain, _ := core.NewBlockChain(db, nil, params.AllCliqueProtocolChanges, engine, vm.Config{}, nil, nil, false) defer chain.Stop() blocks, _ := core.GenerateChain(params.AllCliqueProtocolChanges, genesis, engine, db, 3, func(i int, block *core.BlockGen) { @@ -89,7 +89,7 @@ func TestReimportMirroredState(t *testing.T) { db = rawdb.NewMemoryDatabase() genspec.MustCommit(db) - chain, _ = core.NewBlockChain(db, nil, params.AllCliqueProtocolChanges, engine, vm.Config{}, nil, nil) + chain, _ = core.NewBlockChain(db, nil, params.AllCliqueProtocolChanges, engine, vm.Config{}, nil, nil, false) defer chain.Stop() if _, err := chain.InsertChain(blocks[:2]); err != nil { @@ -102,7 +102,7 @@ func TestReimportMirroredState(t *testing.T) { // Simulate a crash by creating a new chain on top of the database, without // flushing the dirty states out. Insert the last block, triggering a sidechain // reimport. - chain, _ = core.NewBlockChain(db, nil, params.AllCliqueProtocolChanges, engine, vm.Config{}, nil, nil) + chain, _ = core.NewBlockChain(db, nil, params.AllCliqueProtocolChanges, engine, vm.Config{}, nil, nil, false) defer chain.Stop() if _, err := chain.InsertChain(blocks[2:]); err != nil { diff --git a/consensus/clique/snapshot_test.go b/consensus/clique/snapshot_test.go index 790f381031..7b238cae4a 100644 --- a/consensus/clique/snapshot_test.go +++ b/consensus/clique/snapshot_test.go @@ -450,7 +450,7 @@ func TestClique(t *testing.T) { batches[len(batches)-1] = append(batches[len(batches)-1], block) } // Pass all the headers through clique and ensure tallying succeeds - chain, err := core.NewBlockChain(db, nil, &config, engine, vm.Config{}, nil, nil) + chain, err := core.NewBlockChain(db, nil, &config, engine, vm.Config{}, nil, nil, false) if err != nil { t.Errorf("test %d: failed to create test chain: %v", i, err) continue diff --git a/consensus/errors.go b/consensus/errors.go index 978d0974cf..5a40c87128 100644 --- a/consensus/errors.go +++ b/consensus/errors.go @@ -45,8 +45,7 @@ var ( // ErrInvalidL1MessageOrder is returned if a block contains L1 messages in the wrong // order. Possible scenarios are: (1) L1 messages do not follow their QueueIndex order, - // (2) the block skipped one or more L1 messages, (3) L1 messages are not included in - // a contiguous block at the front of the block. + // (2) L1 messages are not included in a contiguous block at the front of the block. ErrInvalidL1MessageOrder = errors.New("invalid L1 message order") // ErrUnknownL1Message is returned if a block contains an L1 message that does not diff --git a/core/bench_test.go b/core/bench_test.go index 622b4433cc..86386944e1 100644 --- a/core/bench_test.go +++ b/core/bench_test.go @@ -201,7 +201,7 @@ func benchInsertChain(b *testing.B, disk bool, gen func(int, *BlockGen)) { // Time the insertion of the new chain. // State and blocks are stored in the same DB. - chainman, _ := NewBlockChain(db, nil, gspec.Config, ethash.NewFaker(), vm.Config{}, nil, nil) + chainman, _ := NewBlockChain(db, nil, gspec.Config, ethash.NewFaker(), vm.Config{}, nil, nil, false) defer chainman.Stop() b.ReportAllocs() b.ResetTimer() @@ -316,7 +316,7 @@ func benchReadChain(b *testing.B, full bool, count uint64) { if err != nil { b.Fatalf("error opening database at %v: %v", dir, err) } - chain, err := NewBlockChain(db, &cacheConfig, params.TestChainConfig, ethash.NewFaker(), vm.Config{}, nil, nil) + chain, err := NewBlockChain(db, &cacheConfig, params.TestChainConfig, ethash.NewFaker(), vm.Config{}, nil, nil, false) if err != nil { b.Fatalf("error creating chain: %v", err) } diff --git a/core/block_validator.go b/core/block_validator.go index 06b197d674..b80c2d1297 100644 --- a/core/block_validator.go +++ b/core/block_validator.go @@ -17,13 +17,18 @@ package core import ( + "errors" "fmt" + "sync" "github.com/scroll-tech/go-ethereum/consensus" "github.com/scroll-tech/go-ethereum/core/rawdb" "github.com/scroll-tech/go-ethereum/core/state" "github.com/scroll-tech/go-ethereum/core/types" + "github.com/scroll-tech/go-ethereum/ethdb" + "github.com/scroll-tech/go-ethereum/log" "github.com/scroll-tech/go-ethereum/params" + "github.com/scroll-tech/go-ethereum/rollup/circuitcapacitychecker" "github.com/scroll-tech/go-ethereum/trie" ) @@ -35,15 +40,25 @@ type BlockValidator struct { config *params.ChainConfig // Chain configuration options bc *BlockChain // Canonical block chain engine consensus.Engine // Consensus engine used for validating + + // circuit capacity checker related fields + checkCircuitCapacity bool // whether enable circuit capacity check + db ethdb.Database // db to store row consumption + cMu sync.Mutex // mutex for circuit capacity checker + circuitCapacityChecker *circuitcapacitychecker.CircuitCapacityChecker // circuit capacity checker instance } // NewBlockValidator returns a new block validator which is safe for re-use -func NewBlockValidator(config *params.ChainConfig, blockchain *BlockChain, engine consensus.Engine) *BlockValidator { +func NewBlockValidator(config *params.ChainConfig, blockchain *BlockChain, engine consensus.Engine, db ethdb.Database, checkCircuitCapacity bool) *BlockValidator { validator := &BlockValidator{ - config: config, - engine: engine, - bc: blockchain, + config: config, + engine: engine, + bc: blockchain, + checkCircuitCapacity: checkCircuitCapacity, + db: db, + circuitCapacityChecker: circuitcapacitychecker.NewCircuitCapacityChecker(), } + log.Info("created new BlockValidator", "CircuitCapacityChecker ID", validator.circuitCapacityChecker.ID) return validator } @@ -79,18 +94,34 @@ func (v *BlockValidator) ValidateBody(block *types.Block) error { } return consensus.ErrPrunedAncestor } - return v.ValidateL1Messages(block) + if err := v.ValidateL1Messages(block); err != nil { + return err + } + if v.checkCircuitCapacity { + // if a block's RowConsumption has been stored, which means it has been processed before, + // (e.g., in miner/worker.go or in insertChain), + // we simply skip its calculation and validation + if rawdb.ReadBlockRowConsumption(v.db, block.Hash()) != nil { + return nil + } + rowConsumption, err := v.validateCircuitRowConsumption(block) + if err != nil { + return err + } + rawdb.WriteBlockRowConsumption(v.db, block.Hash(), rowConsumption) + } + return nil } // ValidateL1Messages validates L1 messages contained in a block. // We check the following conditions: // - L1 messages are in a contiguous section at the front of the block. // - The first L1 message's QueueIndex is right after the last L1 message included in the chain. -// - L1 messages follow the QueueIndex order. No L1 message is skipped. +// - L1 messages follow the QueueIndex order. // - The L1 messages included in the block match the node's view of the L1 ledger. func (v *BlockValidator) ValidateL1Messages(block *types.Block) error { - // no further processing if the block contains no L1 messages - if block.L1MessageCount() == 0 { + // skip DB read if the block contains no L1 messages + if !block.ContainsL1Messages() { return nil } @@ -120,16 +151,30 @@ func (v *BlockValidator) ValidateL1Messages(block *types.Block) error { return consensus.ErrInvalidL1MessageOrder } - // check queue index - // TODO: account for skipped messages here - if tx.AsL1MessageTx().QueueIndex != queueIndex { + // queue index cannot decrease + txQueueIndex := tx.AsL1MessageTx().QueueIndex + + if txQueueIndex < queueIndex { return consensus.ErrInvalidL1MessageOrder } - queueIndex += 1 + // skipped messages + // TODO: consider verifying that skipped messages overflow + for index := queueIndex; index < txQueueIndex; index++ { + log.Debug("Skipped L1 message", "block", block.Hash().String(), "queueIndex", index) + + if exists := it.Next(); !exists { + // the message in this block is not available in our local db. + // we'll reprocess this block at a later time. + return consensus.ErrMissingL1MessageData + } + } + + queueIndex = txQueueIndex + 1 if exists := it.Next(); !exists { - // we'll reprocess this block at a later time + // the message in this block is not available in our local db. + // we'll reprocess this block at a later time. return consensus.ErrMissingL1MessageData } @@ -202,3 +247,35 @@ func CalcGasLimit(parentGasLimit, desiredLimit uint64) uint64 { } return limit } + +func (v *BlockValidator) createTraceEnv(block *types.Block) (*TraceEnv, error) { + parent := v.bc.GetBlock(block.ParentHash(), block.NumberU64()-1) + if parent == nil { + return nil, errors.New("validateCircuitRowConsumption: no parent block found") + } + + statedb, err := v.bc.StateAt(parent.Hash()) + if err != nil { + return nil, err + } + + return CreateTraceEnv(v.config, v.bc, v.engine, statedb, parent, block) +} + +func (v *BlockValidator) validateCircuitRowConsumption(block *types.Block) (*types.RowConsumption, error) { + env, err := v.createTraceEnv(block) + if err != nil { + return nil, err + } + + traces, err := env.GetBlockTrace(block) + if err != nil { + return nil, err + } + + v.cMu.Lock() + defer v.cMu.Unlock() + + v.circuitCapacityChecker.Reset() + return v.circuitCapacityChecker.ApplyBlock(traces) +} diff --git a/core/block_validator_test.go b/core/block_validator_test.go index c94132d001..57121b9ecd 100644 --- a/core/block_validator_test.go +++ b/core/block_validator_test.go @@ -42,7 +42,7 @@ func TestHeaderVerification(t *testing.T) { headers[i] = block.Header() } // Run the header checker for blocks one-by-one, checking for both valid and invalid nonces - chain, _ := NewBlockChain(testdb, nil, params.TestChainConfig, ethash.NewFaker(), vm.Config{}, nil, nil) + chain, _ := NewBlockChain(testdb, nil, params.TestChainConfig, ethash.NewFaker(), vm.Config{}, nil, nil, false) defer chain.Stop() for i := 0; i < len(blocks); i++ { @@ -106,11 +106,11 @@ func testHeaderConcurrentVerification(t *testing.T, threads int) { var results <-chan error if valid { - chain, _ := NewBlockChain(testdb, nil, params.TestChainConfig, ethash.NewFaker(), vm.Config{}, nil, nil) + chain, _ := NewBlockChain(testdb, nil, params.TestChainConfig, ethash.NewFaker(), vm.Config{}, nil, nil, false) _, results = chain.engine.VerifyHeaders(chain, headers, seals) chain.Stop() } else { - chain, _ := NewBlockChain(testdb, nil, params.TestChainConfig, ethash.NewFakeFailer(uint64(len(headers)-1)), vm.Config{}, nil, nil) + chain, _ := NewBlockChain(testdb, nil, params.TestChainConfig, ethash.NewFakeFailer(uint64(len(headers)-1)), vm.Config{}, nil, nil, false) _, results = chain.engine.VerifyHeaders(chain, headers, seals) chain.Stop() } @@ -173,7 +173,7 @@ func testHeaderConcurrentAbortion(t *testing.T, threads int) { defer runtime.GOMAXPROCS(old) // Start the verifications and immediately abort - chain, _ := NewBlockChain(testdb, nil, params.TestChainConfig, ethash.NewFakeDelayer(time.Millisecond), vm.Config{}, nil, nil) + chain, _ := NewBlockChain(testdb, nil, params.TestChainConfig, ethash.NewFakeDelayer(time.Millisecond), vm.Config{}, nil, nil, false) defer chain.Stop() abort, results := chain.engine.VerifyHeaders(chain, headers, seals) diff --git a/core/blockchain.go b/core/blockchain.go index a3bb38ab44..f6e1070788 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -220,7 +220,7 @@ type BlockChain struct { // NewBlockChain returns a fully initialised block chain using information // available in the database. It initialises the default Ethereum Validator and // Processor. -func NewBlockChain(db ethdb.Database, cacheConfig *CacheConfig, chainConfig *params.ChainConfig, engine consensus.Engine, vmConfig vm.Config, shouldPreserve func(block *types.Block) bool, txLookupLimit *uint64) (*BlockChain, error) { +func NewBlockChain(db ethdb.Database, cacheConfig *CacheConfig, chainConfig *params.ChainConfig, engine consensus.Engine, vmConfig vm.Config, shouldPreserve func(block *types.Block) bool, txLookupLimit *uint64, checkCircuitCapacity bool) (*BlockChain, error) { if cacheConfig == nil { cacheConfig = defaultCacheConfig } @@ -263,7 +263,7 @@ func NewBlockChain(db ethdb.Database, cacheConfig *CacheConfig, chainConfig *par engine: engine, vmConfig: vmConfig, } - bc.validator = NewBlockValidator(chainConfig, bc, engine) + bc.validator = NewBlockValidator(chainConfig, bc, engine, db, checkCircuitCapacity) bc.prefetcher = newStatePrefetcher(chainConfig, bc, engine) bc.processor = NewStateProcessor(chainConfig, bc, engine) @@ -1182,10 +1182,14 @@ func (bc *BlockChain) writeBlockWithoutState(block *types.Block, td *big.Int) (e rawdb.WriteBlock(batch, block) queueIndex := rawdb.ReadFirstQueueIndexNotInL2Block(bc.db, block.ParentHash()) + + // note: we can insert blocks with header-only ancestors here, + // so queueIndex might not yet be available in DB. if queueIndex != nil { - // note: we can insert blocks with header-only ancestors here, - // so queueIndex might not yet be available in DB. - rawdb.WriteFirstQueueIndexNotInL2Block(batch, block.Hash(), *queueIndex+uint64(block.L1MessageCount())) + // do not overwrite the index written by the miner worker + if index := rawdb.ReadFirstQueueIndexNotInL2Block(bc.db, block.Hash()); index == nil { + rawdb.WriteFirstQueueIndexNotInL2Block(batch, block.Hash(), *queueIndex+uint64(block.NumL1MessagesProcessed(*queueIndex))) + } } if err := batch.Write(); err != nil { @@ -1249,7 +1253,10 @@ func (bc *BlockChain) writeBlockWithState(block *types.Block, receipts []*types. // so the parent will always be inserted first. log.Crit("Queue index in DB is nil", "parent", block.ParentHash(), "hash", block.Hash()) } - rawdb.WriteFirstQueueIndexNotInL2Block(blockBatch, block.Hash(), *queueIndex+uint64(block.L1MessageCount())) + // do not overwrite the index written by the miner worker + if index := rawdb.ReadFirstQueueIndexNotInL2Block(bc.db, block.Hash()); index == nil { + rawdb.WriteFirstQueueIndexNotInL2Block(blockBatch, block.Hash(), *queueIndex+uint64(block.NumL1MessagesProcessed(*queueIndex))) + } if err := blockBatch.Write(); err != nil { log.Crit("Failed to write block into disk", "err", err) diff --git a/core/blockchain_repair_test.go b/core/blockchain_repair_test.go index 8e846cf007..79aa52d4a0 100644 --- a/core/blockchain_repair_test.go +++ b/core/blockchain_repair_test.go @@ -1783,7 +1783,7 @@ func testRepair(t *testing.T, tt *rewindTest, snapshots bool) { config.SnapshotLimit = 256 config.SnapshotWait = true } - chain, err := NewBlockChain(db, config, params.AllEthashProtocolChanges, engine, vm.Config{}, nil, nil) + chain, err := NewBlockChain(db, config, params.AllEthashProtocolChanges, engine, vm.Config{}, nil, nil, false) if err != nil { t.Fatalf("Failed to create chain: %v", err) } @@ -1836,7 +1836,7 @@ func testRepair(t *testing.T, tt *rewindTest, snapshots bool) { } defer db.Close() - chain, err = NewBlockChain(db, nil, params.AllEthashProtocolChanges, engine, vm.Config{}, nil, nil) + chain, err = NewBlockChain(db, nil, params.AllEthashProtocolChanges, engine, vm.Config{}, nil, nil, false) if err != nil { t.Fatalf("Failed to recreate chain: %v", err) } @@ -1907,7 +1907,7 @@ func TestIssue23496(t *testing.T) { SnapshotWait: true, } ) - chain, err := NewBlockChain(db, config, params.AllEthashProtocolChanges, engine, vm.Config{}, nil, nil) + chain, err := NewBlockChain(db, config, params.AllEthashProtocolChanges, engine, vm.Config{}, nil, nil, false) if err != nil { t.Fatalf("Failed to create chain: %v", err) } @@ -1951,7 +1951,7 @@ func TestIssue23496(t *testing.T) { } defer db.Close() - chain, err = NewBlockChain(db, nil, params.AllEthashProtocolChanges, engine, vm.Config{}, nil, nil) + chain, err = NewBlockChain(db, nil, params.AllEthashProtocolChanges, engine, vm.Config{}, nil, nil, false) if err != nil { t.Fatalf("Failed to recreate chain: %v", err) } diff --git a/core/blockchain_sethead_test.go b/core/blockchain_sethead_test.go index 986ddd7c39..1ddf2476f8 100644 --- a/core/blockchain_sethead_test.go +++ b/core/blockchain_sethead_test.go @@ -1982,7 +1982,7 @@ func testSetHead(t *testing.T, tt *rewindTest, snapshots bool) { config.SnapshotLimit = 256 config.SnapshotWait = true } - chain, err := NewBlockChain(db, config, params.AllEthashProtocolChanges, engine, vm.Config{}, nil, nil) + chain, err := NewBlockChain(db, config, params.AllEthashProtocolChanges, engine, vm.Config{}, nil, nil, false) if err != nil { t.Fatalf("Failed to create chain: %v", err) } diff --git a/core/blockchain_snapshot_test.go b/core/blockchain_snapshot_test.go index 4becdf9f4e..29e179056d 100644 --- a/core/blockchain_snapshot_test.go +++ b/core/blockchain_snapshot_test.go @@ -80,7 +80,7 @@ func (basic *snapshotTestBasic) prepare(t *testing.T) (*BlockChain, []*types.Blo // will happen during the block insertion. cacheConfig = defaultCacheConfig ) - chain, err := NewBlockChain(db, cacheConfig, params.AllEthashProtocolChanges, engine, vm.Config{}, nil, nil) + chain, err := NewBlockChain(db, cacheConfig, params.AllEthashProtocolChanges, engine, vm.Config{}, nil, nil, false) if err != nil { t.Fatalf("Failed to create chain: %v", err) } @@ -223,7 +223,7 @@ func (snaptest *snapshotTest) test(t *testing.T) { // Restart the chain normally chain.Stop() - newchain, err := NewBlockChain(snaptest.db, nil, params.AllEthashProtocolChanges, snaptest.engine, vm.Config{}, nil, nil) + newchain, err := NewBlockChain(snaptest.db, nil, params.AllEthashProtocolChanges, snaptest.engine, vm.Config{}, nil, nil, false) if err != nil { t.Fatalf("Failed to recreate chain: %v", err) } @@ -259,13 +259,13 @@ func (snaptest *crashSnapshotTest) test(t *testing.T) { // the crash, we do restart twice here: one after the crash and one // after the normal stop. It's used to ensure the broken snapshot // can be detected all the time. - newchain, err := NewBlockChain(newdb, nil, params.AllEthashProtocolChanges, snaptest.engine, vm.Config{}, nil, nil) + newchain, err := NewBlockChain(newdb, nil, params.AllEthashProtocolChanges, snaptest.engine, vm.Config{}, nil, nil, false) if err != nil { t.Fatalf("Failed to recreate chain: %v", err) } newchain.Stop() - newchain, err = NewBlockChain(newdb, nil, params.AllEthashProtocolChanges, snaptest.engine, vm.Config{}, nil, nil) + newchain, err = NewBlockChain(newdb, nil, params.AllEthashProtocolChanges, snaptest.engine, vm.Config{}, nil, nil, false) if err != nil { t.Fatalf("Failed to recreate chain: %v", err) } @@ -301,7 +301,7 @@ func (snaptest *gappedSnapshotTest) test(t *testing.T) { TrieTimeLimit: 5 * time.Minute, SnapshotLimit: 0, } - newchain, err := NewBlockChain(snaptest.db, cacheConfig, params.AllEthashProtocolChanges, snaptest.engine, vm.Config{}, nil, nil) + newchain, err := NewBlockChain(snaptest.db, cacheConfig, params.AllEthashProtocolChanges, snaptest.engine, vm.Config{}, nil, nil, false) if err != nil { t.Fatalf("Failed to recreate chain: %v", err) } @@ -309,7 +309,7 @@ func (snaptest *gappedSnapshotTest) test(t *testing.T) { newchain.Stop() // Restart the chain with enabling the snapshot - newchain, err = NewBlockChain(snaptest.db, nil, params.AllEthashProtocolChanges, snaptest.engine, vm.Config{}, nil, nil) + newchain, err = NewBlockChain(snaptest.db, nil, params.AllEthashProtocolChanges, snaptest.engine, vm.Config{}, nil, nil, false) if err != nil { t.Fatalf("Failed to recreate chain: %v", err) } @@ -337,7 +337,7 @@ func (snaptest *setHeadSnapshotTest) test(t *testing.T) { chain.SetHead(snaptest.setHead) chain.Stop() - newchain, err := NewBlockChain(snaptest.db, nil, params.AllEthashProtocolChanges, snaptest.engine, vm.Config{}, nil, nil) + newchain, err := NewBlockChain(snaptest.db, nil, params.AllEthashProtocolChanges, snaptest.engine, vm.Config{}, nil, nil, false) if err != nil { t.Fatalf("Failed to recreate chain: %v", err) } @@ -368,7 +368,7 @@ func (snaptest *restartCrashSnapshotTest) test(t *testing.T) { // and state committed. chain.Stop() - newchain, err := NewBlockChain(snaptest.db, nil, params.AllEthashProtocolChanges, snaptest.engine, vm.Config{}, nil, nil) + newchain, err := NewBlockChain(snaptest.db, nil, params.AllEthashProtocolChanges, snaptest.engine, vm.Config{}, nil, nil, false) if err != nil { t.Fatalf("Failed to recreate chain: %v", err) } @@ -385,7 +385,7 @@ func (snaptest *restartCrashSnapshotTest) test(t *testing.T) { // journal and latest state will be committed // Restart the chain after the crash - newchain, err = NewBlockChain(snaptest.db, nil, params.AllEthashProtocolChanges, snaptest.engine, vm.Config{}, nil, nil) + newchain, err = NewBlockChain(snaptest.db, nil, params.AllEthashProtocolChanges, snaptest.engine, vm.Config{}, nil, nil, false) if err != nil { t.Fatalf("Failed to recreate chain: %v", err) } @@ -420,7 +420,7 @@ func (snaptest *wipeCrashSnapshotTest) test(t *testing.T) { TrieTimeLimit: 5 * time.Minute, SnapshotLimit: 0, } - newchain, err := NewBlockChain(snaptest.db, config, params.AllEthashProtocolChanges, snaptest.engine, vm.Config{}, nil, nil) + newchain, err := NewBlockChain(snaptest.db, config, params.AllEthashProtocolChanges, snaptest.engine, vm.Config{}, nil, nil, false) if err != nil { t.Fatalf("Failed to recreate chain: %v", err) } @@ -436,13 +436,13 @@ func (snaptest *wipeCrashSnapshotTest) test(t *testing.T) { SnapshotLimit: 256, SnapshotWait: false, // Don't wait rebuild } - newchain, err = NewBlockChain(snaptest.db, config, params.AllEthashProtocolChanges, snaptest.engine, vm.Config{}, nil, nil) + newchain, err = NewBlockChain(snaptest.db, config, params.AllEthashProtocolChanges, snaptest.engine, vm.Config{}, nil, nil, false) if err != nil { t.Fatalf("Failed to recreate chain: %v", err) } // Simulate the blockchain crash. - newchain, err = NewBlockChain(snaptest.db, nil, params.AllEthashProtocolChanges, snaptest.engine, vm.Config{}, nil, nil) + newchain, err = NewBlockChain(snaptest.db, nil, params.AllEthashProtocolChanges, snaptest.engine, vm.Config{}, nil, nil, false) if err != nil { t.Fatalf("Failed to recreate chain: %v", err) } diff --git a/core/blockchain_test.go b/core/blockchain_test.go index 2bd033ca7f..cc33bf9202 100644 --- a/core/blockchain_test.go +++ b/core/blockchain_test.go @@ -58,7 +58,7 @@ func newCanonical(engine consensus.Engine, n int, full bool) (ethdb.Database, *B ) // Initialize a fresh chain with only a genesis block - blockchain, _ := NewBlockChain(db, nil, params.AllEthashProtocolChanges, engine, vm.Config{}, nil, nil) + blockchain, _ := NewBlockChain(db, nil, params.AllEthashProtocolChanges, engine, vm.Config{}, nil, nil, false) // Create and inject the requested chain if n == 0 { return db, blockchain, nil @@ -524,7 +524,7 @@ func testReorgBadHashes(t *testing.T, full bool) { blockchain.Stop() // Create a new BlockChain and check that it rolled back the state. - ncm, err := NewBlockChain(blockchain.db, nil, blockchain.chainConfig, ethash.NewFaker(), vm.Config{}, nil, nil) + ncm, err := NewBlockChain(blockchain.db, nil, blockchain.chainConfig, ethash.NewFaker(), vm.Config{}, nil, nil, false) if err != nil { t.Fatalf("failed to create new chain manager: %v", err) } @@ -637,7 +637,7 @@ func TestFastVsFullChains(t *testing.T) { // Import the chain as an archive node for the comparison baseline archiveDb := rawdb.NewMemoryDatabase() gspec.MustCommit(archiveDb) - archive, _ := NewBlockChain(archiveDb, nil, gspec.Config, ethash.NewFaker(), vm.Config{}, nil, nil) + archive, _ := NewBlockChain(archiveDb, nil, gspec.Config, ethash.NewFaker(), vm.Config{}, nil, nil, false) defer archive.Stop() if n, err := archive.InsertChain(blocks); err != nil { @@ -646,7 +646,7 @@ func TestFastVsFullChains(t *testing.T) { // Fast import the chain as a non-archive node to test fastDb := rawdb.NewMemoryDatabase() gspec.MustCommit(fastDb) - fast, _ := NewBlockChain(fastDb, nil, gspec.Config, ethash.NewFaker(), vm.Config{}, nil, nil) + fast, _ := NewBlockChain(fastDb, nil, gspec.Config, ethash.NewFaker(), vm.Config{}, nil, nil, false) defer fast.Stop() headers := make([]*types.Header, len(blocks)) @@ -670,7 +670,7 @@ func TestFastVsFullChains(t *testing.T) { t.Fatalf("failed to create temp freezer db: %v", err) } gspec.MustCommit(ancientDb) - ancient, _ := NewBlockChain(ancientDb, nil, gspec.Config, ethash.NewFaker(), vm.Config{}, nil, nil) + ancient, _ := NewBlockChain(ancientDb, nil, gspec.Config, ethash.NewFaker(), vm.Config{}, nil, nil, false) defer ancient.Stop() if n, err := ancient.InsertHeaderChain(headers, 1); err != nil { @@ -792,7 +792,7 @@ func TestLightVsFastVsFullChainHeads(t *testing.T) { archiveCaching := *defaultCacheConfig archiveCaching.TrieDirtyDisabled = true - archive, _ := NewBlockChain(archiveDb, &archiveCaching, gspec.Config, ethash.NewFaker(), vm.Config{}, nil, nil) + archive, _ := NewBlockChain(archiveDb, &archiveCaching, gspec.Config, ethash.NewFaker(), vm.Config{}, nil, nil, false) if n, err := archive.InsertChain(blocks); err != nil { t.Fatalf("failed to process block %d: %v", n, err) } @@ -805,7 +805,7 @@ func TestLightVsFastVsFullChainHeads(t *testing.T) { // Import the chain as a non-archive node and ensure all pointers are updated fastDb, delfn := makeDb() defer delfn() - fast, _ := NewBlockChain(fastDb, nil, gspec.Config, ethash.NewFaker(), vm.Config{}, nil, nil) + fast, _ := NewBlockChain(fastDb, nil, gspec.Config, ethash.NewFaker(), vm.Config{}, nil, nil, false) defer fast.Stop() headers := make([]*types.Header, len(blocks)) @@ -825,7 +825,7 @@ func TestLightVsFastVsFullChainHeads(t *testing.T) { // Import the chain as a ancient-first node and ensure all pointers are updated ancientDb, delfn := makeDb() defer delfn() - ancient, _ := NewBlockChain(ancientDb, nil, gspec.Config, ethash.NewFaker(), vm.Config{}, nil, nil) + ancient, _ := NewBlockChain(ancientDb, nil, gspec.Config, ethash.NewFaker(), vm.Config{}, nil, nil, false) defer ancient.Stop() if n, err := ancient.InsertHeaderChain(headers, 1); err != nil { @@ -844,7 +844,7 @@ func TestLightVsFastVsFullChainHeads(t *testing.T) { // Import the chain as a light node and ensure all pointers are updated lightDb, delfn := makeDb() defer delfn() - light, _ := NewBlockChain(lightDb, nil, gspec.Config, ethash.NewFaker(), vm.Config{}, nil, nil) + light, _ := NewBlockChain(lightDb, nil, gspec.Config, ethash.NewFaker(), vm.Config{}, nil, nil, false) if n, err := light.InsertHeaderChain(headers, 1); err != nil { t.Fatalf("failed to insert header %d: %v", n, err) } @@ -913,7 +913,7 @@ func TestChainTxReorgs(t *testing.T) { } }) // Import the chain. This runs all block validation rules. - blockchain, _ := NewBlockChain(db, nil, gspec.Config, ethash.NewFaker(), vm.Config{}, nil, nil) + blockchain, _ := NewBlockChain(db, nil, gspec.Config, ethash.NewFaker(), vm.Config{}, nil, nil, false) if i, err := blockchain.InsertChain(chain); err != nil { t.Fatalf("failed to insert original chain[%d]: %v", i, err) } @@ -983,7 +983,7 @@ func TestLogReorgs(t *testing.T) { signer = types.LatestSigner(gspec.Config) ) - blockchain, _ := NewBlockChain(db, nil, gspec.Config, ethash.NewFaker(), vm.Config{}, nil, nil) + blockchain, _ := NewBlockChain(db, nil, gspec.Config, ethash.NewFaker(), vm.Config{}, nil, nil, false) defer blockchain.Stop() rmLogsCh := make(chan RemovedLogsEvent) @@ -1036,7 +1036,7 @@ func TestLogRebirth(t *testing.T) { genesis = gspec.MustCommit(db) signer = types.LatestSigner(gspec.Config) engine = ethash.NewFaker() - blockchain, _ = NewBlockChain(db, nil, gspec.Config, engine, vm.Config{}, nil, nil) + blockchain, _ = NewBlockChain(db, nil, gspec.Config, engine, vm.Config{}, nil, nil, false) ) defer blockchain.Stop() @@ -1099,7 +1099,7 @@ func TestSideLogRebirth(t *testing.T) { gspec = &Genesis{Config: params.TestChainConfig, Alloc: GenesisAlloc{addr1: {Balance: big.NewInt(10000000000000000)}}} genesis = gspec.MustCommit(db) signer = types.LatestSigner(gspec.Config) - blockchain, _ = NewBlockChain(db, nil, gspec.Config, ethash.NewFaker(), vm.Config{}, nil, nil) + blockchain, _ = NewBlockChain(db, nil, gspec.Config, ethash.NewFaker(), vm.Config{}, nil, nil, false) ) defer blockchain.Stop() @@ -1174,7 +1174,7 @@ func TestReorgSideEvent(t *testing.T) { signer = types.LatestSigner(gspec.Config) ) - blockchain, _ := NewBlockChain(db, nil, gspec.Config, ethash.NewFaker(), vm.Config{}, nil, nil) + blockchain, _ := NewBlockChain(db, nil, gspec.Config, ethash.NewFaker(), vm.Config{}, nil, nil, false) defer blockchain.Stop() chain, _ := GenerateChain(gspec.Config, genesis, ethash.NewFaker(), db, 3, func(i int, gen *BlockGen) {}) @@ -1306,7 +1306,7 @@ func TestEIP155Transition(t *testing.T) { genesis = gspec.MustCommit(db) ) - blockchain, _ := NewBlockChain(db, nil, gspec.Config, ethash.NewFaker(), vm.Config{}, nil, nil) + blockchain, _ := NewBlockChain(db, nil, gspec.Config, ethash.NewFaker(), vm.Config{}, nil, nil, false) defer blockchain.Stop() blocks, _ := GenerateChain(gspec.Config, genesis, ethash.NewFaker(), db, 4, func(i int, block *BlockGen) { @@ -1414,7 +1414,7 @@ func TestEIP161AccountRemoval(t *testing.T) { } genesis = gspec.MustCommit(db) ) - blockchain, _ := NewBlockChain(db, nil, gspec.Config, ethash.NewFaker(), vm.Config{}, nil, nil) + blockchain, _ := NewBlockChain(db, nil, gspec.Config, ethash.NewFaker(), vm.Config{}, nil, nil, false) defer blockchain.Stop() blocks, _ := GenerateChain(gspec.Config, genesis, ethash.NewFaker(), db, 3, func(i int, block *BlockGen) { @@ -1489,7 +1489,7 @@ func TestBlockchainHeaderchainReorgConsistency(t *testing.T) { diskdb := rawdb.NewMemoryDatabase() (&Genesis{BaseFee: big.NewInt(params.InitialBaseFee)}).MustCommit(diskdb) - chain, err := NewBlockChain(diskdb, nil, params.TestChainConfig, engine, vm.Config{}, nil, nil) + chain, err := NewBlockChain(diskdb, nil, params.TestChainConfig, engine, vm.Config{}, nil, nil, false) if err != nil { t.Fatalf("failed to create tester chain: %v", err) } @@ -1533,7 +1533,7 @@ func TestTrieForkGC(t *testing.T) { diskdb := rawdb.NewMemoryDatabase() (&Genesis{BaseFee: big.NewInt(params.InitialBaseFee)}).MustCommit(diskdb) - chain, err := NewBlockChain(diskdb, nil, params.TestChainConfig, engine, vm.Config{}, nil, nil) + chain, err := NewBlockChain(diskdb, nil, params.TestChainConfig, engine, vm.Config{}, nil, nil, false) if err != nil { t.Fatalf("failed to create tester chain: %v", err) } @@ -1572,7 +1572,7 @@ func TestLargeReorgTrieGC(t *testing.T) { diskdb := rawdb.NewMemoryDatabase() (&Genesis{BaseFee: big.NewInt(params.InitialBaseFee)}).MustCommit(diskdb) - chain, err := NewBlockChain(diskdb, nil, params.TestChainConfig, engine, vm.Config{}, nil, nil) + chain, err := NewBlockChain(diskdb, nil, params.TestChainConfig, engine, vm.Config{}, nil, nil, false) if err != nil { t.Fatalf("failed to create tester chain: %v", err) } @@ -1633,7 +1633,7 @@ func TestBlockchainRecovery(t *testing.T) { t.Fatalf("failed to create temp freezer db: %v", err) } gspec.MustCommit(ancientDb) - ancient, _ := NewBlockChain(ancientDb, nil, gspec.Config, ethash.NewFaker(), vm.Config{}, nil, nil) + ancient, _ := NewBlockChain(ancientDb, nil, gspec.Config, ethash.NewFaker(), vm.Config{}, nil, nil, false) headers := make([]*types.Header, len(blocks)) for i, block := range blocks { @@ -1653,7 +1653,7 @@ func TestBlockchainRecovery(t *testing.T) { rawdb.WriteHeadFastBlockHash(ancientDb, midBlock.Hash()) // Reopen broken blockchain again - ancient, _ = NewBlockChain(ancientDb, nil, gspec.Config, ethash.NewFaker(), vm.Config{}, nil, nil) + ancient, _ = NewBlockChain(ancientDb, nil, gspec.Config, ethash.NewFaker(), vm.Config{}, nil, nil, false) defer ancient.Stop() if num := ancient.CurrentBlock().NumberU64(); num != 0 { t.Errorf("head block mismatch: have #%v, want #%v", num, 0) @@ -1705,7 +1705,7 @@ func TestInsertReceiptChainRollback(t *testing.T) { } gspec := Genesis{Config: params.AllEthashProtocolChanges} gspec.MustCommit(ancientDb) - ancientChain, _ := NewBlockChain(ancientDb, nil, gspec.Config, ethash.NewFaker(), vm.Config{}, nil, nil) + ancientChain, _ := NewBlockChain(ancientDb, nil, gspec.Config, ethash.NewFaker(), vm.Config{}, nil, nil, false) defer ancientChain.Stop() // Import the canonical header chain. @@ -1766,7 +1766,7 @@ func TestLowDiffLongChain(t *testing.T) { diskdb := rawdb.NewMemoryDatabase() (&Genesis{BaseFee: big.NewInt(params.InitialBaseFee)}).MustCommit(diskdb) - chain, err := NewBlockChain(diskdb, nil, params.TestChainConfig, engine, vm.Config{}, nil, nil) + chain, err := NewBlockChain(diskdb, nil, params.TestChainConfig, engine, vm.Config{}, nil, nil, false) if err != nil { t.Fatalf("failed to create tester chain: %v", err) } @@ -1813,7 +1813,7 @@ func testSideImport(t *testing.T, numCanonBlocksInSidechain, blocksBetweenCommon blocks, _ := GenerateChain(params.TestChainConfig, genesis, engine, db, 2*TriesInMemory, nil) diskdb := rawdb.NewMemoryDatabase() (&Genesis{BaseFee: big.NewInt(params.InitialBaseFee)}).MustCommit(diskdb) - chain, err := NewBlockChain(diskdb, nil, params.TestChainConfig, engine, vm.Config{}, nil, nil) + chain, err := NewBlockChain(diskdb, nil, params.TestChainConfig, engine, vm.Config{}, nil, nil, false) if err != nil { t.Fatalf("failed to create tester chain: %v", err) } @@ -1910,7 +1910,7 @@ func testInsertKnownChainData(t *testing.T, typ string) { (&Genesis{BaseFee: big.NewInt(params.InitialBaseFee)}).MustCommit(chaindb) defer os.RemoveAll(dir) - chain, err := NewBlockChain(chaindb, nil, params.TestChainConfig, engine, vm.Config{}, nil, nil) + chain, err := NewBlockChain(chaindb, nil, params.TestChainConfig, engine, vm.Config{}, nil, nil, false) if err != nil { t.Fatalf("failed to create tester chain: %v", err) } @@ -2019,7 +2019,7 @@ func getLongAndShortChains() (bc *BlockChain, longChain []*types.Block, heavyCha diskdb := rawdb.NewMemoryDatabase() (&Genesis{BaseFee: big.NewInt(params.InitialBaseFee)}).MustCommit(diskdb) - chain, err := NewBlockChain(diskdb, nil, params.TestChainConfig, engine, vm.Config{}, nil, nil) + chain, err := NewBlockChain(diskdb, nil, params.TestChainConfig, engine, vm.Config{}, nil, nil, false) if err != nil { return nil, nil, nil, fmt.Errorf("failed to create tester chain: %v", err) } @@ -2212,7 +2212,7 @@ func TestTransactionIndices(t *testing.T) { // Import all blocks into ancient db l := uint64(0) - chain, err := NewBlockChain(ancientDb, nil, params.TestChainConfig, ethash.NewFaker(), vm.Config{}, nil, &l) + chain, err := NewBlockChain(ancientDb, nil, params.TestChainConfig, ethash.NewFaker(), vm.Config{}, nil, &l, false) if err != nil { t.Fatalf("failed to create tester chain: %v", err) } @@ -2237,7 +2237,7 @@ func TestTransactionIndices(t *testing.T) { t.Fatalf("failed to create temp freezer db: %v", err) } gspec.MustCommit(ancientDb) - chain, err = NewBlockChain(ancientDb, nil, params.TestChainConfig, ethash.NewFaker(), vm.Config{}, nil, &l) + chain, err = NewBlockChain(ancientDb, nil, params.TestChainConfig, ethash.NewFaker(), vm.Config{}, nil, &l, false) if err != nil { t.Fatalf("failed to create tester chain: %v", err) } @@ -2261,7 +2261,7 @@ func TestTransactionIndices(t *testing.T) { limit = []uint64{0, 64 /* drop stale */, 32 /* shorten history */, 64 /* extend history */, 0 /* restore all */} tails := []uint64{0, 67 /* 130 - 64 + 1 */, 100 /* 131 - 32 + 1 */, 69 /* 132 - 64 + 1 */, 0} for i, l := range limit { - chain, err = NewBlockChain(ancientDb, nil, params.TestChainConfig, ethash.NewFaker(), vm.Config{}, nil, &l) + chain, err = NewBlockChain(ancientDb, nil, params.TestChainConfig, ethash.NewFaker(), vm.Config{}, nil, &l, false) if err != nil { t.Fatalf("failed to create tester chain: %v", err) } @@ -2339,7 +2339,7 @@ func TestSkipStaleTxIndicesInFastSync(t *testing.T) { // Import all blocks into ancient db, only HEAD-32 indices are kept. l := uint64(32) - chain, err := NewBlockChain(ancientDb, nil, params.TestChainConfig, ethash.NewFaker(), vm.Config{}, nil, &l) + chain, err := NewBlockChain(ancientDb, nil, params.TestChainConfig, ethash.NewFaker(), vm.Config{}, nil, &l, false) if err != nil { t.Fatalf("failed to create tester chain: %v", err) } @@ -2403,7 +2403,7 @@ func benchmarkLargeNumberOfValueToNonexisting(b *testing.B, numTxs, numBlocks in diskdb := rawdb.NewMemoryDatabase() gspec.MustCommit(diskdb) - chain, err := NewBlockChain(diskdb, nil, params.TestChainConfig, engine, vm.Config{}, nil, nil) + chain, err := NewBlockChain(diskdb, nil, params.TestChainConfig, engine, vm.Config{}, nil, nil, false) if err != nil { b.Fatalf("failed to create tester chain: %v", err) } @@ -2485,7 +2485,7 @@ func TestSideImportPrunedBlocks(t *testing.T) { blocks, _ := GenerateChain(params.TestChainConfig, genesis, engine, db, 2*TriesInMemory, nil) diskdb := rawdb.NewMemoryDatabase() (&Genesis{BaseFee: big.NewInt(params.InitialBaseFee)}).MustCommit(diskdb) - chain, err := NewBlockChain(diskdb, nil, params.TestChainConfig, engine, vm.Config{}, nil, nil) + chain, err := NewBlockChain(diskdb, nil, params.TestChainConfig, engine, vm.Config{}, nil, nil, false) if err != nil { t.Fatalf("failed to create tester chain: %v", err) } @@ -2625,7 +2625,7 @@ func TestDeleteCreateRevert(t *testing.T) { diskdb := rawdb.NewMemoryDatabase() gspec.MustCommit(diskdb) - chain, err := NewBlockChain(diskdb, nil, params.TestChainConfig, engine, vm.Config{}, nil, nil) + chain, err := NewBlockChain(diskdb, nil, params.TestChainConfig, engine, vm.Config{}, nil, nil, false) if err != nil { t.Fatalf("failed to create tester chain: %v", err) } @@ -2730,7 +2730,7 @@ func TestInitThenFailCreateContract(t *testing.T) { chain, err := NewBlockChain(diskdb, nil, params.TestChainConfig, engine, vm.Config{ //Debug: true, //Tracer: vm.NewJSONLogger(nil, os.Stdout), - }, nil, nil) + }, nil, nil, false) if err != nil { t.Fatalf("failed to create tester chain: %v", err) } @@ -2817,7 +2817,7 @@ func TestEIP2718Transition(t *testing.T) { diskdb := rawdb.NewMemoryDatabase() gspec.MustCommit(diskdb) - chain, err := NewBlockChain(diskdb, nil, gspec.Config, engine, vm.Config{}, nil, nil) + chain, err := NewBlockChain(diskdb, nil, gspec.Config, engine, vm.Config{}, nil, nil, false) if err != nil { t.Fatalf("failed to create tester chain: %v", err) } @@ -2912,7 +2912,7 @@ func TestEIP1559Transition(t *testing.T) { diskdb := rawdb.NewMemoryDatabase() gspec.MustCommit(diskdb) - chain, err := NewBlockChain(diskdb, nil, gspec.Config, engine, vm.Config{}, nil, nil) + chain, err := NewBlockChain(diskdb, nil, gspec.Config, engine, vm.Config{}, nil, nil, false) if err != nil { t.Fatalf("failed to create tester chain: %v", err) } @@ -3036,7 +3036,7 @@ func TestPoseidonCodeHash(t *testing.T) { genesis = gspec.MustCommit(db) signer = types.LatestSigner(gspec.Config) engine = ethash.NewFaker() - blockchain, _ = NewBlockChain(db, nil, gspec.Config, engine, vm.Config{}, nil, nil) + blockchain, _ = NewBlockChain(db, nil, gspec.Config, engine, vm.Config{}, nil, nil, false) ) defer blockchain.Stop() @@ -3150,7 +3150,7 @@ func TestFeeVault(t *testing.T) { diskdb := rawdb.NewMemoryDatabase() gspec.MustCommit(diskdb) - chain, err := NewBlockChain(diskdb, nil, gspec.Config, engine, vm.Config{}, nil, nil) + chain, err := NewBlockChain(diskdb, nil, gspec.Config, engine, vm.Config{}, nil, nil, false) if err != nil { t.Fatalf("failed to create tester chain: %v", err) } @@ -3202,7 +3202,7 @@ func TestTransactionCountLimit(t *testing.T) { } // Initialize blockchain - blockchain, err := NewBlockChain(db, nil, config, engine, vm.Config{}, nil, nil) + blockchain, err := NewBlockChain(db, nil, config, engine, vm.Config{}, nil, nil, false) if err != nil { t.Fatalf("failed to create new chain manager: %v", err) } @@ -3266,7 +3266,7 @@ func TestInsertBlocksWithL1Messages(t *testing.T) { rawdb.WriteL1Messages(db, msgs) // initialize blockchain - blockchain, _ := NewBlockChain(db, nil, config, engine, vm.Config{}, nil, nil) + blockchain, _ := NewBlockChain(db, nil, config, engine, vm.Config{}, nil, nil, false) defer blockchain.Stop() // generate blocks with 1 L1 message in each @@ -3302,6 +3302,42 @@ func TestInsertBlocksWithL1Messages(t *testing.T) { queueIndex = rawdb.ReadFirstQueueIndexNotInL2Block(db, blocks[len(blocks)-1].Hash()) assert.NotNil(t, queueIndex) assert.Equal(t, uint64(len(msgs)), *queueIndex) + + // generate block with messages #1 and #2 skipped + blocks, _ = GenerateChain(config, genesis, engine, db, 1, func(_ int, b *BlockGen) { + tx := types.NewTx(&msgs[0]) + b.AddTxWithChain(blockchain, tx) + tx = types.NewTx(&msgs[3]) + b.AddTxWithChain(blockchain, tx) + }) + + // insert blocks, validation should pass + index, err = blockchain.InsertChain(blocks) + assert.Nil(t, err) + assert.Equal(t, 1, index) + + // L1 message DB should be updated + queueIndex = rawdb.ReadFirstQueueIndexNotInL2Block(db, blocks[0].Hash()) + assert.NotNil(t, queueIndex) + assert.Equal(t, uint64(len(msgs)), *queueIndex) + + // generate block with messages #0 and #1 skipped + blocks, _ = GenerateChain(config, genesis, engine, db, 1, func(_ int, b *BlockGen) { + tx := types.NewTx(&msgs[2]) + b.AddTxWithChain(blockchain, tx) + tx = types.NewTx(&msgs[3]) + b.AddTxWithChain(blockchain, tx) + }) + + // insert blocks, validation should pass + index, err = blockchain.InsertChain(blocks) + assert.Nil(t, err) + assert.Equal(t, 1, index) + + // L1 message DB should be updated + queueIndex = rawdb.ReadFirstQueueIndexNotInL2Block(db, blocks[0].Hash()) + assert.NotNil(t, queueIndex) + assert.Equal(t, uint64(len(msgs)), *queueIndex) } // TestL1MessageValidationFailure tests that the chain rejects blocks with incorrect L1MessageTx transactions. @@ -3336,7 +3372,7 @@ func TestL1MessageValidationFailure(t *testing.T) { rawdb.WriteL1Messages(db, msgs) // initialize blockchain - blockchain, _ := NewBlockChain(db, nil, config, engine, vm.Config{}, nil, nil) + blockchain, _ := NewBlockChain(db, nil, config, engine, vm.Config{}, nil, nil, false) defer blockchain.Stop() generateBlock := func(txs []*types.Transaction) ([]*types.Block, []types.Receipts) { @@ -3347,24 +3383,10 @@ func TestL1MessageValidationFailure(t *testing.T) { }) } - // skip #0 - blocks, _ := generateBlock([]*types.Transaction{types.NewTx(&msgs[1])}) - index, err := blockchain.InsertChain(blocks) - assert.Equal(t, 0, index) - assert.Equal(t, consensus.ErrInvalidL1MessageOrder, err) - assert.Equal(t, big.NewInt(0), blockchain.CurrentBlock().Number()) - - // skip #1 - blocks, _ = generateBlock([]*types.Transaction{types.NewTx(&msgs[0]), types.NewTx(&msgs[2])}) - index, err = blockchain.InsertChain(blocks) - assert.Equal(t, 0, index) - assert.Equal(t, consensus.ErrInvalidL1MessageOrder, err) - assert.Equal(t, big.NewInt(0), blockchain.CurrentBlock().Number()) - // L2 tx precedes L1 message tx tx, _ := types.SignTx(types.NewTransaction(0, common.Address{0x00}, new(big.Int), params.TxGas, genspec.BaseFee, nil), signer, key) - blocks, _ = generateBlock([]*types.Transaction{tx, types.NewTx(&msgs[0])}) - index, err = blockchain.InsertChain(blocks) + blocks, _ := generateBlock([]*types.Transaction{tx, types.NewTx(&msgs[0])}) + index, err := blockchain.InsertChain(blocks) assert.Equal(t, 0, index) assert.Equal(t, consensus.ErrInvalidL1MessageOrder, err) assert.Equal(t, big.NewInt(0), blockchain.CurrentBlock().Number()) @@ -3425,7 +3447,7 @@ func TestBlockPayloadSizeLimit(t *testing.T) { } // Initialize blockchain - blockchain, err := NewBlockChain(db, nil, config, engine, vm.Config{}, nil, nil) + blockchain, err := NewBlockChain(db, nil, config, engine, vm.Config{}, nil, nil, false) if err != nil { t.Fatalf("failed to create new chain manager: %v", err) } @@ -3537,7 +3559,7 @@ func TestEIP3651(t *testing.T) { } b.AddTx(tx) }) - chain, err := NewBlockChain(db, nil, gspec.Config, engine, vm.Config{}, nil, nil) + chain, err := NewBlockChain(db, nil, gspec.Config, engine, vm.Config{}, nil, nil, false) if err != nil { t.Fatalf("failed to create tester chain: %v", err) } diff --git a/core/chain_makers_test.go b/core/chain_makers_test.go index 78fcdae5c7..93cf3ce381 100644 --- a/core/chain_makers_test.go +++ b/core/chain_makers_test.go @@ -79,7 +79,7 @@ func ExampleGenerateChain() { }) // Import the chain. This runs all block validation rules. - blockchain, _ := NewBlockChain(db, nil, gspec.Config, ethash.NewFaker(), vm.Config{}, nil, nil) + blockchain, _ := NewBlockChain(db, nil, gspec.Config, ethash.NewFaker(), vm.Config{}, nil, nil, false) defer blockchain.Stop() if i, err := blockchain.InsertChain(chain); err != nil { diff --git a/core/dao_test.go b/core/dao_test.go index 6f221973b8..680302f463 100644 --- a/core/dao_test.go +++ b/core/dao_test.go @@ -45,7 +45,7 @@ func TestDAOForkRangeExtradata(t *testing.T) { proConf.DAOForkBlock = forkBlock proConf.DAOForkSupport = true - proBc, _ := NewBlockChain(proDb, nil, &proConf, ethash.NewFaker(), vm.Config{}, nil, nil) + proBc, _ := NewBlockChain(proDb, nil, &proConf, ethash.NewFaker(), vm.Config{}, nil, nil, false) defer proBc.Stop() conDb := rawdb.NewMemoryDatabase() @@ -55,7 +55,7 @@ func TestDAOForkRangeExtradata(t *testing.T) { conConf.DAOForkBlock = forkBlock conConf.DAOForkSupport = false - conBc, _ := NewBlockChain(conDb, nil, &conConf, ethash.NewFaker(), vm.Config{}, nil, nil) + conBc, _ := NewBlockChain(conDb, nil, &conConf, ethash.NewFaker(), vm.Config{}, nil, nil, false) defer conBc.Stop() if _, err := proBc.InsertChain(prefix); err != nil { @@ -69,7 +69,7 @@ func TestDAOForkRangeExtradata(t *testing.T) { // Create a pro-fork block, and try to feed into the no-fork chain db = rawdb.NewMemoryDatabase() gspec.MustCommit(db) - bc, _ := NewBlockChain(db, nil, &conConf, ethash.NewFaker(), vm.Config{}, nil, nil) + bc, _ := NewBlockChain(db, nil, &conConf, ethash.NewFaker(), vm.Config{}, nil, nil, false) defer bc.Stop() blocks := conBc.GetBlocksFromHash(conBc.CurrentBlock().Hash(), int(conBc.CurrentBlock().NumberU64())) @@ -94,7 +94,7 @@ func TestDAOForkRangeExtradata(t *testing.T) { // Create a no-fork block, and try to feed into the pro-fork chain db = rawdb.NewMemoryDatabase() gspec.MustCommit(db) - bc, _ = NewBlockChain(db, nil, &proConf, ethash.NewFaker(), vm.Config{}, nil, nil) + bc, _ = NewBlockChain(db, nil, &proConf, ethash.NewFaker(), vm.Config{}, nil, nil, false) defer bc.Stop() blocks = proBc.GetBlocksFromHash(proBc.CurrentBlock().Hash(), int(proBc.CurrentBlock().NumberU64())) @@ -120,7 +120,7 @@ func TestDAOForkRangeExtradata(t *testing.T) { // Verify that contra-forkers accept pro-fork extra-datas after forking finishes db = rawdb.NewMemoryDatabase() gspec.MustCommit(db) - bc, _ := NewBlockChain(db, nil, &conConf, ethash.NewFaker(), vm.Config{}, nil, nil) + bc, _ := NewBlockChain(db, nil, &conConf, ethash.NewFaker(), vm.Config{}, nil, nil, false) defer bc.Stop() blocks := conBc.GetBlocksFromHash(conBc.CurrentBlock().Hash(), int(conBc.CurrentBlock().NumberU64())) @@ -140,7 +140,7 @@ func TestDAOForkRangeExtradata(t *testing.T) { // Verify that pro-forkers accept contra-fork extra-datas after forking finishes db = rawdb.NewMemoryDatabase() gspec.MustCommit(db) - bc, _ = NewBlockChain(db, nil, &proConf, ethash.NewFaker(), vm.Config{}, nil, nil) + bc, _ = NewBlockChain(db, nil, &proConf, ethash.NewFaker(), vm.Config{}, nil, nil, false) defer bc.Stop() blocks = proBc.GetBlocksFromHash(proBc.CurrentBlock().Hash(), int(proBc.CurrentBlock().NumberU64())) diff --git a/core/genesis_test.go b/core/genesis_test.go index 02aa408fd0..e107cabaf5 100644 --- a/core/genesis_test.go +++ b/core/genesis_test.go @@ -118,7 +118,7 @@ func TestSetupGenesis(t *testing.T) { // Advance to block #4, past the homestead transition block of customg. genesis := oldcustomg.MustCommit(db) - bc, _ := NewBlockChain(db, nil, oldcustomg.Config, ethash.NewFullFaker(), vm.Config{}, nil, nil) + bc, _ := NewBlockChain(db, nil, oldcustomg.Config, ethash.NewFullFaker(), vm.Config{}, nil, nil, false) defer bc.Stop() blocks, _ := GenerateChain(oldcustomg.Config, genesis, ethash.NewFaker(), db, 4, nil) diff --git a/core/rawdb/accessors_row_consumption.go b/core/rawdb/accessors_row_consumption.go index 5d08e210a9..a737304ded 100644 --- a/core/rawdb/accessors_row_consumption.go +++ b/core/rawdb/accessors_row_consumption.go @@ -11,7 +11,11 @@ import ( ) // WriteBlockRowConsumption writes a RowConsumption of the block to the database. -func WriteBlockRowConsumption(db ethdb.KeyValueWriter, l2BlockHash common.Hash, rc types.RowConsumption) { +func WriteBlockRowConsumption(db ethdb.KeyValueWriter, l2BlockHash common.Hash, rc *types.RowConsumption) { + if rc == nil { + return + } + bytes, err := rlp.EncodeToBytes(&rc) if err != nil { log.Crit("Failed to RLP encode RowConsumption ", "err", err) diff --git a/core/rawdb/accessors_row_consumption_test.go b/core/rawdb/accessors_row_consumption_test.go index 0583f6425e..ca3dc54f17 100644 --- a/core/rawdb/accessors_row_consumption_test.go +++ b/core/rawdb/accessors_row_consumption_test.go @@ -11,9 +11,12 @@ import ( func TestReadBlockRowConsumption(t *testing.T) { l2BlockHash := common.BigToHash(big.NewInt(10)) - rc := types.RowConsumption{types.SubCircuitRowConsumption{CircuitName: "aa", Rows: 12}, types.SubCircuitRowConsumption{CircuitName: "bb", Rows: 100}} + rc := types.RowConsumption{ + types.SubCircuitRowUsage{Name: "aa", RowNumber: 12}, + types.SubCircuitRowUsage{Name: "bb", RowNumber: 100}, + } db := NewMemoryDatabase() - WriteBlockRowConsumption(db, l2BlockHash, rc) + WriteBlockRowConsumption(db, l2BlockHash, &rc) got := ReadBlockRowConsumption(db, l2BlockHash) if got == nil || !reflect.DeepEqual(rc, *got) { t.Fatal("RowConsumption mismatch", "expected", rc, "got", got) diff --git a/core/state_processor_test.go b/core/state_processor_test.go index 860c6da741..5835d5b42f 100644 --- a/core/state_processor_test.go +++ b/core/state_processor_test.go @@ -105,7 +105,7 @@ func TestStateProcessorErrors(t *testing.T) { }, } genesis = gspec.MustCommit(db) - blockchain, _ = NewBlockChain(db, nil, gspec.Config, ethash.NewFaker(), vm.Config{}, nil, nil) + blockchain, _ = NewBlockChain(db, nil, gspec.Config, ethash.NewFaker(), vm.Config{}, nil, nil, false) ) defer blockchain.Stop() bigNumber := new(big.Int).SetBytes(common.FromHex("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")) @@ -246,7 +246,7 @@ func TestStateProcessorErrors(t *testing.T) { }, } genesis = gspec.MustCommit(db) - blockchain, _ = NewBlockChain(db, nil, gspec.Config, ethash.NewFaker(), vm.Config{}, nil, nil) + blockchain, _ = NewBlockChain(db, nil, gspec.Config, ethash.NewFaker(), vm.Config{}, nil, nil, false) ) defer blockchain.Stop() for i, tt := range []struct { @@ -286,7 +286,7 @@ func TestStateProcessorErrors(t *testing.T) { }, } genesis = gspec.MustCommit(db) - blockchain, _ = NewBlockChain(db, nil, gspec.Config, ethash.NewFaker(), vm.Config{}, nil, nil) + blockchain, _ = NewBlockChain(db, nil, gspec.Config, ethash.NewFaker(), vm.Config{}, nil, nil, false) ) defer blockchain.Stop() for i, tt := range []struct { @@ -341,7 +341,7 @@ func TestStateProcessorErrors(t *testing.T) { }, } genesis = gspec.MustCommit(db) - blockchain, _ = NewBlockChain(db, nil, gspec.Config, ethash.NewFaker(), vm.Config{}, nil, nil) + blockchain, _ = NewBlockChain(db, nil, gspec.Config, ethash.NewFaker(), vm.Config{}, nil, nil, false) tooBigInitCode = [params.MaxInitCodeSize + 1]byte{} smallInitCode = [320]byte{} ) diff --git a/core/trace.go b/core/trace.go new file mode 100644 index 0000000000..50a460a4ec --- /dev/null +++ b/core/trace.go @@ -0,0 +1,493 @@ +package core + +import ( + "bytes" + "errors" + "fmt" + "runtime" + "sync" + + "github.com/scroll-tech/go-ethereum/common" + "github.com/scroll-tech/go-ethereum/common/hexutil" + "github.com/scroll-tech/go-ethereum/consensus" + "github.com/scroll-tech/go-ethereum/core/state" + "github.com/scroll-tech/go-ethereum/core/types" + "github.com/scroll-tech/go-ethereum/core/vm" + "github.com/scroll-tech/go-ethereum/log" + "github.com/scroll-tech/go-ethereum/params" + "github.com/scroll-tech/go-ethereum/rollup/fees" + "github.com/scroll-tech/go-ethereum/rollup/rcfg" + "github.com/scroll-tech/go-ethereum/rollup/withdrawtrie" + "github.com/scroll-tech/go-ethereum/trie/zkproof" +) + +type TraceEnv struct { + logConfig *vm.LogConfig + chainConfig *params.ChainConfig + + coinbase common.Address + + // rMu lock is used to protect txs executed in parallel. + signer types.Signer + state *state.StateDB + blockCtx vm.BlockContext + + // pMu lock is used to protect Proofs' read and write mutual exclusion, + // since txs are executed in parallel, so this lock is required. + pMu sync.Mutex + // sMu is required because of txs are executed in parallel, + // this lock is used to protect StorageTrace's read and write mutual exclusion. + sMu sync.Mutex + *types.StorageTrace + TxStorageTraces []*types.StorageTrace + // zktrie tracer is used for zktrie storage to build additional deletion proof + ZkTrieTracer map[string]state.ZktrieProofTracer + ExecutionResults []*types.ExecutionResult +} + +// Context is the same as Context in eth/tracers/tracers.go +type Context struct { + BlockHash common.Hash + TxIndex int + TxHash common.Hash +} + +// txTraceTask is the same as txTraceTask in eth/tracers/api.go +type txTraceTask struct { + statedb *state.StateDB + index int +} + +func CreateTraceEnv(chainConfig *params.ChainConfig, chainContext ChainContext, engine consensus.Engine, statedb *state.StateDB, parent *types.Block, block *types.Block) (*TraceEnv, error) { + var coinbase common.Address + var err error + if chainConfig.Scroll.FeeVaultEnabled() { + coinbase = *chainConfig.Scroll.FeeVaultAddress + } else { + coinbase, err = engine.Author(block.Header()) + if err != nil { + log.Warn("recover coinbase in CreateTraceEnv fail. using zero-address", "err", err, "blockNumber", block.Header().Number, "headerHash", block.Header().Hash()) + } + } + + env := &TraceEnv{ + logConfig: &vm.LogConfig{ + EnableMemory: false, + EnableReturnData: true, + }, + chainConfig: chainConfig, + coinbase: coinbase, + signer: types.MakeSigner(chainConfig, block.Number()), + state: statedb, + blockCtx: NewEVMBlockContext(block.Header(), chainContext, nil), + StorageTrace: &types.StorageTrace{ + RootBefore: parent.Root(), + RootAfter: block.Root(), + Proofs: make(map[string][]hexutil.Bytes), + StorageProofs: make(map[string]map[string][]hexutil.Bytes), + }, + ZkTrieTracer: make(map[string]state.ZktrieProofTracer), + ExecutionResults: make([]*types.ExecutionResult, block.Transactions().Len()), + TxStorageTraces: make([]*types.StorageTrace, block.Transactions().Len()), + } + + key := coinbase.String() + if _, exist := env.Proofs[key]; !exist { + proof, err := env.state.GetProof(coinbase) + if err != nil { + log.Error("Proof for coinbase not available", "coinbase", coinbase, "error", err) + // but we still mark the proofs map with nil array + } + wrappedProof := make([]hexutil.Bytes, len(proof)) + for i, bt := range proof { + wrappedProof[i] = bt + } + env.Proofs[key] = wrappedProof + } + + return env, nil +} + +func (env *TraceEnv) GetBlockTrace(block *types.Block) (*types.BlockTrace, error) { + // Execute all the transaction contained within the block concurrently + var ( + txs = block.Transactions() + pend = new(sync.WaitGroup) + jobs = make(chan *txTraceTask, len(txs)) + errCh = make(chan error, 1) + ) + threads := runtime.NumCPU() + if threads > len(txs) { + threads = len(txs) + } + for th := 0; th < threads; th++ { + pend.Add(1) + go func() { + defer pend.Done() + // Fetch and execute the next transaction trace tasks + for task := range jobs { + if err := env.getTxResult(task.statedb, task.index, block); err != nil { + select { + case errCh <- err: + default: + } + log.Error("failed to trace tx", "txHash", txs[task.index].Hash().String()) + } + } + }() + } + + // Feed the transactions into the tracers and return + var failed error + for i, tx := range txs { + // Send the trace task over for execution + jobs <- &txTraceTask{statedb: env.state.Copy(), index: i} + + // Generate the next state snapshot fast without tracing + msg, _ := tx.AsMessage(env.signer, block.BaseFee()) + env.state.Prepare(tx.Hash(), i) + vmenv := vm.NewEVM(env.blockCtx, NewEVMTxContext(msg), env.state, env.chainConfig, vm.Config{}) + l1DataFee, err := fees.CalculateL1DataFee(tx, env.state) + if err != nil { + failed = err + break + } + if _, err = ApplyMessage(vmenv, msg, new(GasPool).AddGas(msg.Gas()), l1DataFee); err != nil { + failed = err + break + } + // we'd better don't finalise + // env.state.Finalise(vmenv.chainConfig().IsEIP158(block.Number())) + } + close(jobs) + pend.Wait() + + // after all tx has been traced, collect "deletion proof" for zktrie + for _, tracer := range env.ZkTrieTracer { + delProofs, err := tracer.GetDeletionProofs() + if err != nil { + log.Error("deletion proof failure", "error", err) + } else { + for _, proof := range delProofs { + env.DeletionProofs = append(env.DeletionProofs, proof) + } + } + } + + // build dummy per-tx deletion proof + for _, txStorageTrace := range env.TxStorageTraces { + if txStorageTrace != nil { + txStorageTrace.DeletionProofs = env.DeletionProofs + } + } + + // If execution failed in between, abort + select { + case err := <-errCh: + return nil, err + default: + if failed != nil { + return nil, failed + } + } + + return env.fillBlockTrace(block) +} + +func (env *TraceEnv) getTxResult(state *state.StateDB, index int, block *types.Block) error { + tx := block.Transactions()[index] + msg, _ := tx.AsMessage(env.signer, block.BaseFee()) + from, _ := types.Sender(env.signer, tx) + to := tx.To() + + txctx := &Context{ + BlockHash: block.TxHash(), + TxIndex: index, + TxHash: tx.Hash(), + } + + sender := &types.AccountWrapper{ + Address: from, + Nonce: state.GetNonce(from), + Balance: (*hexutil.Big)(state.GetBalance(from)), + KeccakCodeHash: state.GetKeccakCodeHash(from), + PoseidonCodeHash: state.GetPoseidonCodeHash(from), + CodeSize: state.GetCodeSize(from), + } + var receiver *types.AccountWrapper + if to != nil { + receiver = &types.AccountWrapper{ + Address: *to, + Nonce: state.GetNonce(*to), + Balance: (*hexutil.Big)(state.GetBalance(*to)), + KeccakCodeHash: state.GetKeccakCodeHash(*to), + PoseidonCodeHash: state.GetPoseidonCodeHash(*to), + CodeSize: state.GetCodeSize(*to), + } + } + + tracer := vm.NewStructLogger(env.logConfig) + // Run the transaction with tracing enabled. + vmenv := vm.NewEVM(env.blockCtx, NewEVMTxContext(msg), state, env.chainConfig, vm.Config{Debug: true, Tracer: tracer, NoBaseFee: true}) + + // Call Prepare to clear out the statedb access list + state.Prepare(txctx.TxHash, txctx.TxIndex) + + // Computes the new state by applying the given message. + l1DataFee, err := fees.CalculateL1DataFee(tx, state) + if err != nil { + return fmt.Errorf("tracing failed: %w", err) + } + result, err := ApplyMessage(vmenv, msg, new(GasPool).AddGas(msg.Gas()), l1DataFee) + if err != nil { + return fmt.Errorf("tracing failed: %w", err) + } + // If the result contains a revert reason, return it. + returnVal := result.Return() + if len(result.Revert()) > 0 { + returnVal = result.Revert() + } + + createdAcc := tracer.CreatedAccount() + var after []*types.AccountWrapper + if to == nil { + if createdAcc == nil { + return errors.New("unexpected tx: address for created contract unavailable") + } + to = &createdAcc.Address + } + // collect affected account after tx being applied + for _, acc := range []common.Address{from, *to, env.coinbase} { + after = append(after, &types.AccountWrapper{ + Address: acc, + Nonce: state.GetNonce(acc), + Balance: (*hexutil.Big)(state.GetBalance(acc)), + KeccakCodeHash: state.GetKeccakCodeHash(acc), + PoseidonCodeHash: state.GetPoseidonCodeHash(acc), + CodeSize: state.GetCodeSize(acc), + }) + } + + txStorageTrace := &types.StorageTrace{ + Proofs: make(map[string][]hexutil.Bytes), + StorageProofs: make(map[string]map[string][]hexutil.Bytes), + } + // still we have no state root for per tx, only set the head and tail + if index == 0 { + txStorageTrace.RootBefore = state.GetRootHash() + } else if index == len(block.Transactions())-1 { + txStorageTrace.RootAfter = block.Root() + } + + // merge required proof data + proofAccounts := tracer.UpdatedAccounts() + proofAccounts[vmenv.FeeRecipient()] = struct{}{} + for addr := range proofAccounts { + addrStr := addr.String() + + env.pMu.Lock() + checkedProof, existed := env.Proofs[addrStr] + if existed { + txStorageTrace.Proofs[addrStr] = checkedProof + } + env.pMu.Unlock() + if existed { + continue + } + proof, err := state.GetProof(addr) + if err != nil { + log.Error("Proof not available", "address", addrStr, "error", err) + // but we still mark the proofs map with nil array + } + wrappedProof := make([]hexutil.Bytes, len(proof)) + for i, bt := range proof { + wrappedProof[i] = bt + } + env.pMu.Lock() + env.Proofs[addrStr] = wrappedProof + txStorageTrace.Proofs[addrStr] = wrappedProof + env.pMu.Unlock() + } + + proofStorages := tracer.UpdatedStorages() + for addr, keys := range proofStorages { + if _, existed := txStorageTrace.StorageProofs[addr.String()]; !existed { + txStorageTrace.StorageProofs[addr.String()] = make(map[string][]hexutil.Bytes) + } + + env.sMu.Lock() + trie, err := state.GetStorageTrieForProof(addr) + if err != nil { + // but we still continue to next address + log.Error("Storage trie not available", "error", err, "address", addr) + env.sMu.Unlock() + continue + } + zktrieTracer := state.NewProofTracer(trie) + env.sMu.Unlock() + + for key, values := range keys { + addrStr := addr.String() + keyStr := key.String() + isDelete := bytes.Equal(values.Bytes(), common.Hash{}.Bytes()) + + txm := txStorageTrace.StorageProofs[addrStr] + env.sMu.Lock() + m, existed := env.StorageProofs[addrStr] + if !existed { + m = make(map[string][]hexutil.Bytes) + env.StorageProofs[addrStr] = m + if zktrieTracer.Available() { + env.ZkTrieTracer[addrStr] = state.NewProofTracer(trie) + } + } else if proof, existed := m[keyStr]; existed { + txm[keyStr] = proof + // still need to touch tracer for deletion + if isDelete && zktrieTracer.Available() { + env.ZkTrieTracer[addrStr].MarkDeletion(key) + } + env.sMu.Unlock() + continue + } + env.sMu.Unlock() + + var proof [][]byte + var err error + if zktrieTracer.Available() { + proof, err = state.GetSecureTrieProof(zktrieTracer, key) + } else { + proof, err = state.GetSecureTrieProof(trie, key) + } + if err != nil { + log.Error("Storage proof not available", "error", err, "address", addrStr, "key", keyStr) + // but we still mark the proofs map with nil array + } + wrappedProof := make([]hexutil.Bytes, len(proof)) + for i, bt := range proof { + wrappedProof[i] = bt + } + env.sMu.Lock() + txm[keyStr] = wrappedProof + m[keyStr] = wrappedProof + if zktrieTracer.Available() { + if isDelete { + zktrieTracer.MarkDeletion(key) + } + env.ZkTrieTracer[addrStr].Merge(zktrieTracer) + } + env.sMu.Unlock() + } + } + + env.ExecutionResults[index] = &types.ExecutionResult{ + From: sender, + To: receiver, + AccountCreated: createdAcc, + AccountsAfter: after, + L1DataFee: (*hexutil.Big)(result.L1DataFee), + Gas: result.UsedGas, + Failed: result.Failed(), + ReturnValue: fmt.Sprintf("%x", returnVal), + StructLogs: vm.FormatLogs(tracer.StructLogs()), + } + env.TxStorageTraces[index] = txStorageTrace + + return nil +} + +// fillBlockTrace content after all the txs are finished running. +func (env *TraceEnv) fillBlockTrace(block *types.Block) (*types.BlockTrace, error) { + statedb := env.state + + txs := make([]*types.TransactionData, block.Transactions().Len()) + for i, tx := range block.Transactions() { + txs[i] = types.NewTransactionData(tx, block.NumberU64(), env.chainConfig) + } + + intrinsicStorageProofs := map[common.Address][]common.Hash{ + rcfg.L2MessageQueueAddress: {rcfg.WithdrawTrieRootSlot}, + rcfg.L1GasPriceOracleAddress: { + rcfg.L1BaseFeeSlot, + rcfg.OverheadSlot, + rcfg.ScalarSlot, + }, + } + + for addr, storages := range intrinsicStorageProofs { + if _, existed := env.Proofs[addr.String()]; !existed { + if proof, err := statedb.GetProof(addr); err != nil { + log.Error("Proof for intrinstic address not available", "error", err, "address", addr) + } else { + wrappedProof := make([]hexutil.Bytes, len(proof)) + for i, bt := range proof { + wrappedProof[i] = bt + } + env.Proofs[addr.String()] = wrappedProof + } + } + + if _, existed := env.StorageProofs[addr.String()]; !existed { + env.StorageProofs[addr.String()] = make(map[string][]hexutil.Bytes) + } + + for _, slot := range storages { + if _, existed := env.StorageProofs[addr.String()][slot.String()]; !existed { + if trie, err := statedb.GetStorageTrieForProof(addr); err != nil { + log.Error("Storage proof for intrinstic address not available", "error", err, "address", addr) + } else if proof, _ := statedb.GetSecureTrieProof(trie, slot); err != nil { + log.Error("Get storage proof for intrinstic address failed", "error", err, "address", addr, "slot", slot) + } else { + wrappedProof := make([]hexutil.Bytes, len(proof)) + for i, bt := range proof { + wrappedProof[i] = bt + } + env.StorageProofs[addr.String()][slot.String()] = wrappedProof + } + } + } + } + + blockTrace := &types.BlockTrace{ + ChainID: env.chainConfig.ChainID.Uint64(), + Version: params.ArchiveVersion(params.CommitHash), + Coinbase: &types.AccountWrapper{ + Address: env.coinbase, + Nonce: statedb.GetNonce(env.coinbase), + Balance: (*hexutil.Big)(statedb.GetBalance(env.coinbase)), + KeccakCodeHash: statedb.GetKeccakCodeHash(env.coinbase), + PoseidonCodeHash: statedb.GetPoseidonCodeHash(env.coinbase), + CodeSize: statedb.GetCodeSize(env.coinbase), + }, + Header: block.Header(), + StorageTrace: env.StorageTrace, + ExecutionResults: env.ExecutionResults, + TxStorageTraces: env.TxStorageTraces, + Transactions: txs, + } + + for i, tx := range block.Transactions() { + evmTrace := env.ExecutionResults[i] + // probably a Contract Call + if len(tx.Data()) != 0 && tx.To() != nil { + evmTrace.ByteCode = hexutil.Encode(statedb.GetCode(*tx.To())) + // Get tx.to address's code hash. + codeHash := statedb.GetPoseidonCodeHash(*tx.To()) + evmTrace.PoseidonCodeHash = &codeHash + } else if tx.To() == nil { // Contract is created. + evmTrace.ByteCode = hexutil.Encode(tx.Data()) + } + } + + // only zktrie model has the ability to get `mptwitness`. + if env.chainConfig.Scroll.ZktrieEnabled() { + // we use MPTWitnessNothing by default and do not allow switch among MPTWitnessType atm. + // MPTWitness will be removed from traces in the future. + if err := zkproof.FillBlockTraceForMPTWitness(zkproof.MPTWitnessNothing, blockTrace); err != nil { + log.Error("fill mpt witness fail", "error", err) + } + } + + blockTrace.WithdrawTrieRoot = withdrawtrie.ReadWTRSlot(rcfg.L2MessageQueueAddress, env.state) + + return blockTrace, nil +} diff --git a/core/types/block.go b/core/types/block.go index 32176dfe16..ac8fef6355 100644 --- a/core/types/block.go +++ b/core/types/block.go @@ -397,16 +397,39 @@ func (b *Block) Hash() common.Hash { return v } -// L1MessageCount returns the number of L1 messages in this block. -func (b *Block) L1MessageCount() int { +// ContainsL1Messages returns true if this block contains at least one L1 message. +func (b *Block) ContainsL1Messages() bool { + for _, tx := range b.transactions { + if tx.IsL1MessageTx() { + return true + } + } + return false +} + +// NumL1MessagesProcessed returns the number of L1 messages processed in this block. +// This count includes both skipped and included messages. +// `firstQueueIndex` is the first queue index available for this block to process. +func (b *Block) NumL1MessagesProcessed(firstQueueIndex uint64) int { if l1MsgCount := b.l1MsgCount.Load(); l1MsgCount != nil { return l1MsgCount.(int) } - count := 0 - for _, tx := range b.transactions { - if tx.IsL1MessageTx() { - count += 1 + + // find first and last queue index in block + var lastQueueIndex *uint64 + + for ii, tx := range b.transactions { + if !tx.IsL1MessageTx() { + break } + lastQueueIndex = &b.transactions[ii].AsL1MessageTx().QueueIndex + } + + // calculate and cache L1 message count + count := 0 + if lastQueueIndex != nil { + // lastQueueIndex is guaranteed to be non-nil in this case + count = int(*lastQueueIndex - firstQueueIndex + 1) } b.l1MsgCount.Store(count) return count @@ -414,7 +437,13 @@ func (b *Block) L1MessageCount() int { // CountL2Tx returns the number of L2 transactions in this block. func (b *Block) CountL2Tx() int { - return len(b.transactions) - b.L1MessageCount() + count := 0 + for _, tx := range b.transactions { + if !tx.IsL1MessageTx() { + count += 1 + } + } + return count } type Blocks []*Block diff --git a/core/types/gen_row_consumption_json.go b/core/types/gen_row_consumption_json.go index 2b97a016dc..00dfc7ea60 100644 --- a/core/types/gen_row_consumption_json.go +++ b/core/types/gen_row_consumption_json.go @@ -9,37 +9,37 @@ import ( "github.com/scroll-tech/go-ethereum/common/hexutil" ) -var _ = (*subCircuitRowConsumptionMarshaling)(nil) +var _ = (*subCircuitRowUsageMarshaling)(nil) // MarshalJSON marshals as JSON. -func (s SubCircuitRowConsumption) MarshalJSON() ([]byte, error) { - type SubCircuitRowConsumption struct { - CircuitName string `json:"circuitName" gencodec:"required"` - Rows hexutil.Uint64 `json:"rows" gencodec:"required"` +func (s SubCircuitRowUsage) MarshalJSON() ([]byte, error) { + type SubCircuitRowUsage struct { + Name string `json:"name" gencodec:"required"` + RowNumber hexutil.Uint64 `json:"row_number" gencodec:"required"` } - var enc SubCircuitRowConsumption - enc.CircuitName = s.CircuitName - enc.Rows = hexutil.Uint64(s.Rows) + var enc SubCircuitRowUsage + enc.Name = s.Name + enc.RowNumber = hexutil.Uint64(s.RowNumber) return json.Marshal(&enc) } // UnmarshalJSON unmarshals from JSON. -func (s *SubCircuitRowConsumption) UnmarshalJSON(input []byte) error { - type SubCircuitRowConsumption struct { - CircuitName *string `json:"circuitName" gencodec:"required"` - Rows *hexutil.Uint64 `json:"rows" gencodec:"required"` +func (s *SubCircuitRowUsage) UnmarshalJSON(input []byte) error { + type SubCircuitRowUsage struct { + Name *string `json:"name" gencodec:"required"` + RowNumber *hexutil.Uint64 `json:"row_number" gencodec:"required"` } - var dec SubCircuitRowConsumption + var dec SubCircuitRowUsage if err := json.Unmarshal(input, &dec); err != nil { return err } - if dec.CircuitName == nil { - return errors.New("missing required field 'circuitName' for SubCircuitRowConsumption") + if dec.Name == nil { + return errors.New("missing required field 'name' for SubCircuitRowUsage") } - s.CircuitName = *dec.CircuitName - if dec.Rows == nil { - return errors.New("missing required field 'rows' for SubCircuitRowConsumption") + s.Name = *dec.Name + if dec.RowNumber == nil { + return errors.New("missing required field 'row_number' for SubCircuitRowUsage") } - s.Rows = uint64(*dec.Rows) + s.RowNumber = uint64(*dec.RowNumber) return nil } diff --git a/core/types/l2trace.go b/core/types/l2trace.go index 3f9fee5146..c60fd7b646 100644 --- a/core/types/l2trace.go +++ b/core/types/l2trace.go @@ -191,3 +191,12 @@ func NewTransactionData(tx *Transaction, blockNumber uint64, config *params.Chai } return result } + +// WrapProof turn the bytes array into proof type (array of hexutil.Bytes) +func WrapProof(proofBytes [][]byte) (wrappedProof []hexutil.Bytes) { + wrappedProof = make([]hexutil.Bytes, len(proofBytes)) + for i, bt := range proofBytes { + wrappedProof[i] = bt + } + return +} diff --git a/core/types/row_consumption.go b/core/types/row_consumption.go index 380406f48a..61571fcde8 100644 --- a/core/types/row_consumption.go +++ b/core/types/row_consumption.go @@ -4,15 +4,21 @@ import ( "github.com/scroll-tech/go-ethereum/common/hexutil" ) -//go:generate gencodec -type SubCircuitRowConsumption -field-override subCircuitRowConsumptionMarshaling -out gen_row_consumption_json.go -type SubCircuitRowConsumption struct { - CircuitName string `json:"circuitName" gencodec:"required"` - Rows uint64 `json:"rows" gencodec:"required"` +type RowUsage struct { + IsOk bool `json:"is_ok"` + RowNumber uint64 `json:"row_number"` + RowUsageDetails []SubCircuitRowUsage `json:"row_usage_details"` } -type RowConsumption []SubCircuitRowConsumption +//go:generate gencodec -type SubCircuitRowUsage -field-override subCircuitRowUsageMarshaling -out gen_row_consumption_json.go +type SubCircuitRowUsage struct { + Name string `json:"name" gencodec:"required"` + RowNumber uint64 `json:"row_number" gencodec:"required"` +} + +type RowConsumption []SubCircuitRowUsage // field type overrides for gencodec -type subCircuitRowConsumptionMarshaling struct { - Rows hexutil.Uint64 +type subCircuitRowUsageMarshaling struct { + RowNumber hexutil.Uint64 } diff --git a/eth/backend.go b/eth/backend.go index 44e2cfe573..a1fb5cbaf5 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -192,7 +192,7 @@ func New(stack *node.Node, config *ethconfig.Config, l1Client sync_service.EthCl MPTWitness: config.MPTWitness, } ) - eth.blockchain, err = core.NewBlockChain(chainDb, cacheConfig, chainConfig, eth.engine, vmConfig, eth.shouldPreserve, &config.TxLookupLimit) + eth.blockchain, err = core.NewBlockChain(chainDb, cacheConfig, chainConfig, eth.engine, vmConfig, eth.shouldPreserve, &config.TxLookupLimit, config.CheckCircuitCapacity) if err != nil { return nil, err } diff --git a/eth/ethconfig/config.go b/eth/ethconfig/config.go index a4a4375707..e9f95b67ba 100644 --- a/eth/ethconfig/config.go +++ b/eth/ethconfig/config.go @@ -207,6 +207,9 @@ type Config struct { // Trace option MPTWitness int + + // Check circuit capacity in block validator + CheckCircuitCapacity bool } // CreateConsensusEngine creates a consensus engine for the given chain configuration. diff --git a/eth/gasprice/gasprice_test.go b/eth/gasprice/gasprice_test.go index 5cb58687f4..f0415206b1 100644 --- a/eth/gasprice/gasprice_test.go +++ b/eth/gasprice/gasprice_test.go @@ -144,7 +144,7 @@ func newTestBackend(t *testing.T, londonBlock *big.Int, pending bool) *testBacke // Construct testing chain diskdb := rawdb.NewMemoryDatabase() gspec.Commit(diskdb) - chain, err := core.NewBlockChain(diskdb, &core.CacheConfig{TrieCleanNoPrefetch: true}, &config, engine, vm.Config{}, nil, nil) + chain, err := core.NewBlockChain(diskdb, &core.CacheConfig{TrieCleanNoPrefetch: true}, &config, engine, vm.Config{}, nil, nil, false) if err != nil { t.Fatalf("Failed to create local chain, %v", err) } diff --git a/eth/handler_eth_test.go b/eth/handler_eth_test.go index d24705cec0..02cf618a99 100644 --- a/eth/handler_eth_test.go +++ b/eth/handler_eth_test.go @@ -105,8 +105,8 @@ func testForkIDSplit(t *testing.T, protocol uint) { genesisNoFork = gspecNoFork.MustCommit(dbNoFork) genesisProFork = gspecProFork.MustCommit(dbProFork) - chainNoFork, _ = core.NewBlockChain(dbNoFork, nil, configNoFork, engine, vm.Config{}, nil, nil) - chainProFork, _ = core.NewBlockChain(dbProFork, nil, configProFork, engine, vm.Config{}, nil, nil) + chainNoFork, _ = core.NewBlockChain(dbNoFork, nil, configNoFork, engine, vm.Config{}, nil, nil, false) + chainProFork, _ = core.NewBlockChain(dbProFork, nil, configProFork, engine, vm.Config{}, nil, nil, false) blocksNoFork, _ = core.GenerateChain(configNoFork, genesisNoFork, engine, dbNoFork, 2, nil) blocksProFork, _ = core.GenerateChain(configProFork, genesisProFork, engine, dbProFork, 2, nil) diff --git a/eth/handler_test.go b/eth/handler_test.go index b9931a4b38..41d23567a4 100644 --- a/eth/handler_test.go +++ b/eth/handler_test.go @@ -137,7 +137,7 @@ func newTestHandlerWithBlocks(blocks int) *testHandler { Alloc: core.GenesisAlloc{testAddr: {Balance: big.NewInt(1000000)}}, }).MustCommit(db) - chain, _ := core.NewBlockChain(db, nil, params.TestChainConfig, ethash.NewFaker(), vm.Config{}, nil, nil) + chain, _ := core.NewBlockChain(db, nil, params.TestChainConfig, ethash.NewFaker(), vm.Config{}, nil, nil, false) bs, _ := core.GenerateChain(params.TestChainConfig, chain.Genesis(), ethash.NewFaker(), db, blocks, nil) if _, err := chain.InsertChain(bs); err != nil { diff --git a/eth/protocols/eth/handler_test.go b/eth/protocols/eth/handler_test.go index ec5a5e7648..4b9f2493db 100644 --- a/eth/protocols/eth/handler_test.go +++ b/eth/protocols/eth/handler_test.go @@ -69,7 +69,7 @@ func newTestBackendWithGenerator(blocks int, generator func(int, *core.BlockGen) Alloc: core.GenesisAlloc{testAddr: {Balance: big.NewInt(100_000_000_000_000_000)}}, }).MustCommit(db) - chain, _ := core.NewBlockChain(db, nil, params.TestChainConfig, ethash.NewFaker(), vm.Config{}, nil, nil) + chain, _ := core.NewBlockChain(db, nil, params.TestChainConfig, ethash.NewFaker(), vm.Config{}, nil, nil, false) bs, _ := core.GenerateChain(params.TestChainConfig, chain.Genesis(), ethash.NewFaker(), db, blocks, generator) if _, err := chain.InsertChain(bs); err != nil { diff --git a/eth/tracers/api_blocktrace.go b/eth/tracers/api_blocktrace.go index d3f0209dc7..21882419c7 100644 --- a/eth/tracers/api_blocktrace.go +++ b/eth/tracers/api_blocktrace.go @@ -1,55 +1,20 @@ package tracers import ( - "bytes" "context" "errors" - "fmt" - "runtime" - "sync" - "github.com/scroll-tech/go-ethereum/common" - "github.com/scroll-tech/go-ethereum/common/hexutil" "github.com/scroll-tech/go-ethereum/core" - "github.com/scroll-tech/go-ethereum/core/state" "github.com/scroll-tech/go-ethereum/core/types" "github.com/scroll-tech/go-ethereum/core/vm" "github.com/scroll-tech/go-ethereum/log" - "github.com/scroll-tech/go-ethereum/params" - "github.com/scroll-tech/go-ethereum/rollup/fees" - "github.com/scroll-tech/go-ethereum/rollup/rcfg" - "github.com/scroll-tech/go-ethereum/rollup/withdrawtrie" "github.com/scroll-tech/go-ethereum/rpc" - "github.com/scroll-tech/go-ethereum/trie/zkproof" ) type TraceBlock interface { GetBlockTraceByNumberOrHash(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash, config *TraceConfig) (trace *types.BlockTrace, err error) } -type traceEnv struct { - config *TraceConfig - - coinbase common.Address - - // rMu lock is used to protect txs executed in parallel. - signer types.Signer - state *state.StateDB - blockCtx vm.BlockContext - - // pMu lock is used to protect Proofs' read and write mutual exclusion, - // since txs are executed in parallel, so this lock is required. - pMu sync.Mutex - // sMu is required because of txs are executed in parallel, - // this lock is used to protect StorageTrace's read and write mutual exclusion. - sMu sync.Mutex - *types.StorageTrace - txStorageTraces []*types.StorageTrace - // zktrie tracer is used for zktrie storage to build additional deletion proof - zkTrieTracer map[string]state.ZktrieProofTracer - executionResults []*types.ExecutionResult -} - // GetBlockTraceByNumberOrHash replays the block and returns the structured BlockTrace by hash or number. func (api *API) GetBlockTraceByNumberOrHash(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash, config *TraceConfig) (trace *types.BlockTrace, err error) { var block *types.Block @@ -83,11 +48,11 @@ func (api *API) GetBlockTraceByNumberOrHash(ctx context.Context, blockNrOrHash r return nil, err } - return api.getBlockTrace(block, env) + return env.GetBlockTrace(block) } // Make trace environment for current block. -func (api *API) createTraceEnv(ctx context.Context, config *TraceConfig, block *types.Block) (*traceEnv, error) { +func (api *API) createTraceEnv(ctx context.Context, config *TraceConfig, block *types.Block) (*core.TraceEnv, error) { parent, err := api.blockByNumberAndHash(ctx, rpc.BlockNumber(block.NumberU64()-1), block.ParentHash()) if err != nil { return nil, err @@ -100,431 +65,5 @@ func (api *API) createTraceEnv(ctx context.Context, config *TraceConfig, block * if err != nil { return nil, err } - - // get coinbase - var coinbase common.Address - if api.backend.ChainConfig().Scroll.FeeVaultEnabled() { - coinbase = *api.backend.ChainConfig().Scroll.FeeVaultAddress - } else { - coinbase, err = api.backend.Engine().Author(block.Header()) - if err != nil { - return nil, err - } - } - - env := &traceEnv{ - config: config, - coinbase: coinbase, - signer: types.MakeSigner(api.backend.ChainConfig(), block.Number()), - state: statedb, - blockCtx: core.NewEVMBlockContext(block.Header(), api.chainContext(ctx), nil), - StorageTrace: &types.StorageTrace{ - RootBefore: parent.Root(), - RootAfter: block.Root(), - Proofs: make(map[string][]hexutil.Bytes), - StorageProofs: make(map[string]map[string][]hexutil.Bytes), - }, - zkTrieTracer: make(map[string]state.ZktrieProofTracer), - executionResults: make([]*types.ExecutionResult, block.Transactions().Len()), - txStorageTraces: make([]*types.StorageTrace, block.Transactions().Len()), - } - - key := coinbase.String() - if _, exist := env.Proofs[key]; !exist { - proof, err := env.state.GetProof(coinbase) - if err != nil { - log.Error("Proof for coinbase not available", "coinbase", coinbase, "error", err) - // but we still mark the proofs map with nil array - } - wrappedProof := make([]hexutil.Bytes, len(proof)) - for i, bt := range proof { - wrappedProof[i] = bt - } - env.Proofs[key] = wrappedProof - } - - return env, nil -} - -func (api *API) getBlockTrace(block *types.Block, env *traceEnv) (*types.BlockTrace, error) { - // Execute all the transaction contained within the block concurrently - var ( - txs = block.Transactions() - pend = new(sync.WaitGroup) - jobs = make(chan *txTraceTask, len(txs)) - errCh = make(chan error, 1) - ) - threads := runtime.NumCPU() - if threads > len(txs) { - threads = len(txs) - } - for th := 0; th < threads; th++ { - pend.Add(1) - go func() { - defer pend.Done() - // Fetch and execute the next transaction trace tasks - for task := range jobs { - if err := api.getTxResult(env, task.statedb, task.index, block); err != nil { - select { - case errCh <- err: - default: - } - log.Error("failed to trace tx", "txHash", txs[task.index].Hash().String()) - } - } - }() - } - - // Feed the transactions into the tracers and return - var failed error - for i, tx := range txs { - // Send the trace task over for execution - jobs <- &txTraceTask{statedb: env.state.Copy(), index: i} - - // Generate the next state snapshot fast without tracing - msg, _ := tx.AsMessage(env.signer, block.BaseFee()) - env.state.Prepare(tx.Hash(), i) - vmenv := vm.NewEVM(env.blockCtx, core.NewEVMTxContext(msg), env.state, api.backend.ChainConfig(), vm.Config{}) - l1DataFee, err := fees.CalculateL1DataFee(tx, env.state) - if err != nil { - failed = err - break - } - if _, err = core.ApplyMessage(vmenv, msg, new(core.GasPool).AddGas(msg.Gas()), l1DataFee); err != nil { - failed = err - break - } - // Finalize the state so any modifications are written to the trie - // Only delete empty objects if EIP158/161 (a.k.a Spurious Dragon) is in effect - env.state.Finalise(vmenv.ChainConfig().IsEIP158(block.Number())) - } - close(jobs) - pend.Wait() - - // after all tx has been traced, collect "deletion proof" for zktrie - for _, tracer := range env.zkTrieTracer { - delProofs, err := tracer.GetDeletionProofs() - if err != nil { - log.Error("deletion proof failure", "error", err) - } else { - for _, proof := range delProofs { - env.DeletionProofs = append(env.DeletionProofs, proof) - } - } - } - - // build dummy per-tx deletion proof - for _, txStorageTrace := range env.txStorageTraces { - if txStorageTrace != nil { - txStorageTrace.DeletionProofs = env.DeletionProofs - } - } - - // If execution failed in between, abort - select { - case err := <-errCh: - return nil, err - default: - if failed != nil { - return nil, failed - } - } - - return api.fillBlockTrace(env, block) -} - -func (api *API) getTxResult(env *traceEnv, state *state.StateDB, index int, block *types.Block) error { - tx := block.Transactions()[index] - msg, _ := tx.AsMessage(env.signer, block.BaseFee()) - from, _ := types.Sender(env.signer, tx) - to := tx.To() - - txctx := &Context{ - BlockHash: block.TxHash(), - TxIndex: index, - TxHash: tx.Hash(), - } - - sender := &types.AccountWrapper{ - Address: from, - Nonce: state.GetNonce(from), - Balance: (*hexutil.Big)(state.GetBalance(from)), - KeccakCodeHash: state.GetKeccakCodeHash(from), - PoseidonCodeHash: state.GetPoseidonCodeHash(from), - CodeSize: state.GetCodeSize(from), - } - var receiver *types.AccountWrapper - if to != nil { - receiver = &types.AccountWrapper{ - Address: *to, - Nonce: state.GetNonce(*to), - Balance: (*hexutil.Big)(state.GetBalance(*to)), - KeccakCodeHash: state.GetKeccakCodeHash(*to), - PoseidonCodeHash: state.GetPoseidonCodeHash(*to), - CodeSize: state.GetCodeSize(*to), - } - } - - tracer := vm.NewStructLogger(env.config.LogConfig) - // Run the transaction with tracing enabled. - vmenv := vm.NewEVM(env.blockCtx, core.NewEVMTxContext(msg), state, api.backend.ChainConfig(), vm.Config{Debug: true, Tracer: tracer, NoBaseFee: true}) - - // Call Prepare to clear out the statedb access list - state.Prepare(txctx.TxHash, txctx.TxIndex) - - // Computes the new state by applying the given message. - l1DataFee, err := fees.CalculateL1DataFee(tx, state) - if err != nil { - return fmt.Errorf("tracing failed: %w", err) - } - result, err := core.ApplyMessage(vmenv, msg, new(core.GasPool).AddGas(msg.Gas()), l1DataFee) - if err != nil { - return fmt.Errorf("tracing failed: %w", err) - } - // If the result contains a revert reason, return it. - returnVal := result.Return() - if len(result.Revert()) > 0 { - returnVal = result.Revert() - } - - createdAcc := tracer.CreatedAccount() - var after []*types.AccountWrapper - if to == nil { - if createdAcc == nil { - return errors.New("unexpected tx: address for created contract unavailable") - } - to = &createdAcc.Address - } - // collect affected account after tx being applied - for _, acc := range []common.Address{from, *to, env.coinbase} { - after = append(after, &types.AccountWrapper{ - Address: acc, - Nonce: state.GetNonce(acc), - Balance: (*hexutil.Big)(state.GetBalance(acc)), - KeccakCodeHash: state.GetKeccakCodeHash(acc), - PoseidonCodeHash: state.GetPoseidonCodeHash(acc), - CodeSize: state.GetCodeSize(acc), - }) - } - - txStorageTrace := &types.StorageTrace{ - Proofs: make(map[string][]hexutil.Bytes), - StorageProofs: make(map[string]map[string][]hexutil.Bytes), - } - // still we have no state root for per tx, only set the head and tail - if index == 0 { - txStorageTrace.RootBefore = state.GetRootHash() - } else if index == len(block.Transactions())-1 { - txStorageTrace.RootAfter = block.Root() - } - - // merge required proof data - proofAccounts := tracer.UpdatedAccounts() - proofAccounts[vmenv.FeeRecipient()] = struct{}{} - for addr := range proofAccounts { - addrStr := addr.String() - - env.pMu.Lock() - checkedProof, existed := env.Proofs[addrStr] - if existed { - txStorageTrace.Proofs[addrStr] = checkedProof - } - env.pMu.Unlock() - if existed { - continue - } - proof, err := state.GetProof(addr) - if err != nil { - log.Error("Proof not available", "address", addrStr, "error", err) - // but we still mark the proofs map with nil array - } - wrappedProof := make([]hexutil.Bytes, len(proof)) - for i, bt := range proof { - wrappedProof[i] = bt - } - env.pMu.Lock() - env.Proofs[addrStr] = wrappedProof - txStorageTrace.Proofs[addrStr] = wrappedProof - env.pMu.Unlock() - } - - proofStorages := tracer.UpdatedStorages() - for addr, keys := range proofStorages { - if _, existed := txStorageTrace.StorageProofs[addr.String()]; !existed { - txStorageTrace.StorageProofs[addr.String()] = make(map[string][]hexutil.Bytes) - } - - env.sMu.Lock() - trie, err := state.GetStorageTrieForProof(addr) - if err != nil { - // but we still continue to next address - log.Error("Storage trie not available", "error", err, "address", addr) - env.sMu.Unlock() - continue - } - zktrieTracer := state.NewProofTracer(trie) - env.sMu.Unlock() - - for key, values := range keys { - addrStr := addr.String() - keyStr := key.String() - isDelete := bytes.Equal(values.Bytes(), common.Hash{}.Bytes()) - - txm := txStorageTrace.StorageProofs[addrStr] - env.sMu.Lock() - m, existed := env.StorageProofs[addrStr] - if !existed { - m = make(map[string][]hexutil.Bytes) - env.StorageProofs[addrStr] = m - if zktrieTracer.Available() { - env.zkTrieTracer[addrStr] = state.NewProofTracer(trie) - } - } else if proof, existed := m[keyStr]; existed { - txm[keyStr] = proof - // still need to touch tracer for deletion - if isDelete && zktrieTracer.Available() { - env.zkTrieTracer[addrStr].MarkDeletion(key) - } - env.sMu.Unlock() - continue - } - env.sMu.Unlock() - - var proof [][]byte - var err error - if zktrieTracer.Available() { - proof, err = state.GetSecureTrieProof(zktrieTracer, key) - } else { - proof, err = state.GetSecureTrieProof(trie, key) - } - if err != nil { - log.Error("Storage proof not available", "error", err, "address", addrStr, "key", keyStr) - // but we still mark the proofs map with nil array - } - wrappedProof := make([]hexutil.Bytes, len(proof)) - for i, bt := range proof { - wrappedProof[i] = bt - } - env.sMu.Lock() - txm[keyStr] = wrappedProof - m[keyStr] = wrappedProof - if zktrieTracer.Available() { - if isDelete { - zktrieTracer.MarkDeletion(key) - } - env.zkTrieTracer[addrStr].Merge(zktrieTracer) - } - env.sMu.Unlock() - } - } - - env.executionResults[index] = &types.ExecutionResult{ - From: sender, - To: receiver, - AccountCreated: createdAcc, - AccountsAfter: after, - L1DataFee: (*hexutil.Big)(result.L1DataFee), - Gas: result.UsedGas, - Failed: result.Failed(), - ReturnValue: fmt.Sprintf("%x", returnVal), - StructLogs: vm.FormatLogs(tracer.StructLogs()), - } - env.txStorageTraces[index] = txStorageTrace - - return nil -} - -// Fill blockTrace content after all the txs are finished running. -func (api *API) fillBlockTrace(env *traceEnv, block *types.Block) (*types.BlockTrace, error) { - statedb := env.state - - txs := make([]*types.TransactionData, block.Transactions().Len()) - for i, tx := range block.Transactions() { - txs[i] = types.NewTransactionData(tx, block.NumberU64(), api.backend.ChainConfig()) - } - - intrinsicStorageProofs := map[common.Address][]common.Hash{ - rcfg.L2MessageQueueAddress: {rcfg.WithdrawTrieRootSlot}, - rcfg.L1GasPriceOracleAddress: { - rcfg.L1BaseFeeSlot, - rcfg.OverheadSlot, - rcfg.ScalarSlot, - }, - } - - for addr, storages := range intrinsicStorageProofs { - if _, existed := env.Proofs[addr.String()]; !existed { - if proof, err := statedb.GetProof(addr); err != nil { - log.Error("Proof for intrinstic address not available", "error", err, "address", addr) - } else { - wrappedProof := make([]hexutil.Bytes, len(proof)) - for i, bt := range proof { - wrappedProof[i] = bt - } - env.Proofs[addr.String()] = wrappedProof - } - } - - if _, existed := env.StorageProofs[addr.String()]; !existed { - env.StorageProofs[addr.String()] = make(map[string][]hexutil.Bytes) - } - - for _, slot := range storages { - if _, existed := env.StorageProofs[addr.String()][slot.String()]; !existed { - if trie, err := statedb.GetStorageTrieForProof(addr); err != nil { - log.Error("Storage proof for intrinstic address not available", "error", err, "address", addr) - } else if proof, _ := statedb.GetSecureTrieProof(trie, slot); err != nil { - log.Error("Get storage proof for intrinstic address failed", "error", err, "address", addr, "slot", slot) - } else { - wrappedProof := make([]hexutil.Bytes, len(proof)) - for i, bt := range proof { - wrappedProof[i] = bt - } - env.StorageProofs[addr.String()][slot.String()] = wrappedProof - } - } - } - } - - blockTrace := &types.BlockTrace{ - ChainID: api.backend.ChainConfig().ChainID.Uint64(), - Version: params.ArchiveVersion(params.CommitHash), - Coinbase: &types.AccountWrapper{ - Address: env.coinbase, - Nonce: statedb.GetNonce(env.coinbase), - Balance: (*hexutil.Big)(statedb.GetBalance(env.coinbase)), - KeccakCodeHash: statedb.GetKeccakCodeHash(env.coinbase), - PoseidonCodeHash: statedb.GetPoseidonCodeHash(env.coinbase), - CodeSize: statedb.GetCodeSize(env.coinbase), - }, - Header: block.Header(), - StorageTrace: env.StorageTrace, - ExecutionResults: env.executionResults, - TxStorageTraces: env.txStorageTraces, - Transactions: txs, - } - - for i, tx := range block.Transactions() { - evmTrace := env.executionResults[i] - // probably a Contract Call - if len(tx.Data()) != 0 && tx.To() != nil { - evmTrace.ByteCode = hexutil.Encode(statedb.GetCode(*tx.To())) - // Get tx.to address's code hash. - codeHash := statedb.GetPoseidonCodeHash(*tx.To()) - evmTrace.PoseidonCodeHash = &codeHash - } else if tx.To() == nil { // Contract is created. - evmTrace.ByteCode = hexutil.Encode(tx.Data()) - } - } - - // only zktrie model has the ability to get `mptwitness`. - if api.backend.ChainConfig().Scroll.ZktrieEnabled() { - if err := zkproof.FillBlockTraceForMPTWitness(zkproof.MPTWitnessType(api.backend.CacheConfig().MPTWitness), blockTrace); err != nil { - log.Error("fill mpt witness fail", "error", err) - } - } - - blockTrace.WithdrawTrieRoot = withdrawtrie.ReadWTRSlot(rcfg.L2MessageQueueAddress, env.state) - - return blockTrace, nil + return core.CreateTraceEnv(api.backend.ChainConfig(), api.chainContext(ctx), api.backend.Engine(), statedb, parent, block) } diff --git a/eth/tracers/api_test.go b/eth/tracers/api_test.go index 819914e8e7..6f3f2656af 100644 --- a/eth/tracers/api_test.go +++ b/eth/tracers/api_test.go @@ -82,7 +82,7 @@ func newTestBackend(t *testing.T, n int, gspec *core.Genesis, generator func(i i SnapshotLimit: 0, TrieDirtyDisabled: true, // Archive mode } - chain, err := core.NewBlockChain(backend.chaindb, cacheConfig, backend.chainConfig, backend.engine, vm.Config{}, nil, nil) + chain, err := core.NewBlockChain(backend.chaindb, cacheConfig, backend.chainConfig, backend.engine, vm.Config{}, nil, nil, false) if err != nil { t.Fatalf("failed to create tester chain: %v", err) } diff --git a/light/odr_test.go b/light/odr_test.go index 4d359312b6..a7123b1825 100644 --- a/light/odr_test.go +++ b/light/odr_test.go @@ -264,7 +264,7 @@ func testChainOdr(t *testing.T, protocol int, fn odrTestFn) { ) gspec.MustCommit(ldb) // Assemble the test environment - blockchain, _ := core.NewBlockChain(sdb, nil, params.TestChainConfig, ethash.NewFullFaker(), vm.Config{}, nil, nil) + blockchain, _ := core.NewBlockChain(sdb, nil, params.TestChainConfig, ethash.NewFullFaker(), vm.Config{}, nil, nil, false) gchain, _ := core.GenerateChain(params.TestChainConfig, genesis, ethash.NewFaker(), sdb, 4, testChainGen) if _, err := blockchain.InsertChain(gchain); err != nil { t.Fatal(err) diff --git a/light/trie_test.go b/light/trie_test.go index 3dda9ebdb4..ee4c0131c4 100644 --- a/light/trie_test.go +++ b/light/trie_test.go @@ -45,7 +45,7 @@ func TestNodeIterator(t *testing.T) { genesis = gspec.MustCommit(fulldb) ) gspec.MustCommit(lightdb) - blockchain, _ := core.NewBlockChain(fulldb, nil, params.TestChainConfig, ethash.NewFullFaker(), vm.Config{}, nil, nil) + blockchain, _ := core.NewBlockChain(fulldb, nil, params.TestChainConfig, ethash.NewFullFaker(), vm.Config{}, nil, nil, false) gchain, _ := core.GenerateChain(params.TestChainConfig, genesis, ethash.NewFaker(), fulldb, 4, testChainGen) if _, err := blockchain.InsertChain(gchain); err != nil { panic(err) diff --git a/light/txpool_test.go b/light/txpool_test.go index 5bd8281c7a..13757c4965 100644 --- a/light/txpool_test.go +++ b/light/txpool_test.go @@ -91,7 +91,7 @@ func TestTxPool(t *testing.T) { ) gspec.MustCommit(ldb) // Assemble the test environment - blockchain, _ := core.NewBlockChain(sdb, nil, params.TestChainConfig, ethash.NewFullFaker(), vm.Config{}, nil, nil) + blockchain, _ := core.NewBlockChain(sdb, nil, params.TestChainConfig, ethash.NewFullFaker(), vm.Config{}, nil, nil, false) gchain, _ := core.GenerateChain(params.TestChainConfig, genesis, ethash.NewFaker(), sdb, poolTestBlocks, txPoolTestChainGen) if _, err := blockchain.InsertChain(gchain); err != nil { panic(err) diff --git a/miner/miner_test.go b/miner/miner_test.go index a83fc2c8b1..63bb1d4249 100644 --- a/miner/miner_test.go +++ b/miner/miner_test.go @@ -257,7 +257,7 @@ func createMiner(t *testing.T) (*Miner, *event.TypeMux) { // Create consensus engine engine := clique.New(chainConfig.Clique, chainDB) // Create Ethereum backend - bc, err := core.NewBlockChain(chainDB, nil, chainConfig, engine, vm.Config{}, nil, nil) + bc, err := core.NewBlockChain(chainDB, nil, chainConfig, engine, vm.Config{}, nil, nil, false) if err != nil { t.Fatalf("can't create new chain %v", err) } diff --git a/miner/worker.go b/miner/worker.go index 44cb3e5255..6a35b0f984 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -36,6 +36,7 @@ import ( "github.com/scroll-tech/go-ethereum/event" "github.com/scroll-tech/go-ethereum/log" "github.com/scroll-tech/go-ethereum/params" + "github.com/scroll-tech/go-ethereum/rollup/circuitcapacitychecker" "github.com/scroll-tech/go-ethereum/trie" ) @@ -95,14 +96,21 @@ type environment struct { header *types.Header txs []*types.Transaction receipts []*types.Receipt + + // circuit capacity check related fields + traceEnv *core.TraceEnv // env for tracing + accRows *types.RowConsumption // accumulated row consumption for a block + maxL1Index uint64 // maximum L1 index included or skipped } // task contains all information for consensus engine sealing and result submitting. type task struct { - receipts []*types.Receipt - state *state.StateDB - block *types.Block - createdAt time.Time + receipts []*types.Receipt + state *state.StateDB + block *types.Block + createdAt time.Time + accRows *types.RowConsumption // accumulated row consumption in the circuit side + maxL1Index uint64 // maximum L1 index included or skipped } const ( @@ -190,6 +198,8 @@ type worker struct { // External functions isLocalBlock func(block *types.Block) bool // Function used to determine whether the specified block is mined by local miner. + circuitCapacityChecker *circuitcapacitychecker.CircuitCapacityChecker + // Test hooks newTaskHook func(*task) // Method to call upon receiving a new sealing task. skipSealHook func(*task) bool // Method to decide whether skipping the sealing. @@ -199,29 +209,31 @@ type worker struct { func newWorker(config *Config, chainConfig *params.ChainConfig, engine consensus.Engine, eth Backend, mux *event.TypeMux, isLocalBlock func(*types.Block) bool, init bool) *worker { worker := &worker{ - config: config, - chainConfig: chainConfig, - engine: engine, - eth: eth, - mux: mux, - chain: eth.BlockChain(), - isLocalBlock: isLocalBlock, - localUncles: make(map[common.Hash]*types.Block), - remoteUncles: make(map[common.Hash]*types.Block), - unconfirmed: newUnconfirmedBlocks(eth.BlockChain(), miningLogAtDepth), - pendingTasks: make(map[common.Hash]*task), - txsCh: make(chan core.NewTxsEvent, txChanSize), - l1MsgsCh: make(chan core.NewL1MsgsEvent, txChanSize), - chainHeadCh: make(chan core.ChainHeadEvent, chainHeadChanSize), - chainSideCh: make(chan core.ChainSideEvent, chainSideChanSize), - newWorkCh: make(chan *newWorkReq), - taskCh: make(chan *task), - resultCh: make(chan *types.Block, resultQueueSize), - exitCh: make(chan struct{}), - startCh: make(chan struct{}, 1), - resubmitIntervalCh: make(chan time.Duration), - resubmitAdjustCh: make(chan *intervalAdjust, resubmitAdjustChanSize), + config: config, + chainConfig: chainConfig, + engine: engine, + eth: eth, + mux: mux, + chain: eth.BlockChain(), + isLocalBlock: isLocalBlock, + localUncles: make(map[common.Hash]*types.Block), + remoteUncles: make(map[common.Hash]*types.Block), + unconfirmed: newUnconfirmedBlocks(eth.BlockChain(), miningLogAtDepth), + pendingTasks: make(map[common.Hash]*task), + txsCh: make(chan core.NewTxsEvent, txChanSize), + l1MsgsCh: make(chan core.NewL1MsgsEvent, txChanSize), + chainHeadCh: make(chan core.ChainHeadEvent, chainHeadChanSize), + chainSideCh: make(chan core.ChainSideEvent, chainSideChanSize), + newWorkCh: make(chan *newWorkReq), + taskCh: make(chan *task), + resultCh: make(chan *types.Block, resultQueueSize), + exitCh: make(chan struct{}), + startCh: make(chan struct{}, 1), + resubmitIntervalCh: make(chan time.Duration), + resubmitAdjustCh: make(chan *intervalAdjust, resubmitAdjustChanSize), + circuitCapacityChecker: circuitcapacitychecker.NewCircuitCapacityChecker(), } + log.Info("created new worker", "CircuitCapacityChecker ID", worker.circuitCapacityChecker.ID) // Subscribe NewTxsEvent for tx pool worker.txsSub = eth.TxPool().SubscribeNewTxsEvent(worker.txsCh) @@ -625,6 +637,14 @@ func (w *worker) taskLoop() { w.pendingMu.Lock() delete(w.pendingTasks, sealHash) w.pendingMu.Unlock() + } else { + // Store highest L1 queue index processed by this block. This includes both + // included and skipped messages. This way, if a block only skips messages, + // we won't reprocess the same messages from the next block. + rawdb.WriteFirstQueueIndexNotInL2Block(w.eth.ChainDb(), sealHash, task.maxL1Index+1) + + // Store circuit row consumption. + rawdb.WriteBlockRowConsumption(w.eth.ChainDb(), sealHash, task.accRows) } case <-w.exitCh: interrupt() @@ -714,6 +734,15 @@ func (w *worker) makeCurrent(parent *types.Block, header *types.Header) error { if err != nil { return err } + + traceEnv, err := core.CreateTraceEnv(w.chainConfig, w.chain, w.engine, state, parent, + // new block with a placeholder tx, for traceEnv's ExecutionResults length & TxStorageTraces length + types.NewBlockWithHeader(header).WithBody([]*types.Transaction{types.NewTx(&types.LegacyTx{})}, nil), + ) + if err != nil { + return err + } + state.StartPrefetcher("miner") env := &environment{ @@ -723,6 +752,7 @@ func (w *worker) makeCurrent(parent *types.Block, header *types.Header) error { family: mapset.NewSet(), uncles: mapset.NewSet(), header: header, + traceEnv: traceEnv, } // when 08 is processed ancestors contain 07 (quick block) for _, ancestor := range w.chain.GetBlocksFromHash(parent.Hash(), 7) { @@ -736,6 +766,7 @@ func (w *worker) makeCurrent(parent *types.Block, header *types.Header) error { env.tcount = 0 env.blockSize = 0 env.l1TxCount = 0 + env.maxL1Index = 0 // Swap out the old work with the new one, terminating any leftover prefetcher // processes in the mean time and starting a new one. @@ -802,21 +833,44 @@ func (w *worker) updateSnapshot() { func (w *worker) commitTransaction(tx *types.Transaction, coinbase common.Address) ([]*types.Log, error) { snap := w.current.state.Snapshot() + // has to check circuit capacity before `core.ApplyTransaction`, + // because if the tx can be successfully executed but circuit capacity overflows, it will be inconvenient to revert + traces, err := w.current.traceEnv.GetBlockTrace( + types.NewBlockWithHeader(w.current.header).WithBody([]*types.Transaction{tx}, nil), + ) + if err != nil { + // `w.current.traceEnv.State` & `w.current.state` share a same pointer to the state, so only need to revert `w.current.state` + w.current.state.RevertToSnapshot(snap) + return nil, err + } + accRows, err := w.circuitCapacityChecker.ApplyTransaction(traces) + if err != nil { + // `w.current.traceEnv.State` & `w.current.state` share a same pointer to the state, so only need to revert `w.current.state` + w.current.state.RevertToSnapshot(snap) + return nil, err + } + + // revert to snapshot for calling `core.ApplyMessage` again, (both `traceEnv.GetBlockTrace` & `core.ApplyTransaction` will call `core.ApplyMessage`) + w.current.state.RevertToSnapshot(snap) receipt, err := core.ApplyTransaction(w.chainConfig, w.chain, &coinbase, w.current.gasPool, w.current.state, w.current.header, tx, &w.current.header.GasUsed, *w.chain.GetVMConfig()) if err != nil { w.current.state.RevertToSnapshot(snap) return nil, err } + w.current.txs = append(w.current.txs, tx) w.current.receipts = append(w.current.receipts, receipt) + w.current.accRows = accRows return receipt.Logs, nil } -func (w *worker) commitTransactions(txs *types.TransactionsByPriceAndNonce, coinbase common.Address, interrupt *int32) bool { +func (w *worker) commitTransactions(txs *types.TransactionsByPriceAndNonce, coinbase common.Address, interrupt *int32) (bool, bool) { + var circuitCapacityReached bool + // Short circuit if current is nil if w.current == nil { - return true + return true, circuitCapacityReached } gasLimit := w.current.header.GasLimit @@ -826,6 +880,7 @@ func (w *worker) commitTransactions(txs *types.TransactionsByPriceAndNonce, coin var coalescedLogs []*types.Log +loop: for { // In the following three cases, we will interrupt the execution of the transaction. // (1) new head block event arrival, the interrupt signal is 1 @@ -845,7 +900,7 @@ func (w *worker) commitTransactions(txs *types.TransactionsByPriceAndNonce, coin inc: true, } } - return atomic.LoadInt32(interrupt) == commitInterruptNewHead + return atomic.LoadInt32(interrupt) == commitInterruptNewHead, circuitCapacityReached } // If we have collected enough transactions then we're done if !w.chainConfig.Scroll.IsValidL2TxCount(w.current.tcount - w.current.l1TxCount + 1) { @@ -905,6 +960,7 @@ func (w *worker) commitTransactions(txs *types.TransactionsByPriceAndNonce, coin coalescedLogs = append(coalescedLogs, logs...) if tx.IsL1MessageTx() { w.current.l1TxCount++ + w.current.maxL1Index = tx.AsL1MessageTx().QueueIndex } w.current.tcount++ w.current.blockSize += tx.Size() @@ -915,6 +971,43 @@ func (w *worker) commitTransactions(txs *types.TransactionsByPriceAndNonce, coin log.Trace("Skipping unsupported transaction type", "sender", from, "type", tx.Type()) txs.Pop() + case errors.Is(err, circuitcapacitychecker.ErrBlockRowConsumptionOverflow): + // Circuit capacity check: circuit capacity limit reached in a block, + // don't pop or shift, just quit the loop immediately; + // though it might still be possible to add some "smaller" txs, + // but it's a trade-off between tracing overhead & block usage rate + log.Trace("Circuit capacity limit reached in a block", "acc_rows", w.current.accRows, "tx", tx.Hash()) + circuitCapacityReached = true + break loop + + case (errors.Is(err, circuitcapacitychecker.ErrTxRowConsumptionOverflow) && tx.IsL1MessageTx()): + // Circuit capacity check: L1MessageTx row consumption too high, shift to the next from the account, + // because we shouldn't skip the entire txs from the same account. + // This is also useful for skipping "problematic" L1MessageTxs. + queueIndex := tx.AsL1MessageTx().QueueIndex + log.Trace("Circuit capacity limit reached for a single tx", "tx", tx.Hash(), "queueIndex", queueIndex) + w.current.maxL1Index = queueIndex + txs.Shift() + + case (errors.Is(err, circuitcapacitychecker.ErrTxRowConsumptionOverflow) && !tx.IsL1MessageTx()): + // Circuit capacity check: L2MessageTx row consumption too high, skip the account. + // This is also useful for skipping "problematic" L2MessageTxs. + log.Trace("Circuit capacity limit reached for a single tx", "tx", tx.Hash()) + txs.Pop() + + case (errors.Is(err, circuitcapacitychecker.ErrUnknown) && tx.IsL1MessageTx()): + // Circuit capacity check: unknown circuit capacity checker error for L1MessageTx, + // shift to the next from the account because we shouldn't skip the entire txs from the same account + queueIndex := tx.AsL1MessageTx().QueueIndex + log.Trace("Unknown circuit capacity checker error for L1MessageTx", "tx", tx.Hash(), "queueIndex", queueIndex) + w.current.maxL1Index = queueIndex + txs.Shift() + + case (errors.Is(err, circuitcapacitychecker.ErrUnknown) && !tx.IsL1MessageTx()): + // Circuit capacity check: unknown circuit capacity checker error for L2MessageTx, skip the account + log.Trace("Unknown circuit capacity checker error for L2MessageTx", "tx", tx.Hash()) + txs.Pop() + default: // Strange error, discard the transaction and get the next in line (note, the // nonce-too-high clause will prevent us from executing in vain). @@ -943,7 +1036,7 @@ func (w *worker) commitTransactions(txs *types.TransactionsByPriceAndNonce, coin if interrupt != nil { w.resubmitAdjustCh <- &intervalAdjust{inc: false} } - return false + return false, circuitCapacityReached } func (w *worker) collectPendingL1Messages() []types.L1MessageTx { @@ -964,6 +1057,7 @@ func (w *worker) commitNewWork(interrupt *int32, noempty bool, timestamp int64) tstart := time.Now() parent := w.chain.CurrentBlock() + w.circuitCapacityChecker.Reset() if parent.Time() >= uint64(timestamp) { timestamp = int64(parent.Time() + 1) @@ -1092,22 +1186,28 @@ func (w *worker) commitNewWork(interrupt *int32, noempty bool, timestamp int64) localTxs[account] = txs } } + var skipCommit, circuitCapacityReached bool if w.chainConfig.Scroll.ShouldIncludeL1Messages() && len(l1Txs) > 0 { log.Trace("Processing L1 messages for inclusion", "count", pendingL1Txs) txs := types.NewTransactionsByPriceAndNonce(w.current.signer, l1Txs, header.BaseFee) - if w.commitTransactions(txs, w.coinbase, interrupt) { + skipCommit, circuitCapacityReached = w.commitTransactions(txs, w.coinbase, interrupt) + if skipCommit { return } } - if len(localTxs) > 0 { + if len(localTxs) > 0 && !circuitCapacityReached { txs := types.NewTransactionsByPriceAndNonce(w.current.signer, localTxs, header.BaseFee) - if w.commitTransactions(txs, w.coinbase, interrupt) { + skipCommit, circuitCapacityReached = w.commitTransactions(txs, w.coinbase, interrupt) + if skipCommit { return } } - if len(remoteTxs) > 0 { + if len(remoteTxs) > 0 && !circuitCapacityReached { txs := types.NewTransactionsByPriceAndNonce(w.current.signer, remoteTxs, header.BaseFee) - if w.commitTransactions(txs, w.coinbase, interrupt) { + // don't need to get `circuitCapacityReached` here because we don't have further `commitTransactions` + // after this one, and if we assign it won't take effect (`ineffassign`) + skipCommit, _ = w.commitTransactions(txs, w.coinbase, interrupt) + if skipCommit { return } } @@ -1135,7 +1235,7 @@ func (w *worker) commit(uncles []*types.Header, interval func(), update bool, st interval() } select { - case w.taskCh <- &task{receipts: receipts, state: s, block: block, createdAt: time.Now()}: + case w.taskCh <- &task{receipts: receipts, state: s, block: block, createdAt: time.Now(), accRows: w.current.accRows, maxL1Index: w.current.maxL1Index}: w.unconfirmed.Shift(block.NumberU64() - 1) log.Info("Commit new mining work", "number", block.Number(), "sealhash", w.engine.SealHash(block.Header()), "uncles", len(uncles), "txs", w.current.tcount, diff --git a/miner/worker_test.go b/miner/worker_test.go index 5352dd9f8d..78ce61df03 100644 --- a/miner/worker_test.go +++ b/miner/worker_test.go @@ -140,7 +140,7 @@ func newTestWorkerBackend(t *testing.T, chainConfig *params.ChainConfig, engine chain, _ := core.NewBlockChain(db, &core.CacheConfig{TrieDirtyDisabled: true}, gspec.Config, engine, vm.Config{ Debug: true, - Tracer: vm.NewStructLogger(&vm.LogConfig{EnableMemory: true})}, nil, nil) + Tracer: vm.NewStructLogger(&vm.LogConfig{EnableMemory: true})}, nil, nil, false) txpool := core.NewTxPool(testTxPoolConfig, chainConfig, chain) // Generate a small n-block chain and an uncle block for it @@ -241,7 +241,7 @@ func testGenerateBlockAndImport(t *testing.T, isClique bool) { b.genesis.MustCommit(db2) chain, _ := core.NewBlockChain(db2, nil, b.chain.Config(), engine, vm.Config{ Debug: true, - Tracer: vm.NewStructLogger(&vm.LogConfig{EnableMemory: true, EnableReturnData: true})}, nil, nil) + Tracer: vm.NewStructLogger(&vm.LogConfig{EnableMemory: true, EnableReturnData: true})}, nil, nil, false) defer chain.Stop() // Ignore empty commit here for less noise. @@ -571,7 +571,7 @@ func testGenerateBlockWithL1Msg(t *testing.T, isClique bool) { b.genesis.MustCommit(db) chain, _ := core.NewBlockChain(db, nil, b.chain.Config(), engine, vm.Config{ Debug: true, - Tracer: vm.NewStructLogger(&vm.LogConfig{EnableMemory: true, EnableReturnData: true})}, nil, nil) + Tracer: vm.NewStructLogger(&vm.LogConfig{EnableMemory: true, EnableReturnData: true})}, nil, nil, false) defer chain.Stop() // Ignore empty commit here for less noise. @@ -637,7 +637,7 @@ func TestExcludeL1MsgFromTxlimit(t *testing.T) { b.genesis.MustCommit(db) chain, _ := core.NewBlockChain(db, nil, b.chain.Config(), engine, vm.Config{ Debug: true, - Tracer: vm.NewStructLogger(&vm.LogConfig{EnableMemory: true, EnableReturnData: true})}, nil, nil) + Tracer: vm.NewStructLogger(&vm.LogConfig{EnableMemory: true, EnableReturnData: true})}, nil, nil, false) defer chain.Stop() // Ignore empty commit here for less noise. @@ -698,7 +698,7 @@ func TestL1MsgCorrectOrder(t *testing.T) { b.genesis.MustCommit(db) chain, _ := core.NewBlockChain(db, nil, b.chain.Config(), engine, vm.Config{ Debug: true, - Tracer: vm.NewStructLogger(&vm.LogConfig{EnableMemory: true, EnableReturnData: true})}, nil, nil) + Tracer: vm.NewStructLogger(&vm.LogConfig{EnableMemory: true, EnableReturnData: true})}, nil, nil, false) defer chain.Stop() // Ignore empty commit here for less noise. diff --git a/params/version.go b/params/version.go index 6fc08d7b70..119e4be5f6 100644 --- a/params/version.go +++ b/params/version.go @@ -24,7 +24,7 @@ import ( const ( VersionMajor = 4 // Major version component of the current release VersionMinor = 3 // Minor version component of the current release - VersionPatch = 0 // Patch version component of the current release + VersionPatch = 1 // Patch version component of the current release VersionMeta = "sepolia" // Version metadata to append to the version string ) diff --git a/rollup/circuitcapacitychecker/impl.go b/rollup/circuitcapacitychecker/impl.go new file mode 100644 index 0000000000..beb595f9fe --- /dev/null +++ b/rollup/circuitcapacitychecker/impl.go @@ -0,0 +1,141 @@ +//go:build circuit_capacity_checker + +package circuitcapacitychecker + +/* +#cgo LDFLAGS: -lm -ldl -lzkp -lzktrie +#include +#include "./libzkp/libzkp.h" +*/ +import "C" //nolint:typecheck + +import ( + "encoding/json" + "sync" + "unsafe" + + "github.com/scroll-tech/go-ethereum/core/types" + "github.com/scroll-tech/go-ethereum/log" +) + +// mutex for concurrent CircuitCapacityChecker creations +var creationMu sync.Mutex + +func init() { + C.init() +} + +type CircuitCapacityChecker struct { + // mutex for each CircuitCapacityChecker itself + sync.Mutex + ID uint64 +} + +func NewCircuitCapacityChecker() *CircuitCapacityChecker { + creationMu.Lock() + defer creationMu.Unlock() + + id := C.new_circuit_capacity_checker() + return &CircuitCapacityChecker{ID: uint64(id)} +} + +func (ccc *CircuitCapacityChecker) Reset() { + ccc.Lock() + defer ccc.Unlock() + + C.reset_circuit_capacity_checker(C.uint64_t(ccc.ID)) +} + +func (ccc *CircuitCapacityChecker) ApplyTransaction(traces *types.BlockTrace) (*types.RowConsumption, error) { + ccc.Lock() + defer ccc.Unlock() + + if len(traces.Transactions) != 1 || len(traces.ExecutionResults) != 1 || len(traces.TxStorageTraces) != 1 { + log.Error("malformatted BlockTrace in ApplyTransaction", "id", ccc.ID, + "len(traces.Transactions)", len(traces.Transactions), + "len(traces.ExecutionResults)", len(traces.ExecutionResults), + "len(traces.TxStorageTraces)", len(traces.TxStorageTraces), + "err", "length of Transactions, or ExecutionResults, or TxStorageTraces, is not equal to 1") + return nil, ErrUnknown + } + + tracesByt, err := json.Marshal(traces) + if err != nil { + log.Error("fail to json marshal traces in ApplyTransaction", "id", ccc.ID, "TxHash", traces.Transactions[0].TxHash, "err", err) + return nil, ErrUnknown + } + + tracesStr := C.CString(string(tracesByt)) + defer func() { + C.free(unsafe.Pointer(tracesStr)) + }() + + log.Debug("start to check circuit capacity for tx", "id", ccc.ID, "TxHash", traces.Transactions[0].TxHash) + rawResult := C.apply_tx(C.uint64_t(ccc.ID), tracesStr) + log.Debug("check circuit capacity for tx done", "id", ccc.ID, "TxHash", traces.Transactions[0].TxHash) + + result := &WrappedRowUsage{} + if err = json.Unmarshal([]byte(C.GoString(rawResult)), result); err != nil { + log.Error("fail to json unmarshal apply_tx result", "id", ccc.ID, "TxHash", traces.Transactions[0].TxHash, "err", err) + return nil, ErrUnknown + } + + if result.Error != "" { + log.Error("fail to apply_tx in CircuitCapacityChecker", "id", ccc.ID, "TxHash", traces.Transactions[0].TxHash, "err", result.Error) + return nil, ErrUnknown + } + if result.TxRowUsage == nil || result.AccRowUsage == nil { + log.Error("fail to apply_tx in CircuitCapacityChecker", + "id", ccc.ID, "TxHash", traces.Transactions[0].TxHash, + "len(result.TxRowUsage)", len(result.TxRowUsage), + "len(result.AccRowUsage)", len(result.AccRowUsage), + "err", "TxRowUsage or AccRowUsage is empty unexpectedly") + return nil, ErrUnknown + } + if !result.TxRowUsage.IsOk { + return nil, ErrTxRowConsumptionOverflow + } + if !result.AccRowUsage.IsOk { + return nil, ErrBlockRowConsumptionOverflow + } + return (*types.RowConsumption)(&result.AccRowUsage.RowUsageDetails), nil +} + +func (ccc *CircuitCapacityChecker) ApplyBlock(traces *types.BlockTrace) (*types.RowConsumption, error) { + ccc.Lock() + defer ccc.Unlock() + + tracesByt, err := json.Marshal(traces) + if err != nil { + log.Error("fail to json marshal traces in ApplyBlock", "id", ccc.ID, "blockNumber", traces.Header.Number, "blockHash", traces.Header.Hash(), "err", err) + return nil, ErrUnknown + } + + tracesStr := C.CString(string(tracesByt)) + defer func() { + C.free(unsafe.Pointer(tracesStr)) + }() + + log.Debug("start to check circuit capacity for block", "id", ccc.ID, "blockNumber", traces.Header.Number, "blockHash", traces.Header.Hash()) + rawResult := C.apply_block(C.uint64_t(ccc.ID), tracesStr) + log.Debug("check circuit capacity for block done", "id", ccc.ID, "blockNumber", traces.Header.Number, "blockHash", traces.Header.Hash()) + + result := &WrappedRowUsage{} + if err = json.Unmarshal([]byte(C.GoString(rawResult)), result); err != nil { + log.Error("fail to json unmarshal apply_block result", "id", ccc.ID, "blockNumber", traces.Header.Number, "blockHash", traces.Header.Hash(), "err", err) + return nil, ErrUnknown + } + + if result.Error != "" { + log.Error("fail to apply_block in CircuitCapacityChecker", "id", ccc.ID, "blockNumber", traces.Header.Number, "blockHash", traces.Header.Hash(), "err", result.Error) + return nil, ErrUnknown + } + if result.AccRowUsage == nil { + log.Error("fail to apply_block in CircuitCapacityChecker", "id", ccc.ID, "blockNumber", traces.Header.Number, "blockHash", traces.Header.Hash(), "err", "AccRowUsage is empty unexpectedly") + return nil, ErrUnknown + } + if !result.AccRowUsage.IsOk { + return nil, ErrBlockRowConsumptionOverflow + } + return (*types.RowConsumption)(&result.AccRowUsage.RowUsageDetails), nil +} diff --git a/rollup/circuitcapacitychecker/libzkp/.gitignore b/rollup/circuitcapacitychecker/libzkp/.gitignore new file mode 100644 index 0000000000..3170fd5618 --- /dev/null +++ b/rollup/circuitcapacitychecker/libzkp/.gitignore @@ -0,0 +1,3 @@ +target/ +*.a +*.so diff --git a/rollup/circuitcapacitychecker/libzkp/Cargo.lock b/rollup/circuitcapacitychecker/libzkp/Cargo.lock new file mode 100644 index 0000000000..43b1736549 --- /dev/null +++ b/rollup/circuitcapacitychecker/libzkp/Cargo.lock @@ -0,0 +1,4504 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" + +[[package]] +name = "aes" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e8b47f52ea9bae42228d07ec09eb676433d7c4ed1ebdf0f1d1c29ed446f1ab8" +dependencies = [ + "cfg-if 1.0.0", + "cipher", + "cpufeatures", + "opaque-debug 0.3.0", +] + +[[package]] +name = "aggregator" +version = "0.1.0" +source = "git+https://github.com/scroll-tech/zkevm-circuits.git?branch=develop#82fc8ae1176d092227bdc946702b86ed2ca545e4" +dependencies = [ + "ark-std", + "env_logger 0.10.0", + "eth-types", + "ethers-core", + "halo2_proofs", + "itertools", + "log", + "rand", + "serde", + "serde_json", + "snark-verifier", + "snark-verifier-sdk", + "zkevm-circuits", +] + +[[package]] +name = "ahash" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" +dependencies = [ + "getrandom", + "once_cell", + "version_check", +] + +[[package]] +name = "ahash" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" +dependencies = [ + "cfg-if 1.0.0", + "once_cell", + "version_check", +] + +[[package]] +name = "aho-corasick" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67fc08ce920c31afb70f013dcce1bfc3a3195de6a228474e45e1f145b36f8d04" +dependencies = [ + "memchr", +] + +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + +[[package]] +name = "anyhow" +version = "1.0.71" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c7d0618f0e0b7e8ff11427422b64564d5fb0be1940354bfe2e0529b18a9d9b8" + +[[package]] +name = "arc-swap" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bddcadddf5e9015d310179a59bb28c4d4b9920ad0f11e8e14dbadf654890c9a6" + +[[package]] +name = "ark-std" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1df2c09229cbc5a028b1d70e00fdb2acee28b1055dfb5ca73eea49c5a25c4e7c" +dependencies = [ + "num-traits", + "rand", +] + +[[package]] +name = "array-init" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d62b7694a562cdf5a74227903507c56ab2cc8bdd1f781ed5cb4cf9c9f810bfc" + +[[package]] +name = "arrayref" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b4930d2cb77ce62f89ee5d5289b4ac049559b1c45539271f5ed4fdc7db34545" + +[[package]] +name = "arrayvec" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6" + +[[package]] +name = "async-trait" +version = "0.1.68" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9ccdd8f2a161be9bd5c023df56f1b2a0bd1d83872ae53b71a84a12c9bf6e842" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.15", +] + +[[package]] +name = "async_io_stream" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6d7b9decdf35d8908a7e3ef02f64c5e9b1695e230154c0e8de3969142d9b94c" +dependencies = [ + "futures", + "pharos", + "rustc_version", +] + +[[package]] +name = "atty" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" +dependencies = [ + "hermit-abi 0.1.19", + "libc", + "winapi", +] + +[[package]] +name = "auto_impl" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fee3da8ef1276b0bee5dd1c7258010d8fffd31801447323115a25560e1327b89" +dependencies = [ + "proc-macro-error", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + +[[package]] +name = "base16ct" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "349a06037c7bf932dd7e7d1f653678b2038b9ad46a74102f1fc7bd7872678cce" + +[[package]] +name = "base58" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5024ee8015f02155eee35c711107ddd9a9bf3cb689cf2a9089c97e79b6e1ae83" + +[[package]] +name = "base58check" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ee2fe4c9a0c84515f136aaae2466744a721af6d63339c18689d9e995d74d99b" +dependencies = [ + "base58", + "sha2 0.8.2", +] + +[[package]] +name = "base64" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3441f0f7b02788e948e47f457ca01f1d7e6d92c693bc132c22b087d3141c03ff" + +[[package]] +name = "base64" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" + +[[package]] +name = "base64" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4a4ddaa51a5bc52a6948f74c06d20aaaddb71924eab79b8c97a8c556e942d6a" + +[[package]] +name = "base64ct" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a32fd6af2b5827bce66c29053ba0e7c42b9dcab01835835058558c10851a46b" + +[[package]] +name = "bech32" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dabbe35f96fb9507f7330793dc490461b2962659ac5d427181e451a623751d1" + +[[package]] +name = "bincode" +version = "1.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" +dependencies = [ + "serde", +] + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitvec" +version = "0.17.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41262f11d771fd4a61aa3ce019fca363b4b6c282fca9da2a31186d3965a47a5c" +dependencies = [ + "either", + "radium 0.3.0", +] + +[[package]] +name = "bitvec" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" +dependencies = [ + "funty", + "radium 0.7.0", + "tap", + "wyz", +] + +[[package]] +name = "blake2" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46502ad458c9a52b69d4d4d32775c788b7a1b85e8bc9d482d92250fc0e3f8efe" +dependencies = [ + "digest 0.10.6", +] + +[[package]] +name = "blake2b_simd" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c2f0dc9a68c6317d884f97cc36cf5a3d20ba14ce404227df55e1af708ab04bc" +dependencies = [ + "arrayref", + "arrayvec", + "constant_time_eq", +] + +[[package]] +name = "block-buffer" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a076c298b9ecdb530ed9d967e74a6027d6a7478924520acddcddc24c1c8ab3ab" +dependencies = [ + "arrayref", + "byte-tools 0.2.0", +] + +[[package]] +name = "block-buffer" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b" +dependencies = [ + "block-padding 0.1.5", + "byte-tools 0.3.1", + "byteorder", + "generic-array 0.12.4", +] + +[[package]] +name = "block-buffer" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" +dependencies = [ + "block-padding 0.2.1", + "generic-array 0.14.7", +] + +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array 0.14.7", +] + +[[package]] +name = "block-padding" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa79dedbb091f449f1f39e53edf88d5dbe95f895dae6135a8d7b881fb5af73f5" +dependencies = [ + "byte-tools 0.3.1", +] + +[[package]] +name = "block-padding" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d696c370c750c948ada61c69a0ee2cbbb9c50b1019ddb86d9317157a99c2cae" + +[[package]] +name = "borsh" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4114279215a005bc675e386011e594e1d9b800918cea18fcadadcce864a2046b" +dependencies = [ + "borsh-derive", + "hashbrown 0.13.2", +] + +[[package]] +name = "borsh-derive" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0754613691538d51f329cce9af41d7b7ca150bc973056f1156611489475f54f7" +dependencies = [ + "borsh-derive-internal", + "borsh-schema-derive-internal", + "proc-macro-crate 0.1.5", + "proc-macro2", + "syn 1.0.109", +] + +[[package]] +name = "borsh-derive-internal" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "afb438156919598d2c7bad7e1c0adf3d26ed3840dbc010db1a882a65583ca2fb" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "borsh-schema-derive-internal" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "634205cc43f74a1b9046ef87c4540ebda95696ec0f315024860cad7c5b0f5ccd" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "bs58" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "771fe0050b883fcc3ea2359b1a96bcfbc090b7116eae7c3c512c7a083fdf23d3" + +[[package]] +name = "bumpalo" +version = "3.12.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c6ed94e98ecff0c12dd1b04c15ec0d7d9458ca8fe806cea6f12954efe74c63b" + +[[package]] +name = "bus-mapping" +version = "0.1.0" +source = "git+https://github.com/scroll-tech/zkevm-circuits.git?branch=develop#82fc8ae1176d092227bdc946702b86ed2ca545e4" +dependencies = [ + "eth-types", + "ethers-core", + "ethers-providers", + "ethers-signers", + "gadgets", + "halo2_proofs", + "hex", + "itertools", + "keccak256", + "lazy_static", + "log", + "mock", + "once_cell", + "poseidon-circuit", + "rand", + "revm-precompile", + "serde", + "serde_json", + "strum", + "strum_macros", +] + +[[package]] +name = "byte-slice-cast" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" + +[[package]] +name = "byte-tools" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "560c32574a12a89ecd91f5e742165893f86e3ab98d21f8ea548658eb9eef5f40" + +[[package]] +name = "byte-tools" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" + +[[package]] +name = "bytecheck" +version = "0.6.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13fe11640a23eb24562225322cd3e452b93a3d4091d62fab69c70542fcd17d1f" +dependencies = [ + "bytecheck_derive", + "ptr_meta", + "simdutf8", +] + +[[package]] +name = "bytecheck_derive" +version = "0.6.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e31225543cb46f81a7e224762764f4a6a0f097b1db0b175f69e8065efaa42de5" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "byteorder" +version = "1.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" + +[[package]] +name = "bytes" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" +dependencies = [ + "serde", +] + +[[package]] +name = "cc" +version = "1.0.79" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" + +[[package]] +name = "cfg-if" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "chrono" +version = "0.4.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e3c5919066adf22df73762e50cffcde3a758f2a848b113b586d1f86728b673b" +dependencies = [ + "iana-time-zone", + "js-sys", + "num-integer", + "num-traits", + "time", + "wasm-bindgen", + "winapi", +] + +[[package]] +name = "cipher" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ee52072ec15386f770805afd189a01c8841be8696bed250fa2f13c4c0d6dfb7" +dependencies = [ + "generic-array 0.14.7", +] + +[[package]] +name = "codespan-reporting" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e" +dependencies = [ + "termcolor", + "unicode-width", +] + +[[package]] +name = "coins-bip32" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "634c509653de24b439672164bbf56f5f582a2ab0e313d3b0f6af0b7345cf2560" +dependencies = [ + "bincode", + "bs58", + "coins-core", + "digest 0.10.6", + "getrandom", + "hmac 0.12.1", + "k256", + "lazy_static", + "serde", + "sha2 0.10.6", + "thiserror", +] + +[[package]] +name = "coins-bip39" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a11892bcac83b4c6e95ab84b5b06c76d9d70ad73548dd07418269c5c7977171" +dependencies = [ + "bitvec 0.17.4", + "coins-bip32", + "getrandom", + "hex", + "hmac 0.12.1", + "pbkdf2 0.11.0", + "rand", + "sha2 0.10.6", + "thiserror", +] + +[[package]] +name = "coins-core" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c94090a6663f224feae66ab01e41a2555a8296ee07b5f20dab8888bdefc9f617" +dependencies = [ + "base58check", + "base64 0.12.3", + "bech32", + "blake2", + "digest 0.10.6", + "generic-array 0.14.7", + "hex", + "ripemd", + "serde", + "serde_derive", + "sha2 0.10.6", + "sha3 0.10.8", + "thiserror", +] + +[[package]] +name = "const-oid" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "520fbf3c07483f94e3e3ca9d0cfd913d7718ef2483d2cfd91c0d9e91474ab913" + +[[package]] +name = "constant_time_eq" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13418e745008f7349ec7e449155f419a61b92b58a99cc3616942b926825ec76b" + +[[package]] +name = "convert_case" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" + +[[package]] +name = "convert_case" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb4a24b1aaf0fd0ce8b45161144d6f42cd91677fd5940fd431183eb023b3a2b8" + +[[package]] +name = "core-foundation-sys" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" + +[[package]] +name = "cpufeatures" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e4c1eaa2012c47becbbad2ab175484c2a84d1185b566fb2cc5b8707343dfe58" +dependencies = [ + "libc", +] + +[[package]] +name = "crc32fast" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" +dependencies = [ + "cfg-if 1.0.0", +] + +[[package]] +name = "crossbeam" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2801af0d36612ae591caa9568261fddce32ce6e08a7275ea334a06a4ad021a2c" +dependencies = [ + "cfg-if 1.0.0", + "crossbeam-channel", + "crossbeam-deque", + "crossbeam-epoch", + "crossbeam-queue", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-channel" +version = "0.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a33c2bf77f2df06183c3aa30d1e96c0695a313d4f9c453cc3762a6db39f99200" +dependencies = [ + "cfg-if 1.0.0", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-deque" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce6fd6f855243022dcecf8702fef0c297d4338e226845fe067f6341ad9fa0cef" +dependencies = [ + "cfg-if 1.0.0", + "crossbeam-epoch", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46bd5f3f85273295a9d14aedfb86f6aadbff6d8f5295c4a9edb08e819dcf5695" +dependencies = [ + "autocfg", + "cfg-if 1.0.0", + "crossbeam-utils", + "memoffset", + "scopeguard", +] + +[[package]] +name = "crossbeam-queue" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1cfb3ea8a53f37c40dea2c7bedcbd88bdfae54f5e2175d6ecaff1c988353add" +dependencies = [ + "cfg-if 1.0.0", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c063cd8cc95f5c377ed0d4b49a4b21f632396ff690e8470c29b3359b346984b" +dependencies = [ + "cfg-if 1.0.0", +] + +[[package]] +name = "crunchy" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" + +[[package]] +name = "crypto-bigint" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef2b4b23cddf68b89b8f8069890e8c270d54e2d5fe1b143820234805e4cb17ef" +dependencies = [ + "generic-array 0.14.7", + "rand_core", + "subtle", + "zeroize", +] + +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array 0.14.7", + "typenum", +] + +[[package]] +name = "crypto-mac" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b584a330336237c1eecd3e94266efb216c56ed91225d634cb2991c5f3fd1aeab" +dependencies = [ + "generic-array 0.14.7", + "subtle", +] + +[[package]] +name = "ctr" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "049bb91fb4aaf0e3c7efa6cd5ef877dbbbd15b39dad06d9948de4ec8a75761ea" +dependencies = [ + "cipher", +] + +[[package]] +name = "cxx" +version = "1.0.94" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f61f1b6389c3fe1c316bf8a4dccc90a38208354b330925bce1f74a6c4756eb93" +dependencies = [ + "cc", + "cxxbridge-flags", + "cxxbridge-macro", + "link-cplusplus", +] + +[[package]] +name = "cxx-build" +version = "1.0.94" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12cee708e8962df2aeb38f594aae5d827c022b6460ac71a7a3e2c3c2aae5a07b" +dependencies = [ + "cc", + "codespan-reporting", + "once_cell", + "proc-macro2", + "quote", + "scratch", + "syn 2.0.15", +] + +[[package]] +name = "cxxbridge-flags" +version = "1.0.94" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7944172ae7e4068c533afbb984114a56c46e9ccddda550499caa222902c7f7bb" + +[[package]] +name = "cxxbridge-macro" +version = "1.0.94" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2345488264226bf682893e25de0769f3360aac9957980ec49361b083ddaa5bc5" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.15", +] + +[[package]] +name = "darling" +version = "0.13.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a01d95850c592940db9b8194bc39f4bc0e89dee5c4265e4b1807c34a9aba453c" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.13.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "859d65a907b6852c9361e3185c862aae7fafd2887876799fa55f5f99dc40d610" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn 1.0.109", +] + +[[package]] +name = "darling_macro" +version = "0.13.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c972679f83bdf9c42bd905396b6c3588a843a17f0f16dfcfa3e2c5d57441835" +dependencies = [ + "darling_core", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "der" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1a467a65c5e759bce6e65eaf91cc29f466cdc57cb65777bd646872a8a1fd4de" +dependencies = [ + "const-oid", + "zeroize", +] + +[[package]] +name = "derivative" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "derive_more" +version = "0.99.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" +dependencies = [ + "convert_case 0.4.0", + "proc-macro2", + "quote", + "rustc_version", + "syn 1.0.109", +] + +[[package]] +name = "digest" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03b072242a8cbaf9c145665af9d250c59af3b958f83ed6824e13533cf76d5b90" +dependencies = [ + "generic-array 0.9.1", +] + +[[package]] +name = "digest" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" +dependencies = [ + "generic-array 0.12.4", +] + +[[package]] +name = "digest" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" +dependencies = [ + "generic-array 0.14.7", +] + +[[package]] +name = "digest" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8168378f4e5023e7218c89c891c0fd8ecdb5e5e4f18cb78f38cf245dd021e76f" +dependencies = [ + "block-buffer 0.10.4", + "crypto-common", + "subtle", +] + +[[package]] +name = "dotenv" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77c90badedccf4105eca100756a0b1289e191f6fcbdadd3cee1d2f614f97da8f" + +[[package]] +name = "ecdsa" +version = "0.14.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "413301934810f597c1d19ca71c8710e99a3f1ba28a0d2ebc01551a2daeea3c5c" +dependencies = [ + "der", + "elliptic-curve", + "rfc6979", + "signature", +] + +[[package]] +name = "either" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" + +[[package]] +name = "elliptic-curve" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7bb888ab5300a19b8e5bceef25ac745ad065f3c9f7efc6de1b91958110891d3" +dependencies = [ + "base16ct", + "crypto-bigint", + "der", + "digest 0.10.6", + "ff", + "generic-array 0.14.7", + "group", + "pkcs8", + "rand_core", + "sec1", + "subtle", + "zeroize", +] + +[[package]] +name = "encoding_rs" +version = "0.8.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071a31f4ee85403370b58aca746f01041ede6f0da2730960ad001edc2b71b394" +dependencies = [ + "cfg-if 1.0.0", +] + +[[package]] +name = "enumn" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48016319042fb7c87b78d2993084a831793a897a5cd1a2a67cab9d1eeb4b7d76" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.15", +] + +[[package]] +name = "env_logger" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a19187fea3ac7e84da7dacf48de0c45d63c6a76f9490dae389aead16c243fce3" +dependencies = [ + "atty", + "humantime", + "log", + "regex", + "termcolor", +] + +[[package]] +name = "env_logger" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a12e6657c4c97ebab115a42dcee77225f7f482cdd841cf7088c657a42e9e00e7" +dependencies = [ + "atty", + "humantime", + "log", + "regex", + "termcolor", +] + +[[package]] +name = "env_logger" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85cdab6a89accf66733ad5a1693a4dcced6aeff64602b634530dd73c1f3ee9f0" +dependencies = [ + "humantime", + "is-terminal", + "log", + "regex", + "termcolor", +] + +[[package]] +name = "errno" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f639046355ee4f37944e44f60642c6f3a7efa3cf6b78c78a0d989a8ce6c396a1" +dependencies = [ + "errno-dragonfly", + "libc", + "winapi", +] + +[[package]] +name = "errno" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4bcfec3a70f97c962c307b2d2c56e358cf1d00b558d74262b5f929ee8cc7e73a" +dependencies = [ + "errno-dragonfly", + "libc", + "windows-sys 0.48.0", +] + +[[package]] +name = "errno-dragonfly" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" +dependencies = [ + "cc", + "libc", +] + +[[package]] +name = "eth-keystore" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f65b750ac950f2f825b36d08bef4cda4112e19a7b1a68f6e2bb499413e12440" +dependencies = [ + "aes", + "ctr", + "digest 0.10.6", + "hex", + "hmac 0.12.1", + "pbkdf2 0.11.0", + "rand", + "scrypt", + "serde", + "serde_json", + "sha2 0.10.6", + "sha3 0.10.8", + "thiserror", + "uuid", +] + +[[package]] +name = "eth-types" +version = "0.1.0" +source = "git+https://github.com/scroll-tech/zkevm-circuits.git?branch=develop#82fc8ae1176d092227bdc946702b86ed2ca545e4" +dependencies = [ + "ethers-core", + "ethers-signers", + "halo2_proofs", + "hex", + "itertools", + "lazy_static", + "libsecp256k1", + "num", + "num-bigint", + "poseidon-circuit", + "regex", + "serde", + "serde_json", + "serde_with", + "sha3 0.10.8", + "strum", + "strum_macros", + "subtle", + "uint", +] + +[[package]] +name = "ethabi" +version = "17.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4966fba78396ff92db3b817ee71143eccd98acf0f876b8d600e585a670c5d1b" +dependencies = [ + "ethereum-types 0.13.1", + "hex", + "once_cell", + "regex", + "serde", + "serde_json", + "sha3 0.10.8", + "thiserror", + "uint", +] + +[[package]] +name = "ethbloom" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11da94e443c60508eb62cf256243a64da87304c2802ac2528847f79d750007ef" +dependencies = [ + "crunchy", + "fixed-hash 0.7.0", + "impl-rlp", + "impl-serde", + "tiny-keccak", +] + +[[package]] +name = "ethbloom" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c22d4b5885b6aa2fe5e8b9329fb8d232bf739e434e6b87347c63bdd00c120f60" +dependencies = [ + "crunchy", + "fixed-hash 0.8.0", + "tiny-keccak", +] + +[[package]] +name = "ethereum-types" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2827b94c556145446fcce834ca86b7abf0c39a805883fe20e72c5bfdb5a0dc6" +dependencies = [ + "ethbloom 0.12.1", + "fixed-hash 0.7.0", + "impl-rlp", + "impl-serde", + "primitive-types 0.11.1", + "uint", +] + +[[package]] +name = "ethereum-types" +version = "0.14.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02d215cbf040552efcbe99a38372fe80ab9d00268e20012b79fcd0f073edd8ee" +dependencies = [ + "ethbloom 0.13.0", + "fixed-hash 0.8.0", + "primitive-types 0.12.1", + "uint", +] + +[[package]] +name = "ethers-core" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ebdd63c828f58aa067f40f9adcbea5e114fb1f90144b3a1e2858e0c9b1ff4e8" +dependencies = [ + "arrayvec", + "bytes", + "chrono", + "convert_case 0.5.0", + "elliptic-curve", + "ethabi", + "fastrlp", + "generic-array 0.14.7", + "hex", + "k256", + "proc-macro2", + "rand", + "rlp", + "rlp-derive", + "rust_decimal", + "serde", + "serde_json", + "strum", + "syn 1.0.109", + "thiserror", + "tiny-keccak", + "unicode-xid", +] + +[[package]] +name = "ethers-providers" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e46482e4d1e79b20c338fd9db9e166184eb387f0a4e7c05c5b5c0aa2e8c8900c" +dependencies = [ + "async-trait", + "auto_impl", + "base64 0.13.1", + "ethers-core", + "futures-channel", + "futures-core", + "futures-timer", + "futures-util", + "getrandom", + "hashers", + "hex", + "http", + "once_cell", + "parking_lot 0.11.2", + "pin-project", + "reqwest", + "serde", + "serde_json", + "thiserror", + "tokio", + "tokio-tungstenite", + "tracing", + "tracing-futures", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "wasm-timer", + "web-sys", + "ws_stream_wasm", +] + +[[package]] +name = "ethers-signers" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73a72ecad124e8ccd18d6a43624208cab0199e59621b1f0fa6b776b2e0529107" +dependencies = [ + "async-trait", + "coins-bip32", + "coins-bip39", + "elliptic-curve", + "eth-keystore", + "ethers-core", + "hex", + "rand", + "sha2 0.10.6", + "thiserror", +] + +[[package]] +name = "external-tracer" +version = "0.1.0" +source = "git+https://github.com/scroll-tech/zkevm-circuits.git?branch=develop#82fc8ae1176d092227bdc946702b86ed2ca545e4" +dependencies = [ + "eth-types", + "geth-utils", + "log", + "serde", + "serde_json", +] + +[[package]] +name = "fake-simd" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" + +[[package]] +name = "fastrlp" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "089263294bb1c38ac73649a6ad563dd9a5142c8dc0482be15b8b9acb22a1611e" +dependencies = [ + "arrayvec", + "auto_impl", + "bytes", + "ethereum-types 0.13.1", + "fastrlp-derive", +] + +[[package]] +name = "fastrlp-derive" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0f9d074ab623d1b388c12544bfeed759c7df36dc5c300cda053df9ba1232075" +dependencies = [ + "bytes", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "ff" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d013fc25338cc558c5c2cfbad646908fb23591e2404481826742b651c9af7160" +dependencies = [ + "bitvec 1.0.1", + "rand_core", + "subtle", +] + +[[package]] +name = "fixed-hash" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfcf0ed7fe52a17a03854ec54a9f76d6d84508d1c0e66bc1793301c73fc8493c" +dependencies = [ + "byteorder", + "rand", + "rustc-hex", + "static_assertions", +] + +[[package]] +name = "fixed-hash" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "835c052cb0c08c1acf6ffd71c022172e18723949c8282f2b9f27efbc51e64534" +dependencies = [ + "byteorder", + "rand", + "rustc-hex", + "static_assertions", +] + +[[package]] +name = "flate2" +version = "1.0.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b9429470923de8e8cbd4d2dc513535400b4b3fef0319fb5c4e1f520a7bef743" +dependencies = [ + "crc32fast", + "miniz_oxide", +] + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "form_urlencoded" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9c384f161156f5260c24a097c56119f9be8c798586aecc13afbcbe7b7e26bf8" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "funty" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" + +[[package]] +name = "futures" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23342abe12aba583913b2e62f22225ff9c950774065e4bfb61a19cd9770fec40" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-channel" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "955518d47e09b25bbebc7a18df10b81f0c766eaf4c4f1cccef2fca5f2a4fb5f2" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c" + +[[package]] +name = "futures-executor" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccecee823288125bd88b4d7f565c9e58e41858e47ab72e8ea2d64e93624386e0" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-io" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fff74096e71ed47f8e023204cfd0aa1289cd54ae5430a9523be060cdb849964" + +[[package]] +name = "futures-macro" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.15", +] + +[[package]] +name = "futures-sink" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f43be4fe21a13b9781a69afa4985b0f6ee0e1afab2c6f454a8cf30e2b2237b6e" + +[[package]] +name = "futures-task" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76d3d132be6c0e6aa1534069c705a74a5997a356c0dc2f86a47765e5617c5b65" + +[[package]] +name = "futures-timer" +version = "3.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e64b03909df88034c26dc1547e8970b91f98bdb65165d6a4e9110d94263dbb2c" + +[[package]] +name = "futures-util" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-macro", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite", + "pin-utils", + "slab", +] + +[[package]] +name = "fxhash" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c31b6d751ae2c7f11320402d34e41349dd1016f8d5d45e48c4312bc8625af50c" +dependencies = [ + "byteorder", +] + +[[package]] +name = "gadgets" +version = "0.1.0" +source = "git+https://github.com/scroll-tech/zkevm-circuits.git?branch=develop#82fc8ae1176d092227bdc946702b86ed2ca545e4" +dependencies = [ + "digest 0.7.6", + "eth-types", + "halo2_proofs", + "sha3 0.7.3", + "strum", +] + +[[package]] +name = "generic-array" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d00328cedcac5e81c683e5620ca6a30756fc23027ebf9bff405c0e8da1fbb7e" +dependencies = [ + "typenum", +] + +[[package]] +name = "generic-array" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffdf9f34f1447443d37393cc6c2b8313aebddcd96906caf34e54c68d8e57d7bd" +dependencies = [ + "typenum", +] + +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "geth-utils" +version = "0.1.0" +source = "git+https://github.com/scroll-tech/zkevm-circuits.git?branch=develop#82fc8ae1176d092227bdc946702b86ed2ca545e4" +dependencies = [ + "env_logger 0.9.3", + "gobuild 0.1.0-alpha.2 (git+https://github.com/scroll-tech/gobuild.git)", + "log", +] + +[[package]] +name = "getrandom" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c85e1d9ab2eadba7e5040d4e09cbd6d072b76a557ad64e797c2cb9d4da21d7e4" +dependencies = [ + "cfg-if 1.0.0", + "js-sys", + "libc", + "wasi 0.11.0+wasi-snapshot-preview1", + "wasm-bindgen", +] + +[[package]] +name = "git-version" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6b0decc02f4636b9ccad390dcbe77b722a77efedfa393caf8379a51d5c61899" +dependencies = [ + "git-version-macro", + "proc-macro-hack", +] + +[[package]] +name = "git-version-macro" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe69f1cbdb6e28af2bac214e943b99ce8a0a06b447d15d3e61161b0423139f3f" +dependencies = [ + "proc-macro-hack", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "glob" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" + +[[package]] +name = "gobuild" +version = "0.1.0-alpha.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71e156a4ddbf3deb5e8116946c111413bd9a5679bdc1536c78a60618a7a9ac9e" +dependencies = [ + "cc", +] + +[[package]] +name = "gobuild" +version = "0.1.0-alpha.2" +source = "git+https://github.com/scroll-tech/gobuild.git#8b84111fc3b58e2134e4794a06d1f199412cf2b0" +dependencies = [ + "cc", +] + +[[package]] +name = "group" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5dfbfb3a6cfbd390d5c9564ab283a0349b9b9fcd46a706c1eb10e0db70bfbac7" +dependencies = [ + "ff", + "rand_core", + "subtle", +] + +[[package]] +name = "h2" +version = "0.3.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17f8a914c2987b688368b5138aa05321db91f4090cf26118185672ad588bce21" +dependencies = [ + "bytes", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http", + "indexmap", + "slab", + "tokio", + "tokio-util", + "tracing", +] + +[[package]] +name = "halo2-base" +version = "0.2.2" +source = "git+https://github.com/scroll-tech/halo2-lib?branch=develop#2c225864227e74b207d9f4b9e08c4d5f1afc69a1" +dependencies = [ + "ff", + "halo2_proofs", + "itertools", + "num-bigint", + "num-integer", + "num-traits", + "rand_chacha", + "rustc-hash", +] + +[[package]] +name = "halo2-ecc" +version = "0.2.2" +source = "git+https://github.com/scroll-tech/halo2-lib?branch=develop#2c225864227e74b207d9f4b9e08c4d5f1afc69a1" +dependencies = [ + "ff", + "group", + "halo2-base", + "itertools", + "num-bigint", + "num-integer", + "num-traits", + "rand", + "rand_chacha", + "rand_core", + "serde", + "serde_json", +] + +[[package]] +name = "halo2-mpt-circuits" +version = "0.1.0" +source = "git+https://github.com/scroll-tech/mpt-circuit.git?branch=v0.4#9d129125bd792e906c30e56386424bc3ab5920ba" +dependencies = [ + "ethers-core", + "halo2_proofs", + "hex", + "itertools", + "lazy_static", + "log", + "num-bigint", + "num-traits", + "poseidon-circuit", + "rand", + "serde", + "serde_json", + "strum", + "strum_macros", + "thiserror", +] + +[[package]] +name = "halo2_proofs" +version = "0.2.0" +source = "git+https://github.com/scroll-tech/halo2.git?branch=develop#9bf3562083dd9bed8a19f651b52bc810f5e2235f" +dependencies = [ + "ark-std", + "blake2b_simd", + "cfg-if 0.1.10", + "crossbeam", + "env_logger 0.8.4", + "ff", + "group", + "halo2curves", + "log", + "num-bigint", + "num-integer", + "poseidon", + "rand_core", + "rayon", + "sha3 0.9.1", + "subtle", + "tracing", +] + +[[package]] +name = "halo2curves" +version = "0.3.1" +source = "git+https://github.com/scroll-tech/halo2curves.git?branch=0.3.1-derive-serde#c0ac1935e5da2a620204b5b011be2c924b1e0155" +dependencies = [ + "ff", + "group", + "lazy_static", + "num-bigint", + "num-traits", + "pasta_curves", + "paste", + "rand", + "rand_core", + "serde", + "static_assertions", + "subtle", +] + +[[package]] +name = "halo2wrong" +version = "0.1.0" +source = "git+https://github.com/scroll-tech/halo2wrong.git?branch=halo2-ecc-snark-verifier-0323#939d679cb16abf0e820bd606248661e400328afa" +dependencies = [ + "group", + "halo2_proofs", + "num-bigint", + "num-integer", + "num-traits", +] + +[[package]] +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" +dependencies = [ + "ahash 0.7.6", +] + +[[package]] +name = "hashbrown" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" +dependencies = [ + "ahash 0.8.3", +] + +[[package]] +name = "hashers" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2bca93b15ea5a746f220e56587f71e73c6165eab783df9e26590069953e3c30" +dependencies = [ + "fxhash", +] + +[[package]] +name = "heck" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" + +[[package]] +name = "hermit-abi" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" +dependencies = [ + "libc", +] + +[[package]] +name = "hermit-abi" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7" +dependencies = [ + "libc", +] + +[[package]] +name = "hermit-abi" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286" + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "hex-literal" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" + +[[package]] +name = "hmac" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "126888268dcc288495a26bf004b38c5fdbb31682f992c84ceb046a1f0fe38840" +dependencies = [ + "crypto-mac", + "digest 0.9.0", +] + +[[package]] +name = "hmac" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" +dependencies = [ + "digest 0.10.6", +] + +[[package]] +name = "hmac-drbg" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17ea0a1394df5b6574da6e0c1ade9e78868c9fb0a4e5ef4428e32da4676b85b1" +dependencies = [ + "digest 0.9.0", + "generic-array 0.14.7", + "hmac 0.8.1", +] + +[[package]] +name = "http" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd6effc99afb63425aff9b05836f029929e345a6148a14b7ecd5ab67af944482" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "http-body" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1" +dependencies = [ + "bytes", + "http", + "pin-project-lite", +] + +[[package]] +name = "httparse" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" + +[[package]] +name = "httpdate" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421" + +[[package]] +name = "humantime" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" + +[[package]] +name = "hyper" +version = "0.14.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab302d72a6f11a3b910431ff93aae7e773078c769f0a3ef15fb9ec692ed147d4" +dependencies = [ + "bytes", + "futures-channel", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "socket2", + "tokio", + "tower-service", + "tracing", + "want", +] + +[[package]] +name = "hyper-rustls" +version = "0.23.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1788965e61b367cd03a62950836d5cd41560c3577d90e40e0819373194d1661c" +dependencies = [ + "http", + "hyper", + "rustls", + "tokio", + "tokio-rustls", +] + +[[package]] +name = "iana-time-zone" +version = "0.1.56" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0722cd7114b7de04316e7ea5456a0bbb20e4adb46fd27a3697adb812cff0f37c" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "wasm-bindgen", + "windows", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0703ae284fc167426161c2e3f1da3ea71d94b21bedbcc9494e92b28e334e3dca" +dependencies = [ + "cxx", + "cxx-build", +] + +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + +[[package]] +name = "idna" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e14ddfc70884202db2244c223200c204c2bda1bc6e0998d11b5e024d657209e6" +dependencies = [ + "unicode-bidi", + "unicode-normalization", +] + +[[package]] +name = "impl-codec" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba6a270039626615617f3f36d15fc827041df3b78c439da2cadfa47455a77f2f" +dependencies = [ + "parity-scale-codec", +] + +[[package]] +name = "impl-rlp" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f28220f89297a075ddc7245cd538076ee98b01f2a9c23a53a4f1105d5a322808" +dependencies = [ + "rlp", +] + +[[package]] +name = "impl-serde" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4551f042f3438e64dbd6226b20527fc84a6e1fe65688b58746a2f53623f25f5c" +dependencies = [ + "serde", +] + +[[package]] +name = "impl-trait-for-tuples" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "indexmap" +version = "1.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" +dependencies = [ + "autocfg", + "hashbrown 0.12.3", +] + +[[package]] +name = "instant" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" +dependencies = [ + "cfg-if 1.0.0", + "js-sys", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "io-lifetimes" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59ce5ef949d49ee85593fc4d3f3f95ad61657076395cbbce23e2121fc5542074" + +[[package]] +name = "io-lifetimes" +version = "1.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c66c74d2ae7e79a5a8f7ac924adbe38ee42a859c6539ad869eb51f0b52dc220" +dependencies = [ + "hermit-abi 0.3.1", + "libc", + "windows-sys 0.48.0", +] + +[[package]] +name = "ipnet" +version = "2.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12b6ee2129af8d4fb011108c73d99a1b83a85977f23b82460c0ae2e25bb4b57f" + +[[package]] +name = "is-even" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83d558b5cf9dbf1e6c224d9cea60821ad82e09092ade7aed6d83aef48ed382d0" +dependencies = [ + "is-odd", +] + +[[package]] +name = "is-odd" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5741cc4ac9f6105f6bb067d09bb5685dc255e5bdec6f3bf6d86f4bda6187d17e" + +[[package]] +name = "is-terminal" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adcf93614601c8129ddf72e2d5633df827ba6551541c6d8c59520a371475be1f" +dependencies = [ + "hermit-abi 0.3.1", + "io-lifetimes 1.0.10", + "rustix 0.37.19", + "windows-sys 0.48.0", +] + +[[package]] +name = "itertools" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6" + +[[package]] +name = "js-sys" +version = "0.3.62" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68c16e1bfd491478ab155fd8b4896b86f9ede344949b641e61501e07c2b8b4d5" +dependencies = [ + "wasm-bindgen", +] + +[[package]] +name = "k256" +version = "0.11.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72c1e0b51e7ec0a97369623508396067a486bd0cbed95a2659a4b863d28cfc8b" +dependencies = [ + "cfg-if 1.0.0", + "ecdsa", + "elliptic-curve", + "sha2 0.10.6", + "sha3 0.10.8", +] + +[[package]] +name = "keccak" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f6d5ed8676d904364de097082f4e7d240b571b67989ced0240f08b7f966f940" +dependencies = [ + "cpufeatures", +] + +[[package]] +name = "keccak256" +version = "0.1.0" +source = "git+https://github.com/scroll-tech/zkevm-circuits.git?branch=develop#82fc8ae1176d092227bdc946702b86ed2ca545e4" +dependencies = [ + "env_logger 0.9.3", + "eth-types", + "halo2_proofs", + "itertools", + "lazy_static", + "log", + "num-bigint", + "num-traits", +] + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +dependencies = [ + "spin", +] + +[[package]] +name = "libc" +version = "0.2.144" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b00cc1c228a6782d0f076e7b232802e0c5689d41bb5df366f2a6b6621cfdfe1" + +[[package]] +name = "libsecp256k1" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95b09eff1b35ed3b33b877ced3a691fc7a481919c7e29c53c906226fcf55e2a1" +dependencies = [ + "arrayref", + "base64 0.13.1", + "digest 0.9.0", + "hmac-drbg", + "libsecp256k1-core", + "libsecp256k1-gen-ecmult", + "libsecp256k1-gen-genmult", + "rand", + "serde", + "sha2 0.9.9", + "typenum", +] + +[[package]] +name = "libsecp256k1-core" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5be9b9bb642d8522a44d533eab56c16c738301965504753b03ad1de3425d5451" +dependencies = [ + "crunchy", + "digest 0.9.0", + "subtle", +] + +[[package]] +name = "libsecp256k1-gen-ecmult" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3038c808c55c87e8a172643a7d87187fc6c4174468159cb3090659d55bcb4809" +dependencies = [ + "libsecp256k1-core", +] + +[[package]] +name = "libsecp256k1-gen-genmult" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3db8d6ba2cec9eacc40e6e8ccc98931840301f1006e95647ceb2dd5c3aa06f7c" +dependencies = [ + "libsecp256k1-core", +] + +[[package]] +name = "link-cplusplus" +version = "1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ecd207c9c713c34f95a097a5b029ac2ce6010530c7b49d7fea24d977dede04f5" +dependencies = [ + "cc", +] + +[[package]] +name = "linux-raw-sys" +version = "0.0.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4d2456c373231a208ad294c33dc5bff30051eafd954cd4caae83a712b12854d" + +[[package]] +name = "linux-raw-sys" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ece97ea872ece730aed82664c424eb4c8291e1ff2480247ccf7409044bc6479f" + +[[package]] +name = "lock_api" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df" +dependencies = [ + "autocfg", + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" +dependencies = [ + "cfg-if 1.0.0", +] + +[[package]] +name = "log-mdc" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a94d21414c1f4a51209ad204c1776a3d0765002c76c6abcb602a6f09f1e881c7" + +[[package]] +name = "log4rs" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d36ca1786d9e79b8193a68d480a0907b612f109537115c6ff655a3a1967533fd" +dependencies = [ + "anyhow", + "arc-swap", + "chrono", + "derivative", + "fnv", + "libc", + "log", + "log-mdc", + "parking_lot 0.12.1", + "thiserror", + "thread-id", + "winapi", +] + +[[package]] +name = "maingate" +version = "0.1.0" +source = "git+https://github.com/scroll-tech/halo2wrong.git?branch=halo2-ecc-snark-verifier-0323#939d679cb16abf0e820bd606248661e400328afa" +dependencies = [ + "group", + "halo2wrong", + "num-bigint", + "num-integer", + "num-traits", + "rand", + "subtle", +] + +[[package]] +name = "memchr" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" + +[[package]] +name = "memoffset" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d61c719bcfbcf5d62b3a09efa6088de8c54bc0bfcd3ea7ae39fcc186108b8de1" +dependencies = [ + "autocfg", +] + +[[package]] +name = "mime" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" + +[[package]] +name = "miniz_oxide" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" +dependencies = [ + "adler", +] + +[[package]] +name = "mio" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b9d9a46eff5b4ff64b45a9e316a6d1e0bc719ef429cbec4dc630684212bfdf9" +dependencies = [ + "libc", + "log", + "wasi 0.11.0+wasi-snapshot-preview1", + "windows-sys 0.45.0", +] + +[[package]] +name = "mock" +version = "0.1.0" +source = "git+https://github.com/scroll-tech/zkevm-circuits.git?branch=develop#82fc8ae1176d092227bdc946702b86ed2ca545e4" +dependencies = [ + "eth-types", + "ethers-core", + "ethers-signers", + "external-tracer", + "itertools", + "lazy_static", + "rand", + "rand_chacha", +] + +[[package]] +name = "mpt-zktrie" +version = "0.1.0" +source = "git+https://github.com/scroll-tech/zkevm-circuits.git?branch=develop#82fc8ae1176d092227bdc946702b86ed2ca545e4" +dependencies = [ + "bus-mapping", + "eth-types", + "halo2-mpt-circuits", + "halo2_proofs", + "hex", + "lazy_static", + "log", + "num-bigint", + "poseidon-circuit", + "zktrie", +] + +[[package]] +name = "num" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43db66d1170d347f9a065114077f7dccb00c1b9478c89384490a3425279a4606" +dependencies = [ + "num-bigint", + "num-complex", + "num-integer", + "num-iter", + "num-rational", + "num-traits", +] + +[[package]] +name = "num-bigint" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f93ab6289c7b344a8a9f60f88d80aa20032336fe78da341afc91c8a2341fc75f" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", + "rand", +] + +[[package]] +name = "num-complex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02e0d21255c828d6f128a1e41534206671e8c3ea0c62f32291e808dc82cff17d" +dependencies = [ + "num-traits", +] + +[[package]] +name = "num-integer" +version = "0.1.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" +dependencies = [ + "autocfg", + "num-traits", +] + +[[package]] +name = "num-iter" +version = "0.1.43" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d03e6c028c5dc5cac6e2dec0efda81fc887605bb3d884578bb6d6bf7514e252" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-rational" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0638a1c9d0a3c0914158145bc76cff373a75a627e6ecbfb71cbe6f453a5a19b0" +dependencies = [ + "autocfg", + "num-bigint", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" +dependencies = [ + "autocfg", +] + +[[package]] +name = "num_cpus" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fac9e2da13b5eb447a6ce3d392f23a29d8694bff781bf03a16cd9ac8697593b" +dependencies = [ + "hermit-abi 0.2.6", + "libc", +] + +[[package]] +name = "num_enum" +version = "0.5.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f646caf906c20226733ed5b1374287eb97e3c2a5c227ce668c1f2ce20ae57c9" +dependencies = [ + "num_enum_derive", +] + +[[package]] +name = "num_enum_derive" +version = "0.5.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dcbff9bc912032c62bf65ef1d5aea88983b420f4f839db1e9b0c281a25c9c799" +dependencies = [ + "proc-macro-crate 1.3.1", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "once_cell" +version = "1.17.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" + +[[package]] +name = "opaque-debug" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" + +[[package]] +name = "opaque-debug" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" + +[[package]] +name = "parity-scale-codec" +version = "3.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ddb756ca205bd108aee3c62c6d3c994e1df84a59b9d6d4a5ea42ee1fd5a9a28" +dependencies = [ + "arrayvec", + "bitvec 1.0.1", + "byte-slice-cast", + "impl-trait-for-tuples", + "parity-scale-codec-derive", + "serde", +] + +[[package]] +name = "parity-scale-codec-derive" +version = "3.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86b26a931f824dd4eca30b3e43bb4f31cd5f0d3a403c5f5ff27106b805bfde7b" +dependencies = [ + "proc-macro-crate 1.3.1", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "parking_lot" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" +dependencies = [ + "instant", + "lock_api", + "parking_lot_core 0.8.6", +] + +[[package]] +name = "parking_lot" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" +dependencies = [ + "lock_api", + "parking_lot_core 0.9.8", +] + +[[package]] +name = "parking_lot_core" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60a2cfe6f0ad2bfc16aefa463b497d5c7a5ecd44a23efa72aa342d90177356dc" +dependencies = [ + "cfg-if 1.0.0", + "instant", + "libc", + "redox_syscall 0.2.16", + "smallvec", + "winapi", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93f00c865fe7cabf650081affecd3871070f26767e7b2070a3ffae14c654b447" +dependencies = [ + "cfg-if 1.0.0", + "libc", + "redox_syscall 0.3.5", + "smallvec", + "windows-targets 0.48.0", +] + +[[package]] +name = "password-hash" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d791538a6dcc1e7cb7fe6f6b58aca40e7f79403c45b2bc274008b5e647af1d8" +dependencies = [ + "base64ct", + "rand_core", + "subtle", +] + +[[package]] +name = "password-hash" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7676374caaee8a325c9e7a2ae557f216c5563a171d6997b0ef8a65af35147700" +dependencies = [ + "base64ct", + "rand_core", + "subtle", +] + +[[package]] +name = "pasta_curves" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5cc65faf8e7313b4b1fbaa9f7ca917a0eed499a9663be71477f87993604341d8" +dependencies = [ + "blake2b_simd", + "ff", + "group", + "lazy_static", + "rand", + "static_assertions", + "subtle", +] + +[[package]] +name = "paste" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f746c4065a8fa3fe23974dd82f15431cc8d40779821001404d10d2e79ca7d79" + +[[package]] +name = "pbkdf2" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "271779f35b581956db91a3e55737327a03aa051e90b1c47aeb189508533adfd7" +dependencies = [ + "digest 0.10.6", +] + +[[package]] +name = "pbkdf2" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83a0692ec44e4cf1ef28ca317f14f8f07da2d95ec3fa01f86e4467b725e60917" +dependencies = [ + "digest 0.10.6", + "hmac 0.12.1", + "password-hash 0.4.2", + "sha2 0.10.6", +] + +[[package]] +name = "percent-encoding" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" + +[[package]] +name = "pharos" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9567389417feee6ce15dd6527a8a1ecac205ef62c2932bcf3d9f6fc5b78b414" +dependencies = [ + "futures", + "rustc_version", +] + +[[package]] +name = "pin-project" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad29a609b6bcd67fee905812e544992d216af9d755757c05ed2d0e15a74c6ecc" +dependencies = [ + "pin-project-internal", +] + +[[package]] +name = "pin-project-internal" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "069bdb1e05adc7a8990dce9cc75370895fbe4e3d58b9b73bf1aee56359344a55" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "pin-project-lite" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "pkcs8" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9eca2c590a5f85da82668fa685c09ce2888b9430e83299debf1f34b65fd4a4ba" +dependencies = [ + "der", + "spki", +] + +[[package]] +name = "poseidon" +version = "0.2.0" +source = "git+https://github.com/scroll-tech/poseidon.git?branch=scroll-dev-0220#2fb4a2385bada39b50dce12fe50cb80d2fd33476" +dependencies = [ + "group", + "halo2curves", + "subtle", +] + +[[package]] +name = "poseidon-circuit" +version = "0.1.0" +source = "git+https://github.com/scroll-tech/poseidon-circuit.git?branch=scroll-dev-0619#50015b7cfbd5fe3263ec683cb291396c1b99cd1f" +dependencies = [ + "bitvec 1.0.1", + "halo2_proofs", + "lazy_static", + "thiserror", +] + +[[package]] +name = "ppv-lite86" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" + +[[package]] +name = "primitive-types" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e28720988bff275df1f51b171e1b2a18c30d194c4d2b61defdacecd625a5d94a" +dependencies = [ + "fixed-hash 0.7.0", + "impl-codec", + "impl-rlp", + "impl-serde", + "uint", +] + +[[package]] +name = "primitive-types" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f3486ccba82358b11a77516035647c34ba167dfa53312630de83b12bd4f3d66" +dependencies = [ + "fixed-hash 0.8.0", + "impl-codec", + "impl-rlp", + "uint", +] + +[[package]] +name = "proc-macro-crate" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d6ea3c4595b96363c13943497db34af4460fb474a95c43f4446ad341b8c9785" +dependencies = [ + "toml", +] + +[[package]] +name = "proc-macro-crate" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" +dependencies = [ + "once_cell", + "toml_edit", +] + +[[package]] +name = "proc-macro-error" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" +dependencies = [ + "proc-macro-error-attr", + "proc-macro2", + "quote", + "syn 1.0.109", + "version_check", +] + +[[package]] +name = "proc-macro-error-attr" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" +dependencies = [ + "proc-macro2", + "quote", + "version_check", +] + +[[package]] +name = "proc-macro-hack" +version = "0.5.20+deprecated" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc375e1527247fe1a97d8b7156678dfe7c1af2fc075c9a4db3690ecd2a148068" + +[[package]] +name = "proc-macro2" +version = "1.0.56" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b63bdb0cd06f1f4dedf69b254734f9b45af66e4a031e42a7480257d9898b435" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "procfs" +version = "0.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b4030746dfb40582518bebdc6303faef2bedfe787bac3786458bcdcc923b4e8" +dependencies = [ + "bitflags", + "byteorder", + "chrono", + "flate2", + "hex", + "lazy_static", + "rustix 0.35.13", +] + +[[package]] +name = "prover" +version = "0.4.0" +source = "git+https://github.com/scroll-tech/scroll-prover?rev=26e9cf7#26e9cf7a0bc76f5559bbbab5ac28a3e850ddce92" +dependencies = [ + "aggregator", + "anyhow", + "blake2", + "bus-mapping", + "chrono", + "dotenv", + "eth-types", + "ethers-core", + "git-version", + "glob", + "halo2_proofs", + "hex", + "is-even", + "itertools", + "log", + "log4rs", + "mock", + "mpt-zktrie", + "num-bigint", + "once_cell", + "procfs", + "rand", + "rand_xorshift", + "serde", + "serde_derive", + "serde_json", + "serde_stacker", + "sha2 0.10.6", + "snark-verifier", + "snark-verifier-sdk", + "strum", + "strum_macros", + "types", + "zkevm-circuits", +] + +[[package]] +name = "psm" +version = "0.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5787f7cda34e3033a72192c018bc5883100330f362ef279a8cbccfce8bb4e874" +dependencies = [ + "cc", +] + +[[package]] +name = "ptr_meta" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0738ccf7ea06b608c10564b31debd4f5bc5e197fc8bfe088f68ae5ce81e7a4f1" +dependencies = [ + "ptr_meta_derive", +] + +[[package]] +name = "ptr_meta_derive" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16b845dbfca988fa33db069c0e230574d15a3088f147a87b64c7589eb662c9ac" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "quote" +version = "1.0.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f4f29d145265ec1c483c7c654450edde0bfe043d3938d6972630663356d9500" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "radium" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "def50a86306165861203e7f84ecffbbdfdea79f0e51039b33de1e952358c47ac" + +[[package]] +name = "radium" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom", +] + +[[package]] +name = "rand_xorshift" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d25bf25ec5ae4a3f1b92f929810509a2f53d7dca2f50b794ff57e3face536c8f" +dependencies = [ + "rand_core", +] + +[[package]] +name = "rayon" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d2df5196e37bcc87abebc0053e20787d73847bb33134a69841207dd0a47f03b" +dependencies = [ + "either", + "rayon-core", +] + +[[package]] +name = "rayon-core" +version = "1.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b8f95bd6966f5c87776639160a66bd8ab9895d9d4ab01ddba9fc60661aebe8d" +dependencies = [ + "crossbeam-channel", + "crossbeam-deque", + "crossbeam-utils", + "num_cpus", +] + +[[package]] +name = "redox_syscall" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" +dependencies = [ + "bitflags", +] + +[[package]] +name = "redox_syscall" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" +dependencies = [ + "bitflags", +] + +[[package]] +name = "regex" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af83e617f331cc6ae2da5443c602dfa5af81e517212d9d611a5b3ba1777b5370" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5996294f19bd3aae0453a862ad728f60e6600695733dd5df01da90c54363a3c" + +[[package]] +name = "rend" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "581008d2099240d37fb08d77ad713bcaec2c4d89d50b5b21a8bb1996bbab68ab" +dependencies = [ + "bytecheck", +] + +[[package]] +name = "reqwest" +version = "0.11.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13293b639a097af28fc8a90f22add145a9c954e49d77da06263d58cf44d5fb91" +dependencies = [ + "base64 0.21.0", + "bytes", + "encoding_rs", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "hyper", + "hyper-rustls", + "ipnet", + "js-sys", + "log", + "mime", + "once_cell", + "percent-encoding", + "pin-project-lite", + "rustls", + "rustls-pemfile", + "serde", + "serde_json", + "serde_urlencoded", + "tokio", + "tokio-rustls", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "webpki-roots", + "winreg", +] + +[[package]] +name = "revm" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73d84c8f9836efb0f5f5f8de4700a953c4e1f3119e5cfcb0aad8e5be73daf991" +dependencies = [ + "arrayref", + "auto_impl", + "bytes", + "hashbrown 0.13.2", + "num_enum", + "primitive-types 0.12.1", + "revm_precompiles", + "rlp", + "sha3 0.10.8", +] + +[[package]] +name = "revm-precompile" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "66837781605c6dcb7f07ad87604eeab3119dae9149d69d8839073dd6f188673d" +dependencies = [ + "k256", + "num", + "once_cell", + "revm-primitives", + "ripemd", + "secp256k1 0.26.0", + "sha2 0.10.6", + "sha3 0.10.8", + "substrate-bn", +] + +[[package]] +name = "revm-primitives" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "304d998f466ffef72d76c7f20b05bf08a96801736a6fb1fdef47d49a292618df" +dependencies = [ + "auto_impl", + "bitvec 1.0.1", + "bytes", + "derive_more", + "enumn", + "fixed-hash 0.8.0", + "hashbrown 0.13.2", + "hex", + "hex-literal", + "primitive-types 0.12.1", + "rlp", + "ruint", + "sha3 0.10.8", +] + +[[package]] +name = "revm_precompiles" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0353d456ef3e989dc9190f42c6020f09bc2025930c37895826029304413204b5" +dependencies = [ + "bytes", + "hashbrown 0.13.2", + "num", + "once_cell", + "primitive-types 0.12.1", + "ripemd", + "secp256k1 0.24.3", + "sha2 0.10.6", + "sha3 0.10.8", + "substrate-bn", +] + +[[package]] +name = "rfc6979" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7743f17af12fa0b03b803ba12cd6a8d9483a587e89c69445e3909655c0b9fabb" +dependencies = [ + "crypto-bigint", + "hmac 0.12.1", + "zeroize", +] + +[[package]] +name = "ring" +version = "0.16.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3053cf52e236a3ed746dfc745aa9cacf1b791d846bdaf412f60a8d7d6e17c8fc" +dependencies = [ + "cc", + "libc", + "once_cell", + "spin", + "untrusted", + "web-sys", + "winapi", +] + +[[package]] +name = "ripemd" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd124222d17ad93a644ed9d011a40f4fb64aa54275c08cc216524a9ea82fb09f" +dependencies = [ + "digest 0.10.6", +] + +[[package]] +name = "rkyv" +version = "0.7.41" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21499ed91807f07ae081880aabb2ccc0235e9d88011867d984525e9a4c3cfa3e" +dependencies = [ + "bytecheck", + "hashbrown 0.12.3", + "ptr_meta", + "rend", + "rkyv_derive", + "seahash", +] + +[[package]] +name = "rkyv_derive" +version = "0.7.41" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac1c672430eb41556291981f45ca900a0239ad007242d1cb4b4167af842db666" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "rlp" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb919243f34364b6bd2fc10ef797edbfa75f33c252e7998527479c6d6b47e1ec" +dependencies = [ + "bytes", + "rustc-hex", +] + +[[package]] +name = "rlp-derive" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e33d7b2abe0c340d8797fe2907d3f20d3b5ea5908683618bfe80df7f621f672a" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "ruint" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d470e29e933dac4101180fd6574971892315c414cf2961a192729089687cc9b" +dependencies = [ + "derive_more", + "primitive-types 0.12.1", + "rlp", + "ruint-macro", + "rustc_version", + "thiserror", +] + +[[package]] +name = "ruint-macro" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62cc5760263ea229d367e7dff3c0cbf09e4797a125bd87059a6c095804f3b2d1" + +[[package]] +name = "rust_decimal" +version = "1.29.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26bd36b60561ee1fb5ec2817f198b6fd09fa571c897a5e86d1487cfc2b096dfc" +dependencies = [ + "arrayvec", + "borsh", + "bytecheck", + "byteorder", + "bytes", + "num-traits", + "rand", + "rkyv", + "serde", + "serde_json", +] + +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + +[[package]] +name = "rustc-hex" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e75f6a532d0fd9f7f13144f392b6ad56a32696bfcd9c78f797f16bbb6f072d6" + +[[package]] +name = "rustc_version" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" +dependencies = [ + "semver", +] + +[[package]] +name = "rustix" +version = "0.35.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "727a1a6d65f786ec22df8a81ca3121107f235970dc1705ed681d3e6e8b9cd5f9" +dependencies = [ + "bitflags", + "errno 0.2.8", + "io-lifetimes 0.7.5", + "libc", + "linux-raw-sys 0.0.46", + "windows-sys 0.42.0", +] + +[[package]] +name = "rustix" +version = "0.37.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acf8729d8542766f1b2cf77eb034d52f40d375bb8b615d0b147089946e16613d" +dependencies = [ + "bitflags", + "errno 0.3.1", + "io-lifetimes 1.0.10", + "libc", + "linux-raw-sys 0.3.7", + "windows-sys 0.48.0", +] + +[[package]] +name = "rustls" +version = "0.20.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fff78fc74d175294f4e83b28343315ffcfb114b156f0185e9741cb5570f50e2f" +dependencies = [ + "log", + "ring", + "sct", + "webpki", +] + +[[package]] +name = "rustls-pemfile" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d194b56d58803a43635bdc398cd17e383d6f71f9182b9a192c127ca42494a59b" +dependencies = [ + "base64 0.21.0", +] + +[[package]] +name = "rustversion" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f3208ce4d8448b3f3e7d168a73f5e0c43a61e32930de3bceeccedb388b6bf06" + +[[package]] +name = "ryu" +version = "1.0.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041" + +[[package]] +name = "salsa20" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c0fbb5f676da676c260ba276a8f43a8dc67cf02d1438423aeb1c677a7212686" +dependencies = [ + "cipher", +] + +[[package]] +name = "scopeguard" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" + +[[package]] +name = "scratch" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1792db035ce95be60c3f8853017b3999209281c24e2ba5bc8e59bf97a0c590c1" + +[[package]] +name = "scrypt" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e73d6d7c6311ebdbd9184ad6c4447b2f36337e327bda107d3ba9e3c374f9d325" +dependencies = [ + "hmac 0.12.1", + "password-hash 0.3.2", + "pbkdf2 0.10.1", + "salsa20", + "sha2 0.10.6", +] + +[[package]] +name = "sct" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d53dcdb7c9f8158937a7981b48accfd39a43af418591a5d008c7b22b5e1b7ca4" +dependencies = [ + "ring", + "untrusted", +] + +[[package]] +name = "seahash" +version = "4.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c107b6f4780854c8b126e228ea8869f4d7b71260f962fefb57b996b8959ba6b" + +[[package]] +name = "sec1" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3be24c1842290c45df0a7bf069e0c268a747ad05a192f2fd7dcfdbc1cba40928" +dependencies = [ + "base16ct", + "der", + "generic-array 0.14.7", + "pkcs8", + "subtle", + "zeroize", +] + +[[package]] +name = "secp256k1" +version = "0.24.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b1629c9c557ef9b293568b338dddfc8208c98a18c59d722a9d53f859d9c9b62" +dependencies = [ + "secp256k1-sys 0.6.1", +] + +[[package]] +name = "secp256k1" +version = "0.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4124a35fe33ae14259c490fd70fa199a32b9ce9502f2ee6bc4f81ec06fa65894" +dependencies = [ + "secp256k1-sys 0.8.1", +] + +[[package]] +name = "secp256k1-sys" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83080e2c2fc1006e625be82e5d1eb6a43b7fd9578b617fcc55814daf286bba4b" +dependencies = [ + "cc", +] + +[[package]] +name = "secp256k1-sys" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70a129b9e9efbfb223753b9163c4ab3b13cff7fd9c7f010fbac25ab4099fa07e" +dependencies = [ + "cc", +] + +[[package]] +name = "semver" +version = "1.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bebd363326d05ec3e2f532ab7660680f3b02130d780c299bca73469d521bc0ed" + +[[package]] +name = "send_wrapper" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd0b0ec5f1c1ca621c432a25813d8d60c88abe6d3e08a3eb9cf37d97a0fe3d73" + +[[package]] +name = "serde" +version = "1.0.162" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71b2f6e1ab5c2b98c05f0f35b236b22e8df7ead6ffbf51d7808da7f8817e7ab6" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.162" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2a0814352fd64b58489904a44ea8d90cb1a91dcb6b4f5ebabc32c8318e93cb6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.15", +] + +[[package]] +name = "serde_json" +version = "1.0.96" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "057d394a50403bcac12672b2b18fb387ab6d289d957dab67dd201875391e52f1" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "serde_repr" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bcec881020c684085e55a25f7fd888954d56609ef363479dc5a1305eb0d40cab" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.15", +] + +[[package]] +name = "serde_stacker" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f5557f4c1103cecd0e639a17ab22d670b89912d8a506589ee627bf738a15a5d" +dependencies = [ + "serde", + "stacker", +] + +[[package]] +name = "serde_urlencoded" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" +dependencies = [ + "form_urlencoded", + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "serde_with" +version = "1.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "678b5a069e50bf00ecd22d0cd8ddf7c236f68581b03db652061ed5eb13a312ff" +dependencies = [ + "serde", + "serde_with_macros", +] + +[[package]] +name = "serde_with_macros" +version = "1.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e182d6ec6f05393cc0e5ed1bf81ad6db3a8feedf8ee515ecdd369809bcce8082" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "sha-1" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f5058ada175748e33390e40e872bd0fe59a19f265d0158daa551c5a88a76009c" +dependencies = [ + "cfg-if 1.0.0", + "cpufeatures", + "digest 0.10.6", +] + +[[package]] +name = "sha2" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a256f46ea78a0c0d9ff00077504903ac881a1dafdc20da66545699e7776b3e69" +dependencies = [ + "block-buffer 0.7.3", + "digest 0.8.1", + "fake-simd", + "opaque-debug 0.2.3", +] + +[[package]] +name = "sha2" +version = "0.9.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" +dependencies = [ + "block-buffer 0.9.0", + "cfg-if 1.0.0", + "cpufeatures", + "digest 0.9.0", + "opaque-debug 0.3.0", +] + +[[package]] +name = "sha2" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82e6b795fe2e3b1e845bafcb27aa35405c4d47cdfc92af5fc8d3002f76cebdc0" +dependencies = [ + "cfg-if 1.0.0", + "cpufeatures", + "digest 0.10.6", +] + +[[package]] +name = "sha3" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b64dcef59ed4290b9fb562b53df07f564690d6539e8ecdd4728cf392477530bc" +dependencies = [ + "block-buffer 0.3.3", + "byte-tools 0.2.0", + "digest 0.7.6", + "keccak", +] + +[[package]] +name = "sha3" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f81199417d4e5de3f04b1e871023acea7389672c4135918f05aa9cbf2f2fa809" +dependencies = [ + "block-buffer 0.9.0", + "digest 0.9.0", + "keccak", + "opaque-debug 0.3.0", +] + +[[package]] +name = "sha3" +version = "0.10.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75872d278a8f37ef87fa0ddbda7802605cb18344497949862c0d4dcb291eba60" +dependencies = [ + "digest 0.10.6", + "keccak", +] + +[[package]] +name = "signature" +version = "1.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74233d3b3b2f6d4b006dc19dee745e73e2a6bfb6f93607cd3b02bd5b00797d7c" +dependencies = [ + "digest 0.10.6", + "rand_core", +] + +[[package]] +name = "simdutf8" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f27f6278552951f1f2b8cf9da965d10969b2efdea95a6ec47987ab46edfe263a" + +[[package]] +name = "slab" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6528351c9bc8ab22353f9d776db39a20288e8d6c37ef8cfe3317cf875eecfc2d" +dependencies = [ + "autocfg", +] + +[[package]] +name = "smallvec" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" + +[[package]] +name = "snark-verifier" +version = "0.1.0" +source = "git+https://github.com/scroll-tech/snark-verifier?branch=develop#a530941eb9a6151c46d5546ca818d04bbd286c02" +dependencies = [ + "bytes", + "ethereum-types 0.14.1", + "halo2-base", + "halo2-ecc", + "hex", + "itertools", + "lazy_static", + "num-bigint", + "num-integer", + "num-traits", + "poseidon", + "rand", + "revm", + "rlp", + "rustc-hash", + "serde", + "sha3 0.10.8", +] + +[[package]] +name = "snark-verifier-sdk" +version = "0.0.1" +source = "git+https://github.com/scroll-tech/snark-verifier?branch=develop#a530941eb9a6151c46d5546ca818d04bbd286c02" +dependencies = [ + "bincode", + "env_logger 0.10.0", + "ethereum-types 0.14.1", + "halo2-base", + "hex", + "itertools", + "lazy_static", + "log", + "num-bigint", + "num-integer", + "num-traits", + "rand", + "rand_chacha", + "serde", + "serde_json", + "snark-verifier", +] + +[[package]] +name = "socket2" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64a4a911eed85daf18834cfaa86a79b7d266ff93ff5ba14005426219480ed662" +dependencies = [ + "libc", + "winapi", +] + +[[package]] +name = "spin" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" + +[[package]] +name = "spki" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67cf02bbac7a337dc36e4f5a693db6c21e7863f45070f7064577eb4367a3212b" +dependencies = [ + "base64ct", + "der", +] + +[[package]] +name = "stacker" +version = "0.1.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c886bd4480155fd3ef527d45e9ac8dd7118a898a46530b7b94c3e21866259fce" +dependencies = [ + "cc", + "cfg-if 1.0.0", + "libc", + "psm", + "winapi", +] + +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + +[[package]] +name = "strsim" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" + +[[package]] +name = "strum" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "063e6045c0e62079840579a7e47a355ae92f60eb74daaf156fb1e84ba164e63f" +dependencies = [ + "strum_macros", +] + +[[package]] +name = "strum_macros" +version = "0.24.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e385be0d24f186b4ce2f9982191e7101bb737312ad61c1f2f984f34bcf85d59" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "rustversion", + "syn 1.0.109", +] + +[[package]] +name = "substrate-bn" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b5bbfa79abbae15dd642ea8176a21a635ff3c00059961d1ea27ad04e5b441c" +dependencies = [ + "byteorder", + "crunchy", + "lazy_static", + "rand", + "rustc-hex", +] + +[[package]] +name = "subtle" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" + +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "2.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a34fcf3e8b60f57e6a14301a2e916d323af98b0ea63c599441eec8558660c822" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "tap" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" + +[[package]] +name = "termcolor" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "thiserror" +version = "1.0.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "978c9a314bd8dc99be594bc3c175faaa9794be04a5a5e153caba6915336cebac" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.15", +] + +[[package]] +name = "thread-id" +version = "4.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ee93aa2b8331c0fec9091548843f2c90019571814057da3b783f9de09349d73" +dependencies = [ + "libc", + "redox_syscall 0.2.16", + "winapi", +] + +[[package]] +name = "time" +version = "0.1.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b797afad3f312d1c66a56d11d0316f916356d11bd158fbc6ca6389ff6bf805a" +dependencies = [ + "libc", + "wasi 0.10.0+wasi-snapshot-preview1", + "winapi", +] + +[[package]] +name = "tiny-keccak" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c9d3793400a45f954c52e73d068316d76b6f4e36977e3fcebb13a2721e80237" +dependencies = [ + "crunchy", +] + +[[package]] +name = "tinyvec" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" + +[[package]] +name = "tokio" +version = "1.28.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0aa32867d44e6f2ce3385e89dceb990188b8bb0fb25b0cf576647a6f98ac5105" +dependencies = [ + "autocfg", + "bytes", + "libc", + "mio", + "pin-project-lite", + "socket2", + "windows-sys 0.48.0", +] + +[[package]] +name = "tokio-rustls" +version = "0.23.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c43ee83903113e03984cb9e5cebe6c04a5116269e900e3ddba8f068a62adda59" +dependencies = [ + "rustls", + "tokio", + "webpki", +] + +[[package]] +name = "tokio-tungstenite" +version = "0.17.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f714dd15bead90401d77e04243611caec13726c2408afd5b31901dfcdcb3b181" +dependencies = [ + "futures-util", + "log", + "rustls", + "tokio", + "tokio-rustls", + "tungstenite", + "webpki", + "webpki-roots", +] + +[[package]] +name = "tokio-util" +version = "0.7.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "806fe8c2c87eccc8b3267cbae29ed3ab2d0bd37fca70ab622e46aaa9375ddb7d" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "pin-project-lite", + "tokio", + "tracing", +] + +[[package]] +name = "toml" +version = "0.5.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" +dependencies = [ + "serde", +] + +[[package]] +name = "toml_datetime" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ab8ed2edee10b50132aed5f331333428b011c99402b5a534154ed15746f9622" + +[[package]] +name = "toml_edit" +version = "0.19.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "239410c8609e8125456927e6707163a3b1fdb40561e4b803bc041f466ccfdc13" +dependencies = [ + "indexmap", + "toml_datetime", + "winnow", +] + +[[package]] +name = "tower-service" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" + +[[package]] +name = "tracing" +version = "0.1.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" +dependencies = [ + "cfg-if 1.0.0", + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f57e3ca2a01450b1a921183a9c9cbfda207fd822cef4ccb00a65402cbba7a74" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.15", +] + +[[package]] +name = "tracing-core" +version = "0.1.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24eb03ba0eab1fd845050058ce5e616558e8f8d8fca633e6b163fe25c797213a" +dependencies = [ + "once_cell", +] + +[[package]] +name = "tracing-futures" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97d095ae15e245a057c8e8451bab9b3ee1e1f68e9ba2b4fbc18d0ac5237835f2" +dependencies = [ + "pin-project", + "tracing", +] + +[[package]] +name = "try-lock" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" + +[[package]] +name = "tungstenite" +version = "0.17.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e27992fd6a8c29ee7eef28fc78349aa244134e10ad447ce3b9f0ac0ed0fa4ce0" +dependencies = [ + "base64 0.13.1", + "byteorder", + "bytes", + "http", + "httparse", + "log", + "rand", + "rustls", + "sha-1", + "thiserror", + "url", + "utf-8", + "webpki", +] + +[[package]] +name = "typenum" +version = "1.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" + +[[package]] +name = "types" +version = "0.4.0" +source = "git+https://github.com/scroll-tech/scroll-prover?rev=26e9cf7#26e9cf7a0bc76f5559bbbab5ac28a3e850ddce92" +dependencies = [ + "base64 0.13.1", + "blake2", + "eth-types", + "ethers-core", + "serde", + "serde_derive", + "serde_json", + "serde_repr", +] + +[[package]] +name = "uint" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76f64bba2c53b04fcab63c01a7d7427eadc821e3bc48c34dc9ba29c501164b52" +dependencies = [ + "byteorder", + "crunchy", + "hex", + "static_assertions", +] + +[[package]] +name = "unicode-bidi" +version = "0.3.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" + +[[package]] +name = "unicode-ident" +version = "1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" + +[[package]] +name = "unicode-normalization" +version = "0.1.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "unicode-width" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" + +[[package]] +name = "unicode-xid" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" + +[[package]] +name = "untrusted" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" + +[[package]] +name = "url" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d68c799ae75762b8c3fe375feb6600ef5602c883c5d21eb51c09f22b83c4643" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", +] + +[[package]] +name = "utf-8" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" + +[[package]] +name = "uuid" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" +dependencies = [ + "getrandom", + "serde", +] + +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] +name = "want" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ce8a968cb1cd110d136ff8b819a556d6fb6d919363c61534f6860c7eb172ba0" +dependencies = [ + "log", + "try-lock", +] + +[[package]] +name = "wasi" +version = "0.10.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "wasm-bindgen" +version = "0.2.85" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b6cb788c4e39112fbe1822277ef6fb3c55cd86b95cb3d3c4c1c9597e4ac74b4" +dependencies = [ + "cfg-if 1.0.0", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.85" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35e522ed4105a9d626d885b35d62501b30d9666283a5c8be12c14a8bdafe7822" +dependencies = [ + "bumpalo", + "log", + "once_cell", + "proc-macro2", + "quote", + "syn 2.0.15", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "083abe15c5d88556b77bdf7aef403625be9e327ad37c62c4e4129af740168163" +dependencies = [ + "cfg-if 1.0.0", + "js-sys", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.85" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "358a79a0cb89d21db8120cbfb91392335913e4890665b1a7981d9e956903b434" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.85" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4783ce29f09b9d93134d41297aded3a712b7b979e9c6f28c32cb88c973a94869" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.15", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.85" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a901d592cafaa4d711bc324edfaff879ac700b19c3dfd60058d2b445be2691eb" + +[[package]] +name = "wasm-timer" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be0ecb0db480561e9a7642b5d3e4187c128914e58aa84330b9493e3eb68c5e7f" +dependencies = [ + "futures", + "js-sys", + "parking_lot 0.11.2", + "pin-utils", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", +] + +[[package]] +name = "web-sys" +version = "0.3.62" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16b5f940c7edfdc6d12126d98c9ef4d1b3d470011c47c76a6581df47ad9ba721" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "webpki" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f095d78192e208183081cc07bc5515ef55216397af48b873e5edcd72637fa1bd" +dependencies = [ + "ring", + "untrusted", +] + +[[package]] +name = "webpki-roots" +version = "0.22.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c71e40d7d2c34a5106301fb632274ca37242cd0c9d3e64dbece371a40a2d87" +dependencies = [ + "webpki", +] + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-util" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +dependencies = [ + "winapi", +] + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f" +dependencies = [ + "windows-targets 0.48.0", +] + +[[package]] +name = "windows-sys" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" +dependencies = [ + "windows_aarch64_gnullvm 0.42.2", + "windows_aarch64_msvc 0.42.2", + "windows_i686_gnu 0.42.2", + "windows_i686_msvc 0.42.2", + "windows_x86_64_gnu 0.42.2", + "windows_x86_64_gnullvm 0.42.2", + "windows_x86_64_msvc 0.42.2", +] + +[[package]] +name = "windows-sys" +version = "0.45.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" +dependencies = [ + "windows-targets 0.42.2", +] + +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets 0.48.0", +] + +[[package]] +name = "windows-targets" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" +dependencies = [ + "windows_aarch64_gnullvm 0.42.2", + "windows_aarch64_msvc 0.42.2", + "windows_i686_gnu 0.42.2", + "windows_i686_msvc 0.42.2", + "windows_x86_64_gnu 0.42.2", + "windows_x86_64_gnullvm 0.42.2", + "windows_x86_64_msvc 0.42.2", +] + +[[package]] +name = "windows-targets" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5" +dependencies = [ + "windows_aarch64_gnullvm 0.48.0", + "windows_aarch64_msvc 0.48.0", + "windows_i686_gnu 0.48.0", + "windows_i686_msvc 0.48.0", + "windows_x86_64_gnu 0.48.0", + "windows_x86_64_gnullvm 0.48.0", + "windows_x86_64_msvc 0.48.0", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" + +[[package]] +name = "windows_i686_gnu" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" + +[[package]] +name = "windows_i686_gnu" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" + +[[package]] +name = "windows_i686_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" + +[[package]] +name = "windows_i686_msvc" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" + +[[package]] +name = "winnow" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61de7bac303dc551fe038e2b3cef0f571087a47571ea6e79a87692ac99b99699" +dependencies = [ + "memchr", +] + +[[package]] +name = "winreg" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80d0f4e272c85def139476380b12f9ac60926689dd2e01d4923222f40580869d" +dependencies = [ + "winapi", +] + +[[package]] +name = "ws_stream_wasm" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7999f5f4217fe3818726b66257a4475f71e74ffd190776ad053fa159e50737f5" +dependencies = [ + "async_io_stream", + "futures", + "js-sys", + "log", + "pharos", + "rustc_version", + "send_wrapper", + "thiserror", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", +] + +[[package]] +name = "wyz" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" +dependencies = [ + "tap", +] + +[[package]] +name = "zeroize" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a0956f1ba7c7909bfb66c2e9e4124ab6f6482560f6628b5aaeba39207c9aad9" + +[[package]] +name = "zkevm-circuits" +version = "0.1.0" +source = "git+https://github.com/scroll-tech/zkevm-circuits.git?branch=develop#82fc8ae1176d092227bdc946702b86ed2ca545e4" +dependencies = [ + "array-init", + "bus-mapping", + "env_logger 0.9.3", + "eth-types", + "ethers-core", + "ethers-signers", + "gadgets", + "halo2-base", + "halo2-ecc", + "halo2_proofs", + "hex", + "itertools", + "keccak256", + "lazy_static", + "libsecp256k1", + "log", + "maingate", + "mock", + "mpt-zktrie", + "num", + "num-bigint", + "once_cell", + "poseidon-circuit", + "rand", + "rand_chacha", + "rand_xorshift", + "rayon", + "serde_json", + "sha3 0.10.8", + "snark-verifier", + "snark-verifier-sdk", + "strum", + "strum_macros", + "subtle", +] + +[[package]] +name = "zkp" +version = "0.1.0" +dependencies = [ + "env_logger 0.9.3", + "libc", + "log", + "once_cell", + "prover", + "serde", + "serde_derive", + "serde_json", + "types", +] + +[[package]] +name = "zktrie" +version = "0.1.2" +source = "git+https://github.com/scroll-tech/zktrie.git?branch=scroll-dev-0226#1a5562f663a81ff903383db69dc6c9404b63e69d" +dependencies = [ + "gobuild 0.1.0-alpha.2 (registry+https://github.com/rust-lang/crates.io-index)", +] diff --git a/rollup/circuitcapacitychecker/libzkp/Cargo.toml b/rollup/circuitcapacitychecker/libzkp/Cargo.toml new file mode 100644 index 0000000000..12587ec4ba --- /dev/null +++ b/rollup/circuitcapacitychecker/libzkp/Cargo.toml @@ -0,0 +1,39 @@ +[package] +name = "zkp" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +[lib] +crate-type = ["cdylib"] + +[patch."https://github.com/privacy-scaling-explorations/halo2.git"] +halo2_proofs = { git = "https://github.com/scroll-tech/halo2.git", branch = "develop" } +[patch."https://github.com/privacy-scaling-explorations/poseidon.git"] +poseidon = { git = "https://github.com/scroll-tech/poseidon.git", branch = "scroll-dev-0220" } +[patch."https://github.com/privacy-scaling-explorations/halo2wrong.git"] +halo2wrong = { git = "https://github.com/scroll-tech/halo2wrong.git", branch = "halo2-ecc-snark-verifier-0323" } +maingate = { git = "https://github.com/scroll-tech/halo2wrong", branch = "halo2-ecc-snark-verifier-0323" } +[patch."https://github.com/privacy-scaling-explorations/halo2curves.git"] +halo2curves = { git = "https://github.com/scroll-tech/halo2curves.git", branch = "0.3.1-derive-serde" } + +[dependencies] +prover = { git = "https://github.com/scroll-tech/scroll-prover", rev="26e9cf7" } +types = { git = "https://github.com/scroll-tech/scroll-prover", rev="26e9cf7" } + +log = "0.4" +env_logger = "0.9.0" +serde = "1.0" +serde_derive = "1.0" +serde_json = "1.0.66" +libc = "0.2" +once_cell = "1.8.0" + + +[profile.test] +opt-level = 3 +debug-assertions = true + +[profile.release] +opt-level = 3 +debug-assertions = true diff --git a/rollup/circuitcapacitychecker/libzkp/Makefile b/rollup/circuitcapacitychecker/libzkp/Makefile new file mode 100644 index 0000000000..007f338fd5 --- /dev/null +++ b/rollup/circuitcapacitychecker/libzkp/Makefile @@ -0,0 +1,10 @@ +.PHONY: clean libzkp + +clean: + rm -f *.a *.so + cargo clean + +libzkp: + cargo build --release + cp $(PWD)/target/release/libzkp.so $(PWD)/ + find $(PWD)/target | grep libzktrie.so | xargs -I{} cp {} $(PWD)/ diff --git a/rollup/circuitcapacitychecker/libzkp/libzkp.h b/rollup/circuitcapacitychecker/libzkp/libzkp.h new file mode 100644 index 0000000000..524c1ec2eb --- /dev/null +++ b/rollup/circuitcapacitychecker/libzkp/libzkp.h @@ -0,0 +1,6 @@ +#include +void init(); +uint64_t new_circuit_capacity_checker(); +void reset_circuit_capacity_checker(uint64_t id); +char* apply_tx(uint64_t id, char *tx_traces); +char* apply_block(uint64_t id, char *block_trace); diff --git a/rollup/circuitcapacitychecker/libzkp/rust-toolchain b/rollup/circuitcapacitychecker/libzkp/rust-toolchain new file mode 100644 index 0000000000..44b874bfca --- /dev/null +++ b/rollup/circuitcapacitychecker/libzkp/rust-toolchain @@ -0,0 +1 @@ +nightly-2022-12-10 diff --git a/rollup/circuitcapacitychecker/libzkp/src/lib.rs b/rollup/circuitcapacitychecker/libzkp/src/lib.rs new file mode 100644 index 0000000000..67b55e78f9 --- /dev/null +++ b/rollup/circuitcapacitychecker/libzkp/src/lib.rs @@ -0,0 +1,190 @@ +#![feature(once_cell)] + +pub mod checker { + use crate::utils::{c_char_to_vec, vec_to_c_char}; + use libc::c_char; + use prover::zkevm::{CircuitCapacityChecker, RowUsage}; + use serde_derive::{Deserialize, Serialize}; + use std::cell::OnceCell; + use std::collections::HashMap; + use std::panic; + use std::ptr::null; + use types::eth::BlockTrace; + + #[derive(Debug, Clone, Deserialize, Serialize)] + pub struct RowUsageResult { + pub acc_row_usage: Option, + pub tx_row_usage: Option, + pub error: Option, + } + + static mut CHECKERS: OnceCell> = OnceCell::new(); + + /// # Safety + #[no_mangle] + pub unsafe extern "C" fn init() { + env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("debug")) + .format_timestamp_millis() + .init(); + let checkers = HashMap::new(); + CHECKERS + .set(checkers) + .expect("circuit capacity checker initialized twice"); + } + + /// # Safety + #[no_mangle] + pub unsafe extern "C" fn new_circuit_capacity_checker() -> u64 { + let checkers = CHECKERS + .get_mut() + .expect("fail to get circuit capacity checkers map in new_circuit_capacity_checker"); + let id = checkers.len() as u64; + let checker = CircuitCapacityChecker::new(); + checkers.insert(id, checker); + id + } + + /// # Safety + #[no_mangle] + pub unsafe extern "C" fn reset_circuit_capacity_checker(id: u64) { + CHECKERS + .get_mut() + .expect("fail to get circuit capacity checkers map in reset_circuit_capacity_checker") + .get_mut(&id) + .unwrap_or_else(|| panic!("fail to get circuit capacity checker (id: {id:?}) in reset_circuit_capacity_checker")) + .reset() + } + + /// # Safety + #[no_mangle] + pub unsafe extern "C" fn apply_tx(id: u64, tx_traces: *const c_char) -> *const c_char { + let result = panic::catch_unwind(|| { + let tx_traces_vec = c_char_to_vec(tx_traces); + let traces = serde_json::from_slice::(&tx_traces_vec) + .unwrap_or_else(|_| panic!("id: {id:?}, fail to deserialize tx_traces")); + if traces.transactions.len() != 1 { + panic!("traces.transactions.len() != 1") + } else if traces.execution_results.len() != 1 { + panic!("traces.execution_results.len() != 1") + } else if traces.tx_storage_trace.len() != 1 { + panic!("traces.tx_storage_trace.len() != 1") + } + CHECKERS + .get_mut() + .expect("fail to get circuit capacity checkers map in apply_tx") + .get_mut(&id) + .unwrap_or_else(|| { + panic!( + "fail to get circuit capacity checker (id: {id:?}) in apply_tx" + ) + }) + .estimate_circuit_capacity(&[traces.clone()]) + .unwrap_or_else(|_| { + panic!( + "id: {:?}, fail to estimate_circuit_capacity in apply_tx, block_hash: {:?}, tx_hash: {:?}", + id, traces.header.hash, traces.transactions[0].tx_hash + ) + }) + }); + let r = match result { + Ok((acc_row_usage, tx_row_usage)) => { + log::debug!( + "id: {:?}, acc_row_usage: {:?}, tx_row_usage: {:?}", + id, + acc_row_usage.row_number, + tx_row_usage.row_number + ); + RowUsageResult { + acc_row_usage: Some(acc_row_usage), + tx_row_usage: Some(tx_row_usage), + error: None, + } + } + Err(e) => RowUsageResult { + acc_row_usage: None, + tx_row_usage: None, + error: Some(format!("{e:?}")), + }, + }; + serde_json::to_vec(&r).map_or(null(), vec_to_c_char) + } + + /// # Safety + #[no_mangle] + pub unsafe extern "C" fn apply_block(id: u64, block_trace: *const c_char) -> *const c_char { + let result = panic::catch_unwind(|| { + let block_trace = c_char_to_vec(block_trace); + let traces = serde_json::from_slice::(&block_trace) + .unwrap_or_else(|_| panic!("id: {id:?}, fail to deserialize block_trace")); + CHECKERS + .get_mut() + .expect("fail to get circuit capacity checkers map in apply_block") + .get_mut(&id) + .unwrap_or_else(|| { + panic!( + "fail to get circuit capacity checker (id: {id:?}) in apply_block" + ) + }) + .estimate_circuit_capacity(&[traces.clone()]) + .unwrap_or_else(|_| { + panic!( + "id: {:?}, fail to estimate_circuit_capacity in apply_block, block_hash: {:?}", + id, traces.header.hash + ) + }) + }); + let r = match result { + Ok((acc_row_usage, tx_row_usage)) => { + log::debug!( + "id: {:?}, acc_row_usage: {:?}, tx_row_usage: {:?}", + id, + acc_row_usage.row_number, + tx_row_usage.row_number + ); + RowUsageResult { + acc_row_usage: Some(acc_row_usage), + tx_row_usage: Some(tx_row_usage), + error: None, + } + } + Err(e) => RowUsageResult { + acc_row_usage: None, + tx_row_usage: None, + error: Some(format!("{e:?}")), + }, + }; + serde_json::to_vec(&r).map_or(null(), vec_to_c_char) + } +} + +pub(crate) mod utils { + use std::ffi::{CStr, CString}; + use std::os::raw::c_char; + + #[allow(dead_code)] + pub(crate) fn c_char_to_str(c: *const c_char) -> &'static str { + let cstr = unsafe { CStr::from_ptr(c) }; + cstr.to_str().expect("fail to cast cstr to str") + } + + #[allow(dead_code)] + pub(crate) fn c_char_to_vec(c: *const c_char) -> Vec { + let cstr = unsafe { CStr::from_ptr(c) }; + cstr.to_bytes().to_vec() + } + + #[allow(dead_code)] + pub(crate) fn vec_to_c_char(bytes: Vec) -> *const c_char { + CString::new(bytes) + .expect("fail to create new CString from bytes") + .into_raw() + } + + #[allow(dead_code)] + pub(crate) fn bool_to_int(b: bool) -> u8 { + match b { + true => 1, + false => 0, + } + } +} diff --git a/rollup/circuitcapacitychecker/mock.go b/rollup/circuitcapacitychecker/mock.go new file mode 100644 index 0000000000..6d3c789036 --- /dev/null +++ b/rollup/circuitcapacitychecker/mock.go @@ -0,0 +1,28 @@ +//go:build !circuit_capacity_checker + +package circuitcapacitychecker + +import ( + "math/rand" + + "github.com/scroll-tech/go-ethereum/core/types" +) + +type CircuitCapacityChecker struct { + ID uint64 +} + +func NewCircuitCapacityChecker() *CircuitCapacityChecker { + return &CircuitCapacityChecker{ID: rand.Uint64()} +} + +func (ccc *CircuitCapacityChecker) Reset() { +} + +func (ccc *CircuitCapacityChecker) ApplyTransaction(traces *types.BlockTrace) (*types.RowConsumption, error) { + return nil, nil +} + +func (ccc *CircuitCapacityChecker) ApplyBlock(traces *types.BlockTrace) (*types.RowConsumption, error) { + return nil, nil +} diff --git a/rollup/circuitcapacitychecker/types.go b/rollup/circuitcapacitychecker/types.go new file mode 100644 index 0000000000..1c9771cea5 --- /dev/null +++ b/rollup/circuitcapacitychecker/types.go @@ -0,0 +1,19 @@ +package circuitcapacitychecker + +import ( + "errors" + + "github.com/scroll-tech/go-ethereum/core/types" +) + +var ( + ErrUnknown = errors.New("unknown circuit capacity checker error") + ErrTxRowConsumptionOverflow = errors.New("tx row consumption oveflow") + ErrBlockRowConsumptionOverflow = errors.New("block row consumption oveflow") +) + +type WrappedRowUsage struct { + AccRowUsage *types.RowUsage `json:"acc_row_usage,omitempty"` + TxRowUsage *types.RowUsage `json:"tx_row_usage,omitempty"` + Error string `json:"error,omitempty"` +} diff --git a/tests/block_test_util.go b/tests/block_test_util.go index b03452354d..34bdc7c7e1 100644 --- a/tests/block_test_util.go +++ b/tests/block_test_util.go @@ -127,7 +127,7 @@ func (t *BlockTest) Run(snapshotter bool) error { cache.SnapshotLimit = 1 cache.SnapshotWait = true } - chain, err := core.NewBlockChain(db, cache, config, engine, vm.Config{}, nil, nil) + chain, err := core.NewBlockChain(db, cache, config, engine, vm.Config{}, nil, nil, false) if err != nil { return err } diff --git a/tests/fuzzers/les/les-fuzzer.go b/tests/fuzzers/les/les-fuzzer.go index 52dff68601..3a5027bdd2 100644 --- a/tests/fuzzers/les/les-fuzzer.go +++ b/tests/fuzzers/les/les-fuzzer.go @@ -80,7 +80,7 @@ func makechain() (bc *core.BlockChain, addrHashes, txHashes []common.Hash) { addrHashes = append(addrHashes, crypto.Keccak256Hash(addr[:])) txHashes = append(txHashes, tx.Hash()) }) - bc, _ = core.NewBlockChain(db, nil, gspec.Config, ethash.NewFaker(), vm.Config{}, nil, nil) + bc, _ = core.NewBlockChain(db, nil, gspec.Config, ethash.NewFaker(), vm.Config{}, nil, nil, false) if _, err := bc.InsertChain(blocks); err != nil { panic(err) }