Skip to content

Commit 183cb66

Browse files
authored
Merge branch 'develop' into feat-migrate-setcode-tx-upstream-changes
2 parents 15391b3 + 7b56ff1 commit 183cb66

File tree

5 files changed

+81
-14
lines changed

5 files changed

+81
-14
lines changed

common/bytes.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ package common
1919

2020
import (
2121
"encoding/hex"
22+
"errors"
23+
24+
"github.com/scroll-tech/go-ethereum/common/hexutil"
2225
)
2326

2427
// FromHex returns the bytes represented by the hexadecimal string s.
@@ -92,6 +95,15 @@ func Hex2BytesFixed(str string, flen int) []byte {
9295
return hh
9396
}
9497

98+
// ParseHexOrString tries to hexdecode b, but if the prefix is missing, it instead just returns the raw bytes
99+
func ParseHexOrString(str string) ([]byte, error) {
100+
b, err := hexutil.Decode(str)
101+
if errors.Is(err, hexutil.ErrMissingPrefix) {
102+
return []byte(str), nil
103+
}
104+
return b, err
105+
}
106+
95107
// RightPadBytes zero-pads slice to the right up to length l.
96108
func RightPadBytes(slice []byte, l int) []byte {
97109
if l <= len(slice) {

consensus/system_contract/consensus.go

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ func (s *SystemContract) verifyHeader(chain consensus.ChainHeaderReader, header
130130
return errInvalidNonce
131131
}
132132
// Check that the BlockSignature contains signature if block is not requested
133-
if !header.Requested && header.Number.Cmp(big.NewInt(0)) != 0 && len(header.BlockSignature) != extraSeal {
133+
if header.Number.Cmp(big.NewInt(0)) != 0 && len(header.BlockSignature) != extraSeal {
134134
return errMissingSignature
135135
}
136136
// Ensure that the mix digest is zero
@@ -197,20 +197,17 @@ func (s *SystemContract) verifyCascadingFields(chain consensus.ChainHeaderReader
197197
return err
198198
}
199199

200-
// only if block header has NOT been requested, then verify the signature against the current signer
201-
if !header.Requested {
202-
signer, err := ecrecover(header)
203-
if err != nil {
204-
return err
205-
}
200+
signer, err := ecrecover(header)
201+
if err != nil {
202+
return err
203+
}
206204

207-
s.lock.RLock()
208-
defer s.lock.RUnlock()
205+
s.lock.RLock()
206+
defer s.lock.RUnlock()
209207

210-
if signer != s.signerAddressL1 {
211-
log.Error("Unauthorized signer", "Got", signer, "Expected:", s.signerAddressL1)
212-
return ErrUnauthorizedSigner
213-
}
208+
if signer != s.signerAddressL1 {
209+
log.Error("Unauthorized signer", "Got", signer, "Expected:", s.signerAddressL1)
210+
return ErrUnauthorizedSigner
214211
}
215212

216213
return nil

internal/ethapi/dbapi.go

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// Copyright 2022 The go-ethereum Authors
2+
// This file is part of the go-ethereum library.
3+
//
4+
// The go-ethereum library is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU Lesser General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// The go-ethereum library is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU Lesser General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU Lesser General Public License
15+
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
16+
17+
package ethapi
18+
19+
import (
20+
"github.com/scroll-tech/go-ethereum/common"
21+
"github.com/scroll-tech/go-ethereum/common/hexutil"
22+
)
23+
24+
// DbGet returns the raw value of a key stored in the database.
25+
func (api *PublicDebugAPI) DbGet(key string) (hexutil.Bytes, error) {
26+
blob, err := common.ParseHexOrString(key)
27+
if err != nil {
28+
return nil, err
29+
}
30+
return api.b.ChainDb().Get(blob)
31+
}
32+
33+
// DbAncient retrieves an ancient binary blob from the append-only immutable files.
34+
// It is a mapping to the `AncientReaderOp.Ancient` method
35+
func (api *PublicDebugAPI) DbAncient(kind string, number uint64) (hexutil.Bytes, error) {
36+
return api.b.ChainDb().Ancient(kind, number)
37+
}
38+
39+
// DbAncients returns the ancient item numbers in the ancient store.
40+
// It is a mapping to the `AncientReaderOp.Ancients` method
41+
func (api *PublicDebugAPI) DbAncients() (uint64, error) {
42+
return api.b.ChainDb().Ancients()
43+
}

internal/web3ext/web3ext.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,21 @@ web3._extend({
482482
params: 2,
483483
inputFormatter:[web3._extend.formatters.inputBlockNumberFormatter, web3._extend.formatters.inputBlockNumberFormatter],
484484
}),
485+
new web3._extend.Method({
486+
name: 'dbGet',
487+
call: 'debug_dbGet',
488+
params: 1
489+
}),
490+
new web3._extend.Method({
491+
name: 'dbAncient',
492+
call: 'debug_dbAncient',
493+
params: 2
494+
}),
495+
new web3._extend.Method({
496+
name: 'dbAncients',
497+
call: 'debug_dbAncients',
498+
params: 0
499+
}),
485500
new web3._extend.Method({
486501
name: 'executionWitness',
487502
call: 'debug_executionWitness',

params/version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
const (
2525
VersionMajor = 5 // Major version component of the current release
2626
VersionMinor = 8 // Minor version component of the current release
27-
VersionPatch = 41 // Patch version component of the current release
27+
VersionPatch = 43 // Patch version component of the current release
2828
VersionMeta = "mainnet" // Version metadata to append to the version string
2929
)
3030

0 commit comments

Comments
 (0)