Closed duanyytop closed 2 months ago
Those that need to be optimized
Fetching the GitHub JSON file is not stable or slow for some users, we should do something to optimize it.
The GitHub JSON file path is https://github.com/ckb-cell/rgbpp-sdk/pull/191/files#diff-3039d7f71cfd89a5a23296b2cccdb966bc9132c2bf938a39a08bf0aeceed5d58R21
May need a CDN for the static JSON content and test the speed comparing to fetching TypeID script cell deps through ckb-indexer directly.
Setup CDN for https://raw.githubusercontent.com/ckb-cell/typeid-contract-cell-deps/main/deployment/cell-deps.json
We can try using https://www.jsdelivr.com/?docs=gh, they provide a free, fast CDN. For example: https://cdn.jsdelivr.net/gh/ckb-cell/typeid-contract-cell-deps@main/deployment/cell-deps.json
Those that need to be optimized
Fetching the GitHub JSON file is not stable or slow for some users, we should do something to optimize it. The GitHub JSON file path is https://github.com/ckb-cell/rgbpp-sdk/pull/191/files#diff-3039d7f71cfd89a5a23296b2cccdb966bc9132c2bf938a39a08bf0aeceed5d58R21
May need a CDN for the static JSON content and test the speed comparing to fetching TypeID script cell deps through ckb-indexer directly.
# RGB++ Lock deployment type script
➜ rgbpp echo '{
"id": 2,
"jsonrpc": "2.0",
"method": "get_cells",
"params": [
{
"script": {
"code_hash": "0x00000000000000000000000000000000000000000000000000545950455f4944",
"hash_type": "type",
"args": "0xa3bc8441df149def76cfe15fec7b1e51d949548bc27fb7a75e9d4b3ef1c12c7f"
},
"script_type": "type"
},
"asc",
"0x64"
]
}' \
| curl -o /dev/null -s -w 'Total: %{time_total}s\n' -H 'content-type: application/json' -d @- \
https://testnet.ckb.dev/indexer
Total: 0.710650s
# CDN
➜ rgbpp curl -o /dev/null -s -w 'Total: %{time_total}s\n' https://cdn.jsdelivr.net/gh/ckb-cell/typeid-contract-cell-deps@main/deployment/cell-deps.json
Total: 0.197599s
# raw github url
➜ rgbpp curl -o /dev/null -s -w 'Total: %{time_total}s\n' https://raw.githubusercontent.com/ckb-cell/typeid-contract-cell-deps/main/deployment/cell-deps.json
Total: 0.559571s
➜ rgbpp curl -o /dev/null -s -w 'Total: %{time_total}s\n' https://raw.githubusercontent.com/ckb-cell/typeid-contract-cell-deps/main/deployment/cell-deps.json
Total: 0.279097s
const request = (url: string) => axios.get(url, { timeout: 2000 });
const fetchCellDepsJson = async () => {
try {
const response = await Promise.any([request(GITHUB_CELL_DEPS_JSON_URL), request(CDN_GITHUB_CELL_DEPS_JSON_URL)]);
return response.data as CellDepsObject;
} catch (error) {
// console.error('Error fetching cell deps:', error);
}
};
The CDN and timeout have been added to make the cell deps
fetching faster and more stable in https://github.com/ckb-cell/rgbpp-sdk/pull/191/commits/1310d40741e4c7286910ea61a0959c607325895d
Update https://github.com/ckb-cell/typeid-contract-cell-deps automatically through a GitHub action workflow (maybe every 5 mins)
I think the update of the cell-ceps.json
of typeid-contract-cell-deps
should not block this PR. And I will implement the feature in the typeid-contract-cell-deps
repository later.
Update https://github.com/ckb-cell/typeid-contract-cell-deps automatically through a GitHub action workflow (maybe every 5 mins)
I think the update of the
cell-ceps.json
oftypeid-contract-cell-deps
should not block this PR. And I will implement the feature in thetypeid-contract-cell-deps
repository later.
The task of updating latest cell deps has been triggering and the update time is not strictly 5 minutes. https://github.com/ckb-cell/typeid-contract-cell-deps/actions/workflows/update.yml
Problem
Although Lumos provides a function
refreshTypeIdCellDeps
to refresh the cell deps of a upgraded TypeID script, it requires the dApp developers themselves to handle it manually.But usually a dApp developer doesn't know when a TypeID script is updated.
This PR introduces a mechanism to automatically get the TypeID scripts' latest cell deps, trying to make things easier.
Design Goal and Main Changes
fetchTypeIdCellDeps
function to fetchcellDeps
from the GitHub JSON filecellDepsSelected
parameter to select thecellDeps
which are neededcellDeps
for all the RGB++ transactionsfetchCellDepsJson
fails due to a network error, the constants are used as a fallback mechanism.cell-deps.json
should be faster than fetching TypeID script cell deps through ckb-indexer directly. Example: https://cdn.jsdelivr.net/gh/ckb-cell/typeid-contract-cell-deps@main/deployment/cell-deps.json test: https://github.com/ckb-cell/rgbpp-sdk/pull/191#issuecomment-2134720392Those that need to be optimized
Fetching the GitHub JSON file is not stable or slow for some users, we should do something to optimize it.
The GitHub JSON file path is https://github.com/ckb-cell/rgbpp-sdk/pull/191/files#diff-3039d7f71cfd89a5a23296b2cccdb966bc9132c2bf938a39a08bf0aeceed5d58R21
The tests that need to be run
I have tested the examples of
xudt-on-ckb
and using the integration tests of https://github.com/ckb-cell/rgbpp-sdk/pull/169 to test more examples is needed. cc @Dawn-githup