Skip to content

Commit

Permalink
Merge branch 'main' into update-solana-spec
Browse files Browse the repository at this point in the history
  • Loading branch information
Yaroms authored Dec 1, 2024
2 parents ac6ae9a + fcfbef4 commit 37b69c9
Show file tree
Hide file tree
Showing 18 changed files with 371 additions and 249 deletions.
32 changes: 30 additions & 2 deletions cookbook/specs/near.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@
"rule": "=final || =optimistic",
"parse_type": "DEFAULT_VALUE"
},
{
"parse_path": ".params.block_id",
"parse_type": "BLOCK_HASH"
},
{
"parse_path": ".params.[0]",
"parse_type": "BLOCK_HASH"
Expand Down Expand Up @@ -141,6 +145,10 @@
},
"extra_compute_units": 0,
"parsers": [
{
"parse_path": ".params.chunk_id",
"parse_type": "BLOCK_HASH"
},
{
"parse_path": ".params.[0]",
"parse_type": "BLOCK_HASH"
Expand Down Expand Up @@ -339,7 +347,17 @@
"hanging_api": true
},
"extra_compute_units": 0,
"timeout_ms": 10000
"timeout_ms": 10000,
"parsers": [
{
"parse_path": ".params.tx_hash",
"parse_type": "BLOCK_HASH"
},
{
"parse_path": ".params.[0]",
"parse_type": "BLOCK_HASH"
}
]
},
{
"name": "EXPERIMENTAL_tx_status",
Expand All @@ -357,7 +375,17 @@
"subscription": false,
"stateful": 0
},
"extra_compute_units": 0
"extra_compute_units": 0,
"parsers": [
{
"parse_path": ".params.tx_hash",
"parse_type": "BLOCK_HASH"
},
{
"parse_path": ".params.[0]",
"parse_type": "BLOCK_HASH"
}
]
},
{
"name": "EXPERIMENTAL_receipt",
Expand Down
27 changes: 19 additions & 8 deletions cookbook/specs/starknet.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
"data_reliability_enabled": true,
"block_distance_for_finalized_data": 6,
"blocks_in_finalization_proof": 3,
"average_block_time": 12000,
"average_block_time": 30000,
"allowed_block_lag_for_qos_sync": 2,
"shares": 1,
"min_stake_provider": {
"denom": "ulava",
"amount": "47500000000"
"amount": "5000000000"
},
"api_collections": [
{
Expand All @@ -36,7 +36,7 @@
],
"parser_func": "DEFAULT"
},
"compute_units": 10,
"compute_units": 20,
"enabled": true,
"category": {
"deterministic": true,
Expand Down Expand Up @@ -93,7 +93,7 @@
],
"parser_func": "DEFAULT"
},
"compute_units": 10,
"compute_units": 20,
"enabled": true,
"category": {
"deterministic": true,
Expand Down Expand Up @@ -156,7 +156,7 @@
"parser_func": "PARSE_DICTIONARY_OR_ORDERED",
"default_value": "latest"
},
"compute_units": 10,
"compute_units": 20,
"enabled": true,
"category": {
"deterministic": true,
Expand Down Expand Up @@ -445,7 +445,7 @@
],
"parser_func": "DEFAULT"
},
"compute_units": 10,
"compute_units": 20,
"enabled": true,
"category": {
"deterministic": false,
Expand Down Expand Up @@ -598,6 +598,17 @@
"expected_value": "*"
}
]
},
{
"name": "pruning",
"parse_directive": {
"function_tag": "GET_BLOCK_BY_NUM"
},
"values": [
{
"expected_value": "1"
}
]
}
]
},
Expand Down Expand Up @@ -969,11 +980,11 @@
"data_reliability_enabled": true,
"block_distance_for_finalized_data": 1,
"blocks_in_finalization_proof": 3,
"average_block_time": 1800000,
"average_block_time": 32000,
"allowed_block_lag_for_qos_sync": 1,
"min_stake_provider": {
"denom": "ulava",
"amount": "47500000000"
"amount": "5000000000"
},
"api_collections": [
{
Expand Down
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
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
}
2 changes: 1 addition & 1 deletion protocol/rpcconsumer/relay_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ func (rs *RelayState) SetProtocolMessage(protocolMessage chainlib.ProtocolMessag
}

func (rs *RelayState) upgradeToArchiveIfNeeded(numberOfRetriesLaunched int, numberOfNodeErrors uint64) {
if rs == nil || rs.archiveStatus == nil || numberOfNodeErrors == 0 {
if rs == nil || rs.archiveStatus == nil {
return
}
hashes := rs.GetProtocolMessage().GetRequestedBlocksHashes()
Expand Down
Loading

0 comments on commit 37b69c9

Please sign in to comment.