Skip to content

Made a test for reading block gas limit in contracts#337

Closed
joelamouche wants to merge 2 commits intomasterfrom
antoine-test-block-gas-limit-contract
Closed

Made a test for reading block gas limit in contracts#337
joelamouche wants to merge 2 commits intomasterfrom
antoine-test-block-gas-limit-contract

Conversation

@joelamouche
Copy link
Contributor

@joelamouche joelamouche commented Apr 8, 2021

What does it do?

  • deploys
pragma solidity >=0.8.0;

// Docs I'm following to get these properties
// https://docs.soliditylang.org/en/v0.8.2/units-and-global-variables.html

contract CheckBlockGasLimit {
    // This one is broken (evaluates to 0)
    uint public gas;
    // This one works
    uint public chainid;
    
    constructor() {
      gas = block.gaslimit;
      chainid = block.chainid;
   }
}
  • calls gas variable and check that it is>0
  • uses solc package to compile solidity into bytecode and abi

What important points reviewers should know?

Are there relevant PRs or issues in other repositories (Substrate, Polkadot, Frontier, Cumulus)?

polkadot-evm/frontier#327
polkadot-evm/frontier#332

Checklist

  • ❌ Does it require a purge of the network?
  • You bumped the runtime version if there are breaking changes in the runtime ?
  • ❌ Does it require changes in documentation/tutorials ?

@joelamouche joelamouche requested a review from JoshOrndorff April 8, 2021 11:45
Copy link
Contributor

@JoshOrndorff JoshOrndorff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test looks good. Thanks @joelamouche Mind if I take over this PR and merge it once I get the test passing?

import { AbiItem } from "web3-utils";
import solc from "solc";

export function compileSolidity(contractContent: string, contractName: string = "Test") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this is awesome! We should do all of our solidity-based tests this way.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So at first I thought to myself that the repo would be cleaner if we did this for every single contract but then I thought that recompiling every contract every test might slightly increase the duration of testing. Thoughts @crystalin @JoshOrndorff ?

@crystalin
Copy link
Collaborator

crystalin commented Apr 8, 2021 via email

@joelamouche
Copy link
Contributor Author

What do you mean by "kind of cache" ?

@crystalin
Copy link
Collaborator

crystalin commented Apr 8, 2021 via email

@crystalin
Copy link
Collaborator

Closing it in favor of #370

@crystalin crystalin closed this Apr 19, 2021
@joelamouche joelamouche deleted the antoine-test-block-gas-limit-contract branch June 3, 2021 09:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants