diff options
author | chriseth <c@ethdev.com> | 2016-11-30 00:47:47 +0800 |
---|---|---|
committer | chriseth <c@ethdev.com> | 2016-12-01 23:03:59 +0800 |
commit | 6a7ff039df15be59fbb71dc3dfaad09fb0b8961f (patch) | |
tree | 01d433c964f51111800766c30f230dd4c0e680ea /libsolidity | |
parent | e0d4a3d518dc742d94571ef1e16b3f95765ec62f (diff) | |
download | dexon-solidity-6a7ff039df15be59fbb71dc3dfaad09fb0b8961f.tar.gz dexon-solidity-6a7ff039df15be59fbb71dc3dfaad09fb0b8961f.tar.zst dexon-solidity-6a7ff039df15be59fbb71dc3dfaad09fb0b8961f.zip |
Use CBOR encoding.
Diffstat (limited to 'libsolidity')
-rw-r--r-- | libsolidity/codegen/Compiler.cpp | 4 | ||||
-rw-r--r-- | libsolidity/codegen/Compiler.h | 2 | ||||
-rw-r--r-- | libsolidity/interface/CompilerStack.cpp | 9 |
3 files changed, 11 insertions, 4 deletions
diff --git a/libsolidity/codegen/Compiler.cpp b/libsolidity/codegen/Compiler.cpp index b7e0cc64..44264a07 100644 --- a/libsolidity/codegen/Compiler.cpp +++ b/libsolidity/codegen/Compiler.cpp @@ -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. diff --git a/libsolidity/codegen/Compiler.h b/libsolidity/codegen/Compiler.h index 58ef1963..eef078c1 100644 --- a/libsolidity/codegen/Compiler.h +++ b/libsolidity/codegen/Compiler.h @@ -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. diff --git a/libsolidity/interface/CompilerStack.cpp b/libsolidity/interface/CompilerStack.cpp index 357b18bd..d79345f0 100644 --- a/libsolidity/interface/CompilerStack.cpp +++ b/libsolidity/interface/CompilerStack.cpp @@ -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(); |