Skip to content

Commit

Permalink
Fix offline spec bug (#1823)
Browse files Browse the repository at this point in the history
  • Loading branch information
shleikes authored Dec 3, 2024
1 parent e9cfc7d commit 34d7c4e
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions protocol/statetracker/state_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,20 +49,20 @@ type SpecUpdaterInf interface {
}

// Either register for spec updates or set spec for offline spec, used in both consumer and provider process
func RegisterForSpecUpdatesOrSetStaticSpec(ctx context.Context, chainParser chainlib.ChainParser, specPath string, rpcEndpoint lavasession.RPCEndpoint, specUpdaterInf SpecUpdaterInf) (err error) {
if specPath != "" {
// offline spec mode.
parsedOfflineSpec, loadError := specutils.GetSpecsFromPath(specPath, rpcEndpoint.ChainID, nil, nil)
if loadError != nil {
err = utils.LavaFormatError("failed loading offline spec", err, utils.LogAttr("spec_path", specPath), utils.LogAttr("spec_id", rpcEndpoint.ChainID))
}
utils.LavaFormatInfo("Loaded offline spec successfully", utils.LogAttr("spec_path", specPath), utils.LogAttr("chain_id", parsedOfflineSpec.Index))
chainParser.SetSpec(parsedOfflineSpec)
} else {
// register for spec updates
err = specUpdaterInf.RegisterForSpecUpdates(ctx, chainParser, rpcEndpoint)
func RegisterForSpecUpdatesOrSetStaticSpec(ctx context.Context, chainParser chainlib.ChainParser, specPath string, rpcEndpoint lavasession.RPCEndpoint, specUpdaterInf SpecUpdaterInf) error {
if specPath == "" {
return specUpdaterInf.RegisterForSpecUpdates(ctx, chainParser, rpcEndpoint)
}
return

// offline spec mode.
parsedOfflineSpec, err := specutils.GetSpecsFromPath(specPath, rpcEndpoint.ChainID, nil, nil)
if err != nil {
return utils.LavaFormatError("failed loading offline spec", err, utils.LogAttr("spec_path", specPath), utils.LogAttr("spec_id", rpcEndpoint.ChainID))
}
utils.LavaFormatInfo("Loaded offline spec successfully", utils.LogAttr("spec_path", specPath), utils.LogAttr("chain_id", parsedOfflineSpec.Index))
chainParser.SetSpec(parsedOfflineSpec)

return nil
}

func GetLavaSpecWithRetry(ctx context.Context, specQueryClient spectypes.QueryClient) (*spectypes.QueryGetSpecResponse, error) {
Expand Down

0 comments on commit 34d7c4e

Please sign in to comment.