hypersdk icon indicating copy to clipboard operation
hypersdk copied to clipboard

[RPC] Cannot directly serve StatefulBlock i.e. no automatic reflection

Open bianyuanop opened this issue 1 year ago • 3 comments
trafficstars

Background

This issue relates to #697, where I added support of Archiver in Tokenvm. However, blocks cannot be directly served by RPC where Transaction.block.txs.action cannot be unmarshalled, which needs reflection. Relevant Unmarshall function called at requester.go. An automatic reflection is needed to solve this.

Error log

2024/01/24 09:35:55 error frmo client requesting{error 26 0 failed to decode client response: json: cannot unmarshal object into Go struct field Transaction.block.txs.action of type chain.Action http://127.0.0.1:44647/ext/bc/27fLMWHkogB7pWLVrWwyRTNjsLyDszhCrytMtG1kUNzmFdLQtq/tokenapi}

To reproduce

Clone https://github.com/bianyuanop/hypersdk, checkout to s3archiver branch. Create a file named disk_config.json and put following content inside

{
    "archiverType": "disk",
    "enabled": true,
    "location": "/tmp/tokenvm"
}

CD examples/tokenvm Run

MODE="test" ARCHIVER_CONFIG_PATH="./disk_conf.json" ./scripts/run.sh

bianyuanop avatar Jan 24 '24 14:01 bianyuanop

One way to avoid this that we can direcly return bytes then do the reflection manually

bianyuanop avatar Jan 24 '24 14:01 bianyuanop

websocket_packer has that. https://github.com/ava-labs/hypersdk/blob/d27a71b3b49231cda90ab1aafbc481bf77831eb6/rpc/websocket_packer.go#L34

manojkgorle avatar Jan 27 '24 18:01 manojkgorle

This issue has become stale because it has been open 60 days with no activity. Adding the lifecycle/frozen label will exempt this issue from future lifecycle events.

github-actions[bot] avatar Mar 28 '24 00:03 github-actions[bot]