-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
linea_estimateGas compatibility switch (#634)
Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net> Co-authored-by: Sally MacFarlane <macfarla.github@gmail.com>
- Loading branch information
Showing
7 changed files
with
259 additions
and
41 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
...tests/src/test/java/linea/plugin/acc/test/rpc/linea/EstimateGasCompatibilityModeTest.java
This file contains 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 |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Copyright Consensys Software Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations under the License. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
package linea.plugin.acc.test.rpc.linea; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import java.util.List; | ||
|
||
import org.hyperledger.besu.datatypes.Wei; | ||
import org.hyperledger.besu.ethereum.core.Transaction; | ||
|
||
public class EstimateGasCompatibilityModeTest extends EstimateGasTest { | ||
|
||
@Override | ||
public List<String> getTestCliOptions() { | ||
return getTestCommandLineOptionsBuilder() | ||
.set("--plugin-linea-estimate-gas-compatibility-mode-enabled=", "true") | ||
.build(); | ||
} | ||
|
||
@Override | ||
protected void assertIsProfitable( | ||
final Transaction tx, | ||
final Wei estimatedPriorityFee, | ||
final Wei estimatedMaxGasPrice, | ||
final long estimatedGasLimit) { | ||
final var minGasPrice = minerNode.getMiningParameters().getMinTransactionGasPrice(); | ||
|
||
// since we are in compatibility mode, we want to check that returned profitable priority fee is | ||
// the min mineable gas price | ||
assertThat(estimatedMaxGasPrice).isEqualTo(minGasPrice); | ||
} | ||
} |
This file contains 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 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
73 changes: 73 additions & 0 deletions
73
arithmetization/src/main/java/net/consensys/linea/config/LineaRpcCliOptions.java
This file contains 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 |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* | ||
* Copyright Consensys Software Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations under the License. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package net.consensys.linea.config; | ||
|
||
import com.google.common.base.MoreObjects; | ||
import picocli.CommandLine; | ||
|
||
/** The Linea RPC CLI options. */ | ||
public class LineaRpcCliOptions { | ||
private static final String ESTIMATE_GAS_COMPATIBILITY_MODE_ENABLED = | ||
"--plugin-linea-estimate-gas-compatibility-mode-enabled"; | ||
|
||
@CommandLine.Option( | ||
names = {ESTIMATE_GAS_COMPATIBILITY_MODE_ENABLED}, | ||
paramLabel = "<BOOLEAN>", | ||
description = | ||
"Set to true to return the min mineable gas price, instead of the profitable price (default: ${DEFAULT-VALUE})") | ||
private boolean estimateGasCompatibilityModeEnabled = false; | ||
|
||
private LineaRpcCliOptions() {} | ||
|
||
/** | ||
* Create Linea RPC CLI options. | ||
* | ||
* @return the Linea RPC CLI options | ||
*/ | ||
public static LineaRpcCliOptions create() { | ||
return new LineaRpcCliOptions(); | ||
} | ||
|
||
/** | ||
* Linea RPC CLI options from config. | ||
* | ||
* @param config the config | ||
* @return the Linea RPC CLI options | ||
*/ | ||
public static LineaRpcCliOptions fromConfig(final LineaRpcConfiguration config) { | ||
final LineaRpcCliOptions options = create(); | ||
options.estimateGasCompatibilityModeEnabled = config.estimateGasCompatibilityModeEnabled(); | ||
return options; | ||
} | ||
|
||
/** | ||
* To domain object Linea factory configuration. | ||
* | ||
* @return the Linea factory configuration | ||
*/ | ||
public LineaRpcConfiguration toDomainObject() { | ||
return LineaRpcConfiguration.builder() | ||
.estimateGasCompatibilityModeEnabled(estimateGasCompatibilityModeEnabled) | ||
.build(); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return MoreObjects.toStringHelper(this) | ||
.add(ESTIMATE_GAS_COMPATIBILITY_MODE_ENABLED, estimateGasCompatibilityModeEnabled) | ||
.toString(); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
arithmetization/src/main/java/net/consensys/linea/config/LineaRpcConfiguration.java
This file contains 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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
* Copyright Consensys Software Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations under the License. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package net.consensys.linea.config; | ||
|
||
import lombok.Builder; | ||
|
||
/** The Linea RPC configuration. */ | ||
@Builder(toBuilder = true) | ||
public record LineaRpcConfiguration(boolean estimateGasCompatibilityModeEnabled) {} |
This file contains 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
Oops, something went wrong.