Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose downloading Wasm binary #1712

Closed
MaksymZavershynskyi opened this issue Nov 17, 2019 · 2 comments
Closed

Expose downloading Wasm binary #1712

MaksymZavershynskyi opened this issue Nov 17, 2019 · 2 comments
Assignees
Labels
A-RPC Area: rpc C-enhancement Category: An issue proposing an enhancement or a PR with one. P-low Priority: low

Comments

@MaksymZavershynskyi
Copy link
Contributor

Currently, RPC allows seeing the account state (which includes Wasm code hash) and key values stored by the smart contract. But it does not allow seeing the code of the smart contract itself.

@MaksymZavershynskyi MaksymZavershynskyi added the C-enhancement Category: An issue proposing an enhancement or a PR with one. label Nov 17, 2019
@MaksymZavershynskyi MaksymZavershynskyi changed the title [RPC] Expose downloading Wasm binary Expose downloading Wasm binary Nov 20, 2019
@ilblackdragon ilblackdragon added the P-low Priority: low label Nov 27, 2019
@ilblackdragon ilblackdragon added this to the MainNet milestone Dec 8, 2019
@ilblackdragon ilblackdragon removed this from the MainNet milestone Mar 20, 2020
@frol frol added the A-RPC Area: rpc label May 1, 2020
@mikedotexe
Copy link

Clicked the subscribe button on this issue. Been talking with an experienced Ethereum dev who's excited about NEAR and he's similarly emphasized the importance of this. Wanted to give this issue a friendly bump.

@ailisp ailisp self-assigned this Dec 8, 2020
frol pushed a commit that referenced this issue Dec 17, 2020
Address #1712,
also, add a dump_code command to state-viewer, so we can dump wasm file given account id, from node that doesn't yet have this rpc, e.g. testnet/mainnet:
```
nearcore (query-view-code) target/debug/state-viewer dump_code --account 1.test.near
Dec 08 17:48:01.772  INFO near: Opening store database at "/home/bo/.near/data"    
Dec 08 17:48:01.911  INFO runtime: Tracking shards: {}    
Dump contract of account 1.test.near into file output.wasm
nearcore (query-view-code) ls
ATTRIBUTIONS.md     CODEOWNERS         Dockerfile          METRICS.md   runtime         tests
Cargo.lock          config3601.json    Dockerfile.nightly  neard        rustfmt.toml    test-utils
Cargo.toml          configmaster.json  docs                nightly      rust-toolchain  tools
chain               CONTRIBUTING.md    genesis-tools       output.wasm  scripts         utils
codecov.yml         core               LICENSE             pytest       SECURITY.md
CODE_OF_CONDUCT.md  deny.toml          Makefile            README.md    target
nearcore (query-view-code) base64 < output.wasm 
47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=
```


Test Plan
------------
```
~ http post http://localhost:3030 jsonrpc=2.0 id=dontcare method=query params:='{"request_type":"view_code","finality":"final","account_id":"test.near"}'
HTTP/1.1 200 OK
content-length: 155
content-type: application/json
date: Tue, 08 Dec 2020 23:05:36 GMT

{
    "error": {
        "code": -32000,
        "data": "contract code of account test.near does not exist while viewing",
        "message": "Server error"
    },
    "id": "dontcare",
    "jsonrpc": "2.0"
}

~ http post http://localhost:3030 jsonrpc=2.0 id=dontcare method=query params:='{"request_type":"view_code","finality":"final","account_id":"1.test.near"}'
HTTP/1.1 200 OK
content-length: 240
content-type: application/json
date: Tue, 08 Dec 2020 23:05:43 GMT

{
    "id": "dontcare",
    "jsonrpc": "2.0",
    "result": {
        "block_hash": "3mZUK6DnPUnGSKr7LdU56pNRd2vuMCsnWQQpP1qMFXnH",
        "block_height": 41020,
        "code_base64": "47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=",
        "hash": "7KoFshMQkdyo5iTx8P2LbLu9jQpxRn24d27FrKShNVXs"
    }
}
```

and also nightly ci test_upload_contract_testnet
@ailisp
Copy link
Member

ailisp commented Dec 19, 2020

Done in #3714

@ailisp ailisp closed this as completed Dec 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-RPC Area: rpc C-enhancement Category: An issue proposing an enhancement or a PR with one. P-low Priority: low
Projects
None yet
Development

No branches or pull requests

5 participants