-
Notifications
You must be signed in to change notification settings - Fork 239
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
Is there any PoC on implementing mathematical operations using Stateful Precompiles in Custom Subnets? #696
Comments
You can write any golang program you want inside of each precompile function including accessing the stateDB directly if you want to read/write the storage trie of your precompile as long as it is deterministic. Here's the stateful precompile tutorial: https://docs.avax.network/subnets/hello-world-precompile-tutorial and the most recent pending PR that will update it to make development easier: https://github.com/ava-labs/avalanche-docs/pull/1418/files (pending release of a new repo). Could you be more specific about what issues you are running into? |
I have pushed a precompile contract in the counter-pc branch here: https://github.com/ashucoder9/subnet-evm/tree/counter-pc Currently, my goal is to create a counter precompile that returns the value or increments by X as specified (can be 1 also for general increment). Given that I do not have much experience with GoLang, I might be wrong in implementing the code. Might need a little help on that. Feel free to propose/comment any improvements! Apart from that, is the precompile disabled by default? If yes, where do we enable it? I remember running the HelloWorld tutorial without any modifications for E2E tests (I assumed it was working PoC) and failed a test for which the most likely reasoning is that it may be disabled. |
Even though this attempt is focused on a generalized understanding of the working of mathematical operations with stateful precompiles, it can lead to developing custom EVM extensions that were not implemented in the Ethereum Virtual Machine like this. |
@ceyonur can you please check why the Ginkgo tests are failing to run: https://github.com/ashucoder9/subnet-evm/tree/counter-precompile |
Hey @ashucoder9 , it looks like CI is not running at all on that repo. Workflows are disabled by default (parameter of GitHub, not related to Subnet-EVM), so you should check to make sure that they are enabled and running correctly. |
No worries, I figured the rest out and also updated the docs with new detail. Thanks to @ceyonur! |
Let's suppose I want to create a universal calculator precompile that performs computation like Addition.
Can be extended with toolings to store in the stateDB and more.
I am working on launching something similar to a Counter program and stuck in the contract phase so it'd helpful in understanding working of the functions and their interactions with variable states.
The text was updated successfully, but these errors were encountered: