Skip to content

Commit d87b55d

Browse files
committed
Check that local signer is valid signer
1 parent c60c1ca commit d87b55d

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

consensus/system_contract/consensus.go

+9-1
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,15 @@ func (s *SystemContract) Seal(chain consensus.ChainHeaderReader, block *types.Bl
284284
s.lock.RUnlock()
285285

286286
// Bail out if we're unauthorized to sign a block
287-
// todo
287+
expectedSigner, err := s.findSignerSlice(number)
288+
if err != nil {
289+
// e.g., "no signer for block"
290+
return fmt.Errorf("cannot seal block %d: %w", number, err)
291+
}
292+
293+
if signer != expectedSigner {
294+
return errors.New("local node is not authorized to sign this block")
295+
}
288296

289297
// Sweet, the protocol permits us to sign the block, wait for our time
290298
delay := time.Unix(int64(header.Time), 0).Sub(time.Now()) // nolint: gosimple

consensus/system_contract/system_contract.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"fmt"
66
"github.com/scroll-tech/go-ethereum"
77
"github.com/scroll-tech/go-ethereum/accounts/abi"
8-
"github.com/scroll-tech/go-ethereum/ethclient"
98
"math/big"
109
"strings"
1110
"sync"
@@ -96,7 +95,7 @@ func (s *SystemContract) fetchAllSigners(blockNum *big.Int) ([]SignerAddressL1,
9695
}
9796

9897
// Perform the call via the ethclient interface (need to cast)
99-
output, err := s.client.(*ethclient.Client).CallContract(s.ctx, msg, blockNum)
98+
output, err := s.client.CallContract(s.ctx, msg, blockNum)
10099
if err != nil {
101100
return nil, fmt.Errorf("CallContract error: %w", err)
102101
}

rollup/sync_service/types.go

+1
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,5 @@ type EthClient interface {
2020
TransactionByHash(ctx context.Context, txHash common.Hash) (tx *types.Transaction, isPending bool, err error)
2121
BlockByHash(ctx context.Context, hash common.Hash) (*types.Block, error)
2222
StorageAt(ctx context.Context, account common.Address, key common.Hash, blockNumber *big.Int) ([]byte, error)
23+
CallContract(ctx context.Context, msg ethereum.CallMsg, blockNumber *big.Int) ([]byte, error)
2324
}

0 commit comments

Comments
 (0)