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

Add file id and init bytecode in ContractCallContext #9799

Conversation

bilyana-gospodinova
Copy link
Contributor

@bilyana-gospodinova bilyana-gospodinova commented Nov 22, 2024

Description:
During the implementation of the reusable services integration it turns out that now the contracts are deployed in 2 steps:

  1. The initcode is uploaded and saved as a file using a FileCreateTransactionBody.
  2. The returned file id from step 1 is then passed to a ContractCreateTransactionBody.
    Each step performs a separate transaction.
    For step 2 even if we pass the correct file id, since the mirror node data is readonly, the FileReadableKVState is not able to populate the contract's bytecode from the DB since it was never explicitly persisted in the DB.

This PR add a new field in the ContractCallContext that preserve the file id and the contract's bytecode. The new field is called "file". If it is available when we call FileReadableKVState#readFromDataSource then we return the file from the context with priority.

This field might need to be cleared up at some point but this will probably added later when the correct place is found during testing.

Fixes #9798

Signed-off-by: Bilyana Gospodinova <bilyana.gospodinova14@gmail.com>
Signed-off-by: Bilyana Gospodinova <bilyana.gospodinova14@gmail.com>
Signed-off-by: Bilyana Gospodinova <bilyana.gospodinova14@gmail.com>
Signed-off-by: Bilyana Gospodinova <bilyana.gospodinova14@gmail.com>
Signed-off-by: Bilyana Gospodinova <bilyana.gospodinova14@gmail.com>
@bilyana-gospodinova bilyana-gospodinova added enhancement Type: New feature web3 Area: Web3 API labels Nov 22, 2024
@bilyana-gospodinova bilyana-gospodinova self-assigned this Nov 22, 2024
@bilyana-gospodinova bilyana-gospodinova changed the title Add file id and init bytecode in context Add file id and init bytecode in ContractCallContext Nov 22, 2024
Signed-off-by: Bilyana Gospodinova <bilyana.gospodinova14@gmail.com>
Signed-off-by: Bilyana Gospodinova <bilyana.gospodinova14@gmail.com>
@bilyana-gospodinova bilyana-gospodinova marked this pull request as ready for review December 10, 2024 09:27
@bilyana-gospodinova bilyana-gospodinova requested a review from a team as a code owner December 10, 2024 09:27
Signed-off-by: Bilyana Gospodinova <bilyana.gospodinova14@gmail.com>
Signed-off-by: Bilyana Gospodinova <bilyana.gospodinova14@gmail.com>
…798-enhance-FileReadableKVState-to-fetch-contract-from-ContractCallContext
Signed-off-by: Bilyana Gospodinova <bilyana.gospodinova14@gmail.com>
@steven-sheehy steven-sheehy added this to the 0.121.0 milestone Dec 11, 2024
steven-sheehy
steven-sheehy previously approved these changes Dec 11, 2024
Signed-off-by: Bilyana Gospodinova <bilyana.gospodinova14@gmail.com>
Signed-off-by: Bilyana Gospodinova <bilyana.gospodinova14@gmail.com>
Signed-off-by: Bilyana Gospodinova <bilyana.gospodinova14@gmail.com>
Signed-off-by: Bilyana Gospodinova <bilyana.gospodinova14@gmail.com>
kselveliev
kselveliev previously approved these changes Dec 12, 2024
Base automatically changed from 09791-init-mirror-node-state-and-subcomponents to main December 12, 2024 14:47
@steven-sheehy steven-sheehy dismissed kselveliev’s stale review December 12, 2024 14:47

The base branch was changed.

@steven-sheehy steven-sheehy dismissed their stale review December 12, 2024 14:47

The base branch was changed.

…dableKVState-to-fetch-contract-from-ContractCallContext
steven-sheehy
steven-sheehy previously approved these changes Dec 12, 2024
Copy link
Member

@steven-sheehy steven-sheehy left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link

codecov bot commented Dec 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.24%. Comparing base (5ff2e24) to head (2e5f39f).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##               main    #9799   +/-   ##
=========================================
  Coverage     92.24%   92.24%           
- Complexity     7830     7832    +2     
=========================================
  Files           953      953           
  Lines         32759    32766    +7     
  Branches       4142     4143    +1     
=========================================
+ Hits          30217    30225    +8     
  Misses         1568     1568           
+ Partials        974      973    -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Signed-off-by: Bilyana Gospodinova <bilyana.gospodinova14@gmail.com>
@steven-sheehy steven-sheehy merged commit 1b67fd1 into main Dec 12, 2024
32 checks passed
@steven-sheehy steven-sheehy deleted the 09798-enhance-FileReadableKVState-to-fetch-contract-from-ContractCallContext branch December 12, 2024 15:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Type: New feature web3 Area: Web3 API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add option in the ContractCallContext to hold the contract that is currently being deployed
3 participants