-
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.
feat: Report rejected transactions to an external service for tx pool…
… validators used by LineaTransactionPoolValidatorPlugin (#85) * Extract reporting endpoint URI cli option * Linea Transaction Pool Validator to report rejected tx * Linea node type and refactored request builder * Update unit tests to use refactored generateSaveRejectedTxJsonRpc * Use transactionSelectionResult.toString in LineaTransactionSelector * Use Mutually exclusive = false for co-dep cli options * Add unit test for cli options. Change endpoint type to URL * JsonRpcManager - Use plugin identifier to create sub directories to store rpc calls * JsonRpcManager convert submitNewJsonRpcCall to do async chaining before calling submitJsonRpcCall * Add rej tx reporting to all tx pool validators
- Loading branch information
1 parent
fcd99a4
commit 8e9fe21
Showing
28 changed files
with
773 additions
and
174 deletions.
There are no files selected for viewing
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
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
23 changes: 23 additions & 0 deletions
23
sequencer/src/main/java/net/consensys/linea/config/LineaNodeType.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,23 @@ | ||
/* | ||
* 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; | ||
|
||
/** Linea node type that is used when reporting rejected transactions. */ | ||
public enum LineaNodeType { | ||
SEQUENCER, | ||
RPC, | ||
P2P | ||
} |
117 changes: 117 additions & 0 deletions
117
sequencer/src/main/java/net/consensys/linea/config/LineaRejectedTxReportingCliOptions.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,117 @@ | ||
/* | ||
* 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 java.net.URL; | ||
import java.util.Optional; | ||
|
||
import com.google.common.base.MoreObjects; | ||
import net.consensys.linea.plugins.LineaCliOptions; | ||
import picocli.CommandLine.ArgGroup; | ||
import picocli.CommandLine.Option; | ||
|
||
/** The Linea Rejected Transaction Reporting CLI options. */ | ||
public class LineaRejectedTxReportingCliOptions implements LineaCliOptions { | ||
/** | ||
* The configuration key used in AbstractLineaPrivateOptionsPlugin to identify the cli options. | ||
*/ | ||
public static final String CONFIG_KEY = "rejected-tx-reporting-config"; | ||
|
||
/** The rejected transaction endpoint. */ | ||
public static final String REJECTED_TX_ENDPOINT = "--plugin-linea-rejected-tx-endpoint"; | ||
|
||
/** The Linea node type. */ | ||
public static final String LINEA_NODE_TYPE = "--plugin-linea-node-type"; | ||
|
||
@ArgGroup(exclusive = false) | ||
DependentOptions dependentOptions; // will be null if no options from this group are specified | ||
|
||
static class DependentOptions { | ||
@Option( | ||
names = {REJECTED_TX_ENDPOINT}, | ||
hidden = true, | ||
required = true, // required within the group | ||
paramLabel = "<URL>", | ||
description = | ||
"Endpoint URI for reporting rejected transactions. Specify a valid URI to enable reporting.") | ||
URL rejectedTxEndpoint = null; | ||
|
||
@Option( | ||
names = {LINEA_NODE_TYPE}, | ||
hidden = true, | ||
required = true, // required within the group | ||
paramLabel = "<NODE_TYPE>", | ||
description = | ||
"Linea Node type to use when reporting rejected transactions. (default: ${DEFAULT-VALUE}. Valid values: ${COMPLETION-CANDIDATES})") | ||
LineaNodeType lineaNodeType = null; | ||
} | ||
|
||
/** Default constructor. */ | ||
private LineaRejectedTxReportingCliOptions() {} | ||
|
||
/** | ||
* Create Linea Rejected Transaction Reporting CLI options. | ||
* | ||
* @return the Linea Rejected Transaction Reporting CLI options | ||
*/ | ||
public static LineaRejectedTxReportingCliOptions create() { | ||
return new LineaRejectedTxReportingCliOptions(); | ||
} | ||
|
||
/** | ||
* Instantiates a new Linea rejected tx reporting cli options from Configuration object | ||
* | ||
* @param config An instance of LineaRejectedTxReportingConfiguration | ||
*/ | ||
public static LineaRejectedTxReportingCliOptions fromConfig( | ||
final LineaRejectedTxReportingConfiguration config) { | ||
final LineaRejectedTxReportingCliOptions options = create(); | ||
// both options are required. | ||
if (config.rejectedTxEndpoint() != null && config.lineaNodeType() != null) { | ||
final var depOpts = new DependentOptions(); | ||
depOpts.rejectedTxEndpoint = config.rejectedTxEndpoint(); | ||
depOpts.lineaNodeType = config.lineaNodeType(); | ||
options.dependentOptions = depOpts; | ||
} | ||
|
||
return options; | ||
} | ||
|
||
@Override | ||
public LineaRejectedTxReportingConfiguration toDomainObject() { | ||
final var rejectedTxEndpoint = | ||
Optional.ofNullable(dependentOptions).map(o -> o.rejectedTxEndpoint).orElse(null); | ||
final var lineaNodeType = | ||
Optional.ofNullable(dependentOptions).map(o -> o.lineaNodeType).orElse(null); | ||
|
||
return LineaRejectedTxReportingConfiguration.builder() | ||
.rejectedTxEndpoint(rejectedTxEndpoint) | ||
.lineaNodeType(lineaNodeType) | ||
.build(); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
final var rejectedTxEndpoint = | ||
Optional.ofNullable(dependentOptions).map(o -> o.rejectedTxEndpoint).orElse(null); | ||
final var lineaNodeType = | ||
Optional.ofNullable(dependentOptions).map(o -> o.lineaNodeType).orElse(null); | ||
|
||
return MoreObjects.toStringHelper(this) | ||
.add(REJECTED_TX_ENDPOINT, rejectedTxEndpoint) | ||
.add(LINEA_NODE_TYPE, lineaNodeType) | ||
.toString(); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
...encer/src/main/java/net/consensys/linea/config/LineaRejectedTxReportingConfiguration.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,26 @@ | ||
/* | ||
* 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 java.net.URL; | ||
|
||
import lombok.Builder; | ||
import net.consensys.linea.plugins.LineaOptionsConfiguration; | ||
|
||
/** Linea Rejected Transactions Reporting Configuration */ | ||
@Builder(toBuilder = true) | ||
public record LineaRejectedTxReportingConfiguration( | ||
URL rejectedTxEndpoint, LineaNodeType lineaNodeType) implements LineaOptionsConfiguration {} |
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.