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

Commit

Permalink
Merge branch 'main' into handle_reorg
Browse files Browse the repository at this point in the history
  • Loading branch information
RogerLamTd authored May 16, 2023
2 parents dc0ebb6 + ab8305d commit 94072ca
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 22 deletions.
6 changes: 6 additions & 0 deletions cmd/flags/proposer.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ var (
Usage: "Time interval to propose empty blocks",
Category: proposerCategory,
}
MinBlockGasLimit = &cli.Uint64Flag{
Name: "minimalBlockGasLimit",
Usage: "Minimal block gasLimit when proposing a block",
Category: proposerCategory,
}
)

// All proposer flags.
Expand All @@ -56,4 +61,5 @@ var ProposerFlags = MergeFlags(CommonFlags, []cli.Flag{
CommitSlot,
TxPoolLocals,
ProposeEmptyBlocksInterval,
MinBlockGasLimit,
})
2 changes: 2 additions & 0 deletions proposer/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ type Config struct {
CommitSlot uint64
LocalAddresses []common.Address
ProposeEmptyBlocksInterval *time.Duration
MinBlockGasLimit uint64
}

// NewConfigFromCliContext initializes a Config instance from
Expand Down Expand Up @@ -81,5 +82,6 @@ func NewConfigFromCliContext(c *cli.Context) (*Config, error) {
CommitSlot: c.Uint64(flags.CommitSlot.Name),
LocalAddresses: localAddresses,
ProposeEmptyBlocksInterval: proposeEmptyBlocksInterval,
MinBlockGasLimit: c.Uint64(flags.MinBlockGasLimit.Name),
}, nil
}
16 changes: 16 additions & 0 deletions proposer/proposer.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ type Proposer struct {
proposingTimer *time.Timer
commitSlot uint64
locals []common.Address
minBlockGasLimit *uint64

// Protocol configurations
protocolConfigs *bindings.TaikoDataConfig
Expand Down Expand Up @@ -96,6 +97,17 @@ func InitFromConfig(ctx context.Context, p *Proposer, cfg *Config) (err error) {
}
p.protocolConfigs = &protocolConfigs

if cfg.MinBlockGasLimit != 0 {
if cfg.MinBlockGasLimit > p.protocolConfigs.BlockMaxGasLimit.Uint64() {
return fmt.Errorf(
"minimal block gas limit too large, set: %d, limit: %d",
cfg.MinBlockGasLimit,
p.protocolConfigs.BlockMaxGasLimit,
)
}
p.minBlockGasLimit = &cfg.MinBlockGasLimit
}

log.Info("Protocol configs", "configs", p.protocolConfigs)

return nil
Expand Down Expand Up @@ -229,6 +241,10 @@ func (p *Proposer) ProposeTxList(
txListBytes []byte,
txNum uint,
) error {
if p.minBlockGasLimit != nil && meta.GasLimit < uint32(*p.minBlockGasLimit) {
meta.GasLimit = uint32(*p.minBlockGasLimit)
}

// Propose the transactions list
inputs, err := encoding.EncodeProposeBlockInput(meta)
if err != nil {
Expand Down
27 changes: 7 additions & 20 deletions prover/proof_producer/special_proof_producer.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func (p *SpecialProofProducer) RequestProof(
resultCh chan *ProofWithHeader,
) error {
log.Info(
"Request oracle proof",
"Request special proof",
"blockID", blockID,
"beneficiary", meta.Beneficiary,
"height", header.Number,
Expand Down Expand Up @@ -140,27 +140,14 @@ func (p *SpecialProofProducer) RequestProof(
return fmt.Errorf("failed to sign evidence: %w", err)
}

var (
delay time.Duration = 0
now = time.Now()
blockTime = time.Unix(int64(block.Time()), 0)
)
if !p.isSystemProver && now.Before(blockTime.Add(p.proofTimeTarget)) {
delay = blockTime.Add(p.proofTimeTarget).Sub(now)
resultCh <- &ProofWithHeader{
BlockID: blockID,
Header: header,
Meta: meta,
ZkProof: proof,
Opts: opts,
}

log.Info("Proof submission delay", "delay", delay, "isSystemProver", p.isSystemProver)

time.AfterFunc(delay, func() {
resultCh <- &ProofWithHeader{
BlockID: blockID,
Header: header,
Meta: meta,
ZkProof: proof,
Opts: opts,
}
})

return nil
}

Expand Down
2 changes: 1 addition & 1 deletion prover/prover.go
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ func (p *Prover) onBlockVerified(ctx context.Context, event *bindings.TaikoL1Cli
// and the proof is not the oracle proof address.
func (p *Prover) onBlockProven(ctx context.Context, event *bindings.TaikoL1ClientBlockProven) error {
metrics.ProverReceivedProvenBlockGauge.Update(event.Id.Int64())
// if oracle prover, dont cancel proof.
// if this proof is submitted by an oracle prover or a system prover, dont cancel proof.
if event.Prover == p.oracleProverAddress ||
event.Prover == p.systemProverAddress ||
event.Prover == common.HexToAddress("0x0000000000000000000000000000000000000000") ||
Expand Down
2 changes: 1 addition & 1 deletion version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package version

// Version info.
var (
Version = "0.8.0"
Version = "0.9.0"
Meta = "dev"
)

Expand Down

0 comments on commit 94072ca

Please sign in to comment.