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 EIP: EOA private key deactivation/reactivation #9193

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

colinlyguo
Copy link

Introduce a new precompiled contract to enable Externally Owned Accounts (EOAs) to deactivate and reactivate their private keys.

@colinlyguo colinlyguo requested a review from eth-bot as a code owner December 26, 2024 21:33
@github-actions github-actions bot added c-new Creates a brand new proposal s-draft This EIP is a Draft t-core labels Dec 26, 2024
@eth-bot
Copy link
Collaborator

eth-bot commented Dec 26, 2024

File EIPS/eip-7851.md

Requires 1 more reviewers from @g11tech, @lightclient, @SamWilsn

@eth-bot eth-bot added e-consensus Waiting on editor consensus e-review Waiting on editor to review labels Dec 26, 2024
@github-actions github-actions bot added the w-ci Waiting on CI to pass label Dec 26, 2024
EIPS/eip-xxxx.md Outdated
@@ -0,0 +1,201 @@
---
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
---
---
eip: 7851

Assigning next sequential EIP/ERC/RIP number.
Numbers are assigned by editors & associates.

Please also update the filename.

Copy link
Author

Choose a reason for hiding this comment

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

got it. updated in commit 314ed2b.

EIPS/eip-xxxx.md Outdated
title: Private key deactivation and reactivation
description: Introduce a new precompiled contract to enable Externally Owned Accounts (EOAs) to deactivate and reactivate their private keys.
author: Liyi Guo (@colinlyguo)
discussions-to: <URL>
Copy link
Contributor

Choose a reason for hiding this comment

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

Please create a discussions topic in Eth Magicians using the template: https://ethereum-magicians.org/c/eips/5

Copy link
Author

Choose a reason for hiding this comment

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

thanks. updated in 314ed2b.

@eth-bot eth-bot changed the title Add EIP: Private key deactivation and reactivation Add EIP: Private key deactivation and reactivation of EOAs with delegated code Dec 27, 2024
@github-actions github-actions bot removed the w-ci Waiting on CI to pass label Dec 27, 2024
@eth-bot eth-bot changed the title Add EIP: Private key deactivation and reactivation of EOAs with delegated code Add EIP: EOA private key deactivation/reactivation Dec 27, 2024
@github-actions github-actions bot added the w-ci Waiting on CI to pass label Dec 27, 2024
@github-actions github-actions bot removed the w-ci Waiting on CI to pass label Dec 27, 2024
@jochem-brouwer
Copy link
Member

I don't see how this works with 7702 though. If I have the private key of account A, then if I "deactivate" sending txs from A then I can still auth-sign from address B to A, thus removing the "deactivation" from A?

Should this add an extra check to 7702 when checking the auth-tuples? If the authority has the 00 deactivation byte then skip this authority?

EIPS/eip-7851.md Outdated

A new precompiled contract is introduced at address `PRECOMPILE_ADDRESS`. For each call, it consumes `PRECOMPILE_GAS_COST` gas, and the precompiled contract executes the following steps:

- The precompiled contract checks that the caller is an EOA with delegated code (i.e., its account code begins with the prefix `0xef0100`, as defined in [EIP-7702](./eip-7702)). If the code does not conform to the required prefix, the contract MUST terminate without making any state changes.
Copy link
Member

Choose a reason for hiding this comment

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

"Terminate" here means just "stop" the call to this precompile without making any state changes? (One could also "revert", thus the item put on stack when using the CALL* opcodes to this precompile would put 0 on stack if these conditions are not met (so no state changes are done?))

Copy link
Author

Choose a reason for hiding this comment

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

Thanks for the clarification, the error case of precompile is updated as: "Returns a precompile contract error and consumes all provided gas" (refer to 0f2aaba).

The handling logic is consistent with other precompiles mentioned in https://www.evm.codes/precompiled. Also, consuming all gas for invalid calls (reducing DoS attack vectors) looks reasonable.

For the error return, I searched client implementation in geth and found it handled outside by CALL, STATICCALL, CALLCODE, DELEGATECALL. When precompiles return an error, it will be returned to CALL, and CALL will set return value as 0. But formal documents would help clarify this for sure.

EIPS/eip-7851.md Outdated
- The precompile determines the current state of the delegated code based on its byte length:
- If the delegated code is 24 bytes (`0xef0100 || address || 0x00`), it removes the last byte (`0x00`), transitioning to the active state (`0xef0100 || address`).
- If the delegated code is 23 bytes (`0xef0100 || address`), it appends `0x00`, transitioning to the deactivated state (`0xef0100 || address || 0x00`).
- The updated delegated code is saved as the new account code for the EOA.
Copy link
Member

Choose a reason for hiding this comment

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

I think a rule should be added here. In case that we are updating the delegated code, but we are running in "static" mode (so a call chain after using STATICCALL) this should abort (revert, no state-changes).

Copy link
Author

Choose a reason for hiding this comment

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

yes. you're right! I added the STATICCALL error case in this commit: 0f2aaba

@eth-bot eth-bot changed the title Add EIP: EOA private key deactivation/reactivation Add EIP: EOA private key deactivation and reactivation Dec 28, 2024
@colinlyguo
Copy link
Author

I don't see how this works with 7702 though. If I have the private key of account A, then if I "deactivate" sending txs from A then I can still auth-sign from address B to A, thus removing the "deactivation" from A?

Should this add an extra check to 7702 when checking the auth-tuples? If the authority has the 00 deactivation byte then skip this authority?

nice catch. added the extra check you mentioned in the draft. pls refer to this commit: 0f2aaba

@eth-bot eth-bot changed the title Add EIP: EOA private key deactivation and reactivation Add EIP: EOA private key deactivation/reactivation Dec 28, 2024
Copy link

The commit e8778dc (as a parent of 0008744) contains errors.
Please inspect the Run Summary for details.

@github-actions github-actions bot added the w-ci Waiting on CI to pass label Dec 28, 2024
@github-actions github-actions bot removed the w-ci Waiting on CI to pass label Dec 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c-new Creates a brand new proposal e-consensus Waiting on editor consensus e-review Waiting on editor to review s-draft This EIP is a Draft t-core
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants