Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/ethereum/libethereum int…
Browse files Browse the repository at this point in the history
…o pv63

Conflicts:
	libethereum/EthereumPeer.cpp
  • Loading branch information
arkpar committed Dec 7, 2015
2 parents bdc91d5 + 549c343 commit 52a8cf4
Show file tree
Hide file tree
Showing 106 changed files with 3,327 additions and 1,555 deletions.
14 changes: 12 additions & 2 deletions ethkey/KeyAux.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ class KeyCLI
m_mode = OperationMode::SignTx;
m_signKey = argv[++i];
}
else if (arg == "--show-me-the-secret")
m_showSecret = true;
else if (arg == "--tx-data" && i + 1 < argc)
try
{
Expand Down Expand Up @@ -463,6 +465,11 @@ class KeyCLI
cout << a.abridged() << endl;
cout << " ICAP: " << ICAP(a).encoded() << endl;
cout << " Raw hex: " << a.hex() << endl;
if (m_showSecret)
{
Secret s = keyManager().secret(a);
cout << " Secret: " << (m_showSecret ? toHex(s.ref()) : (toHex(s.ref().cropped(0, 8)) + "...")) << endl;
}
}
break;
}
Expand Down Expand Up @@ -517,15 +524,15 @@ class KeyCLI
cout << " UUID: " << toUUID(u) << ":" << endl;
cout << " ICAP: " << ICAP(toAddress(Secret(s))).encoded() << endl;
cout << " Raw hex: " << toAddress(Secret(s)).hex() << endl;
cout << " Secret: " << toHex(s.ref().cropped(0, 8)) << "..." << endl;
cout << " Secret: " << (m_showSecret ? toHex(s.ref()) : (toHex(s.ref().cropped(0, 8)) + "...")) << endl;
}
else if (h128 u = fromUUID(i))
{
bytesSec s = secretStore().secret(u, [&](){ return getPassword("Enter passphrase for key " + toUUID(u) + ": "); });
cout << "Key " << i << ":" << endl;
cout << " ICAP: " << ICAP(toAddress(Secret(s))).encoded() << endl;
cout << " Raw hex: " << toAddress(Secret(s)).hex() << endl;
cout << " Secret: " << toHex(s.ref().cropped(0, 8)) << "..." << endl;
cout << " Secret: " << (m_showSecret ? toHex(s.ref()) : (toHex(s.ref().cropped(0, 8)) + "...")) << endl;
}
else if (Address a = toAddress(i))
{
Expand Down Expand Up @@ -902,6 +909,9 @@ class KeyCLI
string m_name;
Address m_address;

/// Inspecting
bool m_showSecret = false;

/// Importing
strings m_inputs;

Expand Down
2 changes: 1 addition & 1 deletion ethvm/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ int main(int argc, char** argv)

if (mode == Mode::Statistics)
{
cout << "Gas used: " << res.gasUsed << " (+" << t.gasRequired() << " for transaction, -" << res.gasRefunded << " refunded)" << endl;
cout << "Gas used: " << res.gasUsed << " (+" << t.gasRequired(se->evmSchedule(envInfo)) << " for transaction, -" << res.gasRefunded << " refunded)" << endl;
cout << "Output: " << toHex(output) << endl;
LogEntries logs = executive.logs();
cout << logs.size() << " logs" << (logs.empty() ? "." : ":") << endl;
Expand Down
2 changes: 2 additions & 0 deletions evmjit/libevmjit/GasMeter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ namespace jit
namespace // Helper functions
{

// TODO: FIXME: HOMESTEAD: XXX: @chfast populate m_schedule from an ExtVMFace instance via ExtVMFace::evmSchedule.

int64_t const c_stepGas[] = {0, 2, 3, 5, 8, 10, 20};
int64_t const c_expByteGas = 10;
int64_t const c_sha3Gas = 30;
Expand Down
2 changes: 2 additions & 0 deletions evmjit/libevmjit/GasMeter.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ namespace jit
class RuntimeManager;
using namespace evmjit;

// TODO: FIXME: HOMESTEAD: XXX: @chfast populate m_schedule from an ExtVMFace instance via ExtVMFace::evmSchedule.

class GasMeter : public CompilerHelper // TODO: Use RuntimeHelper
{
public:
Expand Down
2 changes: 2 additions & 0 deletions libethash-cl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ aux_source_directory(. SRC_LIST)
file(GLOB OUR_HEADERS "*.h")
set(HEADERS ${OUR_HEADERS} ${CMAKE_CURRENT_BINARY_DIR}/ethash_cl_miner_kernel.h)

# TODO: Should fix properly. Cmake >= 3.4.0 detects a self linking of ethash-cl library here.
cmake_policy(SET CMP0038 OLD)
add_library(${EXECUTABLE} ${SRC_LIST} ${HEADERS})
eth_use(${EXECUTABLE} REQUIRED Eth::ethash OpenCL)
target_include_directories(${EXECUTABLE} PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
Expand Down
3 changes: 2 additions & 1 deletion libethashseal/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ set(EXECUTABLE ethashseal)
file(GLOB HEADERS "*.h")

add_library(${EXECUTABLE} ${SRC_LIST} ${HEADERS})
eth_use(${EXECUTABLE} REQUIRED Eth::ethereum Eth::ethcore Dev::devcrypto Dev::buildinfo)
eth_use(${EXECUTABLE} REQUIRED Eth::ethereum Eth::ethcore Eth::ethash Dev::devcrypto Dev::buildinfo)
eth_use(${EXECUTABLE} OPTIONAL Eth::ethash-cl Cpuid)

install( TARGETS ${EXECUTABLE} RUNTIME DESTINATION bin ARCHIVE DESTINATION lib LIBRARY DESTINATION lib )
install( FILES ${HEADERS} DESTINATION include/${EXECUTABLE} )
Expand Down
35 changes: 34 additions & 1 deletion libethashseal/Ethash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,22 @@ StringHashMap Ethash::jsInfo(BlockHeader const& _bi) const
return { { "nonce", toJS(nonce(_bi)) }, { "seedHash", toJS(seedHash(_bi)) }, { "mixHash", toJS(mixHash(_bi)) }, { "boundary", toJS(boundary(_bi)) }, { "difficulty", toJS(_bi.difficulty()) } };
}

EVMSchedule Ethash::evmSchedule(EnvInfo const& _envInfo) const
{
EVMSchedule ret;
if (_envInfo.number() >= chainParams().u256Param("frontierCompatibilityModeLimit"))
{
ret.exceptionalFailedCodeDeposit = ret.haveDelegateCall = true;
ret.txCreateGas = 53000;
}
else
{
ret.exceptionalFailedCodeDeposit = ret.haveDelegateCall = false;
ret.txCreateGas = 21000;
}
return ret;
}

void Ethash::verify(Strictness _s, BlockHeader const& _bi, BlockHeader const& _parent, bytesConstRef _block) const
{
SealEngineFace::verify(_s, _bi, _parent, _block);
Expand Down Expand Up @@ -135,6 +151,15 @@ void Ethash::verify(Strictness _s, BlockHeader const& _bi, BlockHeader const& _p
}
}

void Ethash::verifyTransaction(ImportRequirements::value _ir, TransactionBase const& _t, BlockHeader const& _bi) const
{
if (_ir & ImportRequirements::TransactionSignatures && _bi.number() >= chainParams().u256Param("frontierCompatibilityModeLimit"))
_t.checkLowS();
// Unneeded as it's checked again in Executive. Keep it here since tests assume it's checked.
if (_ir & ImportRequirements::TransactionBasic && _t.gasRequired(evmSchedule(EnvInfo(_bi))) > _t.gas())
BOOST_THROW_EXCEPTION(OutOfGasIntrinsic());
}

u256 Ethash::childGasLimit(BlockHeader const& _bi, u256 const& _gasFloorTarget) const
{
u256 gasFloorTarget = _gasFloorTarget == Invalid256 ? 3141562 : _gasFloorTarget;
Expand All @@ -160,7 +185,15 @@ u256 Ethash::calculateDifficulty(BlockHeader const& _bi, BlockHeader const& _par
auto minimumDifficulty = chainParams().u256Param("minimumDifficulty");
auto difficultyBoundDivisor = chainParams().u256Param("difficultyBoundDivisor");
auto durationLimit = chainParams().u256Param("durationLimit");
u256 o = max<u256>(minimumDifficulty, _bi.timestamp() >= _parent.timestamp() + durationLimit ? _parent.difficulty() - (_parent.difficulty() / difficultyBoundDivisor) : (_parent.difficulty() + (_parent.difficulty() / difficultyBoundDivisor)));

bigint target; // stick to a bigint for the target. Don't want to risk going negative.
if (_bi.number() < chainParams().u256Param("frontierCompatibilityModeLimit"))
// Frontier-era difficulty adjustment
target = _bi.timestamp() >= _parent.timestamp() + durationLimit ? _parent.difficulty() - (_parent.difficulty() / difficultyBoundDivisor) : (_parent.difficulty() + (_parent.difficulty() / difficultyBoundDivisor));
else
// Homestead-era difficulty adjustment
target = _parent.difficulty() + _parent.difficulty() / 2048 * max<bigint>(1 - (bigint(_bi.timestamp()) - _parent.timestamp()) / 10, -99);
u256 o = (u256)max<bigint>(minimumDifficulty, target);
unsigned periodCount = unsigned(_parent.number() + 1) / c_expDiffPeriod;
if (periodCount > 1)
o = max<u256>(minimumDifficulty, o + (u256(1) << (periodCount - 2))); // latter will eventually become huge, so ensure it's a bigint.
Expand Down
3 changes: 3 additions & 0 deletions libethashseal/Ethash.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class Ethash: public SealEngineFace

StringHashMap jsInfo(BlockHeader const& _bi) const override;
void verify(Strictness _s, BlockHeader const& _bi, BlockHeader const& _parent, bytesConstRef _block) const override;
void verifyTransaction(ImportRequirements::value _ir, TransactionBase const& _t, BlockHeader const& _bi) const override;
void populateFromParent(BlockHeader& _bi, BlockHeader const& _parent) const override;

strings sealers() const override;
Expand All @@ -68,6 +69,8 @@ class Ethash: public SealEngineFace
u256 calculateDifficulty(BlockHeader const& _bi, BlockHeader const& _parent) const;
u256 childGasLimit(BlockHeader const& _bi, u256 const& _gasFloorTarget = Invalid256) const;

virtual EVMSchedule evmSchedule(EnvInfo const&) const override;

void manuallySetWork(BlockHeader const& _work) { m_sealing = _work; }
void manuallySubmitWork(h256 const& _mixHash, Nonce _nonce);

Expand Down
10 changes: 5 additions & 5 deletions libethashseal/EthashClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,20 +56,20 @@ EthashClient::EthashClient(
asEthashClient(*this);
}

Ethash* EthashClient::sealEngine() const
Ethash* EthashClient::ethash() const
{
return dynamic_cast<Ethash*>(Client::sealEngine());
}

bool EthashClient::isMining() const
{
return sealEngine()->farm().isMining();
return ethash()->farm().isMining();
}

WorkingProgress EthashClient::miningProgress() const
{
if (isMining())
return sealEngine()->farm().miningProgress();
return ethash()->farm().miningProgress();
return WorkingProgress();
}

Expand Down Expand Up @@ -97,13 +97,13 @@ std::tuple<h256, h256, h256> EthashClient::getEthashWork()
else
// otherwise, set this to true so that it gets prepped next time.
m_remoteWorking = true;
sealEngine()->manuallySetWork(m_sealingInfo);
ethash()->manuallySetWork(m_sealingInfo);
return std::tuple<h256, h256, h256>(m_sealingInfo.hash(WithoutSeal), Ethash::seedHash(m_sealingInfo), Ethash::boundary(m_sealingInfo));
}

bool EthashClient::submitEthashWork(h256 const& _mixHash, h64 const& _nonce)
{
sealEngine()->manuallySubmitWork(_mixHash, _nonce);
ethash()->manuallySubmitWork(_mixHash, _nonce);
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion libethashseal/EthashClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class EthashClient: public Client
WithExisting _forceAction = WithExisting::Trust
);

Ethash* sealEngine() const;
Ethash* ethash() const;

/// Enable/disable precomputing of the DAG for next epoch
void setShouldPrecomputeDAG(bool _precompute);
Expand Down
93 changes: 90 additions & 3 deletions libethashseal/GenesisInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ R"ETHEREUM(
"sealEngine": "Ethash",
"params": {
"accountStartNonce": "0x00",
"frontierCompatibilityModeLimit": "0xffffffff",
"maximumExtraDataSize": "0x0400",
"tieBreakingGas": false,
"minGasLimit": "125000",
"gasLimitBoundDivisor": "0x0400",
"minimumDifficulty": "0x020000",
Expand Down Expand Up @@ -74,7 +76,9 @@ R"ETHEREUM(
"sealEngine": "Ethash",
"params": {
"accountStartNonce": "0x0100000",
"frontierCompatibilityModeLimit": "0xfffa2990",
"maximumExtraDataSize": "0x20",
"tieBreakingGas": false,
"minGasLimit": "0x1388",
"gasLimitBoundDivisor": "0x0400",
"minimumDifficulty": "0x020000",
Expand Down Expand Up @@ -104,14 +108,54 @@ R"ETHEREUM(
}
)ETHEREUM";

static h256 const c_genesisStateRootFrontierTest;
static std::string const c_genesisInfoFrontierTest =
R"E(
{
"sealEngine": "Ethash",
"params": {
"accountStartNonce": "0x00",
"frontierCompatibilityModeLimit": "0xffffffffffffffff",
"maximumExtraDataSize": "0x20",
"tieBreakingGas": false,
"minGasLimit": "0x1388",
"gasLimitBoundDivisor": "0x0400",
"minimumDifficulty": "0x020000",
"difficultyBoundDivisor": "0x0800",
"durationLimit": "0x0d",
"blockReward": "0x4563918244F40000",
"registrar" : "0xc6d9d2cd449a754c494264e1809c50e34d64562b",
"networkID" : "0x1"
},
"genesis": {
"nonce": "0x0000000000000042",
"difficulty": "0x400000000",
"mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"author": "0x0000000000000000000000000000000000000000",
"timestamp": "0x00",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"extraData": "0x11bbe8db4e347b4e8c937c1c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82fa",
"gasLimit": "0x1388"
},
"accounts": {
"0000000000000000000000000000000000000001": { "precompiled": { "name": "ecrecover", "linear": { "base": 3000, "word": 0 } } },
"0000000000000000000000000000000000000002": { "precompiled": { "name": "sha256", "linear": { "base": 60, "word": 12 } } },
"0000000000000000000000000000000000000003": { "precompiled": { "name": "ripemd160", "linear": { "base": 600, "word": 120 } } },
"0000000000000000000000000000000000000004": { "precompiled": { "name": "identity", "linear": { "base": 15, "word": 3 } } }
}
}
)E";

static h256 const c_genesisStateRootTest;
static std::string const c_genesisInfoTest = std::string() +
R"E(
{
"sealEngine": "Ethash",
"params": {
"accountStartNonce": "0x00",
"frontierCompatibilityModeLimit": "0xfffa2990",
"maximumExtraDataSize": "0x20",
"tieBreakingGas": false,
"minGasLimit": "0x1388",
"gasLimitBoundDivisor": "0x0400",
"minimumDifficulty": "0x020000",
Expand Down Expand Up @@ -140,14 +184,53 @@ R"E(
}
)E";

static h256 const c_genesisStateRootHomesteadTest;
static std::string const c_genesisInfoHomesteadTest = std::string() +
R"E(
{
"sealEngine": "Ethash",
"params": {
"accountStartNonce": "0x00",
"maximumExtraDataSize": "0x20",
"minGasLimit": "0x1388",
"tieBreakingGas": false,
"gasLimitBoundDivisor": "0x0400",
"minimumDifficulty": "0x020000",
"difficultyBoundDivisor": "0x0800",
"durationLimit": "0x0d",
"blockReward": "0x4563918244F40000",
"registrar" : "0xc6d9d2cd449a754c494264e1809c50e34d64562b",
"networkID" : "0x1"
},
"genesis": {
"nonce": "0x0000000000000042",
"difficulty": "0x400000000",
"mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"author": "0x0000000000000000000000000000000000000000",
"timestamp": "0x00",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"extraData": "0x11bbe8db4e347b4e8c937c1c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82fa",
"gasLimit": "0x1388"
},
"accounts": {
"0000000000000000000000000000000000000001": { "wei": "1", "precompiled": { "name": "ecrecover", "linear": { "base": 3000, "word": 0 } } },
"0000000000000000000000000000000000000002": { "wei": "1", "precompiled": { "name": "sha256", "linear": { "base": 60, "word": 12 } } },
"0000000000000000000000000000000000000003": { "wei": "1", "precompiled": { "name": "ripemd160", "linear": { "base": 600, "word": 120 } } },
"0000000000000000000000000000000000000004": { "wei": "1", "precompiled": { "name": "identity", "linear": { "base": 15, "word": 3 } } }
}
}
)E";

static h256 const c_genesisStateRootFrontier("d7f8974fb5ac78d9ac099b9ad5018bedc2ce0a72dad1827a1709da30580f0544");
static std::string const c_genesisInfoFrontier = std::string() +
R"E(
{
"sealEngine": "Ethash",
"params": {
"accountStartNonce": "0x00",
"frontierCompatibilityModeLimit": "0xfffa2990",
"maximumExtraDataSize": "0x20",
"tieBreakingGas": false,
"minGasLimit": "0x1388",
"gasLimitBoundDivisor": "0x0400",
"minimumDifficulty": "0x020000",
Expand All @@ -171,7 +254,7 @@ R"E(
"0000000000000000000000000000000000000001": { "precompiled": { "name": "ecrecover", "linear": { "base": 3000, "word": 0 } } },
"0000000000000000000000000000000000000002": { "precompiled": { "name": "sha256", "linear": { "base": 60, "word": 12 } } },
"0000000000000000000000000000000000000003": { "precompiled": { "name": "ripemd160", "linear": { "base": 600, "word": 120 } } },
"0000000000000000000000000000000000000004": { "precompiled": { "name": "identity", "linear": { "base": 15, "word": 3 } } }
"0000000000000000000000000000000000000004": { "precompiled": { "name": "identity", "linear": { "base": 15, "word": 3 } } },
"3282791d6fd713f1e94f4bfd565eaa78b3a0599d": {
"balance": "1337000000000000000000"
},
Expand Down Expand Up @@ -27127,8 +27210,10 @@ std::string const& dev::eth::genesisInfo(Network _n)
{
case Network::Olympic: return c_genesisInfoOlympic;
case Network::Frontier: return c_genesisInfoFrontier;
case Network::Test: return c_genesisInfoTest;
case Network::Morden: return c_genesisInfoMorden;
case Network::Test: return c_genesisInfoTest;
case Network::FrontierTest: return c_genesisInfoFrontierTest;
case Network::HomesteadTest: return c_genesisInfoHomesteadTest;
default:
throw std::invalid_argument("Invalid network value");
}
Expand All @@ -27140,8 +27225,10 @@ h256 const& dev::eth::genesisStateRoot(Network _n)
{
case Network::Olympic: return c_genesisStateRootOlympic;
case Network::Frontier: return c_genesisStateRootFrontier;
case Network::Test: return c_genesisStateRootTest;
case Network::Morden: return c_genesisStateRootMorden;
case Network::Test: return c_genesisStateRootTest;
case Network::FrontierTest: return c_genesisStateRootFrontierTest;
case Network::HomesteadTest: return c_genesisStateRootHomesteadTest;
default:
throw std::invalid_argument("Invalid network value");
}
Expand Down
12 changes: 7 additions & 5 deletions libethashseal/GenesisInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,13 @@ namespace eth
/// The network id.
enum class Network
{
Olympic = 0,
Frontier = 1,
Morden = 2,
Test = 70,
Special = 0xff
Olympic = 0, ///< Normal Olympic chain.
Frontier = 1, ///< Normal Frontier/Homestead chain.
Morden = 2, ///< Normal Morden chain.
Test = 70, ///< Normal Frontier/Homestead chain without all the premine.
FrontierTest = 71, ///< Just test the Frontier-era characteristics "forever" (no Homestead portion).
HomesteadTest = 72, ///< Just test the Homestead-era characteristics "forever" (no Frontier portion).
Special = 0xff ///< Something else.
};

std::string const& genesisInfo(Network _n);
Expand Down
Loading

0 comments on commit 52a8cf4

Please sign in to comment.