casper-network / casper-network/casper-node

Different behavior of `new_locked_contract()` than documented

Open
#4,480 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
399
Forks
224
Avg merge
15h 44m
Merged PRs (30d)
2

Description

According to [new_locked_contract()](https://github.com/casper-network/casper-node/blob/e688fbc75206652dce440c3ddb9570c965382d37/smart_contracts/contract/src/contract_api/storage.rs#L114) documentation:

> if `hash_name` is provided, puts contract hash in current context's named keys under `hash_name`

That is not true, because **ContractPackage** is stored at given key name. I would rather expect to see there `HashAddr` of contract itself (not package).

However, if you store _contract hash_ as `Key::Hash(HashAddr)`, then querying it will not give you the address:

![image](https://github.com/casper-network/casper-node/assets/6506780/0d2fcd96-2424-48bc-bd36-706b776f3bbc)

I was able to store it manually via URef, but this seems to be quite counter intuitive.

_**Note:** Documentation/behavior of `new_contract()` is incorrect as well, but I consider upgradable contracts as anti-feature._

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.