Skip to content

Commit

Permalink
shorten verifier interval to 6s (#37)
Browse files Browse the repository at this point in the history
* shorten verifier interval to 6s

* verifier: Parameterized oneDayBlock

* increment version
  • Loading branch information
tak1827 authored Aug 26, 2024
1 parent 8ec869a commit c4b1ca3
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 35 deletions.
19 changes: 10 additions & 9 deletions cmd/config_loader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -332,15 +332,16 @@ func (s *ConfigLoaderTestSuite) configWithMinCliArgs() *config.Config {
Sockname: defaults["ipc.sockname"].(string),
},
Verifier: config.Verifier{
Enable: false,
Wallet: "",
Interval: defaults["verifier.interval"].(time.Duration),
StateCollectLimit: defaults["verifier.state_collect_limit"].(int),
StateCollectTimeout: defaults["verifier.state_collect_timeout"].(time.Duration),
Confirmations: defaults["verifier.confirmations"].(int),
StartBlockOffset: defaults["verifier.start_block_offset"].(uint64),
MaxRetryBackoff: defaults["verifier.max_retry_backoff"].(time.Duration),
RetryTimeout: defaults["verifier.retry_timeout"].(time.Duration),
Enable: false,
Wallet: "",
Interval: defaults["verifier.interval"].(time.Duration),
StateCollectLimit: defaults["verifier.state_collect_limit"].(int),
StateCollectTimeout: defaults["verifier.state_collect_timeout"].(time.Duration),
Confirmations: defaults["verifier.confirmations"].(int),
StartBlockOffset: defaults["verifier.start_block_offset"].(uint64),
MaxLogFetchBlockRange: defaults["verifier.max_log_fetch_block_range"].(uint64),
MaxRetryBackoff: defaults["verifier.max_retry_backoff"].(time.Duration),
RetryTimeout: defaults["verifier.retry_timeout"].(time.Duration),
},
Submitter: config.Submitter{
Enable: false,
Expand Down
18 changes: 11 additions & 7 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,14 @@ func Defaults() map[string]interface{} {

"ipc.sockname": "oasvlfy",

"verifier.interval": 15 * time.Second,
"verifier.state_collect_limit": 1000,
"verifier.state_collect_timeout": 15 * time.Second,
"verifier.confirmations": 3, // 3 confirmations are enough for later than v1.3.0 L1.
"verifier.start_block_offset": uint64(5760 * 2), // 2 days
"verifier.max_retry_backoff": time.Hour,
"verifier.retry_timeout": time.Hour * 24,
"verifier.interval": 6 * time.Second,
"verifier.state_collect_limit": 1000,
"verifier.state_collect_timeout": 15 * time.Second,
"verifier.confirmations": 3, // 3 confirmations are enough for later than v1.3.0 L1.
"verifier.start_block_offset": uint64(14400 * 2), // 2 days in case of 6s block time
"verifier.max_log_fetch_block_range": uint64(14400), // 1 day in case of 6s block time
"verifier.max_retry_backoff": time.Hour,
"verifier.retry_timeout": time.Hour * 24,

// The minimum interval for Verse v0 is 15 seconds.
// On the other hand, the minimum interval for Verse v1 is 80 seconds.
Expand Down Expand Up @@ -389,6 +390,9 @@ type Verifier struct {
// This offset is used at the first time to fetch events.
StartBlockOffset uint64 `koanf:"start_block_offset"`

// The max block range to fetch events.
MaxLogFetchBlockRange uint64 `koanf:"max_log_fetch_block_range"`

// The maximum exponential backoff time for retries.
MaxRetryBackoff time.Duration `koanf:"max_retry_backoff"`

Expand Down
22 changes: 12 additions & 10 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ func (s *ConfigTestSuite) TestNewConfig() {
state_collect_timeout: 1s
confirmations: 4
start_block_offset: 5760
max_log_fetch_block_range: 5760
max_retry_backoff: 1m
retry_timeout: 2m
Expand Down Expand Up @@ -231,15 +232,16 @@ func (s *ConfigTestSuite) TestNewConfig() {
},
IPC: IPC{Sockname: "testsock"},
Verifier: Verifier{
Enable: true,
Wallet: "wallet1",
Interval: 5 * time.Second,
StateCollectLimit: 5,
StateCollectTimeout: time.Second,
Confirmations: 4,
StartBlockOffset: 5760,
MaxRetryBackoff: time.Minute,
RetryTimeout: time.Minute * 2,
Enable: true,
Wallet: "wallet1",
Interval: 5 * time.Second,
StateCollectLimit: 5,
StateCollectTimeout: time.Second,
Confirmations: 4,
StartBlockOffset: 5760,
MaxLogFetchBlockRange: 5760,
MaxRetryBackoff: time.Minute,
RetryTimeout: time.Minute * 2,
},
Submitter: Submitter{
Enable: true,
Expand Down Expand Up @@ -403,7 +405,7 @@ func (s *ConfigTestSuite) TestDefaultValues() {

s.Equal("oasvlfy", got.IPC.Sockname)

s.Equal(15*time.Second, got.Verifier.Interval)
s.Equal(6*time.Second, got.Verifier.Interval)
s.Equal(1000, got.Verifier.StateCollectLimit)
s.Equal(15*time.Second, got.Verifier.StateCollectTimeout)
s.Equal(3, got.Verifier.Confirmations)
Expand Down
6 changes: 3 additions & 3 deletions verifier/verifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ func (w *Verifier) work(parent context.Context, task verse.VerifiableVerse, chai
var (
start uint64
skipFetchlog bool
oneDayBlocks = uint64(5760)
maxRange = w.cfg.MaxLogFetchBlockRange
)
end, err := w.l1Signer.BlockNumber(ctx)
if err != nil {
Expand All @@ -163,9 +163,9 @@ func (w *Verifier) work(parent context.Context, task verse.VerifiableVerse, chai
start = end - offset
}
}
if start < end && oneDayBlocks < end-start {
if start < end && maxRange < end-start {
// If the range is too wide, divide it into one-day blocks.
end = start + oneDayBlocks
end = start + maxRange
}
log = log.New("start", start, "end", end)

Expand Down
11 changes: 6 additions & 5 deletions verifier/verifier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,12 @@ func (s *VerifierTestSuite) SetupTest() {

s.sigsCh = make(chan []*database.OptimismSignature, 4)
s.verifier = NewVerifier(&config.Verifier{
Interval: 50 * time.Millisecond,
StateCollectLimit: 3,
StateCollectTimeout: time.Second,
Confirmations: 2,
StartBlockOffset: 100,
Interval: 50 * time.Millisecond,
StateCollectLimit: 3,
StateCollectTimeout: time.Second,
Confirmations: 2,
StartBlockOffset: 100,
MaxLogFetchBlockRange: 5760,
}, s.DB, &MockP2P{sigsCh: s.sigsCh}, s.SignableHub)

s.task = verse.NewOPLegacy(s.DB, s.Hub, s.SCCAddr).WithVerifiable(s.Verse)
Expand Down
2 changes: 1 addition & 1 deletion version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import "fmt"
const (
Major = 1
Minor = 2
Patch = 2
Patch = 3
Meta = ""
)

Expand Down

0 comments on commit c4b1ca3

Please sign in to comment.