-
Notifications
You must be signed in to change notification settings - Fork 867
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
KZG point eval precompile #4860
Conversation
14c8dfd
to
6e98f95
Compare
evm/src/main/java/org/hyperledger/besu/evm/precompile/KZGPointEvalPrecompiledContract.java
Fixed
Show fixed
Hide fixed
524830b
to
2e21716
Compare
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.
Added some comments but still want to understand and play with the tests a bit more.
Regarding the task list on #4822...
- package the mainnet kzg trusted setup file so it is delivered via distribution in such a way that it can be loaded by native lib from the filesystem; loading from classpath won't work.
What was the solution for this?
- add support for reftests that cover it
Was this done in this PR?
evm/src/main/java/org/hyperledger/besu/evm/internal/EvmConfiguration.java
Outdated
Show resolved
Hide resolved
evm/src/main/java/org/hyperledger/besu/evm/internal/EvmConfiguration.java
Outdated
Show resolved
Hide resolved
evm/src/main/java/org/hyperledger/besu/evm/precompile/MainnetPrecompiledContracts.java
Show resolved
Hide resolved
ethereum/p2p/src/test/java/org/hyperledger/besu/ethereum/p2p/peers/EnodeURLImplTest.java
Outdated
Show resolved
Hide resolved
evm/src/main/java/org/hyperledger/besu/evm/precompile/KZGPointEvalPrecompiledContract.java
Outdated
Show resolved
Hide resolved
evm/src/test/java/org/hyperledger/besu/evm/precompile/KZGPointEvalPrecompileContractTest.java
Show resolved
Hide resolved
evm/src/test/java/org/hyperledger/besu/evm/precompile/KZGPointEvalPrecompileContractTest.java
Show resolved
Hide resolved
evm/src/main/java/org/hyperledger/besu/evm/precompile/MainnetPrecompiledContracts.java
Show resolved
Hide resolved
Signed-off-by: Justin Florentine <justin+github@florentine.us>
Signed-off-by: Justin Florentine <justin+github@florentine.us>
Loading from classpath is fine, and user will be able to override that later. We are still waiting on retesteth updates to cover it. |
Signed-off-by: Justin Florentine <justin+github@florentine.us>
2e21716
to
685cb10
Compare
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.
looks good, please check the comments
...rc/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetPrecompiledContractRegistries.java
Show resolved
Hide resolved
besu/src/main/java/org/hyperledger/besu/cli/options/unstable/EvmOptions.java
Outdated
Show resolved
Hide resolved
evm/src/main/java/org/hyperledger/besu/evm/internal/EvmConfiguration.java
Outdated
Show resolved
Hide resolved
evm/src/main/java/org/hyperledger/besu/evm/precompile/KZGPointEvalPrecompiledContract.java
Outdated
Show resolved
Hide resolved
evm/src/main/java/org/hyperledger/besu/evm/precompile/KZGPointEvalPrecompiledContract.java
Outdated
Show resolved
Hide resolved
evm/src/main/java/org/hyperledger/besu/evm/precompile/KZGPointEvalPrecompiledContract.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Justin Florentine <justin+github@florentine.us>
Signed-off-by: Justin Florentine <justin+github@florentine.us>
Signed-off-by: Justin Florentine <justin+github@florentine.us>
Signed-off-by: Justin Florentine <justin+github@florentine.us>
Signed-off-by: Justin Florentine <justin+github@florentine.us>
…GpointEvalPrecompile
Signed-off-by: Justin Florentine <justin+github@florentine.us>
Signed-off-by: Justin Florentine <justin+github@florentine.us>
Signed-off-by: Justin Florentine <justin+github@florentine.us>
Signed-off-by: Justin Florentine <justin+github@florentine.us>
Signed-off-by: Justin Florentine <justin+github@florentine.us>
Signed-off-by: Justin Florentine <justin+github@florentine.us>
Signed-off-by: Justin Florentine <justin+github@florentine.us>
2bad3ed
to
c4b9ece
Compare
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.
Some old and new comments
besu/src/main/java/org/hyperledger/besu/cli/options/unstable/EvmOptions.java
Outdated
Show resolved
Hide resolved
ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetProtocolSpecs.java
Outdated
Show resolved
Hide resolved
evm/src/main/java/org/hyperledger/besu/evm/internal/EvmConfiguration.java
Outdated
Show resolved
Hide resolved
evm/src/main/java/org/hyperledger/besu/evm/precompile/KZGPointEvalPrecompiledContract.java
Show resolved
Hide resolved
evm/src/main/java/org/hyperledger/besu/evm/precompile/KZGPointEvalPrecompiledContract.java
Outdated
Show resolved
Hide resolved
evm/src/main/java/org/hyperledger/besu/evm/precompile/KZGPointEvalPrecompiledContract.java
Outdated
Show resolved
Hide resolved
…GpointEvalPrecompile
Signed-off-by: Justin Florentine <justin+github@florentine.us>
Signed-off-by: Justin Florentine <justin+github@florentine.us>
Signed-off-by: Justin Florentine <justin+github@florentine.us>
KZGPointEvalPrecompiledContract.class.getResourceAsStream( | ||
"mainnet_kzg_trusted_setup_4096.txt"); | ||
try { | ||
File jniWillLoadFrom = File.createTempFile("kzgTrustedSetup", "txt"); |
Check warning
Code scanning / CodeQL
Local information disclosure in a temporary directory
Signed-off-by: Justin Florentine <justin+github@florentine.us>
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.
LGTM, just a nit
jumpDestCacheWeightKilobytes, Optional.ofNullable(kzgTrustedSetupFilePath)); | ||
jumpDestCacheWeightKilobytes, | ||
kzgTrustedSetupFilePath != null | ||
? Optional.ofNullable(Path.of(kzgTrustedSetupFilePath)) |
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.
nit: result of Path::of is never null
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.
This is not a base level configuration option. This is the wrong place in code to do it. It should be an argument in the MainnetEVMs methods for relevant versions.
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.
I don't like how the KZG files are being brought in. Especially if we already have hard-coded a default as part of the library. It's a config for one precompile so it shouldn't impact the configuration of the base EVM.
Also, once it's up and running how often will alternate KZGs be brought in? Do we really need configurability?
@@ -29,6 +31,8 @@ public class EvmOptions implements CLIOptions<EvmConfiguration> { | |||
/** The constant JUMPDEST_CACHE_WEIGHT. */ | |||
public static final String JUMPDEST_CACHE_WEIGHT = "--Xevm-jumpdest-cache-weight-kb"; | |||
|
|||
public static final String KZG_TRUSTED_SETUP_FILE_PATH = "--evm-kzg-trusted-setup-path"; |
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.
I think this should be an --X
option. Once the ceremony is done we will have the kzg embedded in the distribution, correct? So this is just transitional for testing?
jumpDestCacheWeightKilobytes, Optional.ofNullable(kzgTrustedSetupFilePath)); | ||
jumpDestCacheWeightKilobytes, | ||
kzgTrustedSetupFilePath != null | ||
? Optional.ofNullable(Path.of(kzgTrustedSetupFilePath)) |
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.
This is not a base level configuration option. This is the wrong place in code to do it. It should be an argument in the MainnetEVMs methods for relevant versions.
build.gradle
Outdated
@@ -109,7 +109,7 @@ allprojects { | |||
} | |||
maven { | |||
url 'https://artifacts.consensys.net/public/maven/maven/' | |||
content { includeGroupByRegex('tech\\.pegasys\\..*') } | |||
content { includeGroupByRegex('tech\\.pegasys.*') } |
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.
content { includeGroupByRegex('tech\\.pegasys.*') } | |
content { includeGroupByRegex('tech\\.pegasys(\\..*)?') } |
Removing the dot opens the door wide to uncontrolled DNS names like tech.pegasys-but-not-really:comprimised-kzg
. Instead it should be listed as an optional section.
@@ -71,7 +71,8 @@ public class Address extends DelegatingBytes implements org.hyperledger.besu.plu | |||
/** The constant BLS12_MAP_FP2_TO_G2. */ | |||
public static final Address BLS12_MAP_FP2_TO_G2 = Address.precompiled(0x12); | |||
|
|||
/** The constant ZERO. */ | |||
public static final Address KZG_POINT_EVAL = Address.precompiled(0x14); |
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.
Is this address fixed already? Has BLS been "locked in" to those addresses?
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.
As far as i know it is, the specs have been stable on it.
ethereum/core/build.gradle
Outdated
repositories { | ||
maven { url "https://artifacts.consensys.net/public/maven/maven/" } | ||
} | ||
|
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.
This should not be needed here and should be removed. The repository is already enumerated in the parent build file.
ethereum/core/build.gradle
Outdated
@@ -54,6 +58,7 @@ dependencies { | |||
implementation 'org.apache.tuweni:tuweni-concurrent' | |||
implementation 'org.apache.tuweni:tuweni-units' | |||
implementation 'org.apache.tuweni:tuweni-rlp' | |||
implementation 'tech.pegasys:jc-kzg-4844:0.1.0' |
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.
Versions should not be listed in child build files. Please add an entry to <root>/gradle/versions.gradle
evm/build.gradle
Outdated
repositories { | ||
maven { url "https://artifacts.consensys.net/public/maven/maven/" } | ||
} |
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.
This should not be here, the root gradle should cover this. If it doesn't it should be fixed there.
evm/src/main/java/org/hyperledger/besu/evm/internal/EvmConfiguration.java
Outdated
Show resolved
Hide resolved
Yeah, the cart may be before the horse. I'm gonna remove configurability for interop, and we can add it back in if we actually discover a use case for it. |
Signed-off-by: Justin Florentine <justin+github@florentine.us>
…ry load time Signed-off-by: Justin Florentine <justin+github@florentine.us>
Signed-off-by: Justin Florentine <justin+github@florentine.us>
* KZG implementation Signed-off-by: Justin Florentine <justin+github@florentine.us>
* KZG implementation Signed-off-by: Justin Florentine <justin+github@florentine.us>
* KZG implementation Signed-off-by: Justin Florentine <justin+github@florentine.us>
PR description
Adds a new precompile as part of EIP-4844 which allows contracts to evaluate KZG commitments.
Fixed Issue(s)
fixes #4822
Documentation
doc-change-required
label to this PR ifupdates are required.
Changelog