-
Notifications
You must be signed in to change notification settings - Fork 71
docs: update precompile docs #410
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
Merged
charles-cooper
merged 1 commit into
vyperlang:master
from
charles-cooper:docs/register_raw_precompile
Jun 23, 2025
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,15 +1,37 @@ | ||
| # `deregister_precompile` | ||
| # `deregister_raw_precompile` | ||
|
|
||
| ### Signature | ||
|
|
||
| ```python | ||
| deregister_precompile(address: str, force: bool = True) | ||
| from boa.vm.py_evm import deregister_raw_precompile | ||
|
|
||
| deregister_raw_precompile(address: str, force: bool = True) | ||
| ``` | ||
|
|
||
| ### Description | ||
|
|
||
| Deregister a precompile. | ||
| Remove a previously registered precompile. | ||
|
|
||
| **Note:** `deregister_precompile` has been renamed to `deregister_raw_precompile`. The old name is deprecated. | ||
|
|
||
| **Important:** This function is not available directly from the `boa` module. You must import it from `boa.vm.py_evm`. | ||
|
|
||
| - `address`: The address of a previously registered precompile. | ||
| - `force`: Whether to force removal of the precompile at the specified address. | ||
| - Raises `ValueError`: If a precompile is not registered at the specified address and the force argument is `False`. | ||
|
|
||
| ### Examples | ||
|
|
||
| ```python | ||
| >>> from boa.vm.py_evm import register_raw_precompile, deregister_raw_precompile | ||
| >>> | ||
| >>> # Register a precompile | ||
| >>> register_raw_precompile("0x00000000000000000000000000000000000000ff", lambda c: None) | ||
| >>> | ||
| >>> # Remove it | ||
| >>> deregister_raw_precompile("0x00000000000000000000000000000000000000ff") | ||
| ``` | ||
|
|
||
| ### See Also | ||
|
|
||
| - [`register_raw_precompile`](./register_precompile.md) - Register a precompile function |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,26 +1,40 @@ | ||
| # `register_precompile` | ||
| # `register_raw_precompile` | ||
|
|
||
| ### Signature | ||
|
|
||
| ```python | ||
| register_precompile(address: str, fn: Callable[[eth.abc.ComputationAPI], None], force: bool = False) | ||
| from boa.vm.py_evm import register_raw_precompile | ||
|
|
||
| register_raw_precompile(address: str, fn: Callable[[eth.abc.ComputationAPI], None], force: bool = False) | ||
| ``` | ||
|
|
||
| ### Description | ||
|
|
||
| Register a precompile. | ||
| Register a raw precompile function. This is the low-level interface for registering precompiles. | ||
|
|
||
| **Note:** `register_precompile` has been renamed to `register_raw_precompile`. The old name is deprecated. | ||
|
|
||
| **Important:** This function is not available directly from the `boa` module. You must import it from `boa.vm.py_evm`. | ||
|
|
||
| - `address`: The address to register the precompile at. | ||
| - `fn`: The function to execute when the precompile is called. | ||
| - `fn`: The function to execute when the precompile is called. Receives a ComputationAPI object. | ||
| - `force`: Whether to overwrite the precompile function if one is already registered at the specified address. | ||
| - Raises `ValueError`: If a precompile is already registered at the specified address and the force argument is `False`. | ||
|
|
||
| ### Examples | ||
|
|
||
| ```python | ||
| >>> from boa.vm.py_evm import register_raw_precompile | ||
| >>> import boa | ||
| >>> | ||
| >>> log = lambda computation: print("0x" + computation.msg.sender.hex()) | ||
| >>> boa.register_precompile("0x00000000000000000000000000000000000000ff", log) | ||
| >>> register_raw_precompile("0x00000000000000000000000000000000000000ff", log) | ||
| >>> boa.eval("raw_call(0x00000000000000000000000000000000000000ff, b'')") | ||
| 0x0000000000000000000000000000000000000069 | ||
| ``` | ||
|
|
||
| ### See Also | ||
|
|
||
| - [`deregister_raw_precompile`](./deregister_precompile.md) - Remove a registered precompile | ||
| - [`@precompile` decorator](../../guides/advanced_features.md#precompiles) - Higher-level interface for creating precompiles | ||
| - [`patch_opcode`](./patch_opcode.md) - Modify EVM opcodes |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
That behavior seems a bit unintuitive, especially given that it needs a note. Would it make sense to make
raw_callreturn bytes, like in Vyper, and leaveexecute_codeas a low-level version? Might also need a third function for completeness, one that does not throw and returns ComputationABI but does not require passing bytecode...We don't need to deal with that now ofc