From 912168c5a9e089164e46aa6bdba518e162d166f2 Mon Sep 17 00:00:00 2001 From: Wei Tang Date: Sun, 31 Mar 2019 22:19:58 +0200 Subject: [PATCH 1/7] Init contract-based account versioning --- EIPS/eip-account-versioning3.md | 70 +++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 EIPS/eip-account-versioning3.md diff --git a/EIPS/eip-account-versioning3.md b/EIPS/eip-account-versioning3.md new file mode 100644 index 00000000000000..1f02ce5de96428 --- /dev/null +++ b/EIPS/eip-account-versioning3.md @@ -0,0 +1,70 @@ +--- +eip: +title: Contract-based Account Versioning +author: Wei Tang (@sorpaas) +discussions-to: https://github.com/sorpaas/EIPs/issues/4 +status: Draft +type: Standards Track +category: Core +created: 2019-01-17 +--- + +## Simple Summary + +Provide an alternative proposal compared with EIP-1702 / ECIP-1040 / +EIP-1707, with the following advantages: + +* We don't need to modify existing account state format. +* We don't need to modify how precompiled contracts are invoked. +* The version bytes cannot be forged. + +The basic idea is that we use a contract address' storage to store an +account's version bytes. Note that it is also possible to extend this +scheme to store other information about an account. + +## Specification + +Define `VERSION_CONTRACT_ADDR` at location `0x0000..00f1`. + +After `FORK_BLOCK`, set nonce of `VERSION_CONTRACT_ADDR` to `1`. + +Define two new opcodes `VCREATE` and `VCREATE2` at `0xf6` and `0xf7` +respectively. + +`VCREATE` takes 4 stack arguments (version, value, input offset, input +size), and `VCREATE2` takes 5 stack arguments (version, endowment, +memory_start, memory_length, salt). Note that except the stack item +`version`, other arguments are the same as `CREATE` and `CREATE2`. + +The two new opcodes behave identically to `CREATE` and `CREATE2`, +except that: + +* Gas cost is `CREATE` or `CREATE2`'s gas cost plus `20000`. +* Before writing the contract code resulted from `VCREATE` and + `VCREATE2`, check the following conditions. If any following + conditions does not meet or operation fails, return out-of-gas. + * The `version` provided is supported version bytes. + * Invoke additional checks (if any) required by the specific version + bytes. + * If the above two checks are successful + * Let `address` be the to-be-deployed contract address. + * Set storage of `VERSION_CONTRACT_ADDR` where key is `address` + (prefixed with 0 so that it's 256 bits), and value is `version`. + +When invoking a contract, either by a transaction or a variant of +call: + +* Check whether the storage of `VERSION_CONTRACT_ADDR` has non-zero + value with key `address` (prefixed with 0 so that it's 256 bits). + * If so, invoke the VM version defined by value. + * Otherwise, invoke the default (legacy) VM version. + +When self-destruct a contract: + +* Set storage value of `VERSION_CONTRACT_ADDR` where key is `address` + (prefixed with 0 so that it's 256 bits) to zero. + +## Copyright + +Copyright and related rights waived via +[CC0](https://creativecommons.org/publicdomain/zero/1.0/). From 378c53638c5af4e7a6d40c9f0420b8722abe8b12 Mon Sep 17 00:00:00 2001 From: Wei Tang Date: Sun, 31 Mar 2019 22:21:15 +0200 Subject: [PATCH 2/7] Self-assign eip-1891 --- EIPS/{eip-account-versioning3.md => eip-1891.md} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename EIPS/{eip-account-versioning3.md => eip-1891.md} (99%) diff --git a/EIPS/eip-account-versioning3.md b/EIPS/eip-1891.md similarity index 99% rename from EIPS/eip-account-versioning3.md rename to EIPS/eip-1891.md index 1f02ce5de96428..f74c0d4c2be5b8 100644 --- a/EIPS/eip-account-versioning3.md +++ b/EIPS/eip-1891.md @@ -1,5 +1,5 @@ --- -eip: +eip: 1891 title: Contract-based Account Versioning author: Wei Tang (@sorpaas) discussions-to: https://github.com/sorpaas/EIPs/issues/4 From c48bec4e0e0a3dd6d46f08daf9a06efaafa9ae52 Mon Sep 17 00:00:00 2001 From: Wei Tang Date: Sun, 31 Mar 2019 22:21:39 +0200 Subject: [PATCH 3/7] Fix dates --- EIPS/eip-1891.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EIPS/eip-1891.md b/EIPS/eip-1891.md index f74c0d4c2be5b8..5275c0cb22f1a9 100644 --- a/EIPS/eip-1891.md +++ b/EIPS/eip-1891.md @@ -6,7 +6,7 @@ discussions-to: https://github.com/sorpaas/EIPs/issues/4 status: Draft type: Standards Track category: Core -created: 2019-01-17 +created: 2019-03-31 --- ## Simple Summary From 8c8b00579a66e2955a50b89f51b99c98508d1b1c Mon Sep 17 00:00:00 2001 From: Wei Tang Date: Sun, 31 Mar 2019 22:29:33 +0200 Subject: [PATCH 4/7] Update eip-1891.md --- EIPS/eip-1891.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EIPS/eip-1891.md b/EIPS/eip-1891.md index 5275c0cb22f1a9..659b2ce7f10557 100644 --- a/EIPS/eip-1891.md +++ b/EIPS/eip-1891.md @@ -2,7 +2,7 @@ eip: 1891 title: Contract-based Account Versioning author: Wei Tang (@sorpaas) -discussions-to: https://github.com/sorpaas/EIPs/issues/4 +discussions-to: https://github.com/sorpaas/EIPs/issues/5 status: Draft type: Standards Track category: Core From b5edd0f11f3a19e474cb227b5e349fa1bc8b7f49 Mon Sep 17 00:00:00 2001 From: Wei Tang Date: Sun, 31 Mar 2019 22:29:50 +0200 Subject: [PATCH 5/7] Update eip-1891.md --- EIPS/eip-1891.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EIPS/eip-1891.md b/EIPS/eip-1891.md index 659b2ce7f10557..b3d14618793ab9 100644 --- a/EIPS/eip-1891.md +++ b/EIPS/eip-1891.md @@ -2,7 +2,7 @@ eip: 1891 title: Contract-based Account Versioning author: Wei Tang (@sorpaas) -discussions-to: https://github.com/sorpaas/EIPs/issues/5 +discussions-to: https://github.com/sorpaas/EIPs/issues/6 status: Draft type: Standards Track category: Core From 3678c063c541d65896529e93370bd61892f01091 Mon Sep 17 00:00:00 2001 From: Wei Tang Date: Mon, 1 Apr 2019 03:05:39 +0200 Subject: [PATCH 6/7] Update eip-1891.md --- EIPS/eip-1891.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/EIPS/eip-1891.md b/EIPS/eip-1891.md index b3d14618793ab9..4ef7601fe4d2f7 100644 --- a/EIPS/eip-1891.md +++ b/EIPS/eip-1891.md @@ -51,11 +51,10 @@ except that: * Set storage of `VERSION_CONTRACT_ADDR` where key is `address` (prefixed with 0 so that it's 256 bits), and value is `version`. -When invoking a contract, either by a transaction or a variant of -call: +Before invoking a contract, either by a transaction, `CALL`, `STATICCALL`, `CALLCODE` or `DELEGATECALL`: * Check whether the storage of `VERSION_CONTRACT_ADDR` has non-zero - value with key `address` (prefixed with 0 so that it's 256 bits). + value with key `address` (`I_a` in yellow paper, prefixed with 0 so that it's 256 bits). * If so, invoke the VM version defined by value. * Otherwise, invoke the default (legacy) VM version. @@ -63,6 +62,8 @@ When self-destruct a contract: * Set storage value of `VERSION_CONTRACT_ADDR` where key is `address` (prefixed with 0 so that it's 256 bits) to zero. + +Contract creation transaction always uses the default (legacy) VM version. ## Copyright From f74a41dc9bd0b6d85935fa6695173520d6deec3c Mon Sep 17 00:00:00 2001 From: Wei Tang Date: Fri, 28 Jun 2019 11:44:32 +0200 Subject: [PATCH 7/7] Move status to abandoned and add superseded-by tag to 1702 --- EIPS/eip-1891.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/EIPS/eip-1891.md b/EIPS/eip-1891.md index 4ef7601fe4d2f7..114c4c4fa1e5c5 100644 --- a/EIPS/eip-1891.md +++ b/EIPS/eip-1891.md @@ -3,9 +3,10 @@ eip: 1891 title: Contract-based Account Versioning author: Wei Tang (@sorpaas) discussions-to: https://github.com/sorpaas/EIPs/issues/6 -status: Draft +status: Abandoned type: Standards Track category: Core +superseded-by: 1702 created: 2019-03-31 ---