-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extend Module Line Count Verification to
linea_estimateGas
RPC Meth…
…od (#1) Signed-off-by: Gabriel-Trintinalia <[email protected]>
- Loading branch information
1 parent
9dbea10
commit 0be75a3
Showing
17 changed files
with
721 additions
and
128 deletions.
There are no files selected for viewing
63 changes: 63 additions & 0 deletions
63
...sts/src/test/java/linea/plugin/acc/test/rpc/linea/EstimateGasModuleLimitOverflowTest.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,63 @@ | ||
/* | ||
* 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.math.BigInteger; | ||
import java.nio.charset.StandardCharsets; | ||
import java.util.List; | ||
|
||
import linea.plugin.acc.test.LineaPluginTestBase; | ||
import linea.plugin.acc.test.TestCommandLineOptionsBuilder; | ||
import linea.plugin.acc.test.tests.web3j.generated.SimpleStorage; | ||
import org.apache.tuweni.bytes.Bytes; | ||
import org.hyperledger.besu.tests.acceptance.dsl.account.Account; | ||
import org.junit.jupiter.api.Test; | ||
|
||
public class EstimateGasModuleLimitOverflowTest extends LineaPluginTestBase { | ||
@Override | ||
public List<String> getTestCliOptions() { | ||
return new TestCommandLineOptionsBuilder() | ||
.set( | ||
"--plugin-linea-module-limit-file-path=", | ||
getResourcePath("/txOverflowModuleLimits.toml")) | ||
.build(); | ||
} | ||
|
||
@Test | ||
public void estimateGasFailsForExceedingModuleLineCountTest() throws Exception { | ||
|
||
final Account sender = accounts.getSecondaryBenefactor(); | ||
|
||
final SimpleStorage simpleStorage = deploySimpleStorage(); | ||
final String txData = simpleStorage.add(BigInteger.valueOf(100)).encodeFunctionCall(); | ||
final var payload = Bytes.wrap(txData.getBytes(StandardCharsets.UTF_8)); | ||
|
||
final EstimateGasTest.CallParams callParams = | ||
new EstimateGasTest.CallParams( | ||
sender.getAddress(), | ||
simpleStorage.getContractAddress(), | ||
null, | ||
payload.toHexString(), | ||
"0"); | ||
|
||
final var reqLinea = new EstimateGasTest.BadLineaEstimateGasRequest(callParams); | ||
final var respLinea = reqLinea.execute(minerNode.nodeRequests()); | ||
assertThat(respLinea.getCode()).isEqualTo(-32000); | ||
assertThat(respLinea.getMessage()) | ||
.isEqualTo("Transaction line count for module HUB=66 is above the limit 30"); | ||
} | ||
} |
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
22 changes: 22 additions & 0 deletions
22
arithmetization/src/main/java/net/consensys/linea/config/LineaTracerConfiguration.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 tracer configuration. */ | ||
@Builder(toBuilder = true) | ||
public record LineaTracerConfiguration(String moduleLimitsFilePath) {} |
72 changes: 72 additions & 0 deletions
72
...tization/src/main/java/net/consensys/linea/config/LineaTracerConfigurationCLiOptions.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,72 @@ | ||
/* | ||
* 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; | ||
|
||
public class LineaTracerConfigurationCLiOptions { | ||
|
||
public static final String MODULE_LIMIT_FILE_PATH = "--plugin-linea-module-limit-file-path"; | ||
public static final String DEFAULT_MODULE_LIMIT_FILE_PATH = "moduleLimitFile.toml"; | ||
|
||
@CommandLine.Option( | ||
names = {MODULE_LIMIT_FILE_PATH}, | ||
hidden = true, | ||
paramLabel = "<STRING>", | ||
description = | ||
"Path to the toml file containing the module limits (default: ${DEFAULT-VALUE})") | ||
private String moduleLimitFilePath = DEFAULT_MODULE_LIMIT_FILE_PATH; | ||
|
||
private LineaTracerConfigurationCLiOptions() {} | ||
|
||
/** | ||
* Create Linea cli options. | ||
* | ||
* @return the Linea cli options | ||
*/ | ||
public static LineaTracerConfigurationCLiOptions create() { | ||
return new LineaTracerConfigurationCLiOptions(); | ||
} | ||
|
||
/** | ||
* Linea cli options from config. | ||
* | ||
* @param config the config | ||
* @return the Linea cli options | ||
*/ | ||
public static LineaTracerConfigurationCLiOptions fromConfig( | ||
final LineaTracerConfiguration config) { | ||
final LineaTracerConfigurationCLiOptions options = create(); | ||
options.moduleLimitFilePath = config.moduleLimitsFilePath(); | ||
return options; | ||
} | ||
|
||
/** | ||
* To domain object Linea factory configuration. | ||
* | ||
* @return the Linea factory configuration | ||
*/ | ||
public LineaTracerConfiguration toDomainObject() { | ||
return LineaTracerConfiguration.builder().moduleLimitsFilePath(moduleLimitFilePath).build(); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return MoreObjects.toStringHelper(this) | ||
.add(MODULE_LIMIT_FILE_PATH, moduleLimitFilePath) | ||
.toString(); | ||
} | ||
} |
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
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.