From 74fe1567d0cc43e2d26d3f4af777794bc6c3a9f5 Mon Sep 17 00:00:00 2001 From: jeff <113397187+cyberhorsey@users.noreply.github.com> Date: Thu, 11 May 2023 18:43:36 -0700 Subject: [PATCH] fix(prover): submit L2 signal service root instead of L1 when submitting proof (#219) --- driver/anchor_tx_constructor/anchor_tx_constructor.go | 2 +- pkg/rpc/methods.go | 10 ++++++++-- prover/proof_producer/special_proof_producer.go | 8 ++++++-- prover/proof_submitter/valid_proof_submitter.go | 4 ++-- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/driver/anchor_tx_constructor/anchor_tx_constructor.go b/driver/anchor_tx_constructor/anchor_tx_constructor.go index cc0732dd2..4bece3f77 100644 --- a/driver/anchor_tx_constructor/anchor_tx_constructor.go +++ b/driver/anchor_tx_constructor/anchor_tx_constructor.go @@ -71,7 +71,7 @@ func (c *AnchorTxConstructor) AssembleAnchorTx( return nil, err } - signalRoot, err := c.rpc.GetStorageRoot(ctx, c.signalServiceAddress, l1Height) + signalRoot, err := c.rpc.GetStorageRoot(ctx, c.rpc.L1GethClient, c.signalServiceAddress, l1Height) if err != nil { return nil, err } diff --git a/pkg/rpc/methods.go b/pkg/rpc/methods.go index b50cb8c1a..0ecfe0dc8 100644 --- a/pkg/rpc/methods.go +++ b/pkg/rpc/methods.go @@ -14,6 +14,7 @@ import ( "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/ethclient/gethclient" "github.com/ethereum/go-ethereum/log" "github.com/taikoxyz/taiko-client/bindings" "golang.org/x/sync/errgroup" @@ -293,8 +294,13 @@ func (c *Client) GetProtocolStateVariables(opts *bind.CallOpts) (*bindings.Taiko } // GetStorageRoot returns a contract's storage root at the given height. -func (c *Client) GetStorageRoot(ctx context.Context, contract common.Address, height *big.Int) (common.Hash, error) { - proof, err := c.L1GethClient.GetProof( +func (c *Client) GetStorageRoot( + ctx context.Context, + gethclient *gethclient.Client, + contract common.Address, + height *big.Int, +) (common.Hash, error) { + proof, err := gethclient.GetProof( ctx, contract, []string{"0x0000000000000000000000000000000000000000000000000000000000000000"}, diff --git a/prover/proof_producer/special_proof_producer.go b/prover/proof_producer/special_proof_producer.go index 09e8403b0..35a92448f 100644 --- a/prover/proof_producer/special_proof_producer.go +++ b/prover/proof_producer/special_proof_producer.go @@ -87,9 +87,13 @@ func (p *SpecialProofProducer) RequestProof( return fmt.Errorf("invalid anchor transaction: %w", err) } - signalRoot, err := p.anchorTxValidator.GetAnchoredSignalRoot(ctx, anchorTx) + signalRoot, err := p.rpc.GetStorageRoot(ctx, p.rpc.L2GethClient, opts.L2SignalService, block.Number()) if err != nil { - return err + return fmt.Errorf("error getting storageroot: %w", err) + } + + if err := p.anchorTxValidator.ValidateAnchorTx(ctx, anchorTx); err != nil { + return fmt.Errorf("invalid anchor transaction: %w", err) } parent, err := p.rpc.L2.BlockByHash(ctx, block.ParentHash()) diff --git a/prover/proof_submitter/valid_proof_submitter.go b/prover/proof_submitter/valid_proof_submitter.go index 456a7f6d0..0c6d76b6c 100644 --- a/prover/proof_submitter/valid_proof_submitter.go +++ b/prover/proof_submitter/valid_proof_submitter.go @@ -117,9 +117,9 @@ func (s *ValidProofSubmitter) RequestProof(ctx context.Context, event *bindings. return errors.New("no transaction in block") } - signalRoot, err := s.anchorTxValidator.GetAnchoredSignalRoot(ctx, block.Transactions()[0]) + signalRoot, err := s.rpc.GetStorageRoot(ctx, s.rpc.L2GethClient, s.l2SignalService, block.Number()) if err != nil { - return err + return fmt.Errorf("error getting storageroot: %w", err) } // Request proof.