-
Notifications
You must be signed in to change notification settings - Fork 878
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 <[email protected]> * Fix null pointer exception Signed-off-by: Fabio Di Fabio <[email protected]> * fix another null pointer exception Signed-off-by: Fabio Di Fabio <[email protected]> * uncomment code Signed-off-by: Fabio Di Fabio <[email protected]> * Move miner options tests Signed-off-by: Fabio Di Fabio <[email protected]> * Unit test fixes Signed-off-by: Fabio Di Fabio <[email protected]> * Removed the commented code Signed-off-by: Fabio Di Fabio <[email protected]> * WIP Signed-off-by: Fabio Di Fabio <[email protected]> * WIP Signed-off-by: Fabio Di Fabio <[email protected]> * New miner option: min-priority-fee Signed-off-by: Fabio Di Fabio <[email protected]> * Remove not relevant for this feature Signed-off-by: Fabio Di Fabio <[email protected]> * Remove not relevant for this feature Signed-off-by: Fabio Di Fabio <[email protected]> * Fix javadoc Signed-off-by: Fabio Di Fabio <[email protected]> * Remove code not belonging to this PR Signed-off-by: Fabio Di Fabio <[email protected]> * coinbase is an updatable parameter Signed-off-by: Fabio Di Fabio <[email protected]> * Move MiningOptions to upper package Signed-off-by: Fabio Di Fabio <[email protected]> * Fix coinbase for *bft Signed-off-by: Fabio Di Fabio <[email protected]> * Implement methods to get and set min priority fee Signed-off-by: Gabriel-Trintinalia <[email protected]> * Fix spotless Signed-off-by: Gabriel-Trintinalia <[email protected]> * Apply suggestions from code review Signed-off-by: Fabio Di Fabio <[email protected]> * Update besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java [skip-ci] Co-authored-by: Sally MacFarlane <[email protected]> Signed-off-by: Fabio Di Fabio <[email protected]> * Add new config option to everything config Signed-off-by: Gabriel-Trintinalia <[email protected]> * Fix unit test Signed-off-by: Gabriel-Trintinalia <[email protected]> * Accept PR suggestions Signed-off-by: Gabriel-Trintinalia <[email protected]> --------- Signed-off-by: Fabio Di Fabio <[email protected]> Signed-off-by: Gabriel-Trintinalia <[email protected]> Signed-off-by: Stefan Pingel <[email protected]> Co-authored-by: Fabio Di Fabio <[email protected]> Co-authored-by: Sally MacFarlane <[email protected]> Co-authored-by: Stefan Pingel <[email protected]>
- 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.