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

Commit

Permalink
fix(prover): submit L2 signal service root instead of L1 when submitt…
Browse files Browse the repository at this point in the history
…ing proof (#219)
  • Loading branch information
cyberhorsey authored May 12, 2023
1 parent 21d7e78 commit 74fe156
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 7 deletions.
2 changes: 1 addition & 1 deletion driver/anchor_tx_constructor/anchor_tx_constructor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
10 changes: 8 additions & 2 deletions pkg/rpc/methods.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"},
Expand Down
8 changes: 6 additions & 2 deletions prover/proof_producer/special_proof_producer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
4 changes: 2 additions & 2 deletions prover/proof_submitter/valid_proof_submitter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 74fe156

Please sign in to comment.