mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Use updated swarm hash.
This commit is contained in:
parent
aa11ad7d0a
commit
89f0e1e6da
@ -8,6 +8,7 @@ Language Features:
|
||||
|
||||
Compiler Features:
|
||||
* eWasm: Highly experimental eWasm output using ``--ewasm`` in the commandline interface or output selection of ``ewasm.wast`` in standard-json.
|
||||
* Metadata: Update the swarm hash, changes ``bzzr0`` to ``bzzr1`` and urls to use ``bzz-raw://``.
|
||||
|
||||
|
||||
|
||||
|
@ -784,7 +784,7 @@ h256 const& CompilerStack::Source::keccak256() const
|
||||
h256 const& CompilerStack::Source::swarmHash() const
|
||||
{
|
||||
if (swarmHashCached == h256{})
|
||||
swarmHashCached = dev::bzzr0Hash(scanner->source());
|
||||
swarmHashCached = dev::bzzr1Hash(scanner->source());
|
||||
return swarmHashCached;
|
||||
}
|
||||
|
||||
@ -1085,7 +1085,7 @@ string CompilerStack::createMetadata(Contract const& _contract) const
|
||||
else
|
||||
{
|
||||
meta["sources"][s.first]["urls"] = Json::arrayValue;
|
||||
meta["sources"][s.first]["urls"].append("bzzr://" + toHex(s.second.swarmHash().asBytes()));
|
||||
meta["sources"][s.first]["urls"].append("bzz-raw://" + toHex(s.second.swarmHash().asBytes()));
|
||||
meta["sources"][s.first]["urls"].append(s.second.ipfsUrl());
|
||||
}
|
||||
}
|
||||
@ -1232,7 +1232,7 @@ private:
|
||||
bytes CompilerStack::createCBORMetadata(string const& _metadata, bool _experimentalMode)
|
||||
{
|
||||
MetadataCBOREncoder encoder;
|
||||
encoder.pushBytes("bzzr0", dev::bzzr0Hash(_metadata).asBytes());
|
||||
encoder.pushBytes("bzzr1", dev::bzzr1Hash(_metadata).asBytes());
|
||||
if (_experimentalMode)
|
||||
encoder.pushBool("experimental", true);
|
||||
if (m_release)
|
||||
|
@ -40,18 +40,18 @@ namespace test
|
||||
#define CHECK_DEPLOY_GAS(_gasNoOpt, _gasOpt) \
|
||||
do \
|
||||
{ \
|
||||
u256 bzzr0Cost = GasMeter::dataGas(dev::bzzr0Hash(m_compiler.metadata(m_compiler.lastContractName())).asBytes(), true); \
|
||||
u256 bzzr1Cost = GasMeter::dataGas(dev::bzzr1Hash(m_compiler.metadata(m_compiler.lastContractName())).asBytes(), true); \
|
||||
u256 gasOpt{_gasOpt}; \
|
||||
u256 gasNoOpt{_gasNoOpt}; \
|
||||
u256 gas = m_optimiserSettings == OptimiserSettings::minimal() ? gasNoOpt : gasOpt; \
|
||||
BOOST_CHECK_MESSAGE( \
|
||||
m_gasUsed >= bzzr0Cost, \
|
||||
m_gasUsed >= bzzr1Cost, \
|
||||
"Gas used: " + \
|
||||
m_gasUsed.str() + \
|
||||
" is less than the data cost for the bzzr0 hash: " + \
|
||||
u256(bzzr0Cost).str() \
|
||||
" is less than the data cost for the bzzr1 hash: " + \
|
||||
u256(bzzr1Cost).str() \
|
||||
); \
|
||||
u256 gasUsed = m_gasUsed - bzzr0Cost; \
|
||||
u256 gasUsed = m_gasUsed - bzzr1Cost; \
|
||||
BOOST_CHECK_MESSAGE( \
|
||||
gas == gasUsed, \
|
||||
"Gas used: " + \
|
||||
|
@ -70,7 +70,7 @@ BOOST_AUTO_TEST_CASE(metadata_stamp)
|
||||
bytes const& bytecode = compilerStack.runtimeObject("test").bytecode;
|
||||
std::string const& metadata = compilerStack.metadata("test");
|
||||
BOOST_CHECK(dev::test::isValidMetadata(metadata));
|
||||
bytes hash = dev::bzzr0Hash(metadata).asBytes();
|
||||
bytes hash = dev::bzzr1Hash(metadata).asBytes();
|
||||
BOOST_REQUIRE(hash.size() == 32);
|
||||
auto const cborMetadata = requireParsedCBORMetadata(bytecode);
|
||||
BOOST_CHECK(cborMetadata.size() == 2);
|
||||
@ -79,8 +79,8 @@ BOOST_AUTO_TEST_CASE(metadata_stamp)
|
||||
BOOST_CHECK(cborMetadata.at("solc") == toHex(VersionCompactBytes));
|
||||
else
|
||||
BOOST_CHECK(cborMetadata.at("solc") == VersionStringStrict);
|
||||
BOOST_CHECK(cborMetadata.count("bzzr0") == 1);
|
||||
BOOST_CHECK(cborMetadata.at("bzzr0") == toHex(hash));
|
||||
BOOST_CHECK(cborMetadata.count("bzzr1") == 1);
|
||||
BOOST_CHECK(cborMetadata.at("bzzr1") == toHex(hash));
|
||||
}
|
||||
}
|
||||
|
||||
@ -105,7 +105,7 @@ BOOST_AUTO_TEST_CASE(metadata_stamp_experimental)
|
||||
bytes const& bytecode = compilerStack.runtimeObject("test").bytecode;
|
||||
std::string const& metadata = compilerStack.metadata("test");
|
||||
BOOST_CHECK(dev::test::isValidMetadata(metadata));
|
||||
bytes hash = dev::bzzr0Hash(metadata).asBytes();
|
||||
bytes hash = dev::bzzr1Hash(metadata).asBytes();
|
||||
BOOST_REQUIRE(hash.size() == 32);
|
||||
auto const cborMetadata = requireParsedCBORMetadata(bytecode);
|
||||
BOOST_CHECK(cborMetadata.size() == 3);
|
||||
@ -114,8 +114,8 @@ BOOST_AUTO_TEST_CASE(metadata_stamp_experimental)
|
||||
BOOST_CHECK(cborMetadata.at("solc") == toHex(VersionCompactBytes));
|
||||
else
|
||||
BOOST_CHECK(cborMetadata.at("solc") == VersionStringStrict);
|
||||
BOOST_CHECK(cborMetadata.count("bzzr0") == 1);
|
||||
BOOST_CHECK(cborMetadata.at("bzzr0") == toHex(hash));
|
||||
BOOST_CHECK(cborMetadata.count("bzzr1") == 1);
|
||||
BOOST_CHECK(cborMetadata.at("bzzr1") == toHex(hash));
|
||||
BOOST_CHECK(cborMetadata.count("experimental") == 1);
|
||||
BOOST_CHECK(cborMetadata.at("experimental") == "true");
|
||||
}
|
||||
|
@ -377,7 +377,7 @@ BOOST_AUTO_TEST_CASE(basic_compilation)
|
||||
"tag_1:\n /* \"fileA\":0:14 contract A { } */\n pop\n dataSize(sub_0)\n dup1\n "
|
||||
"dataOffset(sub_0)\n 0x00\n codecopy\n 0x00\n return\nstop\n\nsub_0: assembly {\n "
|
||||
"/* \"fileA\":0:14 contract A { } */\n mstore(0x40, 0x80)\n 0x00\n "
|
||||
"dup1\n revert\n\n auxdata: 0xa265627a7a72305820"
|
||||
"dup1\n revert\n\n auxdata: 0xa265627a7a72315820"
|
||||
) == 0);
|
||||
BOOST_CHECK(contract["evm"]["gasEstimates"].isObject());
|
||||
BOOST_CHECK_EQUAL(contract["evm"]["gasEstimates"].size(), 1);
|
||||
|
Loading…
Reference in New Issue
Block a user