Skip to content

Commit

Permalink
upgrade zkevm-circuit to v0.10.5 and improve libzkp (#79)
Browse files Browse the repository at this point in the history
  • Loading branch information
FletcherMan authored May 17, 2024
1 parent 99599e0 commit c6e7135
Show file tree
Hide file tree
Showing 9 changed files with 1,013 additions and 781 deletions.
4 changes: 2 additions & 2 deletions Dockerfile.morph
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ ARG VERSION=""
ARG BUILDNUM=""

# Build libzkp dependency
FROM morph/go-rust-builder:go-1.20-rust-nightly-2022-12-10 as chef
FROM morph/go-rust-builder:go-1.20-rust-nightly-2023-12-03 as chef
WORKDIR /app

FROM chef as planner
Expand All @@ -21,7 +21,7 @@ COPY ./rollup/circuitcapacitychecker/libzkp .
RUN cargo build --release
RUN find ./ | grep libzktrie.so | xargs -I{} cp {} /app/target/release/

FROM morph/go-rust-builder:go-1.20-rust-nightly-2022-12-10 as builder
FROM morph/go-rust-builder:go-1.20-rust-nightly-2023-12-03 as builder

ADD . /go-ethereum
COPY --from=zkp-builder /app/target/release/libzkp.so /usr/local/lib/
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ mockccc_alpine_docker:
docker build -t morph/l2geth:latest ./ -f Dockerfile.mockccc.alpine

base_image:
docker build -t morph/go-rust-builder:go-1.19-rust-nightly-2022-12-10 ./ -f go-rust-builder.Dockerfile
docker build -t morph/go-rust-builder:go-1.19-rust-nightly-2023-12-03 ./ -f go-rust-builder.Dockerfile

morph_docker:
docker build -t morph/l2geth:latest ./ -f Dockerfile.morph
Expand Down
2 changes: 1 addition & 1 deletion go-rust-builder.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ARG GO_VERSION=1.20
ARG RUST_VERSION=nightly-2022-12-10
ARG RUST_VERSION=nightly-2023-12-03
ARG CARGO_CHEF_TAG=0.1.41

FROM ubuntu:20.04
Expand Down
14 changes: 9 additions & 5 deletions rollup/circuitcapacitychecker/impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ package circuitcapacitychecker
import "C" //nolint:typecheck

import (
"bytes"
"encoding/json"
"fmt"
"sync"
Expand All @@ -30,7 +31,8 @@ func init() {
type CircuitCapacityChecker struct {
// mutex for each CircuitCapacityChecker itself
sync.Mutex
ID uint64
ID uint64
jsonBuffer bytes.Buffer
}

// NewCircuitCapacityChecker creates a new CircuitCapacityChecker
Expand Down Expand Up @@ -66,13 +68,14 @@ func (ccc *CircuitCapacityChecker) ApplyTransaction(traces *types.BlockTrace) (*
return nil, ErrUnknown
}

tracesByt, err := json.Marshal(traces)
ccc.jsonBuffer.Reset()
err := json.NewEncoder(&ccc.jsonBuffer).Encode(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))
tracesStr := C.CString(string(ccc.jsonBuffer.Bytes()))
defer func() {
C.free(unsafe.Pointer(tracesStr))
}()
Expand Down Expand Up @@ -112,13 +115,14 @@ func (ccc *CircuitCapacityChecker) ApplyBlock(traces *types.BlockTrace) (*types.
ccc.Lock()
defer ccc.Unlock()

tracesByt, err := json.Marshal(traces)
ccc.jsonBuffer.Reset()
err := json.NewEncoder(&ccc.jsonBuffer).Encode(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))
tracesStr := C.CString(string(ccc.jsonBuffer.Bytes()))
defer func() {
C.free(unsafe.Pointer(tracesStr))
}()
Expand Down
Loading

0 comments on commit c6e7135

Please sign in to comment.