From 73b1a5dde04a60bad5659a0b0b5153bdb735b7c0 Mon Sep 17 00:00:00 2001 From: inphi Date: Fri, 9 Feb 2024 13:00:02 -0500 Subject: [PATCH 1/5] fault-proof: kzg point eval precompile --- specs/experimental/fault-proof/index.md | 29 +++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/specs/experimental/fault-proof/index.md b/specs/experimental/fault-proof/index.md index a1c5d16e3..8611a3958 100644 --- a/specs/experimental/fault-proof/index.md +++ b/specs/experimental/fault-proof/index.md @@ -13,7 +13,9 @@ - [Type `3`: Global generic key](#type-3-global-generic-key) - [Type `4`: Global SHA2-256 key](#type-4-global-sha2-256-key) - [Type `5`: Global EIP-4844 Point-evaluation key](#type-5-global-eip-4844-point-evaluation-key) - - [Type `6-128`: reserved range](#type-6-128-reserved-range) + - [Type `6`: Global EIP-4844 Point-evaluation precompile key]( + #type-6-global-eip-4844-point-evaluation-precompile-key) + - [Type `7-128`: reserved range](#type-7-128-reserved-range) - [Type `129-255`: application usage](#type-129-255-application-usage) - [Bootstrapping](#bootstrapping) - [Hinting](#hinting) @@ -26,6 +28,7 @@ - [`l1-block-header `](#l1-block-header-blockhash) - [`l1-transactions `](#l1-transactions-blockhash) - [`l1-receipts `](#l1-receipts-blockhash) + - [`l1-kzg-point-evaluation `](#l1-kzg-point-evaluation-bytes) - [`l2-block-header `](#l2-block-header-blockhash) - [`l2-transactions `](#l2-transactions-blockhash) - [`l2-code `](#l2-code-codehash) @@ -156,7 +159,24 @@ Key: `5 ++ keccak256(commitment ++ z)[1:]`, where: - `commitment` is a bytes48, representing the KZG commitment. - `z` is a big-endian `uint256` -#### Type `6-128`: reserved range +#### Type `6`: Global EIP-4844 Point-evaluation precompile key + +An EIP-4844 point-evaluation precompile result. + +It returns the result of the EIP-4844 point-evaluation precompile introduced in Cancun. + +Key: `6 ++ keccak256(input)[1:]`, where: + +- `6` is the type byte +- `++` is concatenation +- `input` is the 192 byte input to the KZG point evaluation precompile + +The result has two possible 1-byte values: + +- `0` if the point evaluation precompile fails +- `1` - otherwise + +#### Type `7-128`: reserved range Range start and end both inclusive. @@ -385,6 +405,11 @@ prepare the RLP pre-images of each of them, including transactions-list MPT node Requests the host to prepare the list of receipts of the L1 block with ``: prepare the RLP pre-images of each of them, including receipts-list MPT nodes. +#### `l1-kzg-point-evaluation ` + +Requests the host to prepare the result of the L1 KZG point evaluation precompile given +`` as the input. + #### `l2-block-header ` Requests the host to prepare the L2 block header RLP pre-image of the block ``. From cd13646d01b39bfdbaa78deee16b08aac8d09273 Mon Sep 17 00:00:00 2001 From: inphi Date: Mon, 12 Feb 2024 17:59:03 -0500 Subject: [PATCH 2/5] add section on precompiles --- specs/experimental/fault-proof/index.md | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/specs/experimental/fault-proof/index.md b/specs/experimental/fault-proof/index.md index 8611a3958..90d410a10 100644 --- a/specs/experimental/fault-proof/index.md +++ b/specs/experimental/fault-proof/index.md @@ -161,9 +161,11 @@ Key: `5 ++ keccak256(commitment ++ z)[1:]`, where: #### Type `6`: Global EIP-4844 Point-evaluation precompile key -An EIP-4844 point-evaluation precompile result. +An EIP-4844 point-evaluation precompile result. It result maps directly to the EIP-4844 +point-evaluation precompile introduced in Cancun. -It returns the result of the EIP-4844 point-evaluation precompile introduced in Cancun. +This preimage key can be used to avoid running expensive point-evaluation routine in + a program. Key: `6 ++ keccak256(input)[1:]`, where: @@ -405,10 +407,11 @@ prepare the RLP pre-images of each of them, including transactions-list MPT node Requests the host to prepare the list of receipts of the L1 block with ``: prepare the RLP pre-images of each of them, including receipts-list MPT nodes. -#### `l1-kzg-point-evaluation ` +#### `l1-kzg-point-evaluation ` Requests the host to prepare the result of the L1 KZG point evaluation precompile given -`` as the input. +`` as the input. The host also prepares a [global keccak256 preimage](#type-2-global-keccak256-key) +of the input. #### `l2-block-header ` @@ -433,6 +436,19 @@ Requests the host to prepare the L2 Output at the l2 output root ``. The L2 Output is the preimage of a [computed output root](../../protocol/proposals.md#l2-output-commitment-construction). +### Precompile Accelerators + +Precompiles that are too expensive to be executed in a fault-proof VM can be executed +more efficiently using the pre-image oracle. +This approach ensures that the fault proof program can complete a state transition in some +amount of time. + +During program execution, the precompiles are substituted with interactions with pre-image oracle. +An example of this is the KZG point evaluation precompile, where the program provides +the host with a hint for the point evaluation input. This allows it to subsequently retrieve the result +using a [type `6` pre-image key](#type-6-global-eip-4844-point-evaluation-precompile-key) from the oracle. +All accelerated precompiles must be functionally equivalent to their EVM equivalent. + ## Fault Proof VM [VM]: #Fault-Proof-VM From 421d1d286972863b42a0b2d964b28b2732a06544 Mon Sep 17 00:00:00 2001 From: inphi Date: Mon, 12 Feb 2024 18:08:00 -0500 Subject: [PATCH 3/5] nits --- specs/experimental/fault-proof/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/specs/experimental/fault-proof/index.md b/specs/experimental/fault-proof/index.md index 90d410a10..6c4e5fa22 100644 --- a/specs/experimental/fault-proof/index.md +++ b/specs/experimental/fault-proof/index.md @@ -447,7 +447,7 @@ During program execution, the precompiles are substituted with interactions with An example of this is the KZG point evaluation precompile, where the program provides the host with a hint for the point evaluation input. This allows it to subsequently retrieve the result using a [type `6` pre-image key](#type-6-global-eip-4844-point-evaluation-precompile-key) from the oracle. -All accelerated precompiles must be functionally equivalent to their EVM equivalent. +All accelerated precompiles must be functionally equivalent to their EVM equivalent. ## Fault Proof VM From 07b60469a51233989f153b085767aafbca342339 Mon Sep 17 00:00:00 2001 From: Inphi Date: Mon, 12 Feb 2024 18:37:24 -0500 Subject: [PATCH 4/5] Update specs/experimental/fault-proof/index.md Co-authored-by: Adrian Sutton --- specs/experimental/fault-proof/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/specs/experimental/fault-proof/index.md b/specs/experimental/fault-proof/index.md index 6c4e5fa22..5f58ee74b 100644 --- a/specs/experimental/fault-proof/index.md +++ b/specs/experimental/fault-proof/index.md @@ -161,7 +161,7 @@ Key: `5 ++ keccak256(commitment ++ z)[1:]`, where: #### Type `6`: Global EIP-4844 Point-evaluation precompile key -An EIP-4844 point-evaluation precompile result. It result maps directly to the EIP-4844 +An EIP-4844 point-evaluation precompile result. It maps directly to the EIP-4844 point-evaluation precompile introduced in Cancun. This preimage key can be used to avoid running expensive point-evaluation routine in From 956cc803dfdbccb4bf7e09b28905b3988d3d87a9 Mon Sep 17 00:00:00 2001 From: Inphi Date: Mon, 12 Feb 2024 18:37:46 -0500 Subject: [PATCH 5/5] Update specs/experimental/fault-proof/index.md Co-authored-by: Adrian Sutton --- specs/experimental/fault-proof/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/specs/experimental/fault-proof/index.md b/specs/experimental/fault-proof/index.md index 5f58ee74b..17f9a3962 100644 --- a/specs/experimental/fault-proof/index.md +++ b/specs/experimental/fault-proof/index.md @@ -440,7 +440,7 @@ The L2 Output is the preimage of a Precompiles that are too expensive to be executed in a fault-proof VM can be executed more efficiently using the pre-image oracle. -This approach ensures that the fault proof program can complete a state transition in some +This approach ensures that the fault proof program can complete a state transition in a reasonable amount of time. During program execution, the precompiles are substituted with interactions with pre-image oracle.