Skip to content

Commit

Permalink
Merge pull request hyperledger-labs#115 from siburu/lc-refresh
Browse files Browse the repository at this point in the history
LC refresh
  • Loading branch information
siburu authored Oct 26, 2023
2 parents 4e913ba + a95ff90 commit 2cd2b03
Show file tree
Hide file tree
Showing 15 changed files with 561 additions and 172 deletions.
23 changes: 19 additions & 4 deletions chains/tendermint/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"errors"
"fmt"
"strings"
"time"

"github.com/hyperledger-labs/yui-relayer/core"
)
Expand Down Expand Up @@ -62,11 +63,25 @@ func (c ProverConfig) Build(chain core.Chain) (core.Prover, error) {
}

func (c ProverConfig) Validate() error {
isEmpty := func(s string) bool {
return strings.TrimSpace(s) == ""
if _, err := time.ParseDuration(c.TrustingPeriod); err != nil {
return fmt.Errorf("config attribute \"trusting_period\" is invalid: %v", err)
}
if c.RefreshThresholdRate.Denominator == 0 {
return fmt.Errorf("config attribute \"refresh_threshold_rate.denominator\" must not be zero")
}
if c.RefreshThresholdRate.Numerator == 0 {
return fmt.Errorf("config attribute \"refresh_threshold_rate.numerator\" must not be zero")
}
if isEmpty(c.TrustingPeriod) {
return fmt.Errorf("config attribute \"trusting_period\" is empty")
if c.RefreshThresholdRate.Numerator > c.RefreshThresholdRate.Denominator {
return fmt.Errorf("config attribute \"refresh_threshold_rate\" must be less than or equal to 1.0: actual=%v/%v", c.RefreshThresholdRate.Numerator, c.RefreshThresholdRate.Denominator)
}
return nil
}

func (c ProverConfig) GetTrustingPeriod() time.Duration {
if d, err := time.ParseDuration(c.TrustingPeriod); err != nil {
panic(err)
} else {
return d
}
}
289 changes: 261 additions & 28 deletions chains/tendermint/config.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 2cd2b03

Please sign in to comment.