Skip to content

Commit

Permalink
refactor: CNS-999 - Pairing cache (#1576)
Browse files Browse the repository at this point in the history
* CNS-994: use utils to encode/decode epoch

* CNS-994: stake storage refactor not final

* CNS-994: fix some of the unit tests

* CNS-994: finish refactor

* CNS-994: fix serialization to be big endian (avoid common 0 prefix of little endian)

* CNS-994: fix unit test

* CNS-994: fix e2e

* CNS-998: install collections

* CNS-998: rename collections.go to collcompat (for standard)

* CNS-998: make stake entries use collections

* CNS-994: migrator

* CNS-994: fix migrator

* CNS-994: updated readme

* CNS-994: the pairing mechanism assumes that the retrived entries are with decending order of stake

* CNS-998: iterate over providers in reverse

* CNS-994: fix unit test

* CNS-998: fix unit test

* CNS-999: pairing cache implementation

* CNS-999: small change

* CNS-999: remove test code

* CNS-999: rename

* CNS-999: relay pairing cache implementaion + unit tests

* CNS-994: revert Serialize to little endian and created SerializeBigEndian

* CNS-994: remove outdated migrators

* CNS-994: complete migrator removal

* CNS-994: delete outdated test file

* CNS-994: sort stake storage in GetAllStakeEntriesForGenesis

* CNS-994: reverted removal of stakeEntries map in unresponsive provider code

* CNS-994: test scripts 100 providers

* CNS-994: migrator fix order stake entries for pairing

* CNS-994: another migrator fix

* refactor: CNS-998 - use collections instead of KV stores (#1570)

* CNS-998: install collections

* CNS-998: rename collections.go to collcompat (for standard)

* CNS-998: make stake entries use collections

* CNS-998: iterate over providers in reverse

* CNS-998: fix unit test

* CNS-998: make stakeEntries hold extra unique index of epoch, chainid and address

* CNS-998: add chain id and vault indices for stake entries current

* CNS-998: small changes

* CNS-998: added comment

* CNS-998: other part of merge

* CNS-998: make epoch hashes a collections map

* CNS-998: add error handling for epoch hash remove

* CNS-998: migrator fix

* Update scripts/test/inich_100_providers.sh

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* CNS-994: fix lint and small issues

* CNS-994: fix lint

* CNS-999: fix unit tests

* Update scripts/test/inich_100_providers.sh

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Update x/epochstorage/keeper/stake_entries.go

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* CNS-994: enhance error messages in stake entries methods

* CNS-999: rabbitAi changes

* CNS-999: lint

* CNS-999: fix protocgen

* CNS-999: fix lint

* CNS-999: lint fix

* CNS-999: make relay pairing cache use a KV store

* CNS-999: lint fix

* CNS-999: change relay cache key and save allowed_cu in cache

* Update x/pairing/keeper/pairing.go

* Update x/pairing/keeper/pairing_cache.go

* Update pairing_cache.go

* CNS-999: added unit test

* CNS-999: lint fixes

* CNS-999: more lint fixes

* CNS-999: lint fixes

* CNS-999: lint

* CNS-999: lint

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: Omer <[email protected]>
  • Loading branch information
3 people authored Aug 14, 2024
1 parent 7a1efd8 commit afa45b7
Show file tree
Hide file tree
Showing 31 changed files with 633 additions and 173 deletions.
6 changes: 6 additions & 0 deletions proto/lavanet/lava/pairing/relay.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ option go_package = "github.com/lavanet/lava/v2/x/pairing/types";
import "gogoproto/gogo.proto";
import "google/protobuf/wrappers.proto";
import "google/protobuf/timestamp.proto";
import "lavanet/lava/epochstorage/stake_entry.proto";

service Relayer {
rpc Relay (RelayRequest) returns (RelayReply) {}
Expand Down Expand Up @@ -110,3 +111,8 @@ message QualityOfServiceReport{
(gogoproto.nullable) = false
];
}

message PairingRelayCache {
repeated lavanet.lava.epochstorage.StakeEntry entries = 1 [(gogoproto.nullable) = false];
uint64 allowed_cu = 2;
}
2 changes: 1 addition & 1 deletion protocol/chainlib/chain_fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func (cf *ChainFetcher) Verify(ctx context.Context, verification VerificationCon

collectionType := verification.ConnectionType
path := parsing.ApiName
data := []byte(fmt.Sprintf(parsing.FunctionTemplate))
data := []byte(parsing.FunctionTemplate)

if !verification.IsActive() {
utils.LavaFormatDebug("skipping disabled verification", []utils.Attribute{
Expand Down
2 changes: 1 addition & 1 deletion protocol/chainlib/chain_message.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func (bcnc *baseChainMessageContainer) GetParseDirective() *spectypes.ParseDirec
}

func (pm *baseChainMessageContainer) GetRawRequestHash() ([]byte, error) {
if pm.inputHashCache != nil && len(pm.inputHashCache) > 0 {
if len(pm.inputHashCache) > 0 {
// Get the cached value
return pm.inputHashCache, nil
}
Expand Down
4 changes: 2 additions & 2 deletions protocol/chainlib/chainproxy/rpcclient/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ func DialHTTP(endpoint string) (*Client, error) {
func (c *Client) sendHTTP(ctx context.Context, op *requestOp, msg interface{}, isJsonRPC bool, strict bool) error {
hc, ok := c.writeConn.(*httpConn)
if !ok {
return fmt.Errorf("sendHTTP - c.writeConn.(*httpConn) - type assertion failed" + fmt.Sprintf("%s", c.writeConn))
return fmt.Errorf("sendHTTP - c.writeConn.(*httpConn) - type assertion failed %s", c.writeConn)
}
respBody, err := hc.doRequest(ctx, msg, isJsonRPC, strict)
if err != nil {
Expand All @@ -166,7 +166,7 @@ func (c *Client) sendHTTP(ctx context.Context, op *requestOp, msg interface{}, i
func (c *Client) sendBatchHTTP(ctx context.Context, op *requestOp, msgs []*JsonrpcMessage, strict bool) error {
hc, ok := c.writeConn.(*httpConn)
if !ok {
return fmt.Errorf("sendBatchHTTP - c.writeConn.(*httpConn) - type assertion failed, type:" + fmt.Sprintf("%s", c.writeConn))
return fmt.Errorf("sendBatchHTTP - c.writeConn.(*httpConn) - type assertion failed, type: %s", c.writeConn)
}
respBody, err := hc.doRequest(ctx, msgs, true, strict)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion protocol/chainlib/chainproxy/rpcclient/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ func (c *callback) call(ctx context.Context, method string, args []reflect.Value
var ok bool
errRet, ok := err.(error)
if !ok {
return reflect.Value{}, fmt.Errorf("(c *callback) call - errRet, ok := err.(error) - type assertion failed" + fmt.Sprintf("%s", err))
return reflect.Value{}, fmt.Errorf("(c *callback) call - errRet, ok := err.(error) - type assertion failed %s", err)
}
return reflect.Value{}, errRet
}
Expand Down
4 changes: 2 additions & 2 deletions protocol/chainlib/chainproxy/rpcclient/subscription.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ func (sub *ClientSubscription) forward() (unsubscribeServer bool, err error) {
var ok bool
err, ok = recv.Interface().(error)
if !ok {
return false, fmt.Errorf("(sub *ClientSubscription) forward() - recv.Interface().(error) - type assertion failed" + fmt.Sprintf("%s", recv.Interface()))
return false, fmt.Errorf("(sub *ClientSubscription) forward() - recv.Interface().(error) - type assertion failed %s", recv.Interface())
}
}
if err == errUnsubscribed {
Expand All @@ -352,7 +352,7 @@ func (sub *ClientSubscription) forward() (unsubscribeServer bool, err error) {
case 1: // <-sub.in
msg, ok := recv.Interface().(*JsonrpcMessage)
if !ok {
return false, fmt.Errorf("(sub *ClientSubscription) forward() - recv.Interface().(*JsonrpcMessage) - type assertion failed" + fmt.Sprintf("%s", recv.Interface()))
return false, fmt.Errorf("(sub *ClientSubscription) forward() - recv.Interface().(*JsonrpcMessage) - type assertion failed %s", recv.Interface())
}
if msg.Error != nil {
return true, err
Expand Down
2 changes: 1 addition & 1 deletion protocol/chainlib/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ func (apil *GrpcChainListener) Serve(ctx context.Context, cmdFlags common.Consum
if err != nil {
errMasking := apil.logger.GetUniqueGuidResponseForError(err, msgSeed)
apil.logger.LogRequestAndResponse("grpc in/out", true, method, string(reqBody), "", errMasking, msgSeed, time.Since(startTime), err)
return nil, nil, utils.LavaFormatError("Failed to SendRelay", fmt.Errorf(errMasking))
return nil, nil, utils.LavaFormatError("Failed to SendRelay", fmt.Errorf("%s", errMasking))
}
apil.logger.LogRequestAndResponse("grpc in/out", false, method, string(reqBody), "", "", msgSeed, time.Since(startTime), nil)
apil.logger.AddMetricForProcessingLatencyAfterProvider(metricsData, apil.endpoint.ChainID, apiInterface)
Expand Down
4 changes: 2 additions & 2 deletions protocol/chainlib/node_error_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,11 @@ func (geh *genericErrorHandler) HandleJSONFormatError(replyData []byte) error {
func (geh *genericErrorHandler) ValidateRequestAndResponseIds(nodeMessageID json.RawMessage, replyMsgID json.RawMessage) error {
reqId, idErr := rpcInterfaceMessages.IdFromRawMessage(nodeMessageID)
if idErr != nil {
return fmt.Errorf("Failed parsing ID " + idErr.Error())
return fmt.Errorf("failed parsing ID %s", idErr.Error())
}
respId, idErr := rpcInterfaceMessages.IdFromRawMessage(replyMsgID)
if idErr != nil {
return fmt.Errorf("Failed parsing ID " + idErr.Error())
return fmt.Errorf("failed parsing ID %s", idErr.Error())
}
if reqId != respId {
return fmt.Errorf("ID mismatch error")
Expand Down
2 changes: 1 addition & 1 deletion protocol/chaintracker/wanted_block_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func (wbd *WantedBlocksData) New(fromBlock, toBlock, specificBlock, latestBlock,
toBlockArg := fromBlockArg // [from,to] with only one block
wbd.specificBlock, err = NewBlockRange(fromBlockArg, toBlockArg, earliestBlockSaved, latestBlock)
if err != nil {
return InvalidRequestedSpecificBlock.Wrapf("specific " + err.Error())
return InvalidRequestedSpecificBlock.Wrapf("specific %s", err.Error())
}
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion protocol/rpcconsumer/relay_errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func (r *RelayErrors) mergeAllErrors() error {
mergedMessage += ", "
}
}
return fmt.Errorf(mergedMessage)
return fmt.Errorf("%s", mergedMessage)
}

// TODO: there's no need to save error twice and provider info twice, this can just be a relayResponse
Expand Down
22 changes: 11 additions & 11 deletions protocol/rpcconsumer/relay_errors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func TestRelayError(t *testing.T) {
},
},
{
err: fmt.Errorf(expectedValue),
err: fmt.Errorf("%s", expectedValue),
ProviderInfo: common.ProviderInfo{
ProviderQoSExcellenceSummery: sdk.OneDec(),
ProviderStake: sdk.NewInt64Coin("ulava", 50),
Expand Down Expand Up @@ -106,7 +106,7 @@ func TestRelayError(t *testing.T) {
},
},
{
err: fmt.Errorf(expectedValue),
err: fmt.Errorf("%s", expectedValue),
ProviderInfo: common.ProviderInfo{
ProviderQoSExcellenceSummery: sdk.MustNewDecFromStr("0.8"),
ProviderStake: sdk.NewInt64Coin("ulava", 10),
Expand Down Expand Up @@ -135,21 +135,21 @@ func TestRelayError(t *testing.T) {
},
},
{
err: fmt.Errorf(expectedValue),
err: fmt.Errorf("%s", expectedValue),
ProviderInfo: common.ProviderInfo{
ProviderQoSExcellenceSummery: sdk.ZeroDec(),
ProviderStake: sdk.NewInt64Coin("ulava", 0),
},
},
{
err: fmt.Errorf(expectedValue),
err: fmt.Errorf("%s", expectedValue),
ProviderInfo: common.ProviderInfo{
ProviderQoSExcellenceSummery: sdk.ZeroDec(),
ProviderStake: sdk.NewInt64Coin("ulava", 0),
},
},
{
err: fmt.Errorf(expectedValue),
err: fmt.Errorf("%s", expectedValue),
ProviderInfo: common.ProviderInfo{
ProviderQoSExcellenceSummery: sdk.ZeroDec(),
ProviderStake: sdk.NewInt64Coin("ulava", 0),
Expand All @@ -164,14 +164,14 @@ func TestRelayError(t *testing.T) {
onFailureMergeAll: true,
relayErrors: []RelayError{
{
err: fmt.Errorf(expectedValue),
err: fmt.Errorf("%s", expectedValue),
ProviderInfo: common.ProviderInfo{
ProviderQoSExcellenceSummery: sdk.OneDec(),
ProviderStake: sdk.NewInt64Coin("ulava", 10),
},
},
{
err: fmt.Errorf(expectedValue),
err: fmt.Errorf("%s", expectedValue),
ProviderInfo: common.ProviderInfo{
ProviderQoSExcellenceSummery: sdk.OneDec(),
ProviderStake: sdk.NewInt64Coin("ulava", 20),
Expand All @@ -192,7 +192,7 @@ func TestRelayError(t *testing.T) {
},
},
{
err: fmt.Errorf(expectedValue),
err: fmt.Errorf("%s", expectedValue),
ProviderInfo: common.ProviderInfo{
ProviderQoSExcellenceSummery: sdk.OneDec(),
ProviderStake: sdk.NewInt64Coin("ulava", 10),
Expand All @@ -207,14 +207,14 @@ func TestRelayError(t *testing.T) {
onFailureMergeAll: true,
relayErrors: []RelayError{
{
err: fmt.Errorf(expectedValue),
err: fmt.Errorf("%s", expectedValue),
ProviderInfo: common.ProviderInfo{
ProviderQoSExcellenceSummery: sdk.OneDec(),
ProviderStake: sdk.NewInt64Coin("ulava", 10),
},
},
{
err: fmt.Errorf(expectedValue),
err: fmt.Errorf("%s", expectedValue),
ProviderInfo: common.ProviderInfo{
ProviderQoSExcellenceSummery: sdk.OneDec(),
ProviderStake: sdk.NewInt64Coin("ulava", 20),
Expand All @@ -235,7 +235,7 @@ func TestRelayError(t *testing.T) {
},
},
{
err: fmt.Errorf(expectedValue),
err: fmt.Errorf("%s", expectedValue),
ProviderInfo: common.ProviderInfo{
ProviderQoSExcellenceSummery: sdk.OneDec(),
ProviderStake: sdk.NewInt64Coin("ulava", 10),
Expand Down
2 changes: 1 addition & 1 deletion protocol/rpcconsumer/relay_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ func (rp *RelayProcessor) setValidResponse(response *relayResponse) {
// this is a node error, meaning we still didn't get a good response.
// we may choose to wait until there will be a response or timeout happens
// if we decide to wait and timeout happens we will take the majority of response messages
err := fmt.Errorf(errorMessage)
err := fmt.Errorf("%s", errorMessage)
rp.nodeResponseErrors.relayErrors = append(rp.nodeResponseErrors.relayErrors, RelayError{err: err, ProviderInfo: response.relayResult.ProviderInfo, response: response})
// send relay error metrics only on non stateful queries, as stateful queries always return X-1/X errors.
if rp.selection != BestResult {
Expand Down
2 changes: 1 addition & 1 deletion protocol/rpcprovider/rewardserver/reward_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func stubPaymentEvents(num int, specId string, sessionId uint64) (tos []map[stri
QoS, _ := relay.QosReport.ComputeQoS()
rewardCoins, _ := sdk.ParseCoinNormalized("50ulava")
burnAmount, _ := sdk.ParseCoinNormalized("40ulava")
from := map[string]string{"chainID": fmt.Sprintf(relay.SpecId), "client": clientAddr.String(), "provider": providerAddr.String(), "CU": strconv.FormatUint(relay.CuSum, 10), "BasePay": rewardCoins.String(), "totalCUInEpoch": strconv.FormatUint(700, 10), "uniqueIdentifier": strconv.FormatUint(relay.SessionId, 10), "descriptionString": "banana"}
from := map[string]string{"chainID": relay.SpecId, "client": clientAddr.String(), "provider": providerAddr.String(), "CU": strconv.FormatUint(relay.CuSum, 10), "BasePay": rewardCoins.String(), "totalCUInEpoch": strconv.FormatUint(700, 10), "uniqueIdentifier": strconv.FormatUint(relay.SessionId, 10), "descriptionString": "banana"}
from["QoSReport"] = "Latency: " + relay.QosReport.Latency.String() + ", Availability: " + relay.QosReport.Availability.String() + ", Sync: " + relay.QosReport.Sync.String()
from["QoSLatency"] = relay.QosReport.Latency.String()
from["QoSAvailability"] = relay.QosReport.Availability.String()
Expand Down
2 changes: 1 addition & 1 deletion protocol/rpcprovider/rpcprovider_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ func (rpcps *RPCProviderServer) Relay(ctx context.Context, request *pairingtypes
if err != nil {
extraInfo = err.Error()
}
err = sdkerrors.Wrapf(relayFailureError, "On relay failure: "+extraInfo)
err = sdkerrors.Wrapf(relayFailureError, "On relay failure: %s", extraInfo)
}
err = utils.LavaFormatError("TryRelay Failed", err,
utils.Attribute{Key: "request.SessionId", Value: request.RelaySession.SessionId},
Expand Down
2 changes: 1 addition & 1 deletion protocol/statetracker/tx_sender.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ func (ts *TxSender) parseTxErrorsAndTryGettingANewFactory(txResultString string,
} else if strings.Contains(txResultString, "insufficient fees; got:") { // handle a case where node minimum gas fees is misconfigured
return ts.txFactory, parseInsufficientFeesError(txResultString, gasUsed)
}
return txfactory, fmt.Errorf(txResultString)
return txfactory, fmt.Errorf("%s", txResultString)
}

func (ts *TxSender) simulateTxWithRetry(clientCtx client.Context, txfactory tx.Factory, msg sdk.Msg) (tx.Factory, uint64, error) {
Expand Down
1 change: 1 addition & 0 deletions scripts/protocgen.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash

__dir=$(dirname "$0")
. $__dir/useful_commands.sh

Expand Down
2 changes: 1 addition & 1 deletion scripts/test/inich_100_providers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ sleep_until_next_epoch
HEALTH_FILE="config/health_examples/health_template.yml"
create_health_config $HEALTH_FILE "$(lavad keys show user1 -a)" "$(lavad keys show servicer2 -a)" "$(lavad keys show servicer3 -a)"

lavad tx gov submit-legacy-proposal set-iprpc-data 1000000000ulava --min-cost 100ulava --add-subscriptions $(lavad keys show -a user1) --from alice -y
lavad tx gov submit-legacy-proposal set-iprpc-data 1000000000ulava --min-cost 100ulava --add-subscriptions "$(lavad keys show -a user1)" --from alice -y
wait_count_blocks 1
lavad tx gov vote "$(latest_vote)" yes -y --from alice --gas-adjustment "1.5" --gas "auto" --gas-prices $GASPRICE

Expand Down
1 change: 1 addition & 0 deletions scripts/test/unstake_100_providers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ done

for user in "${users[@]}"; do
lavad tx pairing unstake-provider ETH1 "$(operator_address)" --from $user -y --gas-adjustment "1.5" --gas "auto" --gas-prices "$GASPRICE"
echo "Unstake failed for user: $user" >&2
done
16 changes: 8 additions & 8 deletions testutil/e2e/protocolE2E.go
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ func jsonrpcTests(rpcURL string, testDuration time.Duration) error {
}

if len(errors) > 0 {
return fmt.Errorf(strings.Join(errors, ",\n"))
return fmt.Errorf("%s", strings.Join(errors, ",\n"))
}

return nil
Expand Down Expand Up @@ -611,7 +611,7 @@ func tendermintTests(rpcURL string, testDuration time.Duration) error {
}
}
if len(errors) > 0 {
return fmt.Errorf(strings.Join(errors, ",\n"))
return fmt.Errorf("%s", strings.Join(errors, ",\n"))
}
return nil
}
Expand All @@ -638,7 +638,7 @@ func tendermintURITests(rpcURL string, testDuration time.Duration) error {
}

if len(errors) > 0 {
return fmt.Errorf(strings.Join(errors, ",\n"))
return fmt.Errorf("%s", strings.Join(errors, ",\n"))
}
return nil
}
Expand Down Expand Up @@ -694,7 +694,7 @@ func restTests(rpcURL string, testDuration time.Duration) error {
}

if len(errors) > 0 {
return fmt.Errorf(strings.Join(errors, ",\n"))
return fmt.Errorf("%s", strings.Join(errors, ",\n"))
}
return nil
}
Expand All @@ -711,7 +711,7 @@ func restRelayTest(rpcURL string) error {
}

if len(errors) > 0 {
return fmt.Errorf(strings.Join(errors, ",\n"))
return fmt.Errorf("%s", strings.Join(errors, ",\n"))
}
return nil
}
Expand Down Expand Up @@ -777,7 +777,7 @@ func grpcTests(rpcURL string, testDuration time.Duration) error {
}
}
if len(errors) > 0 {
return fmt.Errorf(strings.Join(errors, ",\n"))
return fmt.Errorf("%s", strings.Join(errors, ",\n"))
}
return nil
}
Expand Down Expand Up @@ -983,7 +983,7 @@ func (lt *lavaTest) checkQoS() error {
utils.LavaFormatInfo("QOS CHECK OK")

if len(errors) > 0 {
return fmt.Errorf(strings.Join(errors, ",\n"))
return fmt.Errorf("%s", strings.Join(errors, ",\n"))
}
return nil
}
Expand Down Expand Up @@ -1191,7 +1191,7 @@ func (lt *lavaTest) checkResponse(tendermintConsumerURL string, restConsumerURL
}

if len(errors) > 0 {
return fmt.Errorf(strings.Join(errors, ",\n"))
return fmt.Errorf("%s", strings.Join(errors, ",\n"))
}
return nil
}
Expand Down
4 changes: 2 additions & 2 deletions testutil/e2e/proxy/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ func createProxyRequest(req *http.Request, hostURL, body string) (proxyRequest *
}
reqUrlStr, err := url.QueryUnescape(reqUrl.String())
if err != nil {
return nil, fmt.Errorf(" ::: XXX ::: Could not QueryUnescape new request ::: " + reqUrl.Host + dotsStr + err.Error())
return nil, fmt.Errorf(" ::: XXX ::: Could not QueryUnescape new request ::: %s%s%s", reqUrl.Host, dotsStr, err.Error())
}
proxyReq, err := http.NewRequest(req.Method, scheme+":"+reqUrlStr, strings.NewReader(body))
if err != nil {
return nil, fmt.Errorf(" ::: XXX ::: Could not reproduce new request ::: " + reqUrl.Host + dotsStr + err.Error())
return nil, fmt.Errorf(" ::: XXX ::: Could not reproduce new request ::: %s%s%s", reqUrl.Host, dotsStr, err.Error())
}
proxyReq.Header.Set("Host", req.Host)
proxyReq.Header.Set("X-Forwarded-For", req.RemoteAddr)
Expand Down
2 changes: 1 addition & 1 deletion utils/lavalog.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ func LavaFormatLog(description string, err error, attributes []Attribute, severi
// here we return the same type of the original error message, this handles nil case as well
errRet := sdkerrors.Wrap(err, output)
if errRet == nil { // we always want to return an error if lavaFormatError was called
return fmt.Errorf(output)
return fmt.Errorf("%s", output)
}
return errRet
}
Expand Down
2 changes: 1 addition & 1 deletion x/epochstorage/keeper/fixated_params.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ func (k Keeper) GetFixatedParamsForBlock(ctx sdk.Context, fixationKey string, bl
utils.Attribute{Key: "earliest", Value: earliestEpochStart},
)
} else {
err = utils.LavaFormatError("block not found", fmt.Errorf("tried to read index: "+thisIdxKey+" but wasn't found"),
err = utils.LavaFormatError("block not found", fmt.Errorf("tried to read index: %s but wasn't found", thisIdxKey),
utils.Attribute{Key: "block", Value: block},
)
}
Expand Down
Loading

0 comments on commit afa45b7

Please sign in to comment.