Skip to content

Commit 0c1ea7c

Browse files
Merge branch 'develop' into reset_skipped_traces
2 parents 10092a4 + 55b03ff commit 0c1ea7c

File tree

97 files changed

+8275
-995
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+8275
-995
lines changed
+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { URL } from "url";
2+
import { readFileSync, writeFileSync } from "fs";
3+
4+
const versionFilePath = new URL(
5+
"../../params/version.go",
6+
import.meta.url
7+
).pathname;
8+
9+
const versionFileContent = readFileSync(versionFilePath, { encoding: "utf-8" });
10+
11+
const currentVersionPatch = versionFileContent.match(
12+
/VersionPatch = (?<patch>\d+)/
13+
).groups.patch;
14+
15+
try {
16+
parseInt(currentVersionPatch);
17+
} catch (err) {
18+
console.error(new Error("Failed to parse version in version.go file"));
19+
throw err;
20+
}
21+
22+
// prettier-ignore
23+
const newVersionPatch = `${parseInt(currentVersionPatch) + 1}`;
24+
25+
console.log(
26+
`Bump version from ${currentVersionPatch} to ${newVersionPatch}`
27+
);
28+
29+
writeFileSync(
30+
versionFilePath,
31+
versionFileContent.replace(
32+
`VersionPatch = ${currentVersionPatch}`,
33+
`VersionPatch = ${newVersionPatch}`
34+
)
35+
);

.github/workflows/bump_version.yml

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Bump version
2+
3+
on:
4+
pull_request:
5+
branches: [ develop ]
6+
types:
7+
- opened
8+
- reopened
9+
- synchronize
10+
- ready_for_review
11+
- labeled
12+
13+
jobs:
14+
try-to-bump:
15+
if: contains(github.event.pull_request.labels.*.name, 'bump-version')
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v3
20+
with:
21+
ref: ${{ github.head_ref }}
22+
- name: check diff
23+
id: check_diff
24+
run: |
25+
set -euo pipefail
26+
27+
# fetch develop branch so that we can diff against later
28+
git fetch origin develop
29+
30+
echo 'checking verion changes in diff...'
31+
32+
# check if version changed in version.go
33+
# note: the grep will fail if use \d instead of [0-9]
34+
git diff HEAD..origin/develop --text --no-ext-diff --unified=0 --no-prefix params/version.go | grep -E '^\+VersionPatch = "v[0-9]+"$' && true
35+
36+
exit_code=$?
37+
38+
# auto bump if version is not bumped manually
39+
echo '> require auto version bump?'
40+
41+
if [ $exit_code -eq 0 ]; then
42+
echo '> no, already bumped'
43+
echo "result=no-bump" >> "$GITHUB_OUTPUT"
44+
else
45+
echo '> yes'
46+
echo "result=bump" >> "$GITHUB_OUTPUT"
47+
fi
48+
- name: Install Node.js 16
49+
if: steps.check_diff.outputs.result == 'bump'
50+
uses: actions/setup-node@v3
51+
with:
52+
node-version: 16
53+
- name: bump version in params/version.go
54+
if: steps.check_diff.outputs.result == 'bump'
55+
run: node .github/scripts/bump_version_dot_go.mjs
56+
57+
# Commits made by this Action do not trigger new Workflow runs
58+
- uses: stefanzweifel/git-auto-commit-action@3ea6ae190baf489ba007f7c92608f33ce20ef04a
59+
if: steps.check_diff.outputs.result == 'bump'
60+
with:
61+
skip_fetch: true # already did fetch in check diff
62+
file_pattern: "params/version.go"
63+
commit_message: "chore: auto version bump [bot]"

.github/workflows/l2geth_ci.yml

+19-3
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,31 @@ jobs:
6969
- name: Install Go
7070
uses: actions/setup-go@v2
7171
with:
72-
go-version: 1.20.x
72+
go-version: 1.18.x
7373
- name: Install goimports
7474
run: go install golang.org/x/tools/cmd/goimports@latest
7575
- name: Checkout code
7676
uses: actions/checkout@v2
7777
- run: goimports -local github.com/scroll-tech/go-ethereum/ -w .
78+
# If there are any diffs from goimports, fail.
79+
- name: Verify no changes from goimports
80+
run: |
81+
if [ -n "$(git status --porcelain)" ]; then
82+
exit 1
83+
fi
84+
go-mod-tidy-lint:
85+
if: github.event.pull_request.draft == false
86+
runs-on: ubuntu-latest
87+
steps:
88+
- name: Install Go
89+
uses: actions/setup-go@v2
90+
with:
91+
go-version: 1.20.x
92+
- name: Checkout code
93+
uses: actions/checkout@v2
7894
- run: go mod tidy
79-
# If there are any diffs from goimports or go mod tidy, fail.
80-
- name: Verify no changes from goimports and go mod tidy
95+
# If there are any diffs from go mod tidy, fail.
96+
- name: Verify no changes from go mod tidy
8197
run: |
8298
if [ -n "$(git status --porcelain)" ]; then
8399
exit 1

.gitmodules

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
shallow = true
55
[submodule "internal/utesting/blocktraces"]
66
path = internal/utesting/blocktraces
7-
url = git@github.com:scroll-tech/test-traces.git
7+
url = https://github.com/scroll-tech/test-traces.git

Dockerfile

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ COPY --from=planner /app/recipe.json recipe.json
1717
RUN cargo chef cook --release --recipe-path recipe.json
1818

1919
COPY ./rollup/circuitcapacitychecker/libzkp .
20+
RUN cargo clean
2021
RUN cargo build --release
2122
RUN find ./ | grep libzktrie.so | xargs -I{} cp {} /app/target/release/
2223

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ ZK-Rollup adapts the Go Ethereum to run as Layer 2 Sequencer. The codebase is ba
1717

1818
Another implement for storage trie, base on patricia merkle tree, has been induced. It is feasible to zk proving in the storage part. It is specified as a flag in gensis, set `config.scroll.useZktrie` to true for enabling it.
1919

20-
Notice current the snapshot would be disabled by the zktrie implement.
20+
Notice that currently the snapshot would be disabled by the zktrie implement.
2121

2222
## Building the source
2323

accounts/abi/bind/backends/simulated.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@ func (b *SimulatedBackend) callContract(ctx context.Context, call ethereum.CallM
590590
return nil, errors.New("both gasPrice and (maxFeePerGas or maxPriorityFeePerGas) specified")
591591
}
592592
head := b.blockchain.CurrentHeader()
593-
if !b.blockchain.Config().IsLondon(head.Number) {
593+
if !b.blockchain.Config().IsCurie(head.Number) {
594594
// If there's no basefee, then it must be a non-1559 execution
595595
if call.GasPrice == nil {
596596
call.GasPrice = new(big.Int)

accounts/abi/bind/base.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ func (c *BoundContract) createDynamicTx(opts *TransactOpts, contract *common.Add
289289

290290
func (c *BoundContract) createLegacyTx(opts *TransactOpts, contract *common.Address, input []byte) (*types.Transaction, error) {
291291
if opts.GasFeeCap != nil || opts.GasTipCap != nil {
292-
return nil, errors.New("maxFeePerGas or maxPriorityFeePerGas specified but london is not active yet")
292+
return nil, errors.New("maxFeePerGas or maxPriorityFeePerGas specified but curie is not active yet")
293293
}
294294
// Normalize value
295295
value := opts.Value

cmd/evm/internal/t8ntool/transition.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,8 @@ func Transition(ctx *cli.Context) error {
247247
return NewError(ErrorJson, fmt.Errorf("failed signing transactions: %v", err))
248248
}
249249
// Sanity check, to not `panic` in state_transition
250-
if chainConfig.IsLondon(big.NewInt(int64(prestate.Env.Number))) {
251-
if prestate.Env.BaseFee == nil && chainConfig.Scroll.BaseFeeEnabled() {
250+
if chainConfig.IsCurie(big.NewInt(int64(prestate.Env.Number))) {
251+
if prestate.Env.BaseFee == nil {
252252
return NewError(ErrorConfig, errors.New("EIP-1559 config but missing 'currentBaseFee' in env section"))
253253
}
254254
}
@@ -321,8 +321,9 @@ func (t *txWithKey) UnmarshalJSON(input []byte) error {
321321
// signUnsignedTransactions converts the input txs to canonical transactions.
322322
//
323323
// The transactions can have two forms, either
324-
// 1. unsigned or
325-
// 2. signed
324+
// 1. unsigned or
325+
// 2. signed
326+
//
326327
// For (1), r, s, v, need so be zero, and the `secretKey` needs to be set.
327328
// If so, we sign it here and now, with the given `secretKey`
328329
// If the condition above is not met, then it's considered a signed transaction.

consensus/clique/clique.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ func (c *Clique) verifyCascadingFields(chain consensus.ChainHeaderReader, header
335335
if header.GasUsed > header.GasLimit {
336336
return fmt.Errorf("invalid gasUsed: have %d, gasLimit %d", header.GasUsed, header.GasLimit)
337337
}
338-
if !chain.Config().IsLondon(header.Number) {
338+
if !chain.Config().IsCurie(header.Number) {
339339
// Verify BaseFee not present before EIP-1559 fork.
340340
if header.BaseFee != nil {
341341
return fmt.Errorf("invalid baseFee before fork: have %d, want <nil>", header.BaseFee)

consensus/ethash/consensus.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ func (ethash *Ethash) verifyHeader(chain consensus.ChainHeaderReader, header, pa
291291
return fmt.Errorf("invalid gasUsed: have %d, gasLimit %d", header.GasUsed, header.GasLimit)
292292
}
293293
// Verify the block's gas usage and (if applicable) verify the base fee.
294-
if !chain.Config().IsLondon(header.Number) {
294+
if !chain.Config().IsCurie(header.Number) {
295295
// Verify BaseFee not present before EIP-1559 fork.
296296
if header.BaseFee != nil {
297297
return fmt.Errorf("invalid baseFee before fork: have %d, expected 'nil'", header.BaseFee)

consensus/misc/eip1559.go

+26-63
Original file line numberDiff line numberDiff line change
@@ -20,90 +20,53 @@ import (
2020
"fmt"
2121
"math/big"
2222

23-
"github.com/scroll-tech/go-ethereum/common"
24-
"github.com/scroll-tech/go-ethereum/common/math"
2523
"github.com/scroll-tech/go-ethereum/core/types"
2624
"github.com/scroll-tech/go-ethereum/params"
2725
)
2826

27+
// Protocol-enforced maximum L2 base fee.
28+
// We would only go above this if L1 base fee hits 700 Gwei.
29+
const MaximumL2BaseFee = 10000000000
30+
2931
// VerifyEip1559Header verifies some header attributes which were changed in EIP-1559,
3032
// - gas limit check
3133
// - basefee check
3234
func VerifyEip1559Header(config *params.ChainConfig, parent, header *types.Header) error {
3335
// Verify that the gas limit remains within allowed bounds
34-
parentGasLimit := parent.GasLimit
35-
if !config.IsLondon(parent.Number) {
36-
parentGasLimit = parent.GasLimit * params.ElasticityMultiplier
37-
}
38-
if err := VerifyGaslimit(parentGasLimit, header.GasLimit); err != nil {
36+
if err := VerifyGaslimit(parent.GasLimit, header.GasLimit); err != nil {
3937
return err
4038
}
4139
// Verify the header is not malformed
42-
if header.BaseFee == nil && config.Scroll.BaseFeeEnabled() {
43-
return fmt.Errorf("header is missing baseFee")
44-
}
45-
// Now BaseFee can be nil, because !config.Scroll.BaseFeeEnabled()
4640
if header.BaseFee == nil {
47-
return nil
48-
}
49-
// Verify the baseFee is correct based on the parent header.
50-
51-
var expectedBaseFee *big.Int
52-
53-
// compatible check with the logic in commitNewWork
54-
if config.Clique == nil || config.Scroll.BaseFeeEnabled() {
55-
expectedBaseFee = CalcBaseFee(config, parent)
56-
} else {
57-
expectedBaseFee = big.NewInt(0)
41+
return fmt.Errorf("header is missing baseFee")
5842
}
59-
60-
if header.BaseFee.Cmp(expectedBaseFee) != 0 {
61-
return fmt.Errorf("invalid baseFee: have %s, want %s, parentBaseFee %s, parentGasUsed %d",
62-
expectedBaseFee, header.BaseFee, parent.BaseFee, parent.GasUsed)
43+
// note: we do not verify L2 base fee, the sequencer has the
44+
// right to set any base fee below the maximum. L2 base fee
45+
// is not subject to L2 consensus or zk verification.
46+
if header.BaseFee.Cmp(big.NewInt(MaximumL2BaseFee)) > 0 {
47+
return fmt.Errorf("invalid baseFee: have %s, maximum %d", header.BaseFee, MaximumL2BaseFee)
6348
}
6449
return nil
6550
}
6651

6752
// CalcBaseFee calculates the basefee of the header.
68-
func CalcBaseFee(config *params.ChainConfig, parent *types.Header) *big.Int {
69-
// If the current block is the first EIP-1559 block, return the InitialBaseFee.
70-
if !config.IsLondon(parent.Number) {
71-
return new(big.Int).SetUint64(params.InitialBaseFee)
72-
}
53+
func CalcBaseFee(config *params.ChainConfig, parent *types.Header, parentL1BaseFee *big.Int) *big.Int {
54+
l2SequencerFee := big.NewInt(10000000) // 0.01 Gwei
55+
provingFee := big.NewInt(140000000) // 0.14 Gwei
7356

74-
var (
75-
parentGasTarget = parent.GasLimit / params.ElasticityMultiplier
76-
parentGasTargetBig = new(big.Int).SetUint64(parentGasTarget)
77-
baseFeeChangeDenominator = new(big.Int).SetUint64(params.BaseFeeChangeDenominator)
78-
)
79-
if !config.Scroll.BaseFeeEnabled() {
80-
return nil
81-
}
82-
// If the parent gasUsed is the same as the target, the baseFee remains unchanged.
83-
if parent.GasUsed == parentGasTarget {
84-
return new(big.Int).Set(parent.BaseFee)
85-
}
86-
if parent.GasUsed > parentGasTarget {
87-
// If the parent block used more gas than its target, the baseFee should increase.
88-
gasUsedDelta := new(big.Int).SetUint64(parent.GasUsed - parentGasTarget)
89-
x := new(big.Int).Mul(parent.BaseFee, gasUsedDelta)
90-
y := x.Div(x, parentGasTargetBig)
91-
baseFeeDelta := math.BigMax(
92-
x.Div(y, baseFeeChangeDenominator),
93-
common.Big1,
94-
)
57+
// L1_base_fee * 0.014
58+
verificationFee := parentL1BaseFee
59+
verificationFee = new(big.Int).Mul(verificationFee, big.NewInt(14))
60+
verificationFee = new(big.Int).Div(verificationFee, big.NewInt(1000))
9561

96-
return x.Add(parent.BaseFee, baseFeeDelta)
97-
} else {
98-
// Otherwise if the parent block used less gas than its target, the baseFee should decrease.
99-
gasUsedDelta := new(big.Int).SetUint64(parentGasTarget - parent.GasUsed)
100-
x := new(big.Int).Mul(parent.BaseFee, gasUsedDelta)
101-
y := x.Div(x, parentGasTargetBig)
102-
baseFeeDelta := x.Div(y, baseFeeChangeDenominator)
62+
baseFee := big.NewInt(0)
63+
baseFee.Add(baseFee, l2SequencerFee)
64+
baseFee.Add(baseFee, provingFee)
65+
baseFee.Add(baseFee, verificationFee)
10366

104-
return math.BigMax(
105-
x.Sub(parent.BaseFee, baseFeeDelta),
106-
common.Big0,
107-
)
67+
if baseFee.Cmp(big.NewInt(MaximumL2BaseFee)) > 0 {
68+
baseFee = big.NewInt(MaximumL2BaseFee)
10869
}
70+
71+
return baseFee
10972
}

0 commit comments

Comments
 (0)