Skip to content
This repository has been archived by the owner on May 11, 2024. It is now read-only.

Commit

Permalink
feat(all): clean up unused signal service related code (#581)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidtaikocha authored Feb 28, 2024
1 parent 87cce6f commit 13f896a
Show file tree
Hide file tree
Showing 18 changed files with 31 additions and 127 deletions.
21 changes: 7 additions & 14 deletions driver/anchor_tx_constructor/anchor_tx_constructor.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,13 @@ const AnchorGasLimit = 250_000
// AnchorTxConstructor is responsible for assembling the anchor transaction (TaikoL2.anchor) in
// each L2 block, which is always the first transaction.
type AnchorTxConstructor struct {
rpc *rpc.Client
goldenTouchAddress common.Address
signalServiceAddress common.Address
signer *signer.FixedKSigner
rpc *rpc.Client
goldenTouchAddress common.Address
signer *signer.FixedKSigner
}

// New creates a new AnchorConstructor instance.
func New(rpc *rpc.Client, signalServiceAddress common.Address) (*AnchorTxConstructor, error) {
func New(rpc *rpc.Client) (*AnchorTxConstructor, error) {
goldenTouchAddress, err := rpc.TaikoL2.GOLDENTOUCHADDRESS(nil)
if err != nil {
return nil, err
Expand All @@ -41,10 +40,9 @@ func New(rpc *rpc.Client, signalServiceAddress common.Address) (*AnchorTxConstru
}

return &AnchorTxConstructor{
rpc: rpc,
goldenTouchAddress: goldenTouchAddress,
signalServiceAddress: signalServiceAddress,
signer: signer,
rpc: rpc,
goldenTouchAddress: goldenTouchAddress,
signer: signer,
}, nil
}

Expand Down Expand Up @@ -144,8 +142,3 @@ func (c *AnchorTxConstructor) signTxPayload(hash []byte) ([]byte, error) {

return sig[:], nil
}

// SignalServiceAddress returns protocol's L1 singalService constant address.
func (c *AnchorTxConstructor) SignalServiceAddress() common.Address {
return c.signalServiceAddress
}
11 changes: 2 additions & 9 deletions driver/anchor_tx_constructor/anchor_tx_constructor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package anchortxconstructor
import (
"context"
"math/big"
"os"
"testing"

"github.com/ethereum/go-ethereum/common"
Expand All @@ -23,10 +22,7 @@ type AnchorTxConstructorTestSuite struct {

func (s *AnchorTxConstructorTestSuite) SetupTest() {
s.ClientTestSuite.SetupTest()
c, err := New(
s.RPCClient,
common.HexToAddress(os.Getenv("L1_SIGNAL_SERVICE_CONTRACT_ADDRESS")),
)
c, err := New(s.RPCClient)
s.Nil(err)
head, err := s.RPCClient.L1.BlockByNumber(context.Background(), nil)
s.Nil(err)
Expand All @@ -49,10 +45,7 @@ func (s *AnchorTxConstructorTestSuite) TestNewAnchorTransactor() {
goldenTouchAddress, err := s.RPCClient.TaikoL2.GOLDENTOUCHADDRESS(nil)
s.Nil(err)

c, err := New(
s.RPCClient,
common.HexToAddress(os.Getenv("L1_SIGNAL_SERVICE_CONTRACT_ADDRESS")),
)
c, err := New(s.RPCClient)
s.Nil(err)

opts, err := c.transactOpts(context.Background(), common.Big1, common.Big256)
Expand Down
4 changes: 1 addition & 3 deletions driver/chain_syncer/calldata/syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,13 @@ func NewSyncer(
rpc *rpc.Client,
state *state.State,
progressTracker *beaconsync.SyncProgressTracker,
signalServiceAddress common.Address,
) (*Syncer, error) {
configs, err := rpc.TaikoL1.GetConfig(&bind.CallOpts{Context: ctx})
if err != nil {
return nil, fmt.Errorf("failed to get protocol configs: %w", err)
}

constructor, err := anchorTxConstructor.New(rpc, signalServiceAddress)
constructor, err := anchorTxConstructor.New(rpc)
if err != nil {
return nil, fmt.Errorf("failed to initialize anchor constructor: %w", err)
}
Expand Down Expand Up @@ -169,7 +168,6 @@ func (s *Syncer) onBlockProposed(
reorged, l1CurrentToReset, lastInsertedBlockIDToReset, err = s.rpc.CheckL1ReorgFromL2EE(
ctx,
new(big.Int).Sub(event.BlockId, common.Big1),
s.anchorConstructor.SignalServiceAddress(),
)
if err != nil {
return fmt.Errorf("failed to check whether L1 chain has been reorged: %w", err)
Expand Down
2 changes: 0 additions & 2 deletions driver/chain_syncer/calldata/syncer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ func (s *CalldataSyncerTestSuite) SetupTest() {
s.RPCClient,
state,
beaconsync.NewSyncProgressTracker(s.RPCClient.L2, 1*time.Hour),
common.HexToAddress(os.Getenv("L1_SIGNAL_SERVICE_CONTRACT_ADDRESS")),
)
s.Nil(err)
s.s = syncer
Expand Down Expand Up @@ -82,7 +81,6 @@ func (s *CalldataSyncerTestSuite) TestCancelNewSyncer() {
s.RPCClient,
s.s.state,
s.s.progressTracker,
common.HexToAddress(os.Getenv("L1_SIGNAL_SERVICE_CONTRACT_ADDRESS")),
)
s.Nil(syncer)
s.NotNil(err)
Expand Down
4 changes: 1 addition & 3 deletions driver/chain_syncer/chain_syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"time"

"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/log"

Expand Down Expand Up @@ -42,13 +41,12 @@ func New(
state *state.State,
p2pSyncVerifiedBlocks bool,
p2pSyncTimeout time.Duration,
signalServiceAddress common.Address,
) (*L2ChainSyncer, error) {
tracker := beaconsync.NewSyncProgressTracker(rpc.L2, p2pSyncTimeout)
go tracker.Track(ctx)

beaconSyncer := beaconsync.NewSyncer(ctx, rpc, state, tracker)
calldataSyncer, err := calldata.NewSyncer(ctx, rpc, state, tracker, signalServiceAddress)
calldataSyncer, err := calldata.NewSyncer(ctx, rpc, state, tracker)
if err != nil {
return nil, err
}
Expand Down
1 change: 0 additions & 1 deletion driver/chain_syncer/chain_syncer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ func (s *ChainSyncerTestSuite) SetupTest() {
state,
false,
1*time.Hour,
common.HexToAddress(os.Getenv("L1_SIGNAL_SERVICE_CONTRACT_ADDRESS")),
)
s.Nil(err)
s.s = syncer
Expand Down
10 changes: 0 additions & 10 deletions driver/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,22 +76,12 @@ func (d *Driver) InitFromConfig(ctx context.Context, cfg *Config) (err error) {
log.Warn("P2P syncing verified blocks enabled, but no connected peer found in L2 execution engine")
}

signalServiceAddress, err := d.rpc.TaikoL1.Resolve0(
&bind.CallOpts{Context: ctx},
rpc.StringToBytes32("signal_service"),
false,
)
if err != nil {
return err
}

if d.l2ChainSyncer, err = chainSyncer.New(
d.ctx,
d.rpc,
d.state,
cfg.P2PSyncVerifiedBlocks,
cfg.P2PSyncTimeout,
signalServiceAddress,
); err != nil {
return err
}
Expand Down
3 changes: 0 additions & 3 deletions driver/driver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ func (s *DriverTestSuite) TestCheckL1ReorgToHigherFork() {
reorged, _, _, err := s.RPCClient.CheckL1ReorgFromL2EE(
context.Background(),
l2Head2.Number,
common.HexToAddress(os.Getenv("L1_SIGNAL_SERVICE_CONTRACT_ADDRESS")),
)
s.Nil(err)
s.False(reorged)
Expand Down Expand Up @@ -216,7 +215,6 @@ func (s *DriverTestSuite) TestCheckL1ReorgToLowerFork() {
reorged, _, _, err := s.RPCClient.CheckL1ReorgFromL2EE(
context.Background(),
l2Head2.Number,
common.HexToAddress(os.Getenv("L1_SIGNAL_SERVICE_CONTRACT_ADDRESS")),
)
s.Nil(err)
s.False(reorged)
Expand Down Expand Up @@ -275,7 +273,6 @@ func (s *DriverTestSuite) TestCheckL1ReorgToSameHeightFork() {
reorged, _, _, err := s.RPCClient.CheckL1ReorgFromL2EE(
context.Background(),
l2Head2.Number,
common.HexToAddress(os.Getenv("L1_SIGNAL_SERVICE_CONTRACT_ADDRESS")),
)
s.Nil(err)
s.False(reorged)
Expand Down
1 change: 0 additions & 1 deletion integration_test/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ check_env "ASSIGNMENT_HOOK_ADDRESS"
check_env "TIMELOCK_CONTROLLER"
check_env "ROLLUP_ADDRESS_MANAGER_CONTRACT_ADDRESS"
check_env "GUARDIAN_PROVER_CONTRACT_ADDRESS"
check_env "L1_SIGNAL_SERVICE_CONTRACT_ADDRESS"
check_env "L1_CONTRACT_OWNER_PRIVATE_KEY"
check_env "L1_SECURITY_COUNCIL_PRIVATE_KEY"
check_env "L1_PROPOSER_PRIVATE_KEY"
Expand Down
2 changes: 0 additions & 2 deletions integration_test/test_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export ASSIGNMENT_HOOK_ADDRESS=$(echo "$DEPLOYMENT_JSON" | jq '.assignment_hook'
export TIMELOCK_CONTROLLER=$(echo "$DEPLOYMENT_JSON" | jq '.timelock_controller' | sed 's/\"//g')
export ROLLUP_ADDRESS_MANAGER_CONTRACT_ADDRESS=$(echo "$DEPLOYMENT_JSON" | jq '.rollup_address_manager' | sed 's/\"//g')
export GUARDIAN_PROVER_CONTRACT_ADDRESS=$(echo "$DEPLOYMENT_JSON" | jq '.guardian_prover' | sed 's/\"//g')
export L1_SIGNAL_SERVICE_CONTRACT_ADDRESS=$(echo "$DEPLOYMENT_JSON" | jq '.signal_service' | sed 's/\"//g')
export L1_CONTRACT_OWNER_PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
export L1_SECURITY_COUNCIL_PRIVATE_KEY=0xdbda1821b80551c9d65939329250298aa3472ba22feea921c0cf5d620ea67b97
export L1_PROPOSER_PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
Expand All @@ -41,7 +40,6 @@ ASSIGNMENT_HOOK_ADDRESS=$ASSIGNMENT_HOOK_ADDRESS
TIMELOCK_CONTROLLER=$TIMELOCK_CONTROLLER
ROLLUP_ADDRESS_MANAGER_CONTRACT_ADDRESS=$ROLLUP_ADDRESS_MANAGER_CONTRACT_ADDRESS
GUARDIAN_PROVER_CONTRACT_ADDRESS=$GUARDIAN_PROVER_CONTRACT_ADDRESS
L1_SIGNAL_SERVICE_CONTRACT_ADDRESS=$L1_SIGNAL_SERVICE_CONTRACT_ADDRESS
L1_CONTRACT_OWNER_PRIVATE_KEY=$L1_CONTRACT_OWNER_PRIVATE_KEY
L1_SECURITY_COUNCIL_PRIVATE_KEY=$L1_SECURITY_COUNCIL_PRIVATE_KEY
L1_PROPOSER_PRIVATE_KEY=$L1_PROPOSER_PRIVATE_KEY
Expand Down
9 changes: 2 additions & 7 deletions pkg/rpc/methods.go
Original file line number Diff line number Diff line change
Expand Up @@ -388,11 +388,7 @@ func (c *Client) GetProtocolStateVariables(opts *bind.CallOpts) (*struct {

// CheckL1ReorgFromL2EE checks whether the L1 chain has been reorged from the L1Origin records in L2 EE,
// if so, returns the l1Current cursor and L2 blockID that need to reset to.
func (c *Client) CheckL1ReorgFromL2EE(
ctx context.Context,
blockID *big.Int,
l1SignalService common.Address,
) (bool, *types.Header, *big.Int, error) {
func (c *Client) CheckL1ReorgFromL2EE(ctx context.Context, blockID *big.Int) (bool, *types.Header, *big.Int, error) {
var (
reorged bool
l1CurrentToReset *types.Header
Expand Down Expand Up @@ -474,7 +470,7 @@ func (c *Client) CheckL1ReorgFromL2EE(
}

isSyncedL1SnippetInvalid, err := c.checkSyncedL1SnippetFromAnchor(
ctx, blockID, l1Origin.L1BlockHeight.Uint64(), l1SignalService,
ctx, blockID, l1Origin.L1BlockHeight.Uint64(),
)
if err != nil {
return false, nil, nil, fmt.Errorf("failed to check L1 reorg from anchor transaction: %w", err)
Expand Down Expand Up @@ -508,7 +504,6 @@ func (c *Client) checkSyncedL1SnippetFromAnchor(
ctx context.Context,
blockID *big.Int,
l1Height uint64,
l1SignalService common.Address,
) (bool, error) {
log.Info("Check synced L1 snippet from anchor", "blockID", blockID)
block, err := c.L2.BlockByNumber(ctx, blockID)
Expand Down
2 changes: 0 additions & 2 deletions prover/proof_producer/proof_producer.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ type ProofRequestOptions struct {
BlockID *big.Int
ProverAddress common.Address
ProposeBlockTxHash common.Hash
L1SignalService common.Address
L2SignalService common.Address
TaikoL2 common.Address
MetaHash common.Hash
BlockHash common.Hash
Expand Down
4 changes: 0 additions & 4 deletions prover/proof_producer/zkevm_rpcd_producer.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,6 @@ type RequestMetaData struct {

// ProtocolInstance represents the JSON body of RequestProofBody.Param's `protocol_instance` field.
type ProtocolInstance struct {
L1SignalService string `json:"l1_signal_service"`
L2SignalService string `json:"l2_signal_service"`
TaikoL2 string `json:"l2_contract"`
MetaHash string `json:"meta_hash"`
BlockHash string `json:"block_hash"`
Expand Down Expand Up @@ -274,8 +272,6 @@ func (p *ZkevmRpcdProducer) requestProof(
ProtocolInstance: &ProtocolInstance{
Prover: opts.ProverAddress.Hex()[2:],
Treasury: opts.TaikoL2.Hex()[2:],
L1SignalService: opts.L1SignalService.Hex()[2:],
L2SignalService: opts.L2SignalService.Hex()[2:],
TaikoL2: opts.TaikoL2.Hex()[2:],
MetaHash: opts.MetaHash.Hex()[2:],
BlockHash: opts.BlockHash.Hex()[2:],
Expand Down
23 changes: 6 additions & 17 deletions prover/proof_submitter/proof_contester.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,10 @@ var _ Contester = (*ProofContester)(nil)

// ProofContester is responsible for contesting wrong L2 transitions.
type ProofContester struct {
rpc *rpc.Client
txBuilder *transaction.ProveBlockTxBuilder
txSender *transaction.Sender
l2SignalService common.Address
graffiti [32]byte
rpc *rpc.Client
txBuilder *transaction.ProveBlockTxBuilder
txSender *transaction.Sender
graffiti [32]byte
}

// NewProofContester creates a new ProofContester instance.
Expand All @@ -42,15 +41,6 @@ func NewProofContester(
waitReceiptTimeout time.Duration,
graffiti string,
) (*ProofContester, error) {
l2SignalService, err := rpcClient.TaikoL2.Resolve0(
nil,
rpc.StringToBytes32("signal_service"),
false,
)
if err != nil {
return nil, err
}

var txGasLimit *big.Int
if proveBlockTxGasLimit != nil {
txGasLimit = new(big.Int).SetUint64(*proveBlockTxGasLimit)
Expand All @@ -65,9 +55,8 @@ func NewProofContester(
proveBlockMaxTxGasTipCap,
new(big.Int).SetUint64(txReplacementTipMultiplier),
),
txSender: transaction.NewSender(rpcClient, retryInterval, &submissionMaxRetry, waitReceiptTimeout),
l2SignalService: l2SignalService,
graffiti: rpc.StringToBytes32(graffiti),
txSender: transaction.NewSender(rpcClient, retryInterval, &submissionMaxRetry, waitReceiptTimeout),
graffiti: rpc.StringToBytes32(graffiti),
}, nil
}

Expand Down
28 changes: 4 additions & 24 deletions prover/proof_submitter/proof_submitter.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ type ProofSubmitter struct {
txSender *transaction.Sender
proverAddress common.Address
taikoL2Address common.Address
l1SignalService common.Address
l2SignalService common.Address
graffiti [32]byte
}

Expand All @@ -60,20 +58,6 @@ func New(
return nil, err
}

l1SignalService, err := rpcClient.TaikoL1.Resolve0(nil, rpc.StringToBytes32("signal_service"), false)
if err != nil {
return nil, err
}

l2SignalService, err := rpcClient.TaikoL2.Resolve0(
nil,
rpc.StringToBytes32("signal_service"),
false,
)
if err != nil {
return nil, err
}

var (
maxRetry = &submissionMaxRetry
txGasLimit *big.Int
Expand All @@ -97,12 +81,10 @@ func New(
proveBlockMaxTxGasTipCap,
new(big.Int).SetUint64(txReplacementTipMultiplier),
),
txSender: transaction.NewSender(rpcClient, retryInterval, maxRetry, waitReceiptTimeout),
proverAddress: crypto.PubkeyToAddress(proverPrivKey.PublicKey),
l1SignalService: l1SignalService,
l2SignalService: l2SignalService,
taikoL2Address: taikoL2Address,
graffiti: rpc.StringToBytes32(graffiti),
txSender: transaction.NewSender(rpcClient, retryInterval, maxRetry, waitReceiptTimeout),
proverAddress: crypto.PubkeyToAddress(proverPrivKey.PublicKey),
taikoL2Address: taikoL2Address,
graffiti: rpc.StringToBytes32(graffiti),
}, nil
}

Expand Down Expand Up @@ -143,8 +125,6 @@ func (s *ProofSubmitter) RequestProof(ctx context.Context, event *bindings.Taiko
BlockID: block.Number(),
ProverAddress: s.proverAddress,
ProposeBlockTxHash: event.Raw.TxHash,
L1SignalService: s.l1SignalService,
L2SignalService: s.l2SignalService,
TaikoL2: s.taikoL2Address,
MetaHash: blockInfo.Blk.MetaHash,
BlockHash: block.Hash(),
Expand Down
1 change: 0 additions & 1 deletion prover/proof_submitter/proof_submitter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ func (s *ProofSubmitterTestSuite) SetupTest() {
s.RPCClient,
testState,
tracker,
common.HexToAddress(os.Getenv("L1_SIGNAL_SERVICE_CONTRACT_ADDRESS")),
)
s.Nil(err)

Expand Down
Loading

0 comments on commit 13f896a

Please sign in to comment.