Skip to content

Commit

Permalink
Merge pull request #1888 from lavanet/PRT-fix-arbitrum
Browse files Browse the repository at this point in the history
fix: PRT - Fix Arbitrum with arbtrace addon
  • Loading branch information
Yaroms authored Jan 6, 2025
2 parents b351306 + 9dcf985 commit fb57508
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 19 deletions.
6 changes: 3 additions & 3 deletions protocol/common/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import sdkerrors "cosmossdk.io/errors"

var (
ContextDeadlineExceededError = sdkerrors.New("ContextDeadlineExceeded Error", 300, "context deadline exceeded")
StatusCodeError504 = sdkerrors.New("Disallowed StatusCode Error", 504, "Disallowed status code error")
StatusCodeError429 = sdkerrors.New("Disallowed StatusCode Error", 429, "Disallowed status code error")
StatusCodeErrorStrict = sdkerrors.New("Disallowed StatusCode Error", 800, "Disallowed status code error")
StatusCodeError504 = sdkerrors.New("Disallowed StatusCode Error", 504, "Disallowed status code error (504)")
StatusCodeError429 = sdkerrors.New("Disallowed StatusCode Error", 429, "Disallowed status code error (429)")
StatusCodeErrorStrict = sdkerrors.New("Disallowed StatusCode Error", 800, "Disallowed status code error (800)")
APINotSupportedError = sdkerrors.New("APINotSupported Error", 900, "api not supported")
SubscriptionNotFoundError = sdkerrors.New("SubscriptionNotFoundError Error", 901, "subscription not found")
ProviderFinalizationDataAccountabilityError = sdkerrors.New("ProviderFinalizationDataAccountability Error", 3365, "provider returned invalid finalization data, with accountability")
Expand Down
23 changes: 18 additions & 5 deletions protocol/parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,13 +317,26 @@ func (p *ParsedInput) GetBlockHashes() ([]string, error) {
}

func getMapForParse(rpcInput RPCInput) map[string]interface{} {
var result map[string]interface{}
rpcInputResult := rpcInput.GetResult()
if rpcInputResult != nil {
json.Unmarshal(rpcInputResult, &result)
result := parseRawResult(rpcInput.GetResult())
return map[string]interface{}{
"params": rpcInput.GetParams(),
"result": result,
"error": rpcInput.GetError().ToMap(),
}
}

func parseRawResult(rawResult json.RawMessage) interface{} {
if rawResult == nil {
return nil
}

var result interface{}
if err := json.Unmarshal(rawResult, &result); err != nil {
utils.LavaFormatError("failed to unmarshal result", err, utils.LogAttr("result", rawResult))
return nil
}

return map[string]interface{}{"params": rpcInput.GetParams(), "result": result, "error": rpcInput.GetError().ToMap()}
return result
}

func ParseWithGenericParsers(rpcInput RPCInput, genericParsers []spectypes.GenericParser) (*ParsedInput, error) {
Expand Down
22 changes: 22 additions & 0 deletions protocol/parser/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -757,6 +757,28 @@ func TestParseBlockFromReply(t *testing.T) {
expected: 123,
expectedError: "expected 321, received 123",
},
{
name: "generic_parser_parse_from_array_result",
rpcInput: &RPCInputTest{
Result: []byte(`
[
{
"foo": {
"bar": 123
}
}
]
`),
},
genericParsers: []spectypes.GenericParser{
{
ParsePath: ".result.[0].foo.bar",
Value: "123",
ParseType: spectypes.PARSER_TYPE_RESULT,
},
},
expected: 123,
},
}

for _, test := range tests {
Expand Down
2 changes: 1 addition & 1 deletion scripts/init_chain_commands.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ lavad tx subscription buy DefaultPlan $(lavad keys show user1 -a) --enable-auto-
# lavad tx project set-policy $(lavad keys show user1 -a)-admin ./cookbook/projects/policy_all_chains_with_extension.yml -y --from user1 --gas-adjustment "1.5" --gas "auto" --gas-prices $GASPRICE

# MANTLE
CHAINS="ETH1,SEP1,HOL1,OSMOSIS,FTM250,CELO,LAV1,OSMOSIST,ALFAJORES,ARB1,ARBN,APT1,STRK,JUN1,COSMOSHUB,POLYGON1,EVMOS,OPTM,BASES,CANTO,SUIT,SOLANA,BSC,AXELAR,AVAX,FVM,NEAR,SQDSUBGRAPH,AGR,AGRT,KOIIT,AVAXT,CELESTIATM"
CHAINS="ETH1,SEP1,HOL1,OSMOSIS,FTM250,CELO,LAV1,OSMOSIST,ALFAJORES,ARBITRUM,ARBN,APT1,STRK,JUN1,COSMOSHUB,POLYGON1,EVMOS,OPTM,BASES,CANTO,SUIT,SOLANA,BSC,AXELAR,AVAX,FVM,NEAR,SQDSUBGRAPH,AGR,AGRT,KOIIT,AVAXT,CELESTIATM"
BASE_CHAINS="ETH1,LAV1"
# stake providers on all chains
echo; echo "#### Staking provider 1 ####"
Expand Down
21 changes: 11 additions & 10 deletions specs/mainnet-1/specs/arbitrum.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
"api_interface": "jsonrpc",
"internal_path": "",
"type": "POST",
"add_on": "trace"
"add_on": "arbtrace"
},
"apis": [
{
Expand Down Expand Up @@ -200,21 +200,22 @@
"stateful": 0
},
"extra_compute_units": 0
}
}
],
"verifications": [
{
"name": "enabled",
"parse_directive": {
"function_template": "{\"jsonrpc\":\"2.0\",\"method\":\"arbtrace_block\",\"params\":[\"latest\"],\"id\":1}",
"function_template": "{\"jsonrpc\":\"2.0\",\"method\":\"arbtrace_block\",\"params\":[\"0x152DD46\"],\"id\":1}",
"function_tag": "VERIFICATION",
"result_parsing": {
"parser_arg": [
"0"
],
"parser_func": "PARSE_BY_ARG",
"encoding": "hex"
},
"result_parsing": {},
"parsers": [
{
"parse_path": ".result.[0].blockHash",
"value": "*",
"parse_type": "RESULT"
}
],
"api_name": "arbtrace_block"
},
"values": [
Expand Down

0 comments on commit fb57508

Please sign in to comment.