Merge remote-tracking branch 'origin/develop' into merge_develop_060

This commit is contained in:
Leonardo Alt
2019-11-20 12:27:40 +01:00
104 changed files with 621 additions and 653 deletions
+39 -11
View File
@@ -19,6 +19,7 @@
*/
#include <test/libsolidity/SolidityExecutionFramework.h>
#include <liblangutil/EVMVersion.h>
#include <libdevcore/IpfsHash.h>
#include <libevmasm/GasMeter.h>
@@ -37,7 +38,7 @@ namespace solidity
namespace test
{
#define CHECK_DEPLOY_GAS(_gasNoOpt, _gasOpt) \
#define CHECK_DEPLOY_GAS(_gasNoOpt, _gasOpt, _evmVersion) \
do \
{ \
u256 ipfsCost = GasMeter::dataGas(dev::ipfsHash(m_compiler.metadata(m_compiler.lastContractName())), true); \
@@ -95,34 +96,61 @@ BOOST_AUTO_TEST_CASE(string_storage)
m_compiler.overwriteReleaseFlag(true);
compileAndRun(sourceCode);
if (Options::get().evmVersion() <= EVMVersion::byzantium())
CHECK_DEPLOY_GAS(134145, 130831);
auto evmVersion = dev::test::Options::get().evmVersion();
if (evmVersion <= EVMVersion::byzantium())
CHECK_DEPLOY_GAS(134071, 130763, evmVersion);
// This is only correct on >=Constantinople.
else if (Options::get().useABIEncoderV2)
{
if (Options::get().optimizeYul)
CHECK_DEPLOY_GAS(127785, 127721);
{
// Costs with 0 are cases which cannot be triggered in tests.
if (evmVersion < EVMVersion::istanbul())
CHECK_DEPLOY_GAS(0, 127653, evmVersion);
else
CHECK_DEPLOY_GAS(0, 113821, evmVersion);
}
else
CHECK_DEPLOY_GAS(151587, 135371);
{
if (evmVersion < EVMVersion::istanbul())
CHECK_DEPLOY_GAS(0, 135371, evmVersion);
else
CHECK_DEPLOY_GAS(0, 120083, evmVersion);
}
}
else if (evmVersion < EVMVersion::istanbul())
CHECK_DEPLOY_GAS(126861, 119591, evmVersion);
else
CHECK_DEPLOY_GAS(126929, 119659);
CHECK_DEPLOY_GAS(114173, 107163, evmVersion);
if (Options::get().evmVersion() >= EVMVersion::byzantium())
if (evmVersion >= EVMVersion::byzantium())
{
callContractFunction("f()");
if (Options::get().evmVersion() == EVMVersion::byzantium())
if (evmVersion == EVMVersion::byzantium())
CHECK_GAS(21551, 21526, 20);
// This is only correct on >=Constantinople.
else if (Options::get().useABIEncoderV2)
{
if (Options::get().optimizeYul)
CHECK_GAS(21713, 21567, 20);
{
if (evmVersion < EVMVersion::istanbul())
CHECK_GAS(0, 21567, 20);
else
CHECK_GAS(0, 21351, 20);
}
else
CHECK_GAS(21713, 21635, 20);
{
if (evmVersion < EVMVersion::istanbul())
CHECK_GAS(0, 21635, 20);
else
CHECK_GAS(0, 21431, 20);
}
}
else
else if (evmVersion < EVMVersion::istanbul())
CHECK_GAS(21546, 21526, 20);
else
CHECK_GAS(21332, 21322, 20);
}
}
+2 -1
View File
@@ -114,9 +114,10 @@ public:
static GasMeter::GasConsumption gasForTransaction(bytes const& _data, bool _isCreation)
{
auto evmVersion = dev::test::Options::get().evmVersion();
GasMeter::GasConsumption gas = _isCreation ? GasCosts::txCreateGas : GasCosts::txGas;
for (auto i: _data)
gas += i != 0 ? GasCosts::txDataNonZeroGas : GasCosts::txDataZeroGas;
gas += i != 0 ? GasCosts::txDataNonZeroGas(evmVersion) : GasCosts::txDataZeroGas;
return gas;
}
@@ -0,0 +1,12 @@
contract C {
function f() public returns (uint id) {
assembly {
id := chainid()
}
}
}
// ====
// compileViaYul: also
// EVMVersion: >=istanbul
// ----
// f() -> 1
@@ -0,0 +1,12 @@
contract C {
function f() public payable returns (uint ret) {
assembly {
ret := selfbalance()
}
}
}
// ====
// EVMVersion: >=istanbul
// compileViaYul: also
// ----
// f(), 254 ether -> 254
@@ -0,0 +1,15 @@
contract S
{
int o;
function foo() public returns (int) { return o = 3; }
}
contract B is S
{
function fii() public
{
o = S(super).foo();
}
}
// ----
// TypeError: (129-137): Explicit type conversion not allowed from "contract super B" to "contract S".