Skip to content

Native: store ID->hash map in ContractManagement, add iterator#2807

Merged
shargon merged 7 commits intoneo-project:masterfrom
roman-khimov:management-store-ids
Sep 5, 2022
Merged

Native: store ID->hash map in ContractManagement, add iterator#2807
shargon merged 7 commits intoneo-project:masterfrom
roman-khimov:management-store-ids

Conversation

@roman-khimov
Copy link
Contributor

That probably is the lighest design possible, store and retrieve hashes
only. But it can be expanded to return full contract state (getContractByID,
for example) and probably even iterate over contract states.

Fixes #2803. Not tested.

That probably is the lighest design possible, store and retrieve hashes
only. But it can be expanded to return full contract state (getContractByID,
for example) and probably even iterate over contract states.

Fixes neo-project#2803.
@roman-khimov roman-khimov marked this pull request as ready for review August 25, 2022 09:04
erikzhang
erikzhang previously approved these changes Aug 31, 2022
@superboyiii superboyiii mentioned this pull request Sep 5, 2022
/// <param name="id">Contract ID.</param>
/// <returns>The deployed contract.</returns>
[ContractMethod(CpuFee = 1 << 15, RequiredCallFlags = CallFlags.ReadStates)]
public ContractState GetContractById(DataCache snapshot, int id)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public ContractState GetContractById(DataCache snapshot, int id)
public ContractState GetContractById(DataCache snapshot, uint id)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems this is only for non-native contracts, uint is better.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's GetContractHashes that is specifically for non-natives, but this one can return native contracts as well, it doesn't hurt. Otherwise we'll have to check for int overflows anyway.

Co-authored-by: Shargon <shargon@gmail.com>
@superboyiii
Copy link
Member

Tested OK. Good to Merge.

@shargon shargon merged commit 90cf23b into neo-project:master Sep 5, 2022
roman-khimov added a commit to nspcc-dev/neo-go that referenced this pull request Sep 19, 2022
Follow neo-project/neo#2807. Notice that this data is not cached, our previous
implementation wasn't too and it shouldn't be a problem (not on the hot path).
roman-khimov added a commit to nspcc-dev/neo-go that referenced this pull request Sep 19, 2022
Follow neo-project/neo#2807. Notice that this data is not cached, our previous
implementation wasn't too and it shouldn't be a problem (not on the hot path).
roman-khimov added a commit to nspcc-dev/neo-go that referenced this pull request Nov 25, 2022
Follow neo-project/neo#2807. Notice that this data is not cached, our previous
implementation wasn't too and it shouldn't be a problem (not on the hot path).
roman-khimov added a commit to nspcc-dev/neo-go that referenced this pull request Dec 2, 2022
Follow neo-project/neo#2807. Notice that this data is not cached, our previous
implementation wasn't too and it shouldn't be a problem (not on the hot path).
roman-khimov added a commit to roman-khimov/neo that referenced this pull request Dec 7, 2022
This is an omission of neo-project#2807, even though native hashes are well-known
GetContractById better be symmetric for all contracts. Related to
nspcc-dev/neo-go#2837.
roman-khimov added a commit to roman-khimov/neo that referenced this pull request Dec 7, 2022
This is an omission of neo-project#2807, even though native hashes are well-known
GetContractById better be symmetric for all contracts. Related to
nspcc-dev/neo-go#2837.
shargon added a commit that referenced this pull request Jan 7, 2023
This is an omission of #2807, even though native hashes are well-known
GetContractById better be symmetric for all contracts. Related to
nspcc-dev/neo-go#2837.

Co-authored-by: Shargon <shargon@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Store contract ID->hash mapping and allow to iterate over contracts

4 participants