Skip to content

Commit

Permalink
Merge branch 'develop' into trace/override
Browse files Browse the repository at this point in the history
  • Loading branch information
0xmountaintop authored Jul 9, 2024
2 parents 243f7e7 + 9aee472 commit ecb1720
Show file tree
Hide file tree
Showing 34 changed files with 463 additions and 335 deletions.
13 changes: 8 additions & 5 deletions .github/workflows/docker-arm64.yaml
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
name: Docker
name: Docker-arm64

on:
workflow_dispatch: {}
workflow_dispatch:
inputs:
tag:
description: "tag of this image (suffix -arm64 is added automatically)"
required: true
type: string

jobs:
build-and-push-arm64-image:
runs-on: ubuntu-latest
strategy:
matrix:
arch:
- amd64
- aarch64

steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up QEMU
if: matrix.arch == 'aarch64'
run: |
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
docker buildx create --name multiarch --driver docker-container --use
Expand All @@ -35,4 +38,4 @@ jobs:
context: .
file: Dockerfile
push: true
tags: scrolltech/l2geth:${{github.ref_name}}-arm64-ubuntu
tags: scrolltech/l2geth:${{inputs.tag}}-arm64
15 changes: 14 additions & 1 deletion .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ on:
push:
tags:
- '*'
release:
types: [published]

jobs:
build-and-push:
Expand All @@ -15,6 +17,16 @@ jobs:
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Extract docker metadata
id: meta
uses: docker/metadata-action@v3
with:
images: scrolltech/l2geth
tags: |
type=ref,event=tag,enable=${{ github.event_name == 'push' }}
type=raw,value=latest,enable=${{ github.event_name == 'release' }}
flavor: |
latest=false
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
Expand All @@ -27,6 +39,7 @@ jobs:
file: Dockerfile
# push: ${{ startsWith(github.ref, 'refs/tags/') }}
push: true
tags: scrolltech/l2geth:${{github.ref_name}}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
# cache-from: type=gha,scope=${{ github.workflow }}
# cache-to: type=gha,scope=${{ github.workflow }}
1 change: 0 additions & 1 deletion .github/workflows/l2geth_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ jobs:
run: |
make libzkp
sudo cp ./rollup/circuitcapacitychecker/libzkp/libzkp.so /usr/local/lib/
sudo cp ./rollup/circuitcapacitychecker/libzkp/libzktrie.so /usr/local/lib/
make geth
check:
if: github.event.pull_request.draft == false
Expand Down
3 changes: 0 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ RUN cargo chef cook --release --recipe-path recipe.json
COPY ./rollup/circuitcapacitychecker/libzkp .
RUN cargo clean
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.21-rust-nightly-2023-12-03 as builder
Expand All @@ -32,7 +31,6 @@ ARG SCROLL_LIB_PATH
RUN mkdir -p $SCROLL_LIB_PATH

COPY --from=zkp-builder /app/target/release/libzkp.so $SCROLL_LIB_PATH
COPY --from=zkp-builder /app/target/release/libzktrie.so $SCROLL_LIB_PATH

ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$SCROLL_LIB_PATH
ENV CGO_LDFLAGS="-L$SCROLL_LIB_PATH -Wl,-rpath,$SCROLL_LIB_PATH"
Expand All @@ -52,7 +50,6 @@ ARG SCROLL_LIB_PATH
RUN mkdir -p $SCROLL_LIB_PATH

COPY --from=zkp-builder /app/target/release/libzkp.so $SCROLL_LIB_PATH
COPY --from=zkp-builder /app/target/release/libzktrie.so $SCROLL_LIB_PATH

ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$SCROLL_LIB_PATH
ENV CGO_LDFLAGS="-ldl -L$SCROLL_LIB_PATH -Wl,-rpath,$SCROLL_LIB_PATH"
Expand Down
3 changes: 3 additions & 0 deletions Dockerfile.mockccc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ RUN cd /go-ethereum && env GO111MODULE=on go run build/ci.go install ./cmd/geth
# Pull Geth into a second stage deploy alpine container
FROM ubuntu:20.04

RUN apt-get -qq update \
&& apt-get -qq install -y --no-install-recommends ca-certificates

ENV CGO_LDFLAGS="-ldl"

COPY --from=builder /go-ethereum/build/bin/geth /usr/local/bin/
Expand Down
3 changes: 3 additions & 0 deletions cmd/geth/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,9 @@ func prepare(ctx *cli.Context) {
case ctx.GlobalIsSet(utils.ScrollSepoliaFlag.Name):
log.Info("Starting l2geth on Scroll Sepolia testnet...")

case ctx.GlobalIsSet(utils.ScrollFlag.Name):
log.Info("Starting l2geth on Scroll mainnet...")

case ctx.GlobalIsSet(utils.DeveloperFlag.Name):
log.Info("Starting Geth in ephemeral dev mode...")

Expand Down
2 changes: 1 addition & 1 deletion core/blockchain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3722,7 +3722,7 @@ func TestCurieTransition(t *testing.T) {
b, _ := json.Marshal(params.AllEthashProtocolChanges)
json.Unmarshal(b, &config)
config.CurieBlock = big.NewInt(2)
config.DescartesBlock = nil
config.DarwinTime = nil

var (
db = rawdb.NewMemoryDatabase()
Expand Down
27 changes: 27 additions & 0 deletions core/rawdb/accessors_rollup_event.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,3 +144,30 @@ func ReadFinalizedL2BlockNumber(db ethdb.Reader) *uint64 {
finalizedL2BlockNumber := number.Uint64()
return &finalizedL2BlockNumber
}

// WriteLastFinalizedBatchIndex stores the last finalized batch index in the database.
func WriteLastFinalizedBatchIndex(db ethdb.KeyValueWriter, lastFinalizedBatchIndex uint64) {
value := big.NewInt(0).SetUint64(lastFinalizedBatchIndex).Bytes()
if err := db.Put(lastFinalizedBatchIndexKey, value); err != nil {
log.Crit("failed to store last finalized batch index for rollup event", "batch index", lastFinalizedBatchIndex, "value", value, "err", err)
}
}

// ReadLastFinalizedBatchIndex fetches the last finalized batch index from the database.
func ReadLastFinalizedBatchIndex(db ethdb.Reader) *uint64 {
data, err := db.Get(lastFinalizedBatchIndexKey)
if err != nil && isNotFoundErr(err) {
return nil
}
if err != nil {
log.Crit("failed to read last finalized batch index from database", "key", lastFinalizedBatchIndexKey, "err", err)
}

number := new(big.Int).SetBytes(data)
if !number.IsUint64() {
log.Crit("unexpected finalized batch index in database", "data", data, "number", number)
}

lastFinalizedBatchIndex := number.Uint64()
return &lastFinalizedBatchIndex
}
28 changes: 27 additions & 1 deletion core/rawdb/accessors_rollup_event_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func TestFinalizedL2BlockNumber(t *testing.T) {

// read non-existing value
if got := ReadFinalizedL2BlockNumber(db); got != nil {
t.Fatal("Expected 0 for non-existing value", "got", *got)
t.Fatal("Expected nil for non-existing value", "got", *got)
}

for _, num := range blockNumbers {
Expand All @@ -58,6 +58,32 @@ func TestFinalizedL2BlockNumber(t *testing.T) {
}
}

func TestLastFinalizedBatchIndex(t *testing.T) {
batchIndxes := []uint64{
1,
1 << 2,
1 << 8,
1 << 16,
1 << 32,
}

db := NewMemoryDatabase()

// read non-existing value
if got := ReadLastFinalizedBatchIndex(db); got != nil {
t.Fatal("Expected nil for non-existing value", "got", *got)
}

for _, num := range batchIndxes {
WriteLastFinalizedBatchIndex(db, num)
got := ReadLastFinalizedBatchIndex(db)

if *got != num {
t.Fatal("Batch index mismatch", "expected", num, "got", got)
}
}
}

func TestFinalizedBatchMeta(t *testing.T) {
batches := []*FinalizedBatchMeta{
{
Expand Down
1 change: 1 addition & 0 deletions core/rawdb/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ var (
batchChunkRangesPrefix = []byte("R-bcr")
batchMetaPrefix = []byte("R-bm")
finalizedL2BlockNumberKey = []byte("R-finalized")
lastFinalizedBatchIndexKey = []byte("R-finalizedBatchIndex")

// Row consumption
rowConsumptionPrefix = []byte("rc") // rowConsumptionPrefix + hash -> row consumption by block
Expand Down
2 changes: 1 addition & 1 deletion core/state_processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func TestStateProcessorErrors(t *testing.T) {
ShanghaiBlock: big.NewInt(0),
BernoulliBlock: big.NewInt(0),
CurieBlock: big.NewInt(0),
DescartesBlock: big.NewInt(0),
DarwinTime: new(uint64),
Ethash: new(params.EthashConfig),
}
signer = types.LatestSigner(config)
Expand Down
2 changes: 1 addition & 1 deletion core/state_transition.go
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ func (st *StateTransition) TransitionDb() (*ExecutionResult, error) {
var (
msg = st.msg
sender = vm.AccountRef(msg.From())
rules = st.evm.ChainConfig().Rules(st.evm.Context.BlockNumber)
rules = st.evm.ChainConfig().Rules(st.evm.Context.BlockNumber, st.evm.Context.Time.Uint64())
contractCreation = msg.To() == nil
)

Expand Down
3 changes: 3 additions & 0 deletions core/types/transaction_signing.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ func MakeSigner(config *params.ChainConfig, blockNumber *big.Int) Signer {
// have the current block number available, use MakeSigner instead.
func LatestSigner(config *params.ChainConfig) Signer {
if config.ChainID != nil {
if config.CurieBlock != nil {
return NewLondonSignerWithEIP4844(config.ChainID)
}
if config.LondonBlock != nil {
return NewLondonSignerWithEIP4844(config.ChainID)
}
Expand Down
2 changes: 1 addition & 1 deletion core/vm/evm.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ func NewEVM(blockCtx BlockContext, txCtx TxContext, statedb StateDB, chainConfig
StateDB: statedb,
Config: config,
chainConfig: chainConfig,
chainRules: chainConfig.Rules(blockCtx.BlockNumber),
chainRules: chainConfig.Rules(blockCtx.BlockNumber, blockCtx.Time.Uint64()),
}
evm.interpreter = NewEVMInterpreter(evm, config)
return evm
Expand Down
4 changes: 2 additions & 2 deletions core/vm/interpreter.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ func NewEVMInterpreter(evm *EVM, cfg Config) *EVMInterpreter {
if cfg.JumpTable[STOP] == nil {
var jt JumpTable
switch {
case evm.chainRules.IsDescartes:
jt = descartesInstructionSet
case evm.chainRules.IsDarwin:
jt = darwinInstructionSet
case evm.chainRules.IsCurie:
jt = curieInstructionSet
case evm.chainRules.IsShanghai:
Expand Down
8 changes: 4 additions & 4 deletions core/vm/jump_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,15 @@ var (
londonInstructionSet = newLondonInstructionSet()
shanghaiInstructionSet = newShanghaiInstructionSet()
curieInstructionSet = newCurieInstructionSet()
descartesInstructionSet = newDescartesInstructionSet()
darwinInstructionSet = newDarwinInstructionSet()
)

// JumpTable contains the EVM opcodes supported at a given fork.
type JumpTable [256]*operation

// newDescartesInstructionSet returns the frontier, homestead, byzantium,
// contantinople, istanbul, petersburg, berlin, london, shanghai, curie, and descartes instructions.
func newDescartesInstructionSet() JumpTable {
// newDarwinInstructionSet returns the frontier, homestead, byzantium,
// contantinople, istanbul, petersburg, berlin, london, shanghai, curie, and darwin instructions.
func newDarwinInstructionSet() JumpTable {
instructionSet := newCurieInstructionSet()
return instructionSet
}
Expand Down
8 changes: 4 additions & 4 deletions core/vm/runtime/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func setDefaults(cfg *Config) {
ShanghaiBlock: new(big.Int),
BernoulliBlock: new(big.Int),
CurieBlock: new(big.Int),
DescartesBlock: new(big.Int),
DarwinTime: new(uint64),
}
}

Expand Down Expand Up @@ -122,7 +122,7 @@ func Execute(code, input []byte, cfg *Config) ([]byte, *state.StateDB, error) {
address = common.BytesToAddress([]byte("contract"))
vmenv = NewEnv(cfg)
sender = vm.AccountRef(cfg.Origin)
rules = cfg.ChainConfig.Rules(vmenv.Context.BlockNumber)
rules = cfg.ChainConfig.Rules(vmenv.Context.BlockNumber, vmenv.Context.Time.Uint64())
)
// Execute the preparatory steps for state transition which includes:
// - prepare accessList(post-berlin)
Expand Down Expand Up @@ -156,7 +156,7 @@ func Create(input []byte, cfg *Config) ([]byte, common.Address, uint64, error) {
var (
vmenv = NewEnv(cfg)
sender = vm.AccountRef(cfg.Origin)
rules = cfg.ChainConfig.Rules(vmenv.Context.BlockNumber)
rules = cfg.ChainConfig.Rules(vmenv.Context.BlockNumber, vmenv.Context.Time.Uint64())
)
// Execute the preparatory steps for state transition which includes:
// - prepare accessList(post-berlin)
Expand Down Expand Up @@ -185,7 +185,7 @@ func Call(address common.Address, input []byte, cfg *Config) ([]byte, uint64, er
vmenv = NewEnv(cfg)
sender = cfg.State.GetOrNewStateObject(cfg.Origin)
statedb = cfg.State
rules = cfg.ChainConfig.Rules(vmenv.Context.BlockNumber)
rules = cfg.ChainConfig.Rules(vmenv.Context.BlockNumber, vmenv.Context.Time.Uint64())
)
// Execute the preparatory steps for state transition which includes:
// - prepare accessList(post-berlin)
Expand Down
2 changes: 1 addition & 1 deletion eth/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ func (s *Ethereum) Protocols() []p2p.Protocol {
// Start implements node.Lifecycle, starting all internal goroutines needed by the
// Ethereum protocol implementation.
func (s *Ethereum) Start() error {
//eth.StartENRUpdater(s.blockchain, s.p2pServer.LocalNode())
eth.StartENRUpdater(s.blockchain, s.p2pServer.LocalNode())

// Start the bloom bits servicing goroutines
s.startBloomHandlers(params.BloomBitsBlocks)
Expand Down
2 changes: 1 addition & 1 deletion eth/gasprice/gasprice_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func newTestBackend(t *testing.T, londonBlock *big.Int, pending bool, pendingTxC
config.ShanghaiBlock = londonBlock
config.BernoulliBlock = londonBlock
config.CurieBlock = londonBlock
config.DescartesBlock = londonBlock
config.DarwinTime = nil
engine := ethash.NewFaker()
db := rawdb.NewMemoryDatabase()
genesis, err := gspec.Commit(db)
Expand Down
2 changes: 1 addition & 1 deletion eth/tracers/js/tracer.go
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,7 @@ func (jst *jsTracer) CaptureStart(env *vm.EVM, from common.Address, to common.Ad
jst.ctx["block"] = env.Context.BlockNumber.Uint64()
jst.dbWrapper.db = env.StateDB
// Update list of precompiles based on current block
rules := env.ChainConfig().Rules(env.Context.BlockNumber)
rules := env.ChainConfig().Rules(env.Context.BlockNumber, env.Context.Time.Uint64())
jst.activePrecompiles = vm.ActivePrecompiles(rules)

// Compute intrinsic gas
Expand Down
2 changes: 1 addition & 1 deletion eth/tracers/native/4byte.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func (t *fourByteTracer) CaptureStart(env *vm.EVM, from common.Address, to commo
t.env = env

// Update list of precompiles based on current block
rules := env.ChainConfig().Rules(env.Context.BlockNumber)
rules := env.ChainConfig().Rules(env.Context.BlockNumber, env.Context.Time.Uint64())
t.activePrecompiles = vm.ActivePrecompiles(rules)

// Save the outer calldata also
Expand Down
2 changes: 1 addition & 1 deletion internal/ethapi/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -1492,7 +1492,7 @@ func AccessList(ctx context.Context, b Backend, blockNrOrHash rpc.BlockNumberOrH
to = crypto.CreateAddress(args.from(), uint64(*args.Nonce))
}
// Retrieve the precompiles since they don't need to be added to the access list
precompiles := vm.ActivePrecompiles(b.ChainConfig().Rules(header.Number))
precompiles := vm.ActivePrecompiles(b.ChainConfig().Rules(header.Number, header.Time))

// Create an initial tracer
prevTracer := vm.NewAccessListTracer(nil, args.from(), to, precompiles)
Expand Down
Loading

0 comments on commit ecb1720

Please sign in to comment.