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

Commit

Permalink
chore(all): update error checks (#271)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidtaikocha committed Jun 7, 2023
1 parent 6c06b6e commit e738ece
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 3 deletions.
5 changes: 5 additions & 0 deletions cmd/flags/proposer.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ var (
Value: 1,
Category: proposerCategory,
}
ProposeBlockTxGasLimit = &cli.Uint64Flag{
Name: "proposeBlockTxGasLimit",
Category: proposerCategory,
}
)

// All proposer flags.
Expand All @@ -68,4 +72,5 @@ var ProposerFlags = MergeFlags(CommonFlags, []cli.Flag{
ProposeEmptyBlocksInterval,
MinBlockGasLimit,
MaxProposedTxListsPerEpoch,
ProposeBlockTxGasLimit,
})
2 changes: 1 addition & 1 deletion pkg/chain_iterator/block_batch_iterator.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ func (i *BlockBatchIterator) end() {
// event.Raw.Removed, which will also call `i.rewindOnReorgDetected` to rewind back
func (i *BlockBatchIterator) ensureCurrentNotReorged() error {
current, err := i.client.HeaderByHash(i.ctx, i.current.Hash())
if err != nil && !errors.Is(err, ethereum.NotFound) {
if err != nil && !(err.Error() == ethereum.NotFound.Error()) {
return err
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/rpc/methods.go
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ func (c *Client) CheckL1Reorg(ctx context.Context, blockID *big.Int) (bool, *typ
if err != nil {
// If the L2 EE is just synced through P2P, there is a chance that the EE do not have
// the chain head L1Origin information recorded.
if errors.Is(err, ethereum.NotFound) {
if err.Error() == ethereum.NotFound.Error() {
log.Info("L1Origin not found", "blockID", blockID)
return false, nil, nil, nil
}
Expand All @@ -367,7 +367,7 @@ func (c *Client) CheckL1Reorg(ctx context.Context, blockID *big.Int) (bool, *typ

l1Header, err := c.L1.HeaderByNumber(ctx, l1Origin.L1BlockHeight)
if err != nil {
if errors.Is(err, ethereum.NotFound) {
if err.Error() == ethereum.NotFound.Error() {
continue
}
return false, nil, nil, fmt.Errorf("failed to fetch L1 header (%d): %w", l1Origin.L1BlockHeight, err)
Expand Down
8 changes: 8 additions & 0 deletions proposer/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ type Config struct {
ProposeEmptyBlocksInterval *time.Duration
MinBlockGasLimit uint64
MaxProposedTxListsPerEpoch uint64
ProposeBlockTxGasLimit *uint64
}

// NewConfigFromCliContext initializes a Config instance from
Expand Down Expand Up @@ -72,6 +73,12 @@ func NewConfigFromCliContext(c *cli.Context) (*Config, error) {
}
}

var proposeBlockTxGasLimit *uint64
if c.IsSet(flags.ProposeBlockTxGasLimit.Name) {
gasLimit := c.Uint64(flags.ProposeBlockTxGasLimit.Name)
proposeBlockTxGasLimit = &gasLimit
}

return &Config{
L1Endpoint: c.String(flags.L1WSEndpoint.Name),
L2Endpoint: c.String(flags.L2HTTPEndpoint.Name),
Expand All @@ -85,5 +92,6 @@ func NewConfigFromCliContext(c *cli.Context) (*Config, error) {
ProposeEmptyBlocksInterval: proposeEmptyBlocksInterval,
MinBlockGasLimit: c.Uint64(flags.MinBlockGasLimit.Name),
MaxProposedTxListsPerEpoch: c.Uint64(flags.MaxProposedTxListsPerEpoch.Name),
ProposeBlockTxGasLimit: proposeBlockTxGasLimit,
}, nil
}
5 changes: 5 additions & 0 deletions proposer/proposer.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ type Proposer struct {
locals []common.Address
minBlockGasLimit *uint64
maxProposedTxListsPerEpoch uint64
proposeBlockTxGasLimit *uint64

// Protocol configurations
protocolConfigs *bindings.TaikoDataConfig
Expand Down Expand Up @@ -77,6 +78,7 @@ func InitFromConfig(ctx context.Context, p *Proposer, cfg *Config) (err error) {
p.l2SuggestedFeeRecipient = cfg.L2SuggestedFeeRecipient
p.proposingInterval = cfg.ProposeInterval
p.proposeEmptyBlocksInterval = cfg.ProposeEmptyBlocksInterval
p.proposeBlockTxGasLimit = cfg.ProposeBlockTxGasLimit
p.wg = sync.WaitGroup{}
p.locals = cfg.LocalAddresses
p.commitSlot = cfg.CommitSlot
Expand Down Expand Up @@ -292,6 +294,9 @@ func (p *Proposer) ProposeTxList(
if nonce != nil {
opts.Nonce = new(big.Int).SetUint64(*nonce)
}
if p.proposeBlockTxGasLimit != nil {
opts.GasLimit = *p.proposeBlockTxGasLimit
}

proposeTx, err := p.rpc.TaikoL1.ProposeBlock(opts, inputs, txListBytes)
if err != nil {
Expand Down
13 changes: 13 additions & 0 deletions prover/prover.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"sync"
"time"

"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/event"
Expand Down Expand Up @@ -502,8 +503,20 @@ func (p *Prover) initL1Current(startingBlockID *big.Int) error {
startingBlockID = new(big.Int).SetUint64(stateVars.LastVerifiedBlockId)
}

log.Info("Init L1Current cursor", "startingBlockID", startingBlockID)

latestVerifiedHeaderL1Origin, err := p.rpc.L2.L1OriginByID(p.ctx, startingBlockID)
if err != nil {
if err.Error() == ethereum.NotFound.Error() {
log.Warn("Failed to find L1Origin for blockID: %d, use latest L1 head instead", startingBlockID)
l1Head, err := p.rpc.L1.BlockNumber(p.ctx)
if err != nil {
return err
}

p.l1Current = l1Head
return nil
}
return err
}

Expand Down

0 comments on commit e738ece

Please sign in to comment.