-
Notifications
You must be signed in to change notification settings - Fork 185
feat: Create and use contract service interface #22429
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
base: feature/hedera-evm-pectra-support
Are you sure you want to change the base?
feat: Create and use contract service interface #22429
Conversation
Signed-off-by: Luke Lee <luke.lee@hashgraph.com>
Signed-off-by: Luke Lee <luke.lee@hashgraph.com>
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
Signed-off-by: Luke Lee <luke.lee@hashgraph.com>
Signed-off-by: Luke Lee <luke.lee@hashgraph.com>
Coverage summary from CodacySee diff coverage on Codacy
Coverage variation details
Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: Diff coverage details
Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: See your quality gate settings Change summary preferencesFootnotes
|
Signed-off-by: Luke Lee <luke.lee@hashgraph.com>
Signed-off-by: Luke Lee <luke.lee@hashgraph.com>
| * If this field is set, a call to the account's address within a smart contract will | ||
| * result in the code of the authorized contract being executed. | ||
| */ | ||
| bytes delegation_address = 21; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just curious, wouldn't it be more efficient to store the contractID here (and in CryptoCreate)?
Also, do we need to update the Account definition with this new field?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From the perspective of Hedera a contactID could make sense but from the perspective of the EVM, it does not, as everywhere it is used a 2 byte indicator plus the 20 byte EVM address is expected. Every place the indicator is used (including likely in the Besu code) we would have to construct these bytes from the contract alias if we used the contractID.
The ultimate storage location of these bytes is in the ContractStateStore which has a map of AccountID (key) to delegation indicator (the 24 bytes specified above). In order to achieve this storage, this pr introduces a Contract service api so that token service can ask the contract service to save the bytes away in the correct store. Having these bytes in the Account definition would not serve a purpose unless mirror node needs it by my understanding is that the updates in the state_changes.proto as well as the record produced by the crypto_update and crypto_create transaction body is enough to indicate that the delegation_indicator for the Account has changed. Please let me know if you think otherwise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems there is some complexity here; so you are welcome to ping me for a short chat to discuss further if that would help.
Assuming that might not be optimal, I apologize in advance for the length of this response.
Let me try to understand this, and include some point-by-point thoughts.
- This is intended to support contract calls from the EVM, and is not in any way intended to support native Hiero clients
- This data is stored in the ContractStateStore, not in the Account.
- You are adding a field to the native Hiero account creation and update transactions for a value that is not part of the account and is not stored with the account.
Given that understanding, I believe this is the wrong place to add this data entirely. We should not, in my opinion, be trying to assign entries in the ContractStateStore via the creation and update of the native Account.
My recommendation would be that either this is a contract operation, implemented via the EVM and possibly a precompile, or it is a new transaction on the SmartContract service to add an account to delegate to a contract (e.g. something like addDelegatingAccount(Contract, AccountID)). In either case the data would then make perfect sense as being stored exclusively in the state managed by the Smart Contract service and would only be referred to when executing a smart contract call (the Smart Contract service would execute the relevant smart contract on encountering the account ID bytes rather than calling out to the native services).
The problem with the approach as described is twofold:
- Anything in a native account create or update is expected to be visible when querying that account, and this value is not. Generally any non-repeated value in an entity creation transaction is expected to be stored with that entity as well.
- This modifies the native Hiero API (HAPI) with a field that is completely irrelevant to a regular native HAPI
Accountand while it could be set; it's meaning and function are almost completely opaque to the native API user.
In summary that Adding this field to the native API here, but then storing it only with smart contracts and in such a manner that it is only ever useable from smart contracts, seems like it's either backwards or missing something important.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes there are some complexities with the definition. I understand your concerns but maybe a conversation will help clarify the intent.
Description:
Create a contract service interface that allows for the updating of the byte code for an EOA and use it from the token service.
Related issue(s):
Fixes #22409
Notes for reviewer:
Checklist