Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

refactor: rename CCC package for less repetition #967

Merged
merged 1 commit into from
Aug 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/l2geth_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
- name: Build
run: |
make libzkp
sudo cp ./rollup/circuitcapacitychecker/libzkp/libzkp.so /usr/local/lib/
sudo cp ./rollup/ccc/libzkp/libzkp.so /usr/local/lib/
make geth
check:
if: github.event.pull_request.draft == false
Expand Down
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ FROM scrolltech/go-rust-builder:go-1.21-rust-nightly-2023-12-03 as chef
WORKDIR app

FROM chef as planner
COPY ./rollup/circuitcapacitychecker/libzkp/ .
COPY ./rollup/ccc/libzkp/ .
RUN cargo chef prepare --recipe-path recipe.json

FROM chef as zkp-builder
COPY ./rollup/circuitcapacitychecker/libzkp/rust-toolchain ./
COPY ./rollup/ccc/libzkp/rust-toolchain ./
COPY --from=planner /app/recipe.json recipe.json
RUN cargo chef cook --release --recipe-path recipe.json

COPY ./rollup/circuitcapacitychecker/libzkp .
COPY ./rollup/ccc/libzkp .
RUN cargo clean
RUN cargo build --release

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ GO ?= latest
GORUN = env GO111MODULE=on go run

libzkp:
cd $(PWD)/rollup/circuitcapacitychecker/libzkp && make libzkp
cd $(PWD)/rollup/ccc/libzkp && make libzkp

nccc_geth: ## geth without circuit capacity checker
$(GORUN) build/ci.go install ./cmd/geth
Expand Down
12 changes: 6 additions & 6 deletions core/block_validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (
"github.com/scroll-tech/go-ethereum/log"
"github.com/scroll-tech/go-ethereum/metrics"
"github.com/scroll-tech/go-ethereum/params"
"github.com/scroll-tech/go-ethereum/rollup/circuitcapacitychecker"
"github.com/scroll-tech/go-ethereum/rollup/ccc"
"github.com/scroll-tech/go-ethereum/trie"
)

Expand All @@ -52,10 +52,10 @@ type BlockValidator struct {
engine consensus.Engine // Consensus engine used for validating

// circuit capacity checker related fields
checkCircuitCapacity bool // whether enable circuit capacity check
cMu sync.Mutex // mutex for circuit capacity checker
tracer tracerWrapper // scroll tracer wrapper
circuitCapacityChecker *circuitcapacitychecker.CircuitCapacityChecker // circuit capacity checker instance
checkCircuitCapacity bool // whether enable circuit capacity check
cMu sync.Mutex // mutex for circuit capacity checker
tracer tracerWrapper // scroll tracer wrapper
circuitCapacityChecker *ccc.Checker // circuit capacity checker instance
}

// NewBlockValidator returns a new block validator which is safe for re-use
Expand All @@ -75,7 +75,7 @@ type tracerWrapper interface {
func (v *BlockValidator) SetupTracerAndCircuitCapacityChecker(tracer tracerWrapper) {
v.checkCircuitCapacity = true
v.tracer = tracer
v.circuitCapacityChecker = circuitcapacitychecker.NewCircuitCapacityChecker(true)
v.circuitCapacityChecker = ccc.NewChecker(true)
log.Info("new CircuitCapacityChecker in BlockValidator", "ID", v.circuitCapacityChecker.ID)
}

Expand Down
16 changes: 8 additions & 8 deletions miner/scroll_worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import (
"github.com/scroll-tech/go-ethereum/log"
"github.com/scroll-tech/go-ethereum/metrics"
"github.com/scroll-tech/go-ethereum/params"
"github.com/scroll-tech/go-ethereum/rollup/circuitcapacitychecker"
"github.com/scroll-tech/go-ethereum/rollup/ccc"
"github.com/scroll-tech/go-ethereum/rollup/fees"
"github.com/scroll-tech/go-ethereum/rollup/pipeline"
"github.com/scroll-tech/go-ethereum/trie"
Expand Down Expand Up @@ -128,7 +128,7 @@ 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
circuitCapacityChecker *ccc.Checker
prioritizedTx *prioritizedTransaction

// Test hooks
Expand All @@ -148,7 +148,7 @@ func newWorker(config *Config, chainConfig *params.ChainConfig, engine consensus
chainHeadCh: make(chan core.ChainHeadEvent, chainHeadChanSize),
exitCh: make(chan struct{}),
startCh: make(chan struct{}, 1),
circuitCapacityChecker: circuitcapacitychecker.NewCircuitCapacityChecker(true),
circuitCapacityChecker: ccc.NewChecker(true),
}
log.Info("created new worker", "CircuitCapacityChecker ID", worker.circuitCapacityChecker.ID)

Expand Down Expand Up @@ -176,7 +176,7 @@ func newWorker(config *Config, chainConfig *params.ChainConfig, engine consensus

// getCCC returns a pointer to this worker's CCC instance.
// Only used in tests.
func (w *worker) getCCC() *circuitcapacitychecker.CircuitCapacityChecker {
func (w *worker) getCCC() *ccc.Checker {
return w.circuitCapacityChecker
}

Expand Down Expand Up @@ -586,16 +586,16 @@ func (w *worker) handlePipelineResult(res *pipeline.Result) error {

switch {
case res.OverflowingTx.IsL1MessageTx() &&
errors.Is(res.CCCErr, circuitcapacitychecker.ErrBlockRowConsumptionOverflow):
errors.Is(res.CCCErr, ccc.ErrBlockRowConsumptionOverflow):
l1TxRowConsumptionOverflowCounter.Inc(1)
case !res.OverflowingTx.IsL1MessageTx() &&
errors.Is(res.CCCErr, circuitcapacitychecker.ErrBlockRowConsumptionOverflow):
errors.Is(res.CCCErr, ccc.ErrBlockRowConsumptionOverflow):
l2TxRowConsumptionOverflowCounter.Inc(1)
case res.OverflowingTx.IsL1MessageTx() &&
errors.Is(res.CCCErr, circuitcapacitychecker.ErrUnknown):
errors.Is(res.CCCErr, ccc.ErrUnknown):
l1TxCccUnknownErrCounter.Inc(1)
case !res.OverflowingTx.IsL1MessageTx() &&
errors.Is(res.CCCErr, circuitcapacitychecker.ErrUnknown):
errors.Is(res.CCCErr, ccc.ErrUnknown):
l2TxCccUnknownErrCounter.Inc(1)
}
}
Expand Down
10 changes: 5 additions & 5 deletions miner/scroll_worker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import (
"github.com/scroll-tech/go-ethereum/ethdb"
"github.com/scroll-tech/go-ethereum/event"
"github.com/scroll-tech/go-ethereum/params"
"github.com/scroll-tech/go-ethereum/rollup/circuitcapacitychecker"
"github.com/scroll-tech/go-ethereum/rollup/ccc"
"github.com/scroll-tech/go-ethereum/rollup/sync_service"
)

Expand Down Expand Up @@ -788,7 +788,7 @@ func TestOversizedTxThenNormal(t *testing.T) {
switch blockNum {
case 0:
// schedule to skip 2nd call to ccc
w.getCCC().ScheduleError(2, circuitcapacitychecker.ErrBlockRowConsumptionOverflow)
w.getCCC().ScheduleError(2, ccc.ErrBlockRowConsumptionOverflow)
return false
case 1:
// include #0, fail on #1, then seal the block
Expand All @@ -803,7 +803,7 @@ func TestOversizedTxThenNormal(t *testing.T) {
assert.Equal(uint64(1), *queueIndex)

// schedule to skip next call to ccc
w.getCCC().ScheduleError(1, circuitcapacitychecker.ErrBlockRowConsumptionOverflow)
w.getCCC().ScheduleError(1, ccc.ErrBlockRowConsumptionOverflow)

return false
case 2:
Expand Down Expand Up @@ -869,7 +869,7 @@ func TestPrioritizeOverflowTx(t *testing.T) {

// Process 2 transactions with gas order: tx0 > tx1, tx1 will overflow.
b.txPool.AddRemotesSync([]*types.Transaction{tx0, tx1})
w.getCCC().ScheduleError(2, circuitcapacitychecker.ErrBlockRowConsumptionOverflow)
w.getCCC().ScheduleError(2, ccc.ErrBlockRowConsumptionOverflow)
w.start()

select {
Expand Down Expand Up @@ -903,7 +903,7 @@ func TestPrioritizeOverflowTx(t *testing.T) {
t.Fatalf("timeout")
}

w.getCCC().Skip(tx4.Hash(), circuitcapacitychecker.ErrBlockRowConsumptionOverflow)
w.getCCC().Skip(tx4.Hash(), ccc.ErrBlockRowConsumptionOverflow)
assert.Equal([]error{nil, nil, nil}, b.txPool.AddRemotesSync([]*types.Transaction{tx3, tx4, tx5}))

w.start()
Expand Down
Loading
Loading