From c1bc090104c1d2ca3bbaecb8dd145565d3c8db16 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Thu, 13 Nov 2014 15:50:32 +0100 Subject: [PATCH] Log pricing update. --- libevm/FeeStructure.cpp | 3 +++ libevm/FeeStructure.h | 3 +++ libevm/VM.h | 3 ++- libweb3jsonrpc/WebThreeStubServer.cpp | 3 +-- libwhisper/Common.cpp | 4 ++-- libwhisper/Common.h | 4 ++-- libwhisper/Message.h | 2 +- 7 files changed, 14 insertions(+), 8 deletions(-) diff --git a/libevm/FeeStructure.cpp b/libevm/FeeStructure.cpp index 47236b506..6d868cac5 100644 --- a/libevm/FeeStructure.cpp +++ b/libevm/FeeStructure.cpp @@ -37,3 +37,6 @@ u256 const dev::eth::c_callGas = 20; u256 const dev::eth::c_memoryGas = 1; u256 const dev::eth::c_txDataGas = 5; u256 const dev::eth::c_txGas = 500; +u256 const dev::eth::c_logGas = 32; +u256 const dev::eth::c_logDataGas = 1; +u256 const dev::eth::c_logTopicGas = 32; diff --git a/libevm/FeeStructure.h b/libevm/FeeStructure.h index 84a2551d9..e57f7ccf8 100644 --- a/libevm/FeeStructure.h +++ b/libevm/FeeStructure.h @@ -40,6 +40,9 @@ extern u256 const c_callGas; ///< Once per CALL operation & message call trans extern u256 const c_memoryGas; ///< Times the address of the (highest referenced byte in memory + 1). NOTE: referencing happens on read, write and in instructions such as RETURN and CALL. extern u256 const c_txDataGas; ///< Per byte of data attached to a transaction. NOTE: Not payable on data of calls between transactions. extern u256 const c_txGas; ///< Per transaction. NOTE: Not payable on data of calls between transactions. +extern u256 const c_logGas; ///< Per LOG* operation. +extern u256 const c_logDataGas; ///< Per byte in a LOG* operation's data. +extern u256 const c_logTopicGas; ///< Multiplied by the * of the LOG*, per LOG transaction. e.g. LOG0 incurs 0 * c_txLogTopicGas, LOG4 incurs 4 * c_txLogTopicGas. } } diff --git a/libevm/VM.h b/libevm/VM.h index b3a4c2828..d495b6289 100644 --- a/libevm/VM.h +++ b/libevm/VM.h @@ -206,7 +206,8 @@ template dev::bytesConstRef dev::eth::VM::go(Ext& _ext, OnOpFunc con { unsigned n = (unsigned)inst - (unsigned)Instruction::LOG0; require(n + 2); - newTempSize = memNeed(m_stack[m_stack.size() - 1 ], m_stack[m_stack.size() - 2]); + runGas = c_logGas + c_logTopicGas * n + c_logDataGas * m_stack[m_stack.size() - 2]; + newTempSize = memNeed(m_stack[m_stack.size() - 1], m_stack[m_stack.size() - 2]); break; } diff --git a/libweb3jsonrpc/WebThreeStubServer.cpp b/libweb3jsonrpc/WebThreeStubServer.cpp index 3849fb4a8..092faae09 100644 --- a/libweb3jsonrpc/WebThreeStubServer.cpp +++ b/libweb3jsonrpc/WebThreeStubServer.cpp @@ -271,14 +271,13 @@ static Json::Value toJson(h256 const& _h, shh::Envelope const& _e, shh::Message res["ttl"] = (int)_e.ttl(); res["workProved"] = (int)_e.workProved(); for (auto const& t: _e.topics()) - res["topics"].append(toJS((u256)t)); + res["topics"].append(toJS(t)); res["payload"] = toJS(_m.payload()); res["from"] = toJS(_m.from()); res["to"] = toJS(_m.to()); return res; } - WebThreeStubServer::WebThreeStubServer(jsonrpc::AbstractServerConnector* _conn, WebThreeDirect& _web3, std::vector const& _accounts): AbstractWebThreeStubServer(_conn), m_web3(_web3) diff --git a/libwhisper/Common.cpp b/libwhisper/Common.cpp index 8f58ae994..83f289875 100644 --- a/libwhisper/Common.cpp +++ b/libwhisper/Common.cpp @@ -33,7 +33,7 @@ Topic BuildTopic::toTopic() const Topic ret; ret.reserve(m_parts.size()); for (auto const& h: m_parts) - ret.push_back((TopicPart)u256(h)); + ret.push_back(TopicPart(h)); return ret; } @@ -69,7 +69,7 @@ TopicMask BuildTopicMask::toTopicMask() const TopicMask ret; ret.reserve(m_parts.size()); for (auto const& h: m_parts) - ret.push_back(make_pair((TopicPart)u256(h), h ? ~(uint32_t)0 : 0)); + ret.push_back(make_pair(TopicPart(h), h ? ~TopicPart() : TopicPart())); return ret; } diff --git a/libwhisper/Common.h b/libwhisper/Common.h index 436af8d11..c445ac506 100644 --- a/libwhisper/Common.h +++ b/libwhisper/Common.h @@ -59,7 +59,7 @@ enum WhisperPacket PacketCount }; -using TopicPart = uint32_t; +using TopicPart = FixedHash<4>; using Topic = std::vector; @@ -92,7 +92,7 @@ public: TopicFilter() {} TopicFilter(TopicMask const& _m): m_topicMasks(1, _m) {} TopicFilter(TopicMasks const& _m): m_topicMasks(_m) {} - TopicFilter(RLP const& _r): m_topicMasks(_r.toVector>>()) {} + TopicFilter(RLP const& _r): m_topicMasks(_r.toVector, FixedHash<4>>>>()) {} void streamRLP(RLPStream& _s) const { _s << m_topicMasks; } h256 sha3() const; diff --git a/libwhisper/Message.h b/libwhisper/Message.h index ed26cf145..954aed4a0 100644 --- a/libwhisper/Message.h +++ b/libwhisper/Message.h @@ -55,7 +55,7 @@ public: { m_expiry = _m[0].toInt(); m_ttl = _m[1].toInt(); - m_topic = _m[2].toVector(); + m_topic = _m[2].toVector>(); m_data = _m[3].toBytes(); m_nonce = _m[4].toInt(); }