Skip to content

Commit 8d8ac13

Browse files
committed
feat: add param to skip system config signer check
1 parent 3d0604b commit 8d8ac13

File tree

10 files changed

+32
-12
lines changed

10 files changed

+32
-12
lines changed

cmd/geth/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ var (
182182
utils.GossipSequencerHTTPFlag,
183183
utils.GossipBroadcastToAllEnabledFlag,
184184
utils.GossipBroadcastToAllCapFlag,
185+
utils.SkipSignerCheckFlag,
185186
utils.DASyncEnabledFlag,
186187
utils.DAMissingHeaderFieldsBaseURLFlag,
187188
utils.DABlockNativeAPIEndpointFlag,

cmd/geth/usage.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@ var AppHelpFlagGroups = []flags.FlagGroup{
255255
utils.GossipSequencerHTTPFlag,
256256
utils.GossipBroadcastToAllEnabledFlag,
257257
utils.GossipBroadcastToAllCapFlag,
258+
utils.SkipSignerCheckFlag,
258259
},
259260
},
260261
{

cmd/utils/flags.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -919,6 +919,11 @@ var (
919919
Value: 30,
920920
}
921921

922+
SkipSignerCheckFlag = cli.BoolFlag{
923+
Name: "skipsignercheck",
924+
Usage: "Skip signer check for the SystemContract engine",
925+
}
926+
922927
// DA syncing settings
923928
DASyncEnabledFlag = cli.BoolFlag{
924929
Name: "da.sync",
@@ -1847,6 +1852,10 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
18471852
cfg.GossipBroadcastToAllCap = ctx.GlobalInt(GossipBroadcastToAllCapFlag.Name)
18481853
log.Info("Gossip broadcast to all enabled", "enabled", cfg.GossipBroadcastToAllEnabled, "cap", cfg.GossipBroadcastToAllCap)
18491854
}
1855+
if ctx.GlobalIsSet(SkipSignerCheckFlag.Name) {
1856+
cfg.SkipSignerCheck = ctx.GlobalBool(SkipSignerCheckFlag.Name)
1857+
log.Info("Skip signer check for the SystemContract engine", "skipped", cfg.SkipSignerCheck)
1858+
}
18501859
// Only configure sequencer http flag if we're running in verifier mode i.e. --mine is disabled.
18511860
if ctx.IsSet(GossipSequencerHTTPFlag.Name) && !ctx.IsSet(MiningEnabledFlag.Name) {
18521861
cfg.GossipSequencerHTTP = ctx.String(GossipSequencerHTTPFlag.Name)

consensus/system_contract/consensus.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ func (s *SystemContract) verifyHeader(chain consensus.ChainHeaderReader, header
135135
return errInvalidNonce
136136
}
137137
// Check that the BlockSignature contains signature if block is not requested
138-
if header.Number.Cmp(big.NewInt(0)) != 0 && len(header.BlockSignature) != extraSeal {
138+
if !s.skipSignerCheck && header.Number.Cmp(big.NewInt(0)) != 0 && len(header.BlockSignature) != extraSeal {
139139
return errMissingSignature
140140
}
141141
// Ensure that the mix digest is zero
@@ -202,6 +202,10 @@ func (s *SystemContract) verifyCascadingFields(chain consensus.ChainHeaderReader
202202
return err
203203
}
204204

205+
if s.skipSignerCheck {
206+
return nil
207+
}
208+
205209
signer, err := ecrecover(header)
206210
if err != nil {
207211
return err

consensus/system_contract/system_contract.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,13 @@ type SystemContract struct {
3333

3434
ctx context.Context
3535
cancel context.CancelFunc
36+
37+
skipSignerCheck bool
3638
}
3739

3840
// New creates a SystemContract consensus engine with the initial
3941
// authorized signer fetched from L1 (if available).
40-
func New(ctx context.Context, config *params.SystemContractConfig, client sync_service.EthClient) *SystemContract {
42+
func New(ctx context.Context, config *params.SystemContractConfig, client sync_service.EthClient, skipSignerCheck bool) *SystemContract {
4143
log.Info("Initializing system_contract consensus engine", "config", config)
4244

4345
ctx, cancel := context.WithCancel(ctx)

consensus/system_contract/system_contract_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func TestSystemContract_FetchSigner(t *testing.T) {
3636
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
3737
defer cancel()
3838

39-
sys := New(ctx, config, fakeClient)
39+
sys := New(ctx, config, fakeClient, false)
4040
defer sys.Close()
4141

4242
require.NoError(t, sys.fetchAddressFromL1())
@@ -62,7 +62,7 @@ func TestSystemContract_AuthorizeCheck(t *testing.T) {
6262
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
6363
defer cancel()
6464

65-
sys := New(ctx, config, fakeClient)
65+
sys := New(ctx, config, fakeClient, false)
6666
defer sys.Close()
6767

6868
require.NoError(t, sys.fetchAddressFromL1())
@@ -117,7 +117,7 @@ func TestSystemContract_SignsAfterUpdate(t *testing.T) {
117117
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
118118
defer cancel()
119119

120-
sys := New(ctx, config, fakeClient)
120+
sys := New(ctx, config, fakeClient, false)
121121
defer sys.Close()
122122

123123
require.NoError(t, sys.fetchAddressFromL1())

eth/backend.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ type Ethereum struct {
120120

121121
// New creates a new Ethereum object (including the
122122
// initialisation of the common Ethereum object)
123-
func New(stack *node.Node, config *ethconfig.Config, l1Client l1.Client) (*Ethereum, error) {
123+
func New(stack *node.Node, config *ethconfig.Config, l1Client l1.Client, ) (*Ethereum, error) {
124124
// Ensure configuration values are compatible and sane
125125
if config.SyncMode == downloader.LightSync {
126126
return nil, errors.New("can't run eth.Ethereum in light sync mode, use les.LightEthereum")
@@ -166,7 +166,7 @@ func New(stack *node.Node, config *ethconfig.Config, l1Client l1.Client) (*Ether
166166
chainDb: chainDb,
167167
eventMux: stack.EventMux(),
168168
accountManager: stack.AccountManager(),
169-
engine: ethconfig.CreateConsensusEngine(stack, chainConfig, &ethashConfig, config.Miner.Notify, config.Miner.Noverify, chainDb, l1Client),
169+
engine: ethconfig.CreateConsensusEngine(stack, chainConfig, &ethashConfig, config.Miner.Notify, config.Miner.Noverify, chainDb, l1Client, config.SkipSignerCheck),
170170
closeBloomHandler: make(chan struct{}),
171171
networkID: config.NetworkId,
172172
gasPrice: config.Miner.GasPrice,

eth/ethconfig/config.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -236,14 +236,17 @@ type Config struct {
236236
GossipSequencerHTTP string
237237
GossipBroadcastToAllEnabled bool
238238
GossipBroadcastToAllCap int
239+
240+
// Skip signer check for the SystemContract engine
241+
SkipSignerCheck bool
239242
}
240243

241244
// CreateConsensusEngine creates a consensus engine for the given chain configuration.
242-
func CreateConsensusEngine(stack *node.Node, chainConfig *params.ChainConfig, config *ethash.Config, notify []string, noverify bool, db ethdb.Database, l1Client sync_service.EthClient) consensus.Engine {
245+
func CreateConsensusEngine(stack *node.Node, chainConfig *params.ChainConfig, config *ethash.Config, notify []string, noverify bool, db ethdb.Database, l1Client sync_service.EthClient, skipSignerCheck bool) consensus.Engine {
243246
// Case 1: Both SystemContract and Clique are defined: create an upgradable engine.
244247
if chainConfig.SystemContract != nil && chainConfig.Clique != nil {
245248
cliqueEngine := clique.New(chainConfig.Clique, db)
246-
sysEngine := system_contract.New(context.Background(), chainConfig.SystemContract, l1Client)
249+
sysEngine := system_contract.New(context.Background(), chainConfig.SystemContract, l1Client, skipSignerCheck)
247250
sysEngine.Start()
248251
return wrapper.NewUpgradableEngine(chainConfig.IsEuclidV2, cliqueEngine, sysEngine)
249252
}
@@ -255,7 +258,7 @@ func CreateConsensusEngine(stack *node.Node, chainConfig *params.ChainConfig, co
255258

256259
// Case 3: Only the SystemContract engine is defined.
257260
if chainConfig.SystemContract != nil {
258-
sysEngine := system_contract.New(context.Background(), chainConfig.SystemContract, l1Client)
261+
sysEngine := system_contract.New(context.Background(), chainConfig.SystemContract, l1Client, skipSignerCheck)
259262
sysEngine.Start()
260263
return sysEngine
261264
}

les/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ func New(stack *node.Node, config *ethconfig.Config, l1Client sync_service.EthCl
110110
eventMux: stack.EventMux(),
111111
reqDist: newRequestDistributor(peers, &mclock.System{}),
112112
accountManager: stack.AccountManager(),
113-
engine: ethconfig.CreateConsensusEngine(stack, chainConfig, &config.Ethash, nil, false, chainDb, l1Client),
113+
engine: ethconfig.CreateConsensusEngine(stack, chainConfig, &config.Ethash, nil, false, chainDb, l1Client, config.SkipSignerCheck),
114114
bloomRequests: make(chan chan *bloombits.Retrieval),
115115
bloomIndexer: core.NewBloomIndexer(chainDb, params.BloomBitsBlocksClient, params.HelperTrieConfirmations),
116116
p2pServer: stack.Server(),

miner/scroll_worker_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1411,7 +1411,7 @@ func TestEuclidV2TransitionVerification(t *testing.T) {
14111411
// init worker
14121412
db := rawdb.NewMemoryDatabase()
14131413
cliqueEngine := clique.New(chainConfig.Clique, db)
1414-
sysEngine := system_contract.New(context.Background(), chainConfig.SystemContract, &system_contract.FakeEthClient{Value: testBankAddress})
1414+
sysEngine := system_contract.New(context.Background(), chainConfig.SystemContract, &system_contract.FakeEthClient{Value: testBankAddress}, false)
14151415
engine := wrapper.NewUpgradableEngine(chainConfig.IsEuclidV2, cliqueEngine, sysEngine)
14161416
w, b := newTestWorkerWithEmptyBlock(t, chainConfig, engine, db, 0)
14171417
defer w.close()

0 commit comments

Comments
 (0)