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

EVM version #3569

Merged
merged 19 commits into from
Mar 5, 2018
Merged

EVM version #3569

merged 19 commits into from
Mar 5, 2018

Conversation

chriseth
Copy link
Contributor

@chriseth chriseth commented Feb 21, 2018

  • tests for metadata

Fixes #3273.

@chriseth chriseth requested a review from axic February 21, 2018 22:57
static EVMVersion homestead() { return {Version::Homestead}; }
static EVMVersion byzantium() { return {Version::Byzantium}; }

static boost::optional<EVMVersion> fromString(std::string const& _version)
Copy link
Member

Choose a reason for hiding this comment

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

Are we moving over to boost::optional? A lot of places started to use it now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just think it is very convenient in this situation.

@chriseth
Copy link
Contributor Author

Ready for review.

@chriseth chriseth force-pushed the evmVersion branch 4 times, most recently from 72354bb to 8833711 Compare February 26, 2018 17:02
@chriseth
Copy link
Contributor Author

@axic ready for review.

@chriseth
Copy link
Contributor Author

Actually I just realized we have a third test combination to run: contracts compiled for homestead, running on a byzantium VM...

if (futureInstructions.count(_instr))
// We assume that returndatacopy, returndatasize and staticcall are either all available
// or all not available.
solAssert(m_evmVersion.hasReturndatacopy() == m_evmVersion.hasStaticCall(), "");
Copy link
Member

Choose a reason for hiding this comment

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

Does hasReturndatacopy also means hasReturndatasize?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I can rename it to hasReturndatacopyAndReturndatasize or add a comment.

Copy link
Member

Choose a reason for hiding this comment

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

I think a comment is enough. Maybe hasReturndata was the generic name of the feature?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will change it to supportsReturndata.

@@ -224,6 +231,7 @@ void RPCSession::test_setChainParams(vector<string> const& _accounts)
"blockReward": "0x",
"allowFutureBlocks": true,
"homesteadForkBlock": "0x00",
)" + enableByzantium + R"(
"EIP150ForkBlock": "0x00",
Copy link
Member

Choose a reason for hiding this comment

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

This is "tangerine whistle".

@@ -224,6 +231,7 @@ void RPCSession::test_setChainParams(vector<string> const& _accounts)
"blockReward": "0x",
"allowFutureBlocks": true,
"homesteadForkBlock": "0x00",
)" + enableByzantium + R"(
"EIP150ForkBlock": "0x00",
"EIP158ForkBlock": "0x00"
Copy link
Member

Choose a reason for hiding this comment

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

This is "spurious dragon".

@@ -44,6 +44,8 @@ class JSONInterfaceChecker
{
m_compilerStack.reset(false);
m_compilerStack.addSource("", "pragma solidity >=0.0;\n" + _code);
m_compilerStack.setEVMVersion(dev::test::Options::get().evmVersion());
m_compilerStack.setOptimiserSettings(dev::test::Options::get().optimize);
Copy link
Member

Choose a reason for hiding this comment

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

This was missed but shouldn't make any difference.

@@ -6857,7 +6857,7 @@ BOOST_AUTO_TEST_CASE(create2_as_variable)
)";
CHECK_ALLOW_MULTI(text, (std::vector<std::pair<Error::Type, std::string>>{
{Error::Type::Warning, "Variable is shadowed in inline assembly by an instruction of the same name"},
{Error::Type::Warning, "only available after the Metropolis"},
{Error::Type::Warning, "The \"create2\" instruction is not supported for the VM version"},
Copy link
Member

Choose a reason for hiding this comment

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

"for the"? Shouldn't that be "in the"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yep!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

by?

Copy link
Member

Choose a reason for hiding this comment

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

Either is fine for me.

}

bool operator==(EVMVersion const& _other) const { return m_version == _other.m_version; }
bool operator!=(EVMVersion const& _other) const { return !this->operator==(_other); }
Copy link
Member

Choose a reason for hiding this comment

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

Should also have comparison operators if we introduce tangerine whistle now.

std::string name() const { return m_version == Version::Byzantium ? "byzantium" : "homestead"; }

bool hasReturndatacopy() const { return m_version == Version::Byzantium; }
bool hasStaticCall() const { return m_version == Version::Byzantium; }
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure if we should have such a granularity. One option is this, the other is comparison whether currently version >= byzantium, though that assumes features can't be removed.

/// or whether we can just forward easily all remaining gas (true).
bool canOverchargeGasForCall() const
{
// @TODO when exactly was this introduced? Was together with the call stack fix.
Copy link
Member

Choose a reason for hiding this comment

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

- run:
name: Init submodules
command: |
git submodule update --init
Copy link
Member

Choose a reason for hiding this comment

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

Why were these removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we don't have any submodules anymore, do we? I can remove it from this PR.

@axic
Copy link
Member

axic commented Feb 26, 2018

Actually I just realized we have a third test combination to run: contracts compiled for homestead, running on a byzantium VM...

Probably the simplest way is adding another commandline option to the tests for --runtime-evm-version which changes the version in the genesis.

Then we could have more combinations on the CI.

@chriseth
Copy link
Contributor Author

Added the other versions.

@chriseth
Copy link
Contributor Author

Updated. Will leave it at the current test combinations for now.

@chriseth
Copy link
Contributor Author

Updated.

@chriseth chriseth force-pushed the evmVersion branch 2 times, most recently from 2880ed4 to e3de9ea Compare March 2, 2018 11:23
@@ -353,7 +353,7 @@ void Assembly::injectStart(AssemblyItem const& _i)
m_items.insert(m_items.begin(), _i);
}

Assembly& Assembly::optimise(bool _enable, bool _isCreation, size_t _runs)
Assembly& Assembly::optimise(bool _enable, EVMVersion _evmVersion, bool _isCreation, size_t _runs)
Copy link
Member

Choose a reason for hiding this comment

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

Woohoo, I should be using this for the bitwise shifting optimiser rules in #3580.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it was a really painful process. This setting is needed literally everywhere...

BOOST_CHECK(balanceAt(Address(0xdead)) == 42);
// "send" does not retain enough gas to be able to pay for account creation.
// Disabling for non-tangerineWhistle VMs.
if (dev::test::Options::get().evmVersion().canOverchargeGasForCall())
Copy link
Member

Choose a reason for hiding this comment

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

Hm, can we output a boost message that these are skipped due to the vm?

Also, how about?

if (..)
  return;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried return, but the macro seems to create a function that returns something.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll look into telling boost to skip a test, it seems to have such a feature.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed it accordingly. This will probably show up in the xml test report.

{
char const* sourceCode = R"(
(returnlll
(send 0xdead 42))
Copy link
Member

Choose a reason for hiding this comment

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

Eventually send and msg should be updated I think.

@benjaminion @zigguratt what do you think?

Copy link
Member

@axic axic left a comment

Choose a reason for hiding this comment

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

I think it looks good. I wouldn't have added evmVersion to LLL, but it can actually be useful (will address that separately).

@axic
Copy link
Member

axic commented Mar 3, 2018

It is failing:

Testing soljson via the fuzzer...
--> Running tests using  --evm-version homestead...
Commandline tests successful.
Boost.Test framework internal error: unknown reason
Exited with code 200

@chriseth
Copy link
Contributor Author

chriseth commented Mar 5, 2018

It seems there is a bug in boost which causes skipped tests to be treated as errors: https://svn.boost.org/trac10/ticket/12095

@chriseth
Copy link
Contributor Author

chriseth commented Mar 5, 2018

I will revert to the previous version for now (which just had a if (..) {...}. These LLL tests already cost me 1-2 hours, although LLL is out of scope.

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.

2 participants