mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Use CBOR encoding.
This commit is contained in:
@@ -31,12 +31,12 @@ using namespace dev::solidity;
|
||||
void Compiler::compileContract(
|
||||
ContractDefinition const& _contract,
|
||||
std::map<const ContractDefinition*, eth::Assembly const*> const& _contracts,
|
||||
h256 const& _metadataHash
|
||||
bytes const& _metadata
|
||||
)
|
||||
{
|
||||
ContractCompiler runtimeCompiler(nullptr, m_runtimeContext, m_optimize);
|
||||
runtimeCompiler.compileContract(_contract, _contracts);
|
||||
m_runtimeContext.appendAuxiliaryData(_metadataHash.asBytes());
|
||||
m_runtimeContext.appendAuxiliaryData(_metadata);
|
||||
|
||||
// This might modify m_runtimeContext because it can access runtime functions at
|
||||
// creation time.
|
||||
|
||||
@@ -43,7 +43,7 @@ public:
|
||||
void compileContract(
|
||||
ContractDefinition const& _contract,
|
||||
std::map<ContractDefinition const*, eth::Assembly const*> const& _contracts,
|
||||
h256 const& _metadataHash
|
||||
bytes const& _metadata
|
||||
);
|
||||
/// Compiles a contract that uses DELEGATECALL to call into a pre-deployed version of the given
|
||||
/// contract at runtime, but contains the full creation-time code.
|
||||
|
||||
@@ -611,7 +611,14 @@ void CompilerStack::compileContract(
|
||||
shared_ptr<Compiler> compiler = make_shared<Compiler>(m_optimize, m_optimizeRuns);
|
||||
Contract& compiledContract = m_contracts.at(_contract.name());
|
||||
string onChainMetadata = createOnChainMetadata(compiledContract);
|
||||
compiler->compileContract(_contract, _compiledContracts, dev::swarmHash(onChainMetadata));
|
||||
bytes cborEncodedMetadata =
|
||||
// CBOR-encoding of {"bzzr0": dev::swarmHash(onChainMetadata)}
|
||||
bytes{0xa1, 0x65, 'b', 'z', 'z', 'r', '0', 0x58, 0x20} +
|
||||
dev::swarmHash(onChainMetadata).asBytes();
|
||||
solAssert(cborEncodedMetadata.size() <= 0xffff, "Metadata too large");
|
||||
// 16-bit big endian length
|
||||
cborEncodedMetadata += toCompactBigEndian(cborEncodedMetadata.size(), 2);
|
||||
compiler->compileContract(_contract, _compiledContracts, cborEncodedMetadata);
|
||||
compiledContract.compiler = compiler;
|
||||
compiledContract.object = compiler->assembledObject();
|
||||
compiledContract.runtimeObject = compiler->runtimeObject();
|
||||
|
||||
Reference in New Issue
Block a user