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

Implement and test potential solution for mock-skip blocks on runtimes #486

Open
bogdanS98 opened this issue Jul 19, 2024 · 0 comments · May be fixed by #487
Open

Implement and test potential solution for mock-skip blocks on runtimes #486

bogdanS98 opened this issue Jul 19, 2024 · 0 comments · May be fixed by #487
Assignees

Comments

@bogdanS98
Copy link
Contributor

Continuation from this ticket.
This ticket comes directly as an action point from #190.

Context and recap

We are currently using an isolated foucoco-based runtime for wasm-deploy testings. This variant of the runtime allows us to skip blocks for testing purposes by calling a modified pallet contracts which in turns modifies the reported block number that the contracts see.

We want to remove this extra repository and have this functionality on the main Foucoco repository itself.

Solution to explore

We would like to create a new pallet that would be conditionally compiled with a test feature flag (or equivalent). This pallet will have at least one extrinsic, which will not take fee nor check signature, that will set the desired block we would like the chain to report during contracts execution.

For this, we can leverage the on_initialize hook. When called, we will store the current block number and then call directly the set_block_number method of the frame system pallet and set it to the desired value.

Then, when on_finalize is called, this pallet should revert the changes done on the frame system pallet. The idea is that only during execution of extrinsic the block reported is different to what it should actually be, and does not interfere with production of blocks. See the lifecycle of hooks and extrinsics for context.

Since this will likely introduce an issue with the validity of any transaction made whenever the block has been changed (see this comment for more details), we need to modify the instances were wasm-deploy submits extrinsics to the chain such that the transaction is specified as Immortal. The calls are formed here and here either for deployment or call to an existing contract. Since api-solang already allows for specifying a modifyExtrinsic function, this would be a good place modify the transaction from Mortal to Immortal.

Testing

Ultimately, we are currently using the functionality to skip blocks here. Once the new solution is in place, we should be able to modify the skipBlock function so it calls the new pallet and test if the solution works.

@bogdanS98 bogdanS98 self-assigned this Jul 19, 2024
@bogdanS98 bogdanS98 linked a pull request Jul 19, 2024 that will close this issue
@bogdanS98 bogdanS98 linked a pull request Jul 19, 2024 that will close this issue
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 a pull request may close this issue.

1 participant