-
Notifications
You must be signed in to change notification settings - Fork 862
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement miner_setMinPriorityFee and miner_getMinPriorityFee (#6080)
* Refactor mining options Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net> * Fix null pointer exception Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net> * fix another null pointer exception Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net> * uncomment code Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net> * Move miner options tests Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net> * Unit test fixes Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net> * Removed the commented code Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net> * WIP Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net> * WIP Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net> * New miner option: min-priority-fee Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net> * Remove not relevant for this feature Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net> * Remove not relevant for this feature Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net> * Fix javadoc Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net> * Remove code not belonging to this PR Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net> * coinbase is an updatable parameter Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net> * Move MiningOptions to upper package Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net> * Fix coinbase for *bft Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net> * Implement methods to get and set min priority fee Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net> * Fix spotless Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net> * Apply suggestions from code review Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net> * Update besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java [skip-ci] Co-authored-by: Sally MacFarlane <macfarla.github@gmail.com> Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net> * Add new config option to everything config Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net> * Fix unit test Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net> * Accept PR suggestions Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net> --------- Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net> Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net> Signed-off-by: Stefan Pingel <16143240+pinges@users.noreply.github.com> Co-authored-by: Fabio Di Fabio <fabio.difabio@consensys.net> Co-authored-by: Sally MacFarlane <macfarla.github@gmail.com> Co-authored-by: Stefan Pingel <16143240+pinges@users.noreply.github.com>
- Loading branch information
1 parent
20f518e
commit 3310c41
Showing
21 changed files
with
295 additions
and
4 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
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
41 changes: 41 additions & 0 deletions
41
.../hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerGetMinPriorityFee.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,41 @@ | ||
/* | ||
* Copyright Hyperledger Besu Contributors. | ||
* | ||
* 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 org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.miner; | ||
|
||
import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod; | ||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext; | ||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod; | ||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse; | ||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse; | ||
import org.hyperledger.besu.ethereum.core.MiningParameters; | ||
|
||
public class MinerGetMinPriorityFee implements JsonRpcMethod { | ||
private final MiningParameters miningParameters; | ||
|
||
public MinerGetMinPriorityFee(final MiningParameters miningParameters) { | ||
this.miningParameters = miningParameters; | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return RpcMethod.MINER_GET_MIN_PRIORITY_FEE.getMethodName(); | ||
} | ||
|
||
@Override | ||
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) { | ||
return new JsonRpcSuccessResponse( | ||
requestContext.getRequest().getId(), miningParameters.getMinPriorityFeePerGas().getValue()); | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
.../hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerSetMinPriorityFee.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,53 @@ | ||
/* | ||
* Copyright Hyperledger Besu Contributors. | ||
* | ||
* 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 org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.miner; | ||
|
||
import org.hyperledger.besu.datatypes.Wei; | ||
import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod; | ||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext; | ||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod; | ||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse; | ||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse; | ||
import org.hyperledger.besu.ethereum.core.MiningParameters; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
public class MinerSetMinPriorityFee implements JsonRpcMethod { | ||
private static final Logger LOG = LoggerFactory.getLogger(MinerSetMinPriorityFee.class); | ||
|
||
private final MiningParameters miningParameters; | ||
|
||
public MinerSetMinPriorityFee(final MiningParameters miningParameters) { | ||
this.miningParameters = miningParameters; | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return RpcMethod.MINER_SET_MIN_PRIORITY_FEE.getMethodName(); | ||
} | ||
|
||
@Override | ||
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) { | ||
try { | ||
final Wei minPriorityFeePerGas = Wei.of(requestContext.getRequiredParameter(0, Long.class)); | ||
miningParameters.setMinPriorityFeePerGas(minPriorityFeePerGas); | ||
LOG.debug("min priority fee per gas changed to {}", minPriorityFeePerGas); | ||
return new JsonRpcSuccessResponse(requestContext.getRequest().getId(), true); | ||
} catch (final IllegalArgumentException invalidJsonRpcParameters) { | ||
return new JsonRpcSuccessResponse(requestContext.getRequest().getId(), false); | ||
} | ||
} | ||
} |
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
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.