Add new Warning and Error fields to JSON RPC results

The Solana developer ecosystem has evolved to the point where most dApps no longer directly calling JSON RPC endpoints directly. Instead these calls are often obfuscated behind frameworks or protocol-specific libraries that abstract away the raw calls.

In an ideal world these frameworks and libraries would monitor and manage deprecated RPC calls and update current and previous versions to propagate deprecated and removed methods up to the dApp developer. This would provide a clear signal that the dApp developer should update their library versions to remove deprecated calls.

However, we all know this isn’t the case. There’s no guarantee that libraries or frameworks will be updated, that developers will pull in the latest patch version, or that libraries will even be maintained. Instead I would like to propose that the endpoint returns on Solana RPCs be updated to include Warning and Error fields to indicate a common interface for signaling deprecation or removed endpoints. This would still require current libraries and frameworks to update to process these fields, but going forward it would provide a simple schema for these to propagate deprecations upwards in the stack. This method would also operate more dynamically with runtime-level checks. Frameworks would be able to detect deprecation and removal as soon as the RPC updates, rather than requiring the framework to be updated with the correct deprecation notices.

As an example:

> curl https://api.mainnet-beta.solana.com -X POST -H "Content-Type: application/json" -d '
  { "jsonrpc":"2.0", "id": 1, "method":"getFees"}
' | jq
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   313  100   262  100    51    626    121 --:--:-- --:--:-- --:--:--   747
{
  "jsonrpc": "2.0",
  "result": {
    "context": {
      "apiVersion": "1.18.18",
      "slot": 320162120
    },
    "value": {
      "blockhash": "5xuwdC9NJ5ur8DLXFXVHESnUb74SuwgxQP9wgv9XrJDK",
      "feeCalculator": {
        "lamportsPerSignature": 5000
      },
      "lastValidBlockHeight": 308386678,
      "lastValidSlot": 320162420
    }
  },
  "id": 1
}

A call to the getFees endpoint provides no versioning or notice that the call has been deprecated and will soon be removed.

curl https://api.devnet.solana.com -X POST -H "Content-Type: application/json" -d '                                              
  { "jsonrpc":"2.0", "id": 1, "method":"getFees"}
' | jq
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   129  100    78  100    51    271    177 --:--:-- --:--:-- --:--:--   449
{
  "jsonrpc": "2.0",
  "error": {
    "code": -32601,
    "message": "Method not found"
  },
  "id": 1
}

And as of 2.0 the method is completely gone.

Under this proposal, the above call would look as follows with the new Warning/Error fields:
With deprecation

> curl https://api.mainnet-beta.solana.com -X POST -H "Content-Type: application/json" -d '
  { "jsonrpc":"2.0", "id": 1, "method":"getFees"}
' | jq
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   313  100   262  100    51    626    121 --:--:-- --:--:-- --:--:--   747
{
  "jsonrpc": "2.0",
  "result": {
+ "warning": {
+    "message": "Deprecated as of 1.9. Removal scheduled for 2.0.",
+    "replacement": "getFeeForMessage"
+   },
    "context": {
      "apiVersion": "1.18.18",
      "slot": 320162120
    },
    "value": {
      "blockhash": "5xuwdC9NJ5ur8DLXFXVHESnUb74SuwgxQP9wgv9XrJDK",
      "feeCalculator": {
        "lamportsPerSignature": 5000
      },
      "lastValidBlockHeight": 308386678,
      "lastValidSlot": 320162420
    }
  },
  "id": 1
}

After removal

curl https://api.devnet.solana.com -X POST -H "Content-Type: application/json" -d '                                              
  { "jsonrpc":"2.0", "id": 1, "method":"getFees"}
' | jq
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   129  100    78  100    51    271    177 --:--:-- --:--:-- --:--:--   449
{
  "jsonrpc": "2.0",
  "error": {
    "code": -32601,
-   "message": "Method not found",
+   "message": "Method **getFees** not found",
+   "replacement": "getFeesForMessage"
  },
  "id": 1
}

Frameworks and libraries could then detect these new fields and propagate the associated warning/error upwards to developers and point them to the latest compatible version.