mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Correct namespace for a few things in devcrypto.
Added lower_bound to TrieDB. Added nextActiveAddress to State.
This commit is contained in:
parent
ea27fbe5f3
commit
165e9780f7
@ -55,7 +55,7 @@ public:
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/// 256-bit hash of the node - this is a SHA-3/256 hash of the RLP of the node.
|
/// 256-bit hash of the node - this is a SHA-3/256 hash of the RLP of the node.
|
||||||
h256 hash256() const { RLPStream s; makeRLP(s); return dev::eth::sha3(s.out()); }
|
h256 hash256() const { RLPStream s; makeRLP(s); return dev::sha3(s.out()); }
|
||||||
bytes rlp() const { RLPStream s; makeRLP(s); return s.out(); }
|
bytes rlp() const { RLPStream s; makeRLP(s); return s.out(); }
|
||||||
void mark() { m_hash256 = h256(); }
|
void mark() { m_hash256 = h256(); }
|
||||||
|
|
||||||
@ -200,7 +200,7 @@ void MemTrieNode::putRLP(RLPStream& _parentStream) const
|
|||||||
if (s.out().size() < 32)
|
if (s.out().size() < 32)
|
||||||
_parentStream.APPEND_CHILD(s.out());
|
_parentStream.APPEND_CHILD(s.out());
|
||||||
else
|
else
|
||||||
_parentStream << dev::eth::sha3(s.out());
|
_parentStream << dev::sha3(s.out());
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrieBranchNode::makeRLP(RLPStream& _intoStream) const
|
void TrieBranchNode::makeRLP(RLPStream& _intoStream) const
|
||||||
|
@ -150,7 +150,7 @@ int cryptoTest()
|
|||||||
int ret = secp256k1_ecdsa_recover_compact((byte const*)hmsg.data(), (int)hmsg.size(), (byte const*)sig64.data(), pubkey.data(), &pubkeylen, 0, (int)t.vrs.v - 27);
|
int ret = secp256k1_ecdsa_recover_compact((byte const*)hmsg.data(), (int)hmsg.size(), (byte const*)sig64.data(), pubkey.data(), &pubkeylen, 0, (int)t.vrs.v - 27);
|
||||||
pubkey.resize(pubkeylen);
|
pubkey.resize(pubkeylen);
|
||||||
cout << "RECPUB: " << dec << ret << " " << pubkeylen << " " << toHex(pubkey) << endl;
|
cout << "RECPUB: " << dec << ret << " " << pubkeylen << " " << toHex(pubkey) << endl;
|
||||||
cout << "SENDER: " << hex << toAddress(dev::eth::sha3(bytesConstRef(&pubkey).cropped(1))) << dec << endl;
|
cout << "SENDER: " << hex << toAddress(dev::sha3(bytesConstRef(&pubkey).cropped(1))) << dec << endl;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -29,7 +29,6 @@
|
|||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace dev;
|
using namespace dev;
|
||||||
using namespace dev::eth;
|
|
||||||
namespace js = json_spirit;
|
namespace js = json_spirit;
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(hexPrefix_test)
|
BOOST_AUTO_TEST_CASE(hexPrefix_test)
|
||||||
|
46
trie.cpp
46
trie.cpp
@ -31,7 +31,6 @@
|
|||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace dev;
|
using namespace dev;
|
||||||
using namespace dev::eth;
|
|
||||||
|
|
||||||
namespace js = json_spirit;
|
namespace js = json_spirit;
|
||||||
|
|
||||||
@ -236,6 +235,51 @@ BOOST_AUTO_TEST_CASE(moreTrieTests)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(trieLowerBound)
|
||||||
|
{
|
||||||
|
cnote << "Stress-testing Trie.lower_bound...";
|
||||||
|
{
|
||||||
|
MemoryDB dm;
|
||||||
|
EnforceRefs e(dm, true);
|
||||||
|
GenericTrieDB<MemoryDB> d(&dm);
|
||||||
|
d.init(); // initialise as empty tree.
|
||||||
|
for (int a = 0; a < 20; ++a)
|
||||||
|
{
|
||||||
|
StringMap m;
|
||||||
|
for (int i = 0; i < 50; ++i)
|
||||||
|
{
|
||||||
|
auto k = randomWord();
|
||||||
|
auto v = toString(i);
|
||||||
|
m[k] = v;
|
||||||
|
d.insert(k, v);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (auto i: d)
|
||||||
|
{
|
||||||
|
auto it = d.lower_bound(i.first);
|
||||||
|
for (auto iit = d.begin(); iit != d.end(); ++iit)
|
||||||
|
if ((*iit).first.toString() >= i.first.toString())
|
||||||
|
{
|
||||||
|
BOOST_REQUIRE(it == iit);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (unsigned i = 0; i < 100; ++i)
|
||||||
|
{
|
||||||
|
auto k = randomWord();
|
||||||
|
auto it = d.lower_bound(k);
|
||||||
|
for (auto iit = d.begin(); iit != d.end(); ++iit)
|
||||||
|
if ((*iit).first.toString() >= k)
|
||||||
|
{
|
||||||
|
BOOST_REQUIRE(it == iit);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(trieStess)
|
BOOST_AUTO_TEST_CASE(trieStess)
|
||||||
{
|
{
|
||||||
cnote << "Stress-testing Trie...";
|
cnote << "Stress-testing Trie...";
|
||||||
|
Loading…
Reference in New Issue
Block a user