solana-labs / solana

Web-Scale Blockchain for fast, secure, scalable, decentralized apps and marketplaces.
https://solanalabs.com
Apache License 2.0
13.05k stars 4.21k forks source link

RPC request getProgramAccounts accepts base58 encoding when account data > 129 bytes #18839

Closed Fedor-sa closed 3 years ago

Fedor-sa commented 3 years ago

Problem

Hi, It looks like getProgramAccount method does not consider account data size when using base58. Example: Setup http://api.mainnet-beta.solana.com "feature-set": 4293946943, "solana-core": "1.6.18" Successful case: Request { "method": "getProgramAccounts", "jsonrpc": "2.0", "params": [ "9xQeWvG816bUx9EPjHmaT23yvVM2ZWbrrpZb9PusVFin", { "commitment": "confirmed", "filters": [ { "dataSize": 388 } ], "encoding": "base64" } ], "id": "e54a4d56-f617-4e65-9f6e-5cced4bbd416" } Public key DktgxiwBtA6oPQqzFH9uqMVZF7CQAnk7FnrSdD4VVA9g decoded data length is 388 which is greater than maximum allowed for base58 usage, therefore the same getProgramAccount request with base58 encoding should fail, but Error case Request { "method": "getProgramAccounts", "jsonrpc": "2.0", "params": [ "9xQeWvG816bUx9EPjHmaT23yvVM2ZWbrrpZb9PusVFin", { "commitment": "confirmed", "filters": [ { "dataSize": 388 } ], "encoding": "base58" } ], "id": "e54a4d56-f617-4e65-9f6e-5cced4bbd416" }

Response { "account": { "data": [ "GmH4gu6PYUUKDZqX8Ap8ENgBULRJo6WcHmTvhsXgVp8HbQHTHFxwhaPoZy9vVgRCtUYdAyWVXX2QMxzydAN1FXMo88ddVmYciePtsjPnYcGM8invWoK7MzSgWTUAoJ7mhnZZXYHwtQZsrCLDwAPnvpbDq9tqeGdVT8PgW6ARkwWJZ2vPJ9FECnyTfNMs5HeminKXL2ySZFFfWiQezLDGn9aPzrjkcZ6h5Qn5vBgzXuNYVrHUs6bwo9U165Aqz71puEhhTDmuuZFpFr5fCsPnTH2xLnYD3ZhjwLtBhhBb8eBqQwTX5K3kjVjWvFnNBoYzHdpTXDc35N8vCiB3dGJXSwvoBQtVoAWbt4mCvC4YTdyLfNqbg61PmyuXsqDsJ1TdRR4WFbzqba9YJNLxJ1aqQZHAwCxjiTSwzYr2eq9xBb4aAp8M7Chn5dxh7L8QQQ9PV4pYdXUa3BuQk959DUNidBB7LUyzbFnrp7Bq92mbRWNvfc2sYi1xMYNpa6eTXYyHoSL7Hx1JdfdsTmtXfU", "base58" ], "executable": false, "lamports": 3591360, "owner": "9xQeWvG816bUx9EPjHmaT23yvVM2ZWbrrpZb9PusVFin", "rentEpoch": 203 }, "pubkey": "DktgxiwBtA6oPQqzFH9uqMVZF7CQAnk7FnrSdD4VVA9g" }

Proposed Solution

According to documentation

encoding: - encoding for Account data, either "base58" (slow), "base64", "base64+zstd", or "jsonParsed". "base58" is limited to Account data of less than 129 bytes

I would propose

  1. Return error for such requests, as matching accounts data has more than 129 bytes or
  2. Remove this limitation from documentation
CriesofCarrots commented 3 years ago

Thanks! I went with your option 1

CriesofCarrots commented 3 years ago

Fix will be in v1.7.7

github-actions[bot] commented 2 years ago

This issue has been automatically locked since there has not been any activity in past 7 days after it was closed. Please open a new issue for related bugs.