Skip to content

Commit

Permalink
Merge branch 'main' into PRT-replace-cookbook-with-lava-config
Browse files Browse the repository at this point in the history
  • Loading branch information
shleikes committed Dec 2, 2024
2 parents 279d81e + 8b16323 commit c6cd51f
Show file tree
Hide file tree
Showing 19 changed files with 525 additions and 467 deletions.
5 changes: 3 additions & 2 deletions ecosystem/lavavisor/pkg/state/lavavisor_state_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ type LavaVisorStateTracker struct {

func NewLavaVisorStateTracker(ctx context.Context, txFactory tx.Factory, clientCtx client.Context, chainFetcher chaintracker.ChainFetcher) (lvst *LavaVisorStateTracker, err error) {
// validate chainId
status, err := clientCtx.Client.Status(ctx)
stateQuery := updaters.NewStateQuery(ctx, updaters.NewStateQueryAccessInst(clientCtx))
status, err := stateQuery.Status(ctx)
if err != nil {
return nil, utils.LavaFormatError("[Lavavisor] failed getting status", err)
}
Expand All @@ -36,7 +37,7 @@ func NewLavaVisorStateTracker(ctx context.Context, txFactory tx.Factory, clientC
if err != nil {
utils.LavaFormatFatal("chain is missing Lava spec, cant initialize lavavisor", err)
}
lst := &LavaVisorStateTracker{stateQuery: updaters.NewStateQuery(ctx, clientCtx), averageBlockTime: time.Duration(specResponse.Spec.AverageBlockTime) * time.Millisecond}
lst := &LavaVisorStateTracker{stateQuery: stateQuery, averageBlockTime: time.Duration(specResponse.Spec.AverageBlockTime) * time.Millisecond}
return lst, nil
}

Expand Down
4 changes: 2 additions & 2 deletions protocol/badgegenerator/tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ func NewBadgeStateTracker(ctx context.Context, clientCtx cosmosclient.Context, c
emergencyTracker, blockNotFoundCallback := statetracker.NewEmergencyTracker(nil)
txFactory := tx.Factory{}
txFactory = txFactory.WithChainID(chainId)
stateTrackerBase, err := statetracker.NewStateTracker(ctx, txFactory, clientCtx, chainFetcher, blockNotFoundCallback)
sq := updaters.NewStateQuery(ctx, updaters.NewStateQueryAccessInst(clientCtx))
stateTrackerBase, err := statetracker.NewStateTracker(ctx, txFactory, sq, chainFetcher, blockNotFoundCallback)
if err != nil {
return nil, err
}
sq := updaters.NewStateQuery(ctx, clientCtx)
esq := updaters.NewEpochStateQuery(sq)

pst := &BadgeStateTracker{StateTracker: stateTrackerBase, stateQuery: esq, ConsumerEmergencyTrackerInf: emergencyTracker}
Expand Down
6 changes: 3 additions & 3 deletions protocol/badgeserver/tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ func NewBadgeStateTracker(ctx context.Context, clientCtx cosmosclient.Context, c
emergencyTracker, blockNotFoundCallback := statetracker.NewEmergencyTracker(nil)
txFactory := tx.Factory{}
txFactory = txFactory.WithChainID(chainId)
stateTrackerBase, err := statetracker.NewStateTracker(ctx, txFactory, clientCtx, chainFetcher, blockNotFoundCallback)
stateQuery := updaters.NewStateQuery(ctx, updaters.NewStateQueryAccessInst(clientCtx))
stateTrackerBase, err := statetracker.NewStateTracker(ctx, txFactory, stateQuery, chainFetcher, blockNotFoundCallback)
if err != nil {
return nil, err
}
stateTracker := updaters.NewStateQuery(ctx, clientCtx)
epochStateTracker := updaters.NewEpochStateQuery(stateTracker)
epochStateTracker := updaters.NewEpochStateQuery(stateQuery)

badgeStateTracker := &BadgeStateTracker{
StateTracker: stateTrackerBase,
Expand Down
18 changes: 15 additions & 3 deletions protocol/chainlib/base_chain_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -429,9 +429,21 @@ func getServiceApis(
}

for _, parsing := range apiCollection.ParseDirectives {
taggedApis[parsing.FunctionTag] = TaggedContainer{
Parsing: parsing,
ApiCollection: apiCollection,
// We do this because some specs may have multiple parse directives
// with the same tag - SUBSCRIBE (like in Solana).
//
// Since the function tag is not used for handling the subscription flow,
// we can ignore the extra parse directives and take only the first one. The
// subscription flow is handled by the consumer websocket manager and the chain router
// that uses the api collection to fetch the correct parse directive.
//
// The only place the SUBSCRIBE tag is checked against the taggedApis map is in the chain parser with GetParsingByTag.
// But there, we're not interested in the parse directive, only if the tag is present.
if _, ok := taggedApis[parsing.FunctionTag]; !ok {
taggedApis[parsing.FunctionTag] = TaggedContainer{
Parsing: parsing,
ApiCollection: apiCollection,
}
}
}

Expand Down
23 changes: 23 additions & 0 deletions protocol/rpcconsumer/custom_transport.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package rpcconsumer

import (
"net/http"
)

type CustomLavaTransport struct {
transport http.RoundTripper
}

func NewCustomLavaTransport(httpTransport http.RoundTripper) *CustomLavaTransport {
return &CustomLavaTransport{transport: httpTransport}
}

func (c *CustomLavaTransport) RoundTrip(req *http.Request) (*http.Response, error) {
// Custom logic before the request

// Delegate to the underlying RoundTripper (usually http.Transport)
resp, err := c.transport.RoundTrip(req)

// Custom logic after the request
return resp, err
}
Loading

0 comments on commit c6cd51f

Please sign in to comment.