mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Refactor overwriteRelease flag.
Co-authored-by: Kamil Śliwak <kamil.sliwak@codepoets.it>
This commit is contained in:
parent
003701f6bc
commit
68a4efb2e7
@ -1580,6 +1580,9 @@ private:
|
|||||||
|
|
||||||
bytes CompilerStack::createCBORMetadata(Contract const& _contract) const
|
bytes CompilerStack::createCBORMetadata(Contract const& _contract) const
|
||||||
{
|
{
|
||||||
|
if (m_metadataFormat == MetadataFormat::NoMetadata)
|
||||||
|
return bytes{};
|
||||||
|
|
||||||
bool const experimentalMode = !onlySafeExperimentalFeaturesActivated(
|
bool const experimentalMode = !onlySafeExperimentalFeaturesActivated(
|
||||||
_contract.contract->sourceUnit().annotation().experimentalFeatures
|
_contract.contract->sourceUnit().annotation().experimentalFeatures
|
||||||
);
|
);
|
||||||
@ -1597,10 +1600,16 @@ bytes CompilerStack::createCBORMetadata(Contract const& _contract) const
|
|||||||
|
|
||||||
if (experimentalMode || m_viaIR)
|
if (experimentalMode || m_viaIR)
|
||||||
encoder.pushBool("experimental", true);
|
encoder.pushBool("experimental", true);
|
||||||
if (m_release)
|
if (m_metadataFormat == MetadataFormat::WithReleaseVersionTag)
|
||||||
encoder.pushBytes("solc", VersionCompactBytes);
|
encoder.pushBytes("solc", VersionCompactBytes);
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
solAssert(
|
||||||
|
m_metadataFormat == MetadataFormat::WithPrereleaseVersionTag,
|
||||||
|
"Invalid metadata format."
|
||||||
|
);
|
||||||
encoder.pushString("solc", VersionStringStrict);
|
encoder.pushString("solc", VersionStringStrict);
|
||||||
|
}
|
||||||
return encoder.serialise();
|
return encoder.serialise();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,6 +98,12 @@ public:
|
|||||||
CompilationSuccessful
|
CompilationSuccessful
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum class MetadataFormat {
|
||||||
|
WithReleaseVersionTag,
|
||||||
|
WithPrereleaseVersionTag,
|
||||||
|
NoMetadata
|
||||||
|
};
|
||||||
|
|
||||||
enum class MetadataHash {
|
enum class MetadataHash {
|
||||||
IPFS,
|
IPFS,
|
||||||
Bzzr1,
|
Bzzr1,
|
||||||
@ -336,8 +342,10 @@ public:
|
|||||||
/// @returns a JSON representing the estimated gas usage for contract creation, internal and external functions
|
/// @returns a JSON representing the estimated gas usage for contract creation, internal and external functions
|
||||||
Json::Value gasEstimates(std::string const& _contractName) const;
|
Json::Value gasEstimates(std::string const& _contractName) const;
|
||||||
|
|
||||||
/// Overwrites the release/prerelease flag. Should only be used for testing.
|
/// Changes the format of the metadata appended at the end of the bytecode.
|
||||||
void overwriteReleaseFlag(bool release) { m_release = release; }
|
/// This is mostly a workaround to avoid bytecode and gas differences between compiler builds
|
||||||
|
/// caused by differences in metadata. Should only be used for testing.
|
||||||
|
void setMetadataFormat(MetadataFormat _metadataFormat) { m_metadataFormat = _metadataFormat; }
|
||||||
private:
|
private:
|
||||||
/// The state per source unit. Filled gradually during parsing.
|
/// The state per source unit. Filled gradually during parsing.
|
||||||
struct Source
|
struct Source
|
||||||
@ -496,7 +504,7 @@ private:
|
|||||||
/// Whether or not there has been an error during processing.
|
/// Whether or not there has been an error during processing.
|
||||||
/// If this is true, the stack will refuse to generate code.
|
/// If this is true, the stack will refuse to generate code.
|
||||||
bool m_hasError = false;
|
bool m_hasError = false;
|
||||||
bool m_release = VersionIsRelease;
|
MetadataFormat m_metadataFormat = VersionIsRelease ? MetadataFormat::WithReleaseVersionTag : MetadataFormat::WithPrereleaseVersionTag;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user