Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hardhat_api: Implement hardhat_setNextBlockBaseFeePerGas method #150

Open
4 tasks
dutterbutter opened this issue Sep 28, 2023 · 1 comment
Open
4 tasks
Labels
hardhat_api 👷 Indicates hardhat namespace api tasks medium 🚩 Indicates moderately difficult item p2 🟡 Indicates moderately high priority item

Comments

@dutterbutter
Copy link
Collaborator

Description:

The hardhat_setNextBlockBaseFeePerGas endpoint needs to be implemented. This endpoint is designed to set the base fee for the next block. Refer to the Hardhat documentation for more details. Test implementations can be derived from the Hardhat repo here.

// Interface in the `trait`
#[rpc(name = "hardhat_setNextBlockBaseFeePerGas")]
fn set_next_block_base_fee_per_gas(&self, base_fee_per_gas: U256) -> BoxFuture<Result<bool>>;

// Actual code in the `impl`
fn set_next_block_base_fee_per_gas(&self, base_fee_per_gas: U256) -> BoxFuture<Result<bool>> {
    // TODO: Solution here
}

JS implementation:

/**
 * Sets the base fee of the next block.
 *
 * @param baseFeePerGas The new base fee to use.
 */
export async function setNextBlockBaseFeePerGas(baseFeePerGas: NumberLike): Promise<void> {
  const provider = await getHardhatProvider();

  const baseFeePerGasHex = toRpcQuantity(baseFeePerGas);

  await provider.request({
    method: "hardhat_setNextBlockBaseFeePerGas",
    params: [baseFeePerGasHex],
  });
}

Expected response

Command to test the endpoint:

curl -X POST http://localhost:8011 \
     -H "Content-Type: application/json" \
     --data '{
       "jsonrpc": "2.0",
       "id": 1,
       "method": "hardhat_setNextBlockBaseFeePerGas",
       "params": ["0x2540be400"]
     }'

Response should be:

{"jsonrpc":"2.0", "result":true, "id":1}

Requirements:

  1. Implement the API:

    • The endpoint should return true if successful in setting the base fee for the next block, otherwise false.
    • Ensure the method executes the call reliably and efficiently.
    • Errors must be handled appropriately and returned accordingly.
  2. Unit Tests:

    • Compose unit tests to verify the setNextBlockBaseFeePerGas method functionality.
    • Ensure coverage for multiple edge-case scenarios.
  3. Documentation:

    • Append inline Rust documentation (/// comments) detailing the method's purpose, potential return values, and any significant edge cases or errors.
    • Update the documentation and examples in SUPPORTED_APIS.md.
    • Optionally, include this request in test_endpoints.http for more straightforward manual testing.

Task Checklist:

  • Implement the setNextBlockBaseFeePerGas method.
  • Write unit tests for the setNextBlockBaseFeePerGas method.
  • Add inline documentation for the hardhat_setNextBlockBaseFeePerGas endpoint.
  • Update documentation for the hardhat_dropTransaction endpoint in SUPPORTED_APIS.md.

Additional Notes:

If you're an external contributor looking to take on this issue, please comment below to let us know you're working on it. If you need further clarification on the requirements or need assistance with anything related to the implementation, feel free to ask!

@dutterbutter dutterbutter added the hardhat_api 👷 Indicates hardhat namespace api tasks label Sep 28, 2023
@dutterbutter dutterbutter moved this to Todo 🔨 in Progress Board Sep 28, 2023
@MexicanAce MexicanAce added p2 🟡 Indicates moderately high priority item medium 🚩 Indicates moderately difficult item labels Oct 5, 2023
@nbaztec
Copy link
Contributor

nbaztec commented Oct 13, 2023

While working on this issue it came out that the bootloader would reject any transactions that have their enforced_base_fee parameter set to anything other than what it expects, which is currently 250_000_000.

image

For the implementation WIP, see https://github.com/Moonsong-Labs/era-test-node/tree/nish-fix-150-upstream

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hardhat_api 👷 Indicates hardhat namespace api tasks medium 🚩 Indicates moderately difficult item p2 🟡 Indicates moderately high priority item
Projects
Status: Todo 🔨
Development

No branches or pull requests

3 participants