Skip to content

merge sendRequest precompile into asyncCall#834

Merged
olegrok merged 1 commit into
mainfrom
sendRequest-merge
Apr 21, 2025
Merged

merge sendRequest precompile into asyncCall#834
olegrok merged 1 commit into
mainfrom
sendRequest-merge

Conversation

@olegrok
Copy link
Copy Markdown
Contributor

@olegrok olegrok commented Apr 17, 2025

Here we merge sendRequest precompile code into asyncCall precompile.
At first it allows to eliminate code duplication and then it's the first step before implementation Awaiter contract that will include some request/response machinery for response processing.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 7 out of 9 changed files in this pull request and generated no comments.

Files not reviewed (2)
  • nil/contracts/solidity/tests/TokensTest.sol: Language not supported
  • smart-contracts/contracts/Nil.sol: Language not supported
Comments suppressed due to low confidence (8)

nil/tests/request_response/request_response_test.go:204

  • TestInvalidContext now expects a failed receipt with status 'TooShortContextData'. Ensure this updated assertion aligns with the intended contract behavior.
s.Require().False(receipt.Success)

nil/services/rpc/rawapi/internal/local_call.go:107

  • [nitpick] Verify that the shard ID check (if addr.ShardId() == newEs.ShardId) correctly filters out overrides and that the merging behavior meets the required logic.
for addr, override := range *prevOverrides {

nil/internal/vm/precompiled.go:331

  • [nitpick] Returning baseFee on unpack errors or unexpected argument count may obscure underlying issues; confirm that this fallback is intentional and well documented.
if err != nil || len(args) != argtotal {

nil/internal/vm/precompiled.go:389

  • Ensure that updating the expected number of arguments from 8 to 10 is consistent with the new asyncCall design and that all callers provide the correct arguments.
if len(args) != 10 {

nil/internal/execution/transactions.go:70

  • [nitpick] Passing a 0 responseProcessingGas for the refund transaction appears intentional; verify that using 0 in this context meets the overall gas management strategy.
}, 0); err != nil {

nil/internal/execution/state.go:1002

  • [nitpick] Ensure that passing a 0 responseProcessingGas for bounce transactions is appropriate and does not lead to unexpected gas handling in these cases.
if _, err = es.AddOutTransaction(txn.To, bounceTxn, 0); err != nil {

nil/internal/execution/state.go:1048

  • [nitpick] Confirm that using 0 for responseProcessingGas in response transactions aligns with the overall design and does not inadvertently undercharge gas for these operations.
responseTxn, err := es.AddOutTransaction(txn.To, responsePayload, 0)

nil/internal/execution/state.go:960

  • [nitpick] Verify that setting AsyncContext only when RequestContext is non-empty correctly handles all intended use cases, and that no valid scenarios are missed.
if len(payload.RequestContext) > 0 {

@olegrok olegrok marked this pull request as ready for review April 17, 2025 15:32
@olegrok olegrok requested a review from shermike April 17, 2025 15:32
@olegrok olegrok changed the title [WIP] merge sendRequest precompile into asyncCall merge sendRequest precompile into asyncCall Apr 17, 2025
@olegrok olegrok force-pushed the sendRequest-merge branch from 2e542ae to 12eb34d Compare April 18, 2025 06:54
Here we merge sendRequest precompile code into asyncCall precompile.
At first it allows to eliminate code duplication and then it's the first step before implementation
Awaiter contract that will include some request/response machinery for response processing.
@shermike
Copy link
Copy Markdown
Contributor

shermike commented Apr 21, 2025

LGTM, but tbh I'm not sure that I understand the purpose of such change. Both asyncCall and sendRequest precompiles will be removed, so why we need to move sendRequest to asyncCall now?

@olegrok
Copy link
Copy Markdown
Contributor Author

olegrok commented Apr 21, 2025

LGTM, but tbh I'm not sure that I understand the purpose of such change. Both asyncCall and sendRequest precompiles will be removed, so why we need to move sendRequest to asyncCall now?

To remove one precompile right now. And to have common code for all communication types.
E.g. it was possible to send transactions to non-existent shard. So after this patch we will have common validation path for all calls.

@olegrok olegrok added this pull request to the merge queue Apr 21, 2025
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Apr 21, 2025
@olegrok olegrok added this pull request to the merge queue Apr 21, 2025
Merged via the queue into main with commit c8ead7f Apr 21, 2025
16 checks passed
@olegrok olegrok deleted the sendRequest-merge branch April 21, 2025 18:04
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.

3 participants