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

Check that contract address is being computed correctly everywhere #2533

Open
spencercorwin opened this issue Aug 12, 2021 · 1 comment
Open
Labels
area/cli Categorize issue or PR as cli (@neo-one/cli) related area/client Categorize issue or PR as client (@neo-one/client) related kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. priority/important-soon Must be staffed and worked on either currently, or very soon.

Comments

@spencercorwin
Copy link
Collaborator

Need to find everywhere that we currently/previously computed a contract's address, like:

  • compileContract.ts (incorrect? see comments in code)
  • LocalUserAccountProvider.ts (correct?)
  • startNode.ts (incorrect?)

Then use the information gathered from there to determine where else we need to look to make sure we're calculating the contract address now.

Then go through and check to see if what's in there now is working. If it's not, or it's determined to be incorrect then make changes. The major change is that now the contract address is based on the signer of the transaction that deploys the contract. Since that is done much later on in most of these processes we may need to return a function as part of compiled contracts that will calculated the address with the given signer. And that value should then maybe be returned up the call stack to be passed back to where the contract address is needed.

How it was previously calculated:
const address = scriptHashToAddress(common.uInt160ToString(crypto.toScriptHash(Buffer.from(contract.contract.script, 'hex'))));

How it should be calculated:
const contractAddress = scriptHashToAddress(common.uInt160ToString(crypto.getContractHash(signer.account, nefFile.checkSum, contractIn.manifest.name)));

@spencercorwin spencercorwin added priority/important-soon Must be staffed and worked on either currently, or very soon. area/cli Categorize issue or PR as cli (@neo-one/cli) related area/client Categorize issue or PR as client (@neo-one/client) related kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. labels Aug 12, 2021
@spencercorwin
Copy link
Collaborator Author

Make sure to cover the address in createSmartContract.ts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/cli Categorize issue or PR as cli (@neo-one/cli) related area/client Categorize issue or PR as client (@neo-one/client) related kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. priority/important-soon Must be staffed and worked on either currently, or very soon.
Projects
None yet
Development

No branches or pull requests

1 participant