diff --git a/consensus/system_contract/consensus.go b/consensus/system_contract/consensus.go index 756e9250fdd2..40a8ccf9bdba 100644 --- a/consensus/system_contract/consensus.go +++ b/consensus/system_contract/consensus.go @@ -284,7 +284,15 @@ func (s *SystemContract) Seal(chain consensus.ChainHeaderReader, block *types.Bl s.lock.RUnlock() // Bail out if we're unauthorized to sign a block - // todo + expectedSigner, err := s.findSignerSlice(number) + if err != nil { + // e.g., "no signer for block" + return fmt.Errorf("cannot seal block %d: %w", number, err) + } + + if signer != expectedSigner { + return errors.New("local node is not authorized to sign this block") + } // Sweet, the protocol permits us to sign the block, wait for our time delay := time.Unix(int64(header.Time), 0).Sub(time.Now()) // nolint: gosimple diff --git a/consensus/system_contract/system_contract.go b/consensus/system_contract/system_contract.go index 18064f8ff4b2..3b6bad3a9d07 100644 --- a/consensus/system_contract/system_contract.go +++ b/consensus/system_contract/system_contract.go @@ -5,7 +5,6 @@ import ( "fmt" "github.com/scroll-tech/go-ethereum" "github.com/scroll-tech/go-ethereum/accounts/abi" - "github.com/scroll-tech/go-ethereum/ethclient" "math/big" "strings" "sync" @@ -96,7 +95,7 @@ func (s *SystemContract) fetchAllSigners(blockNum *big.Int) ([]SignerAddressL1, } // Perform the call via the ethclient interface (need to cast) - output, err := s.client.(*ethclient.Client).CallContract(s.ctx, msg, blockNum) + output, err := s.client.CallContract(s.ctx, msg, blockNum) if err != nil { return nil, fmt.Errorf("CallContract error: %w", err) } diff --git a/rollup/sync_service/types.go b/rollup/sync_service/types.go index 08b4dda2ecf0..f3a0149568b6 100644 --- a/rollup/sync_service/types.go +++ b/rollup/sync_service/types.go @@ -20,4 +20,5 @@ type EthClient interface { TransactionByHash(ctx context.Context, txHash common.Hash) (tx *types.Transaction, isPending bool, err error) BlockByHash(ctx context.Context, hash common.Hash) (*types.Block, error) StorageAt(ctx context.Context, account common.Address, key common.Hash, blockNumber *big.Int) ([]byte, error) + CallContract(ctx context.Context, msg ethereum.CallMsg, blockNumber *big.Int) ([]byte, error) }