Compare commits

..

3190 Commits

Author SHA1 Message Date
a0303ff4bd cmd/geth: bumped version 1.0.2 2015-08-20 21:41:39 +02:00
bf2d4e1e1e Merge branch 'release/1.0.1' 2015-08-20 20:58:10 +02:00
f0c7af0477 remove 0x 2015-08-20 20:15:08 +02:00
34c85d58a4 canary update 2015-08-20 20:15:04 +02:00
969eb61886 core, tests: Double SUICIDE fix 2015-08-20 18:24:45 +02:00
7fbf990cc9 xeth: fixed contract addr check 2015-08-07 14:38:21 +02:00
d051274691 xeth: added address hex check and length check 2015-08-07 11:11:32 +02:00
82ef26f600 Merge branch 'develop' 2015-08-05 18:41:08 +02:00
ee5728ec03 fake commit for build server :( 2015-08-05 18:41:00 +02:00
9a02f53726 Merge branch 'develop' 2015-08-05 18:35:28 +02:00
98100f472c cmd/geth: bumped version number 2015-08-05 18:35:23 +02:00
80e5f50713 Merge branch 'develop' 2015-08-05 18:08:52 +02:00
26f838796b Merge pull request #1583 from obscuren/miner-price-order
miner, core: sort txs by price, nonce
2015-08-05 09:03:18 -07:00
35f271b264 miner, core: sort txs by price, nonce 2015-08-05 17:44:19 +02:00
f12e0161ca Merge pull request #1588 from obscuren/diff-bomb
core, miner: added difficulty bomb
2015-08-05 04:26:57 -07:00
71d32f54f7 core, miner: added difficulty bomb 2015-08-05 13:09:09 +02:00
1f4ac6b05a Merge pull request #1587 from obscuren/miner-race
miner: fixed worker race condition
2015-08-05 01:50:49 -07:00
d8590d9790 miner: fixed worker race condition 2015-08-04 20:54:21 +02:00
56219a5e7a Merge pull request #1578 from Gustav-Simonsson/frontier_thawing
miner: gas limit strategy, target 3141592 & def gas price 50 Shannon
2015-08-04 11:53:39 -07:00
26c6e3b206 miner: gas limit strategy, target 3141592 & def gas price 50 Shannon 2015-08-04 15:20:28 +02:00
b01f2c29ae Merge pull request #1574 from fjl/fdtrack
fdtrack: hack to track file descriptor usage
2015-08-04 03:51:16 -07:00
ff66e8fa29 Merge pull request #1562 from ethersphere/blankpasswd
jsre: leave out lines from history possibly containing passwords
2015-08-04 03:10:59 -07:00
17b481e3c3 Merge pull request #1581 from obscuren/olympic
cmd, core, eth: support for the olympic network
2015-08-04 00:54:07 -07:00
5c949d3b3b fdtrack: temporary hack for tracking file descriptor usage
Package fdtrack logs statistics about open file descriptors.
This should help identify the source of #1549.
2015-08-04 03:10:27 +02:00
dcdb7059cc cmd, core, eth: support for the olympic network
Added a --olympic flag which initialiser the olympic protocol settings
2015-08-03 18:15:48 +02:00
bf48ed32dd metrics: fix file descriptor leak when reading disk stats on linux
The disk stats file was not closed after reading.
2015-08-03 16:27:36 +02:00
ba14957cf3 rpc/comms: use ConnState to track HTTP connections
The JSON-RPC server wraps TCP connections in order to be able to shut
down them down when RPC is stopped. This is rather scary code. Go 1.3
introduced the http.Server.ConnState hook for such purposes. We can use
this facility now that we depend on Go 1.4.

There are multiple reasons for the switch apart from making the code
less scary:

* the TCP listener no longer ticks every second to check a channel
* pending requests are allowed to finish after stopping the server
* we can time out idle keep-alive connections
2015-08-03 16:27:36 +02:00
97cdf84899 Merge pull request #1479 from tgerring/ethtest
Update ethtest default path for BlockTests
2015-08-03 07:18:48 -07:00
98db08c42f Merge pull request #1548 from fjl/accounts-test-deflake
accounts: bump timeout in TestSignRace
2015-08-03 07:16:36 -07:00
cc6c5846e5 Merge pull request #1568 from obscuren/issue-1559
core: added a running flag to prevent panics in the chainmanager
2015-08-03 07:15:19 -07:00
db988a46dd Merge pull request #1569 from obscuren/default-genesis
core: added default genesis block
2015-08-03 04:49:30 -07:00
7a75da63c6 core: added default genesis block
When a user runs a freshly setup geth w/o a database initialised the
default genesis block is decoded and inserted in to the database.
2015-08-02 01:23:02 +02:00
33efb3381c Merge pull request #1461 from bas-vk/eth_resend
Old transaction after resend was not removed from pool
2015-08-01 16:18:54 -07:00
5aec1d94ad accounts: bump timeout and spin less in TestSignRace
This should fix the flakeyness.
2015-08-02 00:49:53 +02:00
a8b39b5cc0 Merge pull request #1541 from bas-vk/issue1518
Improved error handling for NewTransactionFromBytes
2015-08-01 08:47:32 -07:00
acd2c4e520 core: added a running flag to prevent panics in the chainmanager
The running flag will determine whether the chain manager is still
running or not. This will prevent the quit channel from being closed
twice resulting in a panic. This PR should fix this issue.

Closes #1559
2015-08-01 12:32:28 +02:00
ab85a3593a Merge pull request #1545 from obscuren/log-index
core/state: Set log index. Closes #1226
2015-07-31 10:36:42 -07:00
c1c06fffcb Merge pull request #1561 from karalabe/add-missing-autocompletes
rpc/api: add missing autocomplete commands
2015-07-31 03:09:08 -07:00
6628eeb6ca jsre: leave out lines from history containing methods of the personal module 2015-07-31 11:51:18 +02:00
0d3a8ad6dd rpc/api: add missing autocomplete commands 2015-07-31 12:46:16 +03:00
4231de3914 Merge pull request #1553 from prusnak/develop
remove elliptic.P224 usage
2015-07-30 03:59:25 -07:00
3f07afbbd2 remove elliptic.P224 usage
Fedora/RedHat distros comply with US patent law and remove this curve,
which makes it impossible to run ethereum with distro provided Golang.

File crypto/ecies/README claims it is unsupported anyway.
2015-07-30 12:47:45 +02:00
64e2f52c2e Merge pull request #1534 from obscuren/issue-1040
rpc: to in eth_call no longer required. Fixed eth_estimateGas
2015-07-30 03:25:47 -07:00
d261c3f455 rpc: to in Call no longer required. Fixed eth_estimateGas 2015-07-29 15:12:12 +02:00
e7f4232b10 Merge pull request #1544 from karalabe/fix-stall-detector
eth, eth/downloader: don't report stall if fetcher filled the block
2015-07-29 06:11:43 -07:00
f715547fc7 core/state: Set log index. Closes #1226 2015-07-29 15:08:59 +02:00
fa286688ab Merge pull request #1546 from obscuren/tests-update
tests: updated
2015-07-29 06:07:19 -07:00
03c39d4fc0 tests: updated 2015-07-29 15:01:42 +02:00
6adbaabc65 eth, eth/downloader: don't report stall if fetcher filled the block 2015-07-29 15:39:08 +03:00
81e2124ea2 improved error detection and handling for NewTransactionFromBytes
integrated review comments
2015-07-29 10:30:00 +02:00
cc27be9d44 Merge pull request #1543 from enriquefynn/develop
FreeBSD support
2015-07-28 16:20:13 -07:00
7065ebd2ed FreeBSD support 2015-07-28 19:16:16 -03:00
a281df783d Merge pull request #1533 from ethersphere/frontier/etherbase
Etherbase defaults to first account even if it is created during the session
2015-07-28 05:11:43 -07:00
1fad8798ec Merge pull request #1515 from fjl/license-fixes
all: fix license headers one more time
2015-07-28 04:29:42 -07:00
7e31df3987 bugfix, pending transaction was resend with new gas price/limit but not removed from transaction pool 2015-07-28 10:42:31 +02:00
572e78cee0 Merge pull request #1536 from fjl/fix-go1.5-build
crypto: fix build with Go 1.5
2015-07-28 00:59:52 +02:00
453d2c9ce1 crypto: fix build with Go 1.5 2015-07-27 19:13:45 +02:00
1356daad27 etherbase defaults to first account even if created during the session 2015-07-27 10:50:29 +02:00
d18d256442 Merge pull request #1529 from obscuren/extra-data-fix
core: genesis extra data field fix
2015-07-26 15:15:36 -07:00
3530acb9e2 core: genesis extra data field fix 2015-07-26 14:44:54 +02:00
8a5ea466e4 Merge pull request #1528 from obscuren/reduce-extra-data
params: reduce extra data to 32 bytes & target block time
2015-07-26 04:04:10 -07:00
1e241e84f7 params: reduce extra data to 32 bytes 2015-07-26 12:47:57 +02:00
e86233abc9 Merge pull request #1525 from obscuren/genesis-write-fix
core: fixed genesis write out to write only canon number
2015-07-25 13:13:27 -07:00
c1c895a36b core: fixed genesis write out to write only canon number 2015-07-25 21:48:53 +02:00
73a576c9af Merge pull request #1524 from obscuren/default-extra
eth: set default miner extra to client name
2015-07-25 08:58:08 -07:00
665eaff9b9 Merge pull request #1520 from obscuren/reward-5eth
core: 5 ether block reward
2015-07-25 08:57:33 -07:00
9afda6ab8c core: 5 ether block reward 2015-07-25 17:47:20 +02:00
3adaeb1dbc eth: set default miner extra to client name 2015-07-25 17:36:56 +02:00
0efcd7ed05 Merge pull request #1521 from obscuren/client-update
cmd/geth, core, eth: Version 1.0.0
2015-07-25 08:36:04 -07:00
4019e2a6f2 Merge pull request #1497 from obscuren/remove-rle
ethdb, trie: removed RLE compression
2015-07-25 08:35:40 -07:00
f6097f4a0a Merge pull request #1522 from obscuren/genesis-block-check
core: check genesis block before writeout
2015-07-25 08:10:08 -07:00
d4428cc77f Merge pull request #1523 from obscuren/lower-gasprice
cmd/util: lowered default gas price
2015-07-25 08:09:55 -07:00
ba15f9d282 cmd/util: lowered default gas price 2015-07-25 17:03:10 +02:00
0c718afe90 core: check genesis block before writeout 2015-07-25 16:53:35 +02:00
036e6301af cmd/geth, core, eth: Version 1.0.0
Genesis release. Closes #1402

Conflicts:
	cmd/geth/main.go
2015-07-25 13:55:56 +02:00
6cffa743ee Merge pull request #1519 from obscuren/develop
web3: updated 0.9.1
2015-07-25 04:06:43 -07:00
5001f778aa web3: updated 0.9.1 2015-07-25 12:22:39 +02:00
cd657b9878 Godeps: use BSD-licensed version of gopkg.in/karalabe/cookiejar.v2 2015-07-24 14:23:02 +02:00
67598d9d08 crypto/sha3: add full license headers 2015-07-24 12:32:58 +02:00
fd2356c620 common: remove config.go
The code in config.go is unused. The main reason for removing it is to
get rid github.com/rakyll/goini in Godeps (it has no license).
2015-07-24 11:43:32 +02:00
bfbcfbe4a9 all: fix license headers one more time
I forgot to update one instance of "go-ethereum" in commit 3f047be5a.
2015-07-23 18:35:11 +02:00
adc7ab0dd6 Merge pull request #1507 from obscuren/batch-write
cmd/core,xeth: removed unneeded states & added batch writes
2015-07-23 07:50:07 -07:00
8f56eea77d ethdb, trie: removed RLE compression 2015-07-23 12:57:33 +02:00
8fc9830971 cmd/core,xeth: removed unneeded states & added batch writes 2015-07-23 10:45:31 +02:00
0cff61beda Merge pull request #1510 from fjl/license-fixes
all: license fixes
2015-07-23 01:43:11 -07:00
b403b9e4c3 Merge pull request #1508 from karalabe/database-caching
cmd, core, eth, ethdb: cache flag to allocate memory for db internal use
2015-07-23 01:17:18 -07:00
26a269ea09 Merge pull request #1511 from karalabe/rlp-data-race
core: fix an RLP encoding data race due to deep struct copy
2015-07-22 20:10:41 +02:00
04bb89604e core: fix an RLP encoding data race due to deep struct copy 2015-07-22 20:54:53 +03:00
0428cae226 remove LICENSE files 2015-07-22 18:54:45 +02:00
3f047be5aa all: update license headers to distiguish GPL/LGPL
All code outside of cmd/ is licensed as LGPL. The headers
now reflect this by calling the whole work "the go-ethereum library".
2015-07-22 18:51:45 +02:00
f4acdea402 crypto: fix license of curve.go
crypto/curve.go is not our code and has its own license. This commit
excludes it in update-license.go and removes our GPL header.
2015-07-22 18:50:31 +02:00
c7e7778f2a cmd, core, eth, ethdb: cache flag to allocate memory for db internal use 2015-07-22 14:00:52 +03:00
d1d45aa839 Merge pull request #1503 from fjl/fix-accounts-race
accounts: fix data race when key is locked after the unlock timeout
2015-07-22 13:00:09 +02:00
d103af5dd4 Disassociate test directory from test name 2015-07-22 11:39:36 +01:00
ed1d2f858e Merge pull request #1481 from tgerring/legalese
Legalese updates
2015-07-22 03:35:33 -07:00
482cc4957d Merge pull request #1500 from karalabe/fix-miner-race
miner: fix current work data race
2015-07-22 03:16:13 -07:00
f1daed65b1 Merge pull request #1502 from ethereum/canaryFix
Fixed canary to require 2+ nonzero, not sum 2+
2015-07-20 16:17:48 -07:00
cf5313f13e Update disclaimer 2015-07-20 18:49:25 +02:00
06d5898d6a crypto: remove debug print call after decrypting a key from disk 2015-07-20 18:04:23 +02:00
7662dd9bbb accounts: fix data race when key is locked after the unlock timeout
While here, also improve the docs and speed up the tests.
The tests used the scrypt keystore with ridiculous settins and took 20s
each.
2015-07-20 18:04:23 +02:00
8160b8618d Fixed canary to require 2+ nonzero, not sum 2+ 2015-07-20 16:28:28 +02:00
3029349761 miner: fix current work data race 2015-07-20 14:37:43 +03:00
02c5022742 Merge pull request #1496 from karalabe/fix-xeth-races
xeth: fix #1485, data race in fiilter creation and event firing
2015-07-20 04:27:10 -07:00
3642441ca3 xeth: fix #1485, data race in fiilter creation and event firing 2015-07-20 14:02:02 +03:00
12bb743b35 Merge pull request #1484 from fjl/rlp-json-tests
cmd/ethtest, tests: add support for RLP JSON tests
2015-07-19 05:05:16 -07:00
26c0fa1cb0 Merge pull request #1480 from obscuren/miner-state-sync
miner: moved state sync
2015-07-19 05:03:59 -07:00
a38f3740d6 Merge pull request #1488 from ethereum/travis
Travis container support
2015-07-18 09:05:29 -07:00
345590f27f rlp: fix check for canonical byte array size
Decoding did not reject byte arrays of length one with a single element
b where 55 < b < 128. Such byte arrays must be rejected because
they must be encoded as the single byte b instead.
2015-07-18 16:23:35 +02:00
5a41326521 Travis container support 2015-07-18 16:12:48 +02:00
cefd948267 rlp: reject trailing data when using DecodeBytes 2015-07-18 01:47:17 +02:00
593b1b65e7 tests: document RLP tests 2015-07-17 15:42:23 +02:00
5da82077d1 cmd/ethtest, tests: add support for RLP JSON tests 2015-07-17 15:13:24 +02:00
1b9ef0e52d miner: moved state sync
Moved the state sync so it only syncs the state when the block mining yield a possitive result
2015-07-16 14:19:27 +02:00
a75b95b876 Merge pull request #1477 from tgerring/legalese
Prompt user to accept legalese when datadir doesn't exist
2015-07-16 04:40:15 -07:00
e954375109 Merge pull request #1469 from obscuren/smart-mining
miner: smart mining
2015-07-16 04:39:07 -07:00
618991f136 Move text to separate file 2015-07-16 13:34:34 +02:00
bc6b6932d0 Merge pull request #1476 from obscuren/deadlock-logs
xeth: removed mutex lock
2015-07-16 03:35:43 -07:00
1909d26fe2 Prompt user to accept legalese when datadir doesn't exist 2015-07-16 12:27:42 +02:00
b1d0d3c0ed xeth: removed unneeded mutex lock 2015-07-16 11:04:53 +02:00
9addb3df3a Merge pull request #1475 from obscuren/issue1473
core: during chain reorg rewrite receipts and transactions
2015-07-15 13:17:07 -07:00
e870e61bc9 miner: smart mining
Work is now handled and carried over multiple sessions. Previously one
session only was assumed, potentially resulting in invalid (outdated)
work

* Larger work / result queue
* Full validation option
2015-07-15 20:37:12 +02:00
cecc9cdd2f Merge pull request #1468 from Gustav-Simonsson/xeth_transact_logging
xeth: log signed tx hash
2015-07-15 11:35:51 -07:00
e17d8ddbeb core: during chain reorg rewrite receipts and transactions
Added PutBlockReceipts; storing receipts by blocks. Eventually this will
require pruning during some cleanup cycle. During forks the receipts by
block are used to get the new canonical receipts and transactions.

This PR fixes #1473 by rewriting transactions and receipts from the point
of where the fork occured.
2015-07-14 18:40:03 +02:00
afba798357 xeth: log signed tx hash 2015-07-13 03:09:02 +02:00
796c18db93 Merge pull request #1462 from obscuren/genesis
core: genesis preparation
2015-07-12 03:45:45 -07:00
a32c51effd cmd, core, eth, common: genesis preparation
Implemented the --genesis flag thru which we can set a custom genesis
block, including the official Ethereum genesis block.
2015-07-10 17:37:41 +02:00
5a810758db cmd/geth: bump version 0.9.39 2015-07-09 18:07:52 +02:00
6f9377475c Merge branch 'release/0.9.38' into develop 2015-07-09 18:06:49 +02:00
98f4c936f2 Merge branch 'release/0.9.38' 2015-07-09 18:06:39 +02:00
344277d026 cmd/geth: version bump 0.9.38 2015-07-09 17:43:45 +02:00
3add8cfdb0 Merge pull request #1452 from obscuren/develop
core/vm: added str to op
2015-07-09 08:42:38 -07:00
8b5a65c14a core/vm: added str to op 2015-07-09 17:08:33 +02:00
0646cc8d14 Merge pull request #1453 from ethersphere/frozen-accounts
accounts, crypto: fixed file naming for windows
2015-07-09 08:08:09 -07:00
97d22be318 Merge pull request #1441 from obscuren/logs-return-fix
miner, xeth: fire log event during mining. Fix return raw tx
2015-07-09 07:24:35 -07:00
4c62ce831b Merge pull request #1451 from karalabe/handle-potential-TD-forge-attack
eth/downloader: drop peer if advertised TD but won't delvier
2015-07-09 07:23:50 -07:00
b041aed660 Merge pull request #1450 from karalabe/fix-propagation-td
eth: calculate the correct TD, only update if better
2015-07-09 07:23:16 -07:00
cd6d703e94 Merge pull request #1447 from karalabe/fix-database-metrics-race-3
eth, ethdb: fix a data race during startup/shutdown
2015-07-09 07:22:54 -07:00
dd140beb73 Merge pull request #1443 from Gustav-Simonsson/core_uint64_ts
Core uint64 ts
2015-07-09 07:22:38 -07:00
06afabb631 Merge pull request #1436 from bas-vk/net_version
added net.version
2015-07-09 07:22:20 -07:00
505b77a0d5 Merge pull request #1432 from tgerring/develop
Adjust .mailmap
2015-07-09 07:21:41 -07:00
c3f5403b64 fix wallet key duplicate write - how did it get there? mystery. fixes #1411 2015-07-09 14:07:35 +01:00
589f1c85b9 : colon => dash - in keyfile name - slight deviation from ISO8601 for WIN FS compatibility 2015-07-09 13:55:09 +01:00
492d5454b1 eth/downloader: drop peer if advertised TD but won't delvier 2015-07-09 14:40:18 +03:00
4f95e2f9ec eth: calculate the correct TD, only update if better 2015-07-09 13:55:06 +03:00
eb2d168710 eth, ethdb: fix a data race during startup/shutdown 2015-07-09 12:44:07 +03:00
d25634662b web3: updated 2015-07-08 15:47:33 +02:00
819ecd4508 miner, xeth: fire log event during mining. Fix return raw tx 2015-07-08 15:34:11 +02:00
5d6d40f329 Use uint64 on ts in chain_manager, block_processor 2015-07-08 13:21:06 +02:00
b08abe64e4 Unskip SimpleTx3, check err in pre/post state validations 2015-07-08 13:09:22 +02:00
0b53a5c673 Update Ethereum JSON test files and wrappers 2015-07-08 13:08:42 +02:00
e84f3ec1d4 added net.version 2015-07-08 08:03:20 +02:00
b1af5af30e Adjust .mailmap 2015-07-07 11:50:49 -05:00
423c2f499c Merge branch 'release/0.9.36' 2015-07-07 15:33:55 +02:00
a2333bcbb4 Merge pull request #1430 from obscuren/web3-0.8.0
web3 update
2015-07-07 06:33:38 -07:00
c6578d2336 Merge branch 'release/0.9.36' 2015-07-07 15:32:04 +02:00
c5972b4ac7 web3 update 2015-07-07 15:21:24 +02:00
0c9c5439d4 Merge branch 'release/0.9.36' into develop 2015-07-07 15:13:11 +02:00
193c62fdba Merge branch 'release/0.9.36' 2015-07-07 15:12:56 +02:00
d673c34c8d Merge branch 'release/0.9.36' of github.com-obscure:ethereum/go-ethereum into release/0.9.36 2015-07-07 14:55:39 +02:00
df54510e3e common/natspec: fixed test 2015-07-07 14:55:27 +02:00
ee04b71887 cmd/geth, cmd/utils: changed ParamsToAddress to return error
ParamsToAddress no longer aborts the process, it now returns an error
instead so that the caller can handle the error properly.
2015-07-07 14:55:27 +02:00
4b5c99d97f cmd/geth: version number 0.9.36 2015-07-07 14:55:27 +02:00
9e7d5d9d3b Merge pull request #1426 from fjl/license
all: update license information and godoc comments
2015-07-07 05:55:06 -07:00
b2d18393c4 README.md: update copyright 2015-07-07 14:12:45 +02:00
335d7f4855 LICENSE, cmd/LICENSE: the go-ethereum authors have copyright 2015-07-07 14:12:45 +02:00
4fb28e0dab all: goimports -w 2015-07-07 14:12:45 +02:00
bdae4fd573 all: add some godoc synopsis comments 2015-07-07 14:12:45 +02:00
e813626ee1 all: remove @author comments 2015-07-07 14:12:44 +02:00
7bb77c02da build: change license regexp for // comments 2015-07-07 14:12:44 +02:00
ea54283b30 all: update license information 2015-07-07 14:12:44 +02:00
46fbd34c70 .mailmap: update 2015-07-07 14:01:33 +02:00
3ff5cfd028 build: new update-license.go
This version is less clever. All names are listed in a single file,
AUTHORS. All source files have the same header. This is an improvement
over the previous version, which attempted to list copyright holders in
each source file.
2015-07-07 14:01:33 +02:00
922f881c3d common/natspec: fixed test 2015-07-07 13:01:39 +02:00
bfcac89881 cmd/geth, cmd/utils: changed ParamsToAddress to return error
ParamsToAddress no longer aborts the process, it now returns an error
instead so that the caller can handle the error properly.
2015-07-07 12:53:36 +02:00
db06906c4f cmd/geth: version number 0.9.36 2015-07-07 12:21:36 +02:00
3016f23864 cmd/geth: fixed test 2015-07-07 12:18:05 +02:00
e5fba8fd70 Merge pull request #1428 from obscuren/coinbase-fixes
cmd,eth,rpc,tests: default coinbase
2015-07-07 02:55:33 -07:00
916d155467 Merge pull request #1429 from obscuren/rebase-registrar
Rebase registrar
2015-07-07 02:55:23 -07:00
c5cb6e8e70 fix/skip tests, adapt registrar to no contract address
registry initialisers now return the txhash which caller can use to retrieve receipt
2015-07-07 11:30:55 +02:00
3791831081 rebase with zelig/frontier/registrar 2015-07-07 11:30:45 +02:00
7e6c1f8024 corrected input formatters as suggested during review 2015-07-07 11:30:23 +02:00
ceb0739ba1 fixed web3 formatters mismatch 2015-07-07 11:30:11 +02:00
37c1a8f69d eth,miner,rpc: set coinbase 2015-07-07 10:58:47 +02:00
6ea28f93b9 output BigNumbers objects in console as strings 2015-07-07 10:43:49 +02:00
1208ac83d5 fix natspec test
* registar url string retrieval chop leading zeros now
* rewrite test using test mining
* remove temporary applyTxs from xeth
2015-07-07 10:43:49 +02:00
aa22cf323e fix js arguments and TestContract passes 2015-07-07 10:43:49 +02:00
492e5049d7 rename js methods in js_test for new console API
+ rebase fixes
2015-07-07 10:43:49 +02:00
042c3290b3 fix GPO missing flags 2015-07-07 10:43:49 +02:00
518dc87db3 fix sleepBlocks, implement sleep 2015-07-07 10:43:49 +02:00
6391ec0c8f add missing method to api/admin 2015-07-07 10:43:31 +02:00
2739233719 Registrar and contractInfo handling
* resolver -> common/registrar
  * global registrar name registry interface
  * add Call to resolver backend interface
  * the hashReg and UrlHing contracts now initialised from global registry
  * initialization of contracts uniform
  * improve errors and more econsistent method names
* common/registrar/ethreg: versioned registrar
* integrate new naming and registrar in natspec
* js console api: setGlobalRegistrar, setHashReg, setUrlHint
* js test TestContract uses mining - tests fixed all pass
* eth/backend: allow PoW test mode (small ethash DAG)
* console jsre refers to resolver.abi/addr,
* cmd/geth/contracts.go moved to common/registrar
2015-07-07 10:43:31 +02:00
83ee39448e Registrar and contractInfo handling
* resolver -> common/registrar
  * global registrar name registry interface
  * add Call to resolver backend interface
  * the hashReg and UrlHing contracts now initialised from global registry
  * initialization of contracts uniform
  * improve errors and more econsistent method names
* common/registrar/ethreg: versioned registrar
* integrate new naming and registrar in natspec
* js console api: setGlobalRegistrar, setHashReg, setUrlHint
* js test TestContract uses mining - tests fixed all pass
* eth/backend: allow PoW test mode (small ethash DAG)
* console jsre refers to resolver.abi/addr,
* cmd/geth/contracts.go moved to common/registrar
2015-07-07 10:43:31 +02:00
35cd355c14 cmd,eth,rpc,tests: default coinbase 2015-07-07 10:32:05 +02:00
d764bd0584 Merge pull request #1423 from obscuren/gasused-receipt-fix
core, eth, rpc: proper gas used. Closes #1422
2015-07-06 12:41:55 -07:00
666a7dda36 core, eth, rpc: proper gas used. Closes #1417
Added some additional backward compatibility code for old receipts
2015-07-06 21:18:24 +02:00
45618d5f6b Merge pull request #1418 from fjl/one-interrupt
cmd/utils: fix interrupt handling to actually see subsequent interrupts
2015-07-06 11:05:54 -07:00
d4c2e9de32 cmd/utils: fix interrupt handling to actually see subsequent interrupts 2015-07-06 16:48:34 +02:00
6220707e03 Merge pull request #1414 from Gustav-Simonsson/update_tests
Add TestBcGasPricer, comments and unskip tests
2015-07-06 06:39:19 -07:00
4c30f0f9ac Merge pull request #1416 from fjl/one-interrupt
cmd/geth, cmd/utils: improve interrupt handling
2015-07-06 06:32:24 -07:00
5615fc4714 cmd/geth, cmd/utils: improve interrupt handling
The new strategy for interrupts is to handle them explicitly.
Ethereum.Stop is now only called once, even if multiple interrupts
are sent. Interrupting ten times in a row forces a panic.

Fixes #869
Fixes #1359
2015-07-06 15:06:11 +02:00
fa7b3b7276 Merge pull request #1415 from obscuren/web3-update
web3: updated
2015-07-06 05:01:39 -07:00
b0aec6402a web3: updated 2015-07-06 14:01:03 +02:00
cc29b4bc27 Merge pull request #1413 from obscuren/receipt-fix
rpc, xeth: fixed returned tx hash & receipt logs
2015-07-06 05:00:17 -07:00
b7e8d954ef Add TestBcGasPricer, comments and unskip tests 2015-07-06 13:56:56 +02:00
4f7fc7b23f rpc, xeth: fixed returned tx hash & receipt logs 2015-07-06 13:43:02 +02:00
457a3c8f76 Merge pull request #1410 from obscuren/newerrors-fix
core, miner: adopted new style errors
2015-07-06 04:00:37 -07:00
e6bb9c1cad core, miner: removed vm errors from consensus err checking
Removed VM errors from the consensus errors. They now used for output
only.
2015-07-06 12:43:05 +02:00
aa4502060b Merge pull request #1400 from obscuren/badblock-reporting
core, miner, tests: added test, implemented bad block reporting
2015-07-06 02:03:50 -07:00
b533aaa765 Merge pull request #1409 from fjl/fix-tx-hash
core/types, xeth: separate tx hash and tx signature hash
2015-07-06 01:59:41 -07:00
35add89c87 Merge pull request #1397 from tgerring/rpcreceipt
getTransactionReceipt RPC support
2015-07-06 01:53:21 -07:00
46e7c8512e Merge pull request #1395 from Gustav-Simonsson/fix_core_errors_in_apply_txs
Fix core errors in apply txs
2015-07-06 01:51:14 -07:00
ec9620fb2f core/types, xeth: separate tx hash and tx signature hash 2015-07-06 10:45:45 +02:00
6c7f5e3d0e Add autocomplete support for console 2015-07-05 15:42:04 -05:00
dd521ece3f Always return transaction hash 2015-07-05 12:25:44 -05:00
bcc1660abc core, miner, tests: added test, implemented bad block reporting 2015-07-05 15:14:31 +02:00
62559ac330 Cleanup 2015-07-04 12:14:06 -05:00
30afd37604 Compose additional fields 2015-07-04 12:03:37 -05:00
cd4cc309ae Remove redundant function 2015-07-04 11:28:30 -05:00
3be9046c21 Rename local variable for clarity 2015-07-04 10:24:52 -05:00
9c3db1be1d Merge pull request #1369 from obscuren/statedb-update-cleanup
core, core/state: throw out intermediate state
2015-07-04 03:42:13 -07:00
9bb575be7d Merge pull request #1283 from ethersphere/frontier/accounts
Account management improvements
2015-07-04 03:40:23 -07:00
0f04af5916 Fix core error forwarding, unify OOG VM err 2015-07-04 09:27:42 +02:00
481b221279 Decode full receipt storage 2015-07-04 00:00:23 -05:00
80eb8f46b7 Fix hex conversion 2015-07-03 23:46:59 -05:00
3a983d2419 Initial getTransactionReceipt support 2015-07-03 23:03:11 -05:00
47460b3b4a trie: removed shallow copies (thanks to @fjl) 2015-07-04 02:51:37 +02:00
0a1ff68c11 trie: dirty tracking 2015-07-04 02:51:36 +02:00
ab16ce70fc core, miner, tests: renamed state methods
* Update => SyncIntermediate
* Added SyncObjects

SyncIntermediate only updates whatever has changed, but, as a side
effect, requires much more disk space.

SyncObjects will only sync whatever is required for a block and will not
save intermediate state to disk. As drawback this requires more time
when more txs come in.
2015-07-04 02:51:36 +02:00
08caeedd84 core, core/state: only write necessary state. Skip intermediate 2015-07-04 02:51:36 +02:00
6f69b4d61f Merge pull request #1399 from obscuren/receipts-storing-fix
core, eth, miner, xeth: receipt storage fix
2015-07-03 17:50:46 -07:00
2feb23c1da core, eth, miner, xeth: receipt storage fix
* Added GetReceiptsFromBlock, GetReceipt, PutReceipts
* Added ContractAddress to receipt. See #1042
2015-07-04 02:32:10 +02:00
efd7da0ce8 Merge pull request #1385 from Gustav-Simonsson/update_tests
Update Ethereum JSON test files, skip failing tests
2015-07-03 09:20:21 -07:00
acd85fe95f Merge pull request #1393 from bas-vk/issue1377
Upgrade web3 to version 0.7.1
2015-07-03 08:27:04 -07:00
4dfcd6012b Merge pull request #1392 from bas-vk/ipcpipelining
Several bugfixes to IPC channel
2015-07-03 08:26:57 -07:00
546c0f631c Merge pull request #1394 from obscuren/develop
miner: ignore future errors
2015-07-03 08:22:30 -07:00
0e33fbdcb9 miner: ignore future errors 2015-07-03 17:21:23 +02:00
8150c0a726 upgrade web3 to version 0.7.1 2015-07-03 17:08:41 +02:00
e8c1399bbf fixed unittest after new implementation 2015-07-03 16:57:40 +02:00
1cbab291a9 Merge pull request #1389 from obscuren/txpool-issues
core, miner: miner header validation, transaction & receipt writing
2015-07-03 07:50:30 -07:00
8181929c9a Merge pull request #1391 from tgerring/consolefalse
Prevent false from printing on console
2015-07-03 07:46:49 -07:00
d9efaf754c simplified implementation and improved performance 2015-07-03 15:44:35 +02:00
6afdc52483 Prevent debug value from printing on console 2015-07-03 07:40:47 -05:00
29e2fb38f8 core, miner: miner header validation, transaction & receipt writing
* Miners do now verify their own header, not their state.
* Changed old putTx and putReceipts to be exported
* Moved writing of transactions and receipts out of the block processer
  in to the chain manager. Closes #1386
* Miner post ChainHeadEvent & ChainEvent. Closes #1388
2015-07-03 13:56:50 +02:00
03129e7c93 Merge pull request #1390 from karalabe/fix-downloader-test-race
eth/downloader: fix a rare test race on the OSX CI
2015-07-03 04:22:14 -07:00
f0e94b4d71 display rpc error in console 2015-07-03 12:22:20 +02:00
f857fb7600 eth/downloader: fix a rare test race on the OSX CI 2015-07-03 13:01:22 +03:00
ff97059a99 Update Ethereum JSON tests, skip failing 2015-07-03 09:40:07 +02:00
1959346793 account update: migrate or change password
* account.Update
* KeyStore.Cleanup
* fix dir rm for old format deleteKey
2015-07-03 07:52:37 +01:00
fc17a527bc fix account ordering
* chronological order of creation
* new naming scheme keystore/UTC--<created_at UTC ISO8601>-<address hex>
* KeyStore2 -> KeyStore
* backward compatibility
* refactor keyStore methods
2015-07-03 03:19:32 +01:00
a4df9d74ea accounts order by keyfile ctime 2015-07-02 23:29:07 +01:00
eb82ca4563 rpc/js coinbase returns null if no etherbase set 2015-07-02 23:28:12 +01:00
09b6983175 no primary when listing accounts 2015-07-02 23:28:12 +01:00
65a26e40a8 require explicit etherbase address for mining. Falling back to primary is risky given it is inconsistent if keys are imported/merged/created or copied/transfered 2015-07-02 23:28:12 +01:00
fc2e33c594 unlock multiple passes and obsolete primary
* multiple passwords allowed in password file
* split on "\n", sideeffect: chop trailing slashes. fixes common mistake <(echo 'pass')
* remove accounts.Primary method
* do not fall back to primary account for mining
2015-07-02 23:28:11 +01:00
1d72aaa0cd simplify account unlocking 2015-07-02 23:28:11 +01:00
cf66826223 merge conflict 2015-07-02 17:33:21 +02:00
56ed408436 ipcpath issue fix 2015-07-02 17:25:11 +02:00
6be527dd52 prevent discarding requests when parsing fails 2015-07-02 17:25:11 +02:00
effe9cc2cf added pipelining support 2015-07-02 17:25:11 +02:00
89525fcb4e ipcpath issue fix 2015-07-02 17:20:58 +02:00
c2590af7fd prevent discarding requests when parsing fails 2015-07-02 15:26:55 +02:00
9f6016e877 Merge branch 'develop' of github.com:ethereum/go-ethereum into develop 2015-07-02 05:27:31 -04:00
75f41dedca Merge pull request #1378 from obscuren/issue1367
core, xeth: core.AddressFromMessage removed => crypto.CreateAddress
2015-07-02 02:27:20 -07:00
744af9f497 Switched canary addresses 2015-07-02 05:27:19 -04:00
529fb7a7d7 core, xeth: core.AddressFromMessage removed => crypto.CreateAddress 2015-07-02 11:19:10 +02:00
5caff3bc24 Merge pull request #1351 from karalabe/eth61
Implement eth/61
2015-07-01 08:16:44 -07:00
507869bff1 Merge pull request #1373 from obscuren/recovery-tools
core, cmd/geth: improved recover functionality
2015-07-01 08:09:33 -07:00
70d5d791cc core, cmd/geth: improved recover functionality
`geth recover` now accepts both hashes and numbers using "#" and no
longer requires the ethereum instance.
2015-07-01 16:34:35 +02:00
d6f2c0a76f eth, eth/downloader: fix #1231, DOS vulnerability in hash queueing 2015-07-01 15:21:35 +03:00
bb418a43c1 Merge pull request #1370 from obscuren/force-checkpoint
core, cmd/geth: recover by number
2015-07-01 03:57:13 -07:00
2e5242f9bb Merge pull request #1355 from Gustav-Simonsson/block_header_ts_uint64
Use uint64 for block header timestamp
2015-07-01 03:57:02 -07:00
1ae80aaf64 eth: fix #1371, double lock during block/txn known set limitation 2015-07-01 11:12:05 +03:00
41de1cb723 added pipelining support 2015-07-01 08:23:17 +02:00
29ab1fa8a5 core, cmd/geth: recover by number 2015-07-01 00:52:44 +02:00
60454da650 eth/downloader: reduce hash fetches in prep for eth/61 2015-07-01 01:20:49 +03:00
cb2c10d862 Merge pull request #1366 from ethers/rpcRequest
fix logging jsonrpc request #1365
2015-06-30 12:17:59 -07:00
d05305473e fix logging jsonrpc request #1365 2015-06-30 12:14:16 -07:00
be935bff84 Merge pull request #1363 from obscuren/safeguard
core: added checkpoint for last block
2015-06-30 09:25:10 -07:00
f43c07cb3c eth, eth/downloader: transition to eth 61 2015-06-30 19:05:06 +03:00
af51dc4d63 eth, eth/downloader: pass the eth protocol version through 2015-06-30 19:00:01 +03:00
aac2b6ae4c eth: add the blocks from numbers protocol message 2015-06-30 19:00:01 +03:00
5db8f447d5 eth: fix #1319, put an upper limit on the known txns and blocks 2015-06-30 19:00:01 +03:00
6fc85f1ec2 eth: clean up peer struct a bit, fix double txn bcast 2015-06-30 19:00:01 +03:00
2c8ed76e01 eth: start cleaning up old protocol implementation, add metrics 2015-06-30 19:00:00 +03:00
393d675690 cmd/geth, cmd/utils, eth: advertise both eth/60 and eth/61 2015-06-30 19:00:00 +03:00
a748afce03 core: txpool listen for ChainHeadEvent instead of ChainEvent
Changed the transaction pool to listen for ChainHeadEvent when resetting
the state instead of ChainEvent. It makes very little sense to burst
through transactions while we are catching up (e.g., have more than one
block to process)
2015-06-30 17:27:47 +02:00
c14f0a4471 core: added checkpoint for last block
* Add a checkpoint every X blocks
* Removed queued write
2015-06-30 17:27:47 +02:00
ba95e445e1 Merge pull request #1328 from bas-vk/issue1327
Add pendingTransactions and resend
2015-06-30 08:27:03 -07:00
8c4d493c66 solved merge conflicts 2015-06-30 15:32:02 +02:00
a5d5387dee rebase with develop 2015-06-30 15:27:27 +02:00
130f3b270a Merge pull request #1362 from obscuren/txpool-cleanup
core: reduce CPU load by reducing calls to checkQueue
2015-06-30 05:18:51 -07:00
61ca780f3b core: reduce CPU load by reducing calls to checkQueue
* Reduced maxQueue count
* Added proper deletion past maxQueue limit
* Added cheap stats method to txpool

queueCheck was called for **every** transaction instead of:
1. add all txs
2. check queue

previously

1. add txs[i]
2. check queue
3. if i < len(txs) goto 1.
2015-06-30 14:01:12 +02:00
57dff6f1d7 initialize fields to prevent nil pointer exception 2015-06-30 11:20:31 +02:00
7ffabf1d39 add json parsing method for resend transaction 2015-06-30 11:20:31 +02:00
6fdddc5ac9 improved error handling in parsing request 2015-06-30 11:20:31 +02:00
02c6af66bf fixed unittest compilation issue 2015-06-30 11:20:31 +02:00
ec866b066a added eth.resend 2015-06-30 11:20:31 +02:00
056e9dd393 added eth.pendingTransactions 2015-06-30 11:20:31 +02:00
9226369b5d Merge branch 'hotfix/0.9.34-1' into develop 2015-06-30 11:15:08 +02:00
a2ce7b9950 Merge branch 'hotfix/0.9.34-1' 2015-06-30 11:14:59 +02:00
d8fe64acaa core, miner: added queued write to WriteBlock
This fixes an issue with the lru cache not being available when calling
WriteBlock. WriteBlock previously always assumed to be called from the
InsertChain where the lru cache was always created prior to calling
WriteBlock. When being called from the worker this could lead in to a
nil pointer exception being thrown and causing database corruption.
2015-06-30 11:14:43 +02:00
4c490db6af Use uint64 for block header timestamp 2015-06-30 10:52:11 +02:00
b047f05e7e cmd/geth: version bump 0.9.35 2015-06-30 02:30:26 +02:00
8d016ced6b Merge branch 'release/0.9.34' into develop 2015-06-30 02:22:40 +02:00
7625b07dd9 Merge branch 'release/0.9.34' 2015-06-30 02:22:19 +02:00
8f504063f4 cmd/geth: version bump 0.9.34 2015-06-30 02:11:54 +02:00
e896cab82c Merge pull request #1360 from obscuren/peter-metrics
Rebased peter's PR
2015-06-29 16:58:49 -07:00
5f3792c2a7 cmd/geth: decent error message if metrics are disabled 2015-06-30 00:57:55 +02:00
01fe972113 cmd, core, eth, metrics, p2p: require enabling metrics 2015-06-30 00:51:46 +02:00
ccbb56b4f2 cmd/geth, eth, ethdb: monitor database compactions 2015-06-30 00:51:29 +02:00
2aeeb72fa5 cmd/geth, metrics: separate process metric collection, add disk 2015-06-30 00:51:02 +02:00
7c4ed8055c Merge pull request #1357 from obscuren/core-optimisations-2
core: optimisations
2015-06-29 15:44:23 -07:00
992e4f83cb core: replaced BlockCache with lru.Cache 2015-06-30 00:36:25 +02:00
a8ebf756c7 Merge branch 'miner-broadcast' into core-optimisations-2
Conflicts:
	core/chain_manager.go
	miner/worker.go
2015-06-29 18:55:49 +02:00
5d9df7348d gpo non-existent block checks 2015-06-29 18:53:04 +02:00
ac80ec59dc miner: update root only when mining 2015-06-29 18:51:49 +02:00
e349fac97d core: fixed tests 2015-06-29 18:51:49 +02:00
aba901e13c core: removed write's go routine 2015-06-29 18:51:49 +02:00
07db098ccf core: renamed next to pending & fixed tests 2015-06-29 18:51:49 +02:00
855e76fddd core: reduced cache limit to 256 2015-06-29 18:51:49 +02:00
4d11747836 deps: Added golang-lru 2015-06-29 18:51:49 +02:00
6ca3a44638 core: switched to proper LRU 2015-06-29 18:51:49 +02:00
4460dc9d1a core: added LRU caching and added batch writing when LDB is used 2015-06-29 18:51:49 +02:00
2a5a55efaf ethdb: accessor for LDB. TODO remove this interface 2015-06-29 18:51:48 +02:00
c850c41ec1 trie: Implemented a batch write approach for flushing 2015-06-29 18:51:48 +02:00
76821d167a core, eth, rpc: avoid unnecessary block header copying 2015-06-29 18:51:48 +02:00
fccc7d71eb core: remove superfluous big.Int allocations
With blocks now being immutable, use big.Int values from
accessor functions instead of copying their results.
2015-06-29 18:51:48 +02:00
d0bb90c69e core: generate benchmark keys only once 2015-06-29 18:51:48 +02:00
992dc74efd core: avoid duplicate calls to Transaction.Data 2015-06-29 18:51:48 +02:00
0b22ad99c1 core: optimize IntrinsicGas 2015-06-29 18:51:48 +02:00
a8889b092b core/types: cache computed block values 2015-06-29 18:51:48 +02:00
11b8d1df59 core/types: cache computed transaction values 2015-06-29 18:51:48 +02:00
8743cc1c1c rlp: add ListSize 2015-06-29 18:51:48 +02:00
a0566c1058 rlp: remove Flat 2015-06-29 18:51:47 +02:00
3d0c6a8345 rlp: pool encoder allocations 2015-06-29 18:51:47 +02:00
c3d6228023 core: add InsertChain benchmarks 2015-06-29 18:51:47 +02:00
7098ec691c rpc: unmask pending block fields
This pleases the RPC tests.
2015-06-29 18:51:47 +02:00
e0e5f74776 eth/downloader, eth/fetcher: use core.GenerateChain in tests
TestMadeupParentBlockChainAttack has been deleted because it was too
hard to port and the attack that it checks the prevention of is being
averted in a different way (through a protocol change).
2015-06-29 18:51:47 +02:00
ceaf1c080b core: add GenerateChain, GenesisBlockForTesting 2015-06-29 18:51:47 +02:00
1d42888d30 core/types: make blocks immutable 2015-06-29 18:51:47 +02:00
654564e164 core/types: make transactions immutable 2015-06-29 18:51:47 +02:00
9d8b512b27 Merge pull request #1356 from Gustav-Simonsson/debug_develop
Debug develop
2015-06-29 09:33:19 -07:00
b39042db56 core, miner: implemented canary 2015-06-29 13:31:49 +02:00
d1e93db3eb core, miner: added write block method & changed mining propagation 2015-06-29 13:31:49 +02:00
059a1e9e4e miner: broadcast block before insertion/validation 2015-06-29 13:31:49 +02:00
5e7db8f5cd Merge pull request #1353 from karalabe/fix-double-fetch
eth/fetcher: don't double filter/fetch the same block
2015-06-29 04:31:13 -07:00
a7d22658ad eth/fetcher: don't drop on future blocks, just not propagate 2015-06-29 14:20:13 +03:00
29d53b2073 eth/fetcher: don't double filter/fetch the same block 2015-06-29 13:49:04 +03:00
61ccc39b56 initialize fields to prevent nil pointer exception 2015-06-29 12:42:47 +02:00
f9264e87ec add json parsing method for resend transaction 2015-06-29 12:32:01 +02:00
a355777ff8 improved error handling in parsing request 2015-06-29 11:13:28 +02:00
a0191910fc Merge pull request #1341 from karalabe/proto-version-negotiation
p2p: support protocol version negotiation
2015-06-28 13:52:37 +02:00
b9ebdffd83 Merge pull request #1335 from tgerring/mistcleanup
Travis and README cleanup
2015-06-27 02:17:35 -07:00
1169ec7681 Merge pull request #1344 from karalabe/monitor-fixes
Monitor fixes
2015-06-27 02:16:12 -07:00
d099a42c85 cmd/geth: fix monitor panic, don't pre-fill with dummy data 2015-06-26 22:05:49 +03:00
7e69392249 cmd/geth: re-scale charts when changing unit magnitudes 2015-06-26 21:48:21 +03:00
216fc267fa p2p: fix local/remote cap/protocol mixup 2015-06-26 20:45:13 +03:00
d84638bd31 p2p: support protocol version negotiation 2015-06-26 15:48:50 +03:00
b0a5be4495 Merge pull request #1321 from karalabe/cut-it-open-3000
Metrics collecting and reporting support
2015-06-25 08:18:42 -07:00
e64625aa82 Merge pull request #1332 from bas-vk/ipcbatch
IPC interface improvements
2015-06-25 08:06:19 -07:00
c6dbe9dc07 Travis and README cleanup 2015-06-25 16:46:54 +02:00
662285074e improved logging for IPC connection lifetime management 2015-06-25 15:54:16 +02:00
e9c0b5431c cmd/geth: finalize mem stats 2015-06-25 16:19:42 +03:00
fdbf8be735 cmd/geth, rpc/api: fix reported metrics issues 2015-06-25 15:33:26 +03:00
5757a0edb5 added IPC timeout support 2015-06-25 14:32:22 +02:00
04910c902a support for large request/response on windows 2015-06-25 04:53:41 -07:00
ffbe5656ff support for large requests/responses 2015-06-25 13:18:10 +02:00
c0343c8f17 cmd/geth: add memory stat collection too 2015-06-25 13:47:06 +03:00
6d92fdc0df added support for batch requests 2015-06-25 12:01:28 +02:00
6b2a03faa2 Merge pull request #1085 from Gustav-Simonsson/key_store_v3
crypto: key store v3
2015-06-25 02:16:54 -07:00
c6e2af14c0 cmd/geth: limit the maximum chart colums to 6 2015-06-25 12:12:11 +03:00
8774fdcd64 Merge pull request #1329 from Gustav-Simonsson/ethash_input_validations
Update Ethash Godeps
2015-06-25 02:06:06 -07:00
3ea6b5ae32 cmd/geth: list the available metrics if none specified 2015-06-25 11:42:45 +03:00
d02f07a983 cmd/geth: polish monitor visuals, add footer, refresh flag 2015-06-25 11:32:21 +03:00
b98b444179 cmd/geth: add attach and rows flags to the monitor command 2015-06-25 10:36:47 +03:00
1ce40d7581 Godeps: remove mist remnants, add termui deps 2015-06-24 18:40:18 +03:00
92ef33d97a rpc/api, cmd/geth: retrievel all percentiles, add time units 2015-06-24 18:34:05 +03:00
302187ae39 cmd/geth: allow branching metric patterns 2015-06-24 18:34:05 +03:00
bf99d5b33c cmd/geth: polish the monitoring charts a bit 2015-06-24 18:34:05 +03:00
e5b820c47b cmd/geth, rpc/api: extend metrics API, add a basic monitor command 2015-06-24 18:34:05 +03:00
bde2ff0343 cmd/geth, rpc/api: move the metrics into the new console 2015-06-24 18:34:05 +03:00
803b3c4a82 eth, ethdb: measure database operation latencies too 2015-06-24 18:34:05 +03:00
0609fcf030 eth: make sure dbs are lvldb before instrumenting 2015-06-24 18:34:04 +03:00
792b0ddccd core, eth, eth/fetcher, ethdb: polish metrics gathering a bit 2015-06-24 18:34:04 +03:00
6260b86c15 eth/fetcher: fix failed merge 2015-06-24 18:34:04 +03:00
43e4a6501b core, ethdb: instrument the block and state db
Conflicts:
	ethdb/database.go
2015-06-24 18:34:04 +03:00
7bd71fa800 godeps: pull in go-metrics 2015-06-24 18:34:04 +03:00
7f92e708c5 cmd/geth, core: impl. percentile reporting, instrument insertions 2015-06-24 18:34:04 +03:00
b426301467 cmd/geth, eth/fetcher: polish metrics reporting, add some more 2015-06-24 18:34:04 +03:00
6994a3daaa p2p: instrument P2P networking layer 2015-06-24 18:33:33 +03:00
821e01b013 cmd/geth, eth/fetcher: initial metrics support
Conflicts:
	cmd/geth/admin.go
2015-06-24 18:33:33 +03:00
ee73f09727 fixed unittest compilation issue 2015-06-24 16:07:44 +02:00
dc58568a25 added eth.resend 2015-06-24 14:56:53 +02:00
f1a4a6e563 added eth.pendingTransactions 2015-06-24 13:53:37 +02:00
8363aba7ac Update Ethash Godeps 2015-06-24 07:17:21 +02:00
d23ec6c419 Change keystore to version 3
* Change password protection crypto in keystore to version 3
* Update KeyStoreTests/basic_tests.json
* Add support for PBKDF2 with HMAC-SHA256
* Change MAC and encryption key to avoid unnecessary hashing
* Add tests for test vectors in new wiki page defining version 3
* Add tests for new keystore tests in ethereum/tests repo
* Move JSON loading util to common for use in both tests and
  crypto packages
* Add backwards compatibility with key store version 1
2015-06-24 06:03:23 +02:00
22c7ce0162 cmd/geth: version bump 0.9.33 2015-06-23 19:20:20 +02:00
983a33cf11 Merge branch 'release/0.9.32' into develop 2015-06-23 19:19:49 +02:00
72e2613a9f Merge branch 'release/0.9.32' 2015-06-23 19:19:33 +02:00
67e6f74e9a cmd/geth: bump 2015-06-23 19:11:20 +02:00
d21c2bfb68 Merge pull request #1314 from karalabe/handle-fetcher-attacks-2
eth/fetcher: handle and test various DOS attacks
2015-06-23 10:04:44 -07:00
6b5532ab0d Merge pull request #1279 from bas-vk/rpc-http
Integrate console and remove old rpc package structure
2015-06-23 07:44:03 -07:00
139439dcdc Merge pull request #1309 from fjl/p2p-fix-lookup-spin
p2p: throttle all discovery lookups
2015-06-23 05:36:58 -07:00
2b3957f373 fixed relative path issue with javascript files 2015-06-23 09:38:30 +02:00
55424a11af improved action description 2015-06-23 09:11:57 +02:00
57c911c398 bugfix in startRPC error handling 2015-06-23 08:26:17 +02:00
3ce17d2862 eth/fetcher: fix a closure data race 2015-06-22 20:13:18 +03:00
99ca4b619b eth/fetcher: clean up test assertions 2015-06-22 18:28:38 +03:00
b53f701c27 eth/fetcher: remove test sleeps (15s -> 2.8s) 2015-06-22 18:08:28 +03:00
1989d1491a eth/fetcher: handle and (crude) test block memory DOS 2015-06-22 16:49:47 +03:00
4ee7f6fc88 added missing change for sign test 2015-06-22 13:54:13 +02:00
6d596b1ad1 fixed eth sign unittest 2015-06-22 13:19:59 +02:00
d36c25bcbc eth/fetcher: handle and test block announce DOS attacks 2015-06-22 14:07:08 +03:00
2e0b56a72b added RPC start/stop support 2015-06-22 12:47:32 +02:00
2737baa657 fixed unittests 2015-06-22 09:17:09 +02:00
f87501b1c5 added batch support to console and attach actions 2015-06-22 09:17:09 +02:00
3ff272b618 moved solidity test to new rpc structure 2015-06-22 09:17:09 +02:00
29297d3b82 fixed bug where history file was create in cwd 2015-06-22 09:17:09 +02:00
ce5c94e471 added attach over http/rpc support 2015-06-22 09:17:09 +02:00
f202563777 added attach over ipc command 2015-06-22 09:17:09 +02:00
36a6b16a3b removed console command 2015-06-22 09:17:09 +02:00
603192cfa7 cleanup comments/code 2015-06-22 09:17:09 +02:00
a4a4e9fcf8 removed old rpc structure and added new inproc api client 2015-06-22 09:17:09 +02:00
3e1d635f8d fixed rpc test failure in eth.blockNumber 2015-06-22 08:54:21 +02:00
9ac1b4e59e fixed rpc test failure in net_peerCount 2015-06-22 08:54:21 +02:00
5fdf72b1ab fixed web3 rpc test failures 2015-06-22 08:54:21 +02:00
c3f6c322c0 added DB api 2015-06-22 08:54:21 +02:00
5c25403b13 refactored old rpc structure to new 2015-06-22 08:54:21 +02:00
fd764d4ff7 added comms http 2015-06-22 08:54:21 +02:00
60c2ccd99c made ipc handler generic and reusable 2015-06-22 08:54:21 +02:00
9cf7913c61 Merge pull request #1304 from obscuren/state-renames
core, miner, xeth: renamed gas methods
2015-06-21 16:49:47 -07:00
7633dfdc08 Merge pull request #1305 from obscuren/database-error-check
core, ethdb, trie: validate database errors
2015-06-21 16:49:14 -07:00
6fb810adaa p2p: throttle all discovery lookups
Lookup calls would spin out of control when network connectivity was
lost. The throttling that was in place only took effect when the table
returned zero results, which doesn't happen very often.

The new throttling should not have a negative impact when the host is
online. Lookups against the network take some time and dials for all
results must complete or hit the cache before a new one is started. This
usually takes longer than four seconds, leaving online lookups
unaffected.

Fixes #1296
2015-06-22 01:07:58 +02:00
398d08a8dd tests: SetGasLimit 2015-06-21 17:09:19 +02:00
07c3de3f75 core, miner, xeth: renamed gas methods
* BuyGas => SubGas
* RefundGas => AddGas
* SetGasPool => SetGasLimit
2015-06-21 17:09:19 +02:00
a40a91d60f trie: fixed tests 2015-06-21 17:08:47 +02:00
c590b505ed core, ethdb, trie: validate database errors 2015-06-21 16:59:15 +02:00
3deded28a5 Merge pull request #1302 from obscuren/mist-removal
mist: R.I.P.
2015-06-21 07:58:08 -07:00
46bd6c43db travis: removed qt deps 2015-06-20 20:33:25 +02:00
42a14b8a09 mist: R.I.P.
/"""""/""""""".
    /     /         \             __
   /     /           \            ||
  /____ /             \           ||
 |     |  In Loving    |          ||
 |     |   Memory      |          ||
 |     |               |          ||
 |     |   2014-2015   |          ||
 |     |     * *   * * |         _||_
 |     |     *\/* *\/* |        | TT |
 |     |     *_\_  /   ...""""""| || |.""...."""""""".""
 |     |         \/.."""""..."""\ || /.""".......""""...
 |     |...."""""""........""""""^^^^"......."""""""".."
 |......"""""""""""""""........"""""...."""""..""-Jeff W.
2015-06-20 14:37:00 +02:00
9c69c051ba Merge pull request #1236 from tgerring/ethtest
ethtest improvements
2015-06-20 05:32:33 -07:00
53e042f0c4 Added link to ARM develop build 2015-06-19 18:49:15 +02:00
4c2ba1af1d Merge pull request #1298 from karalabe/slack-n-bound
eth/fetcher: lower max cache size, add timeout slack
2015-06-19 07:46:45 -07:00
0fa2750fc9 Merge pull request #1290 from tgerring/dataargs
unit test coverage for NewDataArgs
2015-06-19 07:44:39 -07:00
8c4c7ea192 eth/fetcher: lower max cache size, add timeout slack 2015-06-19 16:46:16 +03:00
d1e589289c Expand --test switch 2015-06-19 15:08:53 +02:00
0743243dce Add --skip option to CLI
Disassociates hardcoded tests to skip when running via CLI. Tests still
skipped when running `go test`
2015-06-19 11:38:23 +02:00
d5871fc200 Merge pull request #1295 from karalabe/fix-broadcast-order
eth: fix the propagation/announce order for mined blocks
2015-06-19 10:15:20 +03:00
4180ca7fe4 eth: fix the propagation/announce order for mined blocks 2015-06-19 10:07:37 +03:00
a9659e6dcf recover test logic 2015-06-18 23:46:42 +02:00
8d3faf69d0 Build error fixes 2015-06-18 22:38:17 +02:00
baea8e87e5 Rebase cleanup 2015-06-18 22:27:44 +02:00
01ec4dbb12 Add stdin option 2015-06-18 22:24:07 +02:00
a86452d22c Minor cleanup 2015-06-18 22:20:45 +02:00
49336675f3 Expand CLI options to allow running all tests 2015-06-18 22:20:45 +02:00
516362bcad Allow specifying single depth directory 2015-06-18 22:20:45 +02:00
30444db020 Add lost rebase changes 2015-06-18 22:20:45 +02:00
c941a39b75 Cleanup logging 2015-06-18 22:20:45 +02:00
8507c867b9 Fix geth blocktest command 2015-06-18 22:20:45 +02:00
6931267324 Wire ethtest to new tests structure 2015-06-18 22:20:45 +02:00
6ff956394a DRY file loading 2015-06-18 22:20:45 +02:00
ac0637c413 More consistent test interfaces + test skipping 2015-06-18 22:20:44 +02:00
b6d40a9312 Cleanup/reorg 2015-06-18 22:20:44 +02:00
c5d6fcbaba Return error up stack instead of passing testing var down 2015-06-18 22:20:44 +02:00
24554629b1 DRY log check 2015-06-18 22:15:08 +02:00
7c6ef0ddac Separate and identify tests runners 2015-06-18 22:15:07 +02:00
1b26d4f220 Flatten helper directory 2015-06-18 22:15:07 +02:00
e82100367f Fix paths 2015-06-18 22:13:42 +02:00
a67a15528a Split tests from helper code 2015-06-18 22:13:42 +02:00
7b9fbb088a Flatten vm directory 2015-06-18 22:13:41 +02:00
6415ed0730 Require a first argument of test type 2015-06-18 22:13:41 +02:00
e4f9ec886b Merge pull request #1267 from SilentCicero/develop
eth_sendRawTransaction JSON RPC
2015-06-18 11:33:50 -07:00
8eaaf24b1e Merge pull request #1275 from karalabe/optimise-fetcher
eth/fetcher: separate the announce based sync into its own package
2015-06-18 11:14:26 -07:00
13c25036ea eth/fetcher: since uncles are allowed, drop phase test 2015-06-18 20:10:07 +03:00
ecd19919c5 eth/fetcher: allow backward uncle imports too 2015-06-18 19:43:47 +03:00
90d45f0397 eth: fix test breakage from the previous commit 2015-06-18 18:25:27 +03:00
b91b581b80 eth, eth/fetcher: propagate after header verify, announce only on insert 2015-06-18 18:00:19 +03:00
629705ad53 eth: clean the block request packet handling a bit 2015-06-18 16:09:34 +03:00
5ec6ecc511 eth, eth/fetcher: move propagated block import into fetcher 2015-06-18 15:56:08 +03:00
a9ada0b5ba eth/fetcher: make tests thread safe 2015-06-18 15:56:08 +03:00
37c5ff392f eth/fetcher: build longest chain until proven otherwise 2015-06-18 15:56:08 +03:00
2a7411bc96 eth/fetcher: fix premature queue cleanup, general polishes 2015-06-18 15:56:08 +03:00
497a7f1717 eth, eth/fetcher: define and enforce propagation boundaries 2015-06-18 15:56:08 +03:00
026ee40650 eth/fetcher: deduplicate future blocks 2015-06-18 15:56:08 +03:00
11c8f83a58 eth, eth/fetcher: cache future propagated blocks too 2015-06-18 15:56:08 +03:00
057bc237ad eth, eth/fetcher: use an import queue to store out of order blocks 2015-06-18 15:56:07 +03:00
8b64e041d6 eth/fetcher: add test to check for duplicate downloads 2015-06-18 15:56:07 +03:00
2a1b722d04 eth/fetcher: fix timer reset bug, add initial tests 2015-06-18 15:56:07 +03:00
7c2af1c117 eth, eth/fetcher: separate notification sync mechanism 2015-06-18 15:56:07 +03:00
2cea410656 Merge pull request #1282 from obscuren/state-cleanup
core/state: cleanup & optimisations
2015-06-18 05:29:53 -07:00
430bcdb219 core/vm: clarified SSTORE 2015-06-18 12:25:02 +02:00
53a6145a2b Merge pull request #1287 from karalabe/fix-downloader-cancel-interrupt
eth, eth/downloader: fix processing interrupt caused by temp cancel
2015-06-18 02:50:19 -07:00
15e169e5b6 core: ValidatedHeader (method => function)
Changed header validation method to function in preparation of
@karalabe's PR.
2015-06-18 11:47:50 +02:00
4365668462 eth/downloader: extend slow test to fix even slower CI server... 2015-06-18 00:42:02 +03:00
55dd8fd621 eth/downloader: always reenter processing if not exiting 2015-06-18 00:26:54 +03:00
2f4cbe22f5 eth, eth/downloader: fix processing interrupt caused by temp cancel 2015-06-18 00:04:57 +03:00
5afebc2a4b unit test coverage for NewDataArgs 2015-06-17 18:07:45 +02:00
f5abc9f188 core, core/vm: state improvements and tx pool speed up
Removed full tx validation during state transitions
2015-06-17 17:10:22 +02:00
753d62a4dd core: TMP testing code 2015-06-17 17:10:13 +02:00
ae36beb38f Merge pull request #1269 from bas-vk/console-batch
added batch mode to console
2015-06-17 07:56:09 -07:00
bdd63837ea core/state: removed trie copy 2015-06-17 13:39:19 +02:00
aa699a1283 core/state: removed state from state object 2015-06-17 13:27:51 +02:00
aaddc99c35 core/state: fixed state tests 2015-06-17 12:53:22 +02:00
e4b54f18c6 Merge pull request #1281 from karalabe/fix-overlapping-delivery-hang
eth/downloader: fix #1280, overlapping (good/bad) delivery hang
2015-06-17 03:24:46 -07:00
a3fdef7529 Merge pull request #1274 from Gustav-Simonsson/update_ethash_godep
Update ethash godep
2015-06-17 03:05:51 -07:00
a977f3c0dc xeth, tests: fixed api 2015-06-17 11:44:40 +02:00
30b27336ea core/state: remove the need for common.Value 2015-06-17 11:30:42 +02:00
787a61bb27 core/state, core/vm: reworked storage get / set to use common.Hash 2015-06-17 11:24:40 +02:00
4a1e82cf3f eth/downloader: fix #1280, overlapping (good/bad) delivery hang 2015-06-17 12:03:16 +03:00
5721fcf668 core/state, core/vm: cleanup refunds 2015-06-17 10:20:33 +02:00
be303ba186 Update ethash Godep (again) 2015-06-17 00:56:25 +02:00
1f34daccc3 Added glog messages like Transaction 2015-06-16 12:47:34 -04:00
6add45cd10 Remove Extra Loggers 2015-06-16 12:30:07 -04:00
7ec8c257ff New DataArgs and eth_sendRawTransaction 2015-06-16 12:28:10 -04:00
a9d6846f92 Update ethash Godep 2015-06-16 12:09:39 +02:00
8f372c867d Update Ethereum JSON test files 2015-06-16 12:09:25 +02:00
e952bb65e7 thanks subtly :) 2015-06-16 00:06:28 -04:00
2642e091e9 NewSigArgs arg change. 2015-06-15 16:01:01 -04:00
dfd18d245a cmd/geth: bump 0.9.31 2015-06-15 19:29:22 +02:00
4699ebf534 Merge branch 'release/0.9.30' into develop 2015-06-15 19:29:06 +02:00
5daf8729be Merge branch 'release/0.9.30' 2015-06-15 19:28:48 +02:00
4673b04503 cmd/geth: bump version number 0.9.30 2015-06-15 19:14:34 +02:00
cc0b451119 Merge pull request #1260 from obscuren/tx-drop-low-tx
core: drop low gas tx
2015-06-15 09:09:44 -07:00
f2a2164184 Merge pull request #990 from zsfelfoldi/gasprice
eth: add GasPriceOracle
2015-06-15 08:44:25 -07:00
f475a01326 Merge pull request #1261 from fjl/p2p-no-writes-at-shutdown
p2p: prevent writes at shutdown time
2015-06-15 08:21:30 -07:00
2628103f1d rpc/api: fixed default gas-(price) issue. 2015-06-15 17:21:08 +02:00
ad56aef5d2 Update utils.go 2015-06-15 11:10:40 -04:00
c3b80123e3 Update eth.go 2015-06-15 11:10:24 -04:00
f9f9352ceb Change eth_pushTx case to eth_sendRawTransaction 2015-06-15 10:50:07 -04:00
1e3f4877c0 Changed miner and gpo min gas price to 1 szabo 2015-06-15 16:48:59 +02:00
e79cc42dfe core: moved check for max queue to checkQueue
Moved the queue to check to the checkQueue method so no undeeded loops
need to be initiated or sorting needs to happen twice.
2015-06-15 16:46:45 +02:00
263903378b Merge pull request #1243 from karalabe/instrument-downloader-sync
eth, eth/downloader: separate concerns, clean up test suite
2015-06-15 07:43:37 -07:00
f06f220c7c added printing support for objects 2015-06-15 16:33:36 +02:00
d6233c7d2d Changed variable names 2015-06-15 10:07:32 -04:00
b42b70eb5f fixed rpc/api.GasPrice 2015-06-15 15:55:39 +02:00
610adfd83f fixed xeth.gpo = nil bug 2015-06-15 15:55:39 +02:00
3c7b64ce20 removed duplicate function after rebase 2015-06-15 15:55:39 +02:00
a977cecbe4 fixed gas price corr. factor 2015-06-15 15:55:38 +02:00
6e212bdc6d fallback for uninitialized GPO config values 2015-06-15 15:55:38 +02:00
2e8016c80d fixed initial base price bug 2015-06-15 15:55:38 +02:00
0930e190a7 added missing source 2015-06-15 15:55:38 +02:00
3f94d09c1f fixed saving receipts 2015-06-15 15:55:38 +02:00
70da79f04c p2p: improve disconnect logging 2015-06-15 15:03:46 +02:00
8dcbdcad0a p2p: track write errors and prevent writes during shutdown
As of this commit, we no longer rely on the protocol handler to report
write errors in a timely fashion. When a write fails, shutdown is
initiated immediately and no new writes can start. This will also
prevent new writes from starting after Server.Stop has been called.
2015-06-15 15:03:46 +02:00
aa250e228a eth: don't refetch non fitting blocks to avoid duplicates 2015-06-15 15:18:31 +03:00
cf7c44a7f6 eth/downloader: detailed comment for the race corner case 2015-06-15 15:18:04 +03:00
21fa29111b core: reduce max allowed queued txs per address
Transactions in the queue are now capped to a maximum of 200
transactions. This number is completely arbitrary.
2015-06-15 12:16:29 +02:00
9c03c374e3 eth/downloader: fix import statistic reset, fetch hashes async 2015-06-15 13:05:01 +03:00
6d817e16c1 core, miner: tx pool drops txs below ask price 2015-06-15 11:33:08 +02:00
b240983e2b eth, eth/downloader: do async block fetches, add dl tests 2015-06-15 12:26:05 +03:00
30a9939388 eth/downloader: sanity test for multi peer syncs 2015-06-15 09:22:37 +03:00
fc7abd9886 eth, eth/downloader: move block processing into the downlaoder 2015-06-15 09:22:37 +03:00
0fc71877a7 eth/downloader: add valid peer during attacks (check interference) 2015-06-15 09:22:37 +03:00
80833f8137 eth/downloader: instreument and test the sync peer drop 2015-06-15 09:22:37 +03:00
faae8b7dd8 eth: fix an accidental test compile error 2015-06-15 09:22:37 +03:00
2dd6a62f67 eth/downloader: support individual peers in the test suite 2015-06-15 09:22:36 +03:00
2937903299 eth/downloader: remove uneeded testing functions 2015-06-15 09:22:36 +03:00
66d3dc8690 eth, eth/downloader: move peer removal into downloader 2015-06-15 09:22:36 +03:00
f9a0a13fa9 eth_pushTx send raw signed encoded TX data to the chain through RPC 2015-06-14 18:07:03 -04:00
2a0528303f added batch mode to console 2015-06-13 19:02:46 +02:00
6f5c6150b7 Merge pull request #1255 from obscuren/chain-proc-interupt
eth, core: interrupt the chain processing on stop
2015-06-12 08:04:02 -07:00
645dfd9693 core: changed interrupt strategy
Removed chain manager's select/channel approach when checking for
interrupts. Now using an atomic int32 instead which checked for every
block processed.
2015-06-12 16:52:54 +02:00
1bca2f6ec4 Merge pull request #1256 from obscuren/fix-printable-chars
core/vm: fixed strange output for trace logging & error reporting
2015-06-12 07:46:59 -07:00
90c4493a10 eth, core: interupt the chain processing on stop
Added an additional channel which is used to interupt the chain manager
when it's processing blocks.
2015-06-12 13:41:34 +02:00
aaac1f0cdd Merge pull request #1254 from bas-vk/ipcwindowspathfix
Invalid named pipe name
2015-06-12 04:39:38 -07:00
287f990891 core/vm: Improved error reporting for trace logging 2015-06-12 13:35:14 +02:00
02d629af8f core/vm: fixed printable characters using unicode instead 2015-06-12 11:18:17 +02:00
55a796b7c3 removed obsolete console flag 2015-06-12 09:42:57 +02:00
359e6414e5 fixed windows ipc path issue 2015-06-12 09:32:37 +02:00
4bb9a61049 Merge pull request #1245 from bas-vk/ipcdatadirfix
ipc socket always uses default path
2015-06-11 12:01:07 -07:00
22080e1fdd ipc socket always used default path 2015-06-11 20:35:19 +02:00
e2c2d8e15e Merge pull request #1239 from bas-vk/rpc-apis
RPC refactoring
2015-06-11 07:41:43 -07:00
b3c07f167f fixed incomplete merge action 2015-06-11 15:06:12 +02:00
ec6a7b35f6 removed obsolete print statement 2015-06-11 15:00:33 +02:00
ebaa9b9feb removed binary files 2015-06-11 14:54:03 +02:00
7584e68c21 upgrade web3.js with _extend support 2015-06-11 14:43:05 +02:00
1fe617fa57 added net API 2015-06-11 14:40:38 +02:00
87dace1fa9 added miner API 2015-06-11 14:20:50 +02:00
aa258dcc5f added console binary 2015-06-11 14:18:54 +02:00
3c93034a32 fixed windows build problem 2015-06-11 14:18:08 +02:00
594a34a88d changed send methods for backwards compatability in geth console 2015-06-11 14:17:28 +02:00
1b59f89095 added console command 2015-06-11 14:17:27 +02:00
bbfa0a3dcb added API/IPC commandline flags 2015-06-11 14:15:33 +02:00
348f1562e2 restructured eth rpc API 2015-06-11 14:13:57 +02:00
7e41d7ac51 added shh API 2015-06-11 14:01:41 +02:00
bd38428f33 cleanup of javascript API 2015-06-11 14:01:41 +02:00
87b62f75a7 added txpool API 2015-06-11 14:01:41 +02:00
c6c443385b changed console welcome message 2015-06-11 14:01:41 +02:00
5f8e5a4875 upgrade web3.js with _extend support 2015-06-11 14:01:41 +02:00
cc9ae39933 added admin API 2015-06-11 14:01:41 +02:00
08d72a9245 added personal API 2015-06-11 14:01:41 +02:00
09d0d55fc5 added debug API 2015-06-11 14:01:41 +02:00
faab931ce1 only load supported api's 2015-06-11 14:01:40 +02:00
d2a87f6f72 added net API 2015-06-11 14:01:40 +02:00
4b9b633dfe added miner API 2015-06-11 14:01:40 +02:00
cb7f2d43b6 added console binary 2015-06-11 14:01:40 +02:00
8aea85e374 fixed windows build problem 2015-06-11 14:01:39 +02:00
0a600a03ee fixed unittest build problem 2015-06-11 14:01:39 +02:00
862117e4bd changed send methods for backwards compatability in geth console 2015-06-11 14:01:39 +02:00
a1a475fb92 added console command 2015-06-11 14:01:39 +02:00
2a0d888326 added API/IPC commandline flags 2015-06-11 14:01:39 +02:00
8ebf2d8fad added RPC/IPC support 2015-06-11 14:01:39 +02:00
2f55a1d798 restructured eth rpc API 2015-06-11 14:01:39 +02:00
6609d45ef4 Merge pull request #1228 from obscuren/vm-optimisations
core/vm: optimisations
2015-06-11 03:32:39 -07:00
13bd452faf Merge pull request #1227 from karalabe/block-fetcher-optimisations
eth: optimize the notification/explicit fetch mechanism
2015-06-11 03:31:41 -07:00
37111aa4bd core: retry block now also parellise nonce checks 2015-06-11 12:06:05 +02:00
f599a1b5f1 core/vm: added a comment regarding the uint64 vs *big.Int 2015-06-11 11:59:30 +02:00
9e9bd35557 cmd/geth: Added optional debug flag for reprocess block 2015-06-11 11:44:39 +02:00
979ebfc126 Merge pull request #1224 from karalabe/report-import-progress
cmd/geth, eth/downloader: collect and report import progress too
2015-06-10 15:30:20 -07:00
8482855bc7 Merge pull request #1218 from tgerring/rpcsign
Updated RPC sign test
2015-06-10 15:11:19 -07:00
acb59f3243 Merge pull request #1223 from obscuren/tx-pool-vroooooom
core: fixed race condition in the transaction pool
2015-06-10 12:10:18 -07:00
5cfae0536f cmd/evm: print trace when running programs 2015-06-10 21:09:12 +02:00
e7627623b9 core/vm: reverse loop stack 2015-06-10 21:08:54 +02:00
f94c5473ad core/vm: fixed a bug where Data ignored the stack ptr 2015-06-10 21:08:04 +02:00
10af69b57c core, core/vm: moved logger and added gas cost to struct logging 2015-06-10 19:56:40 +02:00
3c1cccc801 eth/downloader: fetch the block hashes on the fly, when needed 2015-06-10 20:12:22 +03:00
e61db7145a eth: dedup fetches to ensure no blocks are pulled twice 2015-06-10 19:47:59 +03:00
355b1e3bb1 eth: randomly fetch announced block (don't hammer origin) 2015-06-10 19:47:59 +03:00
b9affbf9fe eth: discard fetched blocks that don't fit (no goroutine) 2015-06-10 19:47:59 +03:00
2e0694b606 Updated test 2015-06-10 12:35:35 -04:00
fc2a061d51 core/vm: unexported stack again. No longer required 2015-06-10 17:47:36 +02:00
065aff9ffa core/vm: documentation and name changes 2015-06-10 17:47:36 +02:00
4407524d13 core: fixed race condition for subscriptions 2015-06-10 17:13:32 +02:00
29f7902fee core: fixed test 2015-06-10 17:13:32 +02:00
65a48f9cd8 core: fixed race condition in the transaction pool
Removed `Stop/Start` mechanism from the transaction pool.
2015-06-10 17:13:32 +02:00
c4af70d0cc cmd/geth: round the import ETA before converting to string 2015-06-10 18:07:23 +03:00
271fb20ecb cmd/geth, eth/downloader: rough guess at the import eta 2015-06-10 18:01:05 +03:00
858a6f0be9 Merge pull request #1230 from fjl/p2p-discover-fix-ping-test
p2p/discover: deflake TestUDP_successfulPing
2015-06-10 07:51:48 -07:00
f249ccaa89 cmd/evm: implements vm.Environment 2015-06-10 16:46:43 +02:00
a8e4cb6dfe p2p/discover: use separate rand.Source instances in tests
rand.Source isn't safe for concurrent use.
2015-06-10 15:18:01 +02:00
cf3aabb9d3 miner: update gas used after tx proc for pending block 2015-06-10 13:52:38 +02:00
261a8077c4 p2p/discover: deflake TestUDP_successfulPing 2015-06-10 13:08:21 +02:00
1774c49456 core: log tx count for each set of blocks we're importing 2015-06-10 12:57:58 +02:00
6fb6e6679e core/vm, core/state: added storage to structured vm logging 2015-06-10 12:57:37 +02:00
38c61f6f25 core, core/vm: added structure logging
This also reduces the time required spend in the VM
2015-06-10 12:23:49 +02:00
ff5b3ef087 core/vm: added structured logging 2015-06-10 10:59:44 +02:00
468501cb86 core/vm: changed program counter to uint64 2015-06-10 10:44:46 +02:00
b3d5ce7d48 cmd/geth, eth/downloader: collect and report import progress too 2015-06-10 01:20:35 +03:00
dffe6d32d6 Merge pull request #1222 from obscuren/state-vm-test-suit-fix
tests: check gas limit error
2015-06-09 14:20:41 -07:00
6a5c9aff3b tests: check gas limit error 2015-06-09 22:49:33 +02:00
e972a116ac Merge pull request #1221 from karalabe/fix-p2p-dial-test
p2p: fix a close race in the dial test
2015-06-09 22:00:49 +02:00
1cbbfbe7fa p2p: fix a close race in the dial test 2015-06-09 22:26:26 +03:00
7e58949c3f cmd/geth: develop version bump 0.9.29 2015-06-09 21:14:11 +02:00
667f5a09c3 Merge branch 'release/0.9.28' into develop 2015-06-09 21:12:44 +02:00
bac9a94ddf Merge branch 'release/0.9.28' 2015-06-09 21:12:25 +02:00
14994fa21b rpc: skip test if solc version doesn't match 2015-06-09 21:02:24 +02:00
bc6031e7bb core, xeth: moved nonce management burden from xeth to txpool 2015-06-09 21:01:02 +02:00
93f4852844 cmd/geth: bumped version number 0.9.28 2015-06-09 21:01:02 +02:00
5950755b12 Merge pull request #1220 from karalabe/fix-chain-deadlock2
core: fix a lock annoyance and potential deadlock
2015-06-09 12:00:47 -07:00
4541c22964 event/filter: hack around data race in the test 2015-06-09 21:33:39 +03:00
d652a58ada core: fix a race condition accessing the gas limit 2015-06-09 21:13:21 +03:00
fecf214175 core: fix a lock annoyance and potential deadlock 2015-06-09 21:02:26 +03:00
5f341e5db5 Merge pull request #1212 from fjl/p2p-eth-block-timeout
eth, p2p: improve write timeouts and behaviour under load
2015-06-09 09:51:09 -07:00
73c355591f core, eth: document that result of GetTransactions is modifiable 2015-06-09 17:07:10 +02:00
8dc3048f65 eth/downloader: fix hash fetch timeout handling
Fixes #1206
2015-06-09 17:07:10 +02:00
3239aca69b p2p: bump global write timeout to 20s
The previous value of 5 seconds causes timeouts for legitimate messages
if large messages are sent.
2015-06-09 17:07:10 +02:00
2c24a73e25 eth: add protocol tests
The protocol tests were commented out when eth/downloader was introduced.
2015-06-09 17:07:10 +02:00
6c73a59806 eth: limit number of sent transactions based on message size
Nodes that are out of sync will queue many transactions, which causes
the initial transactions message to grow very large. Larger transactions
messages can make communication impossible if the message is too big to
send. Big transactions messages also exhaust egress bandwidth, which
degrades other peer connections.

The new approach to combat these issues is to send transactions in
smaller batches. This commit introduces a new goroutine that handles
delivery of all initial transaction transfers. Size-limited packs of
transactions are sent to one peer at a time, conserving precious egress
bandwidth.
2015-06-09 17:07:10 +02:00
41b2008a66 eth: limit number of sent blocks based on message size
If blocks get larger, sending 256 at once can make messages large
enough to exceed the low-level write timeout.
2015-06-09 17:06:31 +02:00
7aefe123e9 core/types: add Transaction.Size 2015-06-09 17:06:31 +02:00
fda49f2b52 Merge pull request #1213 from karalabe/polish-console-prettyprinter
jsre: patch up the pretty printer to have a decent look
2015-06-09 07:29:32 -07:00
d6f4c515f5 jsre: print function arguments too 2015-06-09 17:23:44 +03:00
c71ab2a6a3 Merge pull request #1219 from Gustav-Simonsson/precompiled_ec_recover_padding
Precompiled ec recover padding
2015-06-09 07:21:23 -07:00
7842559353 jsre: sort pretty print output, fields before funcs 2015-06-09 17:19:56 +03:00
6e3b58e491 Remove unneeded if check on EC recover padding 2015-06-09 16:03:05 +02:00
365576620a Merge pull request #1216 from karalabe/fix-eth-dataraces
Fix various data races in eth and core
2015-06-09 06:53:49 -07:00
15166f880b Skip BlockTests/bcValidBlockTests SimpleTx3 2015-06-09 15:53:31 +02:00
ad5b5a4895 Pad precompiled EC recover input and add validations 2015-06-09 15:41:15 +02:00
d8e55a5cc3 Skip VMTests RandomTests temporarily until they are fixed 2015-06-09 15:40:43 +02:00
e885a2912b Update Ethereum JSON test files 2015-06-09 15:39:24 +02:00
ebf2aabd25 core: fix up a deadlock caused by double locking 2015-06-09 16:26:44 +03:00
60b780c21b Merge pull request #1217 from tgerring/rpcsign
Fix RPC sign
2015-06-09 06:19:39 -07:00
76148515fa skip sol on new compiler 2015-06-09 15:19:20 +02:00
ff84352fb7 p2p: fix close data race 2015-06-09 16:12:24 +03:00
f371e6c81a Merge pull request #1156 from tgerring/issue1145
Differentiate between 0 and unspecified gas/gasprice
2015-06-09 05:49:55 -07:00
046411866b Fixed signing + tests 2015-06-09 08:47:20 -04:00
ca8cb65b73 core: fix data race accessing ChainManager.currentBlock 2015-06-09 15:30:46 +03:00
07baf66200 core: fix data race in accessing ChainManager.td 2015-06-09 15:23:20 +03:00
1a96798642 gas -> gasprice 2015-06-09 08:13:26 -04:00
1c364b6beb gas -> gasprice 2015-06-09 08:13:25 -04:00
c8a9a4e76d Differentiate between 0 and unspecified gas/gasprice 2015-06-09 08:13:25 -04:00
d09ead546c eth: fix a data race in the hash announcement processing 2015-06-09 15:09:15 +03:00
f86707713c eth: fix data race accessing peer.td 2015-06-09 14:56:27 +03:00
3054fd4811 Merge pull request #1215 from obscuren/issue1202
core: skip genesis block for reprocess. Closes #1202
2015-06-09 04:46:13 -07:00
7da8ebdfd0 Fixed readme links and description 2015-06-09 13:45:35 +02:00
44147d057d eth: fix data race accessing peer.recentHash 2015-06-09 14:27:44 +03:00
190c1b688a core: skip genesis block for reprocess. Closes #1202 2015-06-09 13:24:32 +02:00
05cae69d72 Merge pull request #1188 from karalabe/newblockhashes-proposal
eth: implement the NewBlockHashes protocol proposal
2015-06-09 04:07:46 -07:00
087949227c Merge pull request #1153 from karalabe/downloader-banned-starvation-attack
eth/downloader: gather and ban hashes from invalid chains
2015-06-09 03:45:41 -07:00
3f4ce70d92 jsre: fix wrong separator comma placing due to non consistent field orders 2015-06-09 13:27:45 +03:00
11f65cf885 Merge pull request #1211 from obscuren/genesis_writout_fix
core: write accounts to statedb. Closes #1210
2015-06-09 02:55:47 -07:00
a5b977aa90 core: write accounts to statedb. Closes #1210 2015-06-09 11:37:01 +02:00
0f1cdfa53a Merge pull request #1193 from tgerring/hotbackup
Improve export command
2015-06-08 16:32:38 -07:00
81ceac1b96 Merge pull request #1209 from obscuren/txpool_test_and_pending_fix
core: added a test for missing nonces
2015-06-08 16:04:30 -07:00
5245bd7b20 core: added a test for missing nonces
This test showed the logic in the queue was slightly flawed sending out
transactions to its peer it couldn't even resolve itself.
2015-06-09 00:41:47 +02:00
8216bb901c eth: clean up pending announce download map, polish logs 2015-06-09 00:37:10 +03:00
55b7c14554 Merge pull request #1199 from obscuren/settable_genesis_nonce
core: settable genesis nonce
2015-06-08 13:43:41 -07:00
75522f95ce Merge pull request #1204 from carver/deep-log-crashfix
crash fix: skip deep log if self.chain is not caught up
2015-06-08 13:35:11 -07:00
a9c058dfe0 crash fix: skip deep log if self.chain is not caught up
@see trace https://gist.github.com/eupraxic/87fdfefe702c51d5944d
2015-06-08 11:49:59 -07:00
9ed166c196 eth: split and handle explicitly vs. download requested blocks 2015-06-08 20:38:39 +03:00
44e5ff7d15 Fix blocktest 2015-06-08 12:55:15 -04:00
6244b10a8f core: settable genesis nonce
You can set the nonce of the block with `--genesisnonce`. When the
genesis nonce changes and it doesn't match with the first block in your
database it will fail. A new `datadir` must be given if the nonce of the
genesis block changes.
2015-06-08 18:33:43 +02:00
fdccce781e eth: fetch announced hashes from origin, periodically 2015-06-08 19:24:56 +03:00
8c012e103f eth: mark blocks as known when broadcasting hashes too 2015-06-08 18:44:02 +03:00
6f415b96b3 eth: implement the NewBlockHashes protocol proposal 2015-06-08 18:44:02 +03:00
4ed3509a02 eth/downloader: test registration rejection on head ban 2015-06-08 15:02:52 +03:00
c4f224932f eth/downloader: reject peer registration if head is banned 2015-06-08 14:46:31 +03:00
63c6cedb14 eth/downloader: cap the hash ban set, add test for it 2015-06-08 14:12:00 +03:00
4b2dd44711 eth/downloader: fix throttling test to be less timing dependent 2015-06-08 13:23:58 +03:00
2d627995cf eth/downloader: fix another rebase error 2015-06-08 13:23:58 +03:00
b40c796ff7 eth/downloader: preallocate the block cache 2015-06-08 13:23:58 +03:00
1d7bf3d39f eth/downloader: fix merge compile error 2015-06-08 13:23:58 +03:00
6d497f61c6 eth/downloader: don't block hash deliveries while pulling blocks 2015-06-08 13:23:58 +03:00
9da0232eef eth/downloader: update test for shitty travis 2015-06-08 13:23:58 +03:00
0275fcb3d3 eth/downloader: clean up and simplify the code a bit 2015-06-08 13:23:58 +03:00
abdfcda4dd eth/downloader: short circuit sync if head hash is banned 2015-06-08 13:23:58 +03:00
84bc93d8cb eth/downloader: accumulating hash bans for reconnecting attackers 2015-06-08 13:23:58 +03:00
eedb25b22a eth/downloader: clean up tests and unused variables 2015-06-08 13:23:57 +03:00
c6faa18ec9 Merge pull request #1198 from fjl/core-fix-nonce-check
core: fix nonce verification one more time
2015-06-08 01:31:34 -07:00
6c27e2aaf6 core: add bad block for the 'missing nonce check' fork 2015-06-08 02:54:10 +02:00
0b493910d3 core: fix the nonce check one more time
The block nonce verification was effectively disabled by a typo.
This time, there is an actual test for it.
2015-06-08 02:19:39 +02:00
4ab0cedf42 Export should start with block 0 2015-06-06 10:59:56 -04:00
2729e6294a Improved error checking 2015-06-06 10:04:13 -04:00
ed621aae33 Cleanup 2015-06-06 09:50:23 -04:00
e822f440b0 added ARM builds 2015-06-06 14:33:08 +02:00
d65b64c884 Allow export command to take first and last args 2015-06-06 00:02:32 -04:00
89c9320d80 Allow exporting subset of chain 2015-06-05 23:01:54 -04:00
43ceb0f5c7 cmd/geth: version bump 0.9.27 2015-06-05 17:36:42 +02:00
7ab87f9f6e wip 2015-06-05 17:33:30 +02:00
b94a76d17e Merge pull request #1189 from karalabe/downloader-polishes
eth/downloader: handle timeouts more gracefully
2015-06-05 08:31:57 -07:00
8c28126984 Merge pull request #1100 from karalabe/drop-sync-peer-on-empty-hash
eth, eth/downloader: fix #1098, elevate empty hash errors to peer drops
2015-06-05 08:28:08 -07:00
94e525ae12 eth, eth/downloader: fix #1098, elevate empty hash errors to peer drops 2015-06-05 12:52:48 +03:00
328ef60b85 eth/downloader: differentiate stale and nonexistent deliveries 2015-06-05 12:37:48 +03:00
94e4aa6ea9 eth/downloader: log hard timeouts and reset capacity 2015-06-05 11:53:46 +03:00
067e66b348 Merge pull request #1185 from fjl/p2p-nat-timeouts
p2p/nat: request timeouts for UPnP discovery
2015-06-04 15:55:39 -07:00
fc6a5ae3ec p2p/nat: add timeout for UPnP SOAP requests 2015-06-04 22:25:43 +02:00
6a831ca015 Godeps: update github.com/huin/goupnp to 5cff77a69fb22f5
This includes a fix adding a timeout to router discovery requests.
2015-06-04 22:25:43 +02:00
8b4605c336 Merge pull request #1186 from obscuren/log_fixes
tests: log coalescing fixes
2015-06-04 10:49:00 -07:00
246db4250b tests: use state logs instead own kept logs 2015-06-04 19:48:23 +02:00
45152dead5 Merge pull request #1181 from obscuren/txpool_fixes
cmd: transaction pool fixes and improvements
2015-06-04 10:47:23 -07:00
10fc733767 Merge pull request #1184 from karalabe/nonstop-block-fetches
eth/downloader: fix #1178, don't request blocks beyond the cache bounds
2015-06-04 10:42:34 -07:00
912cf7ba04 core: added fork test & double nonce test 2015-06-04 19:28:39 +02:00
0f51ee6c88 crypto: return common.Address rather than raw bytes 2015-06-04 19:28:39 +02:00
dcdb4554d7 core: documented changes in tx pool 2015-06-04 16:19:22 +02:00
cf5ad266f6 core: only change the nonce if the account nonce is lower 2015-06-04 15:44:42 +02:00
d754c25cc8 eth/downloader: drop log entry from peer, it's covered already 2015-06-04 16:22:55 +03:00
24cca2f18d eth/downloader: log after state updates, easier to debug 2015-06-04 15:10:43 +03:00
28c32d1b1b eth/downloader: fix #1178, don't request blocks beyond the cache bounds 2015-06-04 14:51:14 +03:00
2bb0e48a7b skipped failing natspec tests 2015-06-04 13:17:47 +02:00
9dd12a64a7 core: renamed txs to pending 2015-06-04 13:16:31 +02:00
9b27fb91c0 cmd/geth, common/natspec: updating tests (still failing?) 2015-06-04 11:41:20 +02:00
36c0db2ac9 xeth: use the correct nonce for creating transactions 2015-06-04 11:35:37 +02:00
140d883901 core: test updates 2015-06-03 22:53:33 +02:00
d09a6e5421 core, eth, miner: moved nonce management to tx pool.
Removed the managed tx state from the chain manager to the transaction
pool where it's much easier to keep track of nonces (and manage them).
The transaction pool now also uses the queue and pending txs differently
where queued txs are now moved over to the pending queue (i.e. txs ready
for processing and propagation).
2015-06-03 22:43:23 +02:00
5197aed7db cmd/utils, eth: core.NewBlockProcessor no longer needs TxPool 2015-06-03 22:43:23 +02:00
ec7a2c3442 core: don't remove transactions after block processing
The transaction pool drops processed transactions on its own
during pool maintenance.
2015-06-03 22:43:23 +02:00
5721c43585 core: update documentation comments for TxPool 2015-06-03 22:43:23 +02:00
ca31d71107 core: remove unused code from TxPool 2015-06-03 22:43:23 +02:00
08befff8f1 core: compute less transaction hashes in TxPool 2015-06-03 22:43:23 +02:00
770a0e7839 wip 2015-06-03 22:39:17 +02:00
b26f5e0bb7 types: block json unmarshal method added 2015-06-03 22:39:17 +02:00
fa4aefee44 core/vm: cleanup and renames 2015-06-03 22:39:17 +02:00
8610314918 Merge pull request #1167 from Gustav-Simonsson/check_ec_recover_err
Add missing err checks on From()
2015-06-03 10:29:47 -07:00
71d9367edc Merge pull request #1151 from fjl/parallel-nonce-2
core: re-add parallel nonce checks
2015-06-03 09:12:06 -07:00
122d2db095 Merge pull request #1150 from fjl/fix-jumpdest
core/vm: improve JUMPDEST analysis
2015-06-03 09:11:56 -07:00
0cd72369f7 Merge pull request #1176 from karalabe/congestion-control
eth/downloader: add a basic block download congestion control
2015-06-03 08:24:52 -07:00
02f785af70 Merge pull request #1166 from Gustav-Simonsson/add_ec_sig_validations
Add EC signature validations before call to libsecp256k1
2015-06-03 08:11:24 -07:00
c9ed9d253a tests/files: update tests to d309b4679a58d2 2015-06-03 16:25:06 +02:00
48fb0c3213 core/vm: check for 'no code' before doing any work 2015-06-03 16:25:06 +02:00
ea2718c946 core/vm: improve JUMPDEST analysis
* JUMPDEST analysis is faster because less type conversions are performed.
* The map of JUMPDEST locations is now created lazily at the first JUMP.
* The result of the analysis is kept around for recursive invocations
  through CALL/CALLCODE.

Fixes #1147
2015-06-03 16:25:05 +02:00
edbd902a1b Initialise curve N value in package init 2015-06-03 14:44:29 +02:00
3ec159ab6b eth/downloader: demote peers if they exceed the soft limits at 1 blocks already 2015-06-03 15:43:12 +03:00
c9a546c310 eth/downloader: add a basic block download congestion control 2015-06-03 14:40:11 +03:00
827bccb64b Merge pull request #1175 from karalabe/keccak-update
crypto/sha3: pull in latest keccak from go crypto (45% speed increase)
2015-06-03 04:13:31 -07:00
14e7192d9c crypto/sha3: pull in latest keccak from go crypto (45% speed increase) 2015-06-03 12:00:39 +03:00
9085b10508 Merge pull request #1169 from Gustav-Simonsson/unsupport_bruncles
Unsupport bruncles
2015-06-03 01:20:59 -07:00
0fa9d2431f Add new 0th gen uncle test 2015-06-02 14:47:23 +02:00
8a76b45253 Use older version of stSpecialTest until JUMPDEST fix is merged 2015-06-02 12:25:43 +02:00
8962af2e42 Update Ethereum JSON test files 2015-06-02 12:15:25 +02:00
55bf5051ad Unsupport bruncles 2015-06-01 22:43:05 +02:00
5a692ba4f6 Update Ethereum JSON test files 2015-06-01 22:34:44 +02:00
147a699c65 Add missing err checks on From() (skip RPC for now) 2015-06-01 22:12:03 +02:00
32e1b104f8 Add EC signature validations before call to libsecp256k1 2015-06-01 21:06:52 +02:00
55b60e699b core: insert less length zero chains
This reduces the amount of queueEvents that are sent internally.
2015-06-01 12:48:12 +02:00
e7e2cbfc01 core: re-add parallel nonce checks
In this incancation, the processor waits until the nonce
has been verified before handling the block.
2015-06-01 12:47:13 +02:00
5b14fdb94b Merge pull request #1161 from tgerring/bootnode
Updated SA boot node
2015-06-01 09:51:24 +02:00
057d36b049 Update bootnode 2015-05-31 13:48:27 -05:00
a906a84950 Merge pull request #1155 from karalabe/fix-chainmanager-datarace
core: fix #1154, sort out data race accessing the future blocks
2015-05-30 01:21:09 +02:00
b7fc85d68e core: fix #1154, sort out data race accessing the future blocks 2015-05-29 23:46:10 +03:00
b4818a003a Update Ethereum JSON test files 2015-05-29 13:12:54 +02:00
0e703d92ac Merge branch 'release/0.9.26' 2015-05-28 18:21:14 +02:00
12b90600eb core: moved guards 2015-05-28 18:18:23 +02:00
2587b0ea62 Merge branch 'release/0.9.26' into develop 2015-05-28 18:01:54 +02:00
f082c1b895 Merge branch 'release/0.9.26' 2015-05-28 18:01:40 +02:00
d51d74eb55 cmd/geth: bump version v0.9.26 2015-05-28 17:43:05 +02:00
35806ccc1c build server fix 2015-05-28 17:18:13 +02:00
b25e8b7079 Merge pull request #1142 from obscuren/100-pct-block-prop
eth: 100% block propogation
2015-05-28 08:07:11 -07:00
e5d7627427 eth: 100% block propogation 2015-05-28 17:01:44 +02:00
a225ef9c13 Merge pull request #1140 from Gustav-Simonsson/fix_account_unlock_logging
Validate account length and avoid slicing in logging
2015-05-28 07:39:13 -07:00
b6e137b2b4 Merge pull request #1141 from obscuren/parallelisation-issue
Parallelisation issue
2015-05-28 07:37:37 -07:00
03178a77b6 Merge pull request #1132 from obscuren/log_optimisations
core: log optimisations
2015-05-28 07:35:07 -07:00
16038b4e67 core: added bad block 2015-05-28 16:26:19 +02:00
109f995684 core: log block hash during nonce error 2015-05-28 15:46:36 +02:00
75f5ae80fd core: partially removed nonce parallelisation and added merge error chk
Invalid forks are now detected

Current setup of parellelisation actually inserts bad blocks. This fix
is tmp until a better one is found
2015-05-28 15:35:50 +02:00
9138955ba5 Validate account length and avoid slicing in logging 2015-05-28 15:20:05 +02:00
4baa5ca963 Merge pull request #1137 from obscuren/web3_update
cmd/geth: updated web3
2015-05-28 04:40:14 -07:00
598e454d46 cmd/geth: updated web3 2015-05-28 13:24:09 +02:00
9f467c387a Merge pull request #1123 from fjl/lean-blockchain-commands
cmd/geth: leaner blockchain commands
2015-05-28 04:17:47 -07:00
8add3bb009 Merge pull request #1135 from karalabe/tempban-invalid-hashes
core, eth/downloader: expose the bad hashes, check in downloader
2015-05-28 04:13:08 -07:00
29b0480cfb core, eth/downloader: expose the bad hashes, check in downloader 2015-05-28 14:03:10 +03:00
e84bbcce3c cmd/geth: don't flush databases after import 2015-05-28 01:20:58 +02:00
e1fe75e3b6 cmd/utils: use constant for import batch size 2015-05-28 01:20:58 +02:00
a8bc2181c9 cmd/utils: skip batches with known blocks during import
This makes block importing restartable.
2015-05-28 01:20:58 +02:00
67effb94b6 cmd/geth, cmd/utils: make chain importing interruptible
Interrupting import with Ctrl-C could cause database corruption
because the signal wasn't handled. utils.ImportChain now checks
for a queued interrupt on every batch.
2015-05-28 01:09:26 +02:00
705beb4c25 cmd/utils: print errors only once if stdout and stderr are the same file 2015-05-28 01:09:26 +02:00
74706a0f02 cmd/geth, cmd/utils: rename utils.Get* -> utils.Make*
The renaming should make it clearer that these functions create a new
instance for every call. @obscuren suggested this renaming a while ago.
2015-05-28 01:09:26 +02:00
8e4512a5e7 p2p/nat: bump timeout in TestAutoDiscRace 2015-05-28 01:09:26 +02:00
651030c98d cmd/geth: move blockchain commands to chaincmd.go 2015-05-28 01:09:26 +02:00
62671c93c4 cmd/mist: use utils.SetupLogger 2015-05-28 01:09:26 +02:00
3b9808f23c cmd/geth, cmd/utils: don't use Ethereum for import, export and upgradedb
The blockchain commands don't need the full stack. With this change,
p2p, miner, downloader, etc are no longer started for blockchain
operations.
2015-05-28 01:09:26 +02:00
e3253b5d5e core: fixed an issue with storing receipts 2015-05-28 01:00:23 +02:00
27e0d2a973 Merge pull request #1128 from karalabe/hard-disconnect-trial
eth: hard disconnect if a peer is flaky
2015-05-27 15:28:39 -07:00
5479be9f64 Merge pull request #1129 from obscuren/database_cache_removal
ethdb, common: cache removal
2015-05-27 10:00:08 -07:00
903b95fffa Merge pull request #1124 from karalabe/detaied-download-progress
cmd/geth: expand admin.progress() to something meaningful
2015-05-27 09:05:46 -07:00
020006a8ed common, ethdb: removed caching and LastTD 2015-05-27 18:03:16 +02:00
5235e01b8d eth: hard disconnect if a peer is flaky 2015-05-27 18:58:51 +03:00
7595716816 core: adjust gas calculation 2015-05-27 17:01:28 +02:00
3f91ee4ff8 cmd/geth: expand admin.progress() to something meaningful 2015-05-27 16:46:46 +03:00
8951a03db3 Merge pull request #1121 from obscuren/miner_time_fix
Miner time fix
2015-05-27 04:51:42 -07:00
e13f413ef5 Merge pull request #1112 from fjl/fix-console-exit
cmd/geth: exit the console cleanly when interrupted
2015-05-27 04:40:29 -07:00
69f7a1da5a Merge pull request #1122 from Gustav-Simonsson/improve_validate_header_comments
Update ValidateHeader comments
2015-05-27 04:34:34 -07:00
912ae80350 miner: Added 5 blocks wait in prep for #1067 2015-05-27 13:33:52 +02:00
12650e16d3 core, miner: fixed miner time issue and removed future blocks
* Miner should no longer generate blocks with a time stamp less or equal
than it's parent.
* Future blocks are no longer processed and queued directly.
  Closes #1118
2015-05-27 13:30:52 +02:00
34729c365b Merge pull request #1067 from carver/deep-mining-log
miner: log locally mined blocks after they are 5-deep in the chain
2015-05-27 04:30:31 -07:00
bf5f0b1d0c Update ValidateHeader comments 2015-05-27 13:30:24 +02:00
4b29e5ba85 Merge pull request #1120 from Gustav-Simonsson/revert_gas_limit_change
Revert "core: block.gasLimit - parent.gasLimit <= parent.gasLimit / G…
2015-05-27 04:23:55 -07:00
14955bd454 Revert "core: block.gasLimit - parent.gasLimit <= parent.gasLimit / GasLimitBoundDivisor"
This reverts commit be2b0501b5.
2015-05-27 13:01:06 +02:00
de12183d38 deep-mining-log: need ring buffer to be one bigger for all-blocks-mined case 2015-05-26 18:55:52 -07:00
6019f1bb0a deep-mining-log: only track non-stale blocks
if you track stale blocks, then you quickly overflow your ring buffer in the local network case where you're mining every block and generating a lot of stales.
2015-05-26 18:54:56 -07:00
f5ce848cfe Merge branch 'release/0.9.25' into develop 2015-05-27 02:07:13 +02:00
70867904a0 Merge branch 'release/0.9.25' 2015-05-27 02:07:03 +02:00
2c532a7255 cmd/geth: bump version 0.9.25 2015-05-27 02:06:52 +02:00
aada35af9b Merge pull request #1114 from obscuren/develop
core: block.gasLimit - parent.gasLimit <= parent.gasLimit / GasLimitB…
2015-05-26 17:04:42 -07:00
be2b0501b5 core: block.gasLimit - parent.gasLimit <= parent.gasLimit / GasLimitBoundDivisor 2015-05-27 01:52:03 +02:00
3590591e67 Merge pull request #1113 from obscuren/develop
core: block database version update
2015-05-26 16:47:10 -07:00
222249e622 cmd/geth: Flush instead of close. This solves a nil ptr error 2015-05-27 01:38:41 +02:00
b2f2806055 cmd/geth, core: Updated DB version & seedhash debug method 2015-05-27 01:38:41 +02:00
9253fc337e cmd/geth: exit the console cleanly when interrupted
This fix applies mostly to unsupported terminals that do not trigger the
special interrupt handling in liner. Supported terminals were covered
because liner.Prompt returns an error if Ctrl-C is pressed.
2015-05-27 00:54:48 +02:00
612f01400f p2p/discover: bond with seed nodes too (runs only if findnode failed) 2015-05-26 23:30:41 +02:00
3630432dfb p2p/discovery: fix a cornercase loop if no seeds or bootnodes are known 2015-05-26 23:30:40 +02:00
f539ed1e66 p2p/discover: force refresh if the table is empty 2015-05-26 23:30:40 +02:00
5076170f34 p2p/discover: permit temporary bond failures for previously known nodes 2015-05-26 23:30:40 +02:00
6078aa08eb p2p/discover: watch find failures, evacuate on too many, rebond if failed 2015-05-26 23:30:40 +02:00
64174f196f p2p/discover: add support for counting findnode failures 2015-05-26 23:30:40 +02:00
6a674ffea5 Merge pull request #1108 from karalabe/fine-seeding
Fine tune seeder and p2p peer handling
2015-05-26 22:03:11 +02:00
b1f7b5d1f6 Merge pull request #1111 from obscuren/neg_tx_check
core: check negative value transactions. Closes #1109
2015-05-26 11:45:23 -07:00
c37389f19c core: check negative value transactions. Closes #1109 2015-05-26 20:38:26 +02:00
a55f408c10 Merge pull request #1090 from fjl/jsre-fixes
jsre: fixes for concurrent use, improved timer handling
2015-05-26 11:06:54 -07:00
39b1fe8e44 Merge pull request #1086 from debris/solidity_std
common/compiler: compile solidity contracts with std library
2015-05-26 10:58:09 -07:00
365eea9fba Merge pull request #1106 from karalabe/silence-useless-downloader-log
eth/downloader: silence "Added N blocks from..." if N == 0
2015-05-26 09:45:44 -07:00
4de8213887 cmd/geth: fix js console test for p2p server update 2015-05-26 19:35:31 +03:00
68898a4d6b p2p: fix Self() panic if listening is disabled 2015-05-26 19:16:05 +03:00
e1a0ee8fc5 cmd/geth, cmd/utils, eth, p2p: pass and honor a no discovery flag 2015-05-26 19:07:24 +03:00
278183c7e7 eth, p2p: start the p2p server even if maxpeers == 0 2015-05-26 17:49:37 +03:00
ceea1a7051 Merge branch 'develop' 2015-05-26 15:35:57 +02:00
eae0927597 core: prevent crash when last block fails 2015-05-26 15:35:51 +02:00
3083ec5e32 eth/downloader: silence "Added N blocks from..." if N == 0 2015-05-26 16:10:28 +03:00
2f2dd80e48 Merge branch 'develop' 2015-05-26 14:51:41 +02:00
d74ee40c86 cmd/geth: bumped version to 0.9.24 2015-05-26 14:51:28 +02:00
e6b143b00d Merge branch 'develop' 2015-05-26 14:50:37 +02:00
3386ecb59a Merge branch 'release/0.9.24' into develop 2015-05-26 14:49:06 +02:00
52b4e51366 Merge branch 'release/0.9.24' 2015-05-26 14:48:39 +02:00
0a85260bcd cmd/geth: bumped version to 0.9.24 2015-05-26 14:08:51 +02:00
245f30c59b Merge pull request #1014 from fjl/p2p-dialer-3000
p2p: new dialer, peer management without locks
2015-05-26 05:06:00 -07:00
fd38ea4149 Merge pull request #1099 from obscuren/fork_fix
Fork fix
2015-05-26 04:50:04 -07:00
6c2f6f5b03 tests: removed missing block test 2015-05-26 13:48:10 +02:00
a6b46420d0 core: ban hash 38f5bb...a714bc
Hash 38f5bbbffd74804820ffa4bab0cd540e9de229725afb98c1a7e57936f4a714bc
ignored.
2015-05-26 13:48:10 +02:00
f6f81169fe core/vm: Fork fix. Removal of appending 0 bytes in memset 2015-05-26 13:48:10 +02:00
03faccfb08 tests: updated 2015-05-26 13:48:10 +02:00
0de13b0bba Merge pull request #1102 from karalabe/maintain-block-origins
eth, eth/downloader: surface downloaded block origin, drop on error
2015-05-26 04:31:29 -07:00
eafdc1f8e3 eth, eth/downloader: surface downloaded block origin, drop on error 2015-05-26 14:00:21 +03:00
5044eb4b26 Merge pull request #1101 from obscuren/issue-1096
core/vm: Cleanups & SUB output fix. Closes #1096
2015-05-26 03:50:27 -07:00
b419e2631a core/vm: Cleanups & SUB output fix. Closes #1096 2015-05-26 12:42:33 +02:00
cc318ff8db Merge pull request #1078 from carver/patch-1
eth: expand acronym in log message from TD
2015-05-25 02:49:53 +02:00
e221a449e0 cmd/geth, jsre, rpc: run all JS code on the event loop
Some JSRE methods (PrettyPrint, ToVal) bypassed the event loop. All
calls to the JS VM are now wrapped. In order to make this somewhat more
foolproof, the otto VM is now a local variable inside the event loop.
2015-05-25 02:27:37 +02:00
9e1fd70b50 p2p: decrease frameReadTimeout to 30s
This detects hanging connections sooner. We send a ping every 15s and
other implementation have similar limits.
2015-05-25 01:17:14 +02:00
1440f9a37a p2p: new dialer, peer management without locks
The most visible change is event-based dialing, which should be an
improvement over the timer-based system that we have at the moment.
The dialer gets a chance to compute new tasks whenever peers change or
dials complete. This is better than checking peers on a timer because
dials happen faster. The dialer can now make more precise decisions
about whom to dial based on the peer set and we can test those
decisions without actually opening any sockets.

Peer management is easier to test because the tests can inject
connections at checkpoints (after enc handshake, after protocol
handshake).

Most of the handshake stuff is now part of the RLPx code. It could be
exported or move to its own package because it is no longer entangled
with Server logic.
2015-05-25 01:17:14 +02:00
9f38ef5d97 p2p/discover: add ReadRandomNodes 2015-05-25 01:17:14 +02:00
64564da20b p2p: decrease maximum message size for devp2p to 1kB
The previous limit was 10MB which is unacceptable for all kinds
of reasons, the most important one being that we don't want to
allow the remote side to make us allocate 10MB at handshake time.
2015-05-25 01:17:14 +02:00
7b93341836 Godeps: add github.com/davecgh/go-spew 2015-05-25 01:17:14 +02:00
dbdc5fd4b3 p2p: delete Server.Broadcast 2015-05-25 01:17:14 +02:00
2f249fea44 eth: stop p2p.Server on shutdown 2015-05-25 01:17:14 +02:00
394826f520 Merge pull request #1066 from karalabe/peer-db-polishes
p2p/discover: evacuate self from node database during iterations
2015-05-25 01:16:23 +02:00
c31f8e2bd7 compile solidity contracts with std library 2015-05-24 19:12:18 +02:00
f1ce5877ba do not export ring buffer struct 2015-05-23 12:09:59 -07:00
8a7fb5fd34 do not export constant for when to log a deep block you mined 2015-05-23 12:09:52 -07:00
97433f5ef1 expand acronym in log message from TD
to total difficulty
2015-05-22 19:12:59 -07:00
ba295ec6fe Log locally mined blocks, after they are 5-deep in the chain
This helps determine which blocks are unlikely to end up as uncles

 * Store the 5 most recent locally mined block numbers
 * On every imported block, check if the 5-deep block num is in that store
 * Also confirm that the block is signed with miner's coinbase

Why not just check the coinbase? This log is useful if you're running
multiple miners and want to know if *this* miner is performing well.
2015-05-22 12:53:32 -07:00
b2b9b3b567 Merge pull request #1077 from obscuren/disasm
core/vm, rpc: added disasm to `ext_` RPC
2015-05-22 06:51:38 -07:00
7381be8edb core/vm, rpc: added disasm to ext_ RPC 2015-05-22 15:38:46 +02:00
f7415c0bbc Merge pull request #1076 from obscuren/rpc_sign
core: added RPC sign back in
2015-05-22 04:08:51 -07:00
6539ccae7c core: added RPC sign back in 2015-05-22 13:00:04 +02:00
01ddaf5670 Merge pull request #1072 from Gustav-Simonsson/add_random_tests
Add StateTests/RandomTests and VMTests/RandomTests
2015-05-22 02:34:48 -07:00
f5e112ae5a Merge pull request #1074 from bas-vk/issue1068
make registrar available in console
2015-05-22 02:22:49 -07:00
821b578f7e make registrar available in console 2015-05-22 09:13:45 +02:00
6ad817e17b Add StateTests/RandomTests and VMTests/RandomTests 2015-05-21 23:04:46 +02:00
13e662f6de Merge branch 'develop' 2015-05-21 19:53:35 +02:00
054abe20b8 miner: moved break INSIDE the switch ... 2015-05-21 19:53:27 +02:00
8c25a83708 Merge branch 'release/0.9.23' into develop 2015-05-21 18:59:26 +02:00
2c1c78a6d9 Merge branch 'release/0.9.23' 2015-05-21 18:58:57 +02:00
cbd3ae6906 p2p/discover: fix #838, evacuate self entries from the node db 2015-05-21 19:41:46 +03:00
af24c271c7 p2p/discover: fix database presistency test folder 2015-05-21 19:28:10 +03:00
3ea9868b65 miner: on downloader.Done/Fail stop immediately. Ignore pending evs 2015-05-21 18:14:32 +02:00
4600ecb5c7 cmd/geth: bump version 0.9.23 2015-05-21 18:02:15 +02:00
f1cc3619f5 Merge pull request #1055 from ethersphere/autodag
automatic DAG pregeneration for smooth epoch transitions
2015-05-21 09:01:57 -07:00
af28736bd0 Merge pull request #1064 from karalabe/downloader-attacks
Fix two additional download vulnerabilities
2015-05-21 09:00:12 -07:00
06a041589f eth, eth/downloader: remove duplicate consts, bump hash fetch to 2K 2015-05-21 18:16:04 +03:00
bed80133e0 automatic DAG pregeneration for smooth epoch transitions
- backend: AutoDAG bool flag passed from cli/eth.Config to ethereum, autoDAG loop started if true
- backend: autoDAG loop start/stop, remove previous DAG
- cli: AutoDAG bool flag, off by default, but automatically ON if mining
- admin jsre: add startAutoDAG stopAutoDAG and makeDAG in miner section
- switch on/off DAG autogeneration when miner started/stopped on console
2015-05-21 15:53:42 +01:00
1da145675d Merge pull request #1063 from bas-vk/issue1053
prefix dapp key/value entries in extradb
2015-05-21 06:43:17 -07:00
a61e6788db prefix dapp key/value entries in extradb 2015-05-21 15:20:38 +02:00
90b672f1af Merge pull request #1062 from Gustav-Simonsson/tests_updates
Tests updates
2015-05-21 04:49:23 -07:00
bf7dcfce36 Merge pull request #1059 from obscuren/cleanup
Cleanup
2015-05-21 04:11:36 -07:00
907848997b miner: one-shot update loop 2015-05-21 11:57:00 +02:00
207bd55751 eth: reduced max open files for LevelDB 2015-05-21 11:45:35 +02:00
84cd618585 ethdb: documentation and corruption recovery 2015-05-21 11:43:05 +02:00
ef8744d9fc core: switched back to set.Set for uncle verification 2015-05-21 11:36:39 +02:00
ff1630834c xeth: removed Value 2015-05-21 11:36:05 +02:00
52db6d8be5 eth/downloader: circumvent a forged block chain with known parent attack 2015-05-21 08:37:27 +03:00
e8b22b9253 eth/downloader: prevent a peer from dripping bad hashes 2015-05-21 08:07:58 +03:00
9bde7fd72e Merge pull request #1043 from obscuren/test_fixes
core/vm: optimisation on RETURN and updated tests
2015-05-20 03:06:04 -07:00
8fe8ec84f6 Merge pull request #1049 from zsfelfoldi/receipts
Storing tx receipts in extraDb
2015-05-20 03:00:36 -07:00
0300eef94d Merge pull request #1048 from ethersphere/cli-fixes
CLI, JSRE admin and  Solc improvements
2015-05-20 02:31:52 -07:00
6b83a0a589 Merge pull request #1050 from karalabe/handle-slow-download-tester
eth/downloader: fix test to it doesn't time out on a slow machine
2015-05-20 02:29:23 -07:00
adaa49d2cc Merge pull request #1051 from karalabe/fix-odd-naming
eth: fix odd method names in peer set
2015-05-20 02:29:07 -07:00
3c8227b935 eth: fix odd method names in peer set 2015-05-20 10:34:45 +03:00
6f54eb6d9a eth/downloader: fix test to it doesn't time out on a slow machine 2015-05-20 10:15:42 +03:00
00ec4132f8 Storing tx receipts in extraDb 2015-05-20 06:41:50 +02:00
e1d1417729 rpc: NewNotAvailableError instead of NewNotImplementedError if no solc 2015-05-20 05:29:28 +01:00
00f59f5014 fix eth.sign. now implemented in admin jsre until web3.js has it . 2015-05-20 04:38:20 +01:00
b0ae84aa0d multiple contract source for solidity compiler: returns contract array if multiple contracts. fixes #1023 2015-05-20 04:11:48 +01:00
ea893aca8f update web3.js to 0.4.2 2015-05-20 02:58:49 +01:00
d92172f3d4 add usage doc to wallet import 2015-05-20 02:47:13 +01:00
4201a18117 remove solc flair 2015-05-20 02:47:13 +01:00
22b694ee1e solc now in ethereum, fixes solc path setting; setSolc() didnt work 2015-05-20 02:47:13 +01:00
f9abcee0f9 fix solc tests unskip 2015-05-20 02:47:13 +01:00
9617aa8e19 tests: added conditional skip on long running VM tests
Set the TEST_VM_COMPLEX env var to test complex vm tests which require a
lot of ram and quite some time.
2015-05-20 00:21:24 +02:00
f5af1fdca8 core/vm: RETURN op code returns pointer to memory rather than copy 2015-05-20 00:21:23 +02:00
648b352424 tests/vm: updated tests and skipped output for specific tests
Skipped tests due to large return value
2015-05-20 00:21:23 +02:00
79042223dc Merge pull request #1044 from obscuren/thread_safe_block_cache
core: block cache Has method thread safe
2015-05-19 15:11:41 -07:00
b14ee6ce16 Merge pull request #1046 from tgerring/issue1045
Allow unlocking multiple accounts
2015-05-19 15:11:20 -07:00
8dac28f2e3 core: block cache Has method thread safe 2015-05-19 21:50:56 +02:00
87a05c8f38 core: skipped tests while cache disabled 2015-05-19 21:50:26 +02:00
32b8565022 Support multiple account unlock attempts 2015-05-19 14:46:32 -05:00
af8ada45e7 Allow unlocking multiple accounts #1045
Separate accounts with spaces when using --unlock
2015-05-19 13:40:41 -05:00
46d6470c43 Merge pull request #1035 from karalabe/eth-threadsafe-peers
eth: make the peer-set thread safe
2015-05-19 08:50:38 -07:00
9b825e2728 Merge pull request #1036 from tgerring/issue884
JSON RPC null field updates
2015-05-19 06:44:31 -07:00
748263d2f0 Use bytes.Repeat() instead of 32-byte literal 2015-05-19 08:14:48 -05:00
7d9a13e0d5 core: disable cash tmp 2015-05-19 12:59:58 +02:00
6c2ad7b72e Merge pull request #1034 from obscuren/tx_pool_fix
Nonce fix for failing transactions
2015-05-18 12:28:51 -07:00
b7baceefda xeth: remove nonce on error. Fixes #1026 2015-05-18 20:52:25 +02:00
4755caeb2d eth: remote a superfluous peerSet method 2015-05-18 21:35:42 +03:00
5422fe5125 eth: make the peer set thread safe 2015-05-18 21:33:37 +03:00
bd0c0a633b Merge pull request #1022 from obscuren/parallel_nonce_checks
Parallelise nonce checks
2015-05-18 11:13:53 -07:00
d6adadc5e3 Merge pull request #1033 from tgerring/issue1010
Add "removedb" command to Geth
2015-05-18 11:12:58 -07:00
0864f1fc8e Remove unused confirm() method 2015-05-18 12:25:33 -05:00
f14feea436 Refactor user prompts into utils 2015-05-18 12:24:30 -05:00
36a4ba3248 Add user confirmation for removedb 2015-05-18 12:04:35 -05:00
40717465bc core: fixed tests 2015-05-18 18:16:53 +02:00
59c0d01418 core: chain manager no longer exports genesis block 2015-05-18 18:16:53 +02:00
bc5e60cd63 miner: stale block notification 2015-05-18 18:16:53 +02:00
fe41bd6fe8 Add "removedb" command to Geth
Removes the state and blockchain databases
2015-05-18 10:54:15 -05:00
a3a5f8b593 Merge pull request #1032 from tgerring/issue1025
Multiple CORS domains support
2015-05-18 08:49:35 -07:00
54b5c8273d XEth comment clarification 2015-05-18 10:41:56 -05:00
a2598e649d Permit multiple CORS domains
Separated by spaces
2015-05-18 10:31:03 -05:00
62d76b8e1f Cleanup 2015-05-18 10:11:27 -05:00
a528bd04db Return nil for certain fields on eth_getTransactionByHash when not part of a block 2015-05-18 10:09:00 -05:00
677796b351 Merge pull request #1031 from bas-vk/issue1012
fixed race condition in miner
2015-05-18 07:33:06 -07:00
6a72cd45e2 Add wrapper for BlockTests/bcWalletTest.json 2015-05-18 16:28:54 +02:00
1d51cada3c Handle call depth exception for CREATE 2015-05-18 16:23:20 +02:00
d381d9a74c Return nil for certain fields on eth_getBlockByNumber pending 2015-05-18 09:16:10 -05:00
60561cdca2 fixed issue when miner is not stopping af stop command 2015-05-18 16:09:01 +02:00
7778740315 fixed race condition in miner 2015-05-18 15:13:58 +02:00
c67424ecc8 core: parallelise nonce checking when processing blocks
ChainManager now uses a parallel approach to block processing where all
nonces are checked seperatly from the block processing process. This
speeds up the process by about 3 times on my i7
2015-05-18 13:59:22 +02:00
36419defd1 Update Ethereum JSON test files 2015-05-18 12:45:24 +02:00
67d44519ce core: bugfix test 2. set => hash map 2015-05-18 10:49:09 +02:00
54f0f82dd1 ret 2015-05-18 10:14:48 +02:00
e323f0e831 core: tmp diagnostic logs 2015-05-18 10:13:50 +02:00
280b7f23af Merge branch 'hotfix/0.9.22' into develop 2015-05-17 21:35:29 +02:00
915fc0e581 Merge branch 'hotfix/0.9.22' 2015-05-17 21:35:15 +02:00
3a51d5e80c cmd/geth: fixed ver num 2015-05-17 21:34:28 +02:00
443d024843 Merge pull request #1021 from obscuren/global_chain_lock
core: global chain insert lock
2015-05-17 08:54:16 -07:00
27782bbade core: global chain insert lock 2015-05-17 00:55:02 +02:00
426c70ac0b Merge pull request #1011 from obscuren/upgradedb_fix
cmd/geth: delete state db on upgradedb command
2015-05-16 08:48:49 -07:00
28ba374f27 cmd/geth: delete state db on upgradedb command 2015-05-16 17:43:19 +02:00
ad99089567 Merge branch 'hotfix/0.9.21.1' into develop 2015-05-16 13:04:43 +02:00
69f8a1b01a Merge branch 'hotfix/0.9.21-1' 2015-05-16 13:03:30 +02:00
ad7b0efbd3 cmd/geth: hotfix bump 2015-05-16 13:02:30 +02:00
d98a6f85fc core: further improved uncle error messages 2015-05-16 13:02:30 +02:00
c2ef8682fe eth/downloader: moved start event
Start event has moved because it could possibly could stall the miner
2015-05-16 13:02:30 +02:00
fe64a13cea Adjust miner coinbase and not just miner worker coinbase 2015-05-16 12:56:06 +02:00
741fa8ca9c miner: mutex locks on cpu agent. Closes #1007 2015-05-16 12:55:56 +02:00
61e8296bd8 Adjust miner coinbase and not just miner worker coinbase 2015-05-15 21:23:09 -04:00
4b2ee6c30c Merge branch 'release/0.9.21' into develop 2015-05-16 00:27:35 +02:00
1564f1a020 Merge branch 'release/0.9.21' 2015-05-16 00:27:13 +02:00
7ea76fcf99 core, cmd/geth, cmd/mist: cleanup. bump version 0.9.21 2015-05-16 00:26:36 +02:00
79fa05867f xeth: set balance max balance to from in call. Closes #951 2015-05-16 00:03:08 +02:00
d116b9595c Merge pull request #989 from obscuren/develop
core, miner: fork resolving and restart miner after sync op
2015-05-15 15:02:22 -07:00
55d85d60fd eth, cmd/geth: start mining from console respects CLI flag 2015-05-15 20:26:15 +02:00
d3e84cc8b4 miner: properly check for mining operation on Register 2015-05-15 20:26:15 +02:00
5cec1aad15 core, miner: fork resolving and restart miner after sync op
Fork resolving fixes #940
2015-05-15 20:26:15 +02:00
82c0780f81 Merge pull request #996 from karalabe/fix-potential-crosscheck-race
eth/downloader: circumvent download race between crosscheck and hashes
2015-05-15 11:23:44 -07:00
cea1723c68 Merge pull request #997 from karalabe/fix-shitty-test-server-issue
eth/downloader: fix #992, where tests may time out on a slow machine
2015-05-15 11:22:51 -07:00
412cf98bbc eth/downloader: fix #992, where tests may time out on a slow machine 2015-05-15 21:16:42 +03:00
f3ae8f50a5 eth/downloader: circumvent download race between crosscheck and hashes 2015-05-15 20:54:10 +03:00
98998534cb Merge pull request #995 from Gustav-Simonsson/update_state_tests_and_vm_create_return
Update state tests and vm create return
2015-05-15 10:31:41 -07:00
619e8a4f03 Add StateTests/RandomTests but skip for now 2015-05-15 19:17:40 +02:00
164ba56a60 Merge pull request #994 from karalabe/fix-cancel-double-close
eth/downloader: fix cancel channel double close
2015-05-15 10:15:35 -07:00
32276e8b01 Update StateTests and nil create return on failed code deposit 2015-05-15 18:49:31 +02:00
4f0d88cb02 eth/downloader: fix cancel channel double close 2015-05-15 19:43:42 +03:00
830bdb1cfd Update Ethereum JSON tests 2015-05-15 16:08:00 +02:00
dadf01de60 unskip StateTests/stTransactionTest and use test tx nonce 2015-05-15 16:05:11 +02:00
7d71a75d77 Merge pull request #988 from karalabe/fix-downloader-vulnerabilities
Fix downloader vulnerabilities
2015-05-15 06:38:12 -07:00
5c1a7b965c eth/downloader: circumvent a fake blockchain attack 2015-05-15 15:04:15 +03:00
b517967f86 eth/downloader: don't penalize for stale cross checks 2015-05-15 15:03:08 +03:00
83226762c2 eth, eth/downloader: detect and handle madeup hash attacks 2015-05-15 15:01:58 +03:00
9ad515d2dc eth: drop a sync peer if it sends an invalid hash chain 2015-05-15 15:01:58 +03:00
72411eb24c eth/downloader: circumvent hash reordering attacks 2015-05-15 15:01:58 +03:00
bcc2980179 eth/downloader: check sync after failed attacks 2015-05-15 15:01:58 +03:00
366e9627e8 eth/downloader: add a test for detecting missing blocks 2015-05-15 15:01:58 +03:00
cd2fb09051 eth, eth/downloader: prevent hash repeater attack 2015-05-15 15:01:58 +03:00
c1f0d40e34 Merge pull request #987 from obscuren/develop
Miner updates and downloader events
2015-05-15 04:12:46 -07:00
158efbaa45 Merge pull request #984 from tgerring/issue924
Omit replies for RPC notification requests
2015-05-15 04:12:40 -07:00
cfb2b51b74 eth/downloader: fixed test 2015-05-15 12:47:32 +02:00
f6669db001 core: fixed mining strategy 2015-05-15 12:24:29 +02:00
b71091e337 eth, eth/downloader, miner: use download events to check miner start 2015-05-15 00:43:10 +02:00
0f76a1c6df core: changed how head events are checked 2015-05-15 00:42:06 +02:00
580bae0a86 core: improved uncle messages 2015-05-15 00:40:07 +02:00
44a7f997c3 Unreverse ordering 2015-05-14 15:50:39 -05:00
5c6540452a Omit replies for notification requests
When Id is missing, the client does not want a response
2015-05-14 12:39:57 -05:00
3ac34ee3c4 Merge pull request #975 from obscuren/develop
core: changed log message for forks. closes #952
2015-05-14 10:38:10 -07:00
69c78ddbb4 Merge pull request #983 from tgerring/issue958
Format contract code as hexdata
2015-05-14 10:38:01 -07:00
007bced276 Merge pull request #982 from tgerring/issue962
Check for error on DB fetch of tx
2015-05-14 10:37:30 -07:00
6bc8dec7ac Merge pull request #980 from fjl/geth-test-no-scrypt
cmd/geth: use plain keystore for JS tests
2015-05-14 10:36:56 -07:00
4ad8f1035b Format contract code as hexdata 2015-05-14 12:17:19 -05:00
12f82ab2ff Check for error on DB fetch of tx 2015-05-14 11:57:29 -05:00
559cc02313 cmd/geth: use plain keystore for JS tests
This reduces the time it takes to run the tests back to 3 seconds.
2015-05-14 17:51:05 +02:00
b19bf3ec78 core: changed log message for forks. closes #952 2015-05-14 17:16:46 +02:00
060a07cf69 Merge pull request #974 from karalabe/downloader-fix-unknown-parent-attack
eth, eth/downloader: handle a potential unknown parent attack
2015-05-14 08:16:30 -07:00
90b94e64fc Merge pull request #971 from fjl/p2p-limit-tweaks
p2p: tweak connection limits
2015-05-14 08:15:51 -07:00
d2f119cf9b p2p/discover: limit open files for node database 2015-05-14 15:01:13 +02:00
206fe25971 p2p: remove testlog 2015-05-14 14:56:34 +02:00
7fa2607bd1 p2p/discover: bump maxBondingPingPongs to 16
This should increase the speed a bit because all findnode
results (up to 16) can be verified at the same time.
2015-05-14 14:53:29 +02:00
691cb90284 p2p: log remote reason when disconnect is requested
The returned reason is currently not used except for the log
message. This change makes the log messages a bit more useful.
The handshake code also returns the remote reason.
2015-05-14 14:53:29 +02:00
ff87c241a7 Merge pull request #973 from bas-vk/issue972
Introduced default unlock duration when an account is unlocked from t…
2015-05-14 05:48:31 -07:00
fe87feccb1 eth/downloader: add a small additional check to the test 2015-05-14 15:44:54 +03:00
ebf1eb9359 eth/downloader: remove a previous leftover 2015-05-14 15:40:28 +03:00
3eda70c64c eth, eth/downloader: remove parent verification from the downlaoder 2015-05-14 15:38:49 +03:00
1fa48bc5e7 Introduced default unlock duration when an account is unlocked from the console 2015-05-14 14:25:48 +02:00
a4246c2da6 eth, eth/downloader: handle a potential unknown parent attack 2015-05-14 15:24:18 +03:00
7fa740996c Merge pull request #960 from fjl/nat-fixes
p2p/nat: fix UPnP auto discovery
2015-05-14 04:06:13 -07:00
c7a13c9be8 Merge pull request #969 from Gustav-Simonsson/ethash_improve_hashrate_update2
Make read of ethash hashrate atomic and update ethash godep
2015-05-14 04:05:27 -07:00
2b06fe3eff Merge pull request #950 from karalabe/downloader-cancel-sync
eth/downloader: fix deliveries to check for sync cancels
2015-05-14 04:05:13 -07:00
cdeae22356 Merge pull request #949 from bas-vk/issue944
removed invalid filename characters
2015-05-14 04:04:43 -07:00
5f706cd7f5 cmd/utils: print messages from package log through glog
Some of the dependencies use package log. This change ensures that the
log output looks uniform and respects glog flags.
2015-05-14 12:56:37 +02:00
c14de2e973 p2p/nat: tweak port mapping log messages and levels
People stil get confused about the messages. This commit changes
the levels so that the only thing printed at the default level (info)
is a successful mapping.
2015-05-14 12:54:59 +02:00
e4aa011d23 Merge pull request #970 from ethereum/vitalik_quick_test
Created separate family and ancestors environment objects
2015-05-14 03:53:04 -07:00
e7c7b54b82 Godeps: bump github.com/huin/goupnp to c57ae84 2015-05-14 12:29:41 +02:00
663d4e0aff p2p/nat: add test for UPnP auto discovery via SSDP
The test listens for multicast UDP packets on the default interface
because I couldn't get it to work reliably on loopback without massive
changes to goupnp. This means that the test might fail when there is a
UPnP-enabled router attached on that interface. I checked that locally
by looping the test and it passes reliably because the local SSDP server
always responds faster.
2015-05-14 12:13:19 +02:00
bdec8c3e41 Combined two loops 2015-05-14 05:02:15 -04:00
b24f16fa53 Make read of ethash hashrate atomic and update ethash godep 2015-05-14 04:05:49 +02:00
983f5a717a p2p/nat: fix concurrent access to autodisc Interface
Concurrent calls to Interface methods on autodisc could return a "not
discovered" error if the discovery did not finish before the call.
autodisc.wait expected the done channel to carry the found Interface
but it was closed instead.

The fix is to use sync.Once for now, which is easier to get right.
And there is a test. Finally.

This will have to change again when we introduce re-discovery.
2015-05-14 03:53:11 +02:00
7efeb4bd96 p2p: bump maxAcceptConns and defaultDialTimout
On the test network, we've seen that it becomes harder to connect
if the queues are so short.
2015-05-14 03:48:28 +02:00
fca3333f7f Created separate family and ancestors environment objects 2015-05-13 20:46:23 -04:00
bc83761996 Fixed max uncle count error message 2015-05-13 20:29:57 -04:00
f7fdb4dfbe Merge pull request #966 from fjl/fixup-discover-chunked-neighbors
p2p/discover: fix out-of-bounds slicing for chunked neighbors packets
2015-05-13 21:52:58 +02:00
251846d65a p2p/discover: fix out-of-bounds slicing for chunked neighbors packets
The code assumed that Table.closest always returns at least 13 nodes.
This is not true for small tables (e.g. during bootstrap).
2015-05-13 21:49:04 +02:00
fad21fb4a5 Merge pull request #963 from Gustav-Simonsson/fix_keystore_crypto_comments
Update keystore code comments
2015-05-13 11:51:02 -07:00
b2119d8931 Merge pull request #965 from subtly/patch-1
Better UDP & interop. Limit all received datagrams to 1280bytes.
2015-05-13 20:34:10 +02:00
8eef2b765a fix test. 2015-05-13 20:15:01 +02:00
a32693770c Manual send of multiple neighbours packets. Test receiving multiple neighbours packets. 2015-05-13 20:03:17 +02:00
7473c93668 UDP Interop. Limit datagrams to 1280bytes.
We don't have a UDP which specifies any messages that will be 4KB. Aside from being implemented for months and a necessity for encryption and piggy-backing packets, 1280bytes is ideal, and, means this TODO can be completed!

Why 1280 bytes?
* It's less than the default MTU for most WAN/LAN networks. That means fewer fragmented datagrams (esp on well-connected networks).
* Fragmented datagrams and dropped packets suck and add latency while OS waits for a dropped fragment to never arrive (blocking readLoop())
* Most of our packets are < 1280 bytes.
* 1280 bytes is minimum datagram size and MTU for IPv6 -- on IPv6, a datagram < 1280bytes will *never* be fragmented.

UDP datagrams are dropped. A lot! And fragmented datagrams are worse. If a datagram has a 30% chance of being dropped, then a fragmented datagram has a 60% chance of being dropped. More importantly, we have signed packets and can't do anything with a packet unless we receive the entire datagram because the signature can't be verified. The same is true when we have encrypted packets.

So the solution here to picking an ideal buffer size for receiving datagrams is a number under 1400bytes. And the lower-bound value for IPv6 of 1280 bytes make's it a non-decision. On IPv4 most ISPs and 3g/4g/let networks have an MTU just over 1400 -- and *never* over 1500. Never -- that means packets over 1500 (in reality: ~1450) bytes are fragmented. And probably dropped a lot.

Just to prove the point, here are pings sending non-fragmented packets over wifi/ISP, and a second set of pings via cell-phone tethering. It's important to note that, if *any* router between my system and the EC2 node has a lower MTU, the message would not go through:

On wifi w/normal ISP:
localhost:Debug $ ping -D -s 1450 52.6.250.242
PING 52.6.250.242 (52.6.250.242): 1450 data bytes
1458 bytes from 52.6.250.242: icmp_seq=0 ttl=42 time=104.831 ms
1458 bytes from 52.6.250.242: icmp_seq=1 ttl=42 time=119.004 ms
^C
--- 52.6.250.242 ping statistics ---
2 packets transmitted, 2 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 104.831/111.918/119.004/7.087 ms
localhost:Debug $ ping -D -s 1480 52.6.250.242
PING 52.6.250.242 (52.6.250.242): 1480 data bytes
ping: sendto: Message too long
ping: sendto: Message too long
Request timeout for icmp_seq 0
ping: sendto: Message too long
Request timeout for icmp_seq 1


Tethering to O2:
localhost:Debug $ ping -D -s 1480 52.6.250.242
PING 52.6.250.242 (52.6.250.242): 1480 data bytes
ping: sendto: Message too long
ping: sendto: Message too long
Request timeout for icmp_seq 0
^C
--- 52.6.250.242 ping statistics ---
2 packets transmitted, 0 packets received, 100.0% packet loss
localhost:Debug $ ping -D -s 1450 52.6.250.242
PING 52.6.250.242 (52.6.250.242): 1450 data bytes
1458 bytes from 52.6.250.242: icmp_seq=0 ttl=42 time=107.844 ms
1458 bytes from 52.6.250.242: icmp_seq=1 ttl=42 time=105.127 ms
1458 bytes from 52.6.250.242: icmp_seq=2 ttl=42 time=120.483 ms
1458 bytes from 52.6.250.242: icmp_seq=3 ttl=42 time=102.136 ms
2015-05-13 19:03:00 +02:00
56a5592ea0 Update keystore code comments 2015-05-13 18:33:31 +02:00
3edc4698fe Merge pull request #954 from karalabe/fix-downloader-nil-panic
eth/downloader: fix nil panic caused by wrong variable use
2015-05-13 18:15:18 +02:00
910a6d4e46 eth/downloader: fix nil panic caused by wrong variable use 2015-05-13 17:25:01 +03:00
de3a71cafd eth/downloader: remove a redundant sync progress check 2015-05-13 16:56:01 +03:00
48ee0777a5 eth/downloader: add a user sync notificaton 2015-05-13 16:03:05 +03:00
ec57aa64cd eth/downloader: sync the cancel channel during cancel too 2015-05-13 14:01:08 +03:00
ee0c892303 eth/downloader: fix deliveries to check for sync cancels 2015-05-13 13:47:21 +03:00
7cb0e24245 Merge pull request #948 from karalabe/fix-downlaoder-activepeer-shadow
eth/downloader: fix active peer shadowing, polish func names
2015-05-13 03:46:29 -07:00
e30e9fe979 removed invalid filename characters 2015-05-13 12:38:12 +02:00
d2d5dbc6fb eth/downloader: fix active peer shadowing, polish func names 2015-05-13 13:13:43 +03:00
6dec90464d Merge pull request #946 from Gustav-Simonsson/fix_geth_unlock_account
Fix hex conversion in --unlock and log when successful
2015-05-13 01:58:32 -07:00
b5b53d8b32 Fix hex conversion in --unlock and log when successful 2015-05-13 01:11:17 +02:00
28d6b30c0f Merge branch 'release/0.9.20' into develop 2015-05-12 19:05:51 +02:00
8e24378cc1 Merge branch 'release/0.9.20' 2015-05-12 19:05:33 +02:00
8fe01b4bfa eth: 100% tx propagation 2015-05-12 19:01:01 +02:00
36ce54e5dc cmd/geth: bump version to 0.9.20 2015-05-12 19:01:01 +02:00
d6357aa616 Merge pull request #631 from Gustav-Simonsson/improve_key_store_crypto
Improve key store crypto
2015-05-12 10:00:35 -07:00
e389585f1f Change default keystore dir 2015-05-12 18:33:04 +02:00
231fe04f03 Fix address type in js test 2015-05-12 17:48:21 +02:00
58d6ec689f Merge pull request #933 from bas-vk/issue928
replaced path with platform aware filepath module
2015-05-12 08:23:46 -07:00
037772fc07 fix hex conversion bug in RPC for byte slices 2015-05-12 17:22:17 +02:00
8001e48115 Fix natspec test (again x2) types 2015-05-12 17:22:17 +02:00
2c1b0ff17e Update key store to new spec but keep address field for now
* Also fix address types post-rebase
2015-05-12 17:22:17 +02:00
fe9e95a3fd Fix natspec e2e test accounts type (again) 2015-05-12 17:22:17 +02:00
940952f757 Fix HEX hack in xeth accounts() 2015-05-12 17:22:17 +02:00
f98e002d98 Address pull request comments; key header and hex encoding
* Remove key header from unencrypted key file format and replace
  it with a version field
* Change encoding of bytes in key files from base64 to hex
2015-05-12 17:22:17 +02:00
313eec33ad Revert "Add key header to unencrypted key file"
This reverts commit a94d4ba0b53c4558ab838aaed635a2ff66ddfa53.
2015-05-12 17:19:39 +02:00
8754f2b768 Fix common.Address / []byte type conversions 2015-05-12 17:19:39 +02:00
cd88295f5a Add key header to unencrypted key file 2015-05-12 17:19:39 +02:00
29a5a92d13 Add key header to encrypted keys
* Add key header containing key version, kdf and kdf params
* Store key header as JSON in the key file
* Read in KDF params from key header
* Include key header in MAC calculation and MAC verification
2015-05-12 17:19:39 +02:00
ac3371bcb6 Correct accounts hex in XETH API 2015-05-12 17:19:39 +02:00
da9fe951da Use common.Address type for accounts.Address 2015-05-12 17:19:39 +02:00
6b23094cff Improve key store passphrase crypto
* Change MAC-then-Encrypt to Encrypt-then-MAC
* Change AES256 to AES128
* Use first 16 bytes of KDF derived key for AES and
  remaining 16 for MAC
2015-05-12 17:18:30 +02:00
9918b6c84e Remove the awesome, ever misunderstood entropy mixing 2015-05-12 17:18:30 +02:00
f87094b660 Merge pull request #932 from obscuren/develop
xeth, rpc: implement eth_estimateGas. Closes #930
2015-05-12 07:26:38 -07:00
dca290d525 sol: skipped source checking step 2015-05-12 16:19:14 +02:00
ff99752ddd xeth: use same semantics as block processer for transient calls 2015-05-12 15:53:00 +02:00
899df30c24 fixed identing 2015-05-12 15:23:19 +02:00
95773b9673 removed redundant newlines in import block 2015-05-12 15:20:53 +02:00
260536a729 rpc: hexData => hexNum 2015-05-12 15:02:44 +02:00
b79dd188d9 replaced several path.* with filepath.* which is platform independent 2015-05-12 14:24:11 +02:00
66de3f0aa8 xeth, rpc: implement eth_estimateGas. Closes #930 2015-05-12 14:21:43 +02:00
96d4a7d087 eth, ethdb: lower the amount of open files & improve err messages for db
Closes #880
2015-05-12 14:14:56 +02:00
d82caa5ce3 Merge pull request #899 from ethersphere/solc-test-fix
compiler, cli/js: fix solidity compiler tests
2015-05-12 04:16:49 -07:00
03bf902b92 compiler, cli/js: fix solidity compiler tests failing when a different version of solc installed 2015-05-12 12:36:54 +02:00
e8d701a3b2 Merge pull request #929 from obscuren/develop
eth, ethdb: lower the amount of open files & improve err messages for db
2015-05-12 03:29:07 -07:00
13f8f65a58 eth, ethdb: lower the amount of open files & improve err messages for db
Closes #880
2015-05-12 11:28:55 +02:00
76215ca9f3 Merge pull request #925 from obscuren/worker_owned_accounts
miner, cmd/geth: miner will not ignored owned account transactions
2015-05-11 14:23:51 -07:00
97dd4551ef miner, cmd/geth: miner will not ignored owned account transactions
Miner does not ignore low gas txs from accounts that are owned.
2015-05-11 21:47:34 +02:00
0bedf1c376 Merge pull request #918 from obscuren/cpu_miner_fixes
cmd/geth, miner, backend, xeth: Fixed miner threads to be settable
2015-05-11 12:11:27 -07:00
48bd48876c eth, eth/downloader: moved pending queue error message to debug 2015-05-11 17:27:34 +02:00
21e52efdfe cmd/geth, miner, backend, xeth: Fixed miner threads to be settable
Miner threads are now settable through the admin interface (closes #897)
and specify 0 CPU worker threads when eth_getWork is called (closes #916)
2015-05-11 17:21:22 +02:00
064cf16099 eth/downloader: use count instead of peers, clearer 2015-05-11 17:21:22 +02:00
d37a2559b9 eth/downloader: revert to demotion, use harsher penalty 2015-05-11 17:21:22 +02:00
70c65835f4 eth/downloader: fix #910, thread safe peers & polishes 2015-05-11 17:21:22 +02:00
59bc541232 Merge pull request #915 from karalabe/downloader-threading-fixes
eth/downloader: fix #910, thread safe peers & polishes
2015-05-11 08:16:37 -07:00
fe7e284709 Merge pull request #920 from tgerring/issue917
Return 32-byte hashes from GetWork
2015-05-11 07:43:56 -07:00
0329e05823 Merge pull request #914 from ethersphere/develop
Signature on arbitrary data using the private keys of an account
2015-05-11 07:43:43 -07:00
8e77f81586 Return 32-byte hashes from GetWork
Ensures that the Get Work results are a consistent length. Closes #917
2015-05-11 10:11:33 -04:00
fa53c5e074 eth/downloader: use count instead of peers, clearer 2015-05-11 17:10:00 +03:00
51d4566cbf Only allow doSign to sign hashes, enforced by using the type common.Hash 2015-05-11 15:54:19 +02:00
ebbd8b0743 eth/downloader: revert to demotion, use harsher penalty 2015-05-11 16:47:58 +03:00
49559e6d5e Interactive signature creation refactored into separate doSign function. 2015-05-11 15:46:18 +02:00
685862d2ce eth/downloader: fix #910, thread safe peers & polishes 2015-05-11 14:26:20 +03:00
a9e1d38612 Merge branch 'develop' of github.com:ethereum/go-ethereum into develop
Conflicts:
	rpc/jeth.go
2015-05-11 12:47:14 +02:00
5176fbc6fa Merge pull request #908 from obscuren/develop
core, eth, miner: improved tx removal & fatal error on db sync err
2015-05-11 02:59:35 -07:00
6ecba12650 miner: added log message for mining operation. #912 2015-05-11 11:39:33 +02:00
3c6c891680 core: optimise pending transaction processing 2015-05-11 11:39:33 +02:00
df323cdb4e rpc: display error message to stdout 2015-05-11 11:39:33 +02:00
a2919b5e17 core, eth, miner: improved tx removal & fatal error on db sync err
* core: Added GasPriceChange event
* eth: When one of the DB flush methods error a fatal error log message
  is given. Hopefully this will prevent corrupted databases from
  occuring.
* miner: remove transactions with low gas price. Closes #906, #903
2015-05-11 11:39:33 +02:00
6674ea8d67 Merge pull request #911 from karalabe/whisper-graceful-fail
rpc, xeth: fix #881, gracefully handle offline whisper
2015-05-11 02:29:27 -07:00
0ad5898c0f rpc, xeth: fix #881, gracefully handle offline whisper 2015-05-11 11:53:53 +03:00
00280e62e3 Merge branch 'develop' of github.com-obscure:ethereum/go-ethereum into develop 2015-05-10 03:39:47 +02:00
7d69679935 Merge branch 'develop' of github.com-obscure:ethereum/go-ethereum 2015-05-10 03:39:23 +02:00
7551264fa6 cmd/geth, cmd/mist: version 0.9.19 2015-05-10 03:38:46 +02:00
3874f02f1b Merge pull request #894 from obscuren/develop
ethdb: set open file limit to 128 for all leveldbs
2015-05-09 18:36:50 -07:00
0e211ae203 ethdb: set open file limit to 128 for all leveldbs 2015-05-10 01:55:39 +02:00
bd95871a89 Merge pull request #893 from obscuren/develop
eth: added a cancel method for the downloader
2015-05-09 16:54:06 -07:00
05715f27cf eth: added a cancel method for the downloader
Added a cancel method to the downloader which gracefully shuts down any
active syncing process (hash fetching or block downloading) and resets
the queue and remove any pending blocks.

Issue with the downloader which would stall because of an active ongoing
process when an invalid block was found.
2015-05-10 00:34:07 +02:00
45dc690947 cmd/mist: version bump 2015-05-09 13:37:22 +02:00
e289b0a1c1 Merge pull request #888 from obscuren/develop
miner, flags: Configurable gas price & log flag change
2015-05-09 04:13:16 -07:00
658ac3c257 cmd/geth: bump version 0.9.18 2015-05-09 12:54:27 +02:00
7eed47fad5 miner, tests: fixed block test 2015-05-09 12:51:40 +02:00
e3a08875f6 miner: start/stop mutex locked. Closes #887 2015-05-09 12:32:36 +02:00
a7705fc203 miner: moved gasprice to non-method 2015-05-09 12:13:46 +02:00
13ddf20bd2 miner, cmd/geth: settable gas price from flags and console
* --gasprice "<num>" flag
* admin.miner.setGasPrice( <num> )
2015-05-09 12:04:00 +02:00
cb1fa523e4 cmd/geth, cmd/mist, eth, flags: renamed loglevel to verbosity 2015-05-09 12:00:51 +02:00
1fe70a66ba Signature test. 2015-05-08 19:37:35 +02:00
62dd9833ec Merge branch 'develop' of github.com:ethereum/go-ethereum into develop 2015-05-08 17:55:53 +02:00
3a01e3e39b Signing (almost) works. 2015-05-08 17:52:44 +02:00
c8fc4cebe6 version 0.9.17 2015-05-08 17:24:41 +02:00
0214cbe0fb Merge pull request #863 from karalabe/ordered-block-download
eth/downloader: prioritize block fetch based on chain position, cap memo...
2015-05-08 08:19:53 -07:00
7c678554b5 Merge pull request #885 from fjl/p2p-fixes
p2p: more last-minute fixes
2015-05-08 07:47:56 -07:00
edad47bf0e eth/downloader: fix leftover state between syncs 2015-05-08 17:39:03 +03:00
a487396b76 eth_sign added to API for signing arbitrary data. 2015-05-08 16:36:13 +02:00
e94aa421c6 New API call for signatures. 2015-05-08 16:17:19 +02:00
d4f0a67323 p2p: drop connections with no matching protocols 2015-05-08 16:09:55 +02:00
e45d9bb29d cmd/utils: bump default maxpeers to 25
This should improve ethereum block propagation times since
we're not not broadcasting blocks to 100% of peers.
2015-05-08 16:09:55 +02:00
9c0f36c46d p2p: use maxDialingConns instead of maxAcceptConns as dial limit 2015-05-08 16:09:55 +02:00
914e57e49b p2p: fix disconnect at capacity
With the introduction of static/trusted nodes, the peer count
can go above MaxPeers. Update the capacity check to handle this.
While here, decouple the trusted nodes check from the handshake
by passing a function instead.
2015-05-08 16:09:54 +02:00
23454dcfcb Merge pull request #840 from karalabe/throttled-dialing
p2p: throttled handshakes
2015-05-08 06:53:40 -07:00
bd5720f480 eth, eth/downloader: handle sync errors a bit more gracefully 2015-05-08 15:22:48 +03:00
f819ac7158 Merge pull request #882 from zsfelfoldi/develop
Otto.ToValue concurrency error fixed
2015-05-08 04:54:22 -07:00
15bfae52d2 Merge pull request #876 from obscuren/jsre_fixes
jsre, cmd/geth: updated web3.js and altered settimeout
2015-05-08 04:39:33 -07:00
d7dabce732 ToVal serialization fix 2015-05-08 13:29:48 +02:00
f6e71b5749 updated ethereum.js 2015-05-08 13:05:20 +02:00
351d6b0d44 jsre, cmd/geth: updated web3.js and altered settimeout 2015-05-08 13:05:20 +02:00
03473d48c1 Merge pull request #875 from Gustav-Simonsson/test_updates
Test updates
2015-05-08 03:50:14 -07:00
45c070fc8b Merge pull request #833 from ethersphere/frontier/solidity
solidity compiler and contract metadocs integration
2015-05-08 03:43:31 -07:00
1de1359e3b Otto.ToValue concurrency error fixed 2015-05-08 12:27:35 +02:00
637b2415d9 Merge pull request #864 from obscuren/filter_changes
xeth, core, event/filter, rpc: new block and transaction filters
2015-05-08 02:56:55 -07:00
69aac4d531 Merge pull request #877 from Gustav-Simonsson/update_ethash_godep
Update ethash deps (more build fixes, tests)
2015-05-08 02:19:50 -07:00
9d188f73b5 eth, eth/downloader: make synchronize thread safe 2015-05-07 21:07:20 +03:00
3593662b0c Update ethash deps (more build fixes, tests) 2015-05-07 19:39:55 +02:00
60b5a94428 xeth: getTransactionByHash, try pool if db fails 2015-05-07 18:23:24 +02:00
dcfecebe1f core: get transaction by hash from transaction pool 2015-05-07 18:22:57 +02:00
258a7b9a93 xeth: check proper queue for pending transaction filter 2015-05-07 17:20:57 +02:00
b3c9b66f29 rpc: eth_transactionFilter => eth_newPendingTransactionFilter 2015-05-07 14:44:32 +02:00
7e160a677d xeth, core, event/filter, rpc: new block and transaction filters 2015-05-07 14:44:32 +02:00
8735e5addd p2p: increase the handshake timeout in the tests 2015-05-07 15:30:56 +03:00
4d5a719f25 cmd, eth, p2p: introduce pending peer cli arg, add tests 2015-05-07 15:30:56 +03:00
af93217775 p2p: reduce the concurrent handshakes to 10/10 in/out 2015-05-07 15:22:09 +03:00
2060bc8bac p2p: fix dial throttling race condition 2015-05-07 15:22:08 +03:00
29fef349ef p2p: fix a dialing race in the throttler 2015-05-07 15:22:08 +03:00
3953bf0031 p2p: limit the outbound dialing too 2015-05-07 15:22:08 +03:00
43901c9282 eth/downloader: fix priority queue reset, add throttling test 2015-05-07 14:40:50 +03:00
79eb40fc9f Add bcTotalDifficultyTest and unskip now working tx tests 2015-05-07 13:03:22 +02:00
009b221692 solidity compiler and contract metadocs integration
* common/compiler: solidity compiler + tests
* rpc: eth_compilers, eth_compileSolidity + tests
* fix natspec test using keystore API, notice exp dynamically changes addr, cleanup
* resolver implements registrars and needs to create reg contract (temp)
* xeth: solidity compiler. expose getter Solc() and paths setter SetSolc(solcPath)
* ethereumApi: implement compiler related RPC calls using XEth - json struct tests
* admin: make use of XEth.SetSolc to allow runtime setting of compiler paths
* cli: command line flags solc to set custom solc bin path
* js admin api with new features debug and contractInfo modules
* wiki is the doc https://github.com/ethereum/go-ethereum/wiki/Contracts-and-Transactions
2015-05-07 12:58:21 +02:00
2b716aec54 Update JSON test files 2015-05-07 12:44:29 +02:00
45f8304f3c eth/downloader: fix expiration not running while fetching 2015-05-07 12:59:19 +03:00
4800c94392 eth/downloader: prioritize block fetch based on chain position, cap memory use 2015-05-07 10:57:34 +03:00
97c37356fd updated ignore 2015-05-07 00:03:11 +02:00
82ac4712f1 Merge pull request #867 from Gustav-Simonsson/fix_block_tests_genesis_block_total_difficulty
Fix block tests genesis block total difficulty
2015-05-06 14:52:55 -07:00
a0cb1945ae Merge pull request #866 from fjl/p2p-last-minute
Last minute p2p fixes
2015-05-06 14:49:52 -07:00
3e2a928caa p2p: stop dialing at half the maximum peer count 2015-05-06 23:44:51 +02:00
7bc1f487b8 Unskip now working tests, remove debug print 2015-05-06 23:25:44 +02:00
2808409fbd Add genesis block total difficulty in tests 2015-05-06 23:22:49 +02:00
6a2fec5309 p2p, whisper: use glog for peer-level logging 2015-05-06 23:19:14 +02:00
b719801db0 cmd/geth: gofmt screwup fix 2015-05-06 23:10:46 +02:00
458d891c63 cmd/geth: version bump 2015-05-06 23:04:49 +02:00
bcfd788661 p2p/discover: bump packet timeouts to 500ms 2015-05-06 22:59:00 +02:00
fd4b75cfa8 p2p/nat: less confusing error logging 2015-05-06 22:58:03 +02:00
090f593bc0 Merge branch 'karalabe-cherry-trusted-peers' into develop 2015-05-06 22:54:33 +02:00
062fa049d0 fixed merge issue 2015-05-06 22:54:21 +02:00
24d44f35f2 Merge pull request #791 from fjl/discover-sha3-distance
p2p/discover: sha3-based node distance
2015-05-06 13:48:57 -07:00
323216ed85 Merge pull request #861 from obscuren/transaction_pool_fixes
core: transaction pool fixes & resending transactions
2015-05-06 11:23:58 -07:00
1f26a1b863 Merge pull request #859 from Gustav-Simonsson/ethash_reloaded
Ethash reloaded
2015-05-06 11:20:54 -07:00
05ac1209c7 cmd/geth: limit pendingTransactions to owned accounts. 2015-05-06 18:30:56 +02:00
eb4029257a cmd/mist: updated xeth transact 2015-05-06 18:30:56 +02:00
5ebc22807c cmd/geth: admin, switched price with limit in arguments 2015-05-06 18:30:56 +02:00
7fed424435 cmd/geth: implemented resending transaction with different gas settings 2015-05-06 18:30:55 +02:00
92f998c7ef core: use removeTx instead of delete 2015-05-06 18:30:55 +02:00
03bb88dec0 xeth, rpc: added nonce setting through RPC and xeth transact 2015-05-06 18:30:55 +02:00
054947def7 Add ethash linux & windows build fixes 2015-05-06 17:38:28 +02:00
aa884c052d Merge pull request #771 from zsfelfoldi/develop
jsre: support for setTimeout, sendAsync
2015-05-06 07:27:24 -07:00
2adcc31bb4 p2p/discover: new distance metric based on sha3(id)
The previous metric was pubkey1^pubkey2, as specified in the Kademlia
paper. We missed that EC public keys are not uniformly distributed.
Using the hash of the public keys addresses that. It also makes it
a bit harder to generate node IDs that are close to a particular node.
2015-05-06 16:10:41 +02:00
c54d123b31 setTimeout and sendAsync implemented
added and eval queue for serializing JSRE vm execution
2015-05-06 15:58:27 +02:00
2e9ed6f7aa Merge pull request #856 from karalabe/windows-console-color-fix
cmd/geth: colorize console output in windows
2015-05-05 04:50:48 -07:00
c750ef09e1 cmd/geth: fix #853 colorize console output in windows 2015-05-05 14:44:39 +03:00
f4341c7b7f Unskip working blocktests following ethash cache reusage 2015-05-05 08:34:29 +02:00
b1cc9cdc74 Integrate new ethash API and change geth makedag cmd 2015-05-05 08:24:15 +02:00
50659f4b48 Update ethash Godeps files 2015-05-05 07:50:04 +02:00
4accc187d5 eth, p2p: add trusted node list beside static list 2015-05-04 13:59:51 +03:00
2382da4179 cmd/mist: fix a stale error message 2015-05-04 13:11:43 +03:00
54db54931e p2p: add static node dialing test 2015-05-04 13:08:42 +03:00
ac85fdc75e Merge pull request #835 from obscuren/handler_errors
eth, eth/downloader: error handlers and td checks
2015-05-04 02:00:54 -07:00
37770ed0d3 core: added unix timestamp to debug output for block proc 2015-05-03 21:49:19 +02:00
1470b22e90 downloader: hash downloading recovery
If a peer fails to respond (disconnect, etc) during hash downloading
switch to a different peer which has it's current_hash in the queue's
peer set.
2015-05-03 16:27:03 +02:00
ba2236fa51 cmd/geth, eth: bump version & tmp fix for incorrect TD peers 2015-05-03 14:11:47 +02:00
f2a2b2ac70 eth/downloader: put back hashes on block overflow error 2015-05-03 14:11:00 +02:00
493181ea09 eth/downloader: changed has to blockHashes for chain linking 2015-05-03 14:10:31 +02:00
c5b8acbaf0 core: print ignored blocks 2015-05-03 14:09:50 +02:00
25bc88113f eth/downloader: added additional tests 2015-05-03 14:09:33 +02:00
c6ad3aec05 eth,core: changed NewTicker to Tick 2015-05-03 13:27:37 +02:00
b298928c49 core: added 'ignored' status 2015-05-01 16:00:30 +02:00
016f152b36 eth, eth/downloader: Moved block processing & graceful shutdown
The downloader is no longer responsible for processing blocks. The
eth-protocol handler now takes care of this instead.

Added graceful shutdown during block processing. Closes #846
2015-05-01 15:58:44 +02:00
e82ddd9198 p2p: correct a leftover trusted -> static 2015-04-30 19:34:33 +03:00
413ace37d3 eth, p2p: rename trusted nodes to static, drop inbound extra slots 2015-04-30 19:32:48 +03:00
8595198c1b eth/downloader: delete blocks from queue 2015-04-30 17:51:47 +02:00
15873fafc0 core: added a wait group to chain manager for graceful shutdown 2015-04-30 17:50:47 +02:00
701591b403 cmd, eth, p2p: fix review issues enumerated by Felix 2015-04-30 16:15:29 +03:00
1528dbc171 p2p: add trust check to handshake, test privileged connectivity
Conflicts:
	p2p/server_test.go
2015-04-30 16:06:47 +03:00
14f32a0c3a p2p: reduce the severity of a debug log 2015-04-30 16:04:09 +03:00
679c90b873 cmd/geth, cmd/utils, eth: internalize trusted node config file 2015-04-30 16:03:47 +03:00
de0549fabb cmd/geth, cmd/mist, cmd/utils, eth, p2p: support trusted peers 2015-04-30 16:03:10 +03:00
d457a1187d common: add Hash.Generate 2015-04-30 15:02:23 +02:00
72ab6d3255 p2p/discover: track sha3(ID) in Node 2015-04-30 15:02:23 +02:00
b34a8ef624 p2p, p2p/discover: protocol version 4 2015-04-30 14:57:34 +02:00
fc747ef4a6 p2p/discover: new endpoint format
This commit changes the discovery protocol to use the new "v4" endpoint
format, which allows for separate UDP and TCP ports and makes it
possible to discover the UDP address after NAT.
2015-04-30 14:57:33 +02:00
e4dba36892 core: check for parent in calc TD. TD = (N != 0 == parent.TD) || (== D) 2015-04-30 14:55:21 +02:00
28b39267d9 core, eth: verify td of received blocks 2015-04-30 13:50:59 +02:00
9b6e8f6195 eth, eth/downloader: remove bad peers from peer set
Peers in the eth protocol handler are now being ignored for catch up.
2015-04-30 12:38:16 +02:00
3fef601903 Merge pull request #830 from obscuren/downloader-missing-parent
eth/downloader: missing parent improvement
2015-04-29 15:52:25 -07:00
30b921ef46 cmd/geth: bump version to 0.9.14 2015-04-30 00:40:14 +02:00
88292f35db core: remove txs from queue in addition to removal of pending 2015-04-30 00:20:59 +02:00
2590a7dabb core: added some additional chain tests for shortest chain 2015-04-30 00:14:41 +02:00
04c209980b eth: rely on p2p to determine block propagation 2015-04-29 22:50:58 +02:00
01e3d694a6 p2p: added received at to peer message
p2p.Msg.ReceivedAt can be used for determining block propagation from
begining to end.
2015-04-29 22:49:58 +02:00
9e63798d03 core/types, eth: meassure and display propagation times 2015-04-29 19:55:30 +02:00
f8c27d7159 eth/downloader: drop block 2015-04-29 19:55:04 +02:00
c930045834 core: fixed tetst to reflect (int, error) return by insertChain 2015-04-29 15:27:04 +02:00
dfbf580354 eth/downloader: ignore orphan blocks in the downloader.
When blocks have been sorted and are being processed, orphan blocks
should be ignored and thrown out. The protocol handler is responsible
for downloading blocks which have missing parents.
2015-04-29 14:49:37 +02:00
735b029db9 core: return the index of the block that failed when inserting a chain 2015-04-29 14:00:24 +02:00
764e81bf12 Merge pull request #825 from obscuren/develop
core: chain fork fix
2015-04-29 04:47:26 -07:00
bac4440e17 Merge pull request #822 from fjl/makefile-improvements
Makefile improvements
2015-04-29 04:43:38 -07:00
13364a2dcf eth/downloader: reset the chain when parent is missing during processing 2015-04-29 13:40:39 +02:00
745c368987 cmd/geth: bump version number 2015-04-29 12:54:41 +02:00
4e07967711 core: fixed chain reorg during splits
Chain reorgs weren't properly handled when a chain was further ahead.
Previously we'd end up with mixed chains in our canonical numbering
sequence. Added test for this type of forking.

```
     /-o-o-o   A
o-C-+
     \-o-o-o-o B
```

Ends up with with C A1, A2, A3, B4
2015-04-29 12:51:05 +02:00
af73d1d682 core/types: added fake parent hash / hash to String() output 2015-04-29 12:51:05 +02:00
4b7bdc3766 eth: check if downloader is busy before showing log message 2015-04-29 12:51:05 +02:00
7ac24d551b core: seperated proccing mutex and getting mutex 2015-04-29 12:51:04 +02:00
9f32117457 core: bump database version 2015-04-29 12:51:04 +02:00
a4b79f1dac core: moved mutex locks in insert blocks to start of function
Insert blocks will no longer allow processing of multiple chains at the
same time. The block lock has been moved to start of the function.
2015-04-29 12:51:04 +02:00
04a09b7e2d core: set min gas price at startup 2015-04-29 12:51:04 +02:00
32373e3837 Merge pull request #828 from tgerring/pathfixes
Remove path separator literals
2015-04-29 01:54:47 -07:00
f8cdff9a5d Remove path separator literals 2015-04-29 00:30:25 -05:00
aa03e53ca8 Use Makefile for Travis tests 2015-04-29 02:13:37 +02:00
c6b983e449 Makefile: add test target 2015-04-29 02:13:37 +02:00
72d8878084 cmd/mist: always enable whisper
The default value of the Shh option is true, but cli can't
see it because it is not part of the mist options.
2015-04-29 02:13:36 +02:00
eb5e43022e cmd/geth, cmd/mist: use gitCommit in node name 2015-04-29 02:13:36 +02:00
71c28cfb0c Makefile: set main.gitCommit when building 2015-04-29 02:13:36 +02:00
f4e5675303 cmd/mist: add blockchain version flag
This is necessary because cli doesn't see the default
value unless the flag is included.
2015-04-29 02:13:35 +02:00
26fbea5cb7 README: simplify build instructions 2015-04-29 02:13:35 +02:00
8fcd71920a Makefile: clean should also delete Godeps/_workspace/pkg 2015-04-29 01:28:35 +02:00
12df8565cf build: run build commands from the fake workspace root
This ensures that compiler error messages contain the correct path.
2015-04-29 01:28:35 +02:00
a6a49ccbf7 Merge pull request #821 from karalabe/nodedb-fix
p2p/discover: fix api issues caused by leveldb update
2015-04-28 04:07:14 -07:00
a7d894611e Merge pull request #820 from fjl/rlp-readkind-overflow
rlp: fix list bounds check overflow (found by go-fuzz)
2015-04-28 04:04:32 -07:00
b569550a39 p2p/discover: fix api issues caused by leveldb update 2015-04-28 13:57:57 +03:00
91cb8cdd2a Merge pull request #793 from karalabe/discovery-node-cache
p2p/discover: persistent node database
2015-04-28 03:40:10 -07:00
e88b410b4d Merge pull request #819 from karalabe/leveldb-update
godeps: refresh leveldb, clean up stale dependencies
2015-04-28 02:40:49 -07:00
7e3b080f85 godeps: update leveldb and snappy, dump serpent-go 2015-04-28 12:18:01 +03:00
99027c79fe Merge branch 'develop' of github.com-obscure:ethereum/go-ethereum into develop
Conflicts:
	rpc/api.go
2015-04-28 11:17:41 +02:00
bac455c011 Merge branch 'kobigurk-develop' into develop 2015-04-28 11:16:22 +02:00
459d898705 eth, rpc, xeth: ext_hanhrate => eth_hashrate 2015-04-28 11:16:03 +02:00
46f63ef04f Merge branch 'develop' of https://github.com/kobigurk/go-ethereum into kobigurk-develop 2015-04-28 11:10:44 +02:00
a05c420371 Merge pull request #738 from karalabe/whisper-cleanup
Whisper cleanup, part 3
2015-04-28 01:54:05 -07:00
dd49c8e43d rlp: fix list bounds check overflow (found by go-fuzz)
The list size checking overflowed if the size information
for a value was bigger than the list. This is resolved by
always performing the check before reading.
2015-04-28 10:28:15 +02:00
978ffd3097 rpc, xeth: finish cleaning up xeth 2015-04-28 10:49:05 +03:00
2b9fd6b40a whisper: add full filter test suite 2015-04-28 10:49:05 +03:00
406e74e2af whisper: fix a small data race duirng peer connection 2015-04-28 10:49:05 +03:00
70ded4cbf0 xeth: fix un-decoded whisper RPC topic string bug 2015-04-28 10:49:04 +03:00
e252dae499 rpc: use nil topic wildcards instead of "" 2015-04-28 10:49:04 +03:00
db615a85ec ui/qt/qwhisper, whisper, xeth: polish topic filter, fix wildcards 2015-04-28 10:49:04 +03:00
ae4bfc3cfb rpc, ui/qt/qwhisper, whisper, xeth: introduce complex topic filters 2015-04-28 10:49:04 +03:00
15586368e5 whisper: fix spurious From identity with untargeted messages 2015-04-28 10:49:04 +03:00
87447f9f3f whisper: fix payload loss in case of plaintext decrypt 2015-04-28 10:49:04 +03:00
7f48eb8737 whisper, xeth/whisper: surface TTL and hash to the API 2015-04-28 10:49:04 +03:00
19bc4624ea eth: pull in a lost merge change
Ref: 21c4c155ee
2015-04-28 10:49:04 +03:00
7948cc0029 rpc, whisper, xeth: fix RPC message retrieval data race 2015-04-28 10:47:35 +03:00
5aa523e32b whisper: fix send timestamp omission during envelope opening 2015-04-28 10:47:35 +03:00
3563c59b12 rpc, whisper, xeth: polish whisper RPC interface 2015-04-28 10:47:35 +03:00
4992765032 p2p/discover: fix goroutine leak due to blocking on sync.Once 2015-04-28 10:28:04 +03:00
182d484aa7 Merge pull request #817 from tgerring/rpcglog
Remove old logger from RPC pkg
2015-04-27 14:51:00 -07:00
f54c2e75c8 Merge pull request #818 from Gustav-Simonsson/add_privkey_loading_to_block_tests
Add privkey loading to block tests
2015-04-27 14:48:49 -07:00
3ad5243b18 Return Gas Price not Gas
And output as quantity, not data
2015-04-27 13:58:32 -05:00
34c94d5fcd Add loading of block test privkey if present 2015-04-27 20:30:26 +02:00
2a61611c4f Update JSON tests 2015-04-27 19:09:20 +02:00
437cf4b3ac p2p/discover: add node expirer and related tests 2015-04-27 17:38:28 +03:00
9a17dd91a4 Add link to Windows 64-bit geth dev build 2015-04-27 09:24:25 -05:00
b071e7f4db Remove old logger from RPC pkg 2015-04-27 09:18:55 -05:00
a136e2bb22 p2p/discover: parametrize nodedb version, add persistency tests 2015-04-27 15:28:17 +03:00
75fd738dea p2p/discover: drop a superfluous warning 2015-04-27 15:06:31 +03:00
706da56f75 p2p/discover: wrap the pinger to update the node db too 2015-04-27 14:56:42 +03:00
85b4b44235 p2p/discover: use iterator based seeding, drop old protocol test 2015-04-27 14:45:35 +03:00
8de8f61d36 p2p/discover: write the basic tests, catch RLP bug 2015-04-27 12:33:06 +03:00
0201c04b95 p2p/discovery: fix issues raised in the nodeDb PR 2015-04-27 10:19:16 +03:00
aa4c25778f Merge pull request #813 from obscuren/general_fixes
General fixes
2015-04-26 03:12:30 -07:00
7fd368c586 geth/main: removed crazy welcome message :-( 2015-04-26 11:30:33 +02:00
a237ff65ea web3: updated 2015-04-26 11:21:15 +02:00
145e02fc54 core, miner: added value check on tx validation
* Changed CalcGasLimit to no longer need current block
* Added a gas * price + value on tx validation
* Transactions in the pool are now re-validated once every X
2015-04-26 11:19:40 +02:00
8d09f95bc7 Merge pull request #805 from obscuren/download_improvements
eth, eth/downloader: improve downloader and remove asynchronousness
2015-04-24 15:56:17 -07:00
ed036a2ce7 cmd/geth: bump version number 0.9.12 2015-04-24 23:57:05 +02:00
7afbd0f20d Merge pull request #796 from Gustav-Simonsson/fix_ignoring_of_unexpected_files_in_key_dir
Fix ignore of unexpected files in key dir
2015-04-24 14:37:42 -07:00
b0bf12ec87 Remove unneeded allocation 2015-04-24 19:40:28 +02:00
7ce3d06402 eth/downloader: removed update loop and synch channel 2015-04-24 18:28:46 +02:00
405720b218 xeth, core, cmd/utils: Transaction can not be over block gas limit
Transactions will be invalidated when the tx.gas_limit > block.gas_limit
2015-04-24 17:48:13 +02:00
3bb6da9bd3 natspec: disabled natspec test 2015-04-24 17:44:22 +02:00
4d1887093d Use make instead of new for allocation 2015-04-24 17:41:38 +02:00
8646365b42 cmd/bootnode, eth, p2p, p2p/discover: use a fancier db design 2015-04-24 18:04:41 +03:00
1681ee9883 eth: added a few informative messages regarding downloading 2015-04-24 17:03:09 +02:00
c8e21a4d17 Merge pull request #803 from obscuren/log_filter_fixes
core: fixed wildcard topic filters. Closes #725
2015-04-24 07:43:01 -07:00
168ff36676 Merge pull request #773 from ethersphere/frontier/cli
CLI and JS admin changes
2015-04-24 06:58:31 -07:00
a9e4b96573 eth/downloader: fixed tests 2015-04-24 15:56:18 +02:00
d84c2202e7 eth, eth/downloader: simplified synchronisation process 2015-04-24 15:38:10 +02:00
bd9c76097d eth/downloader: removed peer td management and best peer selection 2015-04-24 15:37:07 +02:00
31f82eb334 eth, eth/downloader: don't require td on downloader. Fixed tests 2015-04-24 15:04:58 +02:00
b86e7526e1 eth, eth/downloader: moved peer selection to protocol handler 2015-04-24 14:40:32 +02:00
81379cbc7b Merge pull request #804 from alexvandesande/avsa-geth
Simpler "welcome"
2015-04-24 04:57:05 -07:00
f229dc8f42 Merge branch 'avsa-geth' of https://github.com/alexvandesande/go-ethereum into avsa-geth 2015-04-24 13:51:29 +02:00
8716278ca8 Smaller frontier cover art 2015-04-24 13:50:23 +02:00
c5e9a0a71c cli: correct bootnodes flag usage help line 2015-04-24 12:46:53 +01:00
f1126dbb87 Smaller frontier cover art 2015-04-24 13:46:41 +02:00
cd2782f59c core: fixed wildcard topic filters. Closes #725 2015-04-24 13:45:21 +02:00
6b1b5a4a2a cli/js console: if corsDomain is not given to startRpc, we fall back to value set on command line with -corsDomain 2015-04-24 12:45:11 +01:00
1b7c017076 cli: fatal error if no etherbase for mining 2015-04-24 12:45:11 +01:00
be843959cb backend: start miner in its go routine (no wait to generate DAG) 2015-04-24 12:45:11 +01:00
6512b23b98 cli: fatal error if rpc could not be started 2015-04-24 12:45:11 +01:00
7b2f25b578 cli: clean up flag descriptions, usage docs, account list uses primary and indexes, add help line to account subcnd usage 2015-04-24 12:45:11 +01:00
22450c069b js console: add cors domain optional argument to startRpc 2015-04-24 12:45:11 +01:00
a3fb41981e cmd/admin: rename debug.block to debug.processBlock; move backtrace under debug 2015-04-24 12:45:11 +01:00
9caf880ff9 Update README.md 2015-04-24 13:40:20 +02:00
31811365e0 Merge pull request #800 from obscuren/ethereum_js_update
Ethereum js update
2015-04-24 04:34:51 -07:00
dc62fb2ee9 web3: updated 2015-04-24 11:39:43 +02:00
92c6327593 cmd/geth, jsre: updated ethereum.js => web3.js 2015-04-24 11:37:58 +02:00
6def110c37 cmd/bootnode, eth, p2p, p2p/discover: clean up the seeder and mesh into eth. 2015-04-24 11:33:55 +03:00
971702e7a1 p2p/discovery: fix broken tests due to API update 2015-04-24 11:23:20 +03:00
af923c965f p2p/discovery: use the seed table for finding nodes, auto drop stale ones 2015-04-24 11:23:20 +03:00
5f735d6fce cmd, eth, p2p, p2p/discover: init and clean up the seed cache 2015-04-24 11:23:20 +03:00
936c8e19ff p2p/discover: store nodes in leveldb 2015-04-24 11:23:20 +03:00
516f49c812 eth: cleanup 2015-04-23 23:30:25 +02:00
b6ec1c720f Merge pull request #797 from tgerring/bootnodes
Bootnodes update
2015-04-23 11:53:18 -07:00
f5e0388f62 Merge pull request #778 from bas-vk/issue764
Moved database update loop to eth/backend
2015-04-23 11:46:27 -07:00
abe08d7be3 Merge pull request #794 from Gustav-Simonsson/block_tests_more_validations
Add block header validations for block tests
2015-04-23 11:41:57 -07:00
24995f9ab7 Updated bootnodes
Update pub key for EU node and add new SA node
2015-04-23 13:06:07 -05:00
154570ebd3 Cleanup README developer info 2015-04-23 13:05:37 -05:00
c12180d005 Merge branch 'issue764' of https://github.com/bas-vk/go-ethereum into issue764 2015-04-23 18:01:15 +02:00
c273ed7d82 Moved leveldb update loop to eth/backend
change order of block insert and update LastBlock

bugfix, wrong hash stored in blockDb
2015-04-23 17:58:58 +02:00
5cfa0e9187 bugfix, wrong hash stored in blockDb 2015-04-23 17:35:05 +02:00
94f2adb80a Merge pull request #792 from veox/doc-crypto-secp256k1
doc: crypto/secp256k1 GMP dependency package name.
2015-04-23 08:11:11 -07:00
958c04e79a doc: crypto/secp256k1 GMP dependency package name.
Linux build documentation is mostly geared towards Ubuntu 14.04 (LTS).
Appropriate package is called `libgmp-dev` there.

Note that on pristine installations building `geth` with godep will
fail because this header is missing. This is not documented in the
top-level README, but is on the wiki:

https://github.com/ethereum/go-ethereum/wiki/Installation-Instructions-for-Ubuntu#building-geth-command-line-client

That page recommends `libgmp3-dev`, which ATM provides same version
as `libgmp-dev`.
2015-04-23 17:33:48 +03:00
2f8809df40 Merge pull request #769 from obscuren/develop
core: transaction queue
2015-04-23 02:59:56 -07:00
7f14fbd579 core: pending txs now re-validated once every second 2015-04-23 11:50:12 +02:00
48135657c4 miner: show error message for gas limit per account 2015-04-23 11:50:12 +02:00
d7bab21681 natspec: fixed test to work with new queued transactions 2015-04-23 11:50:12 +02:00
fba40e18d9 core: added accessor for queued transactions 2015-04-23 11:50:12 +02:00
d3be1a2719 eth: moved mined, tx events to protocol-hnd and improved tx propagation
Transactions are now propagated to peers from which we have not yet
received the transaction. This will significantly reduce the chatter on
the network.

Moved new mined block handler to the protocol handler and moved
transaction handling to protocol handler.
2015-04-23 11:50:12 +02:00
888ece0cb2 core: fixed test 2015-04-23 11:50:12 +02:00
7edbb0110f core: set the state for the managed tx state
Set the state for the managed tx state instead of creating a new
managed state.
2015-04-23 11:50:12 +02:00
1506e00a23 core: improved error message for invalid nonce txs 2015-04-23 11:50:11 +02:00
7138404cb0 core: only post event once per tx & fixed test 2015-04-23 11:50:11 +02:00
4feb5f6f9c xeth, miner: updated some logging 2015-04-23 11:50:11 +02:00
5cb5df003d eth: start tx pool in a goroutine 2015-04-23 11:50:11 +02:00
498b24270a core: implemented a queued approach processing transactions
Implemented a new transaction queue. Transactions with a holes in their
nonce sequence are also not propagated over the network.

N: 0,1,2,5,6,7 = propagate 0..2 -- 5..N is kept in the tx pool
2015-04-23 11:50:11 +02:00
2fe54ab233 Merge pull request #779 from Gustav-Simonsson/block_tests_reloaded
Block tests reloaded
2015-04-23 02:49:51 -07:00
0071fbed8c Merge pull request #780 from maran/arm_build
Adding flags to facilitate cross compiling to ARM
2015-04-23 02:22:39 -07:00
67cc80ba66 Merge pull request #786 from tgerring/issue739
Empty Call response should return 0x instead of 0x00. Closes #739
2015-04-23 02:22:35 -07:00
8eefcb8493 Merge pull request #782 from alexvandesande/develop
Changed "Welcome to the Frontier" to something more geeky
2015-04-23 02:11:32 -07:00
359a9773a1 Merge pull request #783 from tgerring/issue777
Issue 777
2015-04-23 02:11:20 -07:00
69788cb973 Merge pull request #784 from tgerring/issue737
Rename eth_Version to eth_protocolVersion. Closes #737
2015-04-23 02:05:20 -07:00
9d2a156453 Fix ignore of unexpected files in key dir 2015-04-23 05:52:41 +02:00
7a223721a5 Add block header validations for block tests 2015-04-23 05:32:56 +02:00
49da462e92 Include ZeroByteAtTheEnd and RandomByteAtTheEnd tests 2015-04-22 23:16:19 +02:00
4e0a2c8e8c Validate block header UncleHash against calculated hash 2015-04-22 23:16:19 +02:00
ec6acacc53 Unskip BlockTests/bcInvalidHeaderTest.json wrongUncleHash 2015-04-22 23:16:19 +02:00
9834f855fa Finally, glorious HEX 2015-04-22 23:16:19 +02:00
24de35ef09 Add StateTests/stMemoryStressTest.json but skip for now 2015-04-22 23:16:19 +02:00
5c70333a12 Exclude TransactionWithSvalue0 as it expects invalid s value to be valid 2015-04-22 23:16:18 +02:00
8ec8bff11c Update github.com/ethereum/tests files 2015-04-22 23:16:18 +02:00
573bc3e05e Explicitly skip TransactionTests/tt10mbDataField.json 2015-04-22 23:16:17 +02:00
7254278c09 Add test wrapper for VMTests/vmInputLimits1.json 2015-04-22 23:16:17 +02:00
c745831118 Merge pull request #787 from ethereum/revert-785-revert-781-develop
Revert "Revert "refactor Dockerfile""
2015-04-22 21:36:01 +02:00
33083e6f6c Revert "Revert "refactor Dockerfile"" 2015-04-22 21:35:46 +02:00
73b3f2837f Handle bug in parent call response 2015-04-22 14:14:10 -05:00
95f172d4dc Merge pull request #785 from ethereum/revert-781-develop
Revert "refactor Dockerfile"
2015-04-22 20:52:47 +02:00
1a0b3d8c84 Revert "refactor Dockerfile" 2015-04-22 20:52:21 +02:00
41e3d01e63 Rename eth_Version to eth_protocolVersion. Closes #737 2015-04-22 13:42:09 -05:00
20bae2b8f6 Tests for magic words 2015-04-22 13:24:29 -05:00
2ea2261156 Accept num or hex as index 2015-04-22 13:24:10 -05:00
35ad9febce Update eth_getBlockByNumber to accept words 2015-04-22 13:14:10 -05:00
5f6c8832af Merge pull request #781 from caktux/develop
refactor Dockerfile
2015-04-22 13:46:04 -04:00
d2fab43abc Changed "Welcome to the Frontier" to something more geeky 2015-04-22 18:33:33 +02:00
39047d7d8b refactor Dockerfile 2015-04-22 11:38:54 -04:00
04e216319e Adding flags to facilitate cross compiling to ARM 2015-04-22 17:04:46 +02:00
35595560f0 Merge pull request #776 from fjl/win32-build-fixes
Win32 build fixes
2015-04-22 06:50:50 -07:00
c9e22976f5 change order of block insert and update LastBlock 2015-04-22 12:50:33 +02:00
07e85d8e14 Moved leveldb update loop to eth/backend 2015-04-22 12:46:41 +02:00
e1f616fadf cmd/geth: improve the JS tests
These changes ensure that the JS tests run without networking
and fixes the block chain export and its associated test.
2015-04-22 12:31:19 +02:00
635b66acdc p2p: return zero node from Self if the server is not running
This helps with fixing the tests for cmd/geth to run without networking.
2015-04-22 12:31:19 +02:00
96e2b6bc07 miner: use 32bit atomic operations
64bit atomic operations are not available on all 32bit platforms.
2015-04-22 12:31:19 +02:00
9d152d6191 common: delete BinaryLength
The test is failing the 32bit build and the function
is not used anywhere.
2015-04-22 12:31:19 +02:00
2f4cc72119 Merge pull request #765 from Gustav-Simonsson/more_block_test_improvements
Further fixes to block test wrapper
2015-04-22 11:53:02 +02:00
15550dc8c5 Merge pull request #766 from tgerring/issue762
Treat hexnums as big.Int instead of int64. Closes #762
2015-04-22 02:42:16 -07:00
13dc8627b5 Treat hexnums as big.Int instead of int64 2015-04-21 08:48:57 -05:00
9e03c48d43 move eth_hashrate to ext 2015-04-21 16:44:08 +03:00
63c5c7fb2d uses newHexNum for eth_hashrate 2015-04-21 16:44:08 +03:00
41b83fe1cd adds eth_hashrate RPC method 2015-04-21 16:44:08 +03:00
4ddbf81e74 Updated README to include windows builds 2015-04-21 12:38:01 +02:00
4ad8b28794 Merge pull request #760 from obscuren/develop
core: transaction fixes
2015-04-21 03:14:38 -07:00
6c2b703c58 Merge branch 'develop' of github.com-obscure:ethereum/go-ethereum into develop 2015-04-21 12:14:07 +02:00
1dc91975ad Merge pull request #756 from Gustav-Simonsson/block_test_improvements
Block test improvements
2015-04-21 03:09:35 -07:00
f4cd66dc00 blockpool: deleted 2015-04-21 12:03:02 +02:00
ed0817c55d core/rpc: fix for null entries in log filters. Closes #725
You can now specify `null` as a way of saying "not interested in this
topic, match all". core.Filter assumes the zero'd address to be the
wildcard. JSON rpc assumes empty strings to be wildcards.
2015-04-21 12:00:57 +02:00
8fce55b4c2 Merge pull request #763 from aboreum/develop
Remove "minGasPrice" field from JSON responses. Closes. #754
2015-04-21 02:30:40 -07:00
093d6d5074 core: removed nonce resetting from the block processor.
All nonce error handling has been moved to the worker
2015-04-21 11:27:12 +02:00
1d6d42919e miner: ignore a tx's transactor after a gas limit has been returned
When worker encounters a gas limit error, subsequent txs should be
ignored from that particular account. This will prevent:

1. Nonce errors been thrown all around
2. The "Known tx" error. Closes #719
3. Repeated contract address. Closes #731
2015-04-21 11:26:04 +02:00
64e8aa6260 syncing to mainline ethereum 2015-04-20 22:19:49 -06:00
3ef1cd43f6 fix for: Please remove the "minGasPrice" from block returns #754 2015-04-20 22:08:50 -06:00
b448390889 Further fixes to block test wrapper
* Move go test wrapper for block tests from cmd/geth to tests
* Fix logic for when tests are valid or not, by adding correct
  validations for expected valid/invalid blocks
* Change block insertion helper to work on single blocks
* Add one test case for each file in BlockTests and comment out
  the tests which are currently failing
* Add Skip call in all block tests in lieu of performance fixes
  around ethash cache which are needed before it will be fast enough
  to start / stop the node between each test
2015-04-21 05:23:10 +02:00
4a240608d4 Merge pull request #761 from aboreum/develop
trivial fix for: Broken link for detailed go build instructions #661
2015-04-20 16:04:44 -07:00
8d85e45c7d syncing to develop 2015-04-20 15:05:13 -06:00
59a7405a80 Broken link for detailed go build instructions #661 2015-04-20 14:47:12 -06:00
4494cba489 Merge branch 'develop' of https://github.com/aboreum/go-ethereum into develop
# Please enter a commit message to explain why this merge is necessary,
# especially if it merges an updated upstream into a topic branch.
#
# Lines starting with '#' will be ignored, and an empty message aborts
# the commit.
2015-04-20 14:43:12 -06:00
859187931b fix for: Broken link for detailed go build instructions #661 2015-04-20 14:31:26 -06:00
79bef9eb16 Merge branch 'develop' of github.com-obscure:obscuren/go-ethereum into develop 2015-04-20 21:57:00 +02:00
b8160cc6d4 core: shuffled some code 2015-04-20 20:37:40 +02:00
99e825ad96 Merge pull request #734 from bas-vk/issue-729
admin.StopRPC added to console
2015-04-20 10:34:50 -07:00
3d7c1b8194 Merge pull request #755 from karalabe/command-flags-cleanup
cmd/geth, cmd/utils: add cli flags for pprof and whisper
2015-04-20 09:17:04 -07:00
3b008723db cmd/geth, cmd/utils: invert --pprof once more 2015-04-20 19:14:49 +03:00
f28b2bb6ed core: upgraded block chain version 2015-04-20 18:12:05 +02:00
3b45fedb81 Merge branch 'ethersphere-frontier/natspec' into develop 2015-04-20 18:09:10 +02:00
36ec42e50c Merge branch 'frontier/natspec' of https://github.com/ethersphere/go-ethereum into ethersphere-frontier/natspec 2015-04-20 18:08:14 +02:00
c8e2b3710c cmd/geth, cmd/utils: use pprof disable flag, start globally 2015-04-20 18:59:41 +03:00
805345d135 Add block tests wrapper and fixes for tx tests
* Add fixes to parsing and converting of fields in tx tests
* Correct logic in tx tests; validation of fields and correct
  logic for when RLP decoding works/fails and when this is
  expected or not
* Rename files for consistency
* Add block tests wrapper to run block tests with go test
2015-04-20 17:46:35 +02:00
8830403acf cmd/geth, cmd/utils: add cli flags for pprof and whisper. 2015-04-20 18:45:37 +03:00
76025cc424 geth: added a admin.debug.block command which reprocess the block 2015-04-20 16:03:19 +02:00
72d065d491 core: force block process & fixed chain manager test 2015-04-20 16:02:50 +02:00
97a9753f87 core: added chain reset mechanism on bad blocks 2015-04-20 12:58:17 +02:00
45da3e17e2 core: added chain head reset to known block 2015-04-20 12:29:02 +02:00
52584596d4 geth: bump version number 2015-04-20 12:01:39 +02:00
97b0c4b697 core: moved TD calculation from proc to chain 2015-04-20 12:01:20 +02:00
fa729a0c55 miner: go fmt 2015-04-20 00:41:50 +02:00
5caf1aa1a9 Switched getWork third output from difficulty to target 2015-04-19 17:42:21 -04:00
093a9106b0 contract addresses include hex prefix
- simplify resolver and tests
- added missing test for KeyToUrl
- fix notice error message and its test with !%x(MISSING)
- natspec test: insertTx modified - does not prepend 0x to contract address
- disable networking in e2e test
2015-04-19 21:09:30 +01:00
2cc9211269 miner: fixed remote miner current work 2015-04-19 21:58:58 +02:00
71c974f3eb fix end to end test import cycle 2015-04-19 20:57:50 +01:00
e9874cbcc1 fixed resolver test 2015-04-19 20:57:50 +01:00
929428d602 URLhint support for URLs longer than 32 bytes 2015-04-19 20:57:49 +01:00
b6fe9e0c83 added missing source file 2015-04-19 20:57:49 +01:00
bb793c829f fixed incomplete merge 2015-04-19 20:57:49 +01:00
d8fb834386 test account is no longer permanently in genesis block, only put there when testing 2015-04-19 20:57:49 +01:00
dba2367157 NatSpec contracts are now not in the genesis block but added by the test 2015-04-19 20:57:49 +01:00
f255336c2c utils linked to natspec notice eval, test notice now using utils.toHex() 2015-04-19 20:57:49 +01:00
c4b7d4d3f7 NatSpec cli option, resolver tests passing 2015-04-19 20:57:49 +01:00
b46e152171 default fallback NatSpec messages 2015-04-19 20:57:49 +01:00
8e6a068d2d natspec test bugfix 2015-04-19 20:57:49 +01:00
b635cad9fe NatSpec passing end to end test 2015-04-19 20:57:49 +01:00
94489b2269 s 2015-04-19 20:57:49 +01:00
e2d333d209 NatSpec contracts in genesis block, end to end test (unfinished) 2015-04-19 20:57:49 +01:00
ac0e5e8b6d resolver tests
- add resolver tests and fix resolver to pass
- statereg constructor fixed
- comments added to natspec plus docserver integration for natspec userdoc fetching
2015-04-19 20:57:49 +01:00
3a540425a3 reorg:
- statereg methods move to natspec/resolver/docserver
- fix failing test on invalid js input
2015-04-19 20:57:48 +01:00
5b0ea1044a add docserver using net/http Transport/Roundtrip 2015-04-19 20:57:48 +01:00
3136bae4a5 NatSpec, URL register storage retrieval
fixed 2/3 tests
2015-04-19 20:57:48 +01:00
97a602864a add common/resolver skeleton 2015-04-19 20:57:48 +01:00
45676382b6 natspec integrated to console frontend confirmTransaction 2015-04-19 20:57:48 +01:00
d0b3536593 new natspec
- constructor takes abidoc, userdoc
- json parsing of userdoc
- method found by abi data
- notice found from method
2015-04-19 20:57:48 +01:00
ea11dba00b Merge branch 'develop' of github.com-obscure:ethereum/go-ethereum into develop 2015-04-19 21:46:41 +02:00
5dd56bb474 geth: admin download status 2015-04-19 21:46:19 +02:00
2c1a6a349b miner: removed default timer & update dag when threads > 0 2015-04-19 21:45:40 +02:00
e6d36fe356 Merge pull request #748 from fjl/build-script-unix
Makefile: for non-gophers
2015-04-19 17:58:42 +02:00
ed07ffcde5 downloader: fixed tests with low ttl 2015-04-19 17:37:01 +02:00
dcf1a1988a moved 2015-04-19 17:14:15 +02:00
8eff550e8b Merge branch 'fjl-rlp-size-validation' into develop 2015-04-19 17:07:59 +02:00
8f3a7e41de Merge branch 'rlp-size-validation' of https://github.com/fjl/go-ethereum into fjl-rlp-size-validation
Conflicts:
	eth/protocol.go
2015-04-19 17:07:40 +02:00
4683f9c0a7 Merge branch 'develop' of github.com-obscure:ethereum/go-ethereum into develop 2015-04-19 13:33:39 +02:00
cce4158cfc Removed debug println 2015-04-19 13:33:14 +02:00
3d497be9bd eth: drop blocks with low TD 2015-04-19 13:31:37 +02:00
6e1aa91aaf geth: added getBlockRlp for dumping block in rlp format 2015-04-19 13:30:55 +02:00
c58918c84a downloader: moved chunk ignoring. Fixes issue with catching up 2015-04-19 13:30:34 +02:00
61885aa965 Don't export types/functions 2015-04-19 10:01:50 +02:00
2c229bac00 Replaced channel pointer field with non pointer channel 2015-04-19 09:55:41 +02:00
9ec56637f9 Merge pull request #749 from fjl/fix-nodekey-persistence
Fix p2p node key persistence
2015-04-19 01:56:56 +02:00
4340996572 eth: temp 100% block propagation because of the current state of the net 2015-04-19 01:40:01 +02:00
5c59d95532 downloader: defer peer reset after download 2015-04-19 01:39:37 +02:00
4907d28967 crypto: update {Load,Save}ECDSA comments to mention hex encoding 2015-04-19 01:33:00 +02:00
da4a0e0555 eth: fix node key persistence
crypto.LoadECDSA has been modified to expect hex data.
The key was being saved as raw bytes, causing the file
to be rewritten on every start.
2015-04-19 01:28:41 +02:00
48f23746f0 Makefile: for non-gophers
Many people need or want to build go-ethereum from the git repository,
mostly to stay up to date with recent changes. We cannot expect that
people without Go experience grok the Go workspace concept.

With the Makefile, building from github requires only
three steps (provided that a Go toolchain is installed):

    - git clone https://github.com/ethereum/go-ethereum
    - ... install C libraries (libgmp, etc.) ...
    - make
2015-04-19 00:42:34 +02:00
86ecdcd5ff downloader: reset hashTtl on receive 2015-04-19 00:15:05 +02:00
71aa5fe8a3 Merge branch 'downloader-proto' into develop 2015-04-19 00:09:12 +02:00
164b878854 cleanup 2015-04-19 00:08:57 +02:00
c453f1f370 tests: hopefully improve test conversion helpers
(cherry picked from commit 035a30acbe)
2015-04-19 00:07:09 +02:00
235ed7ecb9 cmd/geth, tests: enable running multiple tests from a single file
This commit also changes the block test loading so tests containing
invalid RLP blocks can be loaded and return an error only when they are
run.

(cherry picked from commit 898ba87984)
2015-04-19 00:06:52 +02:00
434dea3caf eth: removed debug messages to stdout 2015-04-19 00:03:26 +02:00
2ce21cefdc eth: use NewDB hook also for extra DB
(cherry picked from commit d5083033f1)
2015-04-18 23:59:31 +02:00
50e096e627 downloader: don't remove peers. keep them around 2015-04-18 23:56:08 +02:00
03b4cf74a2 geth: added identity flag which allows to set a custom node name 2015-04-18 23:53:30 +02:00
d34e4dc5ac Merge branch 'develop' into downloader-proto 2015-04-18 21:26:43 +02:00
84f1af6413 core: merge using equal block numbers rather than the current block 2015-04-18 21:23:42 +02:00
c8cc523d4d miner: reverted back to old event 2015-04-18 20:51:05 +02:00
a1d97ea4db typo 2015-04-18 20:35:49 +02:00
c6c22301fa miner: changed listener 2015-04-18 20:26:17 +02:00
6830ddb659 downloader: free up peers from work when the downloader resets 2015-04-18 20:25:55 +02:00
7c5d50f627 downloader: throw an error if there are no peers available for download
If all peers have been tried during the block download process and some
hashes are unfetchable (available peers > 0 and fetching == 0) throw an
error so the process can be aborted.
2015-04-18 19:30:29 +02:00
78e37e98e7 downloader: fixed a race condition for download status 2015-04-18 19:14:25 +02:00
0d536734fe eth: adapted to new synchronous api of downloader's AddBlock 2015-04-18 18:57:59 +02:00
c2c24b3bb4 downloader: improved downloading and synchronisation
* Downloader's peers keeps track of peer's previously requested hashes
  so that we don't have to re-request
* Changed `AddBlock` to be fully synchronous
2015-04-18 18:55:13 +02:00
60613b57d1 downloader: make sure that hashes are only accepted from the active peer 2015-04-18 17:35:03 +02:00
ff67fbf964 Merge branch 'develop' into downloader-proto 2015-04-18 15:14:56 +02:00
525cefa37a updated ethash 2015-04-18 15:14:44 +02:00
8244825bbf downloader: reset the queue if a peer response with an empty hash set 2015-04-18 15:14:12 +02:00
eef4776b5b eth: ignore NewBlockMsg with lower td 2015-04-18 14:25:22 +02:00
1bc2d83b6f core: improved uncle validation error message 2015-04-18 14:24:44 +02:00
8f873b762b downloader: all handlers check for isBusy 2015-04-18 03:15:26 +02:00
a6c0a75f9a eth: fixed proper BroadcastBlock for mined blocks 2015-04-18 02:38:13 +02:00
c39a7b5c0d Merge branch 'develop' of github.com-obscure:ethereum/go-ethereum into develop 2015-04-18 02:33:04 +02:00
89fd752659 rpc: set from. Closes #742 2015-04-18 02:32:55 +02:00
f1ae3dc4aa geth: bump version number 2015-04-18 02:27:50 +02:00
12e8d9c4dd eth: listen for mined blocks and propagate using the protocol manager 2015-04-18 02:27:37 +02:00
ecc74d76cc eth: drop blocks that are known 2015-04-18 02:24:24 +02:00
cc436c4b28 eth: additional cleanups to the subprotocol, improved block propagation
* Improved block propagation by sending blocks only to peers to which, as
  far as we know, the peer does not know about.
* Made sub protocol its own manager
* SubProtocol now contains the p2p.Protocol which is used instead of
  a function-returning-protocol thing.
2015-04-18 02:21:07 +02:00
c2f410214c eth: began split up of peers and protocol manager 2015-04-18 01:11:09 +02:00
2339ee9910 Merge branch 'develop' into downloader-proto
Conflicts:
	eth/downloader/downloader.go
2015-04-18 01:10:32 +02:00
7dc6c33873 Merge pull request #736 from frozeman/develop
add extra space to miner icon
2015-04-17 22:17:50 +02:00
576393550d add extra space to miner icon 2015-04-17 15:00:37 +02:00
7180699d40 rlp: require declared number of input elements for array types 2015-04-17 14:45:10 +02:00
9c7281c17e p2p: make DiscReason bigger than byte
We decode into [1]DiscReason in a few places. That doesn't work anymore
because package rlp no longer accepts RLP lists for byte arrays.
2015-04-17 14:45:10 +02:00
4d5a518a0b rlp: stop accepting lists for byte slices and byte arrays 2015-04-17 14:45:10 +02:00
574d5d6ae6 core/types: add rlp tag "nil" for Transaction.Recipient 2015-04-17 14:45:10 +02:00
cad64fb911 rlp: stricter rules for structs and pointers
The rules have changed as follows:

* When decoding into pointers, empty values no longer produce
  a nil pointer. This can be overriden for struct fields using the
  struct tag "nil".
* When decoding into structs, the input list must contain an element
  for each field.
2015-04-17 14:45:09 +02:00
1e2c93aa2d rlp: reject non-minimal input strings
Input strings of length 1 containing a byte < 56 are non-minimal and
should be encoded as a single byte instead. Reject such strings.
2015-04-17 14:45:09 +02:00
6e9f8035a1 rlp: stricter validation of canonical integer format
All integers (including size information in type tags) need to be
encoded using the smallest possible encoding. This commit expands the
stricter validation introduced for *big.Int in commit 59597d23a5
to all integer types and size tags.
2015-04-17 14:45:09 +02:00
6788f955c2 rlp: fix handling of single byte zero when decoding into a pointer
A single zero byte carries information and should not set the pointer
to nil. This is arguably a corner case. While here, fix the comment
to explain pointer reuse.
2015-04-17 14:45:09 +02:00
509d0a8d78 whisper: fix comment for rlpenv 2015-04-17 14:45:09 +02:00
eedbb1ee9a p2p/discover: use rlp.DecodeBytes 2015-04-17 14:45:09 +02:00
2750ec47b7 rlp: fix integer overflow in list element size validation
It is not safe to add anything to s.size.
2015-04-17 14:45:09 +02:00
56a48101dc cmd/rlpdump, cmd/utils, eth, p2p, whisper: use rlp input limit 2015-04-17 14:45:09 +02:00
c35f4fd0bd rlp: check top-level value sizes against input limit
This is a preliminary fix for #420 (SEC-18 RLP decoder unsafe
allocation). If a sane input limit is set on the rlp.Stream,
it should no longer be possible to cause huge []byte allocations.
2015-04-17 14:42:41 +02:00
4020258801 Merge pull request #718 from karalabe/whisper-cleanup
Whisper cleanup, part 2
2015-04-17 14:10:55 +02:00
73eb8e8c20 eth: basic implementation of the downloader 2015-04-17 13:54:18 +02:00
4afc22ba6e whisper: cleanup lefover scoping 2015-04-17 14:11:46 +03:00
bd14bd6c5b whisper: hide some internal types 2015-04-17 13:25:18 +03:00
d3ed3285e9 Merge pull request #733 from fjl/p2p-dial-timer
p2p: fix the dial timer
2015-04-17 11:32:55 +02:00
5528abc795 p2p: fix the dial timer
The dial timer was not reset properly when the peer count reached
MaxPeers.
2015-04-17 08:17:01 +02:00
545ff1e3f3 Merge pull request #728 from tgerring/issue727
Fix RPC Call output when empty
2015-04-17 00:17:40 +02:00
2c2ddcbf88 Merge branch 'develop' of github.com-obscure:ethereum/go-ethereum into develop 2015-04-17 00:11:58 +02:00
eac2df02d1 downloader: fixed a typo 2015-04-17 00:11:45 +02:00
b6d1724dd9 Merge pull request #730 from Gustav-Simonsson/update_transaction_tests
Update transaction tests
2015-04-17 00:09:10 +02:00
ead3dd9759 Stop accepted and alive connections (http keep-alive) when the rpc service is stopped 2015-04-16 19:23:57 +02:00
e5a03eb066 whisper: don't issue signature warning if none present 2015-04-16 18:24:39 +03:00
57f93d25bd admin.stopRPC support added which stops the RPC HTTP listener 2015-04-16 12:56:51 +02:00
e5e91e9eb3 whisper: track active peers, add peer cache expiry test 2015-04-16 13:05:35 +03:00
ee6531c5ff whisper: remove dead code, rename a few constants 2015-04-16 11:20:01 +03:00
205378016f downloader: added demotion / promotion in prep. for rep. system 2015-04-16 02:16:33 +02:00
eda10c7317 downloader: updated downloader and fixed issues with catch up
Properly ignore blocks coming from peers not in our peer list (blocked)
and do never request anything from bad peers. Added some checks to
account for blocks known when requesting hashes (missing parents).
2015-04-16 01:29:32 +02:00
3a51c3b584 Merge branch 'develop' into downloader-proto 2015-04-16 01:28:24 +02:00
c4678ffd77 downloader: updated downloader and fixed issues with catch up
Properly ignore blocks coming from peers not in our peer list (blocked)
and do never request anything from bad peers. Added some checks to
account for blocks known when requesting hashes (missing parents).
2015-04-16 00:14:31 +02:00
dff39553d4 core: changed split detection to also account for number less than 2015-04-16 00:11:40 +02:00
c617a6ec79 Fixes for TransactionTests
* Include tests which now has consistent HEX encodings
* Comment out two failing tests: "
  "TransactionWithHihghNonce" due to wrong nonce size
  "TransactionWithSvalueHigh" due to wrong ECDSA s range
* Cleanup conversion functions and fix expected encodings for
  tests validation fields
2015-04-15 22:37:16 +02:00
2d8a2d0c99 Update JSON tests 2015-04-15 22:36:33 +02:00
6388767df0 Fix call output when empty 2015-04-15 12:45:20 -05:00
ec6cbb914b miner: start a newly registered agent if the miner is running. Closes #681 2015-04-15 17:04:22 +02:00
52c874a609 common: Added debug reporter
NOTE: For known, non-consensus, hard to reproduce bugs consider the
following method `common.Report("extra", stuff, "you need logged")` will
give you a stack trace and a friendly request to submit it as an issue
on our issue tracker.
2015-04-15 16:39:44 +02:00
eaf73b55bc miner: moved bad uncle logging to ridiculous log level. Closes #720 2015-04-15 12:12:20 +02:00
6ceb253f74 whisper: use async handshakes to handle blocking peers 2015-04-15 13:01:22 +03:00
5d2138a2b2 core: fixed issue for logs filter. Closes #629
Log filter `Address` field was cast to a Hash which causes it to always
fail.
2015-04-15 11:59:41 +02:00
ccb4722a59 core/types: Changed bloom lookup to take anything bytes backed 2015-04-15 11:58:45 +02:00
46ea193a49 whisper: remove some unneeded testing complexity 2015-04-15 12:50:10 +03:00
bcf41797ca whisper: global message expiration tests, polishes 2015-04-15 10:50:31 +03:00
d82aaf617c rpc: changed logging to use glog 2015-04-15 00:09:13 +02:00
f46af4508b geth: fixed failing cli tests 2015-04-14 21:26:28 +02:00
8db7b2374c rpc: change eth_protocolVersion to eth_version. Closes #714 2015-04-14 20:47:21 +02:00
4fb7ab5d09 whisper: mock tests to use simulated peers 2015-04-14 19:00:57 +03:00
86372b20c0 whisper: add basic tests for the whiper peers 2015-04-14 18:21:56 +03:00
f6efdd8aad whisper: shorten constants to TTL and PoW 2015-04-14 15:16:02 +03:00
1a4cfc173e whisper, xeth/whisper, ui/qt/qwhispe: fix API polish breakages 2015-04-14 15:02:31 +03:00
e2b7498c9d whisper: add known message expiration to peers, cleanup 2015-04-14 14:28:59 +03:00
13eb46ea94 geth: added print block to admin 2015-04-14 12:49:30 +02:00
9800c84348 eth: limit the amount of peers that will receive Block/Tx messages
All transaction and block messages are now limited using `sqrt(peers)`
2015-04-14 12:49:15 +02:00
8310bcda61 state: fixed mutex lockes 2015-04-14 12:47:54 +02:00
474aa924ca p2p: added limiter function to limit package broadcasting 2015-04-14 12:47:31 +02:00
59bff46505 whisper: general cleanups, documentation 2015-04-14 13:24:43 +03:00
5205b2f19b whisper: fix anonymous broadcast drop, add broadcast tests 2015-04-14 12:12:47 +03:00
4af7743663 whisper: add utility functions for creating topics 2015-04-14 11:12:09 +03:00
b7e1b686aa Merge branch 'develop' of github.com-obscure:ethereum/go-ethereum into develop 2015-04-14 00:38:53 +02:00
2ea98d9b74 Merge pull request #704 from fjl/p2p-concurrency-fixups
p2p: more concurrency fixups
2015-04-14 00:38:47 +02:00
07eebc38b2 Merge branch 'develop' of github.com-obscure:ethereum/go-ethereum into develop 2015-04-14 00:38:11 +02:00
333d4e0f27 core: during split properly insert parent blocks
During a split parent and grand parent were included in the database but
not in the canonical chain (numbered chain). Added a `merge` function
which finds the common ancestor of the chains and reinserts the missing
blocks.
2015-04-14 00:20:29 +02:00
f6f9a0d515 Merge pull request #709 from ligi/patch-1
Fix links
2015-04-13 23:46:17 +02:00
3a33428578 Fix links
Where 404s before - now linking to the path that they stay valid a little longer ;-)
2015-04-13 23:09:23 +02:00
4f3c169b4e miner: don't break loop when encountering gas limit reach err
Processing transactions should continue when a transaction throws a gas
limit reached error. Other transactions may actually succeed.
2015-04-13 22:58:53 +02:00
d423305f07 state: fixed nonce issue in managed state
Rlock => Lock when creating a new nonce
2015-04-13 22:57:03 +02:00
d61ec9ca76 rpc: removed hash from LogRes. Closes #701 2015-04-13 21:28:05 +02:00
0217652d1b p2p/discover: improve timer handling for reply timeouts 2015-04-13 18:08:11 +02:00
b8aeb04f6f p2p/discover: remove unused field Node.activeStamp 2015-04-13 17:44:14 +02:00
b9929d289d p2p: fix unsynchronized map access during Server shutdown
removePeer can be called even after listenLoop and dialLoop have returned.
2015-04-13 17:37:32 +02:00
333e539ce2 Merge branch 'develop' of github.com-obscure:ethereum/go-ethereum into develop 2015-04-13 17:35:46 +02:00
1fa844aaf5 Merge pull request #702 from ethersphere/frontier/blockpool
blockpool stability fixes:
2015-04-13 17:35:25 +02:00
5f9346bc7a Merge pull request #700 from bas-vk/issue_650
Added blockchain DB versioning support, closes #650
2015-04-13 17:34:34 +02:00
995fab2ebc p2p: fix yet another disconnect hang
Peer.readLoop will only terminate if the connection is closed. Fix the
hang by closing the connection before waiting for readLoop to terminate.

This also removes the british disconnect procedure where we're waiting
for the remote end to close the connection. I have confirmed with
@subtly that cpp-ethereum doesn't adhere to it either.
2015-04-13 17:34:08 +02:00
97d2954e22 eth: added downloader for syncing up the chain 2015-04-13 17:22:32 +02:00
79a6782c1c p2p: fix goroutine leak when handshake read fails
This regression was introduced in b3c058a9e4.
2015-04-13 17:06:19 +02:00
ad4891a09a Merge pull request #689 from Gustav-Simonsson/add_transaction_tests
Add transaction tests
2015-04-13 16:55:21 +02:00
a8a2b2a488 downloader: added missing blocks catchup functionality
When a parent is missing in the block list an attempt should be made to
fetch the missing parent and grandparents.
2015-04-13 16:38:32 +02:00
cb707ba50c whisper: push work in progress for bug report 2015-04-13 16:19:34 +03:00
3d57e377a4 blockpool stability fixes:
- follow up locks and fix them
- chainManager: call SetQueued for parentErr future blocks, uncomment TD checks, unskip test
- make ErrIncorrectTD non-fatal to be forgiving to genuine mistaken nodes (temp) but demote them to guard against stuck best peers.
- add purging to bounded nodeCache (config nodeCacheSize)
- use nodeCache when creating blockpool entries and let non-best peers add blocks (performance boost)
- minor error in addError
- reduce idleBestPeerTimeout to 1 minute
- correct status counts and unskip status passing status test
- glogified logging
2015-04-13 13:13:55 +01:00
faa2747809 Merge pull request #690 from karalabe/whisper-cleanup
Whisper cleanup, part 1
2015-04-13 13:39:59 +02:00
89358d25a4 whisper: start adding integration tests 2015-04-13 13:15:01 +03:00
9a53390f49 whisper: clean up and integrate topics 2015-04-13 12:16:51 +03:00
7b501906db whisper: separate out magic number from the code 2015-04-13 11:31:51 +03:00
49a513bdeb Added blockchain DB versioning support, closes #650 2015-04-13 10:13:52 +02:00
7dcb9825c3 downloader: return an error for peer.fetch and return chunk to queue
If a peer was somehow already fetching and somehow managed to end up in
the `available` pool it should return it's work.
2015-04-12 13:36:01 +02:00
5467e7b312 whisper: fix comment entity capitalizations 2015-04-12 14:34:53 +03:00
6efa8db888 downloader: renamed chunks to queue 2015-04-12 13:24:38 +02:00
acf8452c33 downloader: implemented new downloader 2015-04-12 12:38:25 +02:00
61db7a71dd Merge pull request #695 from ethersphere/frontier/blockpool
bugfixes for headsection deadlocks
2015-04-11 10:46:34 +02:00
406feee570 bugfixes for headsection deadlocks
- switchC initialised as closed
- move select in setChainInfoFromBlock out of peer lock
2015-04-11 04:58:53 +01:00
f047699afb Updated glog 2015-04-10 19:59:07 +02:00
3aa5437a10 Set input to nil for create 2015-04-10 19:59:01 +02:00
36fe11378c Bump 2015-04-10 18:21:27 +02:00
eb75a77151 Merge branch 'develop' of github.com-obscure:ethereum/go-ethereum into develop 2015-04-10 18:21:09 +02:00
6107b53de0 Merge pull request #692 from ethersphere/frontier/blockpool
td update from node + bugfix
2015-04-10 18:20:23 +02:00
5d4f69f483 Merge branch 'develop' of github.com-obscure:ethereum/go-ethereum into develop 2015-04-10 17:59:38 +02:00
92fbb61625 Merge pull request #691 from fjl/discovery-fixes
p2p: a bunch of fixes
2015-04-10 17:59:32 +02:00
3d29805322 Added pprof 2015-04-10 17:38:06 +02:00
da7332a731 td update from node
- reorg and simplify AddBlock
- introduce nodeCache
- TestPeerPromotionByTdOnBlock unskipped and passes
- move switchC/idleC channel creation around: solves deadlock (now respects the contract with section process: either can activate or complete at any one time)
2015-04-10 16:36:40 +01:00
c5332537f5 p2p: limit number of lingering inbound pre-handshake connections
This is supposed to apply some back pressure so Server is not accepting
more connections than it can actually handle. The current limit is 50.
This doesn't really need to be configurable, but we'll see how it
behaves in our test nodes and adjust accordingly.
2015-04-10 17:24:41 +02:00
56977c225e p2p: use RLock instead of Lock for pre-dial checks 2015-04-10 17:23:09 +02:00
b3c058a9e4 p2p: improve disconnect signaling at handshake time
As of this commit, p2p will disconnect nodes directly after the
encryption handshake if too many peer connections are active.
Errors in the protocol handshake packet are now handled more politely
by sending a disconnect packet before closing the connection.
2015-04-10 16:57:56 +02:00
f8a4cd7ec1 xeth/whisper, ui/qt/qwhisper: fix API update breaks. 2015-04-10 17:03:08 +03:00
0e4f21fc37 whisper: polish the Envelope a bit, prep for tests. 2015-04-10 16:52:01 +03:00
7d8ce53eca whisper: polish the messages, fix some bugs, tests
Bugs fixed:
  - Use randomly generated flags as the spec required.
  - During envelope opening check the first bit only for signature.
2015-04-10 15:53:21 +03:00
99a1db2d40 p2p: don't mess with the socket deadline in Peer.readLoop
netWrapper already sets a read deadline in ReadMsg.
2015-04-10 13:26:28 +02:00
145330fdf2 p2p: properly decrement peer wait group counter for setup errors 2015-04-10 13:26:27 +02:00
f1d710af00 p2p: fix Peer shutdown deadlocks
There were multiple synchronization issues in the disconnect handling,
all caused by the odd special-casing of Peer.readLoop errors. Remove the
special handling of read errors and make readLoop part of the Peer
WaitGroup.

Thanks to @Gustav-Simonsson for pointing at arrows in a diagram
and playing rubber-duck.
2015-04-10 13:26:27 +02:00
22d1f0faf1 p2p: improve peer selection logic
This commit introduces a new (temporary) peer selection
strategy based on random lookups.

While we're here, also implement the TODOs in dialLoop.
2015-04-10 13:26:27 +02:00
7be05b4b9d p2p/discover: don't log packet content 2015-04-10 13:26:27 +02:00
9cd8c96157 p2p/discover: make packet processing less concurrent 2015-04-10 13:26:27 +02:00
7e54a9c07f whisper: rename test file according to Go style 2015-04-10 13:46:08 +03:00
a4c8e947b0 whisper: make the test app runnable & do something inside 2015-04-10 13:42:49 +03:00
6d20d634ca Enable more tx tests by expecting most common encoding of values 2015-04-10 12:34:55 +02:00
6dc2146ed7 Remove unneeded map assignments for working tx RLP tests 2015-04-10 12:03:46 +02:00
9ac5671c18 Add TransactionTests wrapped as Go tests
* Add initial go wrapping for TransactionTests with some tests
  disabled in lieu of consistent HEX encodings and a few other
  pending bugfixes
* TODO: Consider better way of perhaps modelling each test in
  the JSON files as a single Go test, instead of one Go test per
  JSON file
2015-04-10 11:55:31 +02:00
1e18f4544b Update JSON test files 2015-04-10 11:52:31 +02:00
fc1d1f9afd Merge branch 'develop' of github.com-obscure:ethereum/go-ethereum into develop 2015-04-10 11:03:46 +02:00
3755cfccb3 Skipped td test 2015-04-10 11:03:36 +02:00
20fd60902b Merge pull request #687 from karalabe/develop
xeth: fix #640, panic converting nil recipient to hex.
2015-04-10 11:02:25 +02:00
d1729acd2b cmd/mist: fix another nil recipient address panic. 2015-04-10 11:43:08 +03:00
b2b1241dd7 cmd/mist: fix #640, panic converting nil recipient to hex.
Fetching the recipient address from a transaction was changed to return nil
instead of a zero-address, but this code path was not updated, so whenever
a contract was created, a nil panic occured.
2015-04-10 11:20:04 +03:00
4de1e1609a Merge pull request #682 from bas-vk/issue_567
bugfix as a result of PR 671
2015-04-09 23:42:17 +02:00
dc2b9fd458 bugfix as a result of PR 671 2015-04-09 20:06:27 +02:00
ec9fbf09aa Added some quotes .... 2015-04-09 18:24:22 +02:00
9f5d24be31 glog 2015-04-09 18:16:22 +02:00
b0f40beea6 Added proper contract for registrar 2015-04-09 17:59:05 +02:00
ab015959e1 bump 2015-04-09 17:54:20 +02:00
2747df3df1 added contracts 2015-04-09 17:42:43 +02:00
01ee012197 Merge branch 'ethersphere-frontier/blockpool' into develop 2015-04-09 17:40:28 +02:00
764a802eaa Disabled TD check
@zelig: Temporarily commented out TD check untill the rest of the network has
been fixed.
2015-04-09 17:39:02 +02:00
663fd8f849 Moved log to debug 2015-04-09 17:19:05 +02:00
46898f1e55 Merge branch 'frontier/blockpool' of https://github.com/ethersphere/go-ethereum into ethersphere-frontier/blockpool 2015-04-09 16:54:32 +02:00
0636e17dbe Added default registrar 2015-04-09 16:37:04 +02:00
be25396340 separate lock for blacklist 2015-04-09 13:58:35 +01:00
a009132c24 oops peer unlocked before return - fixes deadlock 2015-04-09 13:58:35 +01:00
0e2bc23148 uncomment future block TD check, add test for skipping TD check on future block 2015-04-09 13:58:35 +01:00
e55747a074 fix deadlock issue in AddBlock
- add peer switch channel arg to activateChain - no peer locking within
- proper locking in AddBlock - fixes deadlock issue
- comment out TD check and skip incorrect TD test again for hotfix
2015-04-09 13:58:35 +01:00
262714fc6c future queued block support
- queued       bool // flag for blockpool to skip TD check
- set to true when future block queued
- in checkTD: skip check if queued
- TODO: add test (insertchain sets future block)
2015-04-09 13:58:35 +01:00
cbd0b42060 put back checkTD and unskip incorrectTD test 2015-04-09 13:58:35 +01:00
f546b486bf introduce peers registry on nodes
- TestPeerPromotionByTdOnBlock renamed and skipped for now test should pass iff
  if TD is updated based on an agreement
- senders register in AddBlock, flag records if they are coming from newblock
  message (and therefore advertise their TD with the block) or block message
  (TODO: latter are stored on the cache and updated by checkTD call;
  protocol should also call AddBlock on newblock messages by non-best peers)
- remove TD update from optional TD field in addBlock: this is no longer part of
  the eth protocol spec -> TODO: reflect in wiki
- only initialise peer map if at least two
2015-04-09 13:58:35 +01:00
42fb9652f5 fix blockpool deadlock
- do not break from headsection on error
[remove peer after protocol quit will close switchC, until then head block can arrive and block on channel while keeping peers lock causing a deadlock.]
- more careful locking in AddBlock
2015-04-09 13:58:35 +01:00
30830652ae fix TestPoolStatus test crashing, skip tests failing (due to @obscuren hotfixes) 2015-04-09 13:58:35 +01:00
c6b25a4046 Merge branch 'develop' of github.com-obscure:ethereum/go-ethereum into develop 2015-04-09 13:24:08 +02:00
8d059e54f1 Updated xeth logger 2015-04-09 11:49:14 +02:00
558683d10c Merge pull request #678 from bas-vk/feature_635
Support for import/export hex encoded keys
2015-04-09 11:31:44 +02:00
79cc3cc98e Merge pull request #671 from bas-vk/issue_567
Add path expansion support for command line arguments, closes 567
2015-04-09 11:31:04 +02:00
ef393da933 removed utility function and implemented hex conversation in crypto functions 2015-04-09 10:59:37 +02:00
6da5b2fc5f reformat code with goimports 2015-04-09 10:26:26 +02:00
a9959805e5 Removed from as a requirement and changed
Removed the from as a requiremet from the RPC eth_call. Xeth#Call now
also default values to:

1. Supplied account
2. First account if any
3. No managed account => 000000..00
2015-04-09 00:44:20 +02:00
204ac81188 Moved handling of nonces to the managed state 2015-04-08 23:30:07 +02:00
b3a3fdf9a4 Support for import/export hex encoded keys, closes #635 2015-04-08 23:03:47 +02:00
6e2f78ebdd Default log to stderr 2015-04-08 22:18:16 +02:00
2e2860e4df Make sure mist runs ... :-) 2015-04-08 22:17:49 +02:00
6184781b49 Improved transaction pool
The transaction pool will now some easily be able to pre determine the
validity of a transaction by checking the following:

* Account existst
* gas limit higher than the instrinsic gas
* enough funds to pay upfront costs
* nonce check
2015-04-08 20:47:32 +02:00
a7750c929b Fixed tests to reflect log changes 2015-04-08 20:45:39 +02:00
f08e9cbe42 ignore invalid txs right after being added if they prove incorrect 2015-04-08 18:08:21 +02:00
1c872ddf4b Changed how logs are being recorded
Logs are now recorded per transactions instead of tossing them out after
each transaction. This should also fix an issue with
`eth_getFilterLogs` (#629) Also now implemented are the `transactionHash,
blockHash, transactionIndex, logIndex` on logs. Closes #654.
2015-04-08 17:15:45 +02:00
5304f43067 Add path expansion support for command line arguments, closes 567 2015-04-08 15:43:55 +02:00
6284604b52 Merge branch 'develop' of github.com-obscure:ethereum/go-ethereum into develop 2015-04-08 13:07:30 +02:00
a953f3ec97 Sync managed accounts to the network 2015-04-08 13:07:21 +02:00
31b086f511 Added additional methods to the managed state
* GetNonce Returns the canonical nonce
* SetNonce Set the managed account's nonce
2015-04-08 13:06:56 +02:00
7c0a18edb5 Merge pull request #658 from Gustav-Simonsson/add_ec_point_on_curve_check
Add IsOnCurve check to EC unmarshalling in ECIES decryption
2015-04-08 00:51:12 +02:00
09147a50ed Improved tx pool to ignore invalid transactions
Transaction pool will attempt to ignore invalid transactions it had
previously encountered.
2015-04-08 00:31:23 +02:00
d09d2b96fc fixed stop of miner 2015-04-08 00:30:23 +02:00
aa4ff52d84 Add IsOnCurve check to EC unmarshalling in ECIES decryption 2015-04-07 23:50:04 +02:00
7f32a08b60 Queued level db writes and batch writes. Closes #647 2015-04-07 22:19:01 +02:00
758205b187 Merge pull request #648 from Gustav-Simonsson/forward_ecrecover_err_and_remove_dup_checks
Forward and log EC recover err and remove dup pubkey len check
2015-04-07 20:48:56 +02:00
f597863927 Merge pull request #657 from Gustav-Simonsson/disable_libsecp256k1_debug_check
libsecp256k1 #define NDEBUG
2015-04-07 20:39:05 +02:00
941f051358 libsecp256k1 #define NDEBUG 2015-04-07 18:09:58 +02:00
3ddc109778 Merge branch 'Gustav-Simonsson-update_bitcoin_secp256k1_lib2' into develop 2015-04-07 15:20:51 +02:00
50bbdfe582 Link GMP 2015-04-07 15:20:24 +02:00
ce9a28d7bb Merge branch 'update_bitcoin_secp256k1_lib2' of https://github.com/Gustav-Simonsson/go-ethereum into Gustav-Simonsson-update_bitcoin_secp256k1_lib2 2015-04-07 15:10:31 +02:00
0196a97319 Merge branch 'tgerring-rpcfabian' into develop 2015-04-07 15:04:45 +02:00
3063aad7db merge conflict 2015-04-07 15:04:29 +02:00
50aa1f178c updated logging 2015-04-07 14:57:16 +02:00
688d118c7e Updated logging 2015-04-07 14:57:04 +02:00
d0c3f127ee More type fixes 2015-04-07 06:49:31 -05:00
01b2c90179 Updated ethash 2015-04-07 13:17:27 +02:00
c756633fb7 Merge branch 'develop' of github.com-obscure:ethereum/go-ethereum into develop 2015-04-07 13:10:21 +02:00
43454053b0 Fixed tests 2015-04-07 13:10:12 +02:00
1aaeae292d Output format and nil fixes 2015-04-07 06:10:00 -05:00
2591883a18 Use logger.Error instead of 0 with glog 2015-04-07 12:48:19 +02:00
3f306f63d4 Forward and log EC recover err and remove dup pubkey len check 2015-04-07 12:48:19 +02:00
d9b37b6da7 Update Go wrapper around libbsecp256k1 2015-04-07 12:40:31 +02:00
7c583f8222 Merge pull request #653 from debris/circular_structure
fixed printing circular structures
2015-04-07 12:36:11 +02:00
99907f94dc Updated ethereum.js 2015-04-07 12:33:05 +02:00
7b6a8cc9ae Fixed pending states 2015-04-07 12:32:55 +02:00
f4d4f1ccb2 Update bitcoin secp256k1 lib 2015-04-07 12:14:05 +02:00
b09d62bac7 fixed printing circular structures 2015-04-07 05:27:47 +02:00
9c55576c7b Block header changed & console miner control
* miner control moved to `admin.miner`
* miner option to set extra data
* block extra now bytes
2015-04-05 18:59:18 +02:00
3040296beb updated ethash. closes 646 2015-04-05 18:00:22 +02:00
736aefe9b5 time lapse 2015-04-05 17:59:38 +02:00
69ece747d3 v bump 2015-04-05 15:15:19 +02:00
01e1b49831 reflect ethash changes 2015-04-05 15:15:05 +02:00
09d3f2cf2a Update ethash 2015-04-05 15:14:55 +02:00
5b9a0e7118 Disabled PoW check
@zelig we need to discuss this
2015-04-05 15:14:06 +02:00
50edd4243e removed hash rate from info log. Added hashrate js func 2015-04-05 13:05:10 +02:00
ac473a8623 Remove debug log 2015-04-04 23:27:23 +02:00
053d5552ab Updated logging 2015-04-04 23:04:19 +02:00
5dc5e66986 set backtrace during runtime 2015-04-04 22:16:29 +02:00
d651ff968a Temp removed unrequested block error
@zelig look in to this please
2015-04-04 22:06:50 +02:00
f4af9e95c2 Skipping test
@zelig this will need updating with the TD checking
2015-04-04 21:41:42 +02:00
eb1c26746d Changed R S to big int and fixed tests 2015-04-04 21:41:24 +02:00
eb8f0b85f7 Changed R & S to *big.Int 2015-04-04 21:32:24 +02:00
59597d23a5 Reject integers w/ appended zero's 2015-04-04 21:29:23 +02:00
c39484bc4b Added thread safe each 2015-04-04 20:34:10 +02:00
5c988c8ea0 Increased test coverage for args 2015-04-04 11:58:23 -05:00
eff6a43419 Removed debugging 2015-04-04 18:29:11 +02:00
7a18a39351 prevent deadlock 2015-04-04 18:23:51 +02:00
f9488cb763 bumped version number 2015-04-04 16:41:12 +02:00
e1ed8c33bd Improved chain manager, improved block processor, fixed tests
* ChainManager allows cached future blocks for later processing
* BlockProcessor allows a 4 second window on future blocks
* Fixed tests
2015-04-04 16:35:23 +02:00
29f120206e Added block cache delete method 2015-04-04 16:33:12 +02:00
0d1a9ce648 Disabled peer TD check to support suspended blocks (Future blocks)
@zelig When blocks are in the future they'll be cached and processed at
a later time. Because of this the returned TD will be much lower than
the broadcasted TD.
2015-04-04 16:24:44 +02:00
435378e953 Improved test coverage for rpc types 2015-04-04 15:09:30 +02:00
71e62eb620 More test coverage for responses 2015-04-04 14:08:35 +02:00
c985ce4d78 Changed log to new logging 2015-04-04 13:41:58 +02:00
2683aac9b0 Make sure we're not mining on an invalid TS 2015-04-04 13:27:17 +02:00
2b9b9e7704 Allow "earliest" block height 2015-04-04 13:25:47 +02:00
4729826466 Merge branch 'develop' into rpcfabian 2015-04-04 13:24:21 +02:00
c20d04ca67 added verbosity to js admin 2015-04-04 13:24:19 +02:00
1889727144 Moved logging to logger.Core 2015-04-04 13:24:01 +02:00
218bfeb60e check for nil block (tmp).
@zelig this needs to be addressed in the block pool.
2015-04-04 12:40:48 +02:00
a0e44e3281 basic glog 2015-04-04 12:40:11 +02:00
60e097a5f4 Merge branch 'develop' into glog 2015-04-04 12:24:59 +02:00
bc5528b165 version bump 2015-04-03 17:49:33 +02:00
ec8a6e0a2b Merge branch 'develop' into glog 2015-04-03 17:19:22 +02:00
f9d94c7462 do not include BlockEqualTS as valid uncles 2015-04-03 17:19:09 +02:00
11d90d9b22 Merge branch 'develop' of github.com-obscure:ethereum/go-ethereum into develop 2015-04-03 17:09:21 +02:00
36452afd4e glog wip 2015-04-03 17:09:11 +02:00
47feff3611 Merge pull request #627 from ethersphere/frontier/blockpool
Frontier/blockpool BUGFIX
2015-04-03 13:56:39 +02:00
4558e04c0d Merge commit 'f6bd4b16e38f9cacd57b57befdeeaed789a473c4' into develop 2015-04-03 12:29:13 +02:00
f6bd4b16e3 Squashed 'tests/files/' changes from d6fe94a..3ebf646
3ebf646 Merge remote-tracking branch 'origin/develop' into develop
0ecbe27 uncle with same block number as current block

git-subtree-dir: tests/files
git-subtree-split: 3ebf64619911a7cbdec3b70491284c4cd5f4c3a3
2015-04-03 12:29:13 +02:00
f49e398ebe bool => int 2015-04-03 12:28:55 +02:00
a6ca3d0261 Merge pull request #626 from tgerring/rpcfabian
RPC Tests updates
2015-04-03 11:58:18 +02:00
29a9c6bedd Merge branch 'develop' of github.com-obscure:ethereum/go-ethereum into develop 2015-04-03 11:28:32 +02:00
c59c826ab4 fixed stack level 2015-04-03 11:27:56 +02:00
812cbff1a2 Squashed 'tests/files/' changes from ab81bf2..d6fe94a
d6fe94a Merge branch 'develop' of https://github.com/ethereum/tests into develop
cae0693 more fuzz test failures
2110806 fix mem test
049c4d3 Merge remote-tracking branch 'origin' into develop
6025e7b stack size 1024 fix
97655c7 add JS fails
90fe120 JS fails
e8a6964 JS fail

git-subtree-dir: tests/files
git-subtree-split: d6fe94ad047557531c83b551eb78a7a5838feaa4
2015-04-03 10:50:18 +02:00
fd5c5b2969 Merge commit '812cbff1a28d89b44a0c8c5a210ac61c7e19da35' into develop 2015-04-03 10:50:18 +02:00
4415a5bc68 updated coin 2015-04-03 10:50:07 +02:00
ea606733eb Merge pull request #636 from debris/prototype_functions
do not print Plain Object prototype fields in geth console
2015-04-03 01:53:55 +02:00
24c8fdc1d0 do not print Plain Object prototype fields in geth console 2015-04-03 01:47:05 +02:00
97d6b0bab8 Merge pull request #633 from debris/prototype_functions
printing object prototype functions in geth console
2015-04-03 01:29:53 +02:00
1f122626be printing object prototype functions in geth console 2015-04-03 00:49:18 +02:00
3e042317ad Return nil if block does not exist 2015-04-02 20:37:51 +02:00
1d74086b42 New UncleRes type 2015-04-02 17:55:42 +02:00
5cb1b41440 proper locking to prevent "parent unknown" INVALID blocks due to race in peer head info update 2015-04-02 16:30:48 +01:00
dd1791c9fd proper locking to prevent close of closed channel crash when multiple mining peers compete 2015-04-02 15:32:41 +01:00
9bdf0b655d Fix RLP decoding of tx metadata 2015-04-02 16:28:42 +02:00
537e2cfeb6 Return nil when requested uncle index is not valid 2015-04-02 16:12:19 +02:00
e882ba0c29 Return nil when requested index does not exist
Instead of error
2015-04-02 16:11:00 +02:00
aa71e27a3b Detect non-valid strings for blockheight 2015-04-02 15:53:04 +02:00
3908590578 Make "To" field optional in whisper filter 2015-04-02 15:37:35 +02:00
607fc788e3 Merge pull request #619 from tgerring/rpcfabian
RPC Fabian fixes
2015-04-02 15:13:30 +02:00
876ce0fb12 More nil checks 2015-04-02 14:54:28 +02:00
172b34351a HashArgs fix + tests 2015-04-02 14:49:33 +02:00
b9c9d6d798 Use HashArgs for eth_getTransactionByHash 2015-04-02 14:37:11 +02:00
b4eef59b6f No longer require gas & gas price in transactions
Defaults to 0, which is then set to default values in XEth
2015-04-02 14:05:14 +02:00
1e28b424e7 Default gas 2015-04-02 14:00:49 +02:00
015453f5b3 Default Value to 0 for NewTxArgs 2015-04-02 13:55:53 +02:00
55b1c1546b Moved to function 2015-04-02 13:55:35 +02:00
118ad22ee5 Merge branch 'develop' into rpcfabian 2015-04-02 13:39:46 +02:00
81de8ed091 Format code as hexdata 2015-04-02 13:38:12 +02:00
b86450aaae Guard from nil pointers 2015-04-02 13:27:58 +02:00
e402e1dc2e New args types with stricter checking 2015-04-02 13:17:55 +02:00
79828531b1 updated ethereum.js 2015-04-02 13:13:11 +02:00
14c14fd61f Output empty block as nil 2015-04-02 13:05:13 +02:00
2efb89d544 Guard for nil *big.Int 2015-04-02 13:04:58 +02:00
60da9a1289 Put the old hammer back in <3 2015-04-02 13:03:33 +02:00
3f4c1aaf01 info => debug 2015-04-02 12:58:17 +02:00
0f3bf7ef4d Fixes for balance 2015-04-02 12:57:04 +02:00
585aec127c Don't ignore user-specified "include tx" param 2015-04-02 12:56:36 +02:00
edfd2757d9 Better decoding of uint* 2015-04-02 12:52:25 +02:00
b10e33c040 More types supported 2015-04-02 12:31:10 +02:00
cc45b4d8b5 Trim left only, not right 2015-04-02 12:30:42 +02:00
f89baa73e5 transactionRoot -> transactionsRoot 2015-04-02 12:30:22 +02:00
85ebbc9aa5 Default BlockNumber to -1 when missing 2015-04-02 11:57:26 +02:00
7e13ee602e Merge pull request #625 from debris/nonenumerable
print nonenumerable properties of object in geth console && proper printing BigNumbers
2015-04-02 11:35:01 +02:00
c71ca1a089 Better nil handling 2015-04-02 11:32:50 +02:00
f960fc066e fixed printing BigNumbers 2015-04-02 11:02:39 +02:00
bb3ae3026e print nonenumerable properties of object in geth console 2015-04-02 01:53:33 +02:00
b8124ec791 Removed old (unused) argument 2015-04-01 23:58:26 +02:00
219d94c1dd Merge pull request #623 from Gustav-Simonsson/read_protocol_values_from_common_params
Read most protocol params from common/params.json
2015-04-01 23:37:17 +02:00
c26c8d3a44 Read most protocol params from common/params.json
* Add params package with exported variables generated from
  github.com/ethereum/common/blob/master/params.json
* Use params package variables in applicable places
* Add check for minimum gas limit in validation of block's gas limit
* Remove common/params.json from go-ethereum to avoid
  outdated version of it
2015-04-02 06:22:32 +02:00
ab5c007376 Updated ethereum.js 2015-04-01 23:28:45 +02:00
4391c38215 Changed getters on account objects. Closes #610
* GetCode
* GetNonce
* GetStorage
* GetBalance
2015-04-01 23:22:16 +02:00
5d8be9c30d Fixed decoding for uint64 into bytes 2015-04-01 23:08:00 +02:00
344b3556eb Fixed uncle rewards in miner
The uncle rewards were changed in the block processor. This change will
reflect those changes in the miner as well.
2015-04-01 21:18:41 +02:00
516ec28544 sha3 stack check 2015-04-01 17:51:22 +02:00
4e3ffbcf9b Squashed 'tests/files/' changes from 5f8a010..ab81bf2
ab81bf2 go fail

git-subtree-dir: tests/files
git-subtree-split: ab81bf28d6157657b0a1c0d598785f1ed23fdbb1
2015-04-01 17:50:19 +02:00
109b27b552 Merge commit '4e3ffbcf9bae7e44e45fd1b6e504b3645040d73c' into develop 2015-04-01 17:50:19 +02:00
eac4d582d7 Patches 2015-04-01 17:49:22 +02:00
1045015a3c Update nonce field 2015-04-01 17:48:53 +02:00
96cf776f81 Check stack for BALANCE. Closes #622 2015-04-01 17:45:38 +02:00
f801183b8b Squashed 'tests/files/' changes from 29da5ea..5f8a010
5f8a010 go fials
6f7924a add cppjit fail
c21f368 update genesis test
de7266b update js example test

git-subtree-dir: tests/files
git-subtree-split: 5f8a0103c0456f9467b402fde3db4bcde345d53b
2015-04-01 17:41:58 +02:00
516423cdac Merge commit 'f801183b8bea24ce9988fbd06c2f17fedfc3587f' into develop 2015-04-01 17:41:58 +02:00
216ea425e4 corrected 2015-04-01 17:36:56 +02:00
8e961df283 bumped network protocol 2015-04-01 17:10:42 +02:00
fd171eff7f Merge pull request #592 from fjl/disco-ping-pong
Discovery bonding protocol
2015-04-01 17:10:10 +02:00
76218959ab eth: update cpp bootnode address 2015-04-01 17:00:12 +02:00
a77c431e37 p2p/discover: fix off by one error causing buckets to contain duplicates 2015-04-01 17:00:12 +02:00
de7af720d6 p2p/discover: implement node bonding
This a fix for an attack vector where the discovery protocol could be
used to amplify traffic in a DDOS attack. A malicious actor would send a
findnode request with the IP address and UDP port of the target as the
source address. The recipient of the findnode packet would then send a
neighbors packet (which is 16x the size of findnode) to the victim.

Our solution is to require a 'bond' with the sender of findnode. If no
bond exists, the findnode packet is not processed. A bond between nodes
α and β is created when α replies to a ping from β.

This (initial) version of the bonding implementation might still be
vulnerable against replay attacks during the expiration time window.
We will add stricter source address validation later.
2015-04-01 17:00:12 +02:00
b6f0b40037 Respect fullTx option #614 2015-04-01 16:49:07 +02:00
55b9689950 rename messages to types 2015-04-01 15:53:48 +02:00
92928309b2 p2p/discover: add version number to ping packet
The primary motivation for doing this right now is that old PoC 8
nodes and newer PoC 9 nodes keep discovering each other, causing
handshake failures.
2015-04-01 15:53:04 +02:00
bea3879d6f If nil, type doesn't matter 2015-04-01 15:45:56 +02:00
ac03ff6f05 Fix block size output #613 2015-04-01 15:44:09 +02:00
6e8ff578f1 Block nonce as data 2015-04-01 15:28:06 +02:00
93f832a1a7 Make block context optional nulls 2015-04-01 15:27:37 +02:00
0ce971d9d3 Add new formatting regex 2015-04-01 15:27:14 +02:00
101ea1a1e8 Make inner size before assinging. Closes #615 2015-04-01 14:15:20 +02:00
c8e5d53a39 Merge pull request #618 from tgerring/issue613
Issue #613
2015-04-01 13:57:35 +02:00
4a4da9a24e Merge pull request #588 from ethersphere/frontier/SEC-29
Frontier/sec 29
2015-04-01 13:55:42 +02:00
f56fc9cd9d change StatusMsgData.TD back to pointer type *big.Int 2015-04-01 12:36:49 +01:00
6ffea34d8b check TxMsg
- add validation on TxMsg checking for nil
- add test for nil transaction
- add test for zero value transaction (no extra validation needed)
2015-04-01 12:32:42 +01:00
82da6bf4d2 test for invalid rlp encoding of block in BlocksMsg
- rename Validate -> ValidateFields not to confure consensus block validation
- add nil transaction and nil uncle header validation
- remove bigint field checks: rlp already decodes *big.Int to big.NewInt(0)
- add test for nil header, nil transaction
2015-04-01 12:32:42 +01:00
d677190f39 add tests for valid blocks msg handling 2015-04-01 12:32:42 +01:00
e1be34bce1 eth: SEC-29 eth wire protocol decoding invalid message data crashes client
- add validate method to types.Block
- validate after Decode -> error
- add tests for NewBlockMsg
2015-04-01 12:32:42 +01:00
936ddf2ad1 Merge pull request #616 from bas-vk/develop
Frontier/513
2015-04-01 13:25:15 +02:00
dbf17105f6 Build transaction context in BlockRes 2015-04-01 13:18:51 +02:00
88f2a96ca3 Set fullTx option in constructor 2015-04-01 13:18:30 +02:00
1559bd9e1b changed big.Int instantiation 2015-04-01 13:15:21 +02:00
dba9b83aa0 Merge branch 'tgerring-hexify' into develop 2015-04-01 12:51:44 +02:00
b0e09ec827 merge conflict 2015-04-01 12:51:39 +02:00
6afc5e762a Merge branch 'hexify' of https://github.com/tgerring/go-ethereum into tgerring-hexify 2015-04-01 12:49:10 +02:00
720d978e35 Merge pull request #589 from tgerring/corssetting
Configurable CORS domain
2015-04-01 12:38:29 +02:00
6605d00d92 Frontier/513 2015-04-01 12:33:12 +02:00
02fb83782e #612 rename eth_protocol method 2015-04-01 12:28:48 +02:00
86ba7432a9 txMeta storage as struct 2015-04-01 12:14:35 +02:00
4e8f8cfab7 ethereum.js update 2015-04-01 11:51:05 +02:00
f2c6a937f3 Protocol bump 2015-04-01 11:50:19 +02:00
b860b67693 Remove extra type assetion 2015-04-01 11:45:29 +02:00
f468364e4d fixed tests 2015-04-01 11:42:02 +02:00
7b7392826d Improved response tests
Actually verifies output as by regex
2015-04-01 11:38:06 +02:00
0a554a1f27 Blocktest fixed, Execution fixed
* Added new CreateAccount method which properly overwrites previous
  accounts (excluding balance)
* Fixed block tests (100% success)
2015-04-01 10:53:32 +02:00
d3e86f9208 Added gas generator defaults 2015-04-01 10:51:46 +02:00
25998cfc45 Re-enabled response tests (needs improvement) 2015-04-01 09:11:23 +02:00
bbca6250ff Merge branch 'rpccall' into hexify 2015-03-31 22:40:52 +02:00
40ea466200 Store and retrieve tx context metadata #608
Improving this in the future will allow for cleaning up a bit of legacy
code.
2015-03-31 22:40:12 +02:00
7e3875b527 Remove custom MarshalJSON methods
Now formats based on underlying hexdata or hexnum type. Fields directly
with respective constructors that cover from native types
2015-03-31 19:04:02 +02:00
a2501ecfcd Make new types Stringers 2015-03-31 19:02:46 +02:00
8f0e095f4c Index is zero-based #607 2015-03-31 17:56:06 +02:00
81aeb78976 Update output types to use hexnum or hexdata
Benefits from automatic output formatting differences between
quantities and data
2015-03-31 17:40:35 +02:00
3a948b2dba Add hexdata and hexnum types 2015-03-31 17:39:58 +02:00
ec181b308a Squashed 'tests/files/' changes from c6d9629..29da5ea
29da5ea add JS block test example as state test
04108e0 Merge remote-tracking branch 'origin' into develop
6da7f35 JS failures
22b5dfc stQuadraticComplexity Refill with latest develop
c97bf26 Memory / Solidity Test Update

git-subtree-dir: tests/files
git-subtree-split: 29da5ea53ab36d74bd3c0712337168086cabfb8d
2015-03-31 16:25:22 +02:00
2ef0bc03ec Merge commit 'ec181b308addc30c04973e9058960d579c84eef5' into develop 2015-03-31 16:25:22 +02:00
8b51582b53 Merge branch 'develop' of github.com-obscure:ethereum/go-ethereum into develop 2015-03-31 15:31:32 +02:00
3453f8c5d2 Added Code field 2015-03-31 15:30:55 +02:00
653c3deaa5 Merge pull request #606 from tgerring/bootnode
Update Go bootnode address
2015-03-31 14:41:17 +02:00
6daa455243 Update Go bootnode address 2015-03-31 14:14:29 +02:00
485dcf90cd Merge pull request #594 from Gustav-Simonsson/fix_block_header_gas_limit_validation
Correct gas limit validation according to new algorithm
2015-03-31 12:41:05 +02:00
2f3a968136 New CallArgs
Requirements for calls differ from transactions
2015-03-30 16:20:30 +02:00
9feed3f61e Correct gas limit validation according to new algorithm
* Use absolute value of (block's gas limit) - (parent's gas limit)
  in comparison with diff limit.
* Ensure the diff is strictly smaller than the allowed size.
2015-03-30 16:07:24 +02:00
f23529c5cd General repo cleanup 2015-03-30 09:18:22 +02:00
35d00e00c5 Update Godeps 2015-03-29 22:19:38 +02:00
b6fde73ef1 Add settable domain to CORS handler #331 2015-03-29 21:56:04 +02:00
04a7c4ae1e Abstract http into rpc package
New RpcConfig object to pass growing config
2015-03-29 21:26:47 +02:00
24fc1f073d Add flag to control CORS header #394
* Disabled on CLI
* http://localhost on Mist
2015-03-29 21:21:14 +02:00
e1c6c01b4d Merge branch 'develop' of github.com-obscure:ethereum/go-ethereum into develop 2015-03-29 15:03:39 +02:00
b7a0bc7031 Merge branch 'ebuchman-fix_ecrecover' into develop 2015-03-29 15:03:30 +02:00
61c5edcb57 Cleanup. 2015-03-29 15:02:49 +02:00
af153e7884 Merge branch 'fix_ecrecover' of https://github.com/ebuchman/go-ethereum into ebuchman-fix_ecrecover 2015-03-29 13:34:41 +02:00
391d79ef44 Add ExtraData field to RPC output 2015-03-29 12:08:52 +02:00
eb79938060 Docker rename ethereum to geth 2015-03-28 22:17:08 +01:00
2ca6a800ad Remove old go cover location 2015-03-28 22:16:04 +01:00
82eeb5e02a Added Coveralls badges 2015-03-28 22:04:36 +01:00
129fabddb2 Prefer hex prefixed with 0x 2015-03-28 21:47:16 +01:00
d9f8b1e0c1 Report InvalidTypeError as -32602 to JSON RPC 2015-03-28 21:42:44 +01:00
e80ef9ff34 Cleanup 2015-03-28 21:41:34 +01:00
29930da522 eth_getStorageAt output hex should begin with 0x 2015-03-28 21:27:50 +01:00
3b20603eb1 Merge branch 'kobigurk-develop' into develop 2015-03-28 21:06:39 +01:00
779a51c047 Merge branch 'develop' of https://github.com/kobigurk/go-ethereum into kobigurk-develop
Conflicts:
	rpc/api.go
2015-03-28 21:05:32 +01:00
b9ca5eef58 Merge pull request #579 from tgerring/rpcargs
RPC Args
2015-03-28 20:42:45 +01:00
696ff43db3 Merge branch 'develop' of github.com-obscure:ethereum/go-ethereum into develop 2015-03-28 20:34:12 +01:00
368ebe63a9 Cleanup VM.
* CALLDATA use getData
* removed old context get range value
* removed casting big => int for some cases
* pc now big int #457
2015-03-28 20:30:38 +01:00
3b7e4173ce Cleanup VM 2015-03-28 20:03:25 +01:00
2455e0bd18 Merge pull request #585 from aperseghin/patch-2
Minor fix
2015-03-28 11:54:20 +01:00
ed6ca5d007 Merge pull request #586 from aperseghin/patch-3
Update README.md
2015-03-28 11:54:10 +01:00
a4cbd1c7be ethereum -> geth 2015-03-28 00:32:23 +01:00
47af2f02cb eth_getTransactionCount now returns a hex string 2015-03-27 22:22:13 +03:00
3ea8c7301e PUSH gas fix 2015-03-27 16:53:05 +01:00
43d521e90e Decouple core from rpc 2015-03-27 16:36:01 +01:00
df648cbc60 Removed comments 2015-03-27 16:11:19 +01:00
8a22cd5e6c Removed defer/panic. #503 2015-03-27 16:09:57 +01:00
0ac346f707 Merge branch 'develop' into rpcargs 2015-03-27 16:03:49 +01:00
9f84c78eb5 BlockFilterArgs 2015-03-27 15:54:54 +01:00
db1c52918f Update README.md 2015-03-27 09:29:35 -04:00
00f8319faf Explicitly check memory's data store. #515 2015-03-27 14:22:38 +01:00
8e7549db0b Minor fix 2015-03-27 08:38:20 -04:00
eb102bf4bb Etherbase => etherbase 2015-03-27 12:14:00 +01:00
86c43d97bc Merge pull request #581 from aperseghin/patch-1
Update README.md
2015-03-27 12:12:38 +01:00
0b4b2b81f9 Merge pull request #580 from ethersphere/frontier/cli-key
settable etherbase
2015-03-27 12:12:05 +01:00
54a14d5c9d Merge pull request #584 from tgerring/issue577
Use ExtraDB for RPC storage. Fixes #577
2015-03-27 11:48:03 +01:00
09280c5f11 Merge pull request #565 from tgerring/responsetypes
Update response types + tests
2015-03-27 11:44:13 +01:00
2788fb4ce5 More explicit formatting for protocol version 2015-03-27 11:43:14 +01:00
e29396b691 Use ExtraDB for storage. Fixes #577 2015-03-27 09:36:18 +01:00
c38630af23 Test blockHeightFromJsonInvalid 2015-03-27 00:13:03 +01:00
e0781c2548 NewTxArgs accept numbers or strings for value/gas/gasprice 2015-03-27 00:07:28 +01:00
3fcef54f9b tidy 2015-03-26 22:58:12 +01:00
b375bbee5f settable etherbase
- etherbase flag for block reward destination
- coinbase => etherbase
- CLI- eth Config -> eth, xeth -> RPC / Miner
- use primary instead of coinbase as the unlock magic wildcard
- accounts: firstAddr/Coinbase -> Primary
2015-03-26 21:52:22 +00:00
5838847a9a Update README.md
Rename ethereum executable to geth
2015-03-26 17:48:24 -04:00
6bd1f6cc49 Merge remote-tracking branch 'origin' into rpcargs
Conflicts:
	rpc/args.go
2015-03-26 22:42:46 +01:00
bb12dbe233 Prefer args as strings not objects 2015-03-26 22:35:42 +01:00
7eed7e1d96 Merge branch 'rpcargs' of github.com:tgerring/go-ethereum into rpcargs 2015-03-26 22:27:06 +01:00
2c5a32ebbc Undo XEth changes 2015-03-26 22:24:48 +01:00
49a912ce33 Undo xeth changes 2015-03-26 22:14:31 +01:00
b0b0939879 renamed ethereum => geth 2015-03-26 21:27:52 +01:00
829240c325 Merge pull request #550 from ethersphere/frontier/cli-key
import/export accounts
2015-03-26 21:08:15 +01:00
1f3814141b WhisperMessageArgs 2015-03-26 21:07:50 +01:00
9ca87afd0b WhisperFilterArgs 2015-03-26 20:52:09 +01:00
81f36df910 CompileArgs 2015-03-26 20:31:00 +01:00
ddcc8e1673 SubmitWorkArgs tests 2015-03-26 20:25:30 +01:00
b414a1303f WhisperIdentityArgs 2015-03-26 20:20:43 +01:00
1f1e98f96b FilterIdArgs 2015-03-26 20:10:31 +01:00
62ebf999bf FilterStringArgs tests 2015-03-26 20:04:03 +01:00
7577d12614 max paranoia mode to UNsupport unencrypted keys entirely
- remove account export functionality from CLI
- remove accountExport method,
- remove unencrypted-keys flag from everywhere
- improve documentation
2015-03-26 19:00:18 +00:00
abbdf41560 output error message if unlock address is invalid (fixes the wierd "read /path: is a directory") msg 2015-03-26 19:00:18 +00:00
11d2ebc06f unlocking coinbase without knowing address
- accounts: remove Manager.getKey
- cli: for -unlock coinbase, use account manager Coinbase()
2015-03-26 19:00:18 +00:00
4ec38e3932 common: remove WriteFile and ReadAllFile (use ioutil instead) 2015-03-26 19:00:18 +00:00
23e41a57ad Applying: fix adming js test regression (maybe otto update?) 2015-03-26 19:00:18 +00:00
fee224f075 cli test: fix test newJSRE interactive argument 2015-03-26 19:00:18 +00:00
d1b52efdb5 cli: implement ethereum presale wallet import via cli 2015-03-26 19:00:18 +00:00
34d5a6c156 cli: help formatting 2015-03-26 19:00:18 +00:00
1c4c71dcff cli: fix liner not closing (spuriously opened) in noninteractive jsre 2015-03-26 19:00:18 +00:00
fd8d18ec28 unlocking coinbase
- extract accounts.getKey method - if given empty address it retrieves coinbase (first account)
- cli -unlock coinbase will unlock coinbase
2015-03-26 19:00:18 +00:00
859f1f08ca blockpool: wrap intermittent status test in a loop 2015-03-26 19:00:18 +00:00
c4ea921876 import/export accounts
- cli: add passwordfile flag
- cli: change unlock flag only takes account
- cli: with unlock you are prompted for password or use passfile with password flag
- cli: unlockAccount used in normal client start (run) and accountExport
- cli: getPassword used in accountCreate and accountImport
- accounts: Manager.Import, Manager.Export
- crypto: SaveECDSA (to complement LoadECDSA) to save to file
- crypto: NewKeyFromECDSA added (used in accountImport and New = generated constructor)
2015-03-26 19:00:18 +00:00
e21ce9a9b4 DbHexArgs tests 2015-03-26 19:39:40 +01:00
f68ca2b6e6 DbArgs tests 2015-03-26 19:34:32 +01:00
3ab9f26943 Accept number or string for BlockFilterArgs limit/offset 2015-03-26 19:17:25 +01:00
658204bafc bump 2015-03-26 17:55:30 +01:00
c32bca45ad Stack limit 2015-03-26 17:45:09 +01:00
d36501a6e5 Fixed miner
* Miners could stall because the worker wasn't aware the miner was done
2015-03-26 17:45:03 +01:00
6661bc35ef Accept number or string for BlockFilterArgs to/fromBlock 2015-03-26 17:27:29 +01:00
745dd5b7a5 Sha3Args 2015-03-26 16:19:33 +01:00
f695d01354 Convert error checks to Expect functions 2015-03-26 16:16:17 +01:00
3472823be9 HashIndexArgs 2015-03-26 14:17:32 +01:00
cb103c089a BlockNumIndexArgs 2015-03-26 13:57:41 +01:00
cd6b3fd28a GetDataArgs 2015-03-26 13:50:22 +01:00
a49c81547c DecodeParamError -> InvalidTypeError for unexpected input type 2015-03-26 13:45:06 +01:00
ca03e97697 Add InvalidTypeError 2015-03-26 13:33:44 +01:00
a718515b3d Squashed 'tests/files/' changes from a7081bc..c6d9629
c6d9629 added another test

git-subtree-dir: tests/files
git-subtree-split: c6d96293710a37489fa3b074a9fc228e0393f152
2015-03-26 13:14:24 +01:00
d0fa0a234d Merge commit 'a718515b3d43f00497231f981b5ea757b71d55ff' into develop 2015-03-26 13:14:24 +01:00
c139af5826 GetBalanceArgs 2015-03-26 13:10:31 +01:00
4523a00b91 GetTxCountArgs 2015-03-26 12:47:00 +01:00
c33dc3e328 moved helper 2015-03-26 12:40:09 +01:00
83b0cad766 fixed block filter args 2015-03-26 12:34:59 +01:00
b8a667deed debug log 2015-03-26 12:15:25 +01:00
4ba850639e updated web3.js light for console 2015-03-26 12:15:12 +01:00
9c4504dc41 GetStorageAtArgs 2015-03-26 12:11:28 +01:00
ace5b5a1bf updated web3.js 2015-03-26 12:06:45 +01:00
507830eb81 Merge branch 'develop' of github.com-obscure:ethereum/go-ethereum into develop 2015-03-26 12:06:23 +01:00
eb433731aa Fixed filter and refactored code 2015-03-26 12:06:14 +01:00
300d36b864 improved NewTxArgs tests 2015-03-26 11:59:35 +01:00
ad2089b0a3 Add blockHeightFromJson convenience function 2015-03-26 11:59:16 +01:00
493e0d7be8 improved GetBlockByNumber tests 2015-03-26 11:07:14 +01:00
93af30a6f6 improved GetBlockByHashArgs tests 2015-03-26 11:06:45 +01:00
bd1a54f076 GetStorageArgs 2015-03-26 10:52:32 +01:00
966cfa4bdd NewTxArgs 2015-03-26 10:34:21 +01:00
c7dc379da5 GetBlockByHashArgs 2015-03-26 10:14:52 +01:00
7e1e264375 Don't return empty block for "pending" #568 2015-03-26 09:24:07 +01:00
98f970ba59 Updated example for new ethereum.js 2015-03-26 01:03:14 +01:00
88b9bc40d7 Godep issue? 2015-03-26 01:03:03 +01:00
e5a0a0ef48 Moved output to debug 2015-03-26 01:02:51 +01:00
7e4c488717 Fixed storage. Closes #516 2015-03-26 00:42:35 +01:00
505f1fbcbb added tx tests and fixed block tests 2015-03-25 17:05:29 +01:00
65ea55bccd Merge pull request #564 from fjl/rlp-nil-array
rlp: encode nil array pointers as empty list or string
2015-03-25 17:00:25 +01:00
e22bcb78a5 Update response types + tests
To coincide with recent type conversion
2015-03-25 16:50:30 +01:00
181a21c67c rlp: encode nil array pointers as empty list or string 2015-03-25 16:46:29 +01:00
ff5578fc71 updated ethash 2015-03-25 14:58:12 +01:00
a2e3bf6f30 removed big num from pp 2015-03-25 14:51:10 +01:00
aa1eae67ec Merge pull request #560 from tgerring/xethcleanup
XEth cleanup
2015-03-25 13:55:46 +01:00
7f0c2545a9 Merge pull request #561 from ethersphere/frontier/blockpool
bugfix with idle too long triggered after peer switch
2015-03-25 13:55:05 +01:00
221f30c3aa updated ethereum.js 2015-03-25 13:52:45 +01:00
8b32f79445 Removed full path 2015-03-25 13:52:23 +01:00
950b4a68c8 Improved miner recovery
* In case of uncle mining (e.g. same TS) the miner would stop if all
  threads happened to mine a potential uncle
2015-03-25 13:51:12 +01:00
18d1569ce5 header check for test 2015-03-25 12:11:29 +00:00
9d592c0445 bugfix with idle too long triggered after peer switch
- reset bestIdleTimer when launching head section process
- log chain head events
- common.Hash key in activateChain map
2015-03-25 12:11:29 +00:00
a1cae93d78 Improved pretty printer for console 2015-03-25 12:44:41 +01:00
2b93843d86 Improve protocol version reporting 2015-03-25 12:09:55 +01:00
c956bcb13c Move version to const and expose via Version() 2015-03-25 12:08:48 +01:00
6431d088ad bump 2015-03-25 11:54:11 +01:00
ff44347ea1 fixed test 2015-03-25 10:31:58 +01:00
dda1d60556 Store protocol version in the block db **NOT** extra db 2015-03-25 09:58:46 +01:00
3301f6ecef back to debug log 2015-03-24 23:55:48 +01:00
97bf9f1521 Temp fix for console output 2015-03-24 23:50:27 +01:00
3d5f48a160 updated deps 2015-03-24 21:25:11 +01:00
a6e659f74b Merge branch 'master' of github.com-obscure:ethereum/go-ethereum into develop 2015-03-24 19:22:32 +01:00
a33a325ac1 Merge pull request #559 from Gustav-Simonsson/blocktests_update_ethash
Update ethash lib
2015-03-24 19:14:20 +01:00
d41341f77d WithState -> withState 2015-03-24 17:58:16 +01:00
82b5a8af49 DRY up height logic 2015-03-24 17:49:37 +01:00
c38a3b4cc7 Better error reporting in the console. Updated ethereum.js 2015-03-24 17:49:28 +01:00
865f31018b Shuffle 2015-03-24 17:45:31 +01:00
2106a63d60 Move Frontend interface to separate file 2015-03-24 16:42:33 +01:00
65d553d367 Update internal calls to use CurrentBlock() 2015-03-24 16:34:28 +01:00
59b6b619a2 Don't expose backend directly 2015-03-24 16:33:37 +01:00
b9b7442b74 Remove redundant fields 2015-03-24 16:08:18 +01:00
ad420d099a rename eth to backend 2015-03-24 16:01:44 +01:00
b0c4dc8df8 Update ethash lib 2015-03-24 15:51:51 +01:00
6d41402dce Backend no longer needed to resolve import cycle 2015-03-24 15:36:39 +01:00
9de1ad6546 fixed tests 2015-03-24 15:27:05 +01:00
ff9d66e096 Cleaned up changes 2015-03-24 15:23:16 +01:00
23bccbbc58 Modified according to poc 9 changes
* Refund of value
2015-03-24 15:15:17 +01:00
bbe795455a Secure trie shakey / key matching 2015-03-24 15:14:03 +01:00
24066dca46 Squashed 'tests/files/' changes from 8f3fbe6..a7081bc
a7081bc update tests
d2678cb update random tests
ca0401b update tests

git-subtree-dir: tests/files
git-subtree-split: a7081bc54e9d72cc480218cb4b218dbb04c7cde7
2015-03-24 13:39:49 +01:00
d6da533345 Merge commit '24066dca4646c8a376aa5dfbceec0a4b3f872c11' into develop 2015-03-24 13:39:49 +01:00
0ec171ccdf Copy fix 2015-03-24 13:38:16 +01:00
eab8f7355d Event fixes for miner 2015-03-24 13:37:38 +01:00
576df064e5 Updated for PV59
* Value XFER are refunded back to the sender if the execution fails
2015-03-24 11:49:30 +01:00
58c6cc8fd7 Squashed 'tests/files/' changes from 559268b..8f3fbe6
8f3fbe6 Pv59 changes
2633cce JS fails
748f803 Merge remote-tracking branch 'origin' into develop
2e60a20 JS failure
2673f14 Incorrect Test deletion
345261d More Transaction Tests
300998f add blockchain tests - uncle gen 0 - in-chain-uncle
7e8585a gas counter overflow
5af1002 check overflow of v value in tx tests
53ee775 memory stress tests 28
46045b7 add 1024 stack size tests
4678ee8 add 1024 stack size limit tests
3b870f6 rm test
7c51854 fix test
74f1e91 cpp fail
ce9535a add cppjit fail
2e17a2e SDIV tests
cd38e05 first JS failures
d5e80d5 Delete st201503181858GO.json

git-subtree-dir: tests/files
git-subtree-split: 8f3fbe63f92c413fda1fc68cf27a9dbb69681168
2015-03-24 11:22:58 +01:00
4877e52c15 Merge commit '58c6cc8fd7ff8a27004ed62d912e0a61ae1b73bb' into develop 2015-03-24 11:22:58 +01:00
118b79eca7 Added gitter integration for travis 2015-03-24 10:41:04 +01:00
a59ea7ce29 Changed miner
* Instead of delivering `Work` to the `Worker`, push a complete Block to
  the `Worker` so that each agent can work on their own block.
2015-03-24 10:34:06 +01:00
d8e21b39b3 Added copy function 2015-03-24 10:33:00 +01:00
0ee0094cc0 better block propagation 2015-03-23 22:59:19 +01:00
7b8a47f484 removed legacy code 2015-03-23 22:05:12 +01:00
0eaa023ffa Merge branch 'develop' of github.com-obscure:ethereum/go-ethereum into develop 2015-03-23 21:48:50 +01:00
bfb9ed881d Gas validation and clean up of legacy code 2015-03-23 21:48:45 +01:00
ebf4408d73 Decrement depth 2015-03-23 21:48:31 +01:00
e88a29ad02 Merge pull request #553 from ethersphere/jsonlog
natspec: minor fix in test
2015-03-23 18:57:57 +01:00
53af810851 natspec: minor fix in test 2015-03-23 17:36:04 +00:00
f2f65c1a65 Merge branch 'develop' of github.com-obscure:ethereum/go-ethereum into develop 2015-03-23 18:30:11 +01:00
90c710fd26 Merge pull request #552 from ethersphere/jsonlog
Jsonlog
2015-03-23 18:27:06 +01:00
c8e9ca0483 fixed bad uncles 2015-03-23 18:27:05 +01:00
a983a215dc fix ethtest logging 2015-03-23 17:08:49 +00:00
e954c24af0 Implement RPC net_version 2015-03-23 18:06:05 +01:00
60020add74 Merge pull request #551 from ethersphere/frontier/eth-version-exports
eth: fix protocol version/network id copied from config to Ethereum field
2015-03-23 18:00:54 +01:00
1cf6ca8f10 Add Close() method to EthereumApi
To close the handler for LDB
2015-03-23 17:41:50 +01:00
9880f99ccb fix p2p/testlog_test 2015-03-23 16:41:41 +00:00
1e61b75cbf tests + fixes 2015-03-23 17:33:01 +01:00
03cc5df9b7 eth: fix protocol version/network id copied from config to Ethereum field 2015-03-23 16:23:06 +00:00
0330077d76 moved state and vm to core 2015-03-23 16:59:09 +01:00
d7eaa97a29 moved to error 2015-03-23 16:55:40 +01:00
211cb03f83 Merge branch 'develop' of github.com-obscure:ethereum/go-ethereum into develop 2015-03-23 16:47:05 +01:00
9562a9840f Merge pull request #537 from Gustav-Simonsson/blocktests2
Add post state validation to block tests and disable network, add RPC
2015-03-23 16:39:26 +01:00
5707912e2f "pending" convention should be -2 instead of 0 2015-03-23 16:36:12 +01:00
253ecdc8bb Merge branch 'develop' of github.com-obscure:ethereum/go-ethereum into develop 2015-03-23 16:35:49 +01:00
9be7853e34 Fixed issues with stalled remote miner 2015-03-23 16:35:44 +01:00
2f8601ef38 Rename blockAge to blockHeight 2015-03-23 16:34:50 +01:00
becc503230 Correct difficulty calculation to use new difficulty minimum 2015-03-23 16:32:20 +01:00
5d31a475e9 Fix new types for blocktests and comment out non-working log level setter 2015-03-23 16:32:20 +01:00
60de4d6dd1 gofmt 2015-03-23 16:32:20 +01:00
08bb472c91 Add validation of post state accounts to block tests 2015-03-23 16:32:20 +01:00
33c5186fd0 In blocktest cmd, disable network and add RPC flag 2015-03-23 16:32:20 +01:00
dc3a9379f5 logging for possible uncles 2015-03-23 16:14:33 +01:00
3f6e1b2fd3 db_putHex/db_getHex + tests 2015-03-23 16:04:21 +01:00
524f8199bf added some nil checks for cache (testing specific) 2015-03-23 12:22:58 +01:00
6657d544db Merge branch 'develop' of github.com-obscure:ethereum/go-ethereum into develop 2015-03-23 12:12:53 +01:00
0be6d34048 finally merged *the missing* 2015-03-23 12:12:49 +01:00
dbb2af6016 Merge pull request #548 from tgerring/typescleanup
Fix Mist types build errors
2015-03-23 12:12:29 +01:00
91a2275ad3 Move RemoteAgent to miner pkg 2015-03-23 11:21:41 +01:00
439481d177 Rename Agent to RemoteAgent 2015-03-23 11:14:42 +01:00
01c0ba22ae Add DAG seed hash and difficulty to GetWork 2015-03-23 11:09:48 +01:00
0846e15667 go away! 2015-03-23 09:36:28 +01:00
ab6311c1bd Move remote mining agent to XEth 2015-03-23 09:35:42 +01:00
d76e8cb1f1 Consistent var names 2015-03-23 09:24:52 +01:00
16a58f8f2a Always return 3 strings 2015-03-23 08:55:06 +01:00
31879eca8c Stub corrected getWork response 2015-03-23 08:45:09 +01:00
3772f02569 Rename for filename typo 2015-03-23 08:29:41 +01:00
372e1cad5b Cleanup get/submitWork
getWork needs to return additional values
2015-03-23 08:28:54 +01:00
d2fa6e7753 vm: explicit error checks in ecrecover. closes #505 2015-03-22 14:54:40 -07:00
8affdf96e2 Merge pull request #547 from tgerring/commoncleanup
common/common.go cleanup
2015-03-22 21:46:46 +01:00
3133372a6a Merge pull request #536 from zsfelfoldi/develop
using robertkrimen/otto, godeps updated
2015-03-22 21:45:56 +01:00
59eab49cb8 Merge branch 'ethersphere-jsonlog' into develop 2015-03-22 21:43:58 +01:00
8b1b9fc99d Merge branch 'jsonlog' of https://github.com/ethersphere/go-ethereum into ethersphere-jsonlog
Conflicts:
	eth/backend.go
2015-03-22 21:43:36 +01:00
8ed4f226d1 check for nil ptrs 2015-03-22 15:44:00 +01:00
82956df523 Get work / submit work partially implemented.
* WIP missing arguments for submitting new work
* GetWork **done**
2015-03-22 15:38:01 +01:00
d186bf0dfe Fix Mist types build errors 2015-03-22 14:25:33 +01:00
bf73f02fe0 Remove common.go 2015-03-22 13:48:07 +01:00
360c66c65d Move Big* vars to big.go 2015-03-22 13:46:38 +01:00
2477d10aa0 Move MakeName to path 2015-03-22 13:46:21 +01:00
c0741edc34 Move OS-specific funcs to path.go 2015-03-22 13:44:17 +01:00
82a41a198e Move CurrencyToString to size 2015-03-22 13:35:13 +01:00
08b21acff1 Move ToHex/FromHex into bytes 2015-03-22 13:32:52 +01:00
9682a3ef3e Merge pull request #526 from ethersphere/frontier/blockpool
Frontier/blockpool
2015-03-22 13:11:16 +01:00
e349fb9350 bump 2015-03-22 12:20:27 +01:00
13781b922a converted to proper types 2015-03-22 12:12:29 +01:00
0edb33566f fix blockpool test logger 2015-03-22 02:18:07 +00:00
78cff9e3a4 independent flag for json structured logging
- logjson flag remove logformat flag
- passed to eth Config
- logsystem not a field of Ethereum
- LogSystem does not need to expose GetLogLevel/SetLogLevel
- message struct just implements more generic LogMsg interface
- LogMsg is a fmt.Stringer with Level()
- jsonMsg ([]byte) implements LogMsg
- remove "raw" systems
- move level logic inside StdLogSystem
- logsystems only print their kind of msg: jsonLogSystem prints jsonMsg, StdLogSystem prints stdMsg
2015-03-22 02:16:54 +00:00
95038fc62d Idle too long error incorrectly triggered even when peer sending new blocks
- fix status chain map uses common.Hash as key
- add badPeers increment to IncorrectTD errors (forgotten)
- signal head info update to head section process even if parent hash is not in pool (inserted), so that idle timer can be set to nil
- suicideC -> peer.headInfoTimer
- quit -> peer.bestIdleTimer
- and they are properly set from within getBlockHashes and handleSection
2015-03-22 02:02:24 +00:00
7f85608f30 Merge branch 'conversion' into develop 2015-03-21 18:18:19 +01:00
09766d1729 Merge pull request #535 from maran/fixReadmeLink
Fix link to build instructions in the readme
2015-03-21 18:16:55 +01:00
fcacfabe19 Added new ethereum.js 2015-03-21 15:09:03 +01:00
83728e4b64 Merge branch 'develop' into conversion
Conflicts:
	rpc/responses.go
2015-03-21 14:54:25 +01:00
004f5008ff Merge branch 'rpcfrontier' into develop 2015-03-21 14:53:12 +01:00
a7ad9c309b Merge branch 'develop' into conversion 2015-03-21 14:52:42 +01:00
38c7c589e4 Merge branch 'rpcfrontier' into develop 2015-03-21 14:52:31 +01:00
ce862ee758 Removed some comments 2015-03-21 14:51:45 +01:00
4300f2a0fa Fixed state tests 2015-03-21 14:47:50 +01:00
c28116cb3b Fixed incorrect recipient derived 2015-03-21 14:46:50 +01:00
06697775d1 Merge branch 'conversion' of github.com-obscure:ethereum/go-ethereum into conversion 2015-03-21 14:36:20 +01:00
9edb9a21bc Add json LogSystem #538 2015-03-21 07:26:44 +01:00
670021da15 Rename topic to topics #544 2015-03-21 07:08:33 +01:00
069c87b960 whisper: use common.Hash 2015-03-21 00:57:18 +01:00
7c4ff3abb4 eth: enable whisper again 2015-03-21 00:50:20 +01:00
483d43a15a whisper: use package rlp 2015-03-21 00:49:58 +01:00
a829a56587 rlp: add Stream.Raw 2015-03-21 00:49:31 +01:00
81800ca39e Merge remote-tracking branch 'ethereum/conversion' into conversion 2015-03-20 22:47:27 +01:00
b95ff54632 cmd/blocktest: delete package
Blocktests are now integrated in cmd/ethereum.
2015-03-20 22:46:41 +01:00
b41185a68f rlp: fix nil pointer decoding
The generic pointer decoder did not advance the input position
for empty values. This can lead to strange issues and even
infinite loops.
2015-03-20 22:33:40 +01:00
abce6804a0 Right pad bytes to prevent future programmers making bugs 2015-03-20 20:37:56 +01:00
f4e9638867 Merge branch 'ethersphere-frontier/blockpool' into conversion 2015-03-20 18:01:05 +01:00
ecd10d2cf7 iterator returned wrong value 2015-03-20 18:00:54 +01:00
1821d1af48 Merge branch 'frontier/blockpool' of https://github.com/ethersphere/go-ethereum into ethersphere-frontier/blockpool 2015-03-20 17:42:25 +01:00
54dac59285 wip 2015-03-20 17:42:09 +01:00
a59bb053f4 merge 2015-03-20 16:02:01 +01:00
deee9cb170 Added caching for block chain. Currently set to 10k 2015-03-20 15:54:42 +01:00
28e1971272 Merge branch 'rpcxeth' into rpcfrontier
Conflicts:
	rpc/api.go
2015-03-20 15:25:43 +01:00
0cde7a4d46 Add xethAtStateNum convenience method 2015-03-20 14:56:55 +01:00
efcc93e7da Move Account register to xeth 2015-03-20 14:12:07 +01:00
28ddc16a9b Merge remote-tracking branch 'ethereum/conversion' into conversion 2015-03-20 14:01:35 +01:00
c161d73d42 common: drop accessors for Value.Val
I don't see why we would need two different accessors for a public field.
2015-03-20 14:00:26 +01:00
dcb9614dfe common: drop unused kind field from Value
This makes Value 24 bytes smaller on 64bit systems.
2015-03-20 14:00:26 +01:00
f7d1d601e9 common: make Value encodable with package rlp
Value.{Encode,Decode} are gone. It implements rlp.Encoder and rlp.Decoder
instead, so Value can be decoded into directly.
2015-03-20 14:00:26 +01:00
c388e7eac0 crypto: remove use of common.Value.Encode
This seems to be the last remaining use of it.
2015-03-20 14:00:26 +01:00
85acdadcfa fixed jsre test 2015-03-20 13:48:23 +01:00
739c36ad4d inline GetStorageAt 2015-03-20 13:45:07 +01:00
28e5fc8352 Make pretty 2015-03-20 13:37:56 +01:00
8324b683b4 using robertkrimen/otto, godeps updated 2015-03-20 13:22:01 +01:00
7690285cbe Fix link to build instructions in the readme 2015-03-20 13:19:26 +01:00
66b29899c4 use common.Hash as pool key, no string conversion needed 2015-03-20 11:57:47 +00:00
4f5b362bda %#x => %x 2015-03-20 12:52:03 +01:00
91f9f355b2 test 2015-03-20 12:17:57 +01:00
41c493ace9 Merge branch 'rpcfrontier' of github.com-obscure:ethereum/go-ethereum into rpcfrontier 2015-03-20 12:07:19 +01:00
55fdf3e462 Listen to tx pre event and trigger 'pending' 2015-03-20 12:07:06 +01:00
d7564a9a25 fix common.Hash conversion 2015-03-20 10:41:41 +00:00
8987750a36 fix import in reorganised test 2015-03-20 10:41:41 +00:00
0578df9467 remove eth/wallet.go (only commented out content) 2015-03-20 10:41:41 +00:00
a578db5dae improve documentation and move one test 2015-03-20 10:41:41 +00:00
8767179d74 reduce logging output 2015-03-20 10:41:41 +00:00
63cae9b9ac uncomment status test, hack: skip the 2 unreliable fields 2015-03-20 10:41:41 +00:00
137a9c9365 check and penalise td misreporting
- add ErrIncorrectTD
- checkTD called after insertChain successful
- fix tests, use blockPoolTester.tds to map block index to TD
2015-03-20 10:41:41 +00:00
a9926a289d fix missing hexification on IdleTooLong error log 2015-03-20 10:41:40 +00:00
391e89d70a use own total difficulty to limit best peer
- update blockpool td by subscribing to ChainHeadEvent
- if ahead of best peer, demote it
- addPeer now take own td as current td
- removePeer now take own td as current td
- add relevant tests to peers_test
- eth: backend now calls blockpool with eth.eventMux and chainManager.Td
2015-03-20 10:41:40 +00:00
50661f0e68 peer suspension to disallow reconnect after disconnect on fatal error for set period (PeerSuspensionInterval) 2015-03-20 10:41:40 +00:00
01ff0b3176 fixed ethash 2015-03-20 11:40:46 +01:00
d8fe8f60e8 updated ethash 2015-03-20 11:19:12 +01:00
b3329bc698 inline Transact 2015-03-20 07:15:34 +01:00
aa3918efa7 Move transact gas check to XEth 2015-03-20 07:13:29 +01:00
e038a42d7a inline Call 2015-03-20 06:58:53 +01:00
1d6451f5c3 inline GetBlockByNumber 2015-03-20 06:57:23 +01:00
bde161382a inline GetBlockByHash 2015-03-20 06:53:24 +01:00
eb45211501 Merge branch 'rpcfrontier' of github.com:ethereum/go-ethereum into rpcfrontier 2015-03-20 06:45:44 +01:00
b56e20be27 Reorg for clarity 2015-03-20 00:24:23 -04:00
754160afea Move gas defaults to XEth 2015-03-20 00:23:48 -04:00
c3a3d38735 Add tests for errors 2015-03-20 00:08:29 -04:00
3cea7d87c1 Rename FilterOptions to BlockFilterArgs 2015-03-19 23:55:17 -04:00
d791fe4975 Remove unnecessary event mux 2015-03-19 23:34:35 -04:00
19360c0079 Move stateAt func to XEth 2015-03-19 23:28:45 -04:00
6669ef5b70 Rename for clarity 2015-03-19 23:20:54 -04:00
7b45f3377f inline MessagesChanged 2015-03-19 23:14:55 -04:00
2ef2b9f2e0 inline UninstallWhisperFilter 2015-03-19 23:13:52 -04:00
1f9b93647b inline NewWhisperFilter 2015-03-19 23:11:52 -04:00
4b5e592656 inline AllLogs 2015-03-19 23:10:23 -04:00
0bda63eb76 inline Logs 2015-03-19 23:08:26 -04:00
d2e7414230 inline FilterChanged 2015-03-19 23:07:25 -04:00
3e9632e256 inline NewFilterString 2015-03-19 23:06:32 -04:00
84b19971fa inline UninstallFilter 2015-03-19 23:05:23 -04:00
4663a55f12 inline NewFilter 2015-03-19 23:03:53 -04:00
7c30716828 Merge branch 'rpcinline' into rpcxeth
Conflicts:
	rpc/api.go
2015-03-19 23:01:10 -04:00
6c04c19eb4 Reorg filter logic to XEth 2015-03-19 22:58:07 -04:00
12d87226a7 Merge branch 'rpcutil' into rpcfrontier 2015-03-19 20:52:36 -04:00
cdfc03dc8e inline WhisperPost 2015-03-19 20:40:50 -04:00
0895190b64 inline GetBlockTransactionCountByHash 2015-03-19 20:31:40 -04:00
ff657edbb6 inline GetBlockTransactionCountByNumber 2015-03-19 20:30:42 -04:00
c57eb286d6 inline GetBlockUncleCountByHash 2015-03-19 20:29:46 -04:00
216175c265 inline GetBlockUncleCountByNumber 2015-03-19 20:28:25 -04:00
7e6c8a411d fixes 2015-03-19 20:26:09 -04:00
22546dcb55 inline UninstallWhisperFilter 2015-03-19 20:14:27 -04:00
b28e6d8306 inline WhisperMessages 2015-03-19 20:12:52 -04:00
cc91ba0add inline GetTransactionByHash 2015-03-19 20:12:12 -04:00
0eb9572d64 inline RemoveWhisperIdentity 2015-03-19 20:10:05 -04:00
85e03217de inline NewWhisperIdentity 2015-03-19 20:09:54 -04:00
57f6a3b5c0 inline DbGet 2015-03-19 20:06:35 -04:00
6fef616870 inline DbPut 2015-03-19 20:05:48 -04:00
d28cd0f040 inline GetCompilers 2015-03-19 20:04:40 -04:00
152b37ee11 inline GetData 2015-03-19 20:04:02 -04:00
e530c960a4 inline GetTxCountAt 2015-03-19 20:03:27 -04:00
3aea645106 inline GetStorage 2015-03-19 20:02:31 -04:00
7562bc1dbc inline GetBalance 2015-03-19 20:00:41 -04:00
b7745c6835 inline HasWhisperIdentity 2015-03-19 20:00:18 -04:00
6cc02aadbf Inline getStateWithNum 2015-03-19 19:58:59 -04:00
62236dd95e copy over loop 2015-03-19 23:20:41 +01:00
abc3d8d50a Make send internal 2015-03-19 18:06:26 -04:00
df5901fdc5 Removed more casts 2015-03-19 22:45:03 +01:00
013427bde2 Merge branch 'develop' into conversion 2015-03-19 21:18:29 +01:00
f144a95940 Squashed 'tests/files/' changes from e558aa4..559268b
559268b go failure
473f67f BlockTests More Invalid RLPs updated to latest develop
296c653 Fixed test to 15 header items
d011a67 Merge branch 'develop' of git://github.com/ethereum/tests into develop
44a3664 Updated to 16mb size

git-subtree-dir: tests/files
git-subtree-split: 559268ba4b454152c17b343db33d617877f30a3a
2015-03-19 21:14:51 +01:00
b4a51de602 Merge commit 'f144a95940a5df0809bb028eef7b337125423602' into develop 2015-03-19 21:14:51 +01:00
c7b616ac14 Remove util 2015-03-19 14:28:31 -04:00
1f2de6ecd5 Remove extra logger 2015-03-19 14:21:42 -04:00
d670c861d7 Move Log to LogRes 2015-03-19 14:19:52 -04:00
29eb220910 :-) 2015-03-19 17:18:55 +01:00
e861bbe0c1 Merge branch 'rpcfrontier' into develop 2015-03-19 17:00:01 +01:00
463491f8cd moved back to debug 2015-03-19 16:59:54 +01:00
b5a71d955c merge 2015-03-19 16:59:13 +01:00
e540a75030 re-enabled json logging 2015-03-19 16:30:01 +01:00
03b8ddd19c Merge branch 'rpcfrontier' into develop 2015-03-19 16:29:32 +01:00
14a2f42f37 fixed chain event. Closes #529 2015-03-19 16:19:54 +01:00
93ba3df4ff Removed frontier from version :-( 2015-03-19 15:36:38 +01:00
b52807f0c0 Removed frontier in version :-( 2015-03-19 15:36:00 +01:00
ce063e8d9c Merge remote-tracking branch 'ethereum/conversion' into conversion 2015-03-19 15:21:49 +01:00
e80dda6051 eth, whisper: adapt for RLP encoder switch in package p2p
I have rewritten the protocol test to use p2p.MsgPipe because
p2p.NewMsg is gone.
2015-03-19 15:18:31 +01:00
b9e0b11e7d p2p: interrupt MsgPipe payload read/write
This is better because protocols might not actually read the payload for
some errors (msg too big, etc.) which can be a pain to test with the old
behaviour.
2015-03-19 15:16:06 +01:00
a7bced779a p2p: log disconnect requests
This helps a lot with debugging.
2015-03-19 15:15:07 +01:00
5ba51594c7 p2p: use package rlp to encode messages
Message encoding functions have been renamed to catch any uses.
The switch to the new encoder can cause subtle incompatibilities.
If there are any users outside of our tree, they will at least be
alerted that there was a change.

NewMsg no longer exists. The replacements for EncodeMsg are called
Send and SendItems.
2015-03-19 15:11:02 +01:00
4811f460e7 p2p: export ExpectMsg (for eth protocol testing) 2015-03-19 15:08:04 +01:00
797bbce15e Merge branch 'develop' into conversion 2015-03-19 15:07:47 +01:00
554f20930a Merge branch 'develop' into rpcfrontier 2015-03-19 15:07:33 +01:00
a756dbeb7b Removed uint casts 2015-03-19 15:06:56 +01:00
ad7e491214 improved test output 2015-03-19 15:04:29 +01:00
d4e5747d04 Merge branch 'develop' into conversion 2015-03-19 14:31:41 +01:00
cf45b939a0 fixed tests 2015-03-19 14:31:14 +01:00
e13c673980 Merge remote-tracking branch 'ethereum/conversion' into conversion 2015-03-19 12:17:43 +01:00
965c9babe3 rlp: fix encoding of one element strings and byte slices
The encoder was missing a special case for one element strings whose
element is below 0x7f. Such strings must be encoded as a single byte
without a string header.
2015-03-19 12:15:43 +01:00
d7ab716eea Fixed mkdnode & added some tests 2015-03-19 10:57:02 +01:00
8b20c3cc97 Validate NewTx From field is not blank 2015-03-18 20:30:09 -04:00
85fa3790ac Squashed 'tests/files/' changes from 641ebaa..e558aa4
e558aa4 clean up
47096f8 remove corrupted files
47e73ea even more failures
18506ee add tests
a9729da merge
bc09d2e merge
3c89576 new tests
650ac93 Merge remote-tracking branch 'origin/develop' into develop
ee7ea6a update blockChainTests
46484ae fuzz tests
eb8f8fb fuzz testing
1c74972 fuzz testing results
8f06b8f Block Tests +make RLP header larger than rlp +all block fields  +1)Prefixed000  +2)Larger size  +3)Less Size  +4)rlp element list when shouldnt  +5)given as array +random byte at the end +transaction fields +random byte in RLP
fdf6c3e BlokTests Invalid Block Header RLPs (0000prefix, tooLarge, tooShort)
c81751d update gasLimit

git-subtree-dir: tests/files
git-subtree-split: e558aa49d425eb43b8ee2f71f52b6312ab092520
2015-03-18 22:13:08 +01:00
e67d32b467 Merge commit '85fa3790ac9f67232f0e31e7f861c66ef0e0047e' into develop 2015-03-18 22:13:08 +01:00
da427e8843 Merge branch 'rpcutil' into rpcfrontier 2015-03-18 15:57:06 -04:00
0685810ec6 Tests 2015-03-18 15:48:40 -04:00
e02eedb43e BlockNumber as int fix 2015-03-18 15:48:34 -04:00
7cbcd81ddc Remove UnmarshalRawMessages 2015-03-18 15:42:57 -04:00
5f35e6778f Merge branch 'rpcfrontier' into conversion 2015-03-18 18:42:30 +01:00
af9da83ce2 Merge branch 'develop' into rpcfrontier 2015-03-18 18:42:21 +01:00
f0bb136099 Merge branch 'develop' into conversion 2015-03-18 18:42:01 +01:00
c12046d6bf Merge branch 'ethersphere-frontier/cli-private-network' into develop 2015-03-18 18:39:56 +01:00
79f90bf7c1 added frontier to version 2015-03-18 18:39:24 +01:00
bc5ae94384 Merge branch 'frontier/cli-private-network' of https://github.com/ethersphere/go-ethereum into ethersphere-frontier/cli-private-network 2015-03-18 18:37:20 +01:00
f9a6038f5b merge 2015-03-18 18:23:37 +01:00
baca0c2251 Merge pull request #523 from fjl/docker-fast
Dockerfile: use fast™ build steps
2015-03-18 12:09:20 -04:00
3e52c9439a Merge pull request #522 from fjl/makedag
cmd/ethereum: add makedag command for testing
2015-03-18 16:40:50 +01:00
60c43d1952 Remove i2hex 2015-03-18 11:10:08 -04:00
7c9bc8517d Remove RpcServer 2015-03-18 11:08:49 -04:00
4d0ae8b0cb Merge branch 'conversion' of github.com-obscure:ethereum/go-ethereum into conversion 2015-03-18 14:16:07 +01:00
48dd601de0 prep template for fixed size hashes 2015-03-18 14:15:58 +01:00
064279c0ec cmd/ethereum, cmd/utils: partial fix for chain import 2015-03-18 14:04:44 +01:00
e30c323391 merge develop 2015-03-18 08:46:55 -04:00
d15f90645d Merge remote-tracking branch 'ethereum/conversion' into conversion 2015-03-18 13:39:01 +01:00
a59dd393e7 core: fix tests 2015-03-18 13:38:47 +01:00
b5b83db450 core: use package rlp to encode blocks
This also changes the chain export format so there is no
enclosing list around the blocks, which enables streaming export.
2015-03-18 13:36:48 +01:00
c298148a7f core/types: use package rlp instead of common.Decode 2015-03-18 13:24:34 +01:00
b94a6a0193 rlp: add DecodeBytes
Über-convenience.
2015-03-18 13:17:39 +01:00
0a1eeca41e conversions. -compilable- 2015-03-18 13:00:01 +01:00
942980609f conversions 2015-03-18 11:44:25 +01:00
cd52ef315c Added Hex methods 2015-03-18 11:44:17 +01:00
ca8d184173 fix eth tests 2015-03-18 16:31:49 +07:00
b6aa88c099 private network support
- protocolversion, networkid global int flags to cli and mist
- fix bug with protocolversion check using wrong db
- log protocolversion & networkid in backend
2015-03-18 14:44:58 +07:00
67c9d9c2fa Remove JsonWrapper 2015-03-17 20:14:19 -04:00
cb009a5c4d rlp: don't panic for nil *big.Int
All other pointer types can handle nil just fine.
2015-03-17 23:49:49 +01:00
c6f84325b1 Support JSON RPC batch requests 2015-03-17 17:46:22 -04:00
8fd243ee23 Add JSON RPC batch support
http://www.jsonrpc.org/specification#batch
2015-03-17 17:38:05 -04:00
7dbbe1bedc eth/backend: remove spurious and incorrent PeerInfo() 2015-03-18 04:01:47 +07:00
1872418316 eth: remove disused peer_util.go 2015-03-18 03:59:21 +07:00
142e81258c Merge branch 'develop' into conversion 2015-03-17 21:40:05 +01:00
3ea99f989f Merge pull request #498 from maran/feature/drytoHex
DRY up the use of toHex in the project and move it to common
2015-03-17 21:31:42 +01:00
048d4ec5be Merge branch 'rpcfrontier' into develop 2015-03-17 21:30:29 +01:00
917050dc30 Merge branch 'develop' into rpcfrontier 2015-03-17 21:27:34 +01:00
53104b09fa bump 2015-03-17 21:23:05 +01:00
786a58d8b0 Merge pull request #485 from ethersphere/frontier/nodeadmin.js
Frontier console node admin interface
2015-03-17 21:15:23 +01:00
86661de077 Fixed tests and bloom 2015-03-17 18:00:03 +01:00
c21293cd91 bloom 2015-03-17 16:05:17 +01:00
1513413412 Dockerfile: use fast™ build steps 2015-03-17 14:49:37 +01:00
b422835a59 cmd/ethereum: add makedag command for testing 2015-03-17 14:12:34 +01:00
fe819f3b9f Comment out whisper remove identity stubs 2015-03-17 09:11:01 -04:00
0fa7859b94 Fixed VM & Tests w/ conversion 2015-03-17 13:24:25 +01:00
ff55c6f5ba Merge branch 'develop' into conversion
Conflicts:
	common/types.go
2015-03-17 13:09:22 +01:00
b0ebccb31e fixed to 2015-03-17 12:56:29 +01:00
17c5ba2b6b core: actually convert transaction pool 2015-03-17 12:16:21 +01:00
9663493ba0 Merge commit 'dffaa678f966f87dcd011671a16b554b29a37549' into develop 2015-03-17 12:02:50 +01:00
dffaa678f9 Squashed 'tests/files/' changes from 0749546..641ebaa
641ebaa Merge branch 'develop' of https://github.com/ethereum/tests into develop
8e44fd4 possibility to launch more than one machine
5498fd5 2 more python fails
99268f3 update random test simulation files
170485e Merge remote-tracking branch 'origin/develop' into develop
4fcdf8f new python fails
e67b68a Merge branch 'develop' of https://github.com/ethereum/tests into develop
3f45f18 BlockRLPTests block fields prefixed with 0000
9fa9bbd Merge pull request #78 from wanderer/develop
222c2b4 update block tests
9d844dd python fails
05233a4 update blockchaintests
7dc0aa2 update JS_API_Test blockchain
6daf1cc added JS_API_test blockchain
e878f7e consitant address format
0e246ce python fail
57ea9a0 random failures
95934e0 add test for callcode to 0
13b8cd2 new python failures
9e60453 remove empty tests
ca6dfa9 uncle older than 6 generation test
cf7e950 some random failures
282090e update gas limits + uncle generation test
bb4c1f4 cppjit failure
cda9d4c more random failures
31ac17a add calldataload big offset test
f6b8e28 remove seedhash and update blockchain tests
ad69f9d add addmod test in order toc check that nothing get downcasted inbetween
38b7db2 a failing test
b9149b5 Merge remote-tracking branch 'origin/develop' into develop
5bea708 more failing tests
478a07d fix missing comma
6d82797 Merge remote-tracking branch 'origin/develop' into develop
2f380e2 random fails
3cd0ce7 Merge pull request #75 from romanman/develop
afa0a43 Update crypto.json
1b9b7b8 Introduce ECIES crypto test

git-subtree-dir: tests/files
git-subtree-split: 641ebaa3cf257c08838c707bebb481d61e708f95
2015-03-17 12:02:49 +01:00
ee7202fa00 Merge remote-tracking branch 'ethereum/conversion' into conversion 2015-03-17 12:01:40 +01:00
65eee2006d pow/ezp: use common.Hash 2015-03-17 12:01:21 +01:00
27f7aa0163 core: adapt Message for new Transaction.From signature 2015-03-17 12:00:29 +01:00
b95387a0dc core: convert transaction pool to common.{Address,Hash} 2015-03-17 11:59:26 +01:00
e91ab84dbe core/types: don't use Address zero value for invalid addresses 2015-03-17 11:58:31 +01:00
515d9432fc converted vm 2015-03-17 11:19:23 +01:00
d5de6489d7 core/types: fix Transaction.Hash and add support for encoding with package rlp 2015-03-17 01:34:18 +01:00
ad78db4d62 crypto: fix Sha3Hash and add a test for it 2015-03-17 01:32:35 +01:00
8ce6a36478 converted chain manager 2015-03-16 23:48:18 +01:00
94505146a2 updated vm env 2015-03-16 23:17:28 +01:00
843db4978e updated blockpool 2015-03-16 23:10:26 +01:00
176115e22e More empty param tests 2015-03-16 16:49:51 -04:00
4e181c5764 Moved gas 2015-03-16 21:46:47 +01:00
0339a13862 RPC empty args tests 2015-03-16 16:21:51 -04:00
719effa7ec Return error when filter params are not strings 2015-03-16 15:30:31 -04:00
03ac0f18ae Initial support to remove Whisper identities per #491 2015-03-16 14:46:46 -04:00
6aa390abfb Merge branch 'conversion' of github.com-obscure:ethereum/go-ethereum into conversion 2015-03-16 18:43:09 +01:00
91b0b14845 converted vm 2015-03-16 18:42:18 +01:00
e5e265d024 Merge branch 'develop' into rpcfrontier 2015-03-16 13:02:41 -04:00
16df850af2 core/types: use common.{Hash,Address} in for transactions 2015-03-16 17:43:42 +01:00
13ade2ed60 Merge branch 'conversion' of https://github.com/ethereum/go-ethereum 2015-03-16 17:29:08 +01:00
64490897f3 crypto: add Sha3Hash 2015-03-16 17:27:24 +01:00
bfcd2cf132 block conversion 2015-03-16 17:27:23 +01:00
e620bde405 conversion state 2015-03-16 17:09:08 +01:00
7330c97b5b DRY up the use of toHex in the project and move it to common 2015-03-16 16:56:11 +01:00
17cd7a5817 remove long-running mining test, ethutil -> common 2015-03-16 22:56:05 +07:00
b3e133dd15 Merge branch 'frontier/js' into frontier/nodeadmin.js 2015-03-16 22:50:29 +07:00
73af0302be we do not use the name Frontier Console 2015-03-16 22:49:39 +07:00
b4060da9eb ethutil -> common 2015-03-16 22:48:54 +07:00
5e7702fd05 Merge remote-tracking branch 'upstream/develop' into frontier/js
Conflicts:
	cmd/ethereum/js.go
	javascript/types.go
2015-03-16 22:46:29 +07:00
76f215b0fe Getters shouldn't need to be pointer receiver 2015-03-16 16:44:27 +01:00
0dd9ac375b undo 2015-03-16 16:36:58 +01:00
22893b7ac9 removed compile 2015-03-16 16:31:16 +01:00
d338650089 compilable trie (tests fail) 2015-03-16 16:28:16 +01:00
5757f547a6 Allow latest/pending in filter options 2015-03-16 10:38:57 -04:00
20b7162a62 Added functions to Hash & Address
* Set, SetString, SetBytes
* StringTo*, BytesTo*
2015-03-16 13:23:06 +01:00
dc864ee3a5 Added ToString methods 2015-03-16 12:20:17 +01:00
3cf51d5479 tmp 2015-03-16 12:03:52 +01:00
f486c0ae56 new type + additional methods 2015-03-16 11:59:52 +01:00
b523441361 Moved ethutil => common 2015-03-16 11:27:38 +01:00
8139d444f8 Merge remote-tracking branch 'upstream/develop' into frontier/nodeadmin.js 2015-03-16 15:19:09 +07:00
0b8f66ed9e updated godep ethash 2015-03-15 21:47:59 +01:00
22fa59f131 moved to detail 2015-03-15 21:47:35 +01:00
ece5c2aade Merge branch 'frontier/js' into frontier/nodeadmin.js 2015-03-15 22:29:50 +07:00
8393dab470 menubar back to mist main.qml 2015-03-15 22:29:10 +07:00
d2e75cc957 cleaning up unused code 2015-03-15 15:25:09 +01:00
ff86d7d52a Merge branch 'frontier/js' into frontier/nodeadmin.js 2015-03-15 18:43:03 +07:00
7bc40aa963 jsre: remove assetpath using GOPATH from test 2015-03-15 18:42:17 +07:00
c87cc59bdf Merge branch 'develop' of github.com-obscure:ethereum/go-ethereum into develop
Conflicts:
	README.md
2015-03-15 12:20:58 +01:00
8f84ddbbec Linux build links 2015-03-15 12:20:07 +01:00
0f26a62334 Linux build links 2015-03-15 12:19:26 +01:00
132e87a707 node admin interface for Frontier Console, see spec https://github.com/ethereum/go-ethereum/wiki/Frontier-Console 2015-03-15 13:43:48 +07:00
8ad0f1b8a3 eth:
- NodeInfo, PeerInfo types, PeersInfo(), NodeInfo() in eth/backend to support node admin IF
- start net only if MaxPeers > 0, close extraDb in Stop()
- defer s.extraDb.Close()
2015-03-15 13:39:52 +07:00
e150832734 p2p: server>discover table Self=Node exported 2015-03-15 13:38:41 +07:00
7279a485c2 CLI:
- js subcommand for vm
- console for Frontier console interactive REPL
- jspath in cli
- integrate jeth apiBindings
2015-03-15 13:31:40 +07:00
16ecb1e2ea rpc
- camelcase fields dont play nice with otto value magic: JsonRpc -> Jsonrpc, ID -> Id
- jeth: ethereum.js rpc transport provider direct bridge between js and ethereumApi via otto jsre
2015-03-15 13:21:54 +07:00
31ffca6d8a remove jsre from mist 2015-03-15 13:18:58 +07:00
da44097800 jsre:
- require became loadScript(), no require is supplied
- bignumber_js.go: heredoc v2.0.3 minified fixed for otto Regexp incompatibility https://github.com/robertkrimen/otto#regular-expression-incompatibility
- bignumber.min.js also updated in mist/assets/ext
- ethereum_js.go: latest master minified
- assetPath in constructor
- Eval/Exec/Handle/ToVal nice API
- jsre tests
2015-03-15 13:13:39 +07:00
2a5fbced7f removed seed hash 2015-03-14 23:39:45 +01:00
282d8c20fd Merge branch 'fjl-block-tests' into develop 2015-03-14 23:37:37 +01:00
d9966d6158 merge 2015-03-14 23:37:21 +01:00
12cee1377f Increased filter ticker time to 5 minutes 2015-03-14 18:57:12 +01:00
95711bc2dd Updated ethash 2015-03-14 16:42:05 +01:00
387f6bba3e POW fixes 2015-03-14 16:37:57 +01:00
44636e5b82 typo 2015-03-14 13:21:20 +01:00
35bc7b0d8a Merge branch 'rpcfrontier' into develop 2015-03-14 12:44:24 +01:00
532a74f50e Improved errors. Closes #475 2015-03-14 12:43:10 +01:00
51df765e38 Merge pull request #481 from maran/feature/fromHexDry
DRY-up the use of fromHex in the project
2015-03-14 11:46:32 +01:00
9754e7aca7 Support for addresses with or without 0x. Fixes #472 2015-03-14 11:40:13 +01:00
991993357c DRY up the use of fromHex and put it in ethutil 2015-03-14 11:39:35 +01:00
f49e17eb39 Return null coinbase when accounts not created
Was previously returning nonsensical “0x”
2015-03-13 14:32:11 -04:00
67f8f83a1b cmd/ethereum: add blocktest command 2015-03-13 18:41:09 +01:00
e463479b6c eth: add ResetWithGenesisBlock
This depends on a change in ethash which exposes UpdateCache.
2015-03-13 18:41:09 +01:00
6f8a2d6b84 eth: add hook for database creation 2015-03-13 18:41:09 +01:00
58d9d98daf cmd/utils: GetEthereum -> MakeEthConfig
This allows changing the config before starting Ethereum
with it.
2015-03-13 18:41:09 +01:00
a80be98f31 tests: add helper functions for block tests 2015-03-13 18:41:09 +01:00
9326541820 core/types: make Block.{ParentHash,SeedHash,MixDigest} []byte
There is no reason to keep them as ethutil.Bytes.
2015-03-13 18:41:09 +01:00
b927c29469 GetBlockByNumber now properly looks for a number in the database 2015-03-13 18:29:42 +01:00
fee9aecfb2 more tests for remote update 2015-03-13 17:53:53 +01:00
ccda1aacb4 Merge branch 'develop' of github.com-obscure:ethereum/go-ethereum into develop 2015-03-13 17:49:05 +01:00
03403399fc Return proper error 2015-03-13 17:47:11 +01:00
a0266489b4 Make remote dominant 2015-03-13 17:47:00 +01:00
a76d55c83a Merge pull request #467 from ethersphere/frontier/natspec
NatSpec integration
2015-03-13 16:47:16 +01:00
b663e8b29a Merge branch 'rpcfrontier' into develop 2015-03-13 16:36:27 +01:00
f1fcda4f2f Implemented managed state
* Reimplemented nonce management for known accounts.
2015-03-13 16:29:04 +01:00
e3b64d70c2 Rename db_put db_get 2015-03-13 10:56:41 -04:00
d3f96dc720 Consolidate error type switch 2015-03-13 10:03:48 -04:00
0932f84383 Fix eth_newBlockFilter 2015-03-13 10:03:19 -04:00
cda88ce31a Implemented a manage state for keeping track of nonces 2015-03-13 14:37:54 +01:00
aa9f981d5f Bump protocol version 58 2015-03-13 13:52:57 +01:00
e69d5b32e8 Increased genesis gas & gas floor limit to 3141592 2015-03-13 13:52:23 +01:00
f76cc6699e Changed context and ADDMOD, MULMOD
* Cleaned up VM execution. VM run now takes a context
* ADDMOD/MULMOD - removed incorrect cast
2015-03-13 13:44:15 +01:00
d4ed66c83d Add web3_clientVersion 2015-03-12 19:20:46 -05:00
094f921e50 Convert to proper errors
Allow returning different JSON RPC error codes depending on error type
2015-03-12 19:07:03 -05:00
80592f244d more obvious failure for ethtest 2015-03-12 23:26:58 +01:00
6051345bc9 Squashed 'tests/files/' changes from d6c987f..0749546
0749546 random fails
a153865 random fails

git-subtree-dir: tests/files
git-subtree-split: 074954630f43e97f0769997d175511a00a47cc9d
2015-03-12 22:32:05 +01:00
3a88da578f Merge commit '6051345bc9ab8ccf74a49c43342771e0c2cba588' into develop 2015-03-12 22:32:05 +01:00
fa917387e4 Merge branch 'rpcfrontier' into develop 2015-03-12 22:31:13 +01:00
310ca62285 Removed some of that gas pre pay magic 2015-03-12 22:29:10 +01:00
3ff7a627d1 Squashed 'tests/files/' changes from 9e19ff9..d6c987f
d6c987f go failure

git-subtree-dir: tests/files
git-subtree-split: d6c987feed635976ce26b14b9be88289d0ef50d4
2015-03-12 20:01:46 +01:00
2ae90e1eba Merge commit '3ff7a627d1921be0aeacdd8eb2853ba4537487eb' into develop 2015-03-12 20:01:46 +01:00
11390a986a run all test 2015-03-12 19:43:20 +01:00
347cb272be fixed ethtest 2015-03-12 19:41:56 +01:00
412e8b0e37 Squashed 'tests/files/' changes from dbdd0f8..9e19ff9
9e19ff9 random state tests failures
7060dc7 dejavu issues
5a89a4b python fail
2470051 python fails - may be just wrong return value

git-subtree-dir: tests/files
git-subtree-split: 9e19ff93918597bbf53a2f127202a70704646d82
2015-03-12 19:15:12 +01:00
d1c872bace Merge commit '412e8b0e377bd89fc8fc858bd09c89deee805c1e' into develop 2015-03-12 19:15:12 +01:00
fb71c9f6ee Return 1 on fail 2015-03-12 18:22:56 +01:00
83cc08f670 Changed to big.Int.Not 2015-03-12 18:22:35 +01:00
14bdcd2c05 Fix arg names in tests 2015-03-12 11:50:03 -05:00
7235e84c75 #469 2015-03-12 11:09:25 -05:00
d11fabd2ef Update path to web3 library 2015-03-12 10:08:01 -05:00
f7c3c7eda4 Update ethereum.js
Added to git modules
2015-03-12 10:03:35 -05:00
b97c17f4ee Merge branch 'rpcfrontier' of github.com-obscure:ethereum/go-ethereum into rpcfrontier 2015-03-12 15:59:16 +01:00
2273155e7e Get transaction implemented
* Added a GetTransaction to XEth
* Implemented the `eth_getTransactionByHash` RPC method
2015-03-12 15:59:07 +01:00
b006b67768 Merge branch 'develop' into rpcfrontier 2015-03-12 09:24:34 -05:00
26a5636424 Merge branch 'develop' into rpcfrontier 2015-03-12 14:51:05 +01:00
3b3843e158 Merge branch 'develop' of github.com-obscure:ethereum/go-ethereum into develop 2015-03-12 14:50:48 +01:00
ef6706696c Add additional extra database for non-protocol related data
* Add transaction to extra database after a successful block process
2015-03-12 14:50:35 +01:00
2a0e5888fd Merge pull request #460 from tgerring/ethutil
Move MakeName to ethutil
2015-03-12 14:45:31 +01:00
4418e4ea6a Should on empty params #466 2015-03-12 08:42:31 -05:00
21fca93852 Output filter ID as hex 2015-03-12 08:20:07 -05:00
4342fe0f22 include new minified natspec with RE fix; fix test for the improved error messages 2015-03-12 19:08:30 +07:00
704914be08 Check for existance of key before delete 2015-03-12 00:01:18 -05:00
31a95151c9 updated rnd vm test => state test 2015-03-12 01:12:28 +01:00
92c6150199 Squashed 'tests/files/' changes from e390be4..dbdd0f8
dbdd0f8 update test script for python
29dced2 add failing python test
5b7ebb9 OOG or 1024 depth level fail
3f58fd8 run OOG at tx level with to high value for call
39d8595 run OOG and too high value for call/callcode
55fbf95 run OOG and too high value for call/callcode
8856bfb add callCreateCallCode test file
d2da29e check value when doing callcode
129a464 suicide and storage refund tests with and without storage
6aa5e29 suicide and storage refund tests
fff323d python fails
963648b python callcode fail
31ce83a python big memory fail
531bc36 add memory stress test using return
b7021c7 renaming
959ff59 vm input limit tests
1c3741f update blockchain tests with new uncle reward rule

git-subtree-dir: tests/files
git-subtree-split: dbdd0f829dea8aa053159707caf353d83bf5be0f
2015-03-12 00:57:28 +01:00
96496888ed Merge commit '92c6150199395eea6c9893b631cc990e3ff72a33' into develop 2015-03-12 00:57:28 +01:00
7ee5cb0a81 Merge branch 'develop' into rpcfrontier 2015-03-12 00:26:40 +01:00
9fb52c517b Changed V to byte. Closes #456 2015-03-12 00:18:03 +01:00
6af078bd8c Merge pull request #462 from fjl/miner-coinbase
miner: provide coinbase when starting the miner
2015-03-11 23:56:48 +01:00
d5aaf413e0 cmd/ethereum: remove extra check for 'no accounts' error
This error can no longer be returned from eth.New.
2015-03-11 23:43:27 +01:00
d7b5a87b3b miner: provide coinbase when starting the miner
This avoids having to query the coinbase when creating the miner, which
in turn eliminates the dreaded startup error when no accounts are set
up. Later, this will also allow us to simply restart the miner when the
user picks a different coinbase.

This causes a lot of changes in other packages. These are included in
this commit because they're impossible to separate.
2015-03-11 23:43:27 +01:00
70f6f2af07 shh_uninstallFilter 2015-03-11 15:49:21 -05:00
c2181fdbf2 block&index args unmarshal plus test 2015-03-11 15:26:28 -05:00
5a9f712144 Comment out broken test (return type does not exist) 2015-03-11 14:43:39 -05:00
485e37e889 Move MakeName to ethutil 2015-03-11 14:29:07 -05:00
587f748d92 Merge branch 'fjl-unencrypted-keys' into develop 2015-03-11 17:47:17 +01:00
629f4b1d3c merge 2015-03-11 17:46:58 +01:00
239e17de12 Merge branch 'rpcfrontier' into develop 2015-03-11 17:37:17 +01:00
c01d4c2f4c Lowered default gas price and increased default gas limit 2015-03-11 17:36:35 +01:00
2da7af4ba0 Merge branch 'rpcfrontier' of github.com-obscure:ethereum/go-ethereum into rpcfrontier 2015-03-11 17:00:30 +01:00
e8d1b622d9 Default block number changes 2015-03-11 17:00:20 +01:00
90f34ed40a Rename Topic to Topics 2015-03-11 10:56:44 -05:00
61bf29be36 Check length of timestring before taking slice 2015-03-11 10:43:52 -05:00
08b1154033 Changed logging to use internal logger 2015-03-11 16:36:10 +01:00
477815c044 Improved error reporting and removed commented code 2015-03-11 16:33:39 +01:00
6b63759ded Reverted global 2015-03-11 16:33:04 +01:00
7add66c8bb Use the state to up the balance of the coinbase 2015-03-11 16:32:37 +01:00
9e89c803f1 Get Uncles 2015-03-11 10:27:32 -05:00
53ac85cfd3 BlockHash must be a string 2015-03-11 10:27:24 -05:00
d465e410ef TxIndex -> Index 2015-03-11 10:25:15 -05:00
99bc44cf52 cmd/ethereum: add a flag to switch to unencrytped keystore
This is mostly for automated tests. The tests can use the following
commands to start the node:

    ethereum --unencrypted-keys account new
    ...
    ethereum --unencrypted-keys
2015-03-11 13:58:01 +01:00
6bca40274f Merge branch 'rpcfrontier' of github.com:ethereum/go-ethereum into rpcfrontier 2015-03-10 22:25:32 -05:00
9ce5229ddf Get transaction via block & index 2015-03-10 22:25:07 -05:00
ece29c5d8d Nil check block 2015-03-10 19:34:07 -05:00
074ee19fe5 Merge branch 'develop' into rpcfrontier 2015-03-11 01:11:20 +01:00
64933321fb Merge branch 'rpcfrontier' of github.com-obscure:ethereum/go-ethereum into rpcfrontier 2015-03-11 01:10:58 +01:00
58909117be Use ECDSA instead of elliptic 2015-03-11 01:10:25 +01:00
499f816e30 Output hex should be prepended with 0x 2015-03-10 19:10:02 -05:00
7e0ccc9de5 Merge branch 'develop' into rpcfrontier
Conflicts:
	rpc/api.go
	rpc/args.go
2015-03-11 01:08:42 +01:00
fda4d02f94 Left-pad odd length hex inputs and tests 2015-03-10 18:08:31 -05:00
eba4f389a6 don't log whisper start ups 2015-03-10 22:43:07 +01:00
7d77a2ffc3 Merge branch 'develop' of github.com-obscure:ethereum/go-ethereum into develop 2015-03-10 22:42:24 +01:00
73171d18b9 Merge pull request #447 from fjl/accounts-integration
Accounts integration
2015-03-10 22:42:03 +01:00
eb1b4c8ffe Merge branch 'fjl-accounts-integration' into develop 2015-03-10 20:37:23 +01:00
ce595b9266 fallback 2015-03-10 20:28:20 +01:00
35841e5190 id to hex 2015-03-10 20:16:53 +01:00
d9f96293be Merge branch 'rpcfrontier' of github.com-obscure:ethereum/go-ethereum into rpcfrontier
Conflicts:
	rpc/args.go
2015-03-10 20:16:08 +01:00
f22684439a Updated RPC
* Added a generic RawMessage deserialiser
* Updated ethereum.js
* Updated coin test app
2015-03-10 20:14:38 +01:00
3d6519e45b Update response types 2015-03-10 12:52:45 -05:00
617804c327 Merge branch 'rpcfrontier' of github.com:ethereum/go-ethereum into rpcfrontier 2015-03-10 12:50:13 -05:00
269cfbb8ac Merge branch origin/develop into accounts-integration
Conflicts:
	cmd/blocktest/main.go
	cmd/mist/debugger.go
	cmd/utils/cmd.go
2015-03-10 17:14:31 +01:00
972e2c1e31 cmd/utils: improve CLI help templates
Help for a specific command now shows available subcommands.
2015-03-10 16:44:48 +01:00
221fae4112 cmd/ethereum: show some help before prompting for encryption passphrase 2015-03-10 16:44:22 +01:00
2407f006ad Godeps: bump github.com/codegangsta/cli 2015-03-10 16:41:33 +01:00
0bb7377ebe cmd/ethereum: show more helpful message if no accounts exist 2015-03-10 15:44:05 +01:00
9d4e1e8f8b eth: return account errors directly 2015-03-10 15:42:58 +01:00
c3f94a4341 cmd/utils: remove extra space in fatal error message 2015-03-10 15:42:25 +01:00
4ba7871374 accounts: return ErrNoKeys if key directory does not exist 2015-03-10 15:41:08 +01:00
0f67f1e9de xeth: fix signing transaction after unlock 2015-03-10 14:55:00 +01:00
0395c174ca cmd/ethereum: fix line editing setup and history 2015-03-10 14:31:54 +01:00
bbe8b18660 Added unmarshalState 2015-03-10 13:40:49 +01:00
53f8f29744 Merge branch 'develop' into rpcfrontier 2015-03-10 12:39:59 +01:00
0542df941f Merge pull request #449 from Gustav-Simonsson/add_blockchain_tests2
Add empty total difficulty to test blocks and clean up stopping the node
2015-03-10 12:07:34 +01:00
56524d13b5 removed debugger 2015-03-10 12:06:16 +01:00
b87442a9f7 Fixed error message. Closes #448 2015-03-10 11:29:22 +01:00
c0a8e3cd34 Merge branch 'poc-9' into develop 2015-03-10 11:25:32 +01:00
c9b6d268b4 Merge pull request #438 from ethersphere/poc9/cli
Poc9/cli (exportchain)
2015-03-10 11:24:47 +01:00
08d396fdba Merge pull request #437 from ethersphere/poc9/natspec
[WIP] Poc9/natspec
2015-03-10 11:24:30 +01:00
05c9351659 Merge branch 'accounts-integration' of https://github.com/fjl/go-ethereum into fjl-accounts-integration 2015-03-10 11:04:11 +01:00
80985f97da cmd/evm, core, ethdb, state, tests/helper: remove ReadConfig calls 2015-03-10 02:39:53 +01:00
3de51f76ee Allow integers for BlockNumber
If parsing fails, fall back to hex decoding
2015-03-09 20:38:37 -05:00
e6118f2d79 state: fix tests 2015-03-10 02:35:21 +01:00
9b3ae1fdb7 eth: fix tests 2015-03-10 02:34:52 +01:00
ae38871a54 cmd/ethereum: remove "prompter" in identifiers 2015-03-10 02:33:59 +01:00
62ebce304e crypto: delete old key management stuff 2015-03-10 02:12:55 +01:00
9f0e3bd286 cmd/ethereum: unlock accounts on JS REPL 2015-03-10 02:00:57 +01:00
395da0e7c1 xeth: use Frontend interface to unlock accounts
The interface has moved to package xeth because that's where it is
actually used.
2015-03-10 02:00:06 +01:00
0db4a0e898 Merge branch 'poc-9' into develop 2015-03-10 01:22:38 +01:00
0d64163fea Right pad zeros. Closes #446 2015-03-10 01:13:06 +01:00
9007f2bbdc reworked stack 2015-03-10 00:25:27 +01:00
d1e04f7388 cmd/ethereum: allow multiple js files 2015-03-10 00:24:11 +01:00
487f68ec48 accounts: add {Timed,}Unlock, remove SignLocked 2015-03-10 00:19:01 +01:00
0795fd2701 wip 2015-03-09 23:34:31 +01:00
9bf513e993 Merge ethereum/poc-9 into accounts-integration
Conflicts:
	cmd/utils/cmd.go
	cmd/utils/flags.go
	core/manager.go
	eth/backend.go
	rpc/http/server.go
	xeth/xeth.go
2015-03-09 23:25:46 +01:00
cd51860bf0 cmd/utils: delete InitConfig, KeyTasks 2015-03-09 23:08:47 +01:00
697f6748b8 cmd/mist: use cli library and package accounts 2015-03-09 23:08:47 +01:00
c2e5dacf55 accounts: add Manager.HasAccount, delete Manager.Default 2015-03-09 23:08:46 +01:00
63758db379 eth: delete unused RpcServer field 2015-03-09 23:08:46 +01:00
6a7e02fc9f rpc/http: delete package 2015-03-09 23:08:46 +01:00
a11f1d6a7e rpc: add dataDir parameter and JSON-RPC handler 2015-03-09 23:08:46 +01:00
73d1ebe244 cmd/utils: add NewApp 2015-03-09 23:08:46 +01:00
b4fa94c4b1 xeth: don't sign transactions for tx call
This should make calls faster and removes interaction
with account manager.
2015-03-09 23:08:46 +01:00
2ee88a220a core: remove Hash method from Message interface
This will simplify the next commmit. Hash was only used for logging.
2015-03-09 23:08:41 +01:00
2dacb51fb0 cmd/blocktest: simplify to fix build
block tests only need the chain, not all of ethereum.
2015-03-09 23:07:24 +01:00
a7538d0020 merge 2015-03-09 18:19:35 +01:00
27c42ea934 Add empty total difficulty to test blocks and clean up stopping the node 2015-03-09 18:03:35 +01:00
8560004f38 wip 2015-03-09 17:55:01 +01:00
676a0de58d Max size JSON data. Closes #418 2015-03-09 17:28:12 +01:00
9723191b19 Undo client_version changes 2015-03-09 11:04:38 -05:00
fb23a0cfe0 Remove support for compiling serpent 2015-03-09 10:55:18 -05:00
20741a96ac Updated xeth instances to take extra param for ui.Interface
Please be aware that if any of the instances on xeth.frontend are called
the program will crash due to the default, temporarily, frontend
interface.
2015-03-09 13:50:05 +01:00
738d6e20f2 Added ui.Interface to xeth 2015-03-09 13:49:14 +01:00
3deb470b2d Squashed 'tests/files/' changes from b9e4e74..e390be4
e390be4 remove deprecated tests
e9e8e7b update blockchain tests - correct genesis hash
a70dd35 fix genesis hash
35964c9 update uncle tests
82c108f update blocktests - fix LLL in pre state
66f0003 update transactionTests

git-subtree-dir: tests/files
git-subtree-split: e390be4fb8421fdabea041b7bdaea3b582224f7d
2015-03-09 11:43:46 +01:00
21fd722abc Merge commit '3deb470b2d07d28040a381722022cdf8867a829a' into poc-9 2015-03-09 11:43:46 +01:00
19efebe91e Updated tests and fixed suicide 2015-03-09 11:28:35 +01:00
c1cafb56d5 Squashed 'tests/files/' changes from 05fe945..b9e4e74
b9e4e74 adjust gas prices
6a41300 add dajavi memory tests - OOG because of quadratic memory costs
71d80bd update genesis
72b1b52 add randomTest
4b2a090 Merge branch 'PoC9' into develop
fdf7ce0 updated basic blochain test
25c065a Merge pull request #70 from faizkhan00/patch-1
c7e1dac Rename 201501150842LARGE_DATA_IN_CALLCREATE_GOjson to 201501150842LARGE_DATA_IN_CALLCREATE_GO.json
REVERT: 05fe945 Added another pow test

git-subtree-dir: tests/files
git-subtree-split: b9e4e747f01a7b91863ffaa45fd377c251de45aa
2015-03-09 01:02:12 +01:00
93cdffca3a Merge commit 'c1cafb56d5da57a44f1d766c5299f11664b93921' into poc-9 2015-03-09 01:02:12 +01:00
41a89e18f6 version output
- make version output more verbose
- include NetworkId
- go version and os not displayed like env vars (confusing)
2015-03-08 22:50:27 +07:00
51eed7964e add export blockchain subcommand, remove BlockDo 2015-03-08 22:44:48 +07:00
e2c75b0fa1 Squashed 'tests/files/' changes from 15ce2ab..05fe945
05fe945 Added another pow test
7cf2f6b uncle header with block number = 1
d65c7a3 Merge remote-tracking branch 'origin/PoC9' into PoC9
8e05ce5 uncle tests
7c8f2b4 Merge branch 'PoC9' of github.com:ethereum/tests into PoC9
83d1f4d fixed

git-subtree-dir: tests/files
git-subtree-split: 05fe94507b92dbfbfe8c198df33160eaaf9e87fc
2015-03-08 15:29:27 +01:00
30584c7cfb Merge commit 'e2c75b0fa17394553b93fe7ddd62c0f6a6441119' into poc-9 2015-03-08 15:29:27 +01:00
5dfc67efbd ignore 2015-03-08 15:29:23 +01:00
0743d68d4c rename constructor New 2015-03-08 20:17:20 +07:00
97dc4edb45 natspec for poc-9
- put natspec.js in a heredoc string (to help binary)
- constructor takes no args, just sets up js vm
- API: only exports Notice(transaction, abi, method, expression string) (string, error)
- effort to turn natspec.js error strings to proper go errors
- test errors
2015-03-08 20:09:13 +07:00
6684ef201a accounts: don't store address in unlocked and add commentary
This was suggested during review.
2015-03-08 02:47:05 +01:00
fb53a9362e accounts: AccountManager -> Manager 2015-03-08 01:58:35 +01:00
3750ec7b7d accounts: prevent early drops and zero keys in memory when dropping
Private keys would be locked early if SignLocked was called more than
once because the unlockLater was still running. Terminate it properly.
2015-03-08 01:44:15 +01:00
f6df3740a8 ignore 2015-03-08 01:31:19 +01:00
07955b3041 merge 2015-03-08 01:09:34 +01:00
405c0ca4b0 removed 2015-03-08 01:06:59 +01:00
e189758d55 Merge branch 'poc-9' of github.com-obscure:ethereum/go-ethereum into poc-9 2015-03-08 01:02:46 +01:00
8ea0444655 updated ethash 2015-03-08 01:02:39 +01:00
69920c735a Bump v 2015-03-08 00:59:26 +01:00
e26ebc3110 Updated ethereum.js 2015-03-08 00:54:18 +01:00
d6a7332993 accounts: fix uses of sync.RWMutex
RWMutexes must be write-locked when writing in order
to actually protect the writes.
2015-03-08 00:36:06 +01:00
afc530ea41 accounts: use time.Duration correctly
There is no point to using time.Duration if the value is interpreted as
milliseconds. Callers should use the standard multiplication idiom to
choose the unit. In fact, the only caller outside of the tests already
does so.
2015-03-08 00:35:23 +01:00
fda7b4c79d accounts: use pointers consistently
Account is now always a non-pointer. This will be important once
the manager starts remembering accounts.

AccountManager is now always a pointer because it contains locks
and locks cannot be copied.
2015-03-08 00:18:13 +01:00
fca652eeea Fix logger import path 2015-03-07 10:48:38 -06:00
70cbfb199d Added deploy scripts from go-build 2015-03-07 13:16:13 +01:00
a2810c06d7 cmd/ethereum: add account commands 2015-03-07 12:39:52 +01:00
d66f93cecd accounts, core, eth, xeth: use account manager for everything
The account manager is now responsible for picking the
default account and the coinbase.
2015-03-07 12:38:33 +01:00
c27c2be584 Merge pull request #435 from zsfelfoldi/poc-9
Natspec + test
2015-03-06 20:11:43 +01:00
22b493a6ff Fixed tests 2015-03-06 20:10:59 +01:00
e157147253 Now using github.com/obscuren/otto, no need for an Ethereum object
(got rid of some messy code in test)
2015-03-06 18:54:26 +01:00
cd856cb213 Separated block db from state db. Partial fix for #416 2015-03-06 18:26:16 +01:00
ed84b58af5 Debug option for VM & command line flag 2015-03-06 16:58:52 +01:00
dc7022cd61 Increased args test coverage 2015-03-06 09:54:08 -06:00
548e104171 Merge branch 'poc-9' of github.com-obscure:ethereum/go-ethereum into poc-9 2015-03-06 16:40:21 +01:00
8d9be18b29 Queued approach to delivering chain events 2015-03-06 15:50:44 +01:00
bc45e5c6de Integrate eth_accounts and eth_transact to use new account manager
* Add from to eth_transact / xeth.Transact and add static pass in lieu
  of integrating with native Mist window for user passphrase entry
* Make eth_accounts return AccountManager.Accounts()
* Add a Generate Key menu item in Mist
2015-03-06 13:10:42 +00:00
e64f727529 Merge pull request #433 from fjl/newcli
Improved CLI
2015-03-06 14:02:16 +01:00
a91bf01429 Merge pull request #434 from fjl/poc-9
Godeps: bump github.com/ethereum/ethash
2015-03-06 13:31:41 +01:00
71e510540e Godeps: bump github.com/ethereum/ethash
This fixes the build.
2015-03-06 12:28:00 +00:00
de86403f33 cmd/ethereum: fix JS REPL exit and add support for dumb terminals
It is now possible to exit the REPL using Ctrl-C, Ctrl-D or by typing "exit".
2015-03-06 13:08:11 +01:00
b72ca57775 Merge branch 'ethersphere-blockpool3' into poc-9 2015-03-06 12:10:23 +01:00
2393de5d6b Godeps: add github.com/peterh/liner 2015-03-06 10:39:31 +01:00
23ad2f02c0 debug comments & pow handling 2015-03-06 10:22:40 +01:00
5da3d911cf Initial args tests 2015-03-06 00:03:22 -06:00
18b076861e Add web3_sha3 test 2015-03-05 22:41:55 -06:00
03dc760ca0 Tidy 2015-03-05 21:48:03 -06:00
ef9d825cfa Refactor & cleanup 2015-03-05 21:37:45 -06:00
38f6d60e6e cmd/ethereum: new JS repl with cross-platform line editing 2015-03-06 03:57:13 +01:00
bae7e93a9c cmd/ethereum: improve command line interface
The ethereum command line interface is now structured using subcommands.
These separate the different tasks it can perform.

Almost all flag names are backwards compatible.

The key tasks have not been ported to subcommands since they will be
replaced by the new accounts infrastructure very soon.
2015-03-06 03:57:13 +01:00
b67ded9f27 Natspec + test 2015-03-06 03:43:34 +01:00
f9c6bc63df Godeps: delete golang.org/x/net/websocket
It is no longer imported by any package in our tree.
2015-03-06 02:54:57 +01:00
bdba044a80 ethutil: remove Config variable
Various functions throughout the codebase used it to grab settings. This
has to stop because I want to use them without reading the config file.

These functions can now be used without reading the config first:

* ethdb.NewLDBDatabase
* ethrepl.NewJSRepl
* vm.New
2015-03-06 02:46:56 +01:00
5f4a6069c5 Merge branch 'blockpool3' of https://github.com/ethersphere/go-ethereum into ethersphere-blockpool3 2015-03-05 21:53:42 +01:00
94e543bc39 Merge pull request #431 from tgerring/jsonlogs
Structured logging updates
2015-03-05 14:32:41 -06:00
580d09084d Merge branch 'ethersphere-blockpool2' into poc-9 2015-03-05 20:38:36 +01:00
e089478a1c Merge branch 'blockpool2' of https://github.com/ethersphere/go-ethereum into ethersphere-blockpool2 2015-03-05 20:38:19 +01:00
88ff13c241 Spec changes.
* All errors during state transition result in an invalid tx
2015-03-05 19:51:25 +01:00
9067b2848a fix wonky head section loop; correct status counts 2015-03-06 01:33:57 +07:00
9f5e9eb38d Resolve storage/storageat 2015-03-05 12:26:21 -06:00
a6599404e4 Revert to hex response 2015-03-05 11:14:47 -06:00
0d8d51084f Final name changes 2015-03-05 11:07:05 -06:00
5948adfa10 Added eth.chain.received.new_block 2015-03-05 10:58:36 -06:00
fbb307cca0 Added eth.chain.new_head 2015-03-05 10:58:13 -06:00
4e8a9a1cd4 Squashed 'tests/files/' changes from 9e3fe72..15ce2ab
15ce2ab Merge remote-tracking branch 'origin/PoC9' into PoC9
5970b09 add quadratic complexity and performance test
163fa03 more info
560b844 more info
a885549 more change
5fed708 one more tiny change
213a2b8 changed test format
c20e88b Merge branch 'PoC9' of github.com:ethereum/tests into PoC9
715ed17 Added first ethash test
e26a39f update blockchain tests to latest protocol changes
34baee5 poc9 vm tests
20550d9 update block chain test due to difficulty change
597b2b3 increase gasLimit on stateTests
8f573d3 update blockchain tests - 2048 bit logs bloom
06c90e6 typo
ef935fc extra data is hex now, for real
81ab5ad extra data is hex now
b0aeba8 update blockchain tests
f862faf add tx tests
618d724 update state tests
4a989f0 update blockchainII tests
ed56e82 add more vm tests
0417655 Merge remote-tracking branch 'origin/PoC9' into PoC9
1f1cf5d update block tests
76b5a8b Fix trie formats.
325dd6d Merge branch 'PoC9' of git://github.com/ethereum/tests into PoC9
a261c5b test3
1d3ab36 again

git-subtree-dir: tests/files
git-subtree-split: 15ce2ab8e22275e7aa93742cb5f8bc63e4e50db5
2015-03-05 17:51:26 +01:00
ca1093f848 Merge commit '4e8a9a1cd4a10370fc4a888af0fb2def6f1b961b' into poc-9 2015-03-05 17:51:26 +01:00
a7181bd304 merge 2015-03-05 17:49:29 +01:00
76e4e233ad Merge branch 'poc-9' of github.com-obscure:ethereum/go-ethereum into poc-9 2015-03-05 17:48:46 +01:00
f01d745d70 Merge pull request #429 from chfast/pr/fix_vm_tests
Fix VM tests
2015-03-05 17:46:57 +01:00
d44fe4ec62 Merge branch 'develop' into poc-9 2015-03-05 17:46:40 +01:00
72bf02bf15 Merge branch 'tendermint-develop_pull_request' into develop 2015-03-05 17:46:11 +01:00
357d17ae58 Start at 0 2015-03-05 17:46:00 +01:00
1d1ba40965 Merge branch 'develop_pull_request' of https://github.com/tendermint/ethermint into tendermint-develop_pull_request 2015-03-05 17:44:18 +01:00
3b30765378 Merge pull request #426 from Gustav-Simonsson/add_blockchain_tests
Add initial implementation of block tests
2015-03-05 17:43:56 +01:00
377c8a13de Merge branch 'develop' into poc-9 2015-03-05 17:37:18 +01:00
201b09f99a Merge branch 'alexvandesande-ui' into develop 2015-03-05 17:37:09 +01:00
44b83c6ea6 Removed unused variables 2015-03-05 17:37:00 +01:00
12ca70537f Merge branch 'fjl-p2p-handshake-2' into poc-9 2015-03-05 17:26:41 +01:00
ba0c41436c Merge branch 'p2p-handshake-2' of https://github.com/fjl/go-ethereum into fjl-p2p-handshake-2 2015-03-05 17:21:32 +01:00
fabaf4f1f0 wip math 2015-03-05 17:21:16 +01:00
90ceb5218c Update RPC methods
Re-order to match spec and explicitly list unimplemented methods
2015-03-05 08:58:46 -06:00
9329e175d8 fix wonky head section loop; correct status counts 2015-03-05 20:38:23 +07:00
0af08eca1f Fix VM tests not checked 2015-03-05 14:35:27 +01:00
45afbe5d9c Merge remote-tracking branch 'upstream/poc-9' into blockpool3 2015-03-05 16:55:11 +07:00
c47866d251 Miner fixes and updates (including miner) 2015-03-05 09:14:58 +01:00
7315962880 use ethash.Verify in blockpool 2015-03-05 11:22:36 +07:00
=
a6fe92194f Fixed iterator bug which skips the 0x000...000 key 2015-03-05 01:47:49 +00:00
1576551741 Output 0x0 instead of 0x 2015-03-04 14:13:31 -06:00
178798ef87 network back to local files 2015-03-04 16:31:48 -03:00
871dfd399b Add initial implementation of block tests
* Add blocktest cmd and support for block tests files in
  tests/BlockTests , the launched node does not connect to
  network, resets state with a genesis block from the test file
  and starts the RPC API
2015-03-04 20:27:09 +01:00
671e38fb65 Fixed Average Return calculation 2015-03-04 15:13:57 -03:00
e1bae3771e updated network app to latest build 2015-03-04 12:59:17 -03:00
215c763d53 eth, p2p: delete p2p.Blacklist
It is unused and untested right now. We can
bring it back later if required.
2015-03-04 16:54:36 +01:00
429828cd92 p2p: reject messages that cannot be written as simple RLPx frames
Until chunked frames are implemented we cannot send messages
with a size overflowing uint24.
2015-03-04 16:42:01 +01:00
22659a7fea p2p: restore read/write timeouts
They got lost in the transition to rlpxFrameRW.
2015-03-04 16:42:00 +01:00
9b0f00baf3 Output net_peerCount as hex 2015-03-04 08:41:13 -06:00
93141f4b6d Return block number as hex 2015-03-04 08:27:34 -06:00
c3deafabda Update NewTXArgs to accept hex 2015-03-04 08:22:59 -06:00
c92e48ce3f Add client_version RPC message 2015-03-04 07:54:10 -06:00
5f25c117eb Merge branch 'develop' into ui 2015-03-04 10:04:07 -03:00
cf880f78d5 network dashboard is now a local file 2015-03-04 10:02:11 -03:00
6e7e5d5fd5 eth, whisper: fix msg.Payload reads 2015-03-04 13:25:01 +01:00
7964f30dcb p2p: msg.Payload contains list data
With RLPx frames, the message code is contained in the
frame and is no longer part of the encoded data.

EncodeMsg, Msg.Decode have been updated to match.
Code that decodes RLP directly from Msg.Payload will need
to change.
2015-03-04 12:27:24 +01:00
21649100b1 p2p: verify protocol handshake node ID 2015-03-04 12:27:24 +01:00
7d39fd6678 p2p: make encryption handshake code easier to follow
This mostly changes how information is passed around.
Instead of using many function parameters and return values,
put the entire state in a struct and pass that.

This also adds back derivation of ecdhe-shared-secret. I deleted
it by accident in a previous refactoring.
2015-03-04 12:27:24 +01:00
2c505efd1e p2p/discover: add NodeID.Pubkey 2015-03-04 12:27:24 +01:00
d344054e5a p2p: make RLPx frame MAC 16 bytes as defined in the spec 2015-03-04 12:27:24 +01:00
d084aed5e9 p2p: delete frameRW 2015-03-04 12:27:24 +01:00
736e632215 p2p: use RLPx frames for messaging 2015-03-04 12:27:23 +01:00
51e01cceca p2p: encrypted and authenticated RLPx frame I/O 2015-03-04 12:27:23 +01:00
936dd0f3bc p2p: add basic RLPx frame I/O 2015-03-04 12:27:23 +01:00
15f491e500 Clean up REPL 2015-03-04 12:18:26 +01:00
5817dab89e Merge branch 'develop' into poc-9 2015-03-04 10:51:44 +01:00
a56243075a removed double flag. Closes #421 2015-03-04 10:51:17 +01:00
84a4f761f3 uncle validation 2015-03-04 10:49:56 +01:00
d4d505c868 Fixed genesis 2015-03-03 21:48:05 +01:00
08fd0715f9 updated genesis 2015-03-03 21:09:29 +01:00
26de12d9bf Changed nonce to a uint64 2015-03-03 21:04:31 +01:00
2b3c55f20d Merge pull request #413 from chfast/pr/jit_build_fixes
JIT build fixes
2015-03-03 20:39:51 +01:00
e9f1e868e2 Merge branch 'develop' into poc-9 2015-03-03 20:38:46 +01:00
827ea43478 removed all old filters 2015-03-03 20:38:28 +01:00
bb152612e0 Merge branch 'develop' into poc-9
Conflicts:
	cmd/utils/cmd.go
2015-03-03 20:34:48 +01:00
cfe3af099c Merge branch 'ethersphere-jsonlogs' into poc-9 2015-03-03 20:31:12 +01:00
f0b2ea64fc Merge branch 'jsonlogs' of https://github.com/ethersphere/go-ethereum into ethersphere-jsonlogs
Conflicts:
	eth/block_pool.go
	eth/block_pool_test.go
	eth/protocol_test.go
	miner/worker.go
2015-03-03 20:30:05 +01:00
2707891966 Merge branch 'ethersphere-blockpool2' into poc-9 2015-03-03 20:27:15 +01:00
d8a68dc0f1 Merge branch 'blockpool2' of https://github.com/ethersphere/go-ethereum into ethersphere-blockpool2 2015-03-03 20:26:59 +01:00
253eb778d1 Merge pull request #411 from ethersphere/readme
[WIP] Update Readme
2015-03-03 20:17:51 +01:00
988391fc37 Merge pull request #409 from tgerring/jsonlogs
Updated JSON log events
2015-03-03 20:16:55 +01:00
b1603f166e Merge pull request #408 from tgerring/removews
Remove Websockets RPC transport
2015-03-03 20:16:16 +01:00
8e995b97cc Fixes and debug added 2015-03-03 20:13:11 +01:00
2c616bd279 partial fix to idle best peer issue
- best peer cannot be idle for more than idleBestPeerTimeout
- introduce ErrIdleTooLong fatal error
- modify default values
2015-03-04 02:06:15 +07:00
8c2940a98b updating to new network health page 2015-03-03 15:00:34 -03:00
40ff3cac39 merge 2015-03-03 17:56:36 +01:00
53b5a45856 Merge branch 'xcthulhu-publictests' into poc-9 2015-03-03 17:55:29 +01:00
313fe3861b fixed pow stuff 2015-03-03 17:55:23 +01:00
22b132e28f Merge branch 'publictests' of https://github.com/xcthulhu/go-ethereum into xcthulhu-publictests 2015-03-03 17:20:34 +01:00
b0aaa77f02 changed message 2015-03-03 17:20:10 +01:00
ee0a1bec6c GasLimit check updated 2015-03-03 17:05:51 +01:00
c74c07eed1 Fixed error for invalid transaction 2015-03-03 16:20:38 +01:00
6518da7c01 Merge commit 'a6e04ab05150d1b5aa4adb297f3e5146b1559b02' into poc-9 2015-03-03 15:39:34 +01:00
a6e04ab051 Squashed 'tests/files/' changes from 13be3e3..9e3fe72
9e3fe72 update state root hash

git-subtree-dir: tests/files
git-subtree-split: 9e3fe720e3d46f046e06a91e45c881e79557f721
2015-03-03 15:39:33 +01:00
651b2158ba Merge commit '42a210b571b9358df16da148d9724c2ef9abbca5' into poc-9 2015-03-03 15:16:52 +01:00
42a210b571 Squashed 'tests/files/' changes from 402e748..13be3e3
13be3e3 update

git-subtree-dir: tests/files
git-subtree-split: 13be3e33afa8d708786f82b63bf874138f05bb02
2015-03-03 15:16:52 +01:00
9f359dfffa Merge commit 'd9d40888ce9498b25925ccbf1447b1f62597aa2f' into poc-9 2015-03-03 13:56:59 +01:00
d9d40888ce Squashed 'tests/files/' changes from 2bfb7db..402e748
402e748 Merge branch 'PoC9' of github.com:/ethereum/tests into PoC9
13b6a99 State test refill.

git-subtree-dir: tests/files
git-subtree-split: 402e7482f9283e08869b3412329e24ef6287d8c7
2015-03-03 13:56:59 +01:00
2a50931684 Merge commit '0867e4fae96c0b0d234f1710119a129f8b0d96f7' into poc-9 2015-03-03 13:29:59 +01:00
0867e4fae9 Squashed 'tests/files/' changes from 6f75ca3..2bfb7db
2bfb7db update memory test
88f32fa Merge remote-tracking branch 'origin/PoC9' into PoC9
a1f73f9 update gas costs
e16b5d3 Move over to key value rather than array of arrays since they're unordered and no duplicates.
ac11bbc Merge branch 'PoC9' of github.com:/ethereum/tests into PoC9
93ae304 Move to non-repeated.
fd9e406 Added test 2

git-subtree-dir: tests/files
git-subtree-split: 2bfb7dbe09c62319b28a2c2873caf7e7e99bf32a
2015-03-03 13:29:59 +01:00
fa831206c6 Updated gast costs 2015-03-03 13:29:52 +01:00
e72173dc43 Fix JitVm build 2015-03-03 12:31:26 +01:00
4659b51b50 Squashed 'tests/files/' changes from 998e275..6f75ca3
6f75ca3 Merge remote-tracking branch 'origin/PoC9' into PoC9
8d22687 update state root - DEBUG

git-subtree-dir: tests/files
git-subtree-split: 6f75ca354f239fa30f4e07754ede575aed24bbc2
2015-03-03 12:31:09 +01:00
ffa6b99ab6 Merge commit '4659b51b50394c596f0548eb53390c80ba96e392' into poc-9 2015-03-03 12:31:09 +01:00
524bf9e858 wup 2015-03-03 12:30:57 +01:00
b7ec9fbb0e Squashed 'tests/files/' changes from a3d44ca..998e275
998e275 renamed
089e346 Added hex encoded securetrie test
cdefad8 Update VM tests.
ec0a309 update state root
b3d223e update state root hash
171a945 update memory teste

git-subtree-dir: tests/files
git-subtree-split: 998e2756b5491c760f6624c62ebc09e86197c31f
2015-03-03 12:26:24 +01:00
e73d7725df Merge commit 'b7ec9fbb0e49e345a8a2566226a76d50b48266a7' into poc-9 2015-03-03 12:26:24 +01:00
b909a5ec18 Trie => SecureTrie 2015-03-03 12:25:44 +01:00
1650b59cd9 Delet => Delete 2015-03-03 12:21:27 +01:00
bf5365b317 Delet => Delete 2015-03-03 12:15:58 +01:00
ba0a758d8c Quad mem & log changes 2015-03-03 11:56:43 +01:00
49da6a8d80 Fixed test helper 2015-03-03 11:56:28 +01:00
34ee5ab9a8 Bloom expanded by 4 2015-03-03 11:56:12 +01:00
fa910966ed Redone rlp 2015-03-03 11:18:50 +01:00
d0354b8440 Squashed 'tests/files/' changes from c6111e6..a3d44ca
a3d44ca update state tests to PoC9
709d6a7 update stSystemOperationsTest.json
3188f77 fix jumpdest requirements
202b69a remove memory test
41b4e1d add memory tests
2597bdf Merge remote-tracking branch 'origin/PoC9' into PoC9
0de34b2 add stateRoot to state tests
10b4ced Remove unneeded tests.
88eb6bf Fix for tests.
9010f17 Test updates.

git-subtree-dir: tests/files
git-subtree-split: a3d44caae83dd48db7df176dc784c529945e90a1
2015-03-03 11:11:24 +01:00
2f647c443a Merge commit 'd0354b844028220b31f55c2cdbe9d4cc546d4b52' into poc-9 2015-03-03 11:11:24 +01:00
c1ef19bef9 quad mem 2015-03-03 11:11:11 +01:00
6c2856df23 add eth.chain.new_head log to core/chain_manager 2015-03-03 15:44:41 +07:00
fc47f0f27b add eth.chain.received.new_block log to eth protocol 2015-03-03 15:43:05 +07:00
76af536d0d block number is *big.Int, remoteID is string 2015-03-03 15:37:20 +07:00
34be795bc1 Merge remote-tracking branch 'tgerring/jsonlogs' into jsonlogs 2015-03-03 13:52:20 +07:00
7e224b6834 db name database -> blockchain in backend error message 2015-03-03 13:22:19 +07:00
de9f79133f Introducing ethash 2015-03-02 22:29:34 -05:00
080823bdee Only one uncle 2015-03-02 18:56:11 -05:00
21c373b55d Network Health Panel with mining 2015-03-02 18:39:07 -03:00
47278a6e4e log when added peer is behind (hash found in blockchain) 2015-03-03 03:39:21 +07:00
e7b33e9ae7 Move p2p.MakeName to ethutil.MakeVersion 2015-03-02 13:21:57 -06:00
af6971f823 Merge remote-tracking branch 'upstream/develop' into blockpool2 2015-03-03 02:13:41 +07:00
2dc1b7282a remove threatening coding standards section from README 2015-03-03 01:51:00 +07:00
1d8a427753 remove obsolete install script 2015-03-03 01:46:25 +07:00
deb2e50296 minor cleanup 2015-03-03 01:45:50 +07:00
c1bae04203 update README
- TLDR for godep install
- update executable section
- cleanup
- add several links to wiki
2015-03-03 01:44:29 +07:00
24003c76d1 Merge remote-tracking branch 'upstream/develop' into evmjit 2015-03-02 18:46:55 +01:00
a60a18b080 - fix peer disconnect by adding severity function to errs
- improve logging
- suicide -> removeChain
- improved status BlocksInPool calculation
2015-03-03 00:43:12 +07:00
9c6d9dfc5c Add required block number 2015-03-02 18:43:01 +01:00
41c9dc973d Squashed 'tests/files/' changes from ce7204f..c6111e6
c6111e6 New tests.

git-subtree-dir: tests/files
git-subtree-split: c6111e6b5d23766743d004707475e84848ff0ddb
2015-03-02 18:00:10 +01:00
fe7ab662f0 Merge commit '41c9dc973d2dc8614db6c1e3dbb2ec5564935368' into poc-9 2015-03-02 18:00:10 +01:00
200f66537c updated tests 2015-03-02 17:55:45 +01:00
0823254c3b Add 'tests/files/' from commit 'ce7204fa17560f6a76c7592bf5f23d29f22042d6'
git-subtree-dir: tests/files
git-subtree-mainline: 4f3f881c9b
git-subtree-split: ce7204fa17
2015-03-02 16:43:12 +01:00
fb2488235a Remove defunct calls 2015-03-02 09:36:48 -06:00
4f3f881c9b removed tests 2015-03-02 16:36:34 +01:00
540c79e6ad Rename "net" methods 2015-03-02 09:36:14 -06:00
b13735b400 updated tests 2015-03-02 16:34:03 +01:00
b383ff0b96 New gas prices model 2015-03-02 16:32:02 +01:00
ce7204fa17 rm failing tests 2015-03-02 16:20:38 +01:00
d9ea240122 rm failing random tests 2015-03-02 15:59:39 +01:00
67f3f4c1d8 vmGasCostchanges 2015-03-02 15:50:12 +01:00
a75af474f7 Fix logger import in tests 2015-03-02 08:27:26 -06:00
e31ec57f88 Add event eth.tx.received 2015-03-02 08:17:09 -06:00
0976c3024f Don't import logger as ethlogger 2015-03-02 08:15:28 -06:00
cb868a604c add secure trie tests 2015-03-02 14:32:29 +01:00
4cb0bfe939 Merge branch 'develop' of github.com:ethereum/go-ethereum into removews
Conflicts:
	cmd/ethereum/flags.go
	cmd/mist/flags.go
2015-03-02 07:06:08 -06:00
bc1d97b2a7 refine memory stress test 2015-03-02 11:45:29 +01:00
6e50a1e9f5 Filter accepts multiple topics per entry. Fixes #403 2015-03-01 19:08:26 +01:00
ac88ae86a3 GetOrNew for accessors. Fixes #404 2015-03-01 19:07:38 +01:00
cfe0370280 Remove Websockets RPC transport 2015-03-01 16:19:06 +01:00
60a2704b04 Implement eth.miner.new_block event 2015-03-01 16:09:59 +01:00
65cad14f9b Report debug hash rate 2015-02-28 23:09:49 +01:00
fdf939a6f9 Fixed miner threads for ethereum CLI 2015-02-28 23:01:41 +01:00
2dbdcf3636 move extrem memory test to stMemoryStressTest.json 2015-02-28 22:03:38 +01:00
5375dd6756 Merge pull request #69 from winsvega/develop
Fork block tests
2015-02-28 21:19:48 +01:00
cdb77f0ecd Merge pull request #402 from tgerring/rpcupdates
Set RPC listening address via param
2015-02-28 21:07:46 +01:00
43b5777709 Merge pull request #398 from tgerring/assetpath
Check source directory for assets as last resort
2015-02-28 21:06:57 +01:00
35f53abc78 more memmory hard quadratic complexity tests 2015-02-28 20:57:55 +01:00
73c52d1677 Merge branch 'ethersphere-blockpool2' into poc-9 2015-02-28 20:52:57 +01:00
ae45a39dc1 Secure trie 2015-02-28 20:52:29 +01:00
7ab13e0f17 Unused variable 2015-02-28 20:24:20 +01:00
6c0b194382 Merge branch 'develop' of github.com-obscure:ethereum/go-ethereum into develop 2015-02-28 20:14:10 +01:00
7adf065b10 Simple effective VM optimisation
Added a debug flag to the VM which determines if VM output is shown
regardless of the log level set.
2015-02-28 20:14:01 +01:00
6ea7aae29c Removed some methods from the JS REPL 2015-02-28 19:15:57 +01:00
11fbc41e4b Fork block tests 2015-02-28 20:54:09 +03:00
ba1f4bbe91 Exposing stuff for ethash 2015-02-27 20:56:24 -05:00
ea0517b539 Report RPC listening address in logs 2015-02-28 01:04:54 +01:00
f6e821fd33 Add flag to set RPC port 2015-02-28 01:00:42 +01:00
3820a65299 Merge branch 'publictests' of github.com:ebuchman/go-ethereum into ethash_pow 2015-02-27 16:13:31 -05:00
0efd6a881a public functions for making chains on the fly 2015-02-27 16:05:03 -05:00
8653db6df0 Introducign MixDigest and SeedHash 2015-02-27 15:59:33 -05:00
cb8d0fa874 more jump tests 2015-02-27 14:16:25 +01:00
fc3c7760a5 add more addmod mulmod overflow tests 2015-02-27 13:28:44 +01:00
b6155375ae add refund tests with CALL 2015-02-27 12:41:58 +01:00
ad3a21f260 Bump to latest versions for Docker 2015-02-27 00:52:01 +01:00
5a827417d9 Merge branch 'develop' of https://github.com/ethereum/go-ethereum into develop 2015-02-26 17:54:57 -05:00
a39c73672e bump last resort check out of ifelse 2015-02-26 21:04:26 +01:00
d90b71bc55 Check source directroy for assets as last resort 2015-02-26 21:01:40 +01:00
cc5c8a444d Report proper database directory. Closes #397 2015-02-26 20:36:54 +01:00
3a7c8d7ae4 Merge branch 'hotfix/0.8.5-2' into develop 2015-02-26 20:27:16 +01:00
c18ea4de14 Merge branch 'blockpool2' of https://github.com/ethersphere/go-ethereum into ethersphere-blockpool2 2015-02-26 18:39:38 +01:00
37e6870f64 wip 2015-02-26 18:39:05 +01:00
a622eccecb more mem tests - calldatacopy and return 2015-02-26 17:33:34 +01:00
a3b3d19d80 adjust test for new mem rule 2015-02-26 14:22:16 +01:00
d09cbfcf84 update to new quadratic memory cost rule 2015-02-26 13:52:05 +01:00
88913ec89b Merge remote-tracking branch 'origin' into develop 2015-02-26 12:38:57 +01:00
8058f2fdf0 low limit for difficulty is 1024 2015-02-26 12:38:32 +01:00
48276be277 Merge pull request #68 from winsvega/develop
Transaction WrongRLP tests
2015-02-26 12:26:59 +01:00
1e07358ac2 Transaction WrongRLP tests
more rlps with first zeros
2015-02-26 14:25:13 +03:00
a0cfe0d123 tests for mem at 32,64 KB +- 1, 31,32,33 for mstore and mstore8 2015-02-26 08:46:13 +01:00
a431c4a665 Merge pull request #67 from winsvega/develop
Transaction RLP Tests
2015-02-25 18:26:21 +01:00
667cafc13e Transaction RLP Tests
wrong transaction RLPs correction
2015-02-25 19:28:22 +03:00
9f3cee021e Merge pull request #66 from winsvega/develop
Block Tests
2015-02-25 15:44:19 +01:00
6016b942d6 Block Tests
Encoded transaction comment
2015-02-25 17:37:25 +03:00
afb72dc795 Block Tests
Block Rlps with invalid transactions
2015-02-25 16:53:57 +03:00
16ecda951b integrate blockpool into eth
- remove blockpool code
- remove blockpool integration test (kinda embarrassing)
- remove errors.go
2015-02-25 20:38:37 +07:00
cdc86965cb export Sendln/Sendf in logger 2015-02-25 20:04:51 +07:00
422490d75c major rewrite, reorg of blockpool + new features
- blockpool moves to its own package
- uses errs pkg for its own coded errors
- publicly settable config of params (time intervals and batchsizes)
- test helpers in subpackage
- optional TD in blocks used now to update peers chain info
- major improvement in algorithm
- fix fragility and sync/parallelisation bugs
- implement status for reporting on sync status (peers/hashes/blocks etc)
- several tests added and further corner cases covered
2015-02-25 19:34:12 +07:00
d46c7bcaf9 errs pkg for error code based errors 2015-02-25 19:21:59 +07:00
cfb120d179 more Pawel tests 2015-02-25 13:08:47 +01:00
86b14058fd add memory tests 2015-02-25 12:50:24 +01:00
978a29ab72 use 50000 bytes for CALLDATACOPY 2015-02-24 23:05:39 +01:00
36e862c989 add Pawels tests 2015-02-24 22:48:19 +01:00
33c8c2bd7e add quadratic complexity tests 2015-02-24 22:46:56 +01:00
85f765a533 Merge remote-tracking branch 'upstream/develop' into evmjit 2015-02-24 11:27:22 +01:00
e8c84bdf56 Merge remote-tracking branch 'origin/develop' into develop 2015-02-24 10:15:10 +01:00
e48576ada3 remove impossible tests, add create hash collision test 2015-02-24 10:14:36 +01:00
6e2d856d85 spelling error 2015-02-24 01:52:33 -05:00
9315ad3d2c spelling error 2015-02-24 01:46:06 -05:00
13b4ab10ae added genesis info 2015-02-24 01:36:54 -05:00
c72e2588f3 Update crypto.json 2015-02-23 18:40:06 -05:00
114c3b4efe Merge remote-tracking branch 'upstream/develop' into evmjit 2015-02-23 18:39:05 +01:00
e4f44139a1 Merge pull request #65 from romanman/develop
Introduce cryptography testing
2015-02-23 16:25:06 +01:00
f23aeb44e2 Introduce cryptography testing
+ First test case will check the interoperability
   for all clients to decrypt the cipher with AES in
   CTR mode.
2015-02-23 17:14:00 +02:00
dea6584018 Merge branch 'develop' into ui 2015-02-23 09:05:15 -03:00
bb3338df63 changes to sidebar sizes 2015-02-23 08:52:50 -03:00
cb52754e6c Merge remote-tracking branch 'origin/develop' into develop 2015-02-23 11:31:29 +01:00
48606e05c1 fix transaction tests 2015-02-23 11:28:06 +01:00
8b79ae6695 Update trieanyorder.json
In correct anyorder trie tests, where all permuations should have the same root, one can not have 2 keys with the same value.
2015-02-23 09:51:44 +01:00
94f1ca2e09 Format clean up 2015-02-22 14:10:28 -05:00
168ab2b065 consistent values please 2015-02-21 17:33:44 -05:00
b131b37451 added unpaded R value test 2015-02-21 14:43:06 -05:00
18216a6e33 undo gasMemCostChange, add some state tests 2015-02-20 20:50:32 +01:00
b392afac3c memGasCost checks 2015-02-20 15:05:11 +01:00
672f6c44b8 Remove initial allocs - it tests nothing additional and is difficult to maintain, especially with genesis contracts. See https://github.com/ethereum/tests/blob/develop/BasicTests/genesishashestest.json for that information. 2015-02-20 14:46:35 +01:00
9446489cf3 core: chain manager forking tests 2015-02-17 22:02:15 -05:00
2ba65f4fba Merge branch 'develop' of https://github.com/ethereum/go-ethereum into develop 2015-02-17 19:25:18 -05:00
7ec1b7e90a Merge remote-tracking branch 'origin/develop' into develop 2015-02-16 20:20:50 +01:00
a8c4de17da python fail 2015-02-16 20:20:15 +01:00
4b81a98e4a Merge pull request #60 from winsvega/develop
ttWrongRLPTransaction
2015-02-16 20:11:33 +03:00
beff83ecd2 Merge branch 'develop' of https://github.com/ethereum/tests into develop 2015-02-16 20:09:49 +03:00
5797752572 new transaction wrong rlp test 2015-02-16 20:08:44 +03:00
b9894c1d09 Update JIT interface to ABI 0.2: code hash added to input data, gas counter passed as int64 2015-02-16 16:27:11 +01:00
5718f96934 cppjit fails 2015-02-16 15:56:10 +01:00
ea509a6d72 more performance tests 2015-02-16 15:47:52 +01:00
dda2eb84f7 add creation txs in block tests 2015-02-16 13:02:57 +01:00
957f334012 more transaction tests 2015-02-16 13:00:21 +01:00
94af56789a first block tests 2015-02-16 12:59:44 +01:00
4ee0f90b46 Merge pull request #59 from winsvega/develop
new solidity tests, manual altered transaction tests
2015-02-13 12:47:02 +01:00
ddc830be5c new tests
solidity test
wrong transaction rlp (manual)
2015-02-13 14:20:47 +03:00
4e3377333f Merge remote-tracking branch 'origin/develop' into develop 2015-02-13 09:10:27 +01:00
a681d1ec02 performance test 2015-02-13 09:09:11 +01:00
1000b02b18 bump 2015-02-12 00:56:22 -05:00
d0a2eca19b add more transaction tests 2015-02-11 09:00:25 +01:00
ec8404c375 Merge remote-tracking branch 'origin/develop' into develop 2015-02-11 08:40:42 +01:00
766ee65328 cppjit fails 2015-02-11 08:39:55 +01:00
bf2abc3b68 Update ttTransactionTest.json 2015-02-10 21:04:04 -05:00
5a89c6f803 Update ttTransactionTest.json
updated signature
2015-02-10 20:53:43 -05:00
74e1320a0b Update ttTransactionTest.json
updated RLP
2015-02-10 20:36:27 -05:00
eaec21f199 Update ttTransactionTest.json 2015-02-10 20:29:08 -05:00
d1a31850ce added transaction tests to index.js 2015-02-10 14:38:48 -05:00
cf002a4611 undo changed due to memory gas cost rule 2015-02-10 11:22:50 +01:00
be4f40741f cppjit fail 2015-02-10 10:43:36 +01:00
348d3af0fc more memory cost tests 2015-02-09 11:20:14 +01:00
907f229757 update memory rule 2015-02-09 10:29:47 +01:00
bcc5c51630 gas failure cppjit 2015-02-07 18:09:22 +01:00
cb877734f0 cppjit fails 2015-02-07 09:56:24 +01:00
9f52408e70 sha3 performance test 2015-02-06 17:43:35 +01:00
a3780032bf failing tests from random simulation as state tests and transaction tests 2015-02-06 15:38:55 +01:00
16ab949110 cppjit wrong cmake config fail 2015-02-05 18:40:37 +01:00
0c29650bfa debug version for cppjit in dockerfile 2015-02-05 17:01:24 +01:00
af21a32cef enabled tests 2015-02-05 12:31:49 +01:00
5235124460 enabled python in tests 2015-02-05 12:09:35 +01:00
2e2e36cc72 updated python and go to new build requirement. added script to create
dockers locally
2015-02-05 12:07:12 +01:00
83258456d3 remove false tests 2015-02-04 16:23:54 +01:00
936a8c0e3b python fail 2015-02-04 16:21:06 +01:00
7bfa609f38 Merge remote-tracking branch 'origin' into develop 2015-02-04 09:48:31 +01:00
822b05106d goFail 2015-02-04 09:48:16 +01:00
c37ea26dc7 updated blockchain require 2015-02-03 17:35:36 -05:00
901ddf7737 moved blockchain tests 2015-02-03 12:45:23 -05:00
2b3ea9770b cppjit fail 2015-02-03 13:13:10 +01:00
56559162d3 RefundOverflowTest 2015-02-03 01:00:32 +01:00
ca19e52266 Create badBlockChain.json 2015-01-31 18:40:02 -05:00
e76af886bf updated test loader 2015-01-31 18:26:29 -05:00
b4b280c4ff removed old folder 2015-01-31 17:51:22 -05:00
764ed01688 move folder 2015-01-31 17:48:45 -05:00
d1c8fa6bbd Rename basicBlockChain.js to basicBlockChain.json 2015-01-31 17:47:39 -05:00
8ce498ee53 Create basicBlockChain.js 2015-01-31 17:46:24 -05:00
e125e70fa0 bump 2015-01-30 16:07:55 -05:00
5f10d982ac Update genesishashestest.json
fixed initial_alloc
2015-01-30 16:09:25 -05:00
e8e8d12168 update genesis block 2015-01-29 23:05:42 +01:00
fad4ddbcaf delete wrong tests 2015-01-29 22:50:38 +01:00
a20a5b437d Merge pull request #50 from winsvega/develop
Transaction Tests
2015-01-28 06:28:45 +01:00
2da367a2be fix unchecked slice index on tx.From() 2015-01-26 10:57:23 -08:00
d0440eef25 fixes 2015-01-25 23:28:47 +01:00
5deca66a7d fixes 2015-01-25 23:15:41 +01:00
58ec49a34d added EC2 provisioning, optimised docker for EC2, added python and
cppjit client (python not yet working)
2015-01-25 22:52:38 +01:00
382694f593 Transaction Tests
New State Tests
2015-01-23 20:27:51 +03:00
52e174b1f7 make money with transaction gas overflow 2015-01-23 15:23:56 +01:00
fd450b7f9a python fail 2015-01-23 12:04:39 +01:00
04b611df1c python fails 2015-01-23 09:57:49 +01:00
64fc464e03 add python fail 2015-01-22 23:14:12 +01:00
26e84de180 cppjit fail 2015-01-22 17:27:02 +01:00
b4e7a5b1c6 python fail 2015-01-22 17:14:50 +01:00
7f1d2b28c1 cppjit failure 2015-01-22 16:36:43 +01:00
ab0473ef93 failing python test 2015-01-22 14:12:46 +01:00
4b3e56ec23 failing python test 2015-01-22 12:17:52 +01:00
be58138100 more SHA3 tests, and random failing tests for python 2015-01-20 10:33:26 +01:00
dabbb6df65 Merge branch 'develop' of https://github.com/ethereum/tests into develop 2015-01-19 15:17:20 +01:00
8871fb4e0e add python fail 2015-01-19 15:15:41 +01:00
eecee75336 fixed sudo access 2015-01-19 15:10:08 +01:00
6e8085b839 remove old requires 2015-01-18 22:14:53 -05:00
f5ec2470db use require-all 2015-01-18 21:54:29 -05:00
df335682e4 Merge pull request #48 from sveneh/develop
Testrunner deployment
2015-01-16 14:07:37 +01:00
44a12cd070 python fail callcode (insufficient balance) 2015-01-15 11:13:20 +01:00
1287fc3266 add test with large data in callcreate 2015-01-15 09:47:55 +01:00
a5946a969f update vmSystemOperationsTest 2015-01-14 22:38:33 +01:00
6bb10ccc3b fixed testrunner 2015-01-14 18:06:28 +01:00
d30ca5aa8c added a inputLimits tests (46725 test cases) 2015-01-14 17:55:49 +01:00
489994054a re-add vmSystemOperationsTest 2015-01-14 17:53:26 +01:00
fffd981058 uses docker in tesrunner 2015-01-14 17:53:13 +01:00
9326d0a6dd Dockers for go, cpp 2015-01-14 17:03:37 +01:00
74faa30af6 first version of automatic testrunner deployment. Uses ansible, vagrant
and virtualbox
2015-01-14 16:10:33 +01:00
762a93fec8 python fail 2015-01-14 09:21:49 +01:00
f9e891909d cppjit failing on byte? 2015-01-14 09:15:47 +01:00
a6e9bab298 python fail 2015-01-13 23:07:09 +01:00
3f5a075280 python fail 2015-01-13 22:45:12 +01:00
ebf4686858 go create return different address 2015-01-13 18:30:26 +01:00
aca3181b7e more cpp-jit fails 2015-01-13 18:28:18 +01:00
fd0230e5be cppjit fail 2015-01-13 18:20:08 +01:00
0d25bb85d9 cpp-jit fail 2015-01-13 18:13:52 +01:00
54eaf239ac more failing tests 2015-01-13 16:29:04 +01:00
8d7ddf5299 new cppjit failures 2015-01-13 14:54:39 +01:00
6fd011a3b6 cppjit fail 2015-01-13 14:16:47 +01:00
a9930bfd87 first failing cppjit tests 2015-01-13 13:32:26 +01:00
6a2e82a23d python failures, blockhash, invalid jump, invalid opcode 2015-01-13 09:17:56 +01:00
1818dffaec call to precompiled contract and balance 2015-01-13 08:44:44 +01:00
55c689722a addmod mulmod div by zero tests 2015-01-12 16:25:37 +01:00
dfe77eac84 remove wrong mulmod/addmod tests 2015-01-12 16:09:51 +01:00
1aebe33a34 ADDMOD and MULMOD divison by zero 2015-01-12 14:27:08 +01:00
d70a30c056 MULMOD with modul 0 gives division by zero error 2015-01-12 13:55:00 +01:00
2577b803f6 create should return 0 2015-01-12 13:22:18 +01:00
928dde590c create with high value should fail and return 0 2015-01-12 13:08:43 +01:00
5fbb24353a include invalid opcode 0x0c 2015-01-12 12:00:02 +01:00
9f0c292144 jump outside code 2015-01-12 09:36:56 +01:00
d812c685c9 CODECOPY with size larger than codesize 2015-01-12 09:10:11 +01:00
a0008c3508 correct CREATE with zero sized init code 2015-01-10 23:51:54 +01:00
e8a131e05c remove wrong tests 2015-01-09 21:38:57 +01:00
bf798c8dec wrong memmory needed calculation for CREATE in cpp 2015-01-09 20:39:00 +01:00
53dbdf3dd2 return input offset 2015-01-09 19:16:52 +01:00
c674306973 big offset zero size for create 2015-01-09 17:33:41 +01:00
314220a00d big offset zero size for sha3 and return 2015-01-09 17:06:53 +01:00
dd866afc2e LOG0 no mem expansion despite large offset 2015-01-09 15:46:00 +01:00
b227000f19 add blockhash vm tests 2015-01-09 10:56:40 +01:00
ac2ce00e28 add random test which fail on go 2015-01-08 22:41:40 +01:00
f73731d5a4 failing python tests 2015-01-08 22:10:55 +01:00
9b9f7cffde long jumpdest list 2015-01-08 16:39:57 +01:00
eb3451142e sdiv int256.min -1 2015-01-08 15:29:07 +01:00
73ba8a48ab sdiv with negative fractional result 2015-01-08 15:14:20 +01:00
1ad28d0494 add valid jumpdest with jumpdest at beginning 2015-01-08 13:04:29 +01:00
08a72727cd more dynamic jump tests 2015-01-08 11:23:39 +01:00
0aa66f02ef jump into push data is forbidden 2015-01-07 22:33:25 +01:00
b94c610e49 jumpdests tests, OOG at max call depth, ... 2015-01-07 15:54:14 +01:00
99e6e00c34 check address input greater then 2**160 2015-01-07 11:17:09 +01:00
55f6fe4f7b check address input greater then 2**160 2015-01-07 11:16:09 +01:00
6ce9799370 added BlockHash tests 2015-01-06 20:21:11 +01:00
93bf0d6f4e zeroMemExpansionTests 2015-01-06 16:33:47 +01:00
dc087ffa97 more jumpdest test 2015-01-06 14:48:57 +01:00
63d61cb380 added blockhash tests which return 0 2015-01-06 11:50:57 +01:00
128d417f47 protocol update about call depth 2015-01-05 17:26:11 +01:00
0ace267c4f clear random tests due to protocol changes 2015-01-05 13:37:01 +01:00
2e75a216c7 new jumpdest interpretation 2015-01-02 17:05:20 +01:00
7aab71f656 added complete exp tests 2015-01-02 16:55:59 +01:00
3340f4dbfc retuning gas prices of recursive bombs to test limits 2015-01-02 14:26:55 +01:00
456b5791bb more init code, systemoperations and transaction tests 2015-01-02 14:08:55 +01:00
1f5552feb4 added balance tests 2014-12-29 20:12:29 -05:00
4d37c1cea2 added trie tests for branches on
detel
2014-12-27 20:30:42 -05:00
2fdc7bfbd1 more random tests 2014-12-27 22:46:21 +01:00
98fe404e6a Merge remote-tracking branch 'origin/develop' into develop 2014-12-23 16:36:13 +01:00
aafb5f768b first failing random tests 2014-12-23 16:35:35 +01:00
8c34e93b51 added stackOverFlow test to initCode 2014-12-23 10:01:20 -05:00
8a285d258a Merge remote-tracking branch 'origin/develop' into develop 2014-12-20 13:08:18 +01:00
a4ccc6e72e CALLCODE <-> RETURN 2014-12-20 13:07:54 +01:00
6567f9d0b2 add refund tests 2014-12-18 23:39:30 -05:00
07cfec33f8 added trieTest anyorder 2014-12-18 18:31:19 -05:00
86c3b8cfad Merge branch 'develop' of https://github.com/ethereum/tests into develop 2014-12-18 21:43:06 +01:00
b227b10f5d more refund tests 2014-12-18 21:42:41 +01:00
71b5d6e0a3 updated index.js 2014-12-18 12:13:55 -05:00
aefcb9716e transaction tests and refund tests 2014-12-18 09:31:43 +01:00
ccbf120c36 added stInitCodeTest.json 2014-12-13 23:03:21 +01:00
cbf5afdef8 update recursive create 2014-12-12 22:03:54 +01:00
a70c4b51a4 Fix return tests. 2014-12-12 17:22:41 +01:00
f146467607 Add test file. 2014-12-12 16:33:51 +01:00
c2bd8d1d7a Alter "" to null. 2014-12-12 14:27:38 +01:00
ce6344b770 Trie testing. 2014-12-12 14:22:19 +01:00
779f25d36c first random test 2014-12-11 22:59:56 +01:00
68175386c0 update gas prices 2014-12-11 21:34:50 +01:00
ad322fbb58 Log as array 2014-12-08 06:01:17 +01:00
f989f42618 state log tests 2014-12-05 15:12:12 +01:00
4bc65d1129 add calldataload, codecopy, extcodecopy tests 2014-12-04 18:18:49 +01:00
12cfae18e3 add calldataload test 2014-12-04 15:57:56 +01:00
086caf3701 protocol update (CALLCODE <-> RETURN), topics in log are arrays not sets 2014-12-03 08:31:03 +01:00
e6c92673b9 update state tests with logs 2014-12-01 21:14:08 +01:00
4089b809fb update gas costs 2014-12-01 18:19:40 +01:00
cfdca62277 Merge pull request #42 from negedzuregal/fix
vmTest fix
2014-12-01 18:04:51 +01:00
f59f89d876 vmEnvironmentalInfoTest CALLDATACOPY, CODECOPY, EXTCODECOPY fix 2014-12-01 16:18:12 +01:00
68da13fe3e vmArithmeticTest exp fix 2014-12-01 11:10:57 +01:00
2e5175e818 add vmLogTest 2014-11-30 19:55:51 +01:00
b5b9408e64 updated genesis to new header w/o min_gas_price 2014-11-30 16:27:27 +01:00
8e69fbfa98 add special tests 2014-11-21 17:42:05 -08:00
90f4f942e6 typo 2014-11-20 19:01:09 -08:00
c5e5228e0d Removed log,post,out,gas,callcreates if exception occured 2014-11-20 17:04:06 +01:00
9c0232a2b9 MakeMoney test 2014-11-19 18:19:05 +01:00
3ba0007e86 Added log sections in all vmtests + log tests 2014-11-19 16:23:04 +01:00
d84be4fe07 Merge remote-tracking branch 'origin/develop' into develop 2014-11-19 10:00:24 +01:00
c8497ab257 new push32 test and renaming 2014-11-19 10:00:02 +01:00
76d25420e1 adding test 2014-11-17 18:59:30 -08:00
0be275e757 Merge remote-tracking branch 'origin/develop' into develop 2014-11-17 22:47:34 +01:00
1d42d1d7c6 fix ecrecover2 2014-11-17 22:46:51 +01:00
d90868c307 Merge pull request #39 from wanderer/develop
added test for max call depth on creation
2014-11-17 20:26:59 +01:00
6dbcf6b0d6 spelling fix 2014-11-17 14:06:43 -05:00
6fc07a7f81 added test for max call depth on creation 2014-11-15 21:39:59 -05:00
1f38c8c0a2 Merge pull request #38 from wanderer/develop
updated test  'jeff' in trietest.json
2014-11-14 20:10:21 -05:00
cd85ca17ed Update trietest.json 2014-11-14 19:59:34 -05:00
279b284c0d Merge pull request #37 from wanderer/develop
Update trietest.json
2014-11-14 17:43:49 -05:00
6cae937e5e Update trietest.json
'emptyValues' should have the same root as 'puppy'
2014-11-14 17:20:03 -05:00
89675a7153 Merge remote-tracking branch 'origin/develop' into develop 2014-11-13 23:17:49 +01:00
f1de1cc97a Fix CallRecursiveBomb2 2014-11-13 23:17:13 +01:00
32f0c47c68 Merge pull request #36 from wanderer/develop
converted back to arrary format
2014-11-13 15:26:49 -05:00
ab50e76652 Merge pull request #35 from ethers/delOld
rename tests since they are valid opcodes that exist
2014-11-13 07:52:35 +01:00
3da90d01f6 converted back to arrary format 2014-11-12 22:22:47 -05:00
78f1e4a945 rename tests since they are valid opcodes that exist 2014-11-12 19:11:06 -08:00
d06b792cd0 minor change in CallSha256_1_nonzeroValue test 2014-11-12 07:00:17 +01:00
d434ecdcc3 Added CallSha256_1_nonzeroValue test 2014-11-12 06:56:31 +01:00
2c06f34cc0 Store return value of call to precompiled contracts 2014-11-11 18:10:26 +01:00
4b0c3b29ae Fix gas cost for OOG calls 2014-11-11 17:51:14 +01:00
63bcca7604 fix: genesis test 2014-11-11 08:59:19 +01:00
6e0310c1ea Merge remote-tracking branch 'origin/develop' into develop 2014-11-11 08:34:36 +01:00
30c266caff jump to position outside code stops execution 2014-11-11 08:33:59 +01:00
2927763d68 RandomTests were removed 2014-11-10 14:10:22 -08:00
a0fa91b2b8 Merge branch 'develop' of https://github.com/ethereum/tests into develop 2014-11-10 22:22:05 +01:00
60924843f0 Unintended Exceptions work like OOG 2014-11-10 22:21:37 +01:00
fcba866721 add StateTests 2014-11-06 14:19:59 -08:00
a441074ba4 Updated precompiled contracts test 2014-11-06 17:54:36 +01:00
0afa72c82b Added precompiledContracts tests 2014-11-06 15:27:45 +01:00
6be83dd5a1 Update gas cost for PoC7 2014-11-06 13:31:34 +01:00
c18b8ab2d3 Merge remote-tracking branch 'origin/develop' into develop 2014-11-06 09:19:53 +01:00
66c2e1f642 Updated SIGNEXTEND tests 2014-11-06 09:19:22 +01:00
9a9325822e part of 9b4e768 - Delete vmNamecoin.json 2014-11-05 16:20:26 -08:00
e229374f46 Merge remote-tracking branch 'origin/develop' into develop 2014-11-05 20:59:49 +01:00
189527e563 added dynamic jump out of code 2014-11-05 20:59:20 +01:00
9b4e768995 Delete vmNamecoin.json 2014-11-05 20:41:54 +01:00
4669b5694b Merge remote-tracking branch 'origin/develop' into develop 2014-11-05 15:00:12 +01:00
a567fedaa7 added state systemOperationsTest 2014-11-05 14:59:08 +01:00
aaba185ceb Merge pull request #32 from ethers/indexjs
updates needed per restructure
2014-11-04 12:15:40 -08:00
fa782aed93 updates needed per restructure 2014-11-04 11:28:56 -08:00
79d7cbfc4a Merge remote-tracking branch 'origin/develop' into develop 2014-11-04 13:32:11 +01:00
9120274a46 Update tests to latest protocol changes (PoC7) 2014-11-04 13:31:27 +01:00
1c1ba8d161 Merge pull request #31 from CJentzsch/develop
Restructered tests in folders in accordance to test suites
2014-11-04 13:30:52 +01:00
3aebe532e5 Updated vmNamecoin.json to new sstore prices 2014-11-03 13:58:21 +01:00
8a0be21839 Added example state test 2014-11-03 13:53:00 +01:00
83643addbc removed systemoperationstests 2014-11-03 13:36:25 +01:00
3930ca3a9a Restructered tests in folders in accordance to test suites 2014-11-03 13:22:15 +01:00
014d370b5d New SIGNEXTEND tets 2014-10-29 21:23:56 +01:00
155d449be2 New tests for BNOT and SIGNEXTEND 2014-10-29 20:59:05 +01:00
c9eae764b8 Update SSTORE gas cost and BNOT instead of NEG 2014-10-28 12:58:27 +01:00
ad2a75ac58 Added new recursive bombs 2014-10-23 16:05:49 +02:00
834c52af64 Changing gas cost to zero at stackunderflow 2014-10-23 12:01:05 +02:00
c73a8a89d2 Reverted back to original value. 2014-10-22 13:04:45 +02:00
b9a8c92422 fix spelling error 2014-10-21 17:02:52 -04:00
b48ae74af4 Added failing random tests 2014-10-21 17:26:26 +02:00
bee0a4100c Merge remote-tracking branch 'origin/master' into develop 2014-10-21 17:15:05 +02:00
5050d20b4d Merge pull request #26 from wanderer/develop
Add a package.json for node.js
2014-10-20 20:18:20 +02:00
ba35362876 turned tests into a node module 2014-10-19 23:59:47 -04:00
751668571e json was invalid and missing quotes 2014-10-16 17:08:20 -07:00
0e687cee47 Update vmEnvironmentalInfoTest.json 2014-10-16 17:13:24 +02:00
78a78e2e6c updated genesis_hash 2014-10-15 14:19:11 +02:00
b315da618b Merge pull request #23 from ethers/fix22
numbers should be strings #22
2014-10-14 10:33:26 +02:00
0a76a3a312 numbers should be strings #22 2014-10-13 14:45:30 -07:00
1f67385f13 Added some MUL tests 2014-10-11 13:18:00 +02:00
7a7e198395 Added some MUL tests 2014-10-11 13:11:59 +02:00
46eb6283ae tested new opcodes (JUMPDEST,CALLCODE) and created test for CALL/CREATE depth 2014-10-11 12:18:13 +02:00
8d38d62d10 INVALID stops the operation and doesn't cost gas 2014-10-10 18:09:41 +02:00
ed6eba7c8e Update + ABA recursive bomb which needs maximum recursion limit of 1024 2014-10-08 19:08:48 +02:00
2d72050db1 Applied recent protocol changes (PoC7) to existin tests 2014-10-08 14:37:18 +02:00
dfe66cab3f Merge remote-tracking branch 'origin/develop'
Conflicts:
	genesishashestest.json
2014-10-08 11:05:51 +02:00
1a67a96cff Merge pull request #18 from CJentzsch/develop
CallToNameRegistratorOutOfGas balance correction
2014-10-07 15:10:23 +01:00
ffd6bc97ad Merge remote-tracking branch 'origin/develop' into develop 2014-10-07 15:47:34 +02:00
9779d67b8c CallToNameRegistratorOutOfGas balance correction
Even if execution fails, the value gets transferred.
2014-10-07 15:45:53 +02:00
a4f5f45228 Merge pull request #17 from CJentzsch/develop
Added A calls B calls A contracts
2014-10-07 14:13:12 +01:00
b6d7cba499 Merge remote-tracking branch 'upstream/develop' into develop 2014-10-07 15:02:51 +02:00
865cb4083d Added A calls B calls A contracts 2014-10-07 15:02:36 +02:00
49a9f47aec Merge pull request #16 from CJentzsch/develop
corrected amount of used gas for CallToNameRegistratorOutOfGas
2014-10-07 10:56:17 +02:00
94a493b0d9 Merge remote-tracking branch 'upstream/develop' into develop 2014-10-07 10:51:32 +02:00
72853c4382 corrected amount of used gas for CallToNameRegistratorOutOfGas 2014-10-07 10:51:07 +02:00
3b0ec436e4 Merge pull request #15 from CJentzsch/develop
corrected tests and different style for storage
2014-10-07 05:52:43 +01:00
222068b9ba Merge remote-tracking branch 'upstream/develop' into develop 2014-10-06 21:17:28 +02:00
c1696531a6 corrected tests and different style for storage 2014-10-06 21:17:09 +02:00
aec3252b8e Merge pull request #14 from CJentzsch/develop
corrected gas limit in vmSystemOperationsTest
2014-10-06 09:39:46 +01:00
e17a909f70 Merge remote-tracking branch 'upstream/develop' into develop 2014-10-06 10:31:51 +02:00
33fcab5727 Bug fix, corrected gasLimit in vmSystemOperationsTest 2014-10-06 10:30:04 +02:00
25f9fd542a one more vm test 2014-10-04 15:47:00 -04:00
2d561a5373 separated out vmtests 2014-10-04 15:15:37 -04:00
b0c48fa8d6 Merge pull request #13 from CJentzsch/develop
Added comprehensive EVM test suite. All commands are tested.
2014-10-04 17:18:02 +01:00
6cae166f6f Delete tmp.json 2014-10-01 15:34:23 +02:00
4ff906fbc2 corrected CALLSTATELESS tests 2014-10-01 14:06:32 +02:00
5b3fee6806 Completed vm tests. Added ADDMOD, MULMOD, POST, CALLSTATELESS 2014-09-29 13:08:44 +02:00
9cdd218083 Added IOandFlowOperation-, PushDupSwap- and SystemOperations- tests. Removed empty storage from adresses. 2014-09-27 21:48:09 +02:00
28ed968b46 Added blockInfoTest 2014-09-23 15:49:22 +02:00
ffbd5a35b5 Added environmentalInfo- and sha3- test 2014-09-23 15:37:52 +02:00
54c14f1ff3 Added bitwise logic operation test 2014-09-22 13:06:57 +02:00
d0af113aab Added vm arithmetic test 2014-09-20 01:42:51 +02:00
cb8261a78b Update genesishashestest.json 2014-09-19 13:15:44 +02:00
4513623da1 Update keyaddrtest to be valid JSON 2014-07-22 12:24:46 +02:00
e8cb5c221d Added next/prev trie test 2014-07-21 23:30:33 -04:00
98823c04b3 Replaced with deterministic test 2014-07-14 02:51:31 -04:00
357eb21e4d Added my own random and namecoin tests (pyethereum) 2014-07-13 16:12:56 -04:00
00cd0cce8f Output hex strings. 2014-07-12 21:20:04 +02:00
ddfa3af45d Everything a string. 2014-07-10 11:28:35 +01:00
d659f469a9 Code fixes. 2014-07-10 10:16:25 +01:00
5e83ea8228 Prettier VM tests. 2014-07-06 16:17:12 +02:00
a09aae0efe Fix VM tests. 2014-07-06 15:46:01 +02:00
ec9a044a17 Merge pull request #10 from romanman/patch-1
Update vmtests.json
2014-07-04 15:56:52 +02:00
5e0123fbe1 Update vmtests.json 2014-07-04 10:23:04 +01:00
2b6da2f5f2 Update vmtests.json
arith testcase updated
2014-07-03 17:45:04 +01:00
4bb646117d Merge branch 'develop' of github.com:/ethereum/tests into develop 2014-07-02 19:43:22 +02:00
bba38980bd New tests. 2014-07-02 19:43:06 +02:00
a33b309d99 Testing submodules 2014-07-02 10:14:05 -04:00
50318217ca Testing submodules 2014-07-02 10:10:46 -04:00
57fa655522 Testing submodules 2014-07-02 10:09:08 -04:00
ea0eb0a8c8 Latest genesis block. 2014-07-01 15:19:34 +02:00
25bb76b69c Reset 2014-06-30 13:25:04 +02:00
74c6d8424e Updated wrong test 2014-06-30 12:10:06 +02:00
9ea3a60291 Fixed roots 2014-06-28 18:48:28 +02:00
5fc3ac0e92 Simple hex test. 2014-06-28 18:40:06 +02:00
edd3a00c2a Additional test for jeff. Now use the 0x... notation. 2014-06-28 18:22:18 +02:00
5021e0dd83 VM test framework updated. 2014-06-27 21:35:26 +02:00
c818d13202 Removed arrays from Trie tests JSON as per conformance guide and changed
vocabulary to match other tests.
VM test updates.
2014-06-27 18:18:24 +02:00
714770ffb3 Added Gav's new address. 2014-06-11 11:32:42 +01:00
9345bc13d4 Merge branch 'master' of github.com:ethereum/tests into develop 2014-05-30 17:50:38 +02:00
a2257f3471 VM tests. 2014-05-30 17:50:18 +02:00
78576dd3d3 changes based on new account structure nonce, balance, storage, code 2014-05-30 17:19:09 +02:00
125839e848 Merge pull request #5 from bkirwi/master
Fix invalid JSON (removed trailing comma) and add test names
2014-05-22 09:58:45 +02:00
356a3296bc Add some arbitrary test names
This should now conform to the format specified in the README.
2014-05-22 00:20:48 -04:00
42e14ec54f revert to correct data 2014-05-21 23:27:40 +08:00
4300197a74 fix: wrong sha3 hash because of the wrong rlp hex 2014-05-21 22:42:23 +08:00
a0d01b1a0b fix: wrong rlp hex 2014-05-21 22:29:53 +08:00
6bc2fc7405 Merge pull request #4 from ethers/master
fix file name that seems to have been a typo
2014-05-21 14:11:37 +02:00
c31a93c27a fix file name that seems to have been a typo 2014-05-20 15:42:39 -07:00
66bc3665c1 fix: represent integers as strings 2014-05-20 17:36:35 +02:00
ede5499da6 add: current initial alloc and genesis hashes 2014-05-20 17:21:09 +02:00
5131429abb Delete a comma
This should now be parseable as JSON.
2014-05-19 11:18:31 -04:00
f44a859331 add: case when value is long, ensure it's not get rlp encoded as node 2014-05-18 15:04:42 +08:00
e1ae4ad449 PoC-5 VM tests. 2014-05-12 14:40:47 +01:00
2b6c136dda Moved txt to json 2014-05-11 21:42:41 -04:00
cbccbf977c New commit 2014-05-08 21:54:48 -04:00
edbb8d407e Removed unneeded test, added new tests 2014-05-06 16:53:43 -04:00
45a0974f6f Merge pull request #3 from autolycus/develop
Fixed formatting and added test cases
2014-04-27 12:53:47 +01:00
5fd2a98fcb Added some new test cases for the rlp encoding. 2014-04-19 13:26:14 -07:00
4ba150954e Converted spaces to tabs to be compliant with the coding standards defined in cpp-ethereum 2014-04-19 12:48:42 -07:00
15dd8fd794 RLP tests and Trie updates. 2014-02-28 12:54:47 +00:00
33f80fef21 Hex encode tests done. 2014-02-28 11:39:35 +00:00
e1f5e12abb Fix RLP tests. 2014-02-28 11:22:49 +00:00
f87ce15ad2 Fix empty string. 2014-02-27 13:28:11 +00:00
c006ed4ffd Tests fix. 2014-02-24 10:24:39 +00:00
510ff56363 Updated the tests. 2014-02-21 18:54:08 +00:00
a0ec843832 Moved over to new format, but RLP tests still need updating. 2014-02-21 18:49:24 +00:00
660cd26f31 More docs. 2014-02-21 18:35:51 +00:00
6ad14c1a15 Added VM test suite.
Added TODO.
Renamed old files.
2014-02-21 18:33:39 +00:00
f91ad7b385 update trie algorithm 2014-01-08 11:26:58 -05:00
6da2954462 merge 2014-01-08 08:15:38 -05:00
cc4224675f Updated trie test 2014-01-07 14:35:26 -05:00
131c610da6 Merge pull request #1 from obscuren/master
Update trietest.txt
2014-01-01 06:40:54 -08:00
7613302b49 Update trietest.txt
New proposed explanatory format
2014-01-01 15:25:21 +01:00
121632bedd Added obscure's tests 2014-01-01 08:26:18 -05:00
ef6c5506c3 Fixed tests a bit 2013-12-31 19:04:48 -05:00
345e4bcfef Merge branch 'master' of github.com:ethereum/tests 2013-12-31 15:52:46 -05:00
2c81698f31 Added first three tests 2013-12-30 21:09:40 -05:00
e4bbea400f Initial commit 2013-12-30 18:09:03 -08:00
2548 changed files with 2278780 additions and 2600412 deletions

19
.gitignore vendored
View File

@ -6,10 +6,15 @@
/tmp
*/**/*un~
*/**/*.test
*un~
.DS_Store
*/**/.DS_Store
.ethtest
*/**/*tx_database*
*/**/*dapps*
Godeps/_workspace/pkg
Godeps/_workspace/bin
#*
.#*
@ -18,5 +23,15 @@
.project
.settings
cmd/ethereum/ethereum
cmd/mist/mist
deploy/osx/Mist.app
deploy/osx/Mist\ Installer.dmg
cmd/mist/assets/ext/ethereum.js/
# used by the Makefile
/build/_workspace/
/build/bin/
# travis
profile.tmp
profile.cov

6
.gitmodules vendored
View File

@ -1,3 +1,3 @@
[submodule "ethereal/assets/samplecoin"]
path = ethereal/assets/samplecoin
url = git@github.com:obscuren/SampleCoin.git
[submodule "cmd/mist/assets/ext/ethereum.js"]
path = cmd/mist/assets/ext/ethereum.js
url = https://github.com/ethereum/web3.js

View File

@ -9,4 +9,53 @@ Joseph Goulden <joegoulden@gmail.com>
Nick Savers <nicksavers@gmail.com>
Maran Hidskes <maran.hidskes@gmail.com>
Maran Hidskes <maran.hidskes@gmail.com>
Taylor Gerring <taylor.gerring@gmail.com>
Taylor Gerring <taylor.gerring@gmail.com> <taylor.gerring@ethereum.org>
Bas van Kervel <bas@ethdev.com>
Bas van Kervel <bas@ethdev.com> <basvankervel@ziggo.nl>
Bas van Kervel <bas@ethdev.com> <basvankervel@gmail.com>
Sven Ehlert <sven@ethdev.com>
Vitalik Buterin <v@buterin.com>
Marian Oancea <contact@siteshop.ro>
Christoph Jentzsch <jentzsch.software@gmail.com>
Heiko Hees <heiko@heiko.org>
Alex Leverington <alex@ethdev.com>
Alex Leverington <alex@ethdev.com> <subtly@users.noreply.github.com>
Zsolt Felföldi <zsfelfoldi@gmail.com>
Gavin Wood <i@gavwood.com>
Martin Becze <mjbecze@gmail.com>
Martin Becze <mjbecze@gmail.com> <wanderer@users.noreply.github.com>
Dimitry Khokhlov <winsvega@mail.ru>
Roman Mandeleil <roman.mandeleil@gmail.com>
Alec Perseghin <aperseghin@gmail.com>
Alon Muroch <alonmuroch@gmail.com>
Arkadiy Paronyan <arkadiy@ethdev.com>
Jae Kwon <jkwon.work@gmail.com>
Aaron Kumavis <kumavis@users.noreply.github.com>
Nick Dodson <silentcicero@outlook.com>
Jason Carver <jacarver@linkedin.com>
Jason Carver <jacarver@linkedin.com> <ut96caarrs@snkmail.com>
Joseph Chow <ethereum@outlook.com>
Joseph Chow <ethereum@outlook.com> ethers <TODO>

View File

@ -1,16 +1,11 @@
language: go
go:
- 1.4.2
before_install:
- sudo add-apt-repository ppa:beineri/opt-qt541 -y
- sudo apt-get update -qq
- sudo apt-get install -yqq libgmp3-dev libreadline6-dev qt54quickcontrols qt54webengine
install:
# - go get code.google.com/p/go.tools/cmd/goimports
# - go get github.com/golang/lint/golint
# - go get golang.org/x/tools/cmd/vet
- if ! go get code.google.com/p/go.tools/cmd/cover; then go get golang.org/x/tools/cmd/cover; fi
- go get github.com/mattn/goveralls
- go get golang.org/x/tools/cmd/cover github.com/mattn/goveralls
before_script:
# - gofmt -l -w .
# - goimports -l -w .
@ -18,12 +13,21 @@ before_script:
# - go vet ./...
# - go test -race ./...
script:
- ./gocoverage.sh
- make travis-test-with-coverage
after_success:
- if [ "$COVERALLS_TOKEN" ]; then goveralls -coverprofile=profile.cov -service=travis-ci -repotoken $COVERALLS_TOKEN; fi
env:
global:
- PKG_CONFIG_PATH=/opt/qt54/lib/pkgconfig
- LD_LIBRARY_PATH=/opt/qt54/lib
- secure: "U2U1AmkU4NJBgKR/uUAebQY87cNL0+1JHjnLOmmXwxYYyj5ralWb1aSuSH3qSXiT93qLBmtaUkuv9fberHVqrbAeVlztVdUsKAq7JMQH+M99iFkC9UiRMqHmtjWJ0ok4COD1sRYixxi21wb/JrMe3M1iL4QJVS61iltjHhVdM64="
sudo: false
addons:
apt:
packages:
- libgmp3-dev
notifications:
webhooks:
urls:
- https://webhooks.gitter.im/e/e09ccdce1048c5e03445
on_success: change
on_failure: always
on_start: false

24
AUTHORS Normal file
View File

@ -0,0 +1,24 @@
# This is the official list of go-ethereum authors for copyright purposes.
Alex Leverington <alex@ethdev.com>
Alexandre Van de Sande <alex.vandesande@ethdev.com>
Bas van Kervel <bas@ethdev.com>
Daniel A. Nagy <nagy.da@gmail.com>
Ethan Buchman <ethan@coinculture.info>
Fabian Vogelsteller <fabian@frozeman.de>
Felix Lange <fjl@twurst.com>
Gustav Simonsson <gustav.simonsson@gmail.com>
Jae Kwon <jkwon.work@gmail.com>
Jason Carver <jacarver@linkedin.com>
Jeffrey Wilcke <jeffrey@ethereum.org>
Joseph Chow <ethereum@outlook.com>
Kobi Gurkan <kobigurk@gmail.com>
Maran Hidskes <maran.hidskes@gmail.com>
Marek Kotewicz <marek.kotewicz@gmail.com>
Matthew Wampler-Doty <matthew.wampler.doty@gmail.com>
Nick Dodson <silentcicero@outlook.com>
Péter Szilágyi <peterke@gmail.com>
Taylor Gerring <taylor.gerring@gmail.com>
Viktor Trón <viktor.tron@gmail.com>
Vitalik Buterin <v@buterin.com>
Zsolt Felföldi <zsfelfoldi@gmail.com>

619
COPYING Normal file
View File

@ -0,0 +1,619 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2014 The go-ethereum Authors.
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.

165
COPYING.LESSER Normal file
View File

@ -0,0 +1,165 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.

View File

@ -1,40 +0,0 @@
FROM ubuntu:14.04.1
## Environment setup
ENV HOME /root
ENV GOPATH /root/go
ENV PATH /root/go/bin:/usr/local/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
RUN mkdir -p /root/go
ENV DEBIAN_FRONTEND noninteractive
## Install base dependencies
RUN apt-get update && apt-get upgrade -y
RUN apt-get install -y git mercurial build-essential software-properties-common wget pkg-config libgmp3-dev libreadline6-dev libpcre3-dev libpcre++-dev
## Install Qt5.4 (not required for CLI)
# RUN add-apt-repository ppa:beineri/opt-qt54-trusty -y
# RUN apt-get update -y
# RUN apt-get install -y qt54quickcontrols qt54webengine mesa-common-dev libglu1-mesa-dev
# ENV PKG_CONFIG_PATH /opt/qt54/lib/pkgconfig
# Install Golang
RUN wget https://storage.googleapis.com/golang/go1.4.1.linux-amd64.tar.gz
RUN tar -C /usr/local -xzf go*.tar.gz && go version
# this is a workaround, to make sure that docker's cache is invalidated whenever the git repo changes
ADD https://api.github.com/repos/ethereum/go-ethereum/git/refs/heads/develop file_does_not_exist
## Fetch and install go-ethereum
RUN go get -v github.com/tools/godep
RUN go get -v -d github.com/ethereum/go-ethereum/...
WORKDIR $GOPATH/src/github.com/ethereum/go-ethereum
RUN git checkout develop
RUN godep restore
RUN go install -v ./cmd/ethereum
## Run & expose JSON RPC
ENTRYPOINT ["ethereum", "-rpc=true", "-rpcport=8545"]
EXPOSE 8545

96
Godeps/Godeps.json generated
View File

@ -1,6 +1,6 @@
{
"ImportPath": "github.com/ethereum/go-ethereum",
"GoVersion": "go1.4.2",
"GoVersion": "go1.4",
"Packages": [
"./..."
],
@ -11,13 +11,22 @@
"Rev": "7dda39b2e7d5e265014674c5af696ba4186679e9"
},
{
"ImportPath": "code.google.com/p/snappy-go/snappy",
"Comment": "null-15",
"Rev": "12e4b4183793ac4b061921e7980845e750679fd0"
"ImportPath": "github.com/codegangsta/cli",
"Comment": "1.2.0-95-g9b2bd2b",
"Rev": "9b2bd2b3489748d4d0a204fa4eb2ee9e89e0ebc6"
},
{
"ImportPath": "github.com/ethereum/serpent-go",
"Rev": "5767a0dbd759d313df3f404dadb7f98d7ab51443"
"ImportPath": "github.com/davecgh/go-spew/spew",
"Rev": "3e6e67c4dcea3ac2f25fd4731abc0e1deaf36216"
},
{
"ImportPath": "github.com/ethereum/ethash",
"Comment": "v23.1-227-g8f6ccaa",
"Rev": "8f6ccaaef9b418553807a73a95cb5f49cd3ea39f"
},
{
"ImportPath": "github.com/gizak/termui",
"Rev": "bab8dce01c193d82bc04888a0a9a7814d505f532"
},
{
"ImportPath": "github.com/howeyc/fsnotify",
@ -26,7 +35,7 @@
},
{
"ImportPath": "github.com/huin/goupnp",
"Rev": "4191d8a85005844ea202fde52799681971b12dfe"
"Rev": "5cff77a69fb22f5f1774c4451ea2aab63d4d2f20"
},
{
"ImportPath": "github.com/jackpal/go-nat-pmp",
@ -37,48 +46,45 @@
"Rev": "ccfcd0245381f0c94c68f50626665eed3c6b726a"
},
{
"ImportPath": "github.com/obscuren/otto",
"Rev": "cf13cc4228c5e5ce0fe27a7aea90bc10091c4f19"
"ImportPath": "github.com/mattn/go-colorable",
"Rev": "043ae16291351db8465272edf465c9f388161627"
},
{
"ImportPath": "github.com/obscuren/qml",
"Rev": "c288002b52e905973b131089a8a7c761d4a2c36a"
"ImportPath": "github.com/mattn/go-isatty",
"Rev": "fdbe02a1b44e75977b2690062b83cf507d70c013"
},
{
"ImportPath": "github.com/rakyll/globalconf",
"Rev": "415abc325023f1a00cd2d9fa512e0e71745791a2"
"ImportPath": "github.com/mattn/go-runewidth",
"Comment": "travisish-33-g5890272",
"Rev": "5890272cd41c5103531cd7b79e428d99c9e97f76"
},
{
"ImportPath": "github.com/rakyll/goini",
"Rev": "907cca0f578a5316fb864ec6992dc3d9730ec58c"
"ImportPath": "github.com/nsf/termbox-go",
"Rev": "675ffd907b7401b8a709a5ef2249978af5616bb2"
},
{
"ImportPath": "github.com/robertkrimen/otto/ast",
"ImportPath": "github.com/peterh/liner",
"Rev": "29f6a646557d83e2b6e9ba05c45fbea9c006dbe8"
},
{
"ImportPath": "github.com/rcrowley/go-metrics",
"Rev": "a5cfc242a56ba7fa70b785f678d6214837bf93b9"
},
{
"ImportPath": "github.com/robertkrimen/otto",
"Rev": "dea31a3d392779af358ec41f77a07fcc7e9d04ba"
},
{
"ImportPath": "github.com/robertkrimen/otto/dbg",
"Rev": "dea31a3d392779af358ec41f77a07fcc7e9d04ba"
},
{
"ImportPath": "github.com/robertkrimen/otto/file",
"Rev": "dea31a3d392779af358ec41f77a07fcc7e9d04ba"
},
{
"ImportPath": "github.com/robertkrimen/otto/parser",
"Rev": "dea31a3d392779af358ec41f77a07fcc7e9d04ba"
},
{
"ImportPath": "github.com/robertkrimen/otto/registry",
"Rev": "dea31a3d392779af358ec41f77a07fcc7e9d04ba"
},
{
"ImportPath": "github.com/robertkrimen/otto/token",
"Rev": "dea31a3d392779af358ec41f77a07fcc7e9d04ba"
"ImportPath": "github.com/rs/cors",
"Rev": "6e0c3cb65fc0fdb064c743d176a620e3ca446dfb"
},
{
"ImportPath": "github.com/syndtr/goleveldb/leveldb",
"Rev": "832fa7ed4d28545eab80f19e1831fc004305cade"
"Rev": "4875955338b0a434238a31165cb87255ab6e9e4a"
},
{
"ImportPath": "github.com/syndtr/gosnappy/snappy",
"Rev": "156a073208e131d7d2e212cb749feae7c339e846"
},
{
"ImportPath": "golang.org/x/crypto/pbkdf2",
@ -93,8 +99,16 @@
"Rev": "4ed45ec682102c643324fae5dff8dab085b6c300"
},
{
"ImportPath": "golang.org/x/net/websocket",
"Rev": "59b0df9b1f7abda5aab0495ee54f408daf182ce7"
"ImportPath": "golang.org/x/net/html",
"Rev": "e0403b4e005737430c05a57aac078479844f919c"
},
{
"ImportPath": "golang.org/x/text/encoding",
"Rev": "c93e7c9fff19fb9139b5ab04ce041833add0134e"
},
{
"ImportPath": "golang.org/x/text/transform",
"Rev": "c93e7c9fff19fb9139b5ab04ce041833add0134e"
},
{
"ImportPath": "gopkg.in/check.v1",
@ -106,12 +120,8 @@
"Rev": "27c40922c40b43fe04554d8223a402af3ea333f3"
},
{
"ImportPath": "gopkg.in/qml.v1/cdata",
"Rev": "1116cb9cd8dee23f8d444ded354eb53122739f99"
},
{
"ImportPath": "gopkg.in/qml.v1/gl/glbase",
"Rev": "1116cb9cd8dee23f8d444ded354eb53122739f99"
"ImportPath": "gopkg.in/karalabe/cookiejar.v2/collections/prque",
"Rev": "8dcd6a7f4951f6ff3ee9cbb919a06d8925822e57"
}
]
}

View File

@ -1,124 +0,0 @@
// Copyright 2011 The Snappy-Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package snappy
import (
"encoding/binary"
"errors"
)
// ErrCorrupt reports that the input is invalid.
var ErrCorrupt = errors.New("snappy: corrupt input")
// DecodedLen returns the length of the decoded block.
func DecodedLen(src []byte) (int, error) {
v, _, err := decodedLen(src)
return v, err
}
// decodedLen returns the length of the decoded block and the number of bytes
// that the length header occupied.
func decodedLen(src []byte) (blockLen, headerLen int, err error) {
v, n := binary.Uvarint(src)
if n == 0 {
return 0, 0, ErrCorrupt
}
if uint64(int(v)) != v {
return 0, 0, errors.New("snappy: decoded block is too large")
}
return int(v), n, nil
}
// Decode returns the decoded form of src. The returned slice may be a sub-
// slice of dst if dst was large enough to hold the entire decoded block.
// Otherwise, a newly allocated slice will be returned.
// It is valid to pass a nil dst.
func Decode(dst, src []byte) ([]byte, error) {
dLen, s, err := decodedLen(src)
if err != nil {
return nil, err
}
if len(dst) < dLen {
dst = make([]byte, dLen)
}
var d, offset, length int
for s < len(src) {
switch src[s] & 0x03 {
case tagLiteral:
x := uint(src[s] >> 2)
switch {
case x < 60:
s += 1
case x == 60:
s += 2
if s > len(src) {
return nil, ErrCorrupt
}
x = uint(src[s-1])
case x == 61:
s += 3
if s > len(src) {
return nil, ErrCorrupt
}
x = uint(src[s-2]) | uint(src[s-1])<<8
case x == 62:
s += 4
if s > len(src) {
return nil, ErrCorrupt
}
x = uint(src[s-3]) | uint(src[s-2])<<8 | uint(src[s-1])<<16
case x == 63:
s += 5
if s > len(src) {
return nil, ErrCorrupt
}
x = uint(src[s-4]) | uint(src[s-3])<<8 | uint(src[s-2])<<16 | uint(src[s-1])<<24
}
length = int(x + 1)
if length <= 0 {
return nil, errors.New("snappy: unsupported literal length")
}
if length > len(dst)-d || length > len(src)-s {
return nil, ErrCorrupt
}
copy(dst[d:], src[s:s+length])
d += length
s += length
continue
case tagCopy1:
s += 2
if s > len(src) {
return nil, ErrCorrupt
}
length = 4 + int(src[s-2])>>2&0x7
offset = int(src[s-2])&0xe0<<3 | int(src[s-1])
case tagCopy2:
s += 3
if s > len(src) {
return nil, ErrCorrupt
}
length = 1 + int(src[s-3])>>2
offset = int(src[s-2]) | int(src[s-1])<<8
case tagCopy4:
return nil, errors.New("snappy: unsupported COPY_4 tag")
}
end := d + length
if offset > d || end > len(dst) {
return nil, ErrCorrupt
}
for ; d < end; d++ {
dst[d] = dst[d-offset]
}
}
if d != dLen {
return nil, ErrCorrupt
}
return dst[:d], nil
}

View File

@ -1,174 +0,0 @@
// Copyright 2011 The Snappy-Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package snappy
import (
"encoding/binary"
)
// We limit how far copy back-references can go, the same as the C++ code.
const maxOffset = 1 << 15
// emitLiteral writes a literal chunk and returns the number of bytes written.
func emitLiteral(dst, lit []byte) int {
i, n := 0, uint(len(lit)-1)
switch {
case n < 60:
dst[0] = uint8(n)<<2 | tagLiteral
i = 1
case n < 1<<8:
dst[0] = 60<<2 | tagLiteral
dst[1] = uint8(n)
i = 2
case n < 1<<16:
dst[0] = 61<<2 | tagLiteral
dst[1] = uint8(n)
dst[2] = uint8(n >> 8)
i = 3
case n < 1<<24:
dst[0] = 62<<2 | tagLiteral
dst[1] = uint8(n)
dst[2] = uint8(n >> 8)
dst[3] = uint8(n >> 16)
i = 4
case int64(n) < 1<<32:
dst[0] = 63<<2 | tagLiteral
dst[1] = uint8(n)
dst[2] = uint8(n >> 8)
dst[3] = uint8(n >> 16)
dst[4] = uint8(n >> 24)
i = 5
default:
panic("snappy: source buffer is too long")
}
if copy(dst[i:], lit) != len(lit) {
panic("snappy: destination buffer is too short")
}
return i + len(lit)
}
// emitCopy writes a copy chunk and returns the number of bytes written.
func emitCopy(dst []byte, offset, length int) int {
i := 0
for length > 0 {
x := length - 4
if 0 <= x && x < 1<<3 && offset < 1<<11 {
dst[i+0] = uint8(offset>>8)&0x07<<5 | uint8(x)<<2 | tagCopy1
dst[i+1] = uint8(offset)
i += 2
break
}
x = length
if x > 1<<6 {
x = 1 << 6
}
dst[i+0] = uint8(x-1)<<2 | tagCopy2
dst[i+1] = uint8(offset)
dst[i+2] = uint8(offset >> 8)
i += 3
length -= x
}
return i
}
// Encode returns the encoded form of src. The returned slice may be a sub-
// slice of dst if dst was large enough to hold the entire encoded block.
// Otherwise, a newly allocated slice will be returned.
// It is valid to pass a nil dst.
func Encode(dst, src []byte) ([]byte, error) {
if n := MaxEncodedLen(len(src)); len(dst) < n {
dst = make([]byte, n)
}
// The block starts with the varint-encoded length of the decompressed bytes.
d := binary.PutUvarint(dst, uint64(len(src)))
// Return early if src is short.
if len(src) <= 4 {
if len(src) != 0 {
d += emitLiteral(dst[d:], src)
}
return dst[:d], nil
}
// Initialize the hash table. Its size ranges from 1<<8 to 1<<14 inclusive.
const maxTableSize = 1 << 14
shift, tableSize := uint(32-8), 1<<8
for tableSize < maxTableSize && tableSize < len(src) {
shift--
tableSize *= 2
}
var table [maxTableSize]int
// Iterate over the source bytes.
var (
s int // The iterator position.
t int // The last position with the same hash as s.
lit int // The start position of any pending literal bytes.
)
for s+3 < len(src) {
// Update the hash table.
b0, b1, b2, b3 := src[s], src[s+1], src[s+2], src[s+3]
h := uint32(b0) | uint32(b1)<<8 | uint32(b2)<<16 | uint32(b3)<<24
p := &table[(h*0x1e35a7bd)>>shift]
// We need to to store values in [-1, inf) in table. To save
// some initialization time, (re)use the table's zero value
// and shift the values against this zero: add 1 on writes,
// subtract 1 on reads.
t, *p = *p-1, s+1
// If t is invalid or src[s:s+4] differs from src[t:t+4], accumulate a literal byte.
if t < 0 || s-t >= maxOffset || b0 != src[t] || b1 != src[t+1] || b2 != src[t+2] || b3 != src[t+3] {
s++
continue
}
// Otherwise, we have a match. First, emit any pending literal bytes.
if lit != s {
d += emitLiteral(dst[d:], src[lit:s])
}
// Extend the match to be as long as possible.
s0 := s
s, t = s+4, t+4
for s < len(src) && src[s] == src[t] {
s++
t++
}
// Emit the copied bytes.
d += emitCopy(dst[d:], s-t, s-s0)
lit = s
}
// Emit any final pending literal bytes and return.
if lit != len(src) {
d += emitLiteral(dst[d:], src[lit:])
}
return dst[:d], nil
}
// MaxEncodedLen returns the maximum length of a snappy block, given its
// uncompressed length.
func MaxEncodedLen(srcLen int) int {
// Compressed data can be defined as:
// compressed := item* literal*
// item := literal* copy
//
// The trailing literal sequence has a space blowup of at most 62/60
// since a literal of length 60 needs one tag byte + one extra byte
// for length information.
//
// Item blowup is trickier to measure. Suppose the "copy" op copies
// 4 bytes of data. Because of a special check in the encoding code,
// we produce a 4-byte copy only if the offset is < 65536. Therefore
// the copy op takes 3 bytes to encode, and this type of item leads
// to at most the 62/60 blowup for representing literals.
//
// Suppose the "copy" op copies 5 bytes of data. If the offset is big
// enough, it will take 5 bytes to encode the copy op. Therefore the
// worst case here is a one-byte literal followed by a five-byte copy.
// That is, 6 bytes of input turn into 7 bytes of "compressed" data.
//
// This last factor dominates the blowup, so the final estimate is:
return 32 + srcLen + srcLen/6
}

View File

@ -1,38 +0,0 @@
// Copyright 2011 The Snappy-Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Package snappy implements the snappy block-based compression format.
// It aims for very high speeds and reasonable compression.
//
// The C++ snappy implementation is at http://code.google.com/p/snappy/
package snappy
/*
Each encoded block begins with the varint-encoded length of the decoded data,
followed by a sequence of chunks. Chunks begin and end on byte boundaries. The
first byte of each chunk is broken into its 2 least and 6 most significant bits
called l and m: l ranges in [0, 4) and m ranges in [0, 64). l is the chunk tag.
Zero means a literal tag. All other values mean a copy tag.
For literal tags:
- If m < 60, the next 1 + m bytes are literal bytes.
- Otherwise, let n be the little-endian unsigned integer denoted by the next
m - 59 bytes. The next 1 + n bytes after that are literal bytes.
For copy tags, length bytes are copied from offset bytes ago, in the style of
Lempel-Ziv compression algorithms. In particular:
- For l == 1, the offset ranges in [0, 1<<11) and the length in [4, 12).
The length is 4 + the low 3 bits of m. The high 3 bits of m form bits 8-10
of the offset. The next byte is bits 0-7 of the offset.
- For l == 2, the offset ranges in [0, 1<<16) and the length in [1, 65).
The length is 1 + m. The offset is the little-endian unsigned integer
denoted by the next 2 bytes.
- For l == 3, this tag is a legacy format that is no longer supported.
*/
const (
tagLiteral = 0x00
tagCopy1 = 0x01
tagCopy2 = 0x02
tagCopy4 = 0x03
)

View File

@ -1,261 +0,0 @@
// Copyright 2011 The Snappy-Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package snappy
import (
"bytes"
"flag"
"fmt"
"io"
"io/ioutil"
"math/rand"
"net/http"
"os"
"path/filepath"
"strings"
"testing"
)
var download = flag.Bool("download", false, "If true, download any missing files before running benchmarks")
func roundtrip(b, ebuf, dbuf []byte) error {
e, err := Encode(ebuf, b)
if err != nil {
return fmt.Errorf("encoding error: %v", err)
}
d, err := Decode(dbuf, e)
if err != nil {
return fmt.Errorf("decoding error: %v", err)
}
if !bytes.Equal(b, d) {
return fmt.Errorf("roundtrip mismatch:\n\twant %v\n\tgot %v", b, d)
}
return nil
}
func TestEmpty(t *testing.T) {
if err := roundtrip(nil, nil, nil); err != nil {
t.Fatal(err)
}
}
func TestSmallCopy(t *testing.T) {
for _, ebuf := range [][]byte{nil, make([]byte, 20), make([]byte, 64)} {
for _, dbuf := range [][]byte{nil, make([]byte, 20), make([]byte, 64)} {
for i := 0; i < 32; i++ {
s := "aaaa" + strings.Repeat("b", i) + "aaaabbbb"
if err := roundtrip([]byte(s), ebuf, dbuf); err != nil {
t.Errorf("len(ebuf)=%d, len(dbuf)=%d, i=%d: %v", len(ebuf), len(dbuf), i, err)
}
}
}
}
}
func TestSmallRand(t *testing.T) {
rand.Seed(27354294)
for n := 1; n < 20000; n += 23 {
b := make([]byte, n)
for i, _ := range b {
b[i] = uint8(rand.Uint32())
}
if err := roundtrip(b, nil, nil); err != nil {
t.Fatal(err)
}
}
}
func TestSmallRegular(t *testing.T) {
for n := 1; n < 20000; n += 23 {
b := make([]byte, n)
for i, _ := range b {
b[i] = uint8(i%10 + 'a')
}
if err := roundtrip(b, nil, nil); err != nil {
t.Fatal(err)
}
}
}
func benchDecode(b *testing.B, src []byte) {
encoded, err := Encode(nil, src)
if err != nil {
b.Fatal(err)
}
// Bandwidth is in amount of uncompressed data.
b.SetBytes(int64(len(src)))
b.ResetTimer()
for i := 0; i < b.N; i++ {
Decode(src, encoded)
}
}
func benchEncode(b *testing.B, src []byte) {
// Bandwidth is in amount of uncompressed data.
b.SetBytes(int64(len(src)))
dst := make([]byte, MaxEncodedLen(len(src)))
b.ResetTimer()
for i := 0; i < b.N; i++ {
Encode(dst, src)
}
}
func readFile(b *testing.B, filename string) []byte {
src, err := ioutil.ReadFile(filename)
if err != nil {
b.Fatalf("failed reading %s: %s", filename, err)
}
if len(src) == 0 {
b.Fatalf("%s has zero length", filename)
}
return src
}
// expand returns a slice of length n containing repeated copies of src.
func expand(src []byte, n int) []byte {
dst := make([]byte, n)
for x := dst; len(x) > 0; {
i := copy(x, src)
x = x[i:]
}
return dst
}
func benchWords(b *testing.B, n int, decode bool) {
// Note: the file is OS-language dependent so the resulting values are not
// directly comparable for non-US-English OS installations.
data := expand(readFile(b, "/usr/share/dict/words"), n)
if decode {
benchDecode(b, data)
} else {
benchEncode(b, data)
}
}
func BenchmarkWordsDecode1e3(b *testing.B) { benchWords(b, 1e3, true) }
func BenchmarkWordsDecode1e4(b *testing.B) { benchWords(b, 1e4, true) }
func BenchmarkWordsDecode1e5(b *testing.B) { benchWords(b, 1e5, true) }
func BenchmarkWordsDecode1e6(b *testing.B) { benchWords(b, 1e6, true) }
func BenchmarkWordsEncode1e3(b *testing.B) { benchWords(b, 1e3, false) }
func BenchmarkWordsEncode1e4(b *testing.B) { benchWords(b, 1e4, false) }
func BenchmarkWordsEncode1e5(b *testing.B) { benchWords(b, 1e5, false) }
func BenchmarkWordsEncode1e6(b *testing.B) { benchWords(b, 1e6, false) }
// testFiles' values are copied directly from
// https://code.google.com/p/snappy/source/browse/trunk/snappy_unittest.cc.
// The label field is unused in snappy-go.
var testFiles = []struct {
label string
filename string
}{
{"html", "html"},
{"urls", "urls.10K"},
{"jpg", "house.jpg"},
{"pdf", "mapreduce-osdi-1.pdf"},
{"html4", "html_x_4"},
{"cp", "cp.html"},
{"c", "fields.c"},
{"lsp", "grammar.lsp"},
{"xls", "kennedy.xls"},
{"txt1", "alice29.txt"},
{"txt2", "asyoulik.txt"},
{"txt3", "lcet10.txt"},
{"txt4", "plrabn12.txt"},
{"bin", "ptt5"},
{"sum", "sum"},
{"man", "xargs.1"},
{"pb", "geo.protodata"},
{"gaviota", "kppkn.gtb"},
}
// The test data files are present at this canonical URL.
const baseURL = "https://snappy.googlecode.com/svn/trunk/testdata/"
func downloadTestdata(basename string) (errRet error) {
filename := filepath.Join("testdata", basename)
f, err := os.Create(filename)
if err != nil {
return fmt.Errorf("failed to create %s: %s", filename, err)
}
defer f.Close()
defer func() {
if errRet != nil {
os.Remove(filename)
}
}()
resp, err := http.Get(baseURL + basename)
if err != nil {
return fmt.Errorf("failed to download %s: %s", baseURL+basename, err)
}
defer resp.Body.Close()
_, err = io.Copy(f, resp.Body)
if err != nil {
return fmt.Errorf("failed to write %s: %s", filename, err)
}
return nil
}
func benchFile(b *testing.B, n int, decode bool) {
filename := filepath.Join("testdata", testFiles[n].filename)
if stat, err := os.Stat(filename); err != nil || stat.Size() == 0 {
if !*download {
b.Fatal("test data not found; skipping benchmark without the -download flag")
}
// Download the official snappy C++ implementation reference test data
// files for benchmarking.
if err := os.Mkdir("testdata", 0777); err != nil && !os.IsExist(err) {
b.Fatalf("failed to create testdata: %s", err)
}
for _, tf := range testFiles {
if err := downloadTestdata(tf.filename); err != nil {
b.Fatalf("failed to download testdata: %s", err)
}
}
}
data := readFile(b, filename)
if decode {
benchDecode(b, data)
} else {
benchEncode(b, data)
}
}
// Naming convention is kept similar to what snappy's C++ implementation uses.
func Benchmark_UFlat0(b *testing.B) { benchFile(b, 0, true) }
func Benchmark_UFlat1(b *testing.B) { benchFile(b, 1, true) }
func Benchmark_UFlat2(b *testing.B) { benchFile(b, 2, true) }
func Benchmark_UFlat3(b *testing.B) { benchFile(b, 3, true) }
func Benchmark_UFlat4(b *testing.B) { benchFile(b, 4, true) }
func Benchmark_UFlat5(b *testing.B) { benchFile(b, 5, true) }
func Benchmark_UFlat6(b *testing.B) { benchFile(b, 6, true) }
func Benchmark_UFlat7(b *testing.B) { benchFile(b, 7, true) }
func Benchmark_UFlat8(b *testing.B) { benchFile(b, 8, true) }
func Benchmark_UFlat9(b *testing.B) { benchFile(b, 9, true) }
func Benchmark_UFlat10(b *testing.B) { benchFile(b, 10, true) }
func Benchmark_UFlat11(b *testing.B) { benchFile(b, 11, true) }
func Benchmark_UFlat12(b *testing.B) { benchFile(b, 12, true) }
func Benchmark_UFlat13(b *testing.B) { benchFile(b, 13, true) }
func Benchmark_UFlat14(b *testing.B) { benchFile(b, 14, true) }
func Benchmark_UFlat15(b *testing.B) { benchFile(b, 15, true) }
func Benchmark_UFlat16(b *testing.B) { benchFile(b, 16, true) }
func Benchmark_UFlat17(b *testing.B) { benchFile(b, 17, true) }
func Benchmark_ZFlat0(b *testing.B) { benchFile(b, 0, false) }
func Benchmark_ZFlat1(b *testing.B) { benchFile(b, 1, false) }
func Benchmark_ZFlat2(b *testing.B) { benchFile(b, 2, false) }
func Benchmark_ZFlat3(b *testing.B) { benchFile(b, 3, false) }
func Benchmark_ZFlat4(b *testing.B) { benchFile(b, 4, false) }
func Benchmark_ZFlat5(b *testing.B) { benchFile(b, 5, false) }
func Benchmark_ZFlat6(b *testing.B) { benchFile(b, 6, false) }
func Benchmark_ZFlat7(b *testing.B) { benchFile(b, 7, false) }
func Benchmark_ZFlat8(b *testing.B) { benchFile(b, 8, false) }
func Benchmark_ZFlat9(b *testing.B) { benchFile(b, 9, false) }
func Benchmark_ZFlat10(b *testing.B) { benchFile(b, 10, false) }
func Benchmark_ZFlat11(b *testing.B) { benchFile(b, 11, false) }
func Benchmark_ZFlat12(b *testing.B) { benchFile(b, 12, false) }
func Benchmark_ZFlat13(b *testing.B) { benchFile(b, 13, false) }
func Benchmark_ZFlat14(b *testing.B) { benchFile(b, 14, false) }
func Benchmark_ZFlat15(b *testing.B) { benchFile(b, 15, false) }
func Benchmark_ZFlat16(b *testing.B) { benchFile(b, 16, false) }
func Benchmark_ZFlat17(b *testing.B) { benchFile(b, 17, false) }

View File

@ -0,0 +1,6 @@
language: go
go: 1.1
script:
- go vet ./...
- go test -v ./...

View File

@ -0,0 +1,21 @@
Copyright (C) 2013 Jeremy Saenz
All Rights Reserved.
MIT LICENSE
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@ -0,0 +1,298 @@
[![Build Status](https://travis-ci.org/codegangsta/cli.png?branch=master)](https://travis-ci.org/codegangsta/cli)
# cli.go
cli.go is simple, fast, and fun package for building command line apps in Go. The goal is to enable developers to write fast and distributable command line applications in an expressive way.
You can view the API docs here:
http://godoc.org/github.com/codegangsta/cli
## Overview
Command line apps are usually so tiny that there is absolutely no reason why your code should *not* be self-documenting. Things like generating help text and parsing command flags/options should not hinder productivity when writing a command line app.
**This is where cli.go comes into play.** cli.go makes command line programming fun, organized, and expressive!
## Installation
Make sure you have a working Go environment (go 1.1 is *required*). [See the install instructions](http://golang.org/doc/install.html).
To install `cli.go`, simply run:
```
$ go get github.com/codegangsta/cli
```
Make sure your `PATH` includes to the `$GOPATH/bin` directory so your commands can be easily used:
```
export PATH=$PATH:$GOPATH/bin
```
## Getting Started
One of the philosophies behind cli.go is that an API should be playful and full of discovery. So a cli.go app can be as little as one line of code in `main()`.
``` go
package main
import (
"os"
"github.com/codegangsta/cli"
)
func main() {
cli.NewApp().Run(os.Args)
}
```
This app will run and show help text, but is not very useful. Let's give an action to execute and some help documentation:
``` go
package main
import (
"os"
"github.com/codegangsta/cli"
)
func main() {
app := cli.NewApp()
app.Name = "boom"
app.Usage = "make an explosive entrance"
app.Action = func(c *cli.Context) {
println("boom! I say!")
}
app.Run(os.Args)
}
```
Running this already gives you a ton of functionality, plus support for things like subcommands and flags, which are covered below.
## Example
Being a programmer can be a lonely job. Thankfully by the power of automation that is not the case! Let's create a greeter app to fend off our demons of loneliness!
Start by creating a directory named `greet`, and within it, add a file, `greet.go` with the following code in it:
``` go
package main
import (
"os"
"github.com/codegangsta/cli"
)
func main() {
app := cli.NewApp()
app.Name = "greet"
app.Usage = "fight the loneliness!"
app.Action = func(c *cli.Context) {
println("Hello friend!")
}
app.Run(os.Args)
}
```
Install our command to the `$GOPATH/bin` directory:
```
$ go install
```
Finally run our new command:
```
$ greet
Hello friend!
```
cli.go also generates some bitchass help text:
```
$ greet help
NAME:
greet - fight the loneliness!
USAGE:
greet [global options] command [command options] [arguments...]
VERSION:
0.0.0
COMMANDS:
help, h Shows a list of commands or help for one command
GLOBAL OPTIONS
--version Shows version information
```
### Arguments
You can lookup arguments by calling the `Args` function on `cli.Context`.
``` go
...
app.Action = func(c *cli.Context) {
println("Hello", c.Args()[0])
}
...
```
### Flags
Setting and querying flags is simple.
``` go
...
app.Flags = []cli.Flag {
cli.StringFlag{
Name: "lang",
Value: "english",
Usage: "language for the greeting",
},
}
app.Action = func(c *cli.Context) {
name := "someone"
if len(c.Args()) > 0 {
name = c.Args()[0]
}
if c.String("lang") == "spanish" {
println("Hola", name)
} else {
println("Hello", name)
}
}
...
```
#### Alternate Names
You can set alternate (or short) names for flags by providing a comma-delimited list for the `Name`. e.g.
``` go
app.Flags = []cli.Flag {
cli.StringFlag{
Name: "lang, l",
Value: "english",
Usage: "language for the greeting",
},
}
```
That flag can then be set with `--lang spanish` or `-l spanish`. Note that giving two different forms of the same flag in the same command invocation is an error.
#### Values from the Environment
You can also have the default value set from the environment via `EnvVar`. e.g.
``` go
app.Flags = []cli.Flag {
cli.StringFlag{
Name: "lang, l",
Value: "english",
Usage: "language for the greeting",
EnvVar: "APP_LANG",
},
}
```
The `EnvVar` may also be given as a comma-delimited "cascade", where the first environment variable that resolves is used as the default.
``` go
app.Flags = []cli.Flag {
cli.StringFlag{
Name: "lang, l",
Value: "english",
Usage: "language for the greeting",
EnvVar: "LEGACY_COMPAT_LANG,APP_LANG,LANG",
},
}
```
### Subcommands
Subcommands can be defined for a more git-like command line app.
```go
...
app.Commands = []cli.Command{
{
Name: "add",
Aliases: []string{"a"},
Usage: "add a task to the list",
Action: func(c *cli.Context) {
println("added task: ", c.Args().First())
},
},
{
Name: "complete",
Aliases: []string{"c"},
Usage: "complete a task on the list",
Action: func(c *cli.Context) {
println("completed task: ", c.Args().First())
},
},
{
Name: "template",
Aliases: []string{"r"},
Usage: "options for task templates",
Subcommands: []cli.Command{
{
Name: "add",
Usage: "add a new template",
Action: func(c *cli.Context) {
println("new task template: ", c.Args().First())
},
},
{
Name: "remove",
Usage: "remove an existing template",
Action: func(c *cli.Context) {
println("removed task template: ", c.Args().First())
},
},
},
},
}
...
```
### Bash Completion
You can enable completion commands by setting the `EnableBashCompletion`
flag on the `App` object. By default, this setting will only auto-complete to
show an app's subcommands, but you can write your own completion methods for
the App or its subcommands.
```go
...
var tasks = []string{"cook", "clean", "laundry", "eat", "sleep", "code"}
app := cli.NewApp()
app.EnableBashCompletion = true
app.Commands = []cli.Command{
{
Name: "complete",
Aliases: []string{"c"},
Usage: "complete a task on the list",
Action: func(c *cli.Context) {
println("completed task: ", c.Args().First())
},
BashComplete: func(c *cli.Context) {
// This will complete if no args are passed
if len(c.Args()) > 0 {
return
}
for _, t := range tasks {
fmt.Println(t)
}
},
}
}
...
```
#### To Enable
Source the `autocomplete/bash_autocomplete` file in your `.bashrc` file while
setting the `PROG` variable to the name of your program:
`PROG=myprogram source /.../cli/autocomplete/bash_autocomplete`
## Contribution Guidelines
Feel free to put up a pull request to fix a bug or maybe add a feature. I will give it a code review and make sure that it does not break backwards compatibility. If I or any other collaborators agree that it is in line with the vision of the project, we will work with you to get the code into a mergeable state and merge it into the master branch.
If you have contributed something significant to the project, I will most likely add you as a collaborator. As a collaborator you are given the ability to merge others pull requests. It is very important that new code does not break existing code, so be careful about what code you do choose to merge. If you have any questions feel free to link @codegangsta to the issue in question and we can review it together.
If you feel like you have contributed to the project but have not yet been added as a collaborator, I probably forgot to add you. Hit @codegangsta up over email and we will get it figured out.

321
Godeps/_workspace/src/github.com/codegangsta/cli/app.go generated vendored Normal file
View File

@ -0,0 +1,321 @@
package cli
import (
"fmt"
"io"
"io/ioutil"
"os"
"strings"
"text/tabwriter"
"text/template"
"time"
)
// App is the main structure of a cli application. It is recomended that
// and app be created with the cli.NewApp() function
type App struct {
// The name of the program. Defaults to os.Args[0]
Name string
// Description of the program.
Usage string
// Version of the program
Version string
// List of commands to execute
Commands []Command
// List of flags to parse
Flags []Flag
// Boolean to enable bash completion commands
EnableBashCompletion bool
// Boolean to hide built-in help command
HideHelp bool
// Boolean to hide built-in version flag
HideVersion bool
// An action to execute when the bash-completion flag is set
BashComplete func(context *Context)
// An action to execute before any subcommands are run, but after the context is ready
// If a non-nil error is returned, no subcommands are run
Before func(context *Context) error
// An action to execute after any subcommands are run, but after the subcommand has finished
// It is run even if Action() panics
After func(context *Context) error
// The action to execute when no subcommands are specified
Action func(context *Context)
// Execute this function if the proper command cannot be found
CommandNotFound func(context *Context, command string)
// Compilation date
Compiled time.Time
// List of all authors who contributed
Authors []Author
// Name of Author (Note: Use App.Authors, this is deprecated)
Author string
// Email of Author (Note: Use App.Authors, this is deprecated)
Email string
// Writer writer to write output to
Writer io.Writer
}
// Tries to find out when this binary was compiled.
// Returns the current time if it fails to find it.
func compileTime() time.Time {
info, err := os.Stat(os.Args[0])
if err != nil {
return time.Now()
}
return info.ModTime()
}
// Creates a new cli Application with some reasonable defaults for Name, Usage, Version and Action.
func NewApp() *App {
return &App{
Name: os.Args[0],
Usage: "A new cli application",
Version: "0.0.0",
BashComplete: DefaultAppComplete,
Action: helpCommand.Action,
Compiled: compileTime(),
Writer: os.Stdout,
}
}
// Entry point to the cli app. Parses the arguments slice and routes to the proper flag/args combination
func (a *App) Run(arguments []string) (err error) {
if a.Author != "" || a.Email != "" {
a.Authors = append(a.Authors, Author{Name: a.Author, Email: a.Email})
}
if HelpPrinter == nil {
defer func() {
HelpPrinter = nil
}()
HelpPrinter = func(templ string, data interface{}) {
funcMap := template.FuncMap{
"join": strings.Join,
}
w := tabwriter.NewWriter(a.Writer, 0, 8, 1, '\t', 0)
t := template.Must(template.New("help").Funcs(funcMap).Parse(templ))
err := t.Execute(w, data)
if err != nil {
panic(err)
}
w.Flush()
}
}
// append help to commands
if a.Command(helpCommand.Name) == nil && !a.HideHelp {
a.Commands = append(a.Commands, helpCommand)
if (HelpFlag != BoolFlag{}) {
a.appendFlag(HelpFlag)
}
}
//append version/help flags
if a.EnableBashCompletion {
a.appendFlag(BashCompletionFlag)
}
if !a.HideVersion {
a.appendFlag(VersionFlag)
}
// parse flags
set := flagSet(a.Name, a.Flags)
set.SetOutput(ioutil.Discard)
err = set.Parse(arguments[1:])
nerr := normalizeFlags(a.Flags, set)
if nerr != nil {
fmt.Fprintln(a.Writer, nerr)
context := NewContext(a, set, set)
ShowAppHelp(context)
fmt.Fprintln(a.Writer)
return nerr
}
context := NewContext(a, set, set)
if err != nil {
fmt.Fprintf(a.Writer, "Incorrect Usage.\n\n")
ShowAppHelp(context)
fmt.Fprintln(a.Writer)
return err
}
if checkCompletions(context) {
return nil
}
if checkHelp(context) {
return nil
}
if checkVersion(context) {
return nil
}
if a.After != nil {
defer func() {
// err is always nil here.
// There is a check to see if it is non-nil
// just few lines before.
err = a.After(context)
}()
}
if a.Before != nil {
err := a.Before(context)
if err != nil {
return err
}
}
args := context.Args()
if args.Present() {
name := args.First()
c := a.Command(name)
if c != nil {
return c.Run(context)
}
}
// Run default Action
a.Action(context)
return nil
}
// Another entry point to the cli app, takes care of passing arguments and error handling
func (a *App) RunAndExitOnError() {
if err := a.Run(os.Args); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
}
// Invokes the subcommand given the context, parses ctx.Args() to generate command-specific flags
func (a *App) RunAsSubcommand(ctx *Context) (err error) {
// append help to commands
if len(a.Commands) > 0 {
if a.Command(helpCommand.Name) == nil && !a.HideHelp {
a.Commands = append(a.Commands, helpCommand)
if (HelpFlag != BoolFlag{}) {
a.appendFlag(HelpFlag)
}
}
}
// append flags
if a.EnableBashCompletion {
a.appendFlag(BashCompletionFlag)
}
// parse flags
set := flagSet(a.Name, a.Flags)
set.SetOutput(ioutil.Discard)
err = set.Parse(ctx.Args().Tail())
nerr := normalizeFlags(a.Flags, set)
context := NewContext(a, set, ctx.globalSet)
if nerr != nil {
fmt.Fprintln(a.Writer, nerr)
if len(a.Commands) > 0 {
ShowSubcommandHelp(context)
} else {
ShowCommandHelp(ctx, context.Args().First())
}
fmt.Fprintln(a.Writer)
return nerr
}
if err != nil {
fmt.Fprintf(a.Writer, "Incorrect Usage.\n\n")
ShowSubcommandHelp(context)
return err
}
if checkCompletions(context) {
return nil
}
if len(a.Commands) > 0 {
if checkSubcommandHelp(context) {
return nil
}
} else {
if checkCommandHelp(ctx, context.Args().First()) {
return nil
}
}
if a.After != nil {
defer func() {
// err is always nil here.
// There is a check to see if it is non-nil
// just few lines before.
err = a.After(context)
}()
}
if a.Before != nil {
err := a.Before(context)
if err != nil {
return err
}
}
args := context.Args()
if args.Present() {
name := args.First()
c := a.Command(name)
if c != nil {
return c.Run(context)
}
}
// Run default Action
a.Action(context)
return nil
}
// Returns the named command on App. Returns nil if the command does not exist
func (a *App) Command(name string) *Command {
for _, c := range a.Commands {
if c.HasName(name) {
return &c
}
}
return nil
}
func (a *App) hasFlag(flag Flag) bool {
for _, f := range a.Flags {
if flag == f {
return true
}
}
return false
}
func (a *App) appendFlag(flag Flag) {
if !a.hasFlag(flag) {
a.Flags = append(a.Flags, flag)
}
}
// Author represents someone who has contributed to a cli project.
type Author struct {
Name string // The Authors name
Email string // The Authors email
}
// String makes Author comply to the Stringer interface, to allow an easy print in the templating process
func (a Author) String() string {
e := ""
if a.Email != "" {
e = "<" + a.Email + "> "
}
return fmt.Sprintf("%v %v", a.Name, e)
}

View File

@ -0,0 +1,622 @@
package cli_test
import (
"flag"
"fmt"
"os"
"testing"
"github.com/codegangsta/cli"
)
func ExampleApp() {
// set args for examples sake
os.Args = []string{"greet", "--name", "Jeremy"}
app := cli.NewApp()
app.Name = "greet"
app.Flags = []cli.Flag{
cli.StringFlag{Name: "name", Value: "bob", Usage: "a name to say"},
}
app.Action = func(c *cli.Context) {
fmt.Printf("Hello %v\n", c.String("name"))
}
app.Author = "Harrison"
app.Email = "harrison@lolwut.com"
app.Authors = []cli.Author{cli.Author{Name: "Oliver Allen", Email: "oliver@toyshop.com"}}
app.Run(os.Args)
// Output:
// Hello Jeremy
}
func ExampleAppSubcommand() {
// set args for examples sake
os.Args = []string{"say", "hi", "english", "--name", "Jeremy"}
app := cli.NewApp()
app.Name = "say"
app.Commands = []cli.Command{
{
Name: "hello",
Aliases: []string{"hi"},
Usage: "use it to see a description",
Description: "This is how we describe hello the function",
Subcommands: []cli.Command{
{
Name: "english",
Aliases: []string{"en"},
Usage: "sends a greeting in english",
Description: "greets someone in english",
Flags: []cli.Flag{
cli.StringFlag{
Name: "name",
Value: "Bob",
Usage: "Name of the person to greet",
},
},
Action: func(c *cli.Context) {
fmt.Println("Hello,", c.String("name"))
},
},
},
},
}
app.Run(os.Args)
// Output:
// Hello, Jeremy
}
func ExampleAppHelp() {
// set args for examples sake
os.Args = []string{"greet", "h", "describeit"}
app := cli.NewApp()
app.Name = "greet"
app.Flags = []cli.Flag{
cli.StringFlag{Name: "name", Value: "bob", Usage: "a name to say"},
}
app.Commands = []cli.Command{
{
Name: "describeit",
Aliases: []string{"d"},
Usage: "use it to see a description",
Description: "This is how we describe describeit the function",
Action: func(c *cli.Context) {
fmt.Printf("i like to describe things")
},
},
}
app.Run(os.Args)
// Output:
// NAME:
// describeit - use it to see a description
//
// USAGE:
// command describeit [arguments...]
//
// DESCRIPTION:
// This is how we describe describeit the function
}
func ExampleAppBashComplete() {
// set args for examples sake
os.Args = []string{"greet", "--generate-bash-completion"}
app := cli.NewApp()
app.Name = "greet"
app.EnableBashCompletion = true
app.Commands = []cli.Command{
{
Name: "describeit",
Aliases: []string{"d"},
Usage: "use it to see a description",
Description: "This is how we describe describeit the function",
Action: func(c *cli.Context) {
fmt.Printf("i like to describe things")
},
}, {
Name: "next",
Usage: "next example",
Description: "more stuff to see when generating bash completion",
Action: func(c *cli.Context) {
fmt.Printf("the next example")
},
},
}
app.Run(os.Args)
// Output:
// describeit
// d
// next
// help
// h
}
func TestApp_Run(t *testing.T) {
s := ""
app := cli.NewApp()
app.Action = func(c *cli.Context) {
s = s + c.Args().First()
}
err := app.Run([]string{"command", "foo"})
expect(t, err, nil)
err = app.Run([]string{"command", "bar"})
expect(t, err, nil)
expect(t, s, "foobar")
}
var commandAppTests = []struct {
name string
expected bool
}{
{"foobar", true},
{"batbaz", true},
{"b", true},
{"f", true},
{"bat", false},
{"nothing", false},
}
func TestApp_Command(t *testing.T) {
app := cli.NewApp()
fooCommand := cli.Command{Name: "foobar", Aliases: []string{"f"}}
batCommand := cli.Command{Name: "batbaz", Aliases: []string{"b"}}
app.Commands = []cli.Command{
fooCommand,
batCommand,
}
for _, test := range commandAppTests {
expect(t, app.Command(test.name) != nil, test.expected)
}
}
func TestApp_CommandWithArgBeforeFlags(t *testing.T) {
var parsedOption, firstArg string
app := cli.NewApp()
command := cli.Command{
Name: "cmd",
Flags: []cli.Flag{
cli.StringFlag{Name: "option", Value: "", Usage: "some option"},
},
Action: func(c *cli.Context) {
parsedOption = c.String("option")
firstArg = c.Args().First()
},
}
app.Commands = []cli.Command{command}
app.Run([]string{"", "cmd", "my-arg", "--option", "my-option"})
expect(t, parsedOption, "my-option")
expect(t, firstArg, "my-arg")
}
func TestApp_RunAsSubcommandParseFlags(t *testing.T) {
var context *cli.Context
a := cli.NewApp()
a.Commands = []cli.Command{
{
Name: "foo",
Action: func(c *cli.Context) {
context = c
},
Flags: []cli.Flag{
cli.StringFlag{
Name: "lang",
Value: "english",
Usage: "language for the greeting",
},
},
Before: func(_ *cli.Context) error { return nil },
},
}
a.Run([]string{"", "foo", "--lang", "spanish", "abcd"})
expect(t, context.Args().Get(0), "abcd")
expect(t, context.String("lang"), "spanish")
}
func TestApp_CommandWithFlagBeforeTerminator(t *testing.T) {
var parsedOption string
var args []string
app := cli.NewApp()
command := cli.Command{
Name: "cmd",
Flags: []cli.Flag{
cli.StringFlag{Name: "option", Value: "", Usage: "some option"},
},
Action: func(c *cli.Context) {
parsedOption = c.String("option")
args = c.Args()
},
}
app.Commands = []cli.Command{command}
app.Run([]string{"", "cmd", "my-arg", "--option", "my-option", "--", "--notARealFlag"})
expect(t, parsedOption, "my-option")
expect(t, args[0], "my-arg")
expect(t, args[1], "--")
expect(t, args[2], "--notARealFlag")
}
func TestApp_CommandWithNoFlagBeforeTerminator(t *testing.T) {
var args []string
app := cli.NewApp()
command := cli.Command{
Name: "cmd",
Action: func(c *cli.Context) {
args = c.Args()
},
}
app.Commands = []cli.Command{command}
app.Run([]string{"", "cmd", "my-arg", "--", "notAFlagAtAll"})
expect(t, args[0], "my-arg")
expect(t, args[1], "--")
expect(t, args[2], "notAFlagAtAll")
}
func TestApp_Float64Flag(t *testing.T) {
var meters float64
app := cli.NewApp()
app.Flags = []cli.Flag{
cli.Float64Flag{Name: "height", Value: 1.5, Usage: "Set the height, in meters"},
}
app.Action = func(c *cli.Context) {
meters = c.Float64("height")
}
app.Run([]string{"", "--height", "1.93"})
expect(t, meters, 1.93)
}
func TestApp_ParseSliceFlags(t *testing.T) {
var parsedOption, firstArg string
var parsedIntSlice []int
var parsedStringSlice []string
app := cli.NewApp()
command := cli.Command{
Name: "cmd",
Flags: []cli.Flag{
cli.IntSliceFlag{Name: "p", Value: &cli.IntSlice{}, Usage: "set one or more ip addr"},
cli.StringSliceFlag{Name: "ip", Value: &cli.StringSlice{}, Usage: "set one or more ports to open"},
},
Action: func(c *cli.Context) {
parsedIntSlice = c.IntSlice("p")
parsedStringSlice = c.StringSlice("ip")
parsedOption = c.String("option")
firstArg = c.Args().First()
},
}
app.Commands = []cli.Command{command}
app.Run([]string{"", "cmd", "my-arg", "-p", "22", "-p", "80", "-ip", "8.8.8.8", "-ip", "8.8.4.4"})
IntsEquals := func(a, b []int) bool {
if len(a) != len(b) {
return false
}
for i, v := range a {
if v != b[i] {
return false
}
}
return true
}
StrsEquals := func(a, b []string) bool {
if len(a) != len(b) {
return false
}
for i, v := range a {
if v != b[i] {
return false
}
}
return true
}
var expectedIntSlice = []int{22, 80}
var expectedStringSlice = []string{"8.8.8.8", "8.8.4.4"}
if !IntsEquals(parsedIntSlice, expectedIntSlice) {
t.Errorf("%v does not match %v", parsedIntSlice, expectedIntSlice)
}
if !StrsEquals(parsedStringSlice, expectedStringSlice) {
t.Errorf("%v does not match %v", parsedStringSlice, expectedStringSlice)
}
}
func TestApp_DefaultStdout(t *testing.T) {
app := cli.NewApp()
if app.Writer != os.Stdout {
t.Error("Default output writer not set.")
}
}
type mockWriter struct {
written []byte
}
func (fw *mockWriter) Write(p []byte) (n int, err error) {
if fw.written == nil {
fw.written = p
} else {
fw.written = append(fw.written, p...)
}
return len(p), nil
}
func (fw *mockWriter) GetWritten() (b []byte) {
return fw.written
}
func TestApp_SetStdout(t *testing.T) {
w := &mockWriter{}
app := cli.NewApp()
app.Name = "test"
app.Writer = w
err := app.Run([]string{"help"})
if err != nil {
t.Fatalf("Run error: %s", err)
}
if len(w.written) == 0 {
t.Error("App did not write output to desired writer.")
}
}
func TestApp_BeforeFunc(t *testing.T) {
beforeRun, subcommandRun := false, false
beforeError := fmt.Errorf("fail")
var err error
app := cli.NewApp()
app.Before = func(c *cli.Context) error {
beforeRun = true
s := c.String("opt")
if s == "fail" {
return beforeError
}
return nil
}
app.Commands = []cli.Command{
cli.Command{
Name: "sub",
Action: func(c *cli.Context) {
subcommandRun = true
},
},
}
app.Flags = []cli.Flag{
cli.StringFlag{Name: "opt"},
}
// run with the Before() func succeeding
err = app.Run([]string{"command", "--opt", "succeed", "sub"})
if err != nil {
t.Fatalf("Run error: %s", err)
}
if beforeRun == false {
t.Errorf("Before() not executed when expected")
}
if subcommandRun == false {
t.Errorf("Subcommand not executed when expected")
}
// reset
beforeRun, subcommandRun = false, false
// run with the Before() func failing
err = app.Run([]string{"command", "--opt", "fail", "sub"})
// should be the same error produced by the Before func
if err != beforeError {
t.Errorf("Run error expected, but not received")
}
if beforeRun == false {
t.Errorf("Before() not executed when expected")
}
if subcommandRun == true {
t.Errorf("Subcommand executed when NOT expected")
}
}
func TestApp_AfterFunc(t *testing.T) {
afterRun, subcommandRun := false, false
afterError := fmt.Errorf("fail")
var err error
app := cli.NewApp()
app.After = func(c *cli.Context) error {
afterRun = true
s := c.String("opt")
if s == "fail" {
return afterError
}
return nil
}
app.Commands = []cli.Command{
cli.Command{
Name: "sub",
Action: func(c *cli.Context) {
subcommandRun = true
},
},
}
app.Flags = []cli.Flag{
cli.StringFlag{Name: "opt"},
}
// run with the After() func succeeding
err = app.Run([]string{"command", "--opt", "succeed", "sub"})
if err != nil {
t.Fatalf("Run error: %s", err)
}
if afterRun == false {
t.Errorf("After() not executed when expected")
}
if subcommandRun == false {
t.Errorf("Subcommand not executed when expected")
}
// reset
afterRun, subcommandRun = false, false
// run with the Before() func failing
err = app.Run([]string{"command", "--opt", "fail", "sub"})
// should be the same error produced by the Before func
if err != afterError {
t.Errorf("Run error expected, but not received")
}
if afterRun == false {
t.Errorf("After() not executed when expected")
}
if subcommandRun == false {
t.Errorf("Subcommand not executed when expected")
}
}
func TestAppNoHelpFlag(t *testing.T) {
oldFlag := cli.HelpFlag
defer func() {
cli.HelpFlag = oldFlag
}()
cli.HelpFlag = cli.BoolFlag{}
app := cli.NewApp()
err := app.Run([]string{"test", "-h"})
if err != flag.ErrHelp {
t.Errorf("expected error about missing help flag, but got: %s (%T)", err, err)
}
}
func TestAppHelpPrinter(t *testing.T) {
oldPrinter := cli.HelpPrinter
defer func() {
cli.HelpPrinter = oldPrinter
}()
var wasCalled = false
cli.HelpPrinter = func(template string, data interface{}) {
wasCalled = true
}
app := cli.NewApp()
app.Run([]string{"-h"})
if wasCalled == false {
t.Errorf("Help printer expected to be called, but was not")
}
}
func TestAppVersionPrinter(t *testing.T) {
oldPrinter := cli.VersionPrinter
defer func() {
cli.VersionPrinter = oldPrinter
}()
var wasCalled = false
cli.VersionPrinter = func(c *cli.Context) {
wasCalled = true
}
app := cli.NewApp()
ctx := cli.NewContext(app, nil, nil)
cli.ShowVersion(ctx)
if wasCalled == false {
t.Errorf("Version printer expected to be called, but was not")
}
}
func TestAppCommandNotFound(t *testing.T) {
beforeRun, subcommandRun := false, false
app := cli.NewApp()
app.CommandNotFound = func(c *cli.Context, command string) {
beforeRun = true
}
app.Commands = []cli.Command{
cli.Command{
Name: "bar",
Action: func(c *cli.Context) {
subcommandRun = true
},
},
}
app.Run([]string{"command", "foo"})
expect(t, beforeRun, true)
expect(t, subcommandRun, false)
}
func TestGlobalFlagsInSubcommands(t *testing.T) {
subcommandRun := false
app := cli.NewApp()
app.Flags = []cli.Flag{
cli.BoolFlag{Name: "debug, d", Usage: "Enable debugging"},
}
app.Commands = []cli.Command{
cli.Command{
Name: "foo",
Subcommands: []cli.Command{
{
Name: "bar",
Action: func(c *cli.Context) {
if c.GlobalBool("debug") {
subcommandRun = true
}
},
},
},
},
}
app.Run([]string{"command", "-d", "foo", "bar"})
expect(t, subcommandRun, true)
}

View File

@ -0,0 +1,13 @@
#! /bin/bash
_cli_bash_autocomplete() {
local cur prev opts base
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
opts=$( ${COMP_WORDS[@]:0:$COMP_CWORD} --generate-bash-completion )
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
}
complete -F _cli_bash_autocomplete $PROG

View File

@ -0,0 +1,5 @@
autoload -U compinit && compinit
autoload -U bashcompinit && bashcompinit
script_dir=$(dirname $0)
source ${script_dir}/bash_autocomplete

View File

@ -0,0 +1,19 @@
// Package cli provides a minimal framework for creating and organizing command line
// Go applications. cli is designed to be easy to understand and write, the most simple
// cli application can be written as follows:
// func main() {
// cli.NewApp().Run(os.Args)
// }
//
// Of course this application does not do much, so let's make this an actual application:
// func main() {
// app := cli.NewApp()
// app.Name = "greet"
// app.Usage = "say a greeting"
// app.Action = func(c *cli.Context) {
// println("Greetings")
// }
//
// app.Run(os.Args)
// }
package cli

View File

@ -0,0 +1,100 @@
package cli_test
import (
"os"
"github.com/codegangsta/cli"
)
func Example() {
app := cli.NewApp()
app.Name = "todo"
app.Usage = "task list on the command line"
app.Commands = []cli.Command{
{
Name: "add",
Aliases: []string{"a"},
Usage: "add a task to the list",
Action: func(c *cli.Context) {
println("added task: ", c.Args().First())
},
},
{
Name: "complete",
Aliases: []string{"c"},
Usage: "complete a task on the list",
Action: func(c *cli.Context) {
println("completed task: ", c.Args().First())
},
},
}
app.Run(os.Args)
}
func ExampleSubcommand() {
app := cli.NewApp()
app.Name = "say"
app.Commands = []cli.Command{
{
Name: "hello",
Aliases: []string{"hi"},
Usage: "use it to see a description",
Description: "This is how we describe hello the function",
Subcommands: []cli.Command{
{
Name: "english",
Aliases: []string{"en"},
Usage: "sends a greeting in english",
Description: "greets someone in english",
Flags: []cli.Flag{
cli.StringFlag{
Name: "name",
Value: "Bob",
Usage: "Name of the person to greet",
},
},
Action: func(c *cli.Context) {
println("Hello, ", c.String("name"))
},
}, {
Name: "spanish",
Aliases: []string{"sp"},
Usage: "sends a greeting in spanish",
Flags: []cli.Flag{
cli.StringFlag{
Name: "surname",
Value: "Jones",
Usage: "Surname of the person to greet",
},
},
Action: func(c *cli.Context) {
println("Hola, ", c.String("surname"))
},
}, {
Name: "french",
Aliases: []string{"fr"},
Usage: "sends a greeting in french",
Flags: []cli.Flag{
cli.StringFlag{
Name: "nickname",
Value: "Stevie",
Usage: "Nickname of the person to greet",
},
},
Action: func(c *cli.Context) {
println("Bonjour, ", c.String("nickname"))
},
},
},
}, {
Name: "bye",
Usage: "says goodbye",
Action: func(c *cli.Context) {
println("bye")
},
},
}
app.Run(os.Args)
}

View File

@ -0,0 +1,177 @@
package cli
import (
"fmt"
"io/ioutil"
"strings"
)
// Command is a subcommand for a cli.App.
type Command struct {
// The name of the command
Name string
// short name of the command. Typically one character (deprecated, use `Aliases`)
ShortName string
// A list of aliases for the command
Aliases []string
// A short description of the usage of this command
Usage string
// A longer explanation of how the command works
Description string
// The function to call when checking for bash command completions
BashComplete func(context *Context)
// An action to execute before any sub-subcommands are run, but after the context is ready
// If a non-nil error is returned, no sub-subcommands are run
Before func(context *Context) error
// An action to execute after any subcommands are run, but after the subcommand has finished
// It is run even if Action() panics
After func(context *Context) error
// The function to call when this command is invoked
Action func(context *Context)
// List of child commands
Subcommands []Command
// List of flags to parse
Flags []Flag
// Treat all flags as normal arguments if true
SkipFlagParsing bool
// Boolean to hide built-in help command
HideHelp bool
}
// Invokes the command given the context, parses ctx.Args() to generate command-specific flags
func (c Command) Run(ctx *Context) error {
if len(c.Subcommands) > 0 || c.Before != nil || c.After != nil {
return c.startApp(ctx)
}
if !c.HideHelp && (HelpFlag != BoolFlag{}) {
// append help to flags
c.Flags = append(
c.Flags,
HelpFlag,
)
}
if ctx.App.EnableBashCompletion {
c.Flags = append(c.Flags, BashCompletionFlag)
}
set := flagSet(c.Name, c.Flags)
set.SetOutput(ioutil.Discard)
firstFlagIndex := -1
terminatorIndex := -1
for index, arg := range ctx.Args() {
if arg == "--" {
terminatorIndex = index
break
} else if strings.HasPrefix(arg, "-") && firstFlagIndex == -1 {
firstFlagIndex = index
}
}
var err error
if firstFlagIndex > -1 && !c.SkipFlagParsing {
args := ctx.Args()
regularArgs := make([]string, len(args[1:firstFlagIndex]))
copy(regularArgs, args[1:firstFlagIndex])
var flagArgs []string
if terminatorIndex > -1 {
flagArgs = args[firstFlagIndex:terminatorIndex]
regularArgs = append(regularArgs, args[terminatorIndex:]...)
} else {
flagArgs = args[firstFlagIndex:]
}
err = set.Parse(append(flagArgs, regularArgs...))
} else {
err = set.Parse(ctx.Args().Tail())
}
if err != nil {
fmt.Fprint(ctx.App.Writer, "Incorrect Usage.\n\n")
ShowCommandHelp(ctx, c.Name)
fmt.Fprintln(ctx.App.Writer)
return err
}
nerr := normalizeFlags(c.Flags, set)
if nerr != nil {
fmt.Fprintln(ctx.App.Writer, nerr)
fmt.Fprintln(ctx.App.Writer)
ShowCommandHelp(ctx, c.Name)
fmt.Fprintln(ctx.App.Writer)
return nerr
}
context := NewContext(ctx.App, set, ctx.globalSet)
if checkCommandCompletions(context, c.Name) {
return nil
}
if checkCommandHelp(context, c.Name) {
return nil
}
context.Command = c
c.Action(context)
return nil
}
func (c Command) Names() []string {
names := []string{c.Name}
if c.ShortName != "" {
names = append(names, c.ShortName)
}
return append(names, c.Aliases...)
}
// Returns true if Command.Name or Command.ShortName matches given name
func (c Command) HasName(name string) bool {
for _, n := range c.Names() {
if n == name {
return true
}
}
return false
}
func (c Command) startApp(ctx *Context) error {
app := NewApp()
// set the name and usage
app.Name = fmt.Sprintf("%s %s", ctx.App.Name, c.Name)
if c.Description != "" {
app.Usage = c.Description
} else {
app.Usage = c.Usage
}
// set CommandNotFound
app.CommandNotFound = ctx.App.CommandNotFound
// set the flags and commands
app.Commands = c.Subcommands
app.Flags = c.Flags
app.HideHelp = c.HideHelp
// bash completion
app.EnableBashCompletion = ctx.App.EnableBashCompletion
if c.BashComplete != nil {
app.BashComplete = c.BashComplete
}
// set the actions
app.Before = c.Before
app.After = c.After
if c.Action != nil {
app.Action = c.Action
} else {
app.Action = helpSubcommand.Action
}
return app.RunAsSubcommand(ctx)
}

View File

@ -0,0 +1,49 @@
package cli_test
import (
"flag"
"testing"
"github.com/codegangsta/cli"
)
func TestCommandDoNotIgnoreFlags(t *testing.T) {
app := cli.NewApp()
set := flag.NewFlagSet("test", 0)
test := []string{"blah", "blah", "-break"}
set.Parse(test)
c := cli.NewContext(app, set, set)
command := cli.Command{
Name: "test-cmd",
Aliases: []string{"tc"},
Usage: "this is for testing",
Description: "testing",
Action: func(_ *cli.Context) {},
}
err := command.Run(c)
expect(t, err.Error(), "flag provided but not defined: -break")
}
func TestCommandIgnoreFlags(t *testing.T) {
app := cli.NewApp()
set := flag.NewFlagSet("test", 0)
test := []string{"blah", "blah"}
set.Parse(test)
c := cli.NewContext(app, set, set)
command := cli.Command{
Name: "test-cmd",
Aliases: []string{"tc"},
Usage: "this is for testing",
Description: "testing",
Action: func(_ *cli.Context) {},
SkipFlagParsing: true,
}
err := command.Run(c)
expect(t, err, nil)
}

View File

@ -0,0 +1,344 @@
package cli
import (
"errors"
"flag"
"strconv"
"strings"
"time"
)
// Context is a type that is passed through to
// each Handler action in a cli application. Context
// can be used to retrieve context-specific Args and
// parsed command-line options.
type Context struct {
App *App
Command Command
flagSet *flag.FlagSet
globalSet *flag.FlagSet
setFlags map[string]bool
globalSetFlags map[string]bool
}
// Creates a new context. For use in when invoking an App or Command action.
func NewContext(app *App, set *flag.FlagSet, globalSet *flag.FlagSet) *Context {
return &Context{App: app, flagSet: set, globalSet: globalSet}
}
// Looks up the value of a local int flag, returns 0 if no int flag exists
func (c *Context) Int(name string) int {
return lookupInt(name, c.flagSet)
}
// Looks up the value of a local time.Duration flag, returns 0 if no time.Duration flag exists
func (c *Context) Duration(name string) time.Duration {
return lookupDuration(name, c.flagSet)
}
// Looks up the value of a local float64 flag, returns 0 if no float64 flag exists
func (c *Context) Float64(name string) float64 {
return lookupFloat64(name, c.flagSet)
}
// Looks up the value of a local bool flag, returns false if no bool flag exists
func (c *Context) Bool(name string) bool {
return lookupBool(name, c.flagSet)
}
// Looks up the value of a local boolT flag, returns false if no bool flag exists
func (c *Context) BoolT(name string) bool {
return lookupBoolT(name, c.flagSet)
}
// Looks up the value of a local string flag, returns "" if no string flag exists
func (c *Context) String(name string) string {
return lookupString(name, c.flagSet)
}
// Looks up the value of a local string slice flag, returns nil if no string slice flag exists
func (c *Context) StringSlice(name string) []string {
return lookupStringSlice(name, c.flagSet)
}
// Looks up the value of a local int slice flag, returns nil if no int slice flag exists
func (c *Context) IntSlice(name string) []int {
return lookupIntSlice(name, c.flagSet)
}
// Looks up the value of a local generic flag, returns nil if no generic flag exists
func (c *Context) Generic(name string) interface{} {
return lookupGeneric(name, c.flagSet)
}
// Looks up the value of a global int flag, returns 0 if no int flag exists
func (c *Context) GlobalInt(name string) int {
return lookupInt(name, c.globalSet)
}
// Looks up the value of a global time.Duration flag, returns 0 if no time.Duration flag exists
func (c *Context) GlobalDuration(name string) time.Duration {
return lookupDuration(name, c.globalSet)
}
// Looks up the value of a global bool flag, returns false if no bool flag exists
func (c *Context) GlobalBool(name string) bool {
return lookupBool(name, c.globalSet)
}
// Looks up the value of a global string flag, returns "" if no string flag exists
func (c *Context) GlobalString(name string) string {
return lookupString(name, c.globalSet)
}
// Looks up the value of a global string slice flag, returns nil if no string slice flag exists
func (c *Context) GlobalStringSlice(name string) []string {
return lookupStringSlice(name, c.globalSet)
}
// Looks up the value of a global int slice flag, returns nil if no int slice flag exists
func (c *Context) GlobalIntSlice(name string) []int {
return lookupIntSlice(name, c.globalSet)
}
// Looks up the value of a global generic flag, returns nil if no generic flag exists
func (c *Context) GlobalGeneric(name string) interface{} {
return lookupGeneric(name, c.globalSet)
}
// Returns the number of flags set
func (c *Context) NumFlags() int {
return c.flagSet.NFlag()
}
// Determines if the flag was actually set
func (c *Context) IsSet(name string) bool {
if c.setFlags == nil {
c.setFlags = make(map[string]bool)
c.flagSet.Visit(func(f *flag.Flag) {
c.setFlags[f.Name] = true
})
}
return c.setFlags[name] == true
}
// Determines if the global flag was actually set
func (c *Context) GlobalIsSet(name string) bool {
if c.globalSetFlags == nil {
c.globalSetFlags = make(map[string]bool)
c.globalSet.Visit(func(f *flag.Flag) {
c.globalSetFlags[f.Name] = true
})
}
return c.globalSetFlags[name] == true
}
// Returns a slice of flag names used in this context.
func (c *Context) FlagNames() (names []string) {
for _, flag := range c.Command.Flags {
name := strings.Split(flag.getName(), ",")[0]
if name == "help" {
continue
}
names = append(names, name)
}
return
}
// Returns a slice of global flag names used by the app.
func (c *Context) GlobalFlagNames() (names []string) {
for _, flag := range c.App.Flags {
name := strings.Split(flag.getName(), ",")[0]
if name == "help" || name == "version" {
continue
}
names = append(names, name)
}
return
}
type Args []string
// Returns the command line arguments associated with the context.
func (c *Context) Args() Args {
args := Args(c.flagSet.Args())
return args
}
// Returns the nth argument, or else a blank string
func (a Args) Get(n int) string {
if len(a) > n {
return a[n]
}
return ""
}
// Returns the first argument, or else a blank string
func (a Args) First() string {
return a.Get(0)
}
// Return the rest of the arguments (not the first one)
// or else an empty string slice
func (a Args) Tail() []string {
if len(a) >= 2 {
return []string(a)[1:]
}
return []string{}
}
// Checks if there are any arguments present
func (a Args) Present() bool {
return len(a) != 0
}
// Swaps arguments at the given indexes
func (a Args) Swap(from, to int) error {
if from >= len(a) || to >= len(a) {
return errors.New("index out of range")
}
a[from], a[to] = a[to], a[from]
return nil
}
func lookupInt(name string, set *flag.FlagSet) int {
f := set.Lookup(name)
if f != nil {
val, err := strconv.Atoi(f.Value.String())
if err != nil {
return 0
}
return val
}
return 0
}
func lookupDuration(name string, set *flag.FlagSet) time.Duration {
f := set.Lookup(name)
if f != nil {
val, err := time.ParseDuration(f.Value.String())
if err == nil {
return val
}
}
return 0
}
func lookupFloat64(name string, set *flag.FlagSet) float64 {
f := set.Lookup(name)
if f != nil {
val, err := strconv.ParseFloat(f.Value.String(), 64)
if err != nil {
return 0
}
return val
}
return 0
}
func lookupString(name string, set *flag.FlagSet) string {
f := set.Lookup(name)
if f != nil {
return f.Value.String()
}
return ""
}
func lookupStringSlice(name string, set *flag.FlagSet) []string {
f := set.Lookup(name)
if f != nil {
return (f.Value.(*StringSlice)).Value()
}
return nil
}
func lookupIntSlice(name string, set *flag.FlagSet) []int {
f := set.Lookup(name)
if f != nil {
return (f.Value.(*IntSlice)).Value()
}
return nil
}
func lookupGeneric(name string, set *flag.FlagSet) interface{} {
f := set.Lookup(name)
if f != nil {
return f.Value
}
return nil
}
func lookupBool(name string, set *flag.FlagSet) bool {
f := set.Lookup(name)
if f != nil {
val, err := strconv.ParseBool(f.Value.String())
if err != nil {
return false
}
return val
}
return false
}
func lookupBoolT(name string, set *flag.FlagSet) bool {
f := set.Lookup(name)
if f != nil {
val, err := strconv.ParseBool(f.Value.String())
if err != nil {
return true
}
return val
}
return false
}
func copyFlag(name string, ff *flag.Flag, set *flag.FlagSet) {
switch ff.Value.(type) {
case *StringSlice:
default:
set.Set(name, ff.Value.String())
}
}
func normalizeFlags(flags []Flag, set *flag.FlagSet) error {
visited := make(map[string]bool)
set.Visit(func(f *flag.Flag) {
visited[f.Name] = true
})
for _, f := range flags {
parts := strings.Split(f.getName(), ",")
if len(parts) == 1 {
continue
}
var ff *flag.Flag
for _, name := range parts {
name = strings.Trim(name, " ")
if visited[name] {
if ff != nil {
return errors.New("Cannot use two forms of the same flag: " + name + " " + ff.Name)
}
ff = set.Lookup(name)
}
}
if ff == nil {
continue
}
for _, name := range parts {
name = strings.Trim(name, " ")
if !visited[name] {
copyFlag(name, ff, set)
}
}
}
return nil
}

View File

@ -0,0 +1,111 @@
package cli_test
import (
"flag"
"testing"
"time"
"github.com/codegangsta/cli"
)
func TestNewContext(t *testing.T) {
set := flag.NewFlagSet("test", 0)
set.Int("myflag", 12, "doc")
globalSet := flag.NewFlagSet("test", 0)
globalSet.Int("myflag", 42, "doc")
command := cli.Command{Name: "mycommand"}
c := cli.NewContext(nil, set, globalSet)
c.Command = command
expect(t, c.Int("myflag"), 12)
expect(t, c.GlobalInt("myflag"), 42)
expect(t, c.Command.Name, "mycommand")
}
func TestContext_Int(t *testing.T) {
set := flag.NewFlagSet("test", 0)
set.Int("myflag", 12, "doc")
c := cli.NewContext(nil, set, set)
expect(t, c.Int("myflag"), 12)
}
func TestContext_Duration(t *testing.T) {
set := flag.NewFlagSet("test", 0)
set.Duration("myflag", time.Duration(12*time.Second), "doc")
c := cli.NewContext(nil, set, set)
expect(t, c.Duration("myflag"), time.Duration(12*time.Second))
}
func TestContext_String(t *testing.T) {
set := flag.NewFlagSet("test", 0)
set.String("myflag", "hello world", "doc")
c := cli.NewContext(nil, set, set)
expect(t, c.String("myflag"), "hello world")
}
func TestContext_Bool(t *testing.T) {
set := flag.NewFlagSet("test", 0)
set.Bool("myflag", false, "doc")
c := cli.NewContext(nil, set, set)
expect(t, c.Bool("myflag"), false)
}
func TestContext_BoolT(t *testing.T) {
set := flag.NewFlagSet("test", 0)
set.Bool("myflag", true, "doc")
c := cli.NewContext(nil, set, set)
expect(t, c.BoolT("myflag"), true)
}
func TestContext_Args(t *testing.T) {
set := flag.NewFlagSet("test", 0)
set.Bool("myflag", false, "doc")
c := cli.NewContext(nil, set, set)
set.Parse([]string{"--myflag", "bat", "baz"})
expect(t, len(c.Args()), 2)
expect(t, c.Bool("myflag"), true)
}
func TestContext_IsSet(t *testing.T) {
set := flag.NewFlagSet("test", 0)
set.Bool("myflag", false, "doc")
set.String("otherflag", "hello world", "doc")
globalSet := flag.NewFlagSet("test", 0)
globalSet.Bool("myflagGlobal", true, "doc")
c := cli.NewContext(nil, set, globalSet)
set.Parse([]string{"--myflag", "bat", "baz"})
globalSet.Parse([]string{"--myflagGlobal", "bat", "baz"})
expect(t, c.IsSet("myflag"), true)
expect(t, c.IsSet("otherflag"), false)
expect(t, c.IsSet("bogusflag"), false)
expect(t, c.IsSet("myflagGlobal"), false)
}
func TestContext_GlobalIsSet(t *testing.T) {
set := flag.NewFlagSet("test", 0)
set.Bool("myflag", false, "doc")
set.String("otherflag", "hello world", "doc")
globalSet := flag.NewFlagSet("test", 0)
globalSet.Bool("myflagGlobal", true, "doc")
globalSet.Bool("myflagGlobalUnset", true, "doc")
c := cli.NewContext(nil, set, globalSet)
set.Parse([]string{"--myflag", "bat", "baz"})
globalSet.Parse([]string{"--myflagGlobal", "bat", "baz"})
expect(t, c.GlobalIsSet("myflag"), false)
expect(t, c.GlobalIsSet("otherflag"), false)
expect(t, c.GlobalIsSet("bogusflag"), false)
expect(t, c.GlobalIsSet("myflagGlobal"), true)
expect(t, c.GlobalIsSet("myflagGlobalUnset"), false)
expect(t, c.GlobalIsSet("bogusGlobal"), false)
}
func TestContext_NumFlags(t *testing.T) {
set := flag.NewFlagSet("test", 0)
set.Bool("myflag", false, "doc")
set.String("otherflag", "hello world", "doc")
globalSet := flag.NewFlagSet("test", 0)
globalSet.Bool("myflagGlobal", true, "doc")
c := cli.NewContext(nil, set, globalSet)
set.Parse([]string{"--myflag", "--otherflag=foo"})
globalSet.Parse([]string{"--myflagGlobal"})
expect(t, c.NumFlags(), 2)
}

View File

@ -0,0 +1,454 @@
package cli
import (
"flag"
"fmt"
"os"
"strconv"
"strings"
"time"
)
// This flag enables bash-completion for all commands and subcommands
var BashCompletionFlag = BoolFlag{
Name: "generate-bash-completion",
}
// This flag prints the version for the application
var VersionFlag = BoolFlag{
Name: "version, v",
Usage: "print the version",
}
// This flag prints the help for all commands and subcommands
// Set to the zero value (BoolFlag{}) to disable flag -- keeps subcommand
// unless HideHelp is set to true)
var HelpFlag = BoolFlag{
Name: "help, h",
Usage: "show help",
}
// Flag is a common interface related to parsing flags in cli.
// For more advanced flag parsing techniques, it is recomended that
// this interface be implemented.
type Flag interface {
fmt.Stringer
// Apply Flag settings to the given flag set
Apply(*flag.FlagSet)
getName() string
}
func flagSet(name string, flags []Flag) *flag.FlagSet {
set := flag.NewFlagSet(name, flag.ContinueOnError)
for _, f := range flags {
f.Apply(set)
}
return set
}
func eachName(longName string, fn func(string)) {
parts := strings.Split(longName, ",")
for _, name := range parts {
name = strings.Trim(name, " ")
fn(name)
}
}
// Generic is a generic parseable type identified by a specific flag
type Generic interface {
Set(value string) error
String() string
}
// GenericFlag is the flag type for types implementing Generic
type GenericFlag struct {
Name string
Value Generic
Usage string
EnvVar string
}
// String returns the string representation of the generic flag to display the
// help text to the user (uses the String() method of the generic flag to show
// the value)
func (f GenericFlag) String() string {
return withEnvHint(f.EnvVar, fmt.Sprintf("%s%s \"%v\"\t%v", prefixFor(f.Name), f.Name, f.Value, f.Usage))
}
// Apply takes the flagset and calls Set on the generic flag with the value
// provided by the user for parsing by the flag
func (f GenericFlag) Apply(set *flag.FlagSet) {
val := f.Value
if f.EnvVar != "" {
for _, envVar := range strings.Split(f.EnvVar, ",") {
envVar = strings.TrimSpace(envVar)
if envVal := os.Getenv(envVar); envVal != "" {
val.Set(envVal)
break
}
}
}
eachName(f.Name, func(name string) {
set.Var(f.Value, name, f.Usage)
})
}
func (f GenericFlag) getName() string {
return f.Name
}
type StringSlice []string
func (f *StringSlice) Set(value string) error {
*f = append(*f, value)
return nil
}
func (f *StringSlice) String() string {
return fmt.Sprintf("%s", *f)
}
func (f *StringSlice) Value() []string {
return *f
}
type StringSliceFlag struct {
Name string
Value *StringSlice
Usage string
EnvVar string
}
func (f StringSliceFlag) String() string {
firstName := strings.Trim(strings.Split(f.Name, ",")[0], " ")
pref := prefixFor(firstName)
return withEnvHint(f.EnvVar, fmt.Sprintf("%s [%v]\t%v", prefixedNames(f.Name), pref+firstName+" option "+pref+firstName+" option", f.Usage))
}
func (f StringSliceFlag) Apply(set *flag.FlagSet) {
if f.EnvVar != "" {
for _, envVar := range strings.Split(f.EnvVar, ",") {
envVar = strings.TrimSpace(envVar)
if envVal := os.Getenv(envVar); envVal != "" {
newVal := &StringSlice{}
for _, s := range strings.Split(envVal, ",") {
s = strings.TrimSpace(s)
newVal.Set(s)
}
f.Value = newVal
break
}
}
}
eachName(f.Name, func(name string) {
set.Var(f.Value, name, f.Usage)
})
}
func (f StringSliceFlag) getName() string {
return f.Name
}
type IntSlice []int
func (f *IntSlice) Set(value string) error {
tmp, err := strconv.Atoi(value)
if err != nil {
return err
} else {
*f = append(*f, tmp)
}
return nil
}
func (f *IntSlice) String() string {
return fmt.Sprintf("%d", *f)
}
func (f *IntSlice) Value() []int {
return *f
}
type IntSliceFlag struct {
Name string
Value *IntSlice
Usage string
EnvVar string
}
func (f IntSliceFlag) String() string {
firstName := strings.Trim(strings.Split(f.Name, ",")[0], " ")
pref := prefixFor(firstName)
return withEnvHint(f.EnvVar, fmt.Sprintf("%s [%v]\t%v", prefixedNames(f.Name), pref+firstName+" option "+pref+firstName+" option", f.Usage))
}
func (f IntSliceFlag) Apply(set *flag.FlagSet) {
if f.EnvVar != "" {
for _, envVar := range strings.Split(f.EnvVar, ",") {
envVar = strings.TrimSpace(envVar)
if envVal := os.Getenv(envVar); envVal != "" {
newVal := &IntSlice{}
for _, s := range strings.Split(envVal, ",") {
s = strings.TrimSpace(s)
err := newVal.Set(s)
if err != nil {
fmt.Fprintf(os.Stderr, err.Error())
}
}
f.Value = newVal
break
}
}
}
eachName(f.Name, func(name string) {
set.Var(f.Value, name, f.Usage)
})
}
func (f IntSliceFlag) getName() string {
return f.Name
}
type BoolFlag struct {
Name string
Usage string
EnvVar string
}
func (f BoolFlag) String() string {
return withEnvHint(f.EnvVar, fmt.Sprintf("%s\t%v", prefixedNames(f.Name), f.Usage))
}
func (f BoolFlag) Apply(set *flag.FlagSet) {
val := false
if f.EnvVar != "" {
for _, envVar := range strings.Split(f.EnvVar, ",") {
envVar = strings.TrimSpace(envVar)
if envVal := os.Getenv(envVar); envVal != "" {
envValBool, err := strconv.ParseBool(envVal)
if err == nil {
val = envValBool
}
break
}
}
}
eachName(f.Name, func(name string) {
set.Bool(name, val, f.Usage)
})
}
func (f BoolFlag) getName() string {
return f.Name
}
type BoolTFlag struct {
Name string
Usage string
EnvVar string
}
func (f BoolTFlag) String() string {
return withEnvHint(f.EnvVar, fmt.Sprintf("%s\t%v", prefixedNames(f.Name), f.Usage))
}
func (f BoolTFlag) Apply(set *flag.FlagSet) {
val := true
if f.EnvVar != "" {
for _, envVar := range strings.Split(f.EnvVar, ",") {
envVar = strings.TrimSpace(envVar)
if envVal := os.Getenv(envVar); envVal != "" {
envValBool, err := strconv.ParseBool(envVal)
if err == nil {
val = envValBool
break
}
}
}
}
eachName(f.Name, func(name string) {
set.Bool(name, val, f.Usage)
})
}
func (f BoolTFlag) getName() string {
return f.Name
}
type StringFlag struct {
Name string
Value string
Usage string
EnvVar string
}
func (f StringFlag) String() string {
var fmtString string
fmtString = "%s %v\t%v"
if len(f.Value) > 0 {
fmtString = "%s \"%v\"\t%v"
} else {
fmtString = "%s %v\t%v"
}
return withEnvHint(f.EnvVar, fmt.Sprintf(fmtString, prefixedNames(f.Name), f.Value, f.Usage))
}
func (f StringFlag) Apply(set *flag.FlagSet) {
if f.EnvVar != "" {
for _, envVar := range strings.Split(f.EnvVar, ",") {
envVar = strings.TrimSpace(envVar)
if envVal := os.Getenv(envVar); envVal != "" {
f.Value = envVal
break
}
}
}
eachName(f.Name, func(name string) {
set.String(name, f.Value, f.Usage)
})
}
func (f StringFlag) getName() string {
return f.Name
}
type IntFlag struct {
Name string
Value int
Usage string
EnvVar string
}
func (f IntFlag) String() string {
return withEnvHint(f.EnvVar, fmt.Sprintf("%s \"%v\"\t%v", prefixedNames(f.Name), f.Value, f.Usage))
}
func (f IntFlag) Apply(set *flag.FlagSet) {
if f.EnvVar != "" {
for _, envVar := range strings.Split(f.EnvVar, ",") {
envVar = strings.TrimSpace(envVar)
if envVal := os.Getenv(envVar); envVal != "" {
envValInt, err := strconv.ParseInt(envVal, 0, 64)
if err == nil {
f.Value = int(envValInt)
break
}
}
}
}
eachName(f.Name, func(name string) {
set.Int(name, f.Value, f.Usage)
})
}
func (f IntFlag) getName() string {
return f.Name
}
type DurationFlag struct {
Name string
Value time.Duration
Usage string
EnvVar string
}
func (f DurationFlag) String() string {
return withEnvHint(f.EnvVar, fmt.Sprintf("%s \"%v\"\t%v", prefixedNames(f.Name), f.Value, f.Usage))
}
func (f DurationFlag) Apply(set *flag.FlagSet) {
if f.EnvVar != "" {
for _, envVar := range strings.Split(f.EnvVar, ",") {
envVar = strings.TrimSpace(envVar)
if envVal := os.Getenv(envVar); envVal != "" {
envValDuration, err := time.ParseDuration(envVal)
if err == nil {
f.Value = envValDuration
break
}
}
}
}
eachName(f.Name, func(name string) {
set.Duration(name, f.Value, f.Usage)
})
}
func (f DurationFlag) getName() string {
return f.Name
}
type Float64Flag struct {
Name string
Value float64
Usage string
EnvVar string
}
func (f Float64Flag) String() string {
return withEnvHint(f.EnvVar, fmt.Sprintf("%s \"%v\"\t%v", prefixedNames(f.Name), f.Value, f.Usage))
}
func (f Float64Flag) Apply(set *flag.FlagSet) {
if f.EnvVar != "" {
for _, envVar := range strings.Split(f.EnvVar, ",") {
envVar = strings.TrimSpace(envVar)
if envVal := os.Getenv(envVar); envVal != "" {
envValFloat, err := strconv.ParseFloat(envVal, 10)
if err == nil {
f.Value = float64(envValFloat)
}
}
}
}
eachName(f.Name, func(name string) {
set.Float64(name, f.Value, f.Usage)
})
}
func (f Float64Flag) getName() string {
return f.Name
}
func prefixFor(name string) (prefix string) {
if len(name) == 1 {
prefix = "-"
} else {
prefix = "--"
}
return
}
func prefixedNames(fullName string) (prefixed string) {
parts := strings.Split(fullName, ",")
for i, name := range parts {
name = strings.Trim(name, " ")
prefixed += prefixFor(name) + name
if i < len(parts)-1 {
prefixed += ", "
}
}
return
}
func withEnvHint(envVar, str string) string {
envText := ""
if envVar != "" {
envText = fmt.Sprintf(" [$%s]", strings.Join(strings.Split(envVar, ","), ", $"))
}
return str + envText
}

View File

@ -0,0 +1,742 @@
package cli_test
import (
"fmt"
"os"
"reflect"
"strings"
"testing"
"github.com/codegangsta/cli"
)
var boolFlagTests = []struct {
name string
expected string
}{
{"help", "--help\t"},
{"h", "-h\t"},
}
func TestBoolFlagHelpOutput(t *testing.T) {
for _, test := range boolFlagTests {
flag := cli.BoolFlag{Name: test.name}
output := flag.String()
if output != test.expected {
t.Errorf("%s does not match %s", output, test.expected)
}
}
}
var stringFlagTests = []struct {
name string
value string
expected string
}{
{"help", "", "--help \t"},
{"h", "", "-h \t"},
{"h", "", "-h \t"},
{"test", "Something", "--test \"Something\"\t"},
}
func TestStringFlagHelpOutput(t *testing.T) {
for _, test := range stringFlagTests {
flag := cli.StringFlag{Name: test.name, Value: test.value}
output := flag.String()
if output != test.expected {
t.Errorf("%s does not match %s", output, test.expected)
}
}
}
func TestStringFlagWithEnvVarHelpOutput(t *testing.T) {
os.Clearenv()
os.Setenv("APP_FOO", "derp")
for _, test := range stringFlagTests {
flag := cli.StringFlag{Name: test.name, Value: test.value, EnvVar: "APP_FOO"}
output := flag.String()
if !strings.HasSuffix(output, " [$APP_FOO]") {
t.Errorf("%s does not end with [$APP_FOO]", output)
}
}
}
var stringSliceFlagTests = []struct {
name string
value *cli.StringSlice
expected string
}{
{"help", func() *cli.StringSlice {
s := &cli.StringSlice{}
s.Set("")
return s
}(), "--help [--help option --help option]\t"},
{"h", func() *cli.StringSlice {
s := &cli.StringSlice{}
s.Set("")
return s
}(), "-h [-h option -h option]\t"},
{"h", func() *cli.StringSlice {
s := &cli.StringSlice{}
s.Set("")
return s
}(), "-h [-h option -h option]\t"},
{"test", func() *cli.StringSlice {
s := &cli.StringSlice{}
s.Set("Something")
return s
}(), "--test [--test option --test option]\t"},
}
func TestStringSliceFlagHelpOutput(t *testing.T) {
for _, test := range stringSliceFlagTests {
flag := cli.StringSliceFlag{Name: test.name, Value: test.value}
output := flag.String()
if output != test.expected {
t.Errorf("%q does not match %q", output, test.expected)
}
}
}
func TestStringSliceFlagWithEnvVarHelpOutput(t *testing.T) {
os.Clearenv()
os.Setenv("APP_QWWX", "11,4")
for _, test := range stringSliceFlagTests {
flag := cli.StringSliceFlag{Name: test.name, Value: test.value, EnvVar: "APP_QWWX"}
output := flag.String()
if !strings.HasSuffix(output, " [$APP_QWWX]") {
t.Errorf("%q does not end with [$APP_QWWX]", output)
}
}
}
var intFlagTests = []struct {
name string
expected string
}{
{"help", "--help \"0\"\t"},
{"h", "-h \"0\"\t"},
}
func TestIntFlagHelpOutput(t *testing.T) {
for _, test := range intFlagTests {
flag := cli.IntFlag{Name: test.name}
output := flag.String()
if output != test.expected {
t.Errorf("%s does not match %s", output, test.expected)
}
}
}
func TestIntFlagWithEnvVarHelpOutput(t *testing.T) {
os.Clearenv()
os.Setenv("APP_BAR", "2")
for _, test := range intFlagTests {
flag := cli.IntFlag{Name: test.name, EnvVar: "APP_BAR"}
output := flag.String()
if !strings.HasSuffix(output, " [$APP_BAR]") {
t.Errorf("%s does not end with [$APP_BAR]", output)
}
}
}
var durationFlagTests = []struct {
name string
expected string
}{
{"help", "--help \"0\"\t"},
{"h", "-h \"0\"\t"},
}
func TestDurationFlagHelpOutput(t *testing.T) {
for _, test := range durationFlagTests {
flag := cli.DurationFlag{Name: test.name}
output := flag.String()
if output != test.expected {
t.Errorf("%s does not match %s", output, test.expected)
}
}
}
func TestDurationFlagWithEnvVarHelpOutput(t *testing.T) {
os.Clearenv()
os.Setenv("APP_BAR", "2h3m6s")
for _, test := range durationFlagTests {
flag := cli.DurationFlag{Name: test.name, EnvVar: "APP_BAR"}
output := flag.String()
if !strings.HasSuffix(output, " [$APP_BAR]") {
t.Errorf("%s does not end with [$APP_BAR]", output)
}
}
}
var intSliceFlagTests = []struct {
name string
value *cli.IntSlice
expected string
}{
{"help", &cli.IntSlice{}, "--help [--help option --help option]\t"},
{"h", &cli.IntSlice{}, "-h [-h option -h option]\t"},
{"h", &cli.IntSlice{}, "-h [-h option -h option]\t"},
{"test", func() *cli.IntSlice {
i := &cli.IntSlice{}
i.Set("9")
return i
}(), "--test [--test option --test option]\t"},
}
func TestIntSliceFlagHelpOutput(t *testing.T) {
for _, test := range intSliceFlagTests {
flag := cli.IntSliceFlag{Name: test.name, Value: test.value}
output := flag.String()
if output != test.expected {
t.Errorf("%q does not match %q", output, test.expected)
}
}
}
func TestIntSliceFlagWithEnvVarHelpOutput(t *testing.T) {
os.Clearenv()
os.Setenv("APP_SMURF", "42,3")
for _, test := range intSliceFlagTests {
flag := cli.IntSliceFlag{Name: test.name, Value: test.value, EnvVar: "APP_SMURF"}
output := flag.String()
if !strings.HasSuffix(output, " [$APP_SMURF]") {
t.Errorf("%q does not end with [$APP_SMURF]", output)
}
}
}
var float64FlagTests = []struct {
name string
expected string
}{
{"help", "--help \"0\"\t"},
{"h", "-h \"0\"\t"},
}
func TestFloat64FlagHelpOutput(t *testing.T) {
for _, test := range float64FlagTests {
flag := cli.Float64Flag{Name: test.name}
output := flag.String()
if output != test.expected {
t.Errorf("%s does not match %s", output, test.expected)
}
}
}
func TestFloat64FlagWithEnvVarHelpOutput(t *testing.T) {
os.Clearenv()
os.Setenv("APP_BAZ", "99.4")
for _, test := range float64FlagTests {
flag := cli.Float64Flag{Name: test.name, EnvVar: "APP_BAZ"}
output := flag.String()
if !strings.HasSuffix(output, " [$APP_BAZ]") {
t.Errorf("%s does not end with [$APP_BAZ]", output)
}
}
}
var genericFlagTests = []struct {
name string
value cli.Generic
expected string
}{
{"test", &Parser{"abc", "def"}, "--test \"abc,def\"\ttest flag"},
{"t", &Parser{"abc", "def"}, "-t \"abc,def\"\ttest flag"},
}
func TestGenericFlagHelpOutput(t *testing.T) {
for _, test := range genericFlagTests {
flag := cli.GenericFlag{Name: test.name, Value: test.value, Usage: "test flag"}
output := flag.String()
if output != test.expected {
t.Errorf("%q does not match %q", output, test.expected)
}
}
}
func TestGenericFlagWithEnvVarHelpOutput(t *testing.T) {
os.Clearenv()
os.Setenv("APP_ZAP", "3")
for _, test := range genericFlagTests {
flag := cli.GenericFlag{Name: test.name, EnvVar: "APP_ZAP"}
output := flag.String()
if !strings.HasSuffix(output, " [$APP_ZAP]") {
t.Errorf("%s does not end with [$APP_ZAP]", output)
}
}
}
func TestParseMultiString(t *testing.T) {
(&cli.App{
Flags: []cli.Flag{
cli.StringFlag{Name: "serve, s"},
},
Action: func(ctx *cli.Context) {
if ctx.String("serve") != "10" {
t.Errorf("main name not set")
}
if ctx.String("s") != "10" {
t.Errorf("short name not set")
}
},
}).Run([]string{"run", "-s", "10"})
}
func TestParseMultiStringFromEnv(t *testing.T) {
os.Clearenv()
os.Setenv("APP_COUNT", "20")
(&cli.App{
Flags: []cli.Flag{
cli.StringFlag{Name: "count, c", EnvVar: "APP_COUNT"},
},
Action: func(ctx *cli.Context) {
if ctx.String("count") != "20" {
t.Errorf("main name not set")
}
if ctx.String("c") != "20" {
t.Errorf("short name not set")
}
},
}).Run([]string{"run"})
}
func TestParseMultiStringFromEnvCascade(t *testing.T) {
os.Clearenv()
os.Setenv("APP_COUNT", "20")
(&cli.App{
Flags: []cli.Flag{
cli.StringFlag{Name: "count, c", EnvVar: "COMPAT_COUNT,APP_COUNT"},
},
Action: func(ctx *cli.Context) {
if ctx.String("count") != "20" {
t.Errorf("main name not set")
}
if ctx.String("c") != "20" {
t.Errorf("short name not set")
}
},
}).Run([]string{"run"})
}
func TestParseMultiStringSlice(t *testing.T) {
(&cli.App{
Flags: []cli.Flag{
cli.StringSliceFlag{Name: "serve, s", Value: &cli.StringSlice{}},
},
Action: func(ctx *cli.Context) {
if !reflect.DeepEqual(ctx.StringSlice("serve"), []string{"10", "20"}) {
t.Errorf("main name not set")
}
if !reflect.DeepEqual(ctx.StringSlice("s"), []string{"10", "20"}) {
t.Errorf("short name not set")
}
},
}).Run([]string{"run", "-s", "10", "-s", "20"})
}
func TestParseMultiStringSliceFromEnv(t *testing.T) {
os.Clearenv()
os.Setenv("APP_INTERVALS", "20,30,40")
(&cli.App{
Flags: []cli.Flag{
cli.StringSliceFlag{Name: "intervals, i", Value: &cli.StringSlice{}, EnvVar: "APP_INTERVALS"},
},
Action: func(ctx *cli.Context) {
if !reflect.DeepEqual(ctx.StringSlice("intervals"), []string{"20", "30", "40"}) {
t.Errorf("main name not set from env")
}
if !reflect.DeepEqual(ctx.StringSlice("i"), []string{"20", "30", "40"}) {
t.Errorf("short name not set from env")
}
},
}).Run([]string{"run"})
}
func TestParseMultiStringSliceFromEnvCascade(t *testing.T) {
os.Clearenv()
os.Setenv("APP_INTERVALS", "20,30,40")
(&cli.App{
Flags: []cli.Flag{
cli.StringSliceFlag{Name: "intervals, i", Value: &cli.StringSlice{}, EnvVar: "COMPAT_INTERVALS,APP_INTERVALS"},
},
Action: func(ctx *cli.Context) {
if !reflect.DeepEqual(ctx.StringSlice("intervals"), []string{"20", "30", "40"}) {
t.Errorf("main name not set from env")
}
if !reflect.DeepEqual(ctx.StringSlice("i"), []string{"20", "30", "40"}) {
t.Errorf("short name not set from env")
}
},
}).Run([]string{"run"})
}
func TestParseMultiInt(t *testing.T) {
a := cli.App{
Flags: []cli.Flag{
cli.IntFlag{Name: "serve, s"},
},
Action: func(ctx *cli.Context) {
if ctx.Int("serve") != 10 {
t.Errorf("main name not set")
}
if ctx.Int("s") != 10 {
t.Errorf("short name not set")
}
},
}
a.Run([]string{"run", "-s", "10"})
}
func TestParseMultiIntFromEnv(t *testing.T) {
os.Clearenv()
os.Setenv("APP_TIMEOUT_SECONDS", "10")
a := cli.App{
Flags: []cli.Flag{
cli.IntFlag{Name: "timeout, t", EnvVar: "APP_TIMEOUT_SECONDS"},
},
Action: func(ctx *cli.Context) {
if ctx.Int("timeout") != 10 {
t.Errorf("main name not set")
}
if ctx.Int("t") != 10 {
t.Errorf("short name not set")
}
},
}
a.Run([]string{"run"})
}
func TestParseMultiIntFromEnvCascade(t *testing.T) {
os.Clearenv()
os.Setenv("APP_TIMEOUT_SECONDS", "10")
a := cli.App{
Flags: []cli.Flag{
cli.IntFlag{Name: "timeout, t", EnvVar: "COMPAT_TIMEOUT_SECONDS,APP_TIMEOUT_SECONDS"},
},
Action: func(ctx *cli.Context) {
if ctx.Int("timeout") != 10 {
t.Errorf("main name not set")
}
if ctx.Int("t") != 10 {
t.Errorf("short name not set")
}
},
}
a.Run([]string{"run"})
}
func TestParseMultiIntSlice(t *testing.T) {
(&cli.App{
Flags: []cli.Flag{
cli.IntSliceFlag{Name: "serve, s", Value: &cli.IntSlice{}},
},
Action: func(ctx *cli.Context) {
if !reflect.DeepEqual(ctx.IntSlice("serve"), []int{10, 20}) {
t.Errorf("main name not set")
}
if !reflect.DeepEqual(ctx.IntSlice("s"), []int{10, 20}) {
t.Errorf("short name not set")
}
},
}).Run([]string{"run", "-s", "10", "-s", "20"})
}
func TestParseMultiIntSliceFromEnv(t *testing.T) {
os.Clearenv()
os.Setenv("APP_INTERVALS", "20,30,40")
(&cli.App{
Flags: []cli.Flag{
cli.IntSliceFlag{Name: "intervals, i", Value: &cli.IntSlice{}, EnvVar: "APP_INTERVALS"},
},
Action: func(ctx *cli.Context) {
if !reflect.DeepEqual(ctx.IntSlice("intervals"), []int{20, 30, 40}) {
t.Errorf("main name not set from env")
}
if !reflect.DeepEqual(ctx.IntSlice("i"), []int{20, 30, 40}) {
t.Errorf("short name not set from env")
}
},
}).Run([]string{"run"})
}
func TestParseMultiIntSliceFromEnvCascade(t *testing.T) {
os.Clearenv()
os.Setenv("APP_INTERVALS", "20,30,40")
(&cli.App{
Flags: []cli.Flag{
cli.IntSliceFlag{Name: "intervals, i", Value: &cli.IntSlice{}, EnvVar: "COMPAT_INTERVALS,APP_INTERVALS"},
},
Action: func(ctx *cli.Context) {
if !reflect.DeepEqual(ctx.IntSlice("intervals"), []int{20, 30, 40}) {
t.Errorf("main name not set from env")
}
if !reflect.DeepEqual(ctx.IntSlice("i"), []int{20, 30, 40}) {
t.Errorf("short name not set from env")
}
},
}).Run([]string{"run"})
}
func TestParseMultiFloat64(t *testing.T) {
a := cli.App{
Flags: []cli.Flag{
cli.Float64Flag{Name: "serve, s"},
},
Action: func(ctx *cli.Context) {
if ctx.Float64("serve") != 10.2 {
t.Errorf("main name not set")
}
if ctx.Float64("s") != 10.2 {
t.Errorf("short name not set")
}
},
}
a.Run([]string{"run", "-s", "10.2"})
}
func TestParseMultiFloat64FromEnv(t *testing.T) {
os.Clearenv()
os.Setenv("APP_TIMEOUT_SECONDS", "15.5")
a := cli.App{
Flags: []cli.Flag{
cli.Float64Flag{Name: "timeout, t", EnvVar: "APP_TIMEOUT_SECONDS"},
},
Action: func(ctx *cli.Context) {
if ctx.Float64("timeout") != 15.5 {
t.Errorf("main name not set")
}
if ctx.Float64("t") != 15.5 {
t.Errorf("short name not set")
}
},
}
a.Run([]string{"run"})
}
func TestParseMultiFloat64FromEnvCascade(t *testing.T) {
os.Clearenv()
os.Setenv("APP_TIMEOUT_SECONDS", "15.5")
a := cli.App{
Flags: []cli.Flag{
cli.Float64Flag{Name: "timeout, t", EnvVar: "COMPAT_TIMEOUT_SECONDS,APP_TIMEOUT_SECONDS"},
},
Action: func(ctx *cli.Context) {
if ctx.Float64("timeout") != 15.5 {
t.Errorf("main name not set")
}
if ctx.Float64("t") != 15.5 {
t.Errorf("short name not set")
}
},
}
a.Run([]string{"run"})
}
func TestParseMultiBool(t *testing.T) {
a := cli.App{
Flags: []cli.Flag{
cli.BoolFlag{Name: "serve, s"},
},
Action: func(ctx *cli.Context) {
if ctx.Bool("serve") != true {
t.Errorf("main name not set")
}
if ctx.Bool("s") != true {
t.Errorf("short name not set")
}
},
}
a.Run([]string{"run", "--serve"})
}
func TestParseMultiBoolFromEnv(t *testing.T) {
os.Clearenv()
os.Setenv("APP_DEBUG", "1")
a := cli.App{
Flags: []cli.Flag{
cli.BoolFlag{Name: "debug, d", EnvVar: "APP_DEBUG"},
},
Action: func(ctx *cli.Context) {
if ctx.Bool("debug") != true {
t.Errorf("main name not set from env")
}
if ctx.Bool("d") != true {
t.Errorf("short name not set from env")
}
},
}
a.Run([]string{"run"})
}
func TestParseMultiBoolFromEnvCascade(t *testing.T) {
os.Clearenv()
os.Setenv("APP_DEBUG", "1")
a := cli.App{
Flags: []cli.Flag{
cli.BoolFlag{Name: "debug, d", EnvVar: "COMPAT_DEBUG,APP_DEBUG"},
},
Action: func(ctx *cli.Context) {
if ctx.Bool("debug") != true {
t.Errorf("main name not set from env")
}
if ctx.Bool("d") != true {
t.Errorf("short name not set from env")
}
},
}
a.Run([]string{"run"})
}
func TestParseMultiBoolT(t *testing.T) {
a := cli.App{
Flags: []cli.Flag{
cli.BoolTFlag{Name: "serve, s"},
},
Action: func(ctx *cli.Context) {
if ctx.BoolT("serve") != true {
t.Errorf("main name not set")
}
if ctx.BoolT("s") != true {
t.Errorf("short name not set")
}
},
}
a.Run([]string{"run", "--serve"})
}
func TestParseMultiBoolTFromEnv(t *testing.T) {
os.Clearenv()
os.Setenv("APP_DEBUG", "0")
a := cli.App{
Flags: []cli.Flag{
cli.BoolTFlag{Name: "debug, d", EnvVar: "APP_DEBUG"},
},
Action: func(ctx *cli.Context) {
if ctx.BoolT("debug") != false {
t.Errorf("main name not set from env")
}
if ctx.BoolT("d") != false {
t.Errorf("short name not set from env")
}
},
}
a.Run([]string{"run"})
}
func TestParseMultiBoolTFromEnvCascade(t *testing.T) {
os.Clearenv()
os.Setenv("APP_DEBUG", "0")
a := cli.App{
Flags: []cli.Flag{
cli.BoolTFlag{Name: "debug, d", EnvVar: "COMPAT_DEBUG,APP_DEBUG"},
},
Action: func(ctx *cli.Context) {
if ctx.BoolT("debug") != false {
t.Errorf("main name not set from env")
}
if ctx.BoolT("d") != false {
t.Errorf("short name not set from env")
}
},
}
a.Run([]string{"run"})
}
type Parser [2]string
func (p *Parser) Set(value string) error {
parts := strings.Split(value, ",")
if len(parts) != 2 {
return fmt.Errorf("invalid format")
}
(*p)[0] = parts[0]
(*p)[1] = parts[1]
return nil
}
func (p *Parser) String() string {
return fmt.Sprintf("%s,%s", p[0], p[1])
}
func TestParseGeneric(t *testing.T) {
a := cli.App{
Flags: []cli.Flag{
cli.GenericFlag{Name: "serve, s", Value: &Parser{}},
},
Action: func(ctx *cli.Context) {
if !reflect.DeepEqual(ctx.Generic("serve"), &Parser{"10", "20"}) {
t.Errorf("main name not set")
}
if !reflect.DeepEqual(ctx.Generic("s"), &Parser{"10", "20"}) {
t.Errorf("short name not set")
}
},
}
a.Run([]string{"run", "-s", "10,20"})
}
func TestParseGenericFromEnv(t *testing.T) {
os.Clearenv()
os.Setenv("APP_SERVE", "20,30")
a := cli.App{
Flags: []cli.Flag{
cli.GenericFlag{Name: "serve, s", Value: &Parser{}, EnvVar: "APP_SERVE"},
},
Action: func(ctx *cli.Context) {
if !reflect.DeepEqual(ctx.Generic("serve"), &Parser{"20", "30"}) {
t.Errorf("main name not set from env")
}
if !reflect.DeepEqual(ctx.Generic("s"), &Parser{"20", "30"}) {
t.Errorf("short name not set from env")
}
},
}
a.Run([]string{"run"})
}
func TestParseGenericFromEnvCascade(t *testing.T) {
os.Clearenv()
os.Setenv("APP_FOO", "99,2000")
a := cli.App{
Flags: []cli.Flag{
cli.GenericFlag{Name: "foos", Value: &Parser{}, EnvVar: "COMPAT_FOO,APP_FOO"},
},
Action: func(ctx *cli.Context) {
if !reflect.DeepEqual(ctx.Generic("foos"), &Parser{"99", "2000"}) {
t.Errorf("value not set from env")
}
},
}
a.Run([]string{"run"})
}

View File

@ -0,0 +1,215 @@
package cli
import "fmt"
// The text template for the Default help topic.
// cli.go uses text/template to render templates. You can
// render custom help text by setting this variable.
var AppHelpTemplate = `NAME:
{{.Name}} - {{.Usage}}
USAGE:
{{.Name}} {{if .Flags}}[global options] {{end}}command{{if .Flags}} [command options]{{end}} [arguments...]
VERSION:
{{.Version}}
AUTHOR(S):
{{range .Authors}}{{ . }}
{{end}}
COMMANDS:
{{range .Commands}}{{join .Names ", "}}{{ "\t" }}{{.Usage}}
{{end}}{{if .Flags}}
GLOBAL OPTIONS:
{{range .Flags}}{{.}}
{{end}}{{end}}
`
// The text template for the command help topic.
// cli.go uses text/template to render templates. You can
// render custom help text by setting this variable.
var CommandHelpTemplate = `NAME:
{{.Name}} - {{.Usage}}
USAGE:
command {{.Name}}{{if .Flags}} [command options]{{end}} [arguments...]{{if .Description}}
DESCRIPTION:
{{.Description}}{{end}}{{if .Flags}}
OPTIONS:
{{range .Flags}}{{.}}
{{end}}{{ end }}
`
// The text template for the subcommand help topic.
// cli.go uses text/template to render templates. You can
// render custom help text by setting this variable.
var SubcommandHelpTemplate = `NAME:
{{.Name}} - {{.Usage}}
USAGE:
{{.Name}} command{{if .Flags}} [command options]{{end}} [arguments...]
COMMANDS:
{{range .Commands}}{{join .Names ", "}}{{ "\t" }}{{.Usage}}
{{end}}{{if .Flags}}
OPTIONS:
{{range .Flags}}{{.}}
{{end}}{{end}}
`
var helpCommand = Command{
Name: "help",
Aliases: []string{"h"},
Usage: "Shows a list of commands or help for one command",
Action: func(c *Context) {
args := c.Args()
if args.Present() {
ShowCommandHelp(c, args.First())
} else {
ShowAppHelp(c)
}
},
}
var helpSubcommand = Command{
Name: "help",
Aliases: []string{"h"},
Usage: "Shows a list of commands or help for one command",
Action: func(c *Context) {
args := c.Args()
if args.Present() {
ShowCommandHelp(c, args.First())
} else {
ShowSubcommandHelp(c)
}
},
}
// Prints help for the App
type helpPrinter func(templ string, data interface{})
var HelpPrinter helpPrinter = nil
// Prints version for the App
var VersionPrinter = printVersion
func ShowAppHelp(c *Context) {
HelpPrinter(AppHelpTemplate, c.App)
}
// Prints the list of subcommands as the default app completion method
func DefaultAppComplete(c *Context) {
for _, command := range c.App.Commands {
for _, name := range command.Names() {
fmt.Fprintln(c.App.Writer, name)
}
}
}
// Prints help for the given command
func ShowCommandHelp(c *Context, command string) {
// show the subcommand help for a command with subcommands
if command == "" {
HelpPrinter(SubcommandHelpTemplate, c.App)
return
}
for _, c := range c.App.Commands {
if c.HasName(command) {
HelpPrinter(CommandHelpTemplate, c)
return
}
}
if c.App.CommandNotFound != nil {
c.App.CommandNotFound(c, command)
} else {
fmt.Fprintf(c.App.Writer, "No help topic for '%v'\n", command)
}
}
// Prints help for the given subcommand
func ShowSubcommandHelp(c *Context) {
ShowCommandHelp(c, c.Command.Name)
}
// Prints the version number of the App
func ShowVersion(c *Context) {
VersionPrinter(c)
}
func printVersion(c *Context) {
fmt.Fprintf(c.App.Writer, "%v version %v\n", c.App.Name, c.App.Version)
}
// Prints the lists of commands within a given context
func ShowCompletions(c *Context) {
a := c.App
if a != nil && a.BashComplete != nil {
a.BashComplete(c)
}
}
// Prints the custom completions for a given command
func ShowCommandCompletions(ctx *Context, command string) {
c := ctx.App.Command(command)
if c != nil && c.BashComplete != nil {
c.BashComplete(ctx)
}
}
func checkVersion(c *Context) bool {
if c.GlobalBool("version") {
ShowVersion(c)
return true
}
return false
}
func checkHelp(c *Context) bool {
if c.GlobalBool("h") || c.GlobalBool("help") {
ShowAppHelp(c)
return true
}
return false
}
func checkCommandHelp(c *Context, name string) bool {
if c.Bool("h") || c.Bool("help") {
ShowCommandHelp(c, name)
return true
}
return false
}
func checkSubcommandHelp(c *Context) bool {
if c.GlobalBool("h") || c.GlobalBool("help") {
ShowSubcommandHelp(c)
return true
}
return false
}
func checkCompletions(c *Context) bool {
if (c.GlobalBool(BashCompletionFlag.Name) || c.Bool(BashCompletionFlag.Name)) && c.App.EnableBashCompletion {
ShowCompletions(c)
return true
}
return false
}
func checkCommandCompletions(c *Context, name string) bool {
if c.Bool(BashCompletionFlag.Name) && c.App.EnableBashCompletion {
ShowCommandCompletions(c, name)
return true
}
return false
}

View File

@ -0,0 +1,19 @@
package cli_test
import (
"reflect"
"testing"
)
/* Test Helpers */
func expect(t *testing.T, a interface{}, b interface{}) {
if a != b {
t.Errorf("Expected %v (type %v) - Got %v (type %v)", b, reflect.TypeOf(b), a, reflect.TypeOf(a))
}
}
func refute(t *testing.T, a interface{}, b interface{}) {
if a == b {
t.Errorf("Did not expect %v (type %v) - Got %v (type %v)", b, reflect.TypeOf(b), a, reflect.TypeOf(a))
}
}

View File

@ -0,0 +1,450 @@
/*
* Copyright (c) 2013 Dave Collins <dave@davec.name>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
package spew
import (
"bytes"
"fmt"
"io"
"reflect"
"sort"
"strconv"
"unsafe"
)
const (
// ptrSize is the size of a pointer on the current arch.
ptrSize = unsafe.Sizeof((*byte)(nil))
)
var (
// offsetPtr, offsetScalar, and offsetFlag are the offsets for the
// internal reflect.Value fields. These values are valid before golang
// commit ecccf07e7f9d which changed the format. The are also valid
// after commit 82f48826c6c7 which changed the format again to mirror
// the original format. Code in the init function updates these offsets
// as necessary.
offsetPtr = uintptr(ptrSize)
offsetScalar = uintptr(0)
offsetFlag = uintptr(ptrSize * 2)
// flagKindWidth and flagKindShift indicate various bits that the
// reflect package uses internally to track kind information.
//
// flagRO indicates whether or not the value field of a reflect.Value is
// read-only.
//
// flagIndir indicates whether the value field of a reflect.Value is
// the actual data or a pointer to the data.
//
// These values are valid before golang commit 90a7c3c86944 which
// changed their positions. Code in the init function updates these
// flags as necessary.
flagKindWidth = uintptr(5)
flagKindShift = uintptr(flagKindWidth - 1)
flagRO = uintptr(1 << 0)
flagIndir = uintptr(1 << 1)
)
func init() {
// Older versions of reflect.Value stored small integers directly in the
// ptr field (which is named val in the older versions). Versions
// between commits ecccf07e7f9d and 82f48826c6c7 added a new field named
// scalar for this purpose which unfortunately came before the flag
// field, so the offset of the flag field is different for those
// versions.
//
// This code constructs a new reflect.Value from a known small integer
// and checks if the size of the reflect.Value struct indicates it has
// the scalar field. When it does, the offsets are updated accordingly.
vv := reflect.ValueOf(0xf00)
if unsafe.Sizeof(vv) == (ptrSize * 4) {
offsetScalar = ptrSize * 2
offsetFlag = ptrSize * 3
}
// Commit 90a7c3c86944 changed the flag positions such that the low
// order bits are the kind. This code extracts the kind from the flags
// field and ensures it's the correct type. When it's not, the flag
// order has been changed to the newer format, so the flags are updated
// accordingly.
upf := unsafe.Pointer(uintptr(unsafe.Pointer(&vv)) + offsetFlag)
upfv := *(*uintptr)(upf)
flagKindMask := uintptr((1<<flagKindWidth - 1) << flagKindShift)
if (upfv&flagKindMask)>>flagKindShift != uintptr(reflect.Int) {
flagKindShift = 0
flagRO = 1 << 5
flagIndir = 1 << 6
}
}
// unsafeReflectValue converts the passed reflect.Value into a one that bypasses
// the typical safety restrictions preventing access to unaddressable and
// unexported data. It works by digging the raw pointer to the underlying
// value out of the protected value and generating a new unprotected (unsafe)
// reflect.Value to it.
//
// This allows us to check for implementations of the Stringer and error
// interfaces to be used for pretty printing ordinarily unaddressable and
// inaccessible values such as unexported struct fields.
func unsafeReflectValue(v reflect.Value) (rv reflect.Value) {
indirects := 1
vt := v.Type()
upv := unsafe.Pointer(uintptr(unsafe.Pointer(&v)) + offsetPtr)
rvf := *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&v)) + offsetFlag))
if rvf&flagIndir != 0 {
vt = reflect.PtrTo(v.Type())
indirects++
} else if offsetScalar != 0 {
// The value is in the scalar field when it's not one of the
// reference types.
switch vt.Kind() {
case reflect.Uintptr:
case reflect.Chan:
case reflect.Func:
case reflect.Map:
case reflect.Ptr:
case reflect.UnsafePointer:
default:
upv = unsafe.Pointer(uintptr(unsafe.Pointer(&v)) +
offsetScalar)
}
}
pv := reflect.NewAt(vt, upv)
rv = pv
for i := 0; i < indirects; i++ {
rv = rv.Elem()
}
return rv
}
// Some constants in the form of bytes to avoid string overhead. This mirrors
// the technique used in the fmt package.
var (
panicBytes = []byte("(PANIC=")
plusBytes = []byte("+")
iBytes = []byte("i")
trueBytes = []byte("true")
falseBytes = []byte("false")
interfaceBytes = []byte("(interface {})")
commaNewlineBytes = []byte(",\n")
newlineBytes = []byte("\n")
openBraceBytes = []byte("{")
openBraceNewlineBytes = []byte("{\n")
closeBraceBytes = []byte("}")
asteriskBytes = []byte("*")
colonBytes = []byte(":")
colonSpaceBytes = []byte(": ")
openParenBytes = []byte("(")
closeParenBytes = []byte(")")
spaceBytes = []byte(" ")
pointerChainBytes = []byte("->")
nilAngleBytes = []byte("<nil>")
maxNewlineBytes = []byte("<max depth reached>\n")
maxShortBytes = []byte("<max>")
circularBytes = []byte("<already shown>")
circularShortBytes = []byte("<shown>")
invalidAngleBytes = []byte("<invalid>")
openBracketBytes = []byte("[")
closeBracketBytes = []byte("]")
percentBytes = []byte("%")
precisionBytes = []byte(".")
openAngleBytes = []byte("<")
closeAngleBytes = []byte(">")
openMapBytes = []byte("map[")
closeMapBytes = []byte("]")
lenEqualsBytes = []byte("len=")
capEqualsBytes = []byte("cap=")
)
// hexDigits is used to map a decimal value to a hex digit.
var hexDigits = "0123456789abcdef"
// catchPanic handles any panics that might occur during the handleMethods
// calls.
func catchPanic(w io.Writer, v reflect.Value) {
if err := recover(); err != nil {
w.Write(panicBytes)
fmt.Fprintf(w, "%v", err)
w.Write(closeParenBytes)
}
}
// handleMethods attempts to call the Error and String methods on the underlying
// type the passed reflect.Value represents and outputes the result to Writer w.
//
// It handles panics in any called methods by catching and displaying the error
// as the formatted value.
func handleMethods(cs *ConfigState, w io.Writer, v reflect.Value) (handled bool) {
// We need an interface to check if the type implements the error or
// Stringer interface. However, the reflect package won't give us an
// interface on certain things like unexported struct fields in order
// to enforce visibility rules. We use unsafe to bypass these restrictions
// since this package does not mutate the values.
if !v.CanInterface() {
v = unsafeReflectValue(v)
}
// Choose whether or not to do error and Stringer interface lookups against
// the base type or a pointer to the base type depending on settings.
// Technically calling one of these methods with a pointer receiver can
// mutate the value, however, types which choose to satisify an error or
// Stringer interface with a pointer receiver should not be mutating their
// state inside these interface methods.
var viface interface{}
if !cs.DisablePointerMethods {
if !v.CanAddr() {
v = unsafeReflectValue(v)
}
viface = v.Addr().Interface()
} else {
if v.CanAddr() {
v = v.Addr()
}
viface = v.Interface()
}
// Is it an error or Stringer?
switch iface := viface.(type) {
case error:
defer catchPanic(w, v)
if cs.ContinueOnMethod {
w.Write(openParenBytes)
w.Write([]byte(iface.Error()))
w.Write(closeParenBytes)
w.Write(spaceBytes)
return false
}
w.Write([]byte(iface.Error()))
return true
case fmt.Stringer:
defer catchPanic(w, v)
if cs.ContinueOnMethod {
w.Write(openParenBytes)
w.Write([]byte(iface.String()))
w.Write(closeParenBytes)
w.Write(spaceBytes)
return false
}
w.Write([]byte(iface.String()))
return true
}
return false
}
// printBool outputs a boolean value as true or false to Writer w.
func printBool(w io.Writer, val bool) {
if val {
w.Write(trueBytes)
} else {
w.Write(falseBytes)
}
}
// printInt outputs a signed integer value to Writer w.
func printInt(w io.Writer, val int64, base int) {
w.Write([]byte(strconv.FormatInt(val, base)))
}
// printUint outputs an unsigned integer value to Writer w.
func printUint(w io.Writer, val uint64, base int) {
w.Write([]byte(strconv.FormatUint(val, base)))
}
// printFloat outputs a floating point value using the specified precision,
// which is expected to be 32 or 64bit, to Writer w.
func printFloat(w io.Writer, val float64, precision int) {
w.Write([]byte(strconv.FormatFloat(val, 'g', -1, precision)))
}
// printComplex outputs a complex value using the specified float precision
// for the real and imaginary parts to Writer w.
func printComplex(w io.Writer, c complex128, floatPrecision int) {
r := real(c)
w.Write(openParenBytes)
w.Write([]byte(strconv.FormatFloat(r, 'g', -1, floatPrecision)))
i := imag(c)
if i >= 0 {
w.Write(plusBytes)
}
w.Write([]byte(strconv.FormatFloat(i, 'g', -1, floatPrecision)))
w.Write(iBytes)
w.Write(closeParenBytes)
}
// printHexPtr outputs a uintptr formatted as hexidecimal with a leading '0x'
// prefix to Writer w.
func printHexPtr(w io.Writer, p uintptr) {
// Null pointer.
num := uint64(p)
if num == 0 {
w.Write(nilAngleBytes)
return
}
// Max uint64 is 16 bytes in hex + 2 bytes for '0x' prefix
buf := make([]byte, 18)
// It's simpler to construct the hex string right to left.
base := uint64(16)
i := len(buf) - 1
for num >= base {
buf[i] = hexDigits[num%base]
num /= base
i--
}
buf[i] = hexDigits[num]
// Add '0x' prefix.
i--
buf[i] = 'x'
i--
buf[i] = '0'
// Strip unused leading bytes.
buf = buf[i:]
w.Write(buf)
}
// valuesSorter implements sort.Interface to allow a slice of reflect.Value
// elements to be sorted.
type valuesSorter struct {
values []reflect.Value
strings []string // either nil or same len and values
cs *ConfigState
}
// newValuesSorter initializes a valuesSorter instance, which holds a set of
// surrogate keys on which the data should be sorted. It uses flags in
// ConfigState to decide if and how to populate those surrogate keys.
func newValuesSorter(values []reflect.Value, cs *ConfigState) sort.Interface {
vs := &valuesSorter{values: values, cs: cs}
if canSortSimply(vs.values[0].Kind()) {
return vs
}
if !cs.DisableMethods {
vs.strings = make([]string, len(values))
for i := range vs.values {
b := bytes.Buffer{}
if !handleMethods(cs, &b, vs.values[i]) {
vs.strings = nil
break
}
vs.strings[i] = b.String()
}
}
if vs.strings == nil && cs.SpewKeys {
vs.strings = make([]string, len(values))
for i := range vs.values {
vs.strings[i] = Sprintf("%#v", vs.values[i].Interface())
}
}
return vs
}
// canSortSimply tests whether a reflect.Kind is a primitive that can be sorted
// directly, or whether it should be considered for sorting by surrogate keys
// (if the ConfigState allows it).
func canSortSimply(kind reflect.Kind) bool {
// This switch parallels valueSortLess, except for the default case.
switch kind {
case reflect.Bool:
return true
case reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Int:
return true
case reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uint:
return true
case reflect.Float32, reflect.Float64:
return true
case reflect.String:
return true
case reflect.Uintptr:
return true
case reflect.Array:
return true
}
return false
}
// Len returns the number of values in the slice. It is part of the
// sort.Interface implementation.
func (s *valuesSorter) Len() int {
return len(s.values)
}
// Swap swaps the values at the passed indices. It is part of the
// sort.Interface implementation.
func (s *valuesSorter) Swap(i, j int) {
s.values[i], s.values[j] = s.values[j], s.values[i]
if s.strings != nil {
s.strings[i], s.strings[j] = s.strings[j], s.strings[i]
}
}
// valueSortLess returns whether the first value should sort before the second
// value. It is used by valueSorter.Less as part of the sort.Interface
// implementation.
func valueSortLess(a, b reflect.Value) bool {
switch a.Kind() {
case reflect.Bool:
return !a.Bool() && b.Bool()
case reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Int:
return a.Int() < b.Int()
case reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uint:
return a.Uint() < b.Uint()
case reflect.Float32, reflect.Float64:
return a.Float() < b.Float()
case reflect.String:
return a.String() < b.String()
case reflect.Uintptr:
return a.Uint() < b.Uint()
case reflect.Array:
// Compare the contents of both arrays.
l := a.Len()
for i := 0; i < l; i++ {
av := a.Index(i)
bv := b.Index(i)
if av.Interface() == bv.Interface() {
continue
}
return valueSortLess(av, bv)
}
}
return a.String() < b.String()
}
// Less returns whether the value at index i should sort before the
// value at index j. It is part of the sort.Interface implementation.
func (s *valuesSorter) Less(i, j int) bool {
if s.strings == nil {
return valueSortLess(s.values[i], s.values[j])
}
return s.strings[i] < s.strings[j]
}
// sortValues is a sort function that handles both native types and any type that
// can be converted to error or Stringer. Other inputs are sorted according to
// their Value.String() value to ensure display stability.
func sortValues(values []reflect.Value, cs *ConfigState) {
if len(values) == 0 {
return
}
sort.Sort(newValuesSorter(values, cs))
}

View File

@ -0,0 +1,298 @@
/*
* Copyright (c) 2013 Dave Collins <dave@davec.name>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
package spew_test
import (
"fmt"
"reflect"
"testing"
"github.com/davecgh/go-spew/spew"
)
// custom type to test Stinger interface on non-pointer receiver.
type stringer string
// String implements the Stringer interface for testing invocation of custom
// stringers on types with non-pointer receivers.
func (s stringer) String() string {
return "stringer " + string(s)
}
// custom type to test Stinger interface on pointer receiver.
type pstringer string
// String implements the Stringer interface for testing invocation of custom
// stringers on types with only pointer receivers.
func (s *pstringer) String() string {
return "stringer " + string(*s)
}
// xref1 and xref2 are cross referencing structs for testing circular reference
// detection.
type xref1 struct {
ps2 *xref2
}
type xref2 struct {
ps1 *xref1
}
// indirCir1, indirCir2, and indirCir3 are used to generate an indirect circular
// reference for testing detection.
type indirCir1 struct {
ps2 *indirCir2
}
type indirCir2 struct {
ps3 *indirCir3
}
type indirCir3 struct {
ps1 *indirCir1
}
// embed is used to test embedded structures.
type embed struct {
a string
}
// embedwrap is used to test embedded structures.
type embedwrap struct {
*embed
e *embed
}
// panicer is used to intentionally cause a panic for testing spew properly
// handles them
type panicer int
func (p panicer) String() string {
panic("test panic")
}
// customError is used to test custom error interface invocation.
type customError int
func (e customError) Error() string {
return fmt.Sprintf("error: %d", int(e))
}
// stringizeWants converts a slice of wanted test output into a format suitable
// for a test error message.
func stringizeWants(wants []string) string {
s := ""
for i, want := range wants {
if i > 0 {
s += fmt.Sprintf("want%d: %s", i+1, want)
} else {
s += "want: " + want
}
}
return s
}
// testFailed returns whether or not a test failed by checking if the result
// of the test is in the slice of wanted strings.
func testFailed(result string, wants []string) bool {
for _, want := range wants {
if result == want {
return false
}
}
return true
}
type sortableStruct struct {
x int
}
func (ss sortableStruct) String() string {
return fmt.Sprintf("ss.%d", ss.x)
}
type unsortableStruct struct {
x int
}
type sortTestCase struct {
input []reflect.Value
expected []reflect.Value
}
func helpTestSortValues(tests []sortTestCase, cs *spew.ConfigState, t *testing.T) {
getInterfaces := func(values []reflect.Value) []interface{} {
interfaces := []interface{}{}
for _, v := range values {
interfaces = append(interfaces, v.Interface())
}
return interfaces
}
for _, test := range tests {
spew.SortValues(test.input, cs)
// reflect.DeepEqual cannot really make sense of reflect.Value,
// probably because of all the pointer tricks. For instance,
// v(2.0) != v(2.0) on a 32-bits system. Turn them into interface{}
// instead.
input := getInterfaces(test.input)
expected := getInterfaces(test.expected)
if !reflect.DeepEqual(input, expected) {
t.Errorf("Sort mismatch:\n %v != %v", input, expected)
}
}
}
// TestSortValues ensures the sort functionality for relect.Value based sorting
// works as intended.
func TestSortValues(t *testing.T) {
v := reflect.ValueOf
a := v("a")
b := v("b")
c := v("c")
embedA := v(embed{"a"})
embedB := v(embed{"b"})
embedC := v(embed{"c"})
tests := []sortTestCase{
// No values.
{
[]reflect.Value{},
[]reflect.Value{},
},
// Bools.
{
[]reflect.Value{v(false), v(true), v(false)},
[]reflect.Value{v(false), v(false), v(true)},
},
// Ints.
{
[]reflect.Value{v(2), v(1), v(3)},
[]reflect.Value{v(1), v(2), v(3)},
},
// Uints.
{
[]reflect.Value{v(uint8(2)), v(uint8(1)), v(uint8(3))},
[]reflect.Value{v(uint8(1)), v(uint8(2)), v(uint8(3))},
},
// Floats.
{
[]reflect.Value{v(2.0), v(1.0), v(3.0)},
[]reflect.Value{v(1.0), v(2.0), v(3.0)},
},
// Strings.
{
[]reflect.Value{b, a, c},
[]reflect.Value{a, b, c},
},
// Array
{
[]reflect.Value{v([3]int{3, 2, 1}), v([3]int{1, 3, 2}), v([3]int{1, 2, 3})},
[]reflect.Value{v([3]int{1, 2, 3}), v([3]int{1, 3, 2}), v([3]int{3, 2, 1})},
},
// Uintptrs.
{
[]reflect.Value{v(uintptr(2)), v(uintptr(1)), v(uintptr(3))},
[]reflect.Value{v(uintptr(1)), v(uintptr(2)), v(uintptr(3))},
},
// SortableStructs.
{
// Note: not sorted - DisableMethods is set.
[]reflect.Value{v(sortableStruct{2}), v(sortableStruct{1}), v(sortableStruct{3})},
[]reflect.Value{v(sortableStruct{2}), v(sortableStruct{1}), v(sortableStruct{3})},
},
// UnsortableStructs.
{
// Note: not sorted - SpewKeys is false.
[]reflect.Value{v(unsortableStruct{2}), v(unsortableStruct{1}), v(unsortableStruct{3})},
[]reflect.Value{v(unsortableStruct{2}), v(unsortableStruct{1}), v(unsortableStruct{3})},
},
// Invalid.
{
[]reflect.Value{embedB, embedA, embedC},
[]reflect.Value{embedB, embedA, embedC},
},
}
cs := spew.ConfigState{DisableMethods: true, SpewKeys: false}
helpTestSortValues(tests, &cs, t)
}
// TestSortValuesWithMethods ensures the sort functionality for relect.Value
// based sorting works as intended when using string methods.
func TestSortValuesWithMethods(t *testing.T) {
v := reflect.ValueOf
a := v("a")
b := v("b")
c := v("c")
tests := []sortTestCase{
// Ints.
{
[]reflect.Value{v(2), v(1), v(3)},
[]reflect.Value{v(1), v(2), v(3)},
},
// Strings.
{
[]reflect.Value{b, a, c},
[]reflect.Value{a, b, c},
},
// SortableStructs.
{
[]reflect.Value{v(sortableStruct{2}), v(sortableStruct{1}), v(sortableStruct{3})},
[]reflect.Value{v(sortableStruct{1}), v(sortableStruct{2}), v(sortableStruct{3})},
},
// UnsortableStructs.
{
// Note: not sorted - SpewKeys is false.
[]reflect.Value{v(unsortableStruct{2}), v(unsortableStruct{1}), v(unsortableStruct{3})},
[]reflect.Value{v(unsortableStruct{2}), v(unsortableStruct{1}), v(unsortableStruct{3})},
},
}
cs := spew.ConfigState{DisableMethods: false, SpewKeys: false}
helpTestSortValues(tests, &cs, t)
}
// TestSortValuesWithSpew ensures the sort functionality for relect.Value
// based sorting works as intended when using spew to stringify keys.
func TestSortValuesWithSpew(t *testing.T) {
v := reflect.ValueOf
a := v("a")
b := v("b")
c := v("c")
tests := []sortTestCase{
// Ints.
{
[]reflect.Value{v(2), v(1), v(3)},
[]reflect.Value{v(1), v(2), v(3)},
},
// Strings.
{
[]reflect.Value{b, a, c},
[]reflect.Value{a, b, c},
},
// SortableStructs.
{
[]reflect.Value{v(sortableStruct{2}), v(sortableStruct{1}), v(sortableStruct{3})},
[]reflect.Value{v(sortableStruct{1}), v(sortableStruct{2}), v(sortableStruct{3})},
},
// UnsortableStructs.
{
[]reflect.Value{v(unsortableStruct{2}), v(unsortableStruct{1}), v(unsortableStruct{3})},
[]reflect.Value{v(unsortableStruct{1}), v(unsortableStruct{2}), v(unsortableStruct{3})},
},
}
cs := spew.ConfigState{DisableMethods: true, SpewKeys: true}
helpTestSortValues(tests, &cs, t)
}

View File

@ -0,0 +1,294 @@
/*
* Copyright (c) 2013 Dave Collins <dave@davec.name>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
package spew
import (
"bytes"
"fmt"
"io"
"os"
)
// ConfigState houses the configuration options used by spew to format and
// display values. There is a global instance, Config, that is used to control
// all top-level Formatter and Dump functionality. Each ConfigState instance
// provides methods equivalent to the top-level functions.
//
// The zero value for ConfigState provides no indentation. You would typically
// want to set it to a space or a tab.
//
// Alternatively, you can use NewDefaultConfig to get a ConfigState instance
// with default settings. See the documentation of NewDefaultConfig for default
// values.
type ConfigState struct {
// Indent specifies the string to use for each indentation level. The
// global config instance that all top-level functions use set this to a
// single space by default. If you would like more indentation, you might
// set this to a tab with "\t" or perhaps two spaces with " ".
Indent string
// MaxDepth controls the maximum number of levels to descend into nested
// data structures. The default, 0, means there is no limit.
//
// NOTE: Circular data structures are properly detected, so it is not
// necessary to set this value unless you specifically want to limit deeply
// nested data structures.
MaxDepth int
// DisableMethods specifies whether or not error and Stringer interfaces are
// invoked for types that implement them.
DisableMethods bool
// DisablePointerMethods specifies whether or not to check for and invoke
// error and Stringer interfaces on types which only accept a pointer
// receiver when the current type is not a pointer.
//
// NOTE: This might be an unsafe action since calling one of these methods
// with a pointer receiver could technically mutate the value, however,
// in practice, types which choose to satisify an error or Stringer
// interface with a pointer receiver should not be mutating their state
// inside these interface methods.
DisablePointerMethods bool
// ContinueOnMethod specifies whether or not recursion should continue once
// a custom error or Stringer interface is invoked. The default, false,
// means it will print the results of invoking the custom error or Stringer
// interface and return immediately instead of continuing to recurse into
// the internals of the data type.
//
// NOTE: This flag does not have any effect if method invocation is disabled
// via the DisableMethods or DisablePointerMethods options.
ContinueOnMethod bool
// SortKeys specifies map keys should be sorted before being printed. Use
// this to have a more deterministic, diffable output. Note that only
// native types (bool, int, uint, floats, uintptr and string) and types
// that support the error or Stringer interfaces (if methods are
// enabled) are supported, with other types sorted according to the
// reflect.Value.String() output which guarantees display stability.
SortKeys bool
// SpewKeys specifies that, as a last resort attempt, map keys should
// be spewed to strings and sorted by those strings. This is only
// considered if SortKeys is true.
SpewKeys bool
}
// Config is the active configuration of the top-level functions.
// The configuration can be changed by modifying the contents of spew.Config.
var Config = ConfigState{Indent: " "}
// Errorf is a wrapper for fmt.Errorf that treats each argument as if it were
// passed with a Formatter interface returned by c.NewFormatter. It returns
// the formatted string as a value that satisfies error. See NewFormatter
// for formatting details.
//
// This function is shorthand for the following syntax:
//
// fmt.Errorf(format, c.NewFormatter(a), c.NewFormatter(b))
func (c *ConfigState) Errorf(format string, a ...interface{}) (err error) {
return fmt.Errorf(format, c.convertArgs(a)...)
}
// Fprint is a wrapper for fmt.Fprint that treats each argument as if it were
// passed with a Formatter interface returned by c.NewFormatter. It returns
// the number of bytes written and any write error encountered. See
// NewFormatter for formatting details.
//
// This function is shorthand for the following syntax:
//
// fmt.Fprint(w, c.NewFormatter(a), c.NewFormatter(b))
func (c *ConfigState) Fprint(w io.Writer, a ...interface{}) (n int, err error) {
return fmt.Fprint(w, c.convertArgs(a)...)
}
// Fprintf is a wrapper for fmt.Fprintf that treats each argument as if it were
// passed with a Formatter interface returned by c.NewFormatter. It returns
// the number of bytes written and any write error encountered. See
// NewFormatter for formatting details.
//
// This function is shorthand for the following syntax:
//
// fmt.Fprintf(w, format, c.NewFormatter(a), c.NewFormatter(b))
func (c *ConfigState) Fprintf(w io.Writer, format string, a ...interface{}) (n int, err error) {
return fmt.Fprintf(w, format, c.convertArgs(a)...)
}
// Fprintln is a wrapper for fmt.Fprintln that treats each argument as if it
// passed with a Formatter interface returned by c.NewFormatter. See
// NewFormatter for formatting details.
//
// This function is shorthand for the following syntax:
//
// fmt.Fprintln(w, c.NewFormatter(a), c.NewFormatter(b))
func (c *ConfigState) Fprintln(w io.Writer, a ...interface{}) (n int, err error) {
return fmt.Fprintln(w, c.convertArgs(a)...)
}
// Print is a wrapper for fmt.Print that treats each argument as if it were
// passed with a Formatter interface returned by c.NewFormatter. It returns
// the number of bytes written and any write error encountered. See
// NewFormatter for formatting details.
//
// This function is shorthand for the following syntax:
//
// fmt.Print(c.NewFormatter(a), c.NewFormatter(b))
func (c *ConfigState) Print(a ...interface{}) (n int, err error) {
return fmt.Print(c.convertArgs(a)...)
}
// Printf is a wrapper for fmt.Printf that treats each argument as if it were
// passed with a Formatter interface returned by c.NewFormatter. It returns
// the number of bytes written and any write error encountered. See
// NewFormatter for formatting details.
//
// This function is shorthand for the following syntax:
//
// fmt.Printf(format, c.NewFormatter(a), c.NewFormatter(b))
func (c *ConfigState) Printf(format string, a ...interface{}) (n int, err error) {
return fmt.Printf(format, c.convertArgs(a)...)
}
// Println is a wrapper for fmt.Println that treats each argument as if it were
// passed with a Formatter interface returned by c.NewFormatter. It returns
// the number of bytes written and any write error encountered. See
// NewFormatter for formatting details.
//
// This function is shorthand for the following syntax:
//
// fmt.Println(c.NewFormatter(a), c.NewFormatter(b))
func (c *ConfigState) Println(a ...interface{}) (n int, err error) {
return fmt.Println(c.convertArgs(a)...)
}
// Sprint is a wrapper for fmt.Sprint that treats each argument as if it were
// passed with a Formatter interface returned by c.NewFormatter. It returns
// the resulting string. See NewFormatter for formatting details.
//
// This function is shorthand for the following syntax:
//
// fmt.Sprint(c.NewFormatter(a), c.NewFormatter(b))
func (c *ConfigState) Sprint(a ...interface{}) string {
return fmt.Sprint(c.convertArgs(a)...)
}
// Sprintf is a wrapper for fmt.Sprintf that treats each argument as if it were
// passed with a Formatter interface returned by c.NewFormatter. It returns
// the resulting string. See NewFormatter for formatting details.
//
// This function is shorthand for the following syntax:
//
// fmt.Sprintf(format, c.NewFormatter(a), c.NewFormatter(b))
func (c *ConfigState) Sprintf(format string, a ...interface{}) string {
return fmt.Sprintf(format, c.convertArgs(a)...)
}
// Sprintln is a wrapper for fmt.Sprintln that treats each argument as if it
// were passed with a Formatter interface returned by c.NewFormatter. It
// returns the resulting string. See NewFormatter for formatting details.
//
// This function is shorthand for the following syntax:
//
// fmt.Sprintln(c.NewFormatter(a), c.NewFormatter(b))
func (c *ConfigState) Sprintln(a ...interface{}) string {
return fmt.Sprintln(c.convertArgs(a)...)
}
/*
NewFormatter returns a custom formatter that satisfies the fmt.Formatter
interface. As a result, it integrates cleanly with standard fmt package
printing functions. The formatter is useful for inline printing of smaller data
types similar to the standard %v format specifier.
The custom formatter only responds to the %v (most compact), %+v (adds pointer
addresses), %#v (adds types), and %#+v (adds types and pointer addresses) verb
combinations. Any other verbs such as %x and %q will be sent to the the
standard fmt package for formatting. In addition, the custom formatter ignores
the width and precision arguments (however they will still work on the format
specifiers not handled by the custom formatter).
Typically this function shouldn't be called directly. It is much easier to make
use of the custom formatter by calling one of the convenience functions such as
c.Printf, c.Println, or c.Printf.
*/
func (c *ConfigState) NewFormatter(v interface{}) fmt.Formatter {
return newFormatter(c, v)
}
// Fdump formats and displays the passed arguments to io.Writer w. It formats
// exactly the same as Dump.
func (c *ConfigState) Fdump(w io.Writer, a ...interface{}) {
fdump(c, w, a...)
}
/*
Dump displays the passed parameters to standard out with newlines, customizable
indentation, and additional debug information such as complete types and all
pointer addresses used to indirect to the final value. It provides the
following features over the built-in printing facilities provided by the fmt
package:
* Pointers are dereferenced and followed
* Circular data structures are detected and handled properly
* Custom Stringer/error interfaces are optionally invoked, including
on unexported types
* Custom types which only implement the Stringer/error interfaces via
a pointer receiver are optionally invoked when passing non-pointer
variables
* Byte arrays and slices are dumped like the hexdump -C command which
includes offsets, byte values in hex, and ASCII output
The configuration options are controlled by modifying the public members
of c. See ConfigState for options documentation.
See Fdump if you would prefer dumping to an arbitrary io.Writer or Sdump to
get the formatted result as a string.
*/
func (c *ConfigState) Dump(a ...interface{}) {
fdump(c, os.Stdout, a...)
}
// Sdump returns a string with the passed arguments formatted exactly the same
// as Dump.
func (c *ConfigState) Sdump(a ...interface{}) string {
var buf bytes.Buffer
fdump(c, &buf, a...)
return buf.String()
}
// convertArgs accepts a slice of arguments and returns a slice of the same
// length with each argument converted to a spew Formatter interface using
// the ConfigState associated with s.
func (c *ConfigState) convertArgs(args []interface{}) (formatters []interface{}) {
formatters = make([]interface{}, len(args))
for index, arg := range args {
formatters[index] = newFormatter(c, arg)
}
return formatters
}
// NewDefaultConfig returns a ConfigState with the following default settings.
//
// Indent: " "
// MaxDepth: 0
// DisableMethods: false
// DisablePointerMethods: false
// ContinueOnMethod: false
// SortKeys: false
func NewDefaultConfig() *ConfigState {
return &ConfigState{Indent: " "}
}

View File

@ -0,0 +1,202 @@
/*
* Copyright (c) 2013 Dave Collins <dave@davec.name>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/*
Package spew implements a deep pretty printer for Go data structures to aid in
debugging.
A quick overview of the additional features spew provides over the built-in
printing facilities for Go data types are as follows:
* Pointers are dereferenced and followed
* Circular data structures are detected and handled properly
* Custom Stringer/error interfaces are optionally invoked, including
on unexported types
* Custom types which only implement the Stringer/error interfaces via
a pointer receiver are optionally invoked when passing non-pointer
variables
* Byte arrays and slices are dumped like the hexdump -C command which
includes offsets, byte values in hex, and ASCII output (only when using
Dump style)
There are two different approaches spew allows for dumping Go data structures:
* Dump style which prints with newlines, customizable indentation,
and additional debug information such as types and all pointer addresses
used to indirect to the final value
* A custom Formatter interface that integrates cleanly with the standard fmt
package and replaces %v, %+v, %#v, and %#+v to provide inline printing
similar to the default %v while providing the additional functionality
outlined above and passing unsupported format verbs such as %x and %q
along to fmt
Quick Start
This section demonstrates how to quickly get started with spew. See the
sections below for further details on formatting and configuration options.
To dump a variable with full newlines, indentation, type, and pointer
information use Dump, Fdump, or Sdump:
spew.Dump(myVar1, myVar2, ...)
spew.Fdump(someWriter, myVar1, myVar2, ...)
str := spew.Sdump(myVar1, myVar2, ...)
Alternatively, if you would prefer to use format strings with a compacted inline
printing style, use the convenience wrappers Printf, Fprintf, etc with
%v (most compact), %+v (adds pointer addresses), %#v (adds types), or
%#+v (adds types and pointer addresses):
spew.Printf("myVar1: %v -- myVar2: %+v", myVar1, myVar2)
spew.Printf("myVar3: %#v -- myVar4: %#+v", myVar3, myVar4)
spew.Fprintf(someWriter, "myVar1: %v -- myVar2: %+v", myVar1, myVar2)
spew.Fprintf(someWriter, "myVar3: %#v -- myVar4: %#+v", myVar3, myVar4)
Configuration Options
Configuration of spew is handled by fields in the ConfigState type. For
convenience, all of the top-level functions use a global state available
via the spew.Config global.
It is also possible to create a ConfigState instance that provides methods
equivalent to the top-level functions. This allows concurrent configuration
options. See the ConfigState documentation for more details.
The following configuration options are available:
* Indent
String to use for each indentation level for Dump functions.
It is a single space by default. A popular alternative is "\t".
* MaxDepth
Maximum number of levels to descend into nested data structures.
There is no limit by default.
* DisableMethods
Disables invocation of error and Stringer interface methods.
Method invocation is enabled by default.
* DisablePointerMethods
Disables invocation of error and Stringer interface methods on types
which only accept pointer receivers from non-pointer variables.
Pointer method invocation is enabled by default.
* ContinueOnMethod
Enables recursion into types after invoking error and Stringer interface
methods. Recursion after method invocation is disabled by default.
* SortKeys
Specifies map keys should be sorted before being printed. Use
this to have a more deterministic, diffable output. Note that
only native types (bool, int, uint, floats, uintptr and string)
and types which implement error or Stringer interfaces are
supported with other types sorted according to the
reflect.Value.String() output which guarantees display
stability. Natural map order is used by default.
* SpewKeys
Specifies that, as a last resort attempt, map keys should be
spewed to strings and sorted by those strings. This is only
considered if SortKeys is true.
Dump Usage
Simply call spew.Dump with a list of variables you want to dump:
spew.Dump(myVar1, myVar2, ...)
You may also call spew.Fdump if you would prefer to output to an arbitrary
io.Writer. For example, to dump to standard error:
spew.Fdump(os.Stderr, myVar1, myVar2, ...)
A third option is to call spew.Sdump to get the formatted output as a string:
str := spew.Sdump(myVar1, myVar2, ...)
Sample Dump Output
See the Dump example for details on the setup of the types and variables being
shown here.
(main.Foo) {
unexportedField: (*main.Bar)(0xf84002e210)({
flag: (main.Flag) flagTwo,
data: (uintptr) <nil>
}),
ExportedField: (map[interface {}]interface {}) (len=1) {
(string) (len=3) "one": (bool) true
}
}
Byte (and uint8) arrays and slices are displayed uniquely like the hexdump -C
command as shown.
([]uint8) (len=32 cap=32) {
00000000 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 |............... |
00000010 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30 |!"#$%&'()*+,-./0|
00000020 31 32 |12|
}
Custom Formatter
Spew provides a custom formatter that implements the fmt.Formatter interface
so that it integrates cleanly with standard fmt package printing functions. The
formatter is useful for inline printing of smaller data types similar to the
standard %v format specifier.
The custom formatter only responds to the %v (most compact), %+v (adds pointer
addresses), %#v (adds types), or %#+v (adds types and pointer addresses) verb
combinations. Any other verbs such as %x and %q will be sent to the the
standard fmt package for formatting. In addition, the custom formatter ignores
the width and precision arguments (however they will still work on the format
specifiers not handled by the custom formatter).
Custom Formatter Usage
The simplest way to make use of the spew custom formatter is to call one of the
convenience functions such as spew.Printf, spew.Println, or spew.Printf. The
functions have syntax you are most likely already familiar with:
spew.Printf("myVar1: %v -- myVar2: %+v", myVar1, myVar2)
spew.Printf("myVar3: %#v -- myVar4: %#+v", myVar3, myVar4)
spew.Println(myVar, myVar2)
spew.Fprintf(os.Stderr, "myVar1: %v -- myVar2: %+v", myVar1, myVar2)
spew.Fprintf(os.Stderr, "myVar3: %#v -- myVar4: %#+v", myVar3, myVar4)
See the Index for the full list convenience functions.
Sample Formatter Output
Double pointer to a uint8:
%v: <**>5
%+v: <**>(0xf8400420d0->0xf8400420c8)5
%#v: (**uint8)5
%#+v: (**uint8)(0xf8400420d0->0xf8400420c8)5
Pointer to circular struct with a uint8 field and a pointer to itself:
%v: <*>{1 <*><shown>}
%+v: <*>(0xf84003e260){ui8:1 c:<*>(0xf84003e260)<shown>}
%#v: (*main.circular){ui8:(uint8)1 c:(*main.circular)<shown>}
%#+v: (*main.circular)(0xf84003e260){ui8:(uint8)1 c:(*main.circular)(0xf84003e260)<shown>}
See the Printf example for details on the setup of variables being shown
here.
Errors
Since it is possible for custom Stringer/error interfaces to panic, spew
detects them and handles them internally by printing the panic information
inline with the output. Since spew is intended to provide deep pretty printing
capabilities on structures, it intentionally does not return any errors.
*/
package spew

View File

@ -0,0 +1,506 @@
/*
* Copyright (c) 2013 Dave Collins <dave@davec.name>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
package spew
import (
"bytes"
"encoding/hex"
"fmt"
"io"
"os"
"reflect"
"regexp"
"strconv"
"strings"
)
var (
// uint8Type is a reflect.Type representing a uint8. It is used to
// convert cgo types to uint8 slices for hexdumping.
uint8Type = reflect.TypeOf(uint8(0))
// cCharRE is a regular expression that matches a cgo char.
// It is used to detect character arrays to hexdump them.
cCharRE = regexp.MustCompile("^.*\\._Ctype_char$")
// cUnsignedCharRE is a regular expression that matches a cgo unsigned
// char. It is used to detect unsigned character arrays to hexdump
// them.
cUnsignedCharRE = regexp.MustCompile("^.*\\._Ctype_unsignedchar$")
// cUint8tCharRE is a regular expression that matches a cgo uint8_t.
// It is used to detect uint8_t arrays to hexdump them.
cUint8tCharRE = regexp.MustCompile("^.*\\._Ctype_uint8_t$")
)
// dumpState contains information about the state of a dump operation.
type dumpState struct {
w io.Writer
depth int
pointers map[uintptr]int
ignoreNextType bool
ignoreNextIndent bool
cs *ConfigState
}
// indent performs indentation according to the depth level and cs.Indent
// option.
func (d *dumpState) indent() {
if d.ignoreNextIndent {
d.ignoreNextIndent = false
return
}
d.w.Write(bytes.Repeat([]byte(d.cs.Indent), d.depth))
}
// unpackValue returns values inside of non-nil interfaces when possible.
// This is useful for data types like structs, arrays, slices, and maps which
// can contain varying types packed inside an interface.
func (d *dumpState) unpackValue(v reflect.Value) reflect.Value {
if v.Kind() == reflect.Interface && !v.IsNil() {
v = v.Elem()
}
return v
}
// dumpPtr handles formatting of pointers by indirecting them as necessary.
func (d *dumpState) dumpPtr(v reflect.Value) {
// Remove pointers at or below the current depth from map used to detect
// circular refs.
for k, depth := range d.pointers {
if depth >= d.depth {
delete(d.pointers, k)
}
}
// Keep list of all dereferenced pointers to show later.
pointerChain := make([]uintptr, 0)
// Figure out how many levels of indirection there are by dereferencing
// pointers and unpacking interfaces down the chain while detecting circular
// references.
nilFound := false
cycleFound := false
indirects := 0
ve := v
for ve.Kind() == reflect.Ptr {
if ve.IsNil() {
nilFound = true
break
}
indirects++
addr := ve.Pointer()
pointerChain = append(pointerChain, addr)
if pd, ok := d.pointers[addr]; ok && pd < d.depth {
cycleFound = true
indirects--
break
}
d.pointers[addr] = d.depth
ve = ve.Elem()
if ve.Kind() == reflect.Interface {
if ve.IsNil() {
nilFound = true
break
}
ve = ve.Elem()
}
}
// Display type information.
d.w.Write(openParenBytes)
d.w.Write(bytes.Repeat(asteriskBytes, indirects))
d.w.Write([]byte(ve.Type().String()))
d.w.Write(closeParenBytes)
// Display pointer information.
if len(pointerChain) > 0 {
d.w.Write(openParenBytes)
for i, addr := range pointerChain {
if i > 0 {
d.w.Write(pointerChainBytes)
}
printHexPtr(d.w, addr)
}
d.w.Write(closeParenBytes)
}
// Display dereferenced value.
d.w.Write(openParenBytes)
switch {
case nilFound == true:
d.w.Write(nilAngleBytes)
case cycleFound == true:
d.w.Write(circularBytes)
default:
d.ignoreNextType = true
d.dump(ve)
}
d.w.Write(closeParenBytes)
}
// dumpSlice handles formatting of arrays and slices. Byte (uint8 under
// reflection) arrays and slices are dumped in hexdump -C fashion.
func (d *dumpState) dumpSlice(v reflect.Value) {
// Determine whether this type should be hex dumped or not. Also,
// for types which should be hexdumped, try to use the underlying data
// first, then fall back to trying to convert them to a uint8 slice.
var buf []uint8
doConvert := false
doHexDump := false
numEntries := v.Len()
if numEntries > 0 {
vt := v.Index(0).Type()
vts := vt.String()
switch {
// C types that need to be converted.
case cCharRE.MatchString(vts):
fallthrough
case cUnsignedCharRE.MatchString(vts):
fallthrough
case cUint8tCharRE.MatchString(vts):
doConvert = true
// Try to use existing uint8 slices and fall back to converting
// and copying if that fails.
case vt.Kind() == reflect.Uint8:
// We need an addressable interface to convert the type back
// into a byte slice. However, the reflect package won't give
// us an interface on certain things like unexported struct
// fields in order to enforce visibility rules. We use unsafe
// to bypass these restrictions since this package does not
// mutate the values.
vs := v
if !vs.CanInterface() || !vs.CanAddr() {
vs = unsafeReflectValue(vs)
}
vs = vs.Slice(0, numEntries)
// Use the existing uint8 slice if it can be type
// asserted.
iface := vs.Interface()
if slice, ok := iface.([]uint8); ok {
buf = slice
doHexDump = true
break
}
// The underlying data needs to be converted if it can't
// be type asserted to a uint8 slice.
doConvert = true
}
// Copy and convert the underlying type if needed.
if doConvert && vt.ConvertibleTo(uint8Type) {
// Convert and copy each element into a uint8 byte
// slice.
buf = make([]uint8, numEntries)
for i := 0; i < numEntries; i++ {
vv := v.Index(i)
buf[i] = uint8(vv.Convert(uint8Type).Uint())
}
doHexDump = true
}
}
// Hexdump the entire slice as needed.
if doHexDump {
indent := strings.Repeat(d.cs.Indent, d.depth)
str := indent + hex.Dump(buf)
str = strings.Replace(str, "\n", "\n"+indent, -1)
str = strings.TrimRight(str, d.cs.Indent)
d.w.Write([]byte(str))
return
}
// Recursively call dump for each item.
for i := 0; i < numEntries; i++ {
d.dump(d.unpackValue(v.Index(i)))
if i < (numEntries - 1) {
d.w.Write(commaNewlineBytes)
} else {
d.w.Write(newlineBytes)
}
}
}
// dump is the main workhorse for dumping a value. It uses the passed reflect
// value to figure out what kind of object we are dealing with and formats it
// appropriately. It is a recursive function, however circular data structures
// are detected and handled properly.
func (d *dumpState) dump(v reflect.Value) {
// Handle invalid reflect values immediately.
kind := v.Kind()
if kind == reflect.Invalid {
d.w.Write(invalidAngleBytes)
return
}
// Handle pointers specially.
if kind == reflect.Ptr {
d.indent()
d.dumpPtr(v)
return
}
// Print type information unless already handled elsewhere.
if !d.ignoreNextType {
d.indent()
d.w.Write(openParenBytes)
d.w.Write([]byte(v.Type().String()))
d.w.Write(closeParenBytes)
d.w.Write(spaceBytes)
}
d.ignoreNextType = false
// Display length and capacity if the built-in len and cap functions
// work with the value's kind and the len/cap itself is non-zero.
valueLen, valueCap := 0, 0
switch v.Kind() {
case reflect.Array, reflect.Slice, reflect.Chan:
valueLen, valueCap = v.Len(), v.Cap()
case reflect.Map, reflect.String:
valueLen = v.Len()
}
if valueLen != 0 || valueCap != 0 {
d.w.Write(openParenBytes)
if valueLen != 0 {
d.w.Write(lenEqualsBytes)
printInt(d.w, int64(valueLen), 10)
}
if valueCap != 0 {
if valueLen != 0 {
d.w.Write(spaceBytes)
}
d.w.Write(capEqualsBytes)
printInt(d.w, int64(valueCap), 10)
}
d.w.Write(closeParenBytes)
d.w.Write(spaceBytes)
}
// Call Stringer/error interfaces if they exist and the handle methods flag
// is enabled
if !d.cs.DisableMethods {
if (kind != reflect.Invalid) && (kind != reflect.Interface) {
if handled := handleMethods(d.cs, d.w, v); handled {
return
}
}
}
switch kind {
case reflect.Invalid:
// Do nothing. We should never get here since invalid has already
// been handled above.
case reflect.Bool:
printBool(d.w, v.Bool())
case reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Int:
printInt(d.w, v.Int(), 10)
case reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uint:
printUint(d.w, v.Uint(), 10)
case reflect.Float32:
printFloat(d.w, v.Float(), 32)
case reflect.Float64:
printFloat(d.w, v.Float(), 64)
case reflect.Complex64:
printComplex(d.w, v.Complex(), 32)
case reflect.Complex128:
printComplex(d.w, v.Complex(), 64)
case reflect.Slice:
if v.IsNil() {
d.w.Write(nilAngleBytes)
break
}
fallthrough
case reflect.Array:
d.w.Write(openBraceNewlineBytes)
d.depth++
if (d.cs.MaxDepth != 0) && (d.depth > d.cs.MaxDepth) {
d.indent()
d.w.Write(maxNewlineBytes)
} else {
d.dumpSlice(v)
}
d.depth--
d.indent()
d.w.Write(closeBraceBytes)
case reflect.String:
d.w.Write([]byte(strconv.Quote(v.String())))
case reflect.Interface:
// The only time we should get here is for nil interfaces due to
// unpackValue calls.
if v.IsNil() {
d.w.Write(nilAngleBytes)
}
case reflect.Ptr:
// Do nothing. We should never get here since pointers have already
// been handled above.
case reflect.Map:
// nil maps should be indicated as different than empty maps
if v.IsNil() {
d.w.Write(nilAngleBytes)
break
}
d.w.Write(openBraceNewlineBytes)
d.depth++
if (d.cs.MaxDepth != 0) && (d.depth > d.cs.MaxDepth) {
d.indent()
d.w.Write(maxNewlineBytes)
} else {
numEntries := v.Len()
keys := v.MapKeys()
if d.cs.SortKeys {
sortValues(keys, d.cs)
}
for i, key := range keys {
d.dump(d.unpackValue(key))
d.w.Write(colonSpaceBytes)
d.ignoreNextIndent = true
d.dump(d.unpackValue(v.MapIndex(key)))
if i < (numEntries - 1) {
d.w.Write(commaNewlineBytes)
} else {
d.w.Write(newlineBytes)
}
}
}
d.depth--
d.indent()
d.w.Write(closeBraceBytes)
case reflect.Struct:
d.w.Write(openBraceNewlineBytes)
d.depth++
if (d.cs.MaxDepth != 0) && (d.depth > d.cs.MaxDepth) {
d.indent()
d.w.Write(maxNewlineBytes)
} else {
vt := v.Type()
numFields := v.NumField()
for i := 0; i < numFields; i++ {
d.indent()
vtf := vt.Field(i)
d.w.Write([]byte(vtf.Name))
d.w.Write(colonSpaceBytes)
d.ignoreNextIndent = true
d.dump(d.unpackValue(v.Field(i)))
if i < (numFields - 1) {
d.w.Write(commaNewlineBytes)
} else {
d.w.Write(newlineBytes)
}
}
}
d.depth--
d.indent()
d.w.Write(closeBraceBytes)
case reflect.Uintptr:
printHexPtr(d.w, uintptr(v.Uint()))
case reflect.UnsafePointer, reflect.Chan, reflect.Func:
printHexPtr(d.w, v.Pointer())
// There were not any other types at the time this code was written, but
// fall back to letting the default fmt package handle it in case any new
// types are added.
default:
if v.CanInterface() {
fmt.Fprintf(d.w, "%v", v.Interface())
} else {
fmt.Fprintf(d.w, "%v", v.String())
}
}
}
// fdump is a helper function to consolidate the logic from the various public
// methods which take varying writers and config states.
func fdump(cs *ConfigState, w io.Writer, a ...interface{}) {
for _, arg := range a {
if arg == nil {
w.Write(interfaceBytes)
w.Write(spaceBytes)
w.Write(nilAngleBytes)
w.Write(newlineBytes)
continue
}
d := dumpState{w: w, cs: cs}
d.pointers = make(map[uintptr]int)
d.dump(reflect.ValueOf(arg))
d.w.Write(newlineBytes)
}
}
// Fdump formats and displays the passed arguments to io.Writer w. It formats
// exactly the same as Dump.
func Fdump(w io.Writer, a ...interface{}) {
fdump(&Config, w, a...)
}
// Sdump returns a string with the passed arguments formatted exactly the same
// as Dump.
func Sdump(a ...interface{}) string {
var buf bytes.Buffer
fdump(&Config, &buf, a...)
return buf.String()
}
/*
Dump displays the passed parameters to standard out with newlines, customizable
indentation, and additional debug information such as complete types and all
pointer addresses used to indirect to the final value. It provides the
following features over the built-in printing facilities provided by the fmt
package:
* Pointers are dereferenced and followed
* Circular data structures are detected and handled properly
* Custom Stringer/error interfaces are optionally invoked, including
on unexported types
* Custom types which only implement the Stringer/error interfaces via
a pointer receiver are optionally invoked when passing non-pointer
variables
* Byte arrays and slices are dumped like the hexdump -C command which
includes offsets, byte values in hex, and ASCII output
The configuration options are controlled by an exported package global,
spew.Config. See ConfigState for options documentation.
See Fdump if you would prefer dumping to an arbitrary io.Writer or Sdump to
get the formatted result as a string.
*/
func Dump(a ...interface{}) {
fdump(&Config, os.Stdout, a...)
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,97 @@
// Copyright (c) 2013 Dave Collins <dave@davec.name>
//
// Permission to use, copy, modify, and distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
// NOTE: Due to the following build constraints, this file will only be compiled
// when both cgo is supported and "-tags testcgo" is added to the go test
// command line. This means the cgo tests are only added (and hence run) when
// specifially requested. This configuration is used because spew itself
// does not require cgo to run even though it does handle certain cgo types
// specially. Rather than forcing all clients to require cgo and an external
// C compiler just to run the tests, this scheme makes them optional.
// +build cgo,testcgo
package spew_test
import (
"fmt"
"github.com/davecgh/go-spew/spew/testdata"
)
func addCgoDumpTests() {
// C char pointer.
v := testdata.GetCgoCharPointer()
nv := testdata.GetCgoNullCharPointer()
pv := &v
vcAddr := fmt.Sprintf("%p", v)
vAddr := fmt.Sprintf("%p", pv)
pvAddr := fmt.Sprintf("%p", &pv)
vt := "*testdata._Ctype_char"
vs := "116"
addDumpTest(v, "("+vt+")("+vcAddr+")("+vs+")\n")
addDumpTest(pv, "(*"+vt+")("+vAddr+"->"+vcAddr+")("+vs+")\n")
addDumpTest(&pv, "(**"+vt+")("+pvAddr+"->"+vAddr+"->"+vcAddr+")("+vs+")\n")
addDumpTest(nv, "("+vt+")(<nil>)\n")
// C char array.
v2, v2l, v2c := testdata.GetCgoCharArray()
v2Len := fmt.Sprintf("%d", v2l)
v2Cap := fmt.Sprintf("%d", v2c)
v2t := "[6]testdata._Ctype_char"
v2s := "(len=" + v2Len + " cap=" + v2Cap + ") " +
"{\n 00000000 74 65 73 74 32 00 " +
" |test2.|\n}"
addDumpTest(v2, "("+v2t+") "+v2s+"\n")
// C unsigned char array.
v3, v3l, v3c := testdata.GetCgoUnsignedCharArray()
v3Len := fmt.Sprintf("%d", v3l)
v3Cap := fmt.Sprintf("%d", v3c)
v3t := "[6]testdata._Ctype_unsignedchar"
v3s := "(len=" + v3Len + " cap=" + v3Cap + ") " +
"{\n 00000000 74 65 73 74 33 00 " +
" |test3.|\n}"
addDumpTest(v3, "("+v3t+") "+v3s+"\n")
// C signed char array.
v4, v4l, v4c := testdata.GetCgoSignedCharArray()
v4Len := fmt.Sprintf("%d", v4l)
v4Cap := fmt.Sprintf("%d", v4c)
v4t := "[6]testdata._Ctype_schar"
v4t2 := "testdata._Ctype_schar"
v4s := "(len=" + v4Len + " cap=" + v4Cap + ") " +
"{\n (" + v4t2 + ") 116,\n (" + v4t2 + ") 101,\n (" + v4t2 +
") 115,\n (" + v4t2 + ") 116,\n (" + v4t2 + ") 52,\n (" + v4t2 +
") 0\n}"
addDumpTest(v4, "("+v4t+") "+v4s+"\n")
// C uint8_t array.
v5, v5l, v5c := testdata.GetCgoUint8tArray()
v5Len := fmt.Sprintf("%d", v5l)
v5Cap := fmt.Sprintf("%d", v5c)
v5t := "[6]testdata._Ctype_uint8_t"
v5s := "(len=" + v5Len + " cap=" + v5Cap + ") " +
"{\n 00000000 74 65 73 74 35 00 " +
" |test5.|\n}"
addDumpTest(v5, "("+v5t+") "+v5s+"\n")
// C typedefed unsigned char array.
v6, v6l, v6c := testdata.GetCgoTypdefedUnsignedCharArray()
v6Len := fmt.Sprintf("%d", v6l)
v6Cap := fmt.Sprintf("%d", v6c)
v6t := "[6]testdata._Ctype_custom_uchar_t"
v6s := "(len=" + v6Len + " cap=" + v6Cap + ") " +
"{\n 00000000 74 65 73 74 36 00 " +
" |test6.|\n}"
addDumpTest(v6, "("+v6t+") "+v6s+"\n")
}

View File

@ -0,0 +1,26 @@
// Copyright (c) 2013 Dave Collins <dave@davec.name>
//
// Permission to use, copy, modify, and distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
// NOTE: Due to the following build constraints, this file will only be compiled
// when either cgo is not supported or "-tags testcgo" is not added to the go
// test command line. This file intentionally does not setup any cgo tests in
// this scenario.
// +build !cgo !testcgo
package spew_test
func addCgoDumpTests() {
// Don't add any tests for cgo since this file is only compiled when
// there should not be any cgo tests.
}

View File

@ -0,0 +1,230 @@
/*
* Copyright (c) 2013 Dave Collins <dave@davec.name>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
package spew_test
import (
"fmt"
"github.com/davecgh/go-spew/spew"
)
type Flag int
const (
flagOne Flag = iota
flagTwo
)
var flagStrings = map[Flag]string{
flagOne: "flagOne",
flagTwo: "flagTwo",
}
func (f Flag) String() string {
if s, ok := flagStrings[f]; ok {
return s
}
return fmt.Sprintf("Unknown flag (%d)", int(f))
}
type Bar struct {
flag Flag
data uintptr
}
type Foo struct {
unexportedField Bar
ExportedField map[interface{}]interface{}
}
// This example demonstrates how to use Dump to dump variables to stdout.
func ExampleDump() {
// The following package level declarations are assumed for this example:
/*
type Flag int
const (
flagOne Flag = iota
flagTwo
)
var flagStrings = map[Flag]string{
flagOne: "flagOne",
flagTwo: "flagTwo",
}
func (f Flag) String() string {
if s, ok := flagStrings[f]; ok {
return s
}
return fmt.Sprintf("Unknown flag (%d)", int(f))
}
type Bar struct {
flag Flag
data uintptr
}
type Foo struct {
unexportedField Bar
ExportedField map[interface{}]interface{}
}
*/
// Setup some sample data structures for the example.
bar := Bar{Flag(flagTwo), uintptr(0)}
s1 := Foo{bar, map[interface{}]interface{}{"one": true}}
f := Flag(5)
b := []byte{
0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18,
0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20,
0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28,
0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30,
0x31, 0x32,
}
// Dump!
spew.Dump(s1, f, b)
// Output:
// (spew_test.Foo) {
// unexportedField: (spew_test.Bar) {
// flag: (spew_test.Flag) flagTwo,
// data: (uintptr) <nil>
// },
// ExportedField: (map[interface {}]interface {}) (len=1) {
// (string) (len=3) "one": (bool) true
// }
// }
// (spew_test.Flag) Unknown flag (5)
// ([]uint8) (len=34 cap=34) {
// 00000000 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 |............... |
// 00000010 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30 |!"#$%&'()*+,-./0|
// 00000020 31 32 |12|
// }
//
}
// This example demonstrates how to use Printf to display a variable with a
// format string and inline formatting.
func ExamplePrintf() {
// Create a double pointer to a uint 8.
ui8 := uint8(5)
pui8 := &ui8
ppui8 := &pui8
// Create a circular data type.
type circular struct {
ui8 uint8
c *circular
}
c := circular{ui8: 1}
c.c = &c
// Print!
spew.Printf("ppui8: %v\n", ppui8)
spew.Printf("circular: %v\n", c)
// Output:
// ppui8: <**>5
// circular: {1 <*>{1 <*><shown>}}
}
// This example demonstrates how to use a ConfigState.
func ExampleConfigState() {
// Modify the indent level of the ConfigState only. The global
// configuration is not modified.
scs := spew.ConfigState{Indent: "\t"}
// Output using the ConfigState instance.
v := map[string]int{"one": 1}
scs.Printf("v: %v\n", v)
scs.Dump(v)
// Output:
// v: map[one:1]
// (map[string]int) (len=1) {
// (string) (len=3) "one": (int) 1
// }
}
// This example demonstrates how to use ConfigState.Dump to dump variables to
// stdout
func ExampleConfigState_Dump() {
// See the top-level Dump example for details on the types used in this
// example.
// Create two ConfigState instances with different indentation.
scs := spew.ConfigState{Indent: "\t"}
scs2 := spew.ConfigState{Indent: " "}
// Setup some sample data structures for the example.
bar := Bar{Flag(flagTwo), uintptr(0)}
s1 := Foo{bar, map[interface{}]interface{}{"one": true}}
// Dump using the ConfigState instances.
scs.Dump(s1)
scs2.Dump(s1)
// Output:
// (spew_test.Foo) {
// unexportedField: (spew_test.Bar) {
// flag: (spew_test.Flag) flagTwo,
// data: (uintptr) <nil>
// },
// ExportedField: (map[interface {}]interface {}) (len=1) {
// (string) (len=3) "one": (bool) true
// }
// }
// (spew_test.Foo) {
// unexportedField: (spew_test.Bar) {
// flag: (spew_test.Flag) flagTwo,
// data: (uintptr) <nil>
// },
// ExportedField: (map[interface {}]interface {}) (len=1) {
// (string) (len=3) "one": (bool) true
// }
// }
//
}
// This example demonstrates how to use ConfigState.Printf to display a variable
// with a format string and inline formatting.
func ExampleConfigState_Printf() {
// See the top-level Dump example for details on the types used in this
// example.
// Create two ConfigState instances and modify the method handling of the
// first ConfigState only.
scs := spew.NewDefaultConfig()
scs2 := spew.NewDefaultConfig()
scs.DisableMethods = true
// Alternatively
// scs := spew.ConfigState{Indent: " ", DisableMethods: true}
// scs2 := spew.ConfigState{Indent: " "}
// This is of type Flag which implements a Stringer and has raw value 1.
f := flagTwo
// Dump using the ConfigState instances.
scs.Printf("f: %v\n", f)
scs2.Printf("f: %v\n", f)
// Output:
// f: 1
// f: flagTwo
}

View File

@ -0,0 +1,419 @@
/*
* Copyright (c) 2013 Dave Collins <dave@davec.name>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
package spew
import (
"bytes"
"fmt"
"reflect"
"strconv"
"strings"
)
// supportedFlags is a list of all the character flags supported by fmt package.
const supportedFlags = "0-+# "
// formatState implements the fmt.Formatter interface and contains information
// about the state of a formatting operation. The NewFormatter function can
// be used to get a new Formatter which can be used directly as arguments
// in standard fmt package printing calls.
type formatState struct {
value interface{}
fs fmt.State
depth int
pointers map[uintptr]int
ignoreNextType bool
cs *ConfigState
}
// buildDefaultFormat recreates the original format string without precision
// and width information to pass in to fmt.Sprintf in the case of an
// unrecognized type. Unless new types are added to the language, this
// function won't ever be called.
func (f *formatState) buildDefaultFormat() (format string) {
buf := bytes.NewBuffer(percentBytes)
for _, flag := range supportedFlags {
if f.fs.Flag(int(flag)) {
buf.WriteRune(flag)
}
}
buf.WriteRune('v')
format = buf.String()
return format
}
// constructOrigFormat recreates the original format string including precision
// and width information to pass along to the standard fmt package. This allows
// automatic deferral of all format strings this package doesn't support.
func (f *formatState) constructOrigFormat(verb rune) (format string) {
buf := bytes.NewBuffer(percentBytes)
for _, flag := range supportedFlags {
if f.fs.Flag(int(flag)) {
buf.WriteRune(flag)
}
}
if width, ok := f.fs.Width(); ok {
buf.WriteString(strconv.Itoa(width))
}
if precision, ok := f.fs.Precision(); ok {
buf.Write(precisionBytes)
buf.WriteString(strconv.Itoa(precision))
}
buf.WriteRune(verb)
format = buf.String()
return format
}
// unpackValue returns values inside of non-nil interfaces when possible and
// ensures that types for values which have been unpacked from an interface
// are displayed when the show types flag is also set.
// This is useful for data types like structs, arrays, slices, and maps which
// can contain varying types packed inside an interface.
func (f *formatState) unpackValue(v reflect.Value) reflect.Value {
if v.Kind() == reflect.Interface {
f.ignoreNextType = false
if !v.IsNil() {
v = v.Elem()
}
}
return v
}
// formatPtr handles formatting of pointers by indirecting them as necessary.
func (f *formatState) formatPtr(v reflect.Value) {
// Display nil if top level pointer is nil.
showTypes := f.fs.Flag('#')
if v.IsNil() && (!showTypes || f.ignoreNextType) {
f.fs.Write(nilAngleBytes)
return
}
// Remove pointers at or below the current depth from map used to detect
// circular refs.
for k, depth := range f.pointers {
if depth >= f.depth {
delete(f.pointers, k)
}
}
// Keep list of all dereferenced pointers to possibly show later.
pointerChain := make([]uintptr, 0)
// Figure out how many levels of indirection there are by derferencing
// pointers and unpacking interfaces down the chain while detecting circular
// references.
nilFound := false
cycleFound := false
indirects := 0
ve := v
for ve.Kind() == reflect.Ptr {
if ve.IsNil() {
nilFound = true
break
}
indirects++
addr := ve.Pointer()
pointerChain = append(pointerChain, addr)
if pd, ok := f.pointers[addr]; ok && pd < f.depth {
cycleFound = true
indirects--
break
}
f.pointers[addr] = f.depth
ve = ve.Elem()
if ve.Kind() == reflect.Interface {
if ve.IsNil() {
nilFound = true
break
}
ve = ve.Elem()
}
}
// Display type or indirection level depending on flags.
if showTypes && !f.ignoreNextType {
f.fs.Write(openParenBytes)
f.fs.Write(bytes.Repeat(asteriskBytes, indirects))
f.fs.Write([]byte(ve.Type().String()))
f.fs.Write(closeParenBytes)
} else {
if nilFound || cycleFound {
indirects += strings.Count(ve.Type().String(), "*")
}
f.fs.Write(openAngleBytes)
f.fs.Write([]byte(strings.Repeat("*", indirects)))
f.fs.Write(closeAngleBytes)
}
// Display pointer information depending on flags.
if f.fs.Flag('+') && (len(pointerChain) > 0) {
f.fs.Write(openParenBytes)
for i, addr := range pointerChain {
if i > 0 {
f.fs.Write(pointerChainBytes)
}
printHexPtr(f.fs, addr)
}
f.fs.Write(closeParenBytes)
}
// Display dereferenced value.
switch {
case nilFound == true:
f.fs.Write(nilAngleBytes)
case cycleFound == true:
f.fs.Write(circularShortBytes)
default:
f.ignoreNextType = true
f.format(ve)
}
}
// format is the main workhorse for providing the Formatter interface. It
// uses the passed reflect value to figure out what kind of object we are
// dealing with and formats it appropriately. It is a recursive function,
// however circular data structures are detected and handled properly.
func (f *formatState) format(v reflect.Value) {
// Handle invalid reflect values immediately.
kind := v.Kind()
if kind == reflect.Invalid {
f.fs.Write(invalidAngleBytes)
return
}
// Handle pointers specially.
if kind == reflect.Ptr {
f.formatPtr(v)
return
}
// Print type information unless already handled elsewhere.
if !f.ignoreNextType && f.fs.Flag('#') {
f.fs.Write(openParenBytes)
f.fs.Write([]byte(v.Type().String()))
f.fs.Write(closeParenBytes)
}
f.ignoreNextType = false
// Call Stringer/error interfaces if they exist and the handle methods
// flag is enabled.
if !f.cs.DisableMethods {
if (kind != reflect.Invalid) && (kind != reflect.Interface) {
if handled := handleMethods(f.cs, f.fs, v); handled {
return
}
}
}
switch kind {
case reflect.Invalid:
// Do nothing. We should never get here since invalid has already
// been handled above.
case reflect.Bool:
printBool(f.fs, v.Bool())
case reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Int:
printInt(f.fs, v.Int(), 10)
case reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uint:
printUint(f.fs, v.Uint(), 10)
case reflect.Float32:
printFloat(f.fs, v.Float(), 32)
case reflect.Float64:
printFloat(f.fs, v.Float(), 64)
case reflect.Complex64:
printComplex(f.fs, v.Complex(), 32)
case reflect.Complex128:
printComplex(f.fs, v.Complex(), 64)
case reflect.Slice:
if v.IsNil() {
f.fs.Write(nilAngleBytes)
break
}
fallthrough
case reflect.Array:
f.fs.Write(openBracketBytes)
f.depth++
if (f.cs.MaxDepth != 0) && (f.depth > f.cs.MaxDepth) {
f.fs.Write(maxShortBytes)
} else {
numEntries := v.Len()
for i := 0; i < numEntries; i++ {
if i > 0 {
f.fs.Write(spaceBytes)
}
f.ignoreNextType = true
f.format(f.unpackValue(v.Index(i)))
}
}
f.depth--
f.fs.Write(closeBracketBytes)
case reflect.String:
f.fs.Write([]byte(v.String()))
case reflect.Interface:
// The only time we should get here is for nil interfaces due to
// unpackValue calls.
if v.IsNil() {
f.fs.Write(nilAngleBytes)
}
case reflect.Ptr:
// Do nothing. We should never get here since pointers have already
// been handled above.
case reflect.Map:
// nil maps should be indicated as different than empty maps
if v.IsNil() {
f.fs.Write(nilAngleBytes)
break
}
f.fs.Write(openMapBytes)
f.depth++
if (f.cs.MaxDepth != 0) && (f.depth > f.cs.MaxDepth) {
f.fs.Write(maxShortBytes)
} else {
keys := v.MapKeys()
if f.cs.SortKeys {
sortValues(keys, f.cs)
}
for i, key := range keys {
if i > 0 {
f.fs.Write(spaceBytes)
}
f.ignoreNextType = true
f.format(f.unpackValue(key))
f.fs.Write(colonBytes)
f.ignoreNextType = true
f.format(f.unpackValue(v.MapIndex(key)))
}
}
f.depth--
f.fs.Write(closeMapBytes)
case reflect.Struct:
numFields := v.NumField()
f.fs.Write(openBraceBytes)
f.depth++
if (f.cs.MaxDepth != 0) && (f.depth > f.cs.MaxDepth) {
f.fs.Write(maxShortBytes)
} else {
vt := v.Type()
for i := 0; i < numFields; i++ {
if i > 0 {
f.fs.Write(spaceBytes)
}
vtf := vt.Field(i)
if f.fs.Flag('+') || f.fs.Flag('#') {
f.fs.Write([]byte(vtf.Name))
f.fs.Write(colonBytes)
}
f.format(f.unpackValue(v.Field(i)))
}
}
f.depth--
f.fs.Write(closeBraceBytes)
case reflect.Uintptr:
printHexPtr(f.fs, uintptr(v.Uint()))
case reflect.UnsafePointer, reflect.Chan, reflect.Func:
printHexPtr(f.fs, v.Pointer())
// There were not any other types at the time this code was written, but
// fall back to letting the default fmt package handle it if any get added.
default:
format := f.buildDefaultFormat()
if v.CanInterface() {
fmt.Fprintf(f.fs, format, v.Interface())
} else {
fmt.Fprintf(f.fs, format, v.String())
}
}
}
// Format satisfies the fmt.Formatter interface. See NewFormatter for usage
// details.
func (f *formatState) Format(fs fmt.State, verb rune) {
f.fs = fs
// Use standard formatting for verbs that are not v.
if verb != 'v' {
format := f.constructOrigFormat(verb)
fmt.Fprintf(fs, format, f.value)
return
}
if f.value == nil {
if fs.Flag('#') {
fs.Write(interfaceBytes)
}
fs.Write(nilAngleBytes)
return
}
f.format(reflect.ValueOf(f.value))
}
// newFormatter is a helper function to consolidate the logic from the various
// public methods which take varying config states.
func newFormatter(cs *ConfigState, v interface{}) fmt.Formatter {
fs := &formatState{value: v, cs: cs}
fs.pointers = make(map[uintptr]int)
return fs
}
/*
NewFormatter returns a custom formatter that satisfies the fmt.Formatter
interface. As a result, it integrates cleanly with standard fmt package
printing functions. The formatter is useful for inline printing of smaller data
types similar to the standard %v format specifier.
The custom formatter only responds to the %v (most compact), %+v (adds pointer
addresses), %#v (adds types), or %#+v (adds types and pointer addresses) verb
combinations. Any other verbs such as %x and %q will be sent to the the
standard fmt package for formatting. In addition, the custom formatter ignores
the width and precision arguments (however they will still work on the format
specifiers not handled by the custom formatter).
Typically this function shouldn't be called directly. It is much easier to make
use of the custom formatter by calling one of the convenience functions such as
Printf, Println, or Fprintf.
*/
func NewFormatter(v interface{}) fmt.Formatter {
return newFormatter(&Config, v)
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,156 @@
/*
* Copyright (c) 2013 Dave Collins <dave@davec.name>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/*
This test file is part of the spew package rather than than the spew_test
package because it needs access to internals to properly test certain cases
which are not possible via the public interface since they should never happen.
*/
package spew
import (
"bytes"
"reflect"
"testing"
"unsafe"
)
// dummyFmtState implements a fake fmt.State to use for testing invalid
// reflect.Value handling. This is necessary because the fmt package catches
// invalid values before invoking the formatter on them.
type dummyFmtState struct {
bytes.Buffer
}
func (dfs *dummyFmtState) Flag(f int) bool {
if f == int('+') {
return true
}
return false
}
func (dfs *dummyFmtState) Precision() (int, bool) {
return 0, false
}
func (dfs *dummyFmtState) Width() (int, bool) {
return 0, false
}
// TestInvalidReflectValue ensures the dump and formatter code handles an
// invalid reflect value properly. This needs access to internal state since it
// should never happen in real code and therefore can't be tested via the public
// API.
func TestInvalidReflectValue(t *testing.T) {
i := 1
// Dump invalid reflect value.
v := new(reflect.Value)
buf := new(bytes.Buffer)
d := dumpState{w: buf, cs: &Config}
d.dump(*v)
s := buf.String()
want := "<invalid>"
if s != want {
t.Errorf("InvalidReflectValue #%d\n got: %s want: %s", i, s, want)
}
i++
// Formatter invalid reflect value.
buf2 := new(dummyFmtState)
f := formatState{value: *v, cs: &Config, fs: buf2}
f.format(*v)
s = buf2.String()
want = "<invalid>"
if s != want {
t.Errorf("InvalidReflectValue #%d got: %s want: %s", i, s, want)
}
}
// changeKind uses unsafe to intentionally change the kind of a reflect.Value to
// the maximum kind value which does not exist. This is needed to test the
// fallback code which punts to the standard fmt library for new types that
// might get added to the language.
func changeKind(v *reflect.Value, readOnly bool) {
rvf := (*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(v)) + offsetFlag))
*rvf = *rvf | ((1<<flagKindWidth - 1) << flagKindShift)
if readOnly {
*rvf |= flagRO
} else {
*rvf &= ^uintptr(flagRO)
}
}
// TestAddedReflectValue tests functionaly of the dump and formatter code which
// falls back to the standard fmt library for new types that might get added to
// the language.
func TestAddedReflectValue(t *testing.T) {
i := 1
// Dump using a reflect.Value that is exported.
v := reflect.ValueOf(int8(5))
changeKind(&v, false)
buf := new(bytes.Buffer)
d := dumpState{w: buf, cs: &Config}
d.dump(v)
s := buf.String()
want := "(int8) 5"
if s != want {
t.Errorf("TestAddedReflectValue #%d\n got: %s want: %s", i, s, want)
}
i++
// Dump using a reflect.Value that is not exported.
changeKind(&v, true)
buf.Reset()
d.dump(v)
s = buf.String()
want = "(int8) <int8 Value>"
if s != want {
t.Errorf("TestAddedReflectValue #%d\n got: %s want: %s", i, s, want)
}
i++
// Formatter using a reflect.Value that is exported.
changeKind(&v, false)
buf2 := new(dummyFmtState)
f := formatState{value: v, cs: &Config, fs: buf2}
f.format(v)
s = buf2.String()
want = "5"
if s != want {
t.Errorf("TestAddedReflectValue #%d got: %s want: %s", i, s, want)
}
i++
// Formatter using a reflect.Value that is not exported.
changeKind(&v, true)
buf2.Reset()
f = formatState{value: v, cs: &Config, fs: buf2}
f.format(v)
s = buf2.String()
want = "<int8 Value>"
if s != want {
t.Errorf("TestAddedReflectValue #%d got: %s want: %s", i, s, want)
}
}
// SortValues makes the internal sortValues function available to the test
// package.
func SortValues(values []reflect.Value, cs *ConfigState) {
sortValues(values, cs)
}

View File

@ -0,0 +1,148 @@
/*
* Copyright (c) 2013 Dave Collins <dave@davec.name>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
package spew
import (
"fmt"
"io"
)
// Errorf is a wrapper for fmt.Errorf that treats each argument as if it were
// passed with a default Formatter interface returned by NewFormatter. It
// returns the formatted string as a value that satisfies error. See
// NewFormatter for formatting details.
//
// This function is shorthand for the following syntax:
//
// fmt.Errorf(format, spew.NewFormatter(a), spew.NewFormatter(b))
func Errorf(format string, a ...interface{}) (err error) {
return fmt.Errorf(format, convertArgs(a)...)
}
// Fprint is a wrapper for fmt.Fprint that treats each argument as if it were
// passed with a default Formatter interface returned by NewFormatter. It
// returns the number of bytes written and any write error encountered. See
// NewFormatter for formatting details.
//
// This function is shorthand for the following syntax:
//
// fmt.Fprint(w, spew.NewFormatter(a), spew.NewFormatter(b))
func Fprint(w io.Writer, a ...interface{}) (n int, err error) {
return fmt.Fprint(w, convertArgs(a)...)
}
// Fprintf is a wrapper for fmt.Fprintf that treats each argument as if it were
// passed with a default Formatter interface returned by NewFormatter. It
// returns the number of bytes written and any write error encountered. See
// NewFormatter for formatting details.
//
// This function is shorthand for the following syntax:
//
// fmt.Fprintf(w, format, spew.NewFormatter(a), spew.NewFormatter(b))
func Fprintf(w io.Writer, format string, a ...interface{}) (n int, err error) {
return fmt.Fprintf(w, format, convertArgs(a)...)
}
// Fprintln is a wrapper for fmt.Fprintln that treats each argument as if it
// passed with a default Formatter interface returned by NewFormatter. See
// NewFormatter for formatting details.
//
// This function is shorthand for the following syntax:
//
// fmt.Fprintln(w, spew.NewFormatter(a), spew.NewFormatter(b))
func Fprintln(w io.Writer, a ...interface{}) (n int, err error) {
return fmt.Fprintln(w, convertArgs(a)...)
}
// Print is a wrapper for fmt.Print that treats each argument as if it were
// passed with a default Formatter interface returned by NewFormatter. It
// returns the number of bytes written and any write error encountered. See
// NewFormatter for formatting details.
//
// This function is shorthand for the following syntax:
//
// fmt.Print(spew.NewFormatter(a), spew.NewFormatter(b))
func Print(a ...interface{}) (n int, err error) {
return fmt.Print(convertArgs(a)...)
}
// Printf is a wrapper for fmt.Printf that treats each argument as if it were
// passed with a default Formatter interface returned by NewFormatter. It
// returns the number of bytes written and any write error encountered. See
// NewFormatter for formatting details.
//
// This function is shorthand for the following syntax:
//
// fmt.Printf(format, spew.NewFormatter(a), spew.NewFormatter(b))
func Printf(format string, a ...interface{}) (n int, err error) {
return fmt.Printf(format, convertArgs(a)...)
}
// Println is a wrapper for fmt.Println that treats each argument as if it were
// passed with a default Formatter interface returned by NewFormatter. It
// returns the number of bytes written and any write error encountered. See
// NewFormatter for formatting details.
//
// This function is shorthand for the following syntax:
//
// fmt.Println(spew.NewFormatter(a), spew.NewFormatter(b))
func Println(a ...interface{}) (n int, err error) {
return fmt.Println(convertArgs(a)...)
}
// Sprint is a wrapper for fmt.Sprint that treats each argument as if it were
// passed with a default Formatter interface returned by NewFormatter. It
// returns the resulting string. See NewFormatter for formatting details.
//
// This function is shorthand for the following syntax:
//
// fmt.Sprint(spew.NewFormatter(a), spew.NewFormatter(b))
func Sprint(a ...interface{}) string {
return fmt.Sprint(convertArgs(a)...)
}
// Sprintf is a wrapper for fmt.Sprintf that treats each argument as if it were
// passed with a default Formatter interface returned by NewFormatter. It
// returns the resulting string. See NewFormatter for formatting details.
//
// This function is shorthand for the following syntax:
//
// fmt.Sprintf(format, spew.NewFormatter(a), spew.NewFormatter(b))
func Sprintf(format string, a ...interface{}) string {
return fmt.Sprintf(format, convertArgs(a)...)
}
// Sprintln is a wrapper for fmt.Sprintln that treats each argument as if it
// were passed with a default Formatter interface returned by NewFormatter. It
// returns the resulting string. See NewFormatter for formatting details.
//
// This function is shorthand for the following syntax:
//
// fmt.Sprintln(spew.NewFormatter(a), spew.NewFormatter(b))
func Sprintln(a ...interface{}) string {
return fmt.Sprintln(convertArgs(a)...)
}
// convertArgs accepts a slice of arguments and returns a slice of the same
// length with each argument converted to a default spew Formatter interface.
func convertArgs(args []interface{}) (formatters []interface{}) {
formatters = make([]interface{}, len(args))
for index, arg := range args {
formatters[index] = NewFormatter(arg)
}
return formatters
}

View File

@ -0,0 +1,308 @@
/*
* Copyright (c) 2013 Dave Collins <dave@davec.name>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
package spew_test
import (
"bytes"
"fmt"
"github.com/davecgh/go-spew/spew"
"io/ioutil"
"os"
"testing"
)
// spewFunc is used to identify which public function of the spew package or
// ConfigState a test applies to.
type spewFunc int
const (
fCSFdump spewFunc = iota
fCSFprint
fCSFprintf
fCSFprintln
fCSPrint
fCSPrintln
fCSSdump
fCSSprint
fCSSprintf
fCSSprintln
fCSErrorf
fCSNewFormatter
fErrorf
fFprint
fFprintln
fPrint
fPrintln
fSdump
fSprint
fSprintf
fSprintln
)
// Map of spewFunc values to names for pretty printing.
var spewFuncStrings = map[spewFunc]string{
fCSFdump: "ConfigState.Fdump",
fCSFprint: "ConfigState.Fprint",
fCSFprintf: "ConfigState.Fprintf",
fCSFprintln: "ConfigState.Fprintln",
fCSSdump: "ConfigState.Sdump",
fCSPrint: "ConfigState.Print",
fCSPrintln: "ConfigState.Println",
fCSSprint: "ConfigState.Sprint",
fCSSprintf: "ConfigState.Sprintf",
fCSSprintln: "ConfigState.Sprintln",
fCSErrorf: "ConfigState.Errorf",
fCSNewFormatter: "ConfigState.NewFormatter",
fErrorf: "spew.Errorf",
fFprint: "spew.Fprint",
fFprintln: "spew.Fprintln",
fPrint: "spew.Print",
fPrintln: "spew.Println",
fSdump: "spew.Sdump",
fSprint: "spew.Sprint",
fSprintf: "spew.Sprintf",
fSprintln: "spew.Sprintln",
}
func (f spewFunc) String() string {
if s, ok := spewFuncStrings[f]; ok {
return s
}
return fmt.Sprintf("Unknown spewFunc (%d)", int(f))
}
// spewTest is used to describe a test to be performed against the public
// functions of the spew package or ConfigState.
type spewTest struct {
cs *spew.ConfigState
f spewFunc
format string
in interface{}
want string
}
// spewTests houses the tests to be performed against the public functions of
// the spew package and ConfigState.
//
// These tests are only intended to ensure the public functions are exercised
// and are intentionally not exhaustive of types. The exhaustive type
// tests are handled in the dump and format tests.
var spewTests []spewTest
// redirStdout is a helper function to return the standard output from f as a
// byte slice.
func redirStdout(f func()) ([]byte, error) {
tempFile, err := ioutil.TempFile("", "ss-test")
if err != nil {
return nil, err
}
fileName := tempFile.Name()
defer os.Remove(fileName) // Ignore error
origStdout := os.Stdout
os.Stdout = tempFile
f()
os.Stdout = origStdout
tempFile.Close()
return ioutil.ReadFile(fileName)
}
func initSpewTests() {
// Config states with various settings.
scsDefault := spew.NewDefaultConfig()
scsNoMethods := &spew.ConfigState{Indent: " ", DisableMethods: true}
scsNoPmethods := &spew.ConfigState{Indent: " ", DisablePointerMethods: true}
scsMaxDepth := &spew.ConfigState{Indent: " ", MaxDepth: 1}
scsContinue := &spew.ConfigState{Indent: " ", ContinueOnMethod: true}
// Variables for tests on types which implement Stringer interface with and
// without a pointer receiver.
ts := stringer("test")
tps := pstringer("test")
// depthTester is used to test max depth handling for structs, array, slices
// and maps.
type depthTester struct {
ic indirCir1
arr [1]string
slice []string
m map[string]int
}
dt := depthTester{indirCir1{nil}, [1]string{"arr"}, []string{"slice"},
map[string]int{"one": 1}}
// Variable for tests on types which implement error interface.
te := customError(10)
spewTests = []spewTest{
{scsDefault, fCSFdump, "", int8(127), "(int8) 127\n"},
{scsDefault, fCSFprint, "", int16(32767), "32767"},
{scsDefault, fCSFprintf, "%v", int32(2147483647), "2147483647"},
{scsDefault, fCSFprintln, "", int(2147483647), "2147483647\n"},
{scsDefault, fCSPrint, "", int64(9223372036854775807), "9223372036854775807"},
{scsDefault, fCSPrintln, "", uint8(255), "255\n"},
{scsDefault, fCSSdump, "", uint8(64), "(uint8) 64\n"},
{scsDefault, fCSSprint, "", complex(1, 2), "(1+2i)"},
{scsDefault, fCSSprintf, "%v", complex(float32(3), 4), "(3+4i)"},
{scsDefault, fCSSprintln, "", complex(float64(5), 6), "(5+6i)\n"},
{scsDefault, fCSErrorf, "%#v", uint16(65535), "(uint16)65535"},
{scsDefault, fCSNewFormatter, "%v", uint32(4294967295), "4294967295"},
{scsDefault, fErrorf, "%v", uint64(18446744073709551615), "18446744073709551615"},
{scsDefault, fFprint, "", float32(3.14), "3.14"},
{scsDefault, fFprintln, "", float64(6.28), "6.28\n"},
{scsDefault, fPrint, "", true, "true"},
{scsDefault, fPrintln, "", false, "false\n"},
{scsDefault, fSdump, "", complex(-10, -20), "(complex128) (-10-20i)\n"},
{scsDefault, fSprint, "", complex(-1, -2), "(-1-2i)"},
{scsDefault, fSprintf, "%v", complex(float32(-3), -4), "(-3-4i)"},
{scsDefault, fSprintln, "", complex(float64(-5), -6), "(-5-6i)\n"},
{scsNoMethods, fCSFprint, "", ts, "test"},
{scsNoMethods, fCSFprint, "", &ts, "<*>test"},
{scsNoMethods, fCSFprint, "", tps, "test"},
{scsNoMethods, fCSFprint, "", &tps, "<*>test"},
{scsNoPmethods, fCSFprint, "", ts, "stringer test"},
{scsNoPmethods, fCSFprint, "", &ts, "<*>stringer test"},
{scsNoPmethods, fCSFprint, "", tps, "test"},
{scsNoPmethods, fCSFprint, "", &tps, "<*>stringer test"},
{scsMaxDepth, fCSFprint, "", dt, "{{<max>} [<max>] [<max>] map[<max>]}"},
{scsMaxDepth, fCSFdump, "", dt, "(spew_test.depthTester) {\n" +
" ic: (spew_test.indirCir1) {\n <max depth reached>\n },\n" +
" arr: ([1]string) (len=1 cap=1) {\n <max depth reached>\n },\n" +
" slice: ([]string) (len=1 cap=1) {\n <max depth reached>\n },\n" +
" m: (map[string]int) (len=1) {\n <max depth reached>\n }\n}\n"},
{scsContinue, fCSFprint, "", ts, "(stringer test) test"},
{scsContinue, fCSFdump, "", ts, "(spew_test.stringer) " +
"(len=4) (stringer test) \"test\"\n"},
{scsContinue, fCSFprint, "", te, "(error: 10) 10"},
{scsContinue, fCSFdump, "", te, "(spew_test.customError) " +
"(error: 10) 10\n"},
}
}
// TestSpew executes all of the tests described by spewTests.
func TestSpew(t *testing.T) {
initSpewTests()
t.Logf("Running %d tests", len(spewTests))
for i, test := range spewTests {
buf := new(bytes.Buffer)
switch test.f {
case fCSFdump:
test.cs.Fdump(buf, test.in)
case fCSFprint:
test.cs.Fprint(buf, test.in)
case fCSFprintf:
test.cs.Fprintf(buf, test.format, test.in)
case fCSFprintln:
test.cs.Fprintln(buf, test.in)
case fCSPrint:
b, err := redirStdout(func() { test.cs.Print(test.in) })
if err != nil {
t.Errorf("%v #%d %v", test.f, i, err)
continue
}
buf.Write(b)
case fCSPrintln:
b, err := redirStdout(func() { test.cs.Println(test.in) })
if err != nil {
t.Errorf("%v #%d %v", test.f, i, err)
continue
}
buf.Write(b)
case fCSSdump:
str := test.cs.Sdump(test.in)
buf.WriteString(str)
case fCSSprint:
str := test.cs.Sprint(test.in)
buf.WriteString(str)
case fCSSprintf:
str := test.cs.Sprintf(test.format, test.in)
buf.WriteString(str)
case fCSSprintln:
str := test.cs.Sprintln(test.in)
buf.WriteString(str)
case fCSErrorf:
err := test.cs.Errorf(test.format, test.in)
buf.WriteString(err.Error())
case fCSNewFormatter:
fmt.Fprintf(buf, test.format, test.cs.NewFormatter(test.in))
case fErrorf:
err := spew.Errorf(test.format, test.in)
buf.WriteString(err.Error())
case fFprint:
spew.Fprint(buf, test.in)
case fFprintln:
spew.Fprintln(buf, test.in)
case fPrint:
b, err := redirStdout(func() { spew.Print(test.in) })
if err != nil {
t.Errorf("%v #%d %v", test.f, i, err)
continue
}
buf.Write(b)
case fPrintln:
b, err := redirStdout(func() { spew.Println(test.in) })
if err != nil {
t.Errorf("%v #%d %v", test.f, i, err)
continue
}
buf.Write(b)
case fSdump:
str := spew.Sdump(test.in)
buf.WriteString(str)
case fSprint:
str := spew.Sprint(test.in)
buf.WriteString(str)
case fSprintf:
str := spew.Sprintf(test.format, test.in)
buf.WriteString(str)
case fSprintln:
str := spew.Sprintln(test.in)
buf.WriteString(str)
default:
t.Errorf("%v #%d unrecognized function", test.f, i)
continue
}
s := buf.String()
if test.want != s {
t.Errorf("ConfigState #%d\n got: %s want: %s", i, s, test.want)
continue
}
}
}

View File

@ -0,0 +1,82 @@
// Copyright (c) 2013 Dave Collins <dave@davec.name>
//
// Permission to use, copy, modify, and distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
// NOTE: Due to the following build constraints, this file will only be compiled
// when both cgo is supported and "-tags testcgo" is added to the go test
// command line. This code should really only be in the dumpcgo_test.go file,
// but unfortunately Go will not allow cgo in test files, so this is a
// workaround to allow cgo types to be tested. This configuration is used
// because spew itself does not require cgo to run even though it does handle
// certain cgo types specially. Rather than forcing all clients to require cgo
// and an external C compiler just to run the tests, this scheme makes them
// optional.
// +build cgo,testcgo
package testdata
/*
#include <stdint.h>
typedef unsigned char custom_uchar_t;
char *ncp = 0;
char *cp = "test";
char ca[6] = {'t', 'e', 's', 't', '2', '\0'};
unsigned char uca[6] = {'t', 'e', 's', 't', '3', '\0'};
signed char sca[6] = {'t', 'e', 's', 't', '4', '\0'};
uint8_t ui8ta[6] = {'t', 'e', 's', 't', '5', '\0'};
custom_uchar_t tuca[6] = {'t', 'e', 's', 't', '6', '\0'};
*/
import "C"
// GetCgoNullCharPointer returns a null char pointer via cgo. This is only
// used for tests.
func GetCgoNullCharPointer() interface{} {
return C.ncp
}
// GetCgoCharPointer returns a char pointer via cgo. This is only used for
// tests.
func GetCgoCharPointer() interface{} {
return C.cp
}
// GetCgoCharArray returns a char array via cgo and the array's len and cap.
// This is only used for tests.
func GetCgoCharArray() (interface{}, int, int) {
return C.ca, len(C.ca), cap(C.ca)
}
// GetCgoUnsignedCharArray returns an unsigned char array via cgo and the
// array's len and cap. This is only used for tests.
func GetCgoUnsignedCharArray() (interface{}, int, int) {
return C.uca, len(C.uca), cap(C.uca)
}
// GetCgoSignedCharArray returns a signed char array via cgo and the array's len
// and cap. This is only used for tests.
func GetCgoSignedCharArray() (interface{}, int, int) {
return C.sca, len(C.sca), cap(C.sca)
}
// GetCgoUint8tArray returns a uint8_t array via cgo and the array's len and
// cap. This is only used for tests.
func GetCgoUint8tArray() (interface{}, int, int) {
return C.ui8ta, len(C.ui8ta), cap(C.ui8ta)
}
// GetCgoTypdefedUnsignedCharArray returns a typedefed unsigned char array via
// cgo and the array's len and cap. This is only used for tests.
func GetCgoTypdefedUnsignedCharArray() (interface{}, int, int) {
return C.tuca, len(C.tuca), cap(C.tuca)
}

View File

@ -0,0 +1,12 @@
.idea/
.DS_Store
*/**/*un~
.vagrant/
*.pyc
build/
pyethash.egg-info/
*.so
*~
*.swp
MANIFEST
dist/

View File

@ -0,0 +1,23 @@
language: go
go:
- 1.4.2
before_install:
# for g++4.8 and C++11
- sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
# Set up go-ethereum
- sudo apt-get update -y -qq
- sudo apt-get install -yqq libgmp3-dev
- git clone --depth=10 https://github.com/ethereum/go-ethereum ${GOPATH}/src/github.com/ethereum/go-ethereum
# use canned dependencies from the go-ethereum repository
- export GOPATH=$GOPATH:$GOPATH/src/github.com/ethereum/go-ethereum/Godeps/_workspace/
- echo $GOPATH
install:
# need to explicitly request version 1.48 since by default we get 1.46 which does not work with C++11
- sudo apt-get install -qq --yes --force-yes g++-4.8
- sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 50
- sudo apt-get install -qq wget cmake bash libboost-test1.48-dev libboost-system1.48-dev libboost-filesystem1.48-dev nodejs python-pip python-dev valgrind
- sudo pip install virtualenv -q
script: "./test/test.sh"

View File

@ -0,0 +1,14 @@
cmake_minimum_required(VERSION 2.8.7)
project(ethash)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/modules/")
set(ETHHASH_LIBS ethash)
if (WIN32 AND WANT_CRYPTOPP)
add_subdirectory(cryptopp)
endif()
add_subdirectory(src/libethash)
add_subdirectory(src/benchmark EXCLUDE_FROM_ALL)
add_subdirectory(test/c)

View File

@ -0,0 +1,17 @@
include setup.py
# C sources
include src/libethash/internal.c
include src/libethash/sha3.c
include src/libethash/util.c
include src/python/core.c
# Headers
include src/libethash/compiler.h
include src/libethash/data_sizes.h
include src/libethash/endian.h
include src/libethash/ethash.h
include src/libethash/fnv.h
include src/libethash/internal.h
include src/libethash/sha3.h
include src/libethash/util.h

View File

@ -0,0 +1,6 @@
.PHONY: clean test
test:
./test/test.sh
clean:
rm -rf *.so pyethash.egg-info/ build/ test/python/python-virtual-env/ test/c/build/ pyethash.so test/python/*.pyc dist/ MANIFEST

View File

@ -0,0 +1,22 @@
[![Build Status](https://travis-ci.org/ethereum/ethash.svg?branch=master)](https://travis-ci.org/ethereum/ethash)
[![Windows Build Status](https://ci.appveyor.com/api/projects/status/github/debris/ethash?branch=master&svg=true)](https://ci.appveyor.com/project/debris/ethash-nr37r/branch/master)
# Ethash
For details on this project, please see the Ethereum wiki:
https://github.com/ethereum/wiki/wiki/Ethash
### Coding Style for C++ code:
Follow the same exact style as in [cpp-ethereum](https://github.com/ethereum/cpp-ethereum/blob/develop/CodingStandards.txt)
### Coding Style for C code:
The main thing above all is code consistency.
- Tabs for indentation. A tab is 4 spaces
- Try to stick to the [K&R](http://en.wikipedia.org/wiki/Indent_style#K.26R_style),
especially for the C code.
- Keep the line lengths reasonable. No hard limit on 80 characters but don't go further
than 110. Some people work with multiple buffers next to each other.
Make them like you :)

View File

@ -0,0 +1,7 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
config.vm.box = "Ubuntu 12.04"
config.vm.box_url = "https://cloud-images.ubuntu.com/vagrant/precise/current/precise-server-cloudimg-amd64-vagrant-disk1.box"
end

View File

@ -0,0 +1,43 @@
version: 1.0.0.{build}
environment:
BOOST_ROOT: "c:/projects/ethash/deps/boost"
branches:
only:
- master
- develop
os: Windows Server 2012 R2
clone_folder: c:\projects\ethash
#platform: Any CPU
#configuration: Debug
install:
# by default, all script lines are interpreted as batch
# scripts to run before build
before_build:
- echo "Downloading boost..."
- mkdir c:\projects\ethash\deps
- cd c:\projects\ethash\deps
- curl -O https://build.ethdev.com/builds/windows-precompiled/boost.tar.gz
- echo "Unzipping boost..."
- 7z x boost.tar.gz > nul
- 7z x boost.tar > nul
- ls
- echo "Running cmake..."
- cd c:\projects\ethash
- cmake .
build:
project: ALL_BUILD.vcxproj # path to Visual Studio solution or project
after_build:
- echo "Running tests..."
- cd c:\projects\ethash\test\c\Debug
- Test.exe
- echo "Finished!"

View File

@ -0,0 +1,161 @@
#.rst:
# CMakeParseArguments
# -------------------
#
#
#
# CMAKE_PARSE_ARGUMENTS(<prefix> <options> <one_value_keywords>
# <multi_value_keywords> args...)
#
# CMAKE_PARSE_ARGUMENTS() is intended to be used in macros or functions
# for parsing the arguments given to that macro or function. It
# processes the arguments and defines a set of variables which hold the
# values of the respective options.
#
# The <options> argument contains all options for the respective macro,
# i.e. keywords which can be used when calling the macro without any
# value following, like e.g. the OPTIONAL keyword of the install()
# command.
#
# The <one_value_keywords> argument contains all keywords for this macro
# which are followed by one value, like e.g. DESTINATION keyword of the
# install() command.
#
# The <multi_value_keywords> argument contains all keywords for this
# macro which can be followed by more than one value, like e.g. the
# TARGETS or FILES keywords of the install() command.
#
# When done, CMAKE_PARSE_ARGUMENTS() will have defined for each of the
# keywords listed in <options>, <one_value_keywords> and
# <multi_value_keywords> a variable composed of the given <prefix>
# followed by "_" and the name of the respective keyword. These
# variables will then hold the respective value from the argument list.
# For the <options> keywords this will be TRUE or FALSE.
#
# All remaining arguments are collected in a variable
# <prefix>_UNPARSED_ARGUMENTS, this can be checked afterwards to see
# whether your macro was called with unrecognized parameters.
#
# As an example here a my_install() macro, which takes similar arguments
# as the real install() command:
#
# ::
#
# function(MY_INSTALL)
# set(options OPTIONAL FAST)
# set(oneValueArgs DESTINATION RENAME)
# set(multiValueArgs TARGETS CONFIGURATIONS)
# cmake_parse_arguments(MY_INSTALL "${options}" "${oneValueArgs}"
# "${multiValueArgs}" ${ARGN} )
# ...
#
#
#
# Assume my_install() has been called like this:
#
# ::
#
# my_install(TARGETS foo bar DESTINATION bin OPTIONAL blub)
#
#
#
# After the cmake_parse_arguments() call the macro will have set the
# following variables:
#
# ::
#
# MY_INSTALL_OPTIONAL = TRUE
# MY_INSTALL_FAST = FALSE (this option was not used when calling my_install()
# MY_INSTALL_DESTINATION = "bin"
# MY_INSTALL_RENAME = "" (was not used)
# MY_INSTALL_TARGETS = "foo;bar"
# MY_INSTALL_CONFIGURATIONS = "" (was not used)
# MY_INSTALL_UNPARSED_ARGUMENTS = "blub" (no value expected after "OPTIONAL"
#
#
#
# You can then continue and process these variables.
#
# Keywords terminate lists of values, e.g. if directly after a
# one_value_keyword another recognized keyword follows, this is
# interpreted as the beginning of the new option. E.g.
# my_install(TARGETS foo DESTINATION OPTIONAL) would result in
# MY_INSTALL_DESTINATION set to "OPTIONAL", but MY_INSTALL_DESTINATION
# would be empty and MY_INSTALL_OPTIONAL would be set to TRUE therefor.
#=============================================================================
# Copyright 2010 Alexander Neundorf <neundorf@kde.org>
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of CMake, substitute the full
# License text for the above reference.)
if(__CMAKE_PARSE_ARGUMENTS_INCLUDED)
return()
endif()
set(__CMAKE_PARSE_ARGUMENTS_INCLUDED TRUE)
function(CMAKE_PARSE_ARGUMENTS prefix _optionNames _singleArgNames _multiArgNames)
# first set all result variables to empty/FALSE
foreach(arg_name ${_singleArgNames} ${_multiArgNames})
set(${prefix}_${arg_name})
endforeach()
foreach(option ${_optionNames})
set(${prefix}_${option} FALSE)
endforeach()
set(${prefix}_UNPARSED_ARGUMENTS)
set(insideValues FALSE)
set(currentArgName)
# now iterate over all arguments and fill the result variables
foreach(currentArg ${ARGN})
list(FIND _optionNames "${currentArg}" optionIndex) # ... then this marks the end of the arguments belonging to this keyword
list(FIND _singleArgNames "${currentArg}" singleArgIndex) # ... then this marks the end of the arguments belonging to this keyword
list(FIND _multiArgNames "${currentArg}" multiArgIndex) # ... then this marks the end of the arguments belonging to this keyword
if(${optionIndex} EQUAL -1 AND ${singleArgIndex} EQUAL -1 AND ${multiArgIndex} EQUAL -1)
if(insideValues)
if("${insideValues}" STREQUAL "SINGLE")
set(${prefix}_${currentArgName} ${currentArg})
set(insideValues FALSE)
elseif("${insideValues}" STREQUAL "MULTI")
list(APPEND ${prefix}_${currentArgName} ${currentArg})
endif()
else()
list(APPEND ${prefix}_UNPARSED_ARGUMENTS ${currentArg})
endif()
else()
if(NOT ${optionIndex} EQUAL -1)
set(${prefix}_${currentArg} TRUE)
set(insideValues FALSE)
elseif(NOT ${singleArgIndex} EQUAL -1)
set(currentArgName ${currentArg})
set(${prefix}_${currentArgName})
set(insideValues "SINGLE")
elseif(NOT ${multiArgIndex} EQUAL -1)
set(currentArgName ${currentArg})
set(${prefix}_${currentArgName})
set(insideValues "MULTI")
endif()
endif()
endforeach()
# propagate the result variables to the caller:
foreach(arg_name ${_singleArgNames} ${_multiArgNames} ${_optionNames})
set(${prefix}_${arg_name} ${${prefix}_${arg_name}} PARENT_SCOPE)
endforeach()
set(${prefix}_UNPARSED_ARGUMENTS ${${prefix}_UNPARSED_ARGUMENTS} PARENT_SCOPE)
endfunction()

View File

@ -0,0 +1,108 @@
# Module for locating the Crypto++ encryption library.
#
# Customizable variables:
# CRYPTOPP_ROOT_DIR
# This variable points to the CryptoPP root directory. On Windows the
# library location typically will have to be provided explicitly using the
# -D command-line option. The directory should include the include/cryptopp,
# lib and/or bin sub-directories.
#
# Read-only variables:
# CRYPTOPP_FOUND
# Indicates whether the library has been found.
#
# CRYPTOPP_INCLUDE_DIRS
# Points to the CryptoPP include directory.
#
# CRYPTOPP_LIBRARIES
# Points to the CryptoPP libraries that should be passed to
# target_link_libararies.
#
#
# Copyright (c) 2012 Sergiu Dotenco
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
INCLUDE (FindPackageHandleStandardArgs)
FIND_PATH (CRYPTOPP_ROOT_DIR
NAMES cryptopp/cryptlib.h include/cryptopp/cryptlib.h
PATHS ENV CRYPTOPPROOT
DOC "CryptoPP root directory")
# Re-use the previous path:
FIND_PATH (CRYPTOPP_INCLUDE_DIR
NAMES cryptopp/cryptlib.h
HINTS ${CRYPTOPP_ROOT_DIR}
PATH_SUFFIXES include
DOC "CryptoPP include directory")
FIND_LIBRARY (CRYPTOPP_LIBRARY_DEBUG
NAMES cryptlibd cryptoppd
HINTS ${CRYPTOPP_ROOT_DIR}
PATH_SUFFIXES lib
DOC "CryptoPP debug library")
FIND_LIBRARY (CRYPTOPP_LIBRARY_RELEASE
NAMES cryptlib cryptopp
HINTS ${CRYPTOPP_ROOT_DIR}
PATH_SUFFIXES lib
DOC "CryptoPP release library")
IF (CRYPTOPP_LIBRARY_DEBUG AND CRYPTOPP_LIBRARY_RELEASE)
SET (CRYPTOPP_LIBRARY
optimized ${CRYPTOPP_LIBRARY_RELEASE}
debug ${CRYPTOPP_LIBRARY_DEBUG} CACHE DOC "CryptoPP library")
ELSEIF (CRYPTOPP_LIBRARY_RELEASE)
SET (CRYPTOPP_LIBRARY ${CRYPTOPP_LIBRARY_RELEASE} CACHE DOC
"CryptoPP library")
ENDIF (CRYPTOPP_LIBRARY_DEBUG AND CRYPTOPP_LIBRARY_RELEASE)
IF (CRYPTOPP_INCLUDE_DIR)
SET (_CRYPTOPP_VERSION_HEADER ${CRYPTOPP_INCLUDE_DIR}/cryptopp/config.h)
IF (EXISTS ${_CRYPTOPP_VERSION_HEADER})
FILE (STRINGS ${_CRYPTOPP_VERSION_HEADER} _CRYPTOPP_VERSION_TMP REGEX
"^#define CRYPTOPP_VERSION[ \t]+[0-9]+$")
STRING (REGEX REPLACE
"^#define CRYPTOPP_VERSION[ \t]+([0-9]+)" "\\1" _CRYPTOPP_VERSION_TMP
${_CRYPTOPP_VERSION_TMP})
STRING (REGEX REPLACE "([0-9]+)[0-9][0-9]" "\\1" CRYPTOPP_VERSION_MAJOR
${_CRYPTOPP_VERSION_TMP})
STRING (REGEX REPLACE "[0-9]([0-9])[0-9]" "\\1" CRYPTOPP_VERSION_MINOR
${_CRYPTOPP_VERSION_TMP})
STRING (REGEX REPLACE "[0-9][0-9]([0-9])" "\\1" CRYPTOPP_VERSION_PATCH
${_CRYPTOPP_VERSION_TMP})
SET (CRYPTOPP_VERSION_COUNT 3)
SET (CRYPTOPP_VERSION
${CRYPTOPP_VERSION_MAJOR}.${CRYPTOPP_VERSION_MINOR}.${CRYPTOPP_VERSION_PATCH})
ENDIF (EXISTS ${_CRYPTOPP_VERSION_HEADER})
ENDIF (CRYPTOPP_INCLUDE_DIR)
SET (CRYPTOPP_INCLUDE_DIRS ${CRYPTOPP_INCLUDE_DIR})
SET (CRYPTOPP_LIBRARIES ${CRYPTOPP_LIBRARY})
MARK_AS_ADVANCED (CRYPTOPP_INCLUDE_DIR CRYPTOPP_LIBRARY CRYPTOPP_LIBRARY_DEBUG
CRYPTOPP_LIBRARY_RELEASE)
FIND_PACKAGE_HANDLE_STANDARD_ARGS (CryptoPP REQUIRED_VARS CRYPTOPP_ROOT_DIR
CRYPTOPP_INCLUDE_DIR CRYPTOPP_LIBRARY VERSION_VAR CRYPTOPP_VERSION)

View File

@ -0,0 +1,148 @@
#.rst:
# FindOpenCL
# ----------
#
# Try to find OpenCL
#
# Once done this will define::
#
# OpenCL_FOUND - True if OpenCL was found
# OpenCL_INCLUDE_DIRS - include directories for OpenCL
# OpenCL_LIBRARIES - link against this library to use OpenCL
# OpenCL_VERSION_STRING - Highest supported OpenCL version (eg. 1.2)
# OpenCL_VERSION_MAJOR - The major version of the OpenCL implementation
# OpenCL_VERSION_MINOR - The minor version of the OpenCL implementation
#
# The module will also define two cache variables::
#
# OpenCL_INCLUDE_DIR - the OpenCL include directory
# OpenCL_LIBRARY - the path to the OpenCL library
#
#=============================================================================
# Copyright 2014 Matthaeus G. Chajdas
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of CMake, substitute the full
# License text for the above reference.)
function(_FIND_OPENCL_VERSION)
include(CheckSymbolExists)
include(CMakePushCheckState)
set(CMAKE_REQUIRED_QUIET ${OpenCL_FIND_QUIETLY})
CMAKE_PUSH_CHECK_STATE()
foreach(VERSION "2_0" "1_2" "1_1" "1_0")
set(CMAKE_REQUIRED_INCLUDES "${OpenCL_INCLUDE_DIR}")
if(APPLE)
CHECK_SYMBOL_EXISTS(
CL_VERSION_${VERSION}
"${OpenCL_INCLUDE_DIR}/OpenCL/cl.h"
OPENCL_VERSION_${VERSION})
else()
CHECK_SYMBOL_EXISTS(
CL_VERSION_${VERSION}
"${OpenCL_INCLUDE_DIR}/CL/cl.h"
OPENCL_VERSION_${VERSION})
endif()
if(OPENCL_VERSION_${VERSION})
string(REPLACE "_" "." VERSION "${VERSION}")
set(OpenCL_VERSION_STRING ${VERSION} PARENT_SCOPE)
string(REGEX MATCHALL "[0-9]+" version_components "${VERSION}")
list(GET version_components 0 major_version)
list(GET version_components 1 minor_version)
set(OpenCL_VERSION_MAJOR ${major_version} PARENT_SCOPE)
set(OpenCL_VERSION_MINOR ${minor_version} PARENT_SCOPE)
break()
endif()
endforeach()
CMAKE_POP_CHECK_STATE()
endfunction()
find_path(OpenCL_INCLUDE_DIR
NAMES
CL/cl.h OpenCL/cl.h
PATHS
ENV "PROGRAMFILES(X86)"
ENV AMDAPPSDKROOT
ENV INTELOCLSDKROOT
ENV NVSDKCOMPUTE_ROOT
ENV CUDA_PATH
ENV ATISTREAMSDKROOT
PATH_SUFFIXES
include
OpenCL/common/inc
"AMD APP/include")
_FIND_OPENCL_VERSION()
if(WIN32)
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
find_library(OpenCL_LIBRARY
NAMES OpenCL
PATHS
ENV "PROGRAMFILES(X86)"
ENV AMDAPPSDKROOT
ENV INTELOCLSDKROOT
ENV CUDA_PATH
ENV NVSDKCOMPUTE_ROOT
ENV ATISTREAMSDKROOT
PATH_SUFFIXES
"AMD APP/lib/x86"
lib/x86
lib/Win32
OpenCL/common/lib/Win32)
elseif(CMAKE_SIZEOF_VOID_P EQUAL 8)
find_library(OpenCL_LIBRARY
NAMES OpenCL
PATHS
ENV "PROGRAMFILES(X86)"
ENV AMDAPPSDKROOT
ENV INTELOCLSDKROOT
ENV CUDA_PATH
ENV NVSDKCOMPUTE_ROOT
ENV ATISTREAMSDKROOT
PATH_SUFFIXES
"AMD APP/lib/x86_64"
lib/x86_64
lib/x64
OpenCL/common/lib/x64)
endif()
else()
find_library(OpenCL_LIBRARY
NAMES OpenCL
PATHS
ENV "PROGRAMFILES(X86)"
ENV AMDAPPSDKROOT
ENV INTELOCLSDKROOT
ENV CUDA_PATH
ENV NVSDKCOMPUTE_ROOT
ENV ATISTREAMSDKROOT
PATH_SUFFIXES
"AMD APP/lib/x86_64"
lib/x86_64
lib/x64
OpenCL/common/lib/x64)
endif()
set(OpenCL_LIBRARIES ${OpenCL_LIBRARY})
set(OpenCL_INCLUDE_DIRS ${OpenCL_INCLUDE_DIR})
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
find_package_handle_standard_args(
OpenCL
FOUND_VAR OpenCL_FOUND
REQUIRED_VARS OpenCL_LIBRARY OpenCL_INCLUDE_DIR
VERSION_VAR OpenCL_VERSION_STRING)
mark_as_advanced(
OpenCL_INCLUDE_DIR
OpenCL_LIBRARY)

View File

@ -0,0 +1,382 @@
#.rst:
# FindPackageHandleStandardArgs
# -----------------------------
#
#
#
# FIND_PACKAGE_HANDLE_STANDARD_ARGS(<name> ... )
#
# This function is intended to be used in FindXXX.cmake modules files.
# It handles the REQUIRED, QUIET and version-related arguments to
# find_package(). It also sets the <packagename>_FOUND variable. The
# package is considered found if all variables <var1>... listed contain
# valid results, e.g. valid filepaths.
#
# There are two modes of this function. The first argument in both
# modes is the name of the Find-module where it is called (in original
# casing).
#
# The first simple mode looks like this:
#
# ::
#
# FIND_PACKAGE_HANDLE_STANDARD_ARGS(<name>
# (DEFAULT_MSG|"Custom failure message") <var1>...<varN> )
#
# If the variables <var1> to <varN> are all valid, then
# <UPPERCASED_NAME>_FOUND will be set to TRUE. If DEFAULT_MSG is given
# as second argument, then the function will generate itself useful
# success and error messages. You can also supply a custom error
# message for the failure case. This is not recommended.
#
# The second mode is more powerful and also supports version checking:
#
# ::
#
# FIND_PACKAGE_HANDLE_STANDARD_ARGS(NAME
# [FOUND_VAR <resultVar>]
# [REQUIRED_VARS <var1>...<varN>]
# [VERSION_VAR <versionvar>]
# [HANDLE_COMPONENTS]
# [CONFIG_MODE]
# [FAIL_MESSAGE "Custom failure message"] )
#
# In this mode, the name of the result-variable can be set either to
# either <UPPERCASED_NAME>_FOUND or <OriginalCase_Name>_FOUND using the
# FOUND_VAR option. Other names for the result-variable are not
# allowed. So for a Find-module named FindFooBar.cmake, the two
# possible names are FooBar_FOUND and FOOBAR_FOUND. It is recommended
# to use the original case version. If the FOUND_VAR option is not
# used, the default is <UPPERCASED_NAME>_FOUND.
#
# As in the simple mode, if <var1> through <varN> are all valid,
# <packagename>_FOUND will be set to TRUE. After REQUIRED_VARS the
# variables which are required for this package are listed. Following
# VERSION_VAR the name of the variable can be specified which holds the
# version of the package which has been found. If this is done, this
# version will be checked against the (potentially) specified required
# version used in the find_package() call. The EXACT keyword is also
# handled. The default messages include information about the required
# version and the version which has been actually found, both if the
# version is ok or not. If the package supports components, use the
# HANDLE_COMPONENTS option to enable handling them. In this case,
# find_package_handle_standard_args() will report which components have
# been found and which are missing, and the <packagename>_FOUND variable
# will be set to FALSE if any of the required components (i.e. not the
# ones listed after OPTIONAL_COMPONENTS) are missing. Use the option
# CONFIG_MODE if your FindXXX.cmake module is a wrapper for a
# find_package(... NO_MODULE) call. In this case VERSION_VAR will be
# set to <NAME>_VERSION and the macro will automatically check whether
# the Config module was found. Via FAIL_MESSAGE a custom failure
# message can be specified, if this is not used, the default message
# will be displayed.
#
# Example for mode 1:
#
# ::
#
# find_package_handle_standard_args(LibXml2 DEFAULT_MSG
# LIBXML2_LIBRARY LIBXML2_INCLUDE_DIR)
#
#
#
# LibXml2 is considered to be found, if both LIBXML2_LIBRARY and
# LIBXML2_INCLUDE_DIR are valid. Then also LIBXML2_FOUND is set to
# TRUE. If it is not found and REQUIRED was used, it fails with
# FATAL_ERROR, independent whether QUIET was used or not. If it is
# found, success will be reported, including the content of <var1>. On
# repeated Cmake runs, the same message won't be printed again.
#
# Example for mode 2:
#
# ::
#
# find_package_handle_standard_args(LibXslt
# FOUND_VAR LibXslt_FOUND
# REQUIRED_VARS LibXslt_LIBRARIES LibXslt_INCLUDE_DIRS
# VERSION_VAR LibXslt_VERSION_STRING)
#
# In this case, LibXslt is considered to be found if the variable(s)
# listed after REQUIRED_VAR are all valid, i.e. LibXslt_LIBRARIES and
# LibXslt_INCLUDE_DIRS in this case. The result will then be stored in
# LibXslt_FOUND . Also the version of LibXslt will be checked by using
# the version contained in LibXslt_VERSION_STRING. Since no
# FAIL_MESSAGE is given, the default messages will be printed.
#
# Another example for mode 2:
#
# ::
#
# find_package(Automoc4 QUIET NO_MODULE HINTS /opt/automoc4)
# find_package_handle_standard_args(Automoc4 CONFIG_MODE)
#
# In this case, FindAutmoc4.cmake wraps a call to find_package(Automoc4
# NO_MODULE) and adds an additional search directory for automoc4. Here
# the result will be stored in AUTOMOC4_FOUND. The following
# FIND_PACKAGE_HANDLE_STANDARD_ARGS() call produces a proper
# success/error message.
#=============================================================================
# Copyright 2007-2009 Kitware, Inc.
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of CMake, substitute the full
# License text for the above reference.)
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageMessage.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/CMakeParseArguments.cmake)
# internal helper macro
macro(_FPHSA_FAILURE_MESSAGE _msg)
if (${_NAME}_FIND_REQUIRED)
message(FATAL_ERROR "${_msg}")
else ()
if (NOT ${_NAME}_FIND_QUIETLY)
message(STATUS "${_msg}")
endif ()
endif ()
endmacro()
# internal helper macro to generate the failure message when used in CONFIG_MODE:
macro(_FPHSA_HANDLE_FAILURE_CONFIG_MODE)
# <name>_CONFIG is set, but FOUND is false, this means that some other of the REQUIRED_VARS was not found:
if(${_NAME}_CONFIG)
_FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE}: missing: ${MISSING_VARS} (found ${${_NAME}_CONFIG} ${VERSION_MSG})")
else()
# If _CONSIDERED_CONFIGS is set, the config-file has been found, but no suitable version.
# List them all in the error message:
if(${_NAME}_CONSIDERED_CONFIGS)
set(configsText "")
list(LENGTH ${_NAME}_CONSIDERED_CONFIGS configsCount)
math(EXPR configsCount "${configsCount} - 1")
foreach(currentConfigIndex RANGE ${configsCount})
list(GET ${_NAME}_CONSIDERED_CONFIGS ${currentConfigIndex} filename)
list(GET ${_NAME}_CONSIDERED_VERSIONS ${currentConfigIndex} version)
set(configsText "${configsText} ${filename} (version ${version})\n")
endforeach()
if (${_NAME}_NOT_FOUND_MESSAGE)
set(configsText "${configsText} Reason given by package: ${${_NAME}_NOT_FOUND_MESSAGE}\n")
endif()
_FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE} ${VERSION_MSG}, checked the following files:\n${configsText}")
else()
# Simple case: No Config-file was found at all:
_FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE}: found neither ${_NAME}Config.cmake nor ${_NAME_LOWER}-config.cmake ${VERSION_MSG}")
endif()
endif()
endmacro()
function(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FIRST_ARG)
# set up the arguments for CMAKE_PARSE_ARGUMENTS and check whether we are in
# new extended or in the "old" mode:
set(options CONFIG_MODE HANDLE_COMPONENTS)
set(oneValueArgs FAIL_MESSAGE VERSION_VAR FOUND_VAR)
set(multiValueArgs REQUIRED_VARS)
set(_KEYWORDS_FOR_EXTENDED_MODE ${options} ${oneValueArgs} ${multiValueArgs} )
list(FIND _KEYWORDS_FOR_EXTENDED_MODE "${_FIRST_ARG}" INDEX)
if(${INDEX} EQUAL -1)
set(FPHSA_FAIL_MESSAGE ${_FIRST_ARG})
set(FPHSA_REQUIRED_VARS ${ARGN})
set(FPHSA_VERSION_VAR)
else()
CMAKE_PARSE_ARGUMENTS(FPHSA "${options}" "${oneValueArgs}" "${multiValueArgs}" ${_FIRST_ARG} ${ARGN})
if(FPHSA_UNPARSED_ARGUMENTS)
message(FATAL_ERROR "Unknown keywords given to FIND_PACKAGE_HANDLE_STANDARD_ARGS(): \"${FPHSA_UNPARSED_ARGUMENTS}\"")
endif()
if(NOT FPHSA_FAIL_MESSAGE)
set(FPHSA_FAIL_MESSAGE "DEFAULT_MSG")
endif()
endif()
# now that we collected all arguments, process them
if("x${FPHSA_FAIL_MESSAGE}" STREQUAL "xDEFAULT_MSG")
set(FPHSA_FAIL_MESSAGE "Could NOT find ${_NAME}")
endif()
# In config-mode, we rely on the variable <package>_CONFIG, which is set by find_package()
# when it successfully found the config-file, including version checking:
if(FPHSA_CONFIG_MODE)
list(INSERT FPHSA_REQUIRED_VARS 0 ${_NAME}_CONFIG)
list(REMOVE_DUPLICATES FPHSA_REQUIRED_VARS)
set(FPHSA_VERSION_VAR ${_NAME}_VERSION)
endif()
if(NOT FPHSA_REQUIRED_VARS)
message(FATAL_ERROR "No REQUIRED_VARS specified for FIND_PACKAGE_HANDLE_STANDARD_ARGS()")
endif()
list(GET FPHSA_REQUIRED_VARS 0 _FIRST_REQUIRED_VAR)
string(TOUPPER ${_NAME} _NAME_UPPER)
string(TOLOWER ${_NAME} _NAME_LOWER)
if(FPHSA_FOUND_VAR)
if(FPHSA_FOUND_VAR MATCHES "^${_NAME}_FOUND$" OR FPHSA_FOUND_VAR MATCHES "^${_NAME_UPPER}_FOUND$")
set(_FOUND_VAR ${FPHSA_FOUND_VAR})
else()
message(FATAL_ERROR "The argument for FOUND_VAR is \"${FPHSA_FOUND_VAR}\", but only \"${_NAME}_FOUND\" and \"${_NAME_UPPER}_FOUND\" are valid names.")
endif()
else()
set(_FOUND_VAR ${_NAME_UPPER}_FOUND)
endif()
# collect all variables which were not found, so they can be printed, so the
# user knows better what went wrong (#6375)
set(MISSING_VARS "")
set(DETAILS "")
# check if all passed variables are valid
unset(${_FOUND_VAR})
foreach(_CURRENT_VAR ${FPHSA_REQUIRED_VARS})
if(NOT ${_CURRENT_VAR})
set(${_FOUND_VAR} FALSE)
set(MISSING_VARS "${MISSING_VARS} ${_CURRENT_VAR}")
else()
set(DETAILS "${DETAILS}[${${_CURRENT_VAR}}]")
endif()
endforeach()
if(NOT "${${_FOUND_VAR}}" STREQUAL "FALSE")
set(${_FOUND_VAR} TRUE)
endif()
# component handling
unset(FOUND_COMPONENTS_MSG)
unset(MISSING_COMPONENTS_MSG)
if(FPHSA_HANDLE_COMPONENTS)
foreach(comp ${${_NAME}_FIND_COMPONENTS})
if(${_NAME}_${comp}_FOUND)
if(NOT DEFINED FOUND_COMPONENTS_MSG)
set(FOUND_COMPONENTS_MSG "found components: ")
endif()
set(FOUND_COMPONENTS_MSG "${FOUND_COMPONENTS_MSG} ${comp}")
else()
if(NOT DEFINED MISSING_COMPONENTS_MSG)
set(MISSING_COMPONENTS_MSG "missing components: ")
endif()
set(MISSING_COMPONENTS_MSG "${MISSING_COMPONENTS_MSG} ${comp}")
if(${_NAME}_FIND_REQUIRED_${comp})
set(${_FOUND_VAR} FALSE)
set(MISSING_VARS "${MISSING_VARS} ${comp}")
endif()
endif()
endforeach()
set(COMPONENT_MSG "${FOUND_COMPONENTS_MSG} ${MISSING_COMPONENTS_MSG}")
set(DETAILS "${DETAILS}[c${COMPONENT_MSG}]")
endif()
# version handling:
set(VERSION_MSG "")
set(VERSION_OK TRUE)
set(VERSION ${${FPHSA_VERSION_VAR}})
# check with DEFINED here as the requested or found version may be "0"
if (DEFINED ${_NAME}_FIND_VERSION)
if(DEFINED ${FPHSA_VERSION_VAR})
if(${_NAME}_FIND_VERSION_EXACT) # exact version required
# count the dots in the version string
string(REGEX REPLACE "[^.]" "" _VERSION_DOTS "${VERSION}")
# add one dot because there is one dot more than there are components
string(LENGTH "${_VERSION_DOTS}." _VERSION_DOTS)
if (_VERSION_DOTS GREATER ${_NAME}_FIND_VERSION_COUNT)
# Because of the C++ implementation of find_package() ${_NAME}_FIND_VERSION_COUNT
# is at most 4 here. Therefore a simple lookup table is used.
if (${_NAME}_FIND_VERSION_COUNT EQUAL 1)
set(_VERSION_REGEX "[^.]*")
elseif (${_NAME}_FIND_VERSION_COUNT EQUAL 2)
set(_VERSION_REGEX "[^.]*\\.[^.]*")
elseif (${_NAME}_FIND_VERSION_COUNT EQUAL 3)
set(_VERSION_REGEX "[^.]*\\.[^.]*\\.[^.]*")
else ()
set(_VERSION_REGEX "[^.]*\\.[^.]*\\.[^.]*\\.[^.]*")
endif ()
string(REGEX REPLACE "^(${_VERSION_REGEX})\\..*" "\\1" _VERSION_HEAD "${VERSION}")
unset(_VERSION_REGEX)
if (NOT ${_NAME}_FIND_VERSION VERSION_EQUAL _VERSION_HEAD)
set(VERSION_MSG "Found unsuitable version \"${VERSION}\", but required is exact version \"${${_NAME}_FIND_VERSION}\"")
set(VERSION_OK FALSE)
else ()
set(VERSION_MSG "(found suitable exact version \"${VERSION}\")")
endif ()
unset(_VERSION_HEAD)
else ()
if (NOT "${${_NAME}_FIND_VERSION}" VERSION_EQUAL "${VERSION}")
set(VERSION_MSG "Found unsuitable version \"${VERSION}\", but required is exact version \"${${_NAME}_FIND_VERSION}\"")
set(VERSION_OK FALSE)
else ()
set(VERSION_MSG "(found suitable exact version \"${VERSION}\")")
endif ()
endif ()
unset(_VERSION_DOTS)
else() # minimum version specified:
if ("${${_NAME}_FIND_VERSION}" VERSION_GREATER "${VERSION}")
set(VERSION_MSG "Found unsuitable version \"${VERSION}\", but required is at least \"${${_NAME}_FIND_VERSION}\"")
set(VERSION_OK FALSE)
else ()
set(VERSION_MSG "(found suitable version \"${VERSION}\", minimum required is \"${${_NAME}_FIND_VERSION}\")")
endif ()
endif()
else()
# if the package was not found, but a version was given, add that to the output:
if(${_NAME}_FIND_VERSION_EXACT)
set(VERSION_MSG "(Required is exact version \"${${_NAME}_FIND_VERSION}\")")
else()
set(VERSION_MSG "(Required is at least version \"${${_NAME}_FIND_VERSION}\")")
endif()
endif()
else ()
if(VERSION)
set(VERSION_MSG "(found version \"${VERSION}\")")
endif()
endif ()
if(VERSION_OK)
set(DETAILS "${DETAILS}[v${VERSION}(${${_NAME}_FIND_VERSION})]")
else()
set(${_FOUND_VAR} FALSE)
endif()
# print the result:
if (${_FOUND_VAR})
FIND_PACKAGE_MESSAGE(${_NAME} "Found ${_NAME}: ${${_FIRST_REQUIRED_VAR}} ${VERSION_MSG} ${COMPONENT_MSG}" "${DETAILS}")
else ()
if(FPHSA_CONFIG_MODE)
_FPHSA_HANDLE_FAILURE_CONFIG_MODE()
else()
if(NOT VERSION_OK)
_FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE}: ${VERSION_MSG} (found ${${_FIRST_REQUIRED_VAR}})")
else()
_FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE} (missing: ${MISSING_VARS}) ${VERSION_MSG}")
endif()
endif()
endif ()
set(${_FOUND_VAR} ${${_FOUND_VAR}} PARENT_SCOPE)
endfunction()

View File

@ -0,0 +1,57 @@
#.rst:
# FindPackageMessage
# ------------------
#
#
#
# FIND_PACKAGE_MESSAGE(<name> "message for user" "find result details")
#
# This macro is intended to be used in FindXXX.cmake modules files. It
# will print a message once for each unique find result. This is useful
# for telling the user where a package was found. The first argument
# specifies the name (XXX) of the package. The second argument
# specifies the message to display. The third argument lists details
# about the find result so that if they change the message will be
# displayed again. The macro also obeys the QUIET argument to the
# find_package command.
#
# Example:
#
# ::
#
# if(X11_FOUND)
# FIND_PACKAGE_MESSAGE(X11 "Found X11: ${X11_X11_LIB}"
# "[${X11_X11_LIB}][${X11_INCLUDE_DIR}]")
# else()
# ...
# endif()
#=============================================================================
# Copyright 2008-2009 Kitware, Inc.
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of CMake, substitute the full
# License text for the above reference.)
function(FIND_PACKAGE_MESSAGE pkg msg details)
# Avoid printing a message repeatedly for the same find result.
if(NOT ${pkg}_FIND_QUIETLY)
string(REPLACE "\n" "" details "${details}")
set(DETAILS_VAR FIND_PACKAGE_MESSAGE_DETAILS_${pkg})
if(NOT "${details}" STREQUAL "${${DETAILS_VAR}}")
# The message has not yet been printed.
message(STATUS "${msg}")
# Save the find details in the cache to avoid printing the same
# message again.
set("${DETAILS_VAR}" "${details}"
CACHE INTERNAL "Details about finding ${pkg}")
endif()
endif()
endfunction()

View File

@ -0,0 +1,13 @@
set(LIBRARY cryptopp)
include_directories(../../cryptopp)
# todo, subset
file(GLOB HEADERS "../../cryptopp/*.h")
file(GLOB SOURCE "../../cryptopp/*.cpp")
add_library(${LIBRARY} ${HEADERS} ${SOURCE})
set(CRYPTOPP_INCLUDE_DIRS "../.." "../../../" PARENT_SCOPE)
set(CRYPTOPP_LIBRARIES ${LIBRARY} PARENT_SCOPE)
set(CRYPTOPP_FOUND TRUE PARENT_SCOPE)

View File

@ -0,0 +1,376 @@
package ethash
/*
#include "src/libethash/internal.h"
int ethashGoCallback_cgo(unsigned);
*/
import "C"
import (
"errors"
"fmt"
"io/ioutil"
"math/big"
"math/rand"
"os"
"os/user"
"path/filepath"
"runtime"
"sync"
"sync/atomic"
"time"
"unsafe"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/logger/glog"
"github.com/ethereum/go-ethereum/pow"
)
var (
minDifficulty = new(big.Int).Exp(big.NewInt(2), big.NewInt(256), big.NewInt(0))
sharedLight = new(Light)
)
const (
epochLength uint64 = 30000
cacheSizeForTesting C.uint64_t = 1024
dagSizeForTesting C.uint64_t = 1024 * 32
)
var DefaultDir = defaultDir()
func defaultDir() string {
home := os.Getenv("HOME")
if user, err := user.Current(); err == nil {
home = user.HomeDir
}
if runtime.GOOS == "windows" {
return filepath.Join(home, "AppData", "Ethash")
}
return filepath.Join(home, ".ethash")
}
// cache wraps an ethash_light_t with some metadata
// and automatic memory management.
type cache struct {
epoch uint64
test bool
gen sync.Once // ensures cache is only generated once.
ptr *C.struct_ethash_light
}
// generate creates the actual cache. it can be called from multiple
// goroutines. the first call will generate the cache, subsequent
// calls wait until it is generated.
func (cache *cache) generate() {
cache.gen.Do(func() {
started := time.Now()
seedHash := makeSeedHash(cache.epoch)
glog.V(logger.Debug).Infof("Generating cache for epoch %d (%x)", cache.epoch, seedHash)
size := C.ethash_get_cachesize(C.uint64_t(cache.epoch * epochLength))
if cache.test {
size = cacheSizeForTesting
}
cache.ptr = C.ethash_light_new_internal(size, (*C.ethash_h256_t)(unsafe.Pointer(&seedHash[0])))
runtime.SetFinalizer(cache, freeCache)
glog.V(logger.Debug).Infof("Done generating cache for epoch %d, it took %v", cache.epoch, time.Since(started))
})
}
func freeCache(cache *cache) {
C.ethash_light_delete(cache.ptr)
cache.ptr = nil
}
// Light implements the Verify half of the proof of work.
// It uses a small in-memory cache to verify the nonces
// found by Full.
type Light struct {
test bool // if set use a smaller cache size
mu sync.Mutex // protects current
current *cache // last cache which was generated.
// TODO: keep multiple caches.
}
// Verify checks whether the block's nonce is valid.
func (l *Light) Verify(block pow.Block) bool {
// TODO: do ethash_quick_verify before getCache in order
// to prevent DOS attacks.
blockNum := block.NumberU64()
if blockNum >= epochLength*2048 {
glog.V(logger.Debug).Infof("block number %d too high, limit is %d", epochLength*2048)
return false
}
difficulty := block.Difficulty()
/* Cannot happen if block header diff is validated prior to PoW, but can
happen if PoW is checked first due to parallel PoW checking.
We could check the minimum valid difficulty but for SoC we avoid (duplicating)
Ethereum protocol consensus rules here which are not in scope of Ethash
*/
if difficulty.Cmp(common.Big0) == 0 {
glog.V(logger.Debug).Infof("invalid block difficulty")
return false
}
cache := l.getCache(blockNum)
dagSize := C.ethash_get_datasize(C.uint64_t(blockNum))
if l.test {
dagSize = dagSizeForTesting
}
// Recompute the hash using the cache.
hash := hashToH256(block.HashNoNonce())
ret := C.ethash_light_compute_internal(cache.ptr, dagSize, hash, C.uint64_t(block.Nonce()))
if !ret.success {
return false
}
// avoid mixdigest malleability as it's not included in a block's "hashNononce"
if block.MixDigest() != h256ToHash(ret.mix_hash) {
return false
}
// Make sure cache is live until after the C call.
// This is important because a GC might happen and execute
// the finalizer before the call completes.
_ = cache
// The actual check.
target := new(big.Int).Div(minDifficulty, difficulty)
return h256ToHash(ret.result).Big().Cmp(target) <= 0
}
func h256ToHash(in C.ethash_h256_t) common.Hash {
return *(*common.Hash)(unsafe.Pointer(&in.b))
}
func hashToH256(in common.Hash) C.ethash_h256_t {
return C.ethash_h256_t{b: *(*[32]C.uint8_t)(unsafe.Pointer(&in[0]))}
}
func (l *Light) getCache(blockNum uint64) *cache {
var c *cache
epoch := blockNum / epochLength
// Update or reuse the last cache.
l.mu.Lock()
if l.current != nil && l.current.epoch == epoch {
c = l.current
} else {
c = &cache{epoch: epoch, test: l.test}
l.current = c
}
l.mu.Unlock()
// Wait for the cache to finish generating.
c.generate()
return c
}
// dag wraps an ethash_full_t with some metadata
// and automatic memory management.
type dag struct {
epoch uint64
test bool
dir string
gen sync.Once // ensures DAG is only generated once.
ptr *C.struct_ethash_full
}
// generate creates the actual DAG. it can be called from multiple
// goroutines. the first call will generate the DAG, subsequent
// calls wait until it is generated.
func (d *dag) generate() {
d.gen.Do(func() {
var (
started = time.Now()
seedHash = makeSeedHash(d.epoch)
blockNum = C.uint64_t(d.epoch * epochLength)
cacheSize = C.ethash_get_cachesize(blockNum)
dagSize = C.ethash_get_datasize(blockNum)
)
if d.test {
cacheSize = cacheSizeForTesting
dagSize = dagSizeForTesting
}
if d.dir == "" {
d.dir = DefaultDir
}
glog.V(logger.Info).Infof("Generating DAG for epoch %d (%x)", d.epoch, seedHash)
// Generate a temporary cache.
// TODO: this could share the cache with Light
cache := C.ethash_light_new_internal(cacheSize, (*C.ethash_h256_t)(unsafe.Pointer(&seedHash[0])))
defer C.ethash_light_delete(cache)
// Generate the actual DAG.
d.ptr = C.ethash_full_new_internal(
C.CString(d.dir),
hashToH256(seedHash),
dagSize,
cache,
(C.ethash_callback_t)(unsafe.Pointer(C.ethashGoCallback_cgo)),
)
if d.ptr == nil {
panic("ethash_full_new IO or memory error")
}
runtime.SetFinalizer(d, freeDAG)
glog.V(logger.Info).Infof("Done generating DAG for epoch %d, it took %v", d.epoch, time.Since(started))
})
}
func freeDAG(h *dag) {
C.ethash_full_delete(h.ptr)
h.ptr = nil
}
//export ethashGoCallback
func ethashGoCallback(percent C.unsigned) C.int {
glog.V(logger.Info).Infof("Still generating DAG: %d%%", percent)
return 0
}
// MakeDAG pre-generates a DAG file for the given block number in the
// given directory. If dir is the empty string, the default directory
// is used.
func MakeDAG(blockNum uint64, dir string) error {
d := &dag{epoch: blockNum / epochLength, dir: dir}
if blockNum >= epochLength*2048 {
return fmt.Errorf("block number too high, limit is %d", epochLength*2048)
}
d.generate()
if d.ptr == nil {
return errors.New("failed")
}
return nil
}
// Full implements the Search half of the proof of work.
type Full struct {
Dir string // use this to specify a non-default DAG directory
test bool // if set use a smaller DAG size
turbo bool
hashRate int32
mu sync.Mutex // protects dag
current *dag // current full DAG
}
func (pow *Full) getDAG(blockNum uint64) (d *dag) {
epoch := blockNum / epochLength
pow.mu.Lock()
if pow.current != nil && pow.current.epoch == epoch {
d = pow.current
} else {
d = &dag{epoch: epoch, test: pow.test, dir: pow.Dir}
pow.current = d
}
pow.mu.Unlock()
// wait for it to finish generating.
d.generate()
return d
}
func (pow *Full) Search(block pow.Block, stop <-chan struct{}) (nonce uint64, mixDigest []byte) {
dag := pow.getDAG(block.NumberU64())
r := rand.New(rand.NewSource(time.Now().UnixNano()))
diff := block.Difficulty()
i := int64(0)
starti := i
start := time.Now().UnixNano()
previousHashrate := int32(0)
nonce = uint64(r.Int63())
hash := hashToH256(block.HashNoNonce())
target := new(big.Int).Div(minDifficulty, diff)
for {
select {
case <-stop:
atomic.AddInt32(&pow.hashRate, -previousHashrate)
return 0, nil
default:
i++
// we don't have to update hash rate on every nonce, so update after
// first nonce check and then after 2^X nonces
if i == 2 || ((i % (1 << 16)) == 0) {
elapsed := time.Now().UnixNano() - start
hashes := (float64(1e9) / float64(elapsed)) * float64(i-starti)
hashrateDiff := int32(hashes) - previousHashrate
previousHashrate = int32(hashes)
atomic.AddInt32(&pow.hashRate, hashrateDiff)
}
ret := C.ethash_full_compute(dag.ptr, hash, C.uint64_t(nonce))
result := h256ToHash(ret.result).Big()
// TODO: disagrees with the spec https://github.com/ethereum/wiki/wiki/Ethash#mining
if ret.success && result.Cmp(target) <= 0 {
mixDigest = C.GoBytes(unsafe.Pointer(&ret.mix_hash), C.int(32))
atomic.AddInt32(&pow.hashRate, -previousHashrate)
return nonce, mixDigest
}
nonce += 1
}
if !pow.turbo {
time.Sleep(20 * time.Microsecond)
}
}
}
func (pow *Full) GetHashrate() int64 {
return int64(atomic.LoadInt32(&pow.hashRate))
}
func (pow *Full) Turbo(on bool) {
// TODO: this needs to use an atomic operation.
pow.turbo = on
}
// Ethash combines block verification with Light and
// nonce searching with Full into a single proof of work.
type Ethash struct {
*Light
*Full
}
// New creates an instance of the proof of work.
// A single instance of Light is shared across all instances
// created with New.
func New() *Ethash {
return &Ethash{sharedLight, &Full{turbo: true}}
}
// NewForTesting creates a proof of work for use in unit tests.
// It uses a smaller DAG and cache size to keep test times low.
// DAG files are stored in a temporary directory.
//
// Nonces found by a testing instance are not verifiable with a
// regular-size cache.
func NewForTesting() (*Ethash, error) {
dir, err := ioutil.TempDir("", "ethash-test")
if err != nil {
return nil, err
}
return &Ethash{&Light{test: true}, &Full{Dir: dir, test: true}}, nil
}
func GetSeedHash(blockNum uint64) ([]byte, error) {
if blockNum >= epochLength*2048 {
return nil, fmt.Errorf("block number too high, limit is %d", epochLength*2048)
}
sh := makeSeedHash(blockNum / epochLength)
return sh[:], nil
}
func makeSeedHash(epoch uint64) (sh common.Hash) {
for ; epoch > 0; epoch-- {
sh = crypto.Sha3Hash(sh[:])
}
return sh
}

View File

@ -0,0 +1,204 @@
package ethash
import (
"bytes"
"crypto/rand"
"encoding/hex"
"log"
"math/big"
"os"
"sync"
"testing"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
)
func init() {
// glog.SetV(6)
// glog.SetToStderr(true)
}
type testBlock struct {
difficulty *big.Int
hashNoNonce common.Hash
nonce uint64
mixDigest common.Hash
number uint64
}
func (b *testBlock) Difficulty() *big.Int { return b.difficulty }
func (b *testBlock) HashNoNonce() common.Hash { return b.hashNoNonce }
func (b *testBlock) Nonce() uint64 { return b.nonce }
func (b *testBlock) MixDigest() common.Hash { return b.mixDigest }
func (b *testBlock) NumberU64() uint64 { return b.number }
var validBlocks = []*testBlock{
// from proof of concept nine testnet, epoch 0
{
number: 22,
hashNoNonce: common.HexToHash("372eca2454ead349c3df0ab5d00b0b706b23e49d469387db91811cee0358fc6d"),
difficulty: big.NewInt(132416),
nonce: 0x495732e0ed7a801c,
mixDigest: common.HexToHash("2f74cdeb198af0b9abe65d22d372e22fb2d474371774a9583c1cc427a07939f5"),
},
// from proof of concept nine testnet, epoch 1
{
number: 30001,
hashNoNonce: common.HexToHash("7e44356ee3441623bc72a683fd3708fdf75e971bbe294f33e539eedad4b92b34"),
difficulty: big.NewInt(1532671),
nonce: 0x318df1c8adef7e5e,
mixDigest: common.HexToHash("144b180aad09ae3c81fb07be92c8e6351b5646dda80e6844ae1b697e55ddde84"),
},
// from proof of concept nine testnet, epoch 2
{
number: 60000,
hashNoNonce: common.HexToHash("5fc898f16035bf5ac9c6d9077ae1e3d5fc1ecc3c9fd5bee8bb00e810fdacbaa0"),
difficulty: big.NewInt(2467358),
nonce: 0x50377003e5d830ca,
mixDigest: common.HexToHash("ab546a5b73c452ae86dadd36f0ed83a6745226717d3798832d1b20b489e82063"),
},
}
var invalidZeroDiffBlock = testBlock{
number: 61440000,
hashNoNonce: crypto.Sha3Hash([]byte("foo")),
difficulty: big.NewInt(0),
nonce: 0xcafebabec00000fe,
mixDigest: crypto.Sha3Hash([]byte("bar")),
}
func TestEthashVerifyValid(t *testing.T) {
eth := New()
for i, block := range validBlocks {
if !eth.Verify(block) {
t.Errorf("block %d (%x) did not validate.", i, block.hashNoNonce[:6])
}
}
}
func TestEthashVerifyInvalid(t *testing.T) {
eth := New()
if eth.Verify(&invalidZeroDiffBlock) {
t.Errorf("should not validate - we just ensure it does not panic on this block")
}
}
func TestEthashConcurrentVerify(t *testing.T) {
eth, err := NewForTesting()
if err != nil {
t.Fatal(err)
}
defer os.RemoveAll(eth.Full.Dir)
block := &testBlock{difficulty: big.NewInt(10)}
nonce, md := eth.Search(block, nil)
block.nonce = nonce
block.mixDigest = common.BytesToHash(md)
// Verify the block concurrently to check for data races.
var wg sync.WaitGroup
wg.Add(100)
for i := 0; i < 100; i++ {
go func() {
if !eth.Verify(block) {
t.Error("Block could not be verified")
}
wg.Done()
}()
}
wg.Wait()
}
func TestEthashConcurrentSearch(t *testing.T) {
eth, err := NewForTesting()
if err != nil {
t.Fatal(err)
}
eth.Turbo(true)
defer os.RemoveAll(eth.Full.Dir)
type searchRes struct {
n uint64
md []byte
}
var (
block = &testBlock{difficulty: big.NewInt(35000)}
nsearch = 10
wg = new(sync.WaitGroup)
found = make(chan searchRes)
stop = make(chan struct{})
)
rand.Read(block.hashNoNonce[:])
wg.Add(nsearch)
// launch n searches concurrently.
for i := 0; i < nsearch; i++ {
go func() {
nonce, md := eth.Search(block, stop)
select {
case found <- searchRes{n: nonce, md: md}:
case <-stop:
}
wg.Done()
}()
}
// wait for one of them to find the nonce
res := <-found
// stop the others
close(stop)
wg.Wait()
block.nonce = res.n
block.mixDigest = common.BytesToHash(res.md)
if !eth.Verify(block) {
t.Error("Block could not be verified")
}
}
func TestEthashSearchAcrossEpoch(t *testing.T) {
eth, err := NewForTesting()
if err != nil {
t.Fatal(err)
}
defer os.RemoveAll(eth.Full.Dir)
for i := epochLength - 40; i < epochLength+40; i++ {
block := &testBlock{number: i, difficulty: big.NewInt(90)}
rand.Read(block.hashNoNonce[:])
nonce, md := eth.Search(block, nil)
block.nonce = nonce
block.mixDigest = common.BytesToHash(md)
if !eth.Verify(block) {
t.Fatalf("Block could not be verified")
}
}
}
func TestGetSeedHash(t *testing.T) {
seed0, err := GetSeedHash(0)
if err != nil {
t.Errorf("Failed to get seedHash for block 0: %v", err)
}
if bytes.Compare(seed0, make([]byte, 32)) != 0 {
log.Printf("seedHash for block 0 should be 0s, was: %v\n", seed0)
}
seed1, err := GetSeedHash(30000)
if err != nil {
t.Error(err)
}
// From python:
// > from pyethash import get_seedhash
// > get_seedhash(30000)
expectedSeed1, err := hex.DecodeString("290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e563")
if err != nil {
t.Error(err)
}
if bytes.Compare(seed1, expectedSeed1) != 0 {
log.Printf("seedHash for block 1 should be: %v,\nactual value: %v\n", expectedSeed1, seed1)
}
}

View File

@ -0,0 +1,35 @@
package ethash
/*
-mno-stack-arg-probe disables stack probing which avoids the function
__chkstk_ms being linked. this avoids a clash of this symbol as we also
separately link the secp256k1 lib which ends up defining this symbol
1. https://gcc.gnu.org/onlinedocs/gccint/Stack-Checking.html
2. https://groups.google.com/forum/#!msg/golang-dev/v1bziURSQ4k/88fXuJ24e-gJ
3. https://groups.google.com/forum/#!topic/golang-nuts/VNP6Mwz_B6o
*/
/*
#cgo CFLAGS: -std=gnu99 -Wall
#cgo windows CFLAGS: -mno-stack-arg-probe
#cgo LDFLAGS: -lm
#include "src/libethash/internal.c"
#include "src/libethash/sha3.c"
#include "src/libethash/io.c"
#ifdef _WIN32
# include "src/libethash/io_win32.c"
# include "src/libethash/mmap_win32.c"
#else
# include "src/libethash/io_posix.c"
#endif
// 'gateway function' for calling back into go.
extern int ethashGoCallback(unsigned);
int ethashGoCallback_cgo(unsigned percent) { return ethashGoCallback(percent); }
*/
import "C"

View File

@ -0,0 +1,22 @@
The MIT License (MIT)
Copyright (c) 2015 Tim Hughes
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -0,0 +1,190 @@
// ethash.js
// Tim Hughes <tim@twistedfury.com>
// Revision 19
/*jslint node: true, shadow:true */
"use strict";
var Keccak = require('./keccak');
var util = require('./util');
// 32-bit unsigned modulo
function mod32(x, n)
{
return (x>>>0) % (n>>>0);
}
function fnv(x, y)
{
// js integer multiply by 0x01000193 will lose precision
return ((x*0x01000000 | 0) + (x*0x193 | 0)) ^ y;
}
function computeCache(params, seedWords)
{
var cache = new Uint32Array(params.cacheSize >> 2);
var cacheNodeCount = params.cacheSize >> 6;
// Initialize cache
var keccak = new Keccak();
keccak.digestWords(cache, 0, 16, seedWords, 0, seedWords.length);
for (var n = 1; n < cacheNodeCount; ++n)
{
keccak.digestWords(cache, n<<4, 16, cache, (n-1)<<4, 16);
}
var tmp = new Uint32Array(16);
// Do randmemohash passes
for (var r = 0; r < params.cacheRounds; ++r)
{
for (var n = 0; n < cacheNodeCount; ++n)
{
var p0 = mod32(n + cacheNodeCount - 1, cacheNodeCount) << 4;
var p1 = mod32(cache[n<<4|0], cacheNodeCount) << 4;
for (var w = 0; w < 16; w=(w+1)|0)
{
tmp[w] = cache[p0 | w] ^ cache[p1 | w];
}
keccak.digestWords(cache, n<<4, 16, tmp, 0, tmp.length);
}
}
return cache;
}
function computeDagNode(o_node, params, cache, keccak, nodeIndex)
{
var cacheNodeCount = params.cacheSize >> 6;
var dagParents = params.dagParents;
var c = (nodeIndex % cacheNodeCount) << 4;
var mix = o_node;
for (var w = 0; w < 16; ++w)
{
mix[w] = cache[c|w];
}
mix[0] ^= nodeIndex;
keccak.digestWords(mix, 0, 16, mix, 0, 16);
for (var p = 0; p < dagParents; ++p)
{
// compute cache node (word) index
c = mod32(fnv(nodeIndex ^ p, mix[p&15]), cacheNodeCount) << 4;
for (var w = 0; w < 16; ++w)
{
mix[w] = fnv(mix[w], cache[c|w]);
}
}
keccak.digestWords(mix, 0, 16, mix, 0, 16);
}
function computeHashInner(mix, params, cache, keccak, tempNode)
{
var mixParents = params.mixParents|0;
var mixWordCount = params.mixSize >> 2;
var mixNodeCount = mixWordCount >> 4;
var dagPageCount = (params.dagSize / params.mixSize) >> 0;
// grab initial first word
var s0 = mix[0];
// initialise mix from initial 64 bytes
for (var w = 16; w < mixWordCount; ++w)
{
mix[w] = mix[w & 15];
}
for (var a = 0; a < mixParents; ++a)
{
var p = mod32(fnv(s0 ^ a, mix[a & (mixWordCount-1)]), dagPageCount);
var d = (p * mixNodeCount)|0;
for (var n = 0, w = 0; n < mixNodeCount; ++n, w += 16)
{
computeDagNode(tempNode, params, cache, keccak, (d + n)|0);
for (var v = 0; v < 16; ++v)
{
mix[w|v] = fnv(mix[w|v], tempNode[v]);
}
}
}
}
function convertSeed(seed)
{
// todo, reconcile with spec, byte ordering?
// todo, big-endian conversion
var newSeed = util.toWords(seed);
if (newSeed === null)
throw Error("Invalid seed '" + seed + "'");
return newSeed;
}
exports.defaultParams = function()
{
return {
cacheSize: 1048384,
cacheRounds: 3,
dagSize: 1073739904,
dagParents: 256,
mixSize: 128,
mixParents: 64,
};
};
exports.Ethash = function(params, seed)
{
// precompute cache and related values
seed = convertSeed(seed);
var cache = computeCache(params, seed);
// preallocate buffers/etc
var initBuf = new ArrayBuffer(96);
var initBytes = new Uint8Array(initBuf);
var initWords = new Uint32Array(initBuf);
var mixWords = new Uint32Array(params.mixSize / 4);
var tempNode = new Uint32Array(16);
var keccak = new Keccak();
var retWords = new Uint32Array(8);
var retBytes = new Uint8Array(retWords.buffer); // supposedly read-only
this.hash = function(header, nonce)
{
// compute initial hash
initBytes.set(header, 0);
initBytes.set(nonce, 32);
keccak.digestWords(initWords, 0, 16, initWords, 0, 8 + nonce.length/4);
// compute mix
for (var i = 0; i != 16; ++i)
{
mixWords[i] = initWords[i];
}
computeHashInner(mixWords, params, cache, keccak, tempNode);
// compress mix and append to initWords
for (var i = 0; i != mixWords.length; i += 4)
{
initWords[16 + i/4] = fnv(fnv(fnv(mixWords[i], mixWords[i+1]), mixWords[i+2]), mixWords[i+3]);
}
// final Keccak hashes
keccak.digestWords(retWords, 0, 8, initWords, 0, 24); // Keccak-256(s + cmix)
return retBytes;
};
this.cacheDigest = function()
{
return keccak.digest(32, new Uint8Array(cache.buffer));
};
};

View File

@ -0,0 +1,404 @@
// keccak.js
// Tim Hughes <tim@twistedfury.com>
// derived from Markku-Juhani O. Saarinen's C code (http://keccak.noekeon.org/readable_code.html)
/*jslint node: true, shadow:true */
"use strict";
var Keccak_f1600_RC = new Uint32Array([
0x00000001, 0x00000000,
0x00008082, 0x00000000,
0x0000808a, 0x80000000,
0x80008000, 0x80000000,
0x0000808b, 0x00000000,
0x80000001, 0x00000000,
0x80008081, 0x80000000,
0x00008009, 0x80000000,
0x0000008a, 0x00000000,
0x00000088, 0x00000000,
0x80008009, 0x00000000,
0x8000000a, 0x00000000,
0x8000808b, 0x00000000,
0x0000008b, 0x80000000,
0x00008089, 0x80000000,
0x00008003, 0x80000000,
0x00008002, 0x80000000,
0x00000080, 0x80000000,
0x0000800a, 0x00000000,
0x8000000a, 0x80000000,
0x80008081, 0x80000000,
0x00008080, 0x80000000,
0x80000001, 0x00000000,
0x80008008, 0x80000000
]);
function keccak_f1600(outState, outOffset, outSize, inState)
{
// todo, handle big endian loads
var a00l = inState[0]|0;
var a00h = inState[1]|0;
var a01l = inState[2]|0;
var a01h = inState[3]|0;
var a02l = inState[4]|0;
var a02h = inState[5]|0;
var a03l = inState[6]|0;
var a03h = inState[7]|0;
var a04l = inState[8]|0;
var a04h = inState[9]|0;
var a05l = inState[10]|0;
var a05h = inState[11]|0;
var a06l = inState[12]|0;
var a06h = inState[13]|0;
var a07l = inState[14]|0;
var a07h = inState[15]|0;
var a08l = inState[16]|0;
var a08h = inState[17]|0;
var a09l = inState[18]|0;
var a09h = inState[19]|0;
var a10l = inState[20]|0;
var a10h = inState[21]|0;
var a11l = inState[22]|0;
var a11h = inState[23]|0;
var a12l = inState[24]|0;
var a12h = inState[25]|0;
var a13l = inState[26]|0;
var a13h = inState[27]|0;
var a14l = inState[28]|0;
var a14h = inState[29]|0;
var a15l = inState[30]|0;
var a15h = inState[31]|0;
var a16l = inState[32]|0;
var a16h = inState[33]|0;
var a17l = inState[34]|0;
var a17h = inState[35]|0;
var a18l = inState[36]|0;
var a18h = inState[37]|0;
var a19l = inState[38]|0;
var a19h = inState[39]|0;
var a20l = inState[40]|0;
var a20h = inState[41]|0;
var a21l = inState[42]|0;
var a21h = inState[43]|0;
var a22l = inState[44]|0;
var a22h = inState[45]|0;
var a23l = inState[46]|0;
var a23h = inState[47]|0;
var a24l = inState[48]|0;
var a24h = inState[49]|0;
var b00l, b00h, b01l, b01h, b02l, b02h, b03l, b03h, b04l, b04h;
var b05l, b05h, b06l, b06h, b07l, b07h, b08l, b08h, b09l, b09h;
var b10l, b10h, b11l, b11h, b12l, b12h, b13l, b13h, b14l, b14h;
var b15l, b15h, b16l, b16h, b17l, b17h, b18l, b18h, b19l, b19h;
var b20l, b20h, b21l, b21h, b22l, b22h, b23l, b23h, b24l, b24h;
var tl, nl;
var th, nh;
for (var r = 0; r < 48; r = (r+2)|0)
{
// Theta
b00l = a00l ^ a05l ^ a10l ^ a15l ^ a20l;
b00h = a00h ^ a05h ^ a10h ^ a15h ^ a20h;
b01l = a01l ^ a06l ^ a11l ^ a16l ^ a21l;
b01h = a01h ^ a06h ^ a11h ^ a16h ^ a21h;
b02l = a02l ^ a07l ^ a12l ^ a17l ^ a22l;
b02h = a02h ^ a07h ^ a12h ^ a17h ^ a22h;
b03l = a03l ^ a08l ^ a13l ^ a18l ^ a23l;
b03h = a03h ^ a08h ^ a13h ^ a18h ^ a23h;
b04l = a04l ^ a09l ^ a14l ^ a19l ^ a24l;
b04h = a04h ^ a09h ^ a14h ^ a19h ^ a24h;
tl = b04l ^ (b01l << 1 | b01h >>> 31);
th = b04h ^ (b01h << 1 | b01l >>> 31);
a00l ^= tl;
a00h ^= th;
a05l ^= tl;
a05h ^= th;
a10l ^= tl;
a10h ^= th;
a15l ^= tl;
a15h ^= th;
a20l ^= tl;
a20h ^= th;
tl = b00l ^ (b02l << 1 | b02h >>> 31);
th = b00h ^ (b02h << 1 | b02l >>> 31);
a01l ^= tl;
a01h ^= th;
a06l ^= tl;
a06h ^= th;
a11l ^= tl;
a11h ^= th;
a16l ^= tl;
a16h ^= th;
a21l ^= tl;
a21h ^= th;
tl = b01l ^ (b03l << 1 | b03h >>> 31);
th = b01h ^ (b03h << 1 | b03l >>> 31);
a02l ^= tl;
a02h ^= th;
a07l ^= tl;
a07h ^= th;
a12l ^= tl;
a12h ^= th;
a17l ^= tl;
a17h ^= th;
a22l ^= tl;
a22h ^= th;
tl = b02l ^ (b04l << 1 | b04h >>> 31);
th = b02h ^ (b04h << 1 | b04l >>> 31);
a03l ^= tl;
a03h ^= th;
a08l ^= tl;
a08h ^= th;
a13l ^= tl;
a13h ^= th;
a18l ^= tl;
a18h ^= th;
a23l ^= tl;
a23h ^= th;
tl = b03l ^ (b00l << 1 | b00h >>> 31);
th = b03h ^ (b00h << 1 | b00l >>> 31);
a04l ^= tl;
a04h ^= th;
a09l ^= tl;
a09h ^= th;
a14l ^= tl;
a14h ^= th;
a19l ^= tl;
a19h ^= th;
a24l ^= tl;
a24h ^= th;
// Rho Pi
b00l = a00l;
b00h = a00h;
b10l = a01l << 1 | a01h >>> 31;
b10h = a01h << 1 | a01l >>> 31;
b07l = a10l << 3 | a10h >>> 29;
b07h = a10h << 3 | a10l >>> 29;
b11l = a07l << 6 | a07h >>> 26;
b11h = a07h << 6 | a07l >>> 26;
b17l = a11l << 10 | a11h >>> 22;
b17h = a11h << 10 | a11l >>> 22;
b18l = a17l << 15 | a17h >>> 17;
b18h = a17h << 15 | a17l >>> 17;
b03l = a18l << 21 | a18h >>> 11;
b03h = a18h << 21 | a18l >>> 11;
b05l = a03l << 28 | a03h >>> 4;
b05h = a03h << 28 | a03l >>> 4;
b16l = a05h << 4 | a05l >>> 28;
b16h = a05l << 4 | a05h >>> 28;
b08l = a16h << 13 | a16l >>> 19;
b08h = a16l << 13 | a16h >>> 19;
b21l = a08h << 23 | a08l >>> 9;
b21h = a08l << 23 | a08h >>> 9;
b24l = a21l << 2 | a21h >>> 30;
b24h = a21h << 2 | a21l >>> 30;
b04l = a24l << 14 | a24h >>> 18;
b04h = a24h << 14 | a24l >>> 18;
b15l = a04l << 27 | a04h >>> 5;
b15h = a04h << 27 | a04l >>> 5;
b23l = a15h << 9 | a15l >>> 23;
b23h = a15l << 9 | a15h >>> 23;
b19l = a23h << 24 | a23l >>> 8;
b19h = a23l << 24 | a23h >>> 8;
b13l = a19l << 8 | a19h >>> 24;
b13h = a19h << 8 | a19l >>> 24;
b12l = a13l << 25 | a13h >>> 7;
b12h = a13h << 25 | a13l >>> 7;
b02l = a12h << 11 | a12l >>> 21;
b02h = a12l << 11 | a12h >>> 21;
b20l = a02h << 30 | a02l >>> 2;
b20h = a02l << 30 | a02h >>> 2;
b14l = a20l << 18 | a20h >>> 14;
b14h = a20h << 18 | a20l >>> 14;
b22l = a14h << 7 | a14l >>> 25;
b22h = a14l << 7 | a14h >>> 25;
b09l = a22h << 29 | a22l >>> 3;
b09h = a22l << 29 | a22h >>> 3;
b06l = a09l << 20 | a09h >>> 12;
b06h = a09h << 20 | a09l >>> 12;
b01l = a06h << 12 | a06l >>> 20;
b01h = a06l << 12 | a06h >>> 20;
// Chi
a00l = b00l ^ ~b01l & b02l;
a00h = b00h ^ ~b01h & b02h;
a01l = b01l ^ ~b02l & b03l;
a01h = b01h ^ ~b02h & b03h;
a02l = b02l ^ ~b03l & b04l;
a02h = b02h ^ ~b03h & b04h;
a03l = b03l ^ ~b04l & b00l;
a03h = b03h ^ ~b04h & b00h;
a04l = b04l ^ ~b00l & b01l;
a04h = b04h ^ ~b00h & b01h;
a05l = b05l ^ ~b06l & b07l;
a05h = b05h ^ ~b06h & b07h;
a06l = b06l ^ ~b07l & b08l;
a06h = b06h ^ ~b07h & b08h;
a07l = b07l ^ ~b08l & b09l;
a07h = b07h ^ ~b08h & b09h;
a08l = b08l ^ ~b09l & b05l;
a08h = b08h ^ ~b09h & b05h;
a09l = b09l ^ ~b05l & b06l;
a09h = b09h ^ ~b05h & b06h;
a10l = b10l ^ ~b11l & b12l;
a10h = b10h ^ ~b11h & b12h;
a11l = b11l ^ ~b12l & b13l;
a11h = b11h ^ ~b12h & b13h;
a12l = b12l ^ ~b13l & b14l;
a12h = b12h ^ ~b13h & b14h;
a13l = b13l ^ ~b14l & b10l;
a13h = b13h ^ ~b14h & b10h;
a14l = b14l ^ ~b10l & b11l;
a14h = b14h ^ ~b10h & b11h;
a15l = b15l ^ ~b16l & b17l;
a15h = b15h ^ ~b16h & b17h;
a16l = b16l ^ ~b17l & b18l;
a16h = b16h ^ ~b17h & b18h;
a17l = b17l ^ ~b18l & b19l;
a17h = b17h ^ ~b18h & b19h;
a18l = b18l ^ ~b19l & b15l;
a18h = b18h ^ ~b19h & b15h;
a19l = b19l ^ ~b15l & b16l;
a19h = b19h ^ ~b15h & b16h;
a20l = b20l ^ ~b21l & b22l;
a20h = b20h ^ ~b21h & b22h;
a21l = b21l ^ ~b22l & b23l;
a21h = b21h ^ ~b22h & b23h;
a22l = b22l ^ ~b23l & b24l;
a22h = b22h ^ ~b23h & b24h;
a23l = b23l ^ ~b24l & b20l;
a23h = b23h ^ ~b24h & b20h;
a24l = b24l ^ ~b20l & b21l;
a24h = b24h ^ ~b20h & b21h;
// Iota
a00l ^= Keccak_f1600_RC[r|0];
a00h ^= Keccak_f1600_RC[r|1];
}
// todo, handle big-endian stores
outState[outOffset|0] = a00l;
outState[outOffset|1] = a00h;
outState[outOffset|2] = a01l;
outState[outOffset|3] = a01h;
outState[outOffset|4] = a02l;
outState[outOffset|5] = a02h;
outState[outOffset|6] = a03l;
outState[outOffset|7] = a03h;
if (outSize == 8)
return;
outState[outOffset|8] = a04l;
outState[outOffset|9] = a04h;
outState[outOffset|10] = a05l;
outState[outOffset|11] = a05h;
outState[outOffset|12] = a06l;
outState[outOffset|13] = a06h;
outState[outOffset|14] = a07l;
outState[outOffset|15] = a07h;
if (outSize == 16)
return;
outState[outOffset|16] = a08l;
outState[outOffset|17] = a08h;
outState[outOffset|18] = a09l;
outState[outOffset|19] = a09h;
outState[outOffset|20] = a10l;
outState[outOffset|21] = a10h;
outState[outOffset|22] = a11l;
outState[outOffset|23] = a11h;
outState[outOffset|24] = a12l;
outState[outOffset|25] = a12h;
outState[outOffset|26] = a13l;
outState[outOffset|27] = a13h;
outState[outOffset|28] = a14l;
outState[outOffset|29] = a14h;
outState[outOffset|30] = a15l;
outState[outOffset|31] = a15h;
outState[outOffset|32] = a16l;
outState[outOffset|33] = a16h;
outState[outOffset|34] = a17l;
outState[outOffset|35] = a17h;
outState[outOffset|36] = a18l;
outState[outOffset|37] = a18h;
outState[outOffset|38] = a19l;
outState[outOffset|39] = a19h;
outState[outOffset|40] = a20l;
outState[outOffset|41] = a20h;
outState[outOffset|42] = a21l;
outState[outOffset|43] = a21h;
outState[outOffset|44] = a22l;
outState[outOffset|45] = a22h;
outState[outOffset|46] = a23l;
outState[outOffset|47] = a23h;
outState[outOffset|48] = a24l;
outState[outOffset|49] = a24h;
}
var Keccak = function()
{
var stateBuf = new ArrayBuffer(200);
var stateBytes = new Uint8Array(stateBuf);
var stateWords = new Uint32Array(stateBuf);
this.digest = function(oSize, iBytes)
{
for (var i = 0; i < 50; ++i)
{
stateWords[i] = 0;
}
var r = 200 - oSize*2;
var iLength = iBytes.length;
var iOffset = 0;
for ( ; ;)
{
var len = iLength < r ? iLength : r;
for (i = 0; i < len; ++i, ++iOffset)
{
stateBytes[i] ^= iBytes[iOffset];
}
if (iLength < r)
break;
iLength -= len;
keccak_f1600(stateWords, 0, 50, stateWords);
}
stateBytes[iLength] ^= 1;
stateBytes[r-1] ^= 0x80;
keccak_f1600(stateWords, 0, 50, stateWords);
return stateBytes.subarray(0, oSize);
};
this.digestWords = function(oWords, oOffset, oLength, iWords, iOffset, iLength)
{
for (var i = 0; i < 50; ++i)
{
stateWords[i] = 0;
}
var r = 50 - oLength*2;
for (; ; )
{
var len = iLength < r ? iLength : r;
for (i = 0; i < len; ++i, ++iOffset)
{
stateWords[i] ^= iWords[iOffset];
}
if (iLength < r)
break;
iLength -= len;
keccak_f1600(stateWords, 0, 50, stateWords);
}
stateBytes[iLength<<2] ^= 1;
stateBytes[(r<<2) - 1] ^= 0x80;
keccak_f1600(oWords, oOffset, oLength, stateWords);
};
};
module.exports = Keccak;

View File

@ -0,0 +1,201 @@
#!/usr/bin/env node
// makekeccak.js
// Tim Hughes <tim@twistedfury.com>
/*jslint node: true, shadow:true */
"use strict";
var Keccak_f1600_Rho = [
1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 2, 14,
27, 41, 56, 8, 25, 43, 62, 18, 39, 61, 20, 44
];
var Keccak_f1600_Pi= [
10, 7, 11, 17, 18, 3, 5, 16, 8, 21, 24, 4,
15, 23, 19, 13, 12, 2, 20, 14, 22, 9, 6, 1
];
var Keccak_f1600_RC = [
0x00000001, 0x00000000,
0x00008082, 0x00000000,
0x0000808a, 0x80000000,
0x80008000, 0x80000000,
0x0000808b, 0x00000000,
0x80000001, 0x00000000,
0x80008081, 0x80000000,
0x00008009, 0x80000000,
0x0000008a, 0x00000000,
0x00000088, 0x00000000,
0x80008009, 0x00000000,
0x8000000a, 0x00000000,
0x8000808b, 0x00000000,
0x0000008b, 0x80000000,
0x00008089, 0x80000000,
0x00008003, 0x80000000,
0x00008002, 0x80000000,
0x00000080, 0x80000000,
0x0000800a, 0x00000000,
0x8000000a, 0x80000000,
0x80008081, 0x80000000,
0x00008080, 0x80000000,
0x80000001, 0x00000000,
0x80008008, 0x80000000,
];
function makeRotLow(lo, hi, n)
{
if (n === 0 || n === 32) throw Error("unsupported");
if ((n & 0x20) !== 0)
{
n &= ~0x20;
var t = hi;
hi = lo;
lo = t;
}
var hir = hi + " >>> " + (32 - n);
var los = lo + " << " + n;
return los + " | " + hir;
}
function makeRotHigh(lo, hi, n)
{
if (n === 0 || n === 32) throw Error("unsupported");
if ((n & 0x20) !== 0)
{
n &= ~0x20;
var t = hi;
hi = lo;
lo = t;
}
var his = hi + " << " + n;
var lor = lo + " >>> " + (32 - n);
return his + " | " + lor;
}
function makeKeccak_f1600()
{
var format = function(n)
{
return n < 10 ? "0"+n : ""+n;
};
var a = function(n, w)
{
return "a" + format(n) + (w !== 0?'h':'l');
};
var b = function(n, w)
{
return "b" + format(n) + (w !== 0?'h':'l');
};
var str = "";
str += "function keccak_f1600(outState, outOffset, outSize, inState)\n";
str += "{\n";
for (var i = 0; i < 25; ++i)
{
for (var w = 0; w <= 1; ++w)
{
str += "\tvar " + a(i,w) + " = inState["+(i<<1|w)+"]|0;\n";
}
}
for (var j = 0; j < 5; ++j)
{
str += "\tvar ";
for (var i = 0; i < 5; ++i)
{
if (i !== 0)
str += ", ";
str += b(j*5+i,0) + ", " + b(j*5+i,1);
}
str += ";\n";
}
str += "\tvar tl, th;\n";
str += "\n";
str += "\tfor (var r = 0; r < 48; r = (r+2)|0)\n";
str += "\t{\n";
// Theta
str += "\t\t// Theta\n";
for (var i = 0; i < 5; ++i)
{
for (var w = 0; w <= 1; ++w)
{
str += "\t\t" + b(i,w) + " = " + a(i,w) + " ^ " + a(i+5,w) + " ^ " + a(i+10,w) + " ^ " + a(i+15,w) + " ^ " + a(i+20,w) + ";\n";
}
}
for (var i = 0; i < 5; ++i)
{
var i4 = (i + 4) % 5;
var i1 = (i + 1) % 5;
str += "\t\ttl = " + b(i4,0) + " ^ (" + b(i1,0) + " << 1 | " + b(i1,1) + " >>> 31);\n";
str += "\t\tth = " + b(i4,1) + " ^ (" + b(i1,1) + " << 1 | " + b(i1,0) + " >>> 31);\n";
for (var j = 0; j < 25; j = (j+5)|0)
{
str += "\t\t" + a((j+i),0) + " ^= tl;\n";
str += "\t\t" + a((j+i),1) + " ^= th;\n";
}
}
// Rho Pi
str += "\n\t\t// Rho Pi\n";
for (var w = 0; w <= 1; ++w)
{
str += "\t\t" + b(0,w) + " = " + a(0,w) + ";\n";
}
var opi = 1;
for (var i = 0; i < 24; ++i)
{
var pi = Keccak_f1600_Pi[i];
str += "\t\t" + b(pi,0) + " = " + makeRotLow(a(opi,0), a(opi,1), Keccak_f1600_Rho[i]) + ";\n";
str += "\t\t" + b(pi,1) + " = " + makeRotHigh(a(opi,0), a(opi,1), Keccak_f1600_Rho[i]) + ";\n";
opi = pi;
}
// Chi
str += "\n\t\t// Chi\n";
for (var j = 0; j < 25; j += 5)
{
for (var i = 0; i < 5; ++i)
{
for (var w = 0; w <= 1; ++w)
{
str += "\t\t" + a(j+i,w) + " = " + b(j+i,w) + " ^ ~" + b(j+(i+1)%5,w) + " & " + b(j+(i+2)%5,w) + ";\n";
}
}
}
// Iota
str += "\n\t\t// Iota\n";
for (var w = 0; w <= 1; ++w)
{
str += "\t\t" + a(0,w) + " ^= Keccak_f1600_RC[r|" + w + "];\n";
}
str += "\t}\n";
for (var i = 0; i < 25; ++i)
{
if (i == 4 || i == 8)
{
str += "\tif (outSize == " + i*2 + ")\n\t\treturn;\n";
}
for (var w = 0; w <= 1; ++w)
{
str += "\toutState[outOffset|"+(i<<1|w)+"] = " + a(i,w) + ";\n";
}
}
str += "}\n";
return str;
}
console.log(makeKeccak_f1600());

View File

@ -0,0 +1,53 @@
// test.js
// Tim Hughes <tim@twistedfury.com>
/*jslint node: true, shadow:true */
"use strict";
var ethash = require('./ethash');
var util = require('./util');
var Keccak = require('./keccak');
// sanity check hash functions
var src = util.stringToBytes("");
if (util.bytesToHexString(new Keccak().digest(32, src)) != "c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470") throw Error("Keccak-256 failed");
if (util.bytesToHexString(new Keccak().digest(64, src)) != "0eab42de4c3ceb9235fc91acffe746b29c29a8c366b7c60e4e67c466f36a4304c00fa9caf9d87976ba469bcbe06713b435f091ef2769fb160cdab33d3670680e") throw Error("Keccak-512 failed");
src = new Uint32Array(src.buffer);
var dst = new Uint32Array(8);
new Keccak().digestWords(dst, 0, dst.length, src, 0, src.length);
if (util.wordsToHexString(dst) != "c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470") throw Error("Keccak-256 Fast failed");
var dst = new Uint32Array(16);
new Keccak().digestWords(dst, 0, dst.length, src, 0, src.length);
if (util.wordsToHexString(dst) != "0eab42de4c3ceb9235fc91acffe746b29c29a8c366b7c60e4e67c466f36a4304c00fa9caf9d87976ba469bcbe06713b435f091ef2769fb160cdab33d3670680e") throw Error("Keccak-512 Fast failed");
// init params
var ethashParams = ethash.defaultParams();
//ethashParams.cacheRounds = 0;
// create hasher
var seed = util.hexStringToBytes("9410b944535a83d9adf6bbdcc80e051f30676173c16ca0d32d6f1263fc246466")
var startTime = new Date().getTime();
var hasher = new ethash.Ethash(ethashParams, seed);
console.log('Ethash startup took: '+(new Date().getTime() - startTime) + "ms");
console.log('Ethash cache hash: ' + util.bytesToHexString(hasher.cacheDigest()));
var testHexString = "c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470";
if (testHexString != util.bytesToHexString(util.hexStringToBytes(testHexString)))
throw Error("bytesToHexString or hexStringToBytes broken");
var header = util.hexStringToBytes("c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470");
var nonce = util.hexStringToBytes("0000000000000000");
var hash;
startTime = new Date().getTime();
var trials = 10;
for (var i = 0; i < trials; ++i)
{
hash = hasher.hash(header, nonce);
}
console.log("Light client hashes averaged: " + (new Date().getTime() - startTime)/trials + "ms");
console.log("Hash = " + util.bytesToHexString(hash));

View File

@ -0,0 +1,100 @@
// util.js
// Tim Hughes <tim@twistedfury.com>
/*jslint node: true, shadow:true */
"use strict";
function nibbleToChar(nibble)
{
return String.fromCharCode((nibble < 10 ? 48 : 87) + nibble);
}
function charToNibble(chr)
{
if (chr >= 48 && chr <= 57)
{
return chr - 48;
}
if (chr >= 65 && chr <= 70)
{
return chr - 65 + 10;
}
if (chr >= 97 && chr <= 102)
{
return chr - 97 + 10;
}
return 0;
}
function stringToBytes(str)
{
var bytes = new Uint8Array(str.length);
for (var i = 0; i != str.length; ++i)
{
bytes[i] = str.charCodeAt(i);
}
return bytes;
}
function hexStringToBytes(str)
{
var bytes = new Uint8Array(str.length>>>1);
for (var i = 0; i != bytes.length; ++i)
{
bytes[i] = charToNibble(str.charCodeAt(i<<1 | 0)) << 4;
bytes[i] |= charToNibble(str.charCodeAt(i<<1 | 1));
}
return bytes;
}
function bytesToHexString(bytes)
{
var str = "";
for (var i = 0; i != bytes.length; ++i)
{
str += nibbleToChar(bytes[i] >>> 4);
str += nibbleToChar(bytes[i] & 0xf);
}
return str;
}
function wordsToHexString(words)
{
return bytesToHexString(new Uint8Array(words.buffer));
}
function uint32ToHexString(num)
{
var buf = new Uint8Array(4);
buf[0] = (num >> 24) & 0xff;
buf[1] = (num >> 16) & 0xff;
buf[2] = (num >> 8) & 0xff;
buf[3] = (num >> 0) & 0xff;
return bytesToHexString(buf);
}
function toWords(input)
{
if (input instanceof Uint32Array)
{
return input;
}
else if (input instanceof Uint8Array)
{
var tmp = new Uint8Array((input.length + 3) & ~3);
tmp.set(input);
return new Uint32Array(tmp.buffer);
}
else if (typeof input === typeof "")
{
return toWords(stringToBytes(input));
}
return null;
}
exports.stringToBytes = stringToBytes;
exports.hexStringToBytes = hexStringToBytes;
exports.bytesToHexString = bytesToHexString;
exports.wordsToHexString = wordsToHexString;
exports.uint32ToHexString = uint32ToHexString;
exports.toWords = toWords;

View File

@ -0,0 +1,47 @@
#!/usr/bin/env python
import os
from distutils.core import setup, Extension
sources = [
'src/python/core.c',
'src/libethash/io.c',
'src/libethash/internal.c',
'src/libethash/sha3.c']
if os.name == 'nt':
sources += [
'src/libethash/util_win32.c',
'src/libethash/io_win32.c',
'src/libethash/mmap_win32.c',
]
else:
sources += [
'src/libethash/io_posix.c'
]
depends = [
'src/libethash/ethash.h',
'src/libethash/compiler.h',
'src/libethash/data_sizes.h',
'src/libethash/endian.h',
'src/libethash/ethash.h',
'src/libethash/io.h',
'src/libethash/fnv.h',
'src/libethash/internal.h',
'src/libethash/sha3.h',
'src/libethash/util.h',
]
pyethash = Extension('pyethash',
sources=sources,
depends=depends,
extra_compile_args=["-Isrc/", "-std=gnu99", "-Wall"])
setup(
name='pyethash',
author="Matthew Wampler-Doty",
author_email="matthew.wampler.doty@gmail.com",
license='GPL',
version='0.1.23',
url='https://github.com/ethereum/ethash',
download_url='https://github.com/ethereum/ethash/tarball/v23',
description=('Python wrappers for ethash, the ethereum proof of work'
'hashing function'),
ext_modules=[pyethash],
)

View File

@ -0,0 +1,58 @@
include_directories(..)
set(CMAKE_BUILD_TYPE Release)
if (MSVC)
add_definitions("/openmp")
endif()
# enable C++11, should probably be a bit more specific about compiler
if (NOT MSVC)
SET(CMAKE_CXX_FLAGS "-std=c++11")
endif()
if (NOT MPI_FOUND)
find_package(MPI)
endif()
if (NOT CRYPTOPP_FOUND)
find_package(CryptoPP 5.6.2)
endif()
if (CRYPTOPP_FOUND)
add_definitions(-DWITH_CRYPTOPP)
find_package (Threads REQUIRED)
endif()
if (NOT OpenCL_FOUND)
find_package(OpenCL)
endif()
if (OpenCL_FOUND)
add_definitions(-DWITH_OPENCL)
include_directories(${OpenCL_INCLUDE_DIRS})
list(APPEND FILES ethash_cl_miner.cpp ethash_cl_miner.h)
endif()
if (MPI_FOUND)
include_directories(${MPI_INCLUDE_PATH})
add_executable (Benchmark_MPI_FULL benchmark.cpp)
target_link_libraries (Benchmark_MPI_FULL ${ETHHASH_LIBS} ${MPI_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
SET_TARGET_PROPERTIES(Benchmark_MPI_FULL PROPERTIES COMPILE_FLAGS "${COMPILE_FLAGS} ${MPI_COMPILE_FLAGS} -DFULL -DMPI")
add_executable (Benchmark_MPI_LIGHT benchmark.cpp)
target_link_libraries (Benchmark_MPI_LIGHT ${ETHHASH_LIBS} ${MPI_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
SET_TARGET_PROPERTIES(Benchmark_MPI_LIGHT PROPERTIES COMPILE_FLAGS "${COMPILE_FLAGS} ${MPI_COMPILE_FLAGS} -DMPI")
endif()
add_executable (Benchmark_FULL benchmark.cpp)
target_link_libraries (Benchmark_FULL ${ETHHASH_LIBS} ${CMAKE_THREAD_LIBS_INIT})
SET_TARGET_PROPERTIES(Benchmark_FULL PROPERTIES COMPILE_FLAGS "${COMPILE_FLAGS} -DFULL")
add_executable (Benchmark_LIGHT benchmark.cpp)
target_link_libraries (Benchmark_LIGHT ${ETHHASH_LIBS} ${CMAKE_THREAD_LIBS_INIT})
if (OpenCL_FOUND)
add_executable (Benchmark_CL benchmark.cpp)
target_link_libraries (Benchmark_CL ${ETHHASH_LIBS} ethash-cl ${CMAKE_THREAD_LIBS_INIT})
SET_TARGET_PROPERTIES(Benchmark_CL PROPERTIES COMPILE_FLAGS "${COMPILE_FLAGS} -DOPENCL")
endif()

View File

@ -0,0 +1,278 @@
/*
This file is part of cpp-ethereum.
cpp-ethereum is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
cpp-ethereum is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file benchmark.cpp
* @author Tim Hughes <tim@twistedfury.com>
* @date 2015
*/
#include <stdio.h>
#include <stdlib.h>
#include <chrono>
#include <libethash/ethash.h>
#include <libethash/util.h>
#ifdef OPENCL
#include <libethash-cl/ethash_cl_miner.h>
#endif
#include <vector>
#include <algorithm>
#ifdef WITH_CRYPTOPP
#include <libethash/sha3_cryptopp.h>
#include <string>
#else
#include "libethash/sha3.h"
#endif // WITH_CRYPTOPP
#undef min
#undef max
using std::chrono::high_resolution_clock;
#if defined(OPENCL)
const unsigned trials = 1024*1024*32;
#elif defined(FULL)
const unsigned trials = 1024*1024/8;
#else
const unsigned trials = 1024*1024/1024;
#endif
uint8_t g_hashes[1024*32];
static char nibbleToChar(unsigned nibble)
{
return (char) ((nibble >= 10 ? 'a'-10 : '0') + nibble);
}
static uint8_t charToNibble(char chr)
{
if (chr >= '0' && chr <= '9')
{
return (uint8_t) (chr - '0');
}
if (chr >= 'a' && chr <= 'z')
{
return (uint8_t) (chr - 'a' + 10);
}
if (chr >= 'A' && chr <= 'Z')
{
return (uint8_t) (chr - 'A' + 10);
}
return 0;
}
static std::vector<uint8_t> hexStringToBytes(char const* str)
{
std::vector<uint8_t> bytes(strlen(str) >> 1);
for (unsigned i = 0; i != bytes.size(); ++i)
{
bytes[i] = charToNibble(str[i*2 | 0]) << 4;
bytes[i] |= charToNibble(str[i*2 | 1]);
}
return bytes;
}
static std::string bytesToHexString(uint8_t const* bytes, unsigned size)
{
std::string str;
for (unsigned i = 0; i != size; ++i)
{
str += nibbleToChar(bytes[i] >> 4);
str += nibbleToChar(bytes[i] & 0xf);
}
return str;
}
static std::string bytesToHexString(ethash_h256_t const *hash, unsigned size)
{
return bytesToHexString((uint8_t*)hash, size);
}
extern "C" int main(void)
{
// params for ethash
ethash_params params;
ethash_params_init(&params, 0);
//params.full_size = 262147 * 4096; // 1GBish;
//params.full_size = 32771 * 4096; // 128MBish;
//params.full_size = 8209 * 4096; // 8MBish;
//params.cache_size = 8209*4096;
//params.cache_size = 2053*4096;
ethash_h256_t seed;
ethash_h256_t previous_hash;
memcpy(&seed, hexStringToBytes("9410b944535a83d9adf6bbdcc80e051f30676173c16ca0d32d6f1263fc246466").data(), 32);
memcpy(&previous_hash, hexStringToBytes("c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470").data(), 32);
// allocate page aligned buffer for dataset
#ifdef FULL
void* full_mem_buf = malloc(params.full_size + 4095);
void* full_mem = (void*)((uintptr_t(full_mem_buf) + 4095) & ~4095);
#endif
void* cache_mem_buf = malloc(params.cache_size + 63);
void* cache_mem = (void*)((uintptr_t(cache_mem_buf) + 63) & ~63);
ethash_cache cache;
cache.mem = cache_mem;
// compute cache or full data
{
auto startTime = high_resolution_clock::now();
ethash_mkcache(&cache, &params, &seed);
auto time = std::chrono::duration_cast<std::chrono::milliseconds>(high_resolution_clock::now() - startTime).count();
ethash_h256_t cache_hash;
SHA3_256(&cache_hash, (uint8_t const*)cache_mem, params.cache_size);
debugf("ethash_mkcache: %ums, sha3: %s\n", (unsigned)((time*1000)/CLOCKS_PER_SEC), bytesToHexString(&cache_hash, sizeof(cache_hash)).data());
// print a couple of test hashes
{
auto startTime = high_resolution_clock::now();
ethash_return_value hash;
ethash_light(&hash, &cache, &params, &previous_hash, 0);
auto time = std::chrono::duration_cast<std::chrono::milliseconds>(high_resolution_clock::now() - startTime).count();
debugf("ethash_light test: %ums, %s\n", (unsigned)time, bytesToHexString(&hash.result, 32).data());
}
#ifdef FULL
startTime = high_resolution_clock::now();
ethash_compute_full_data(full_mem, &params, &cache);
time = std::chrono::duration_cast<std::chrono::milliseconds>(high_resolution_clock::now() - startTime).count();
debugf("ethash_compute_full_data: %ums\n", (unsigned)time);
#endif // FULL
}
#ifdef OPENCL
ethash_cl_miner miner;
{
auto startTime = high_resolution_clock::now();
if (!miner.init(params, &seed))
exit(-1);
auto time = std::chrono::duration_cast<std::chrono::milliseconds>(high_resolution_clock::now() - startTime).count();
debugf("ethash_cl_miner init: %ums\n", (unsigned)time);
}
#endif
#ifdef FULL
{
auto startTime = high_resolution_clock::now();
ethash_return_value hash;
ethash_full(&hash, full_mem, &params, &previous_hash, 0);
auto time = std::chrono::duration_cast<std::chrono::milliseconds>(high_resolution_clock::now() - startTime).count();
debugf("ethash_full test: %uns\n", (unsigned)time);
}
#endif
#ifdef OPENCL
// validate 1024 hashes against CPU
miner.hash(g_hashes, (uint8_t*)&previous_hash, 0, 1024);
for (unsigned i = 0; i != 1024; ++i)
{
ethash_return_value hash;
ethash_light(&hash, &cache, &params, &previous_hash, i);
if (memcmp(&hash.result, g_hashes + 32*i, 32) != 0)
{
debugf("nonce %u failed: %s %s\n", i, bytesToHexString(g_hashes + 32*i, 32).c_str(), bytesToHexString(&hash.result, 32).c_str());
static unsigned c = 0;
if (++c == 16)
{
exit(-1);
}
}
}
// ensure nothing else is going on
miner.finish();
#endif
auto startTime = high_resolution_clock::now();
unsigned hash_count = trials;
#ifdef OPENCL
{
struct search_hook : ethash_cl_miner::search_hook
{
unsigned hash_count;
std::vector<uint64_t> nonce_vec;
virtual bool found(uint64_t const* nonces, uint32_t count)
{
nonce_vec.insert(nonce_vec.end(), nonces, nonces + count);
return false;
}
virtual bool searched(uint64_t start_nonce, uint32_t count)
{
// do nothing
hash_count += count;
return hash_count >= trials;
}
};
search_hook hook;
hook.hash_count = 0;
miner.search((uint8_t*)&previous_hash, 0x000000ffffffffff, hook);
for (unsigned i = 0; i != hook.nonce_vec.size(); ++i)
{
uint64_t nonce = hook.nonce_vec[i];
ethash_return_value hash;
ethash_light(&hash, &cache, &params, &previous_hash, nonce);
debugf("found: %.8x%.8x -> %s\n", unsigned(nonce>>32), unsigned(nonce), bytesToHexString(&hash.result, 32).c_str());
}
hash_count = hook.hash_count;
}
#else
{
//#pragma omp parallel for
for (int nonce = 0; nonce < trials; ++nonce)
{
ethash_return_value hash;
#ifdef FULL
ethash_full(&hash, full_mem, &params, &previous_hash, nonce);
#else
ethash_light(&hash, &cache, &params, &previous_hash, nonce);
#endif // FULL
}
}
#endif
auto time = std::chrono::duration_cast<std::chrono::microseconds>(high_resolution_clock::now() - startTime).count();
debugf("Search took: %ums\n", (unsigned)time/1000);
unsigned read_size = ETHASH_ACCESSES * ETHASH_MIX_BYTES;
#if defined(OPENCL) || defined(FULL)
debugf(
"hashrate: %8.2f Mh/s, bw: %8.2f GB/s\n",
(double)hash_count * (1000*1000)/time / (1000*1000),
(double)hash_count*read_size * (1000*1000)/time / (1024*1024*1024)
);
#else
debugf(
"hashrate: %8.2f Kh/s, bw: %8.2f MB/s\n",
(double)hash_count * (1000*1000)/time / (1000),
(double)hash_count*read_size * (1000*1000)/time / (1024*1024)
);
#endif
free(cache_mem_buf);
#ifdef FULL
free(full_mem_buf);
#endif
return 0;
}

View File

@ -0,0 +1,44 @@
set(LIBRARY ethash)
if (CPPETHEREUM)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
endif ()
set(CMAKE_BUILD_TYPE Release)
if (NOT MSVC)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99")
endif()
set(FILES util.h
io.c
internal.c
ethash.h
endian.h
compiler.h
fnv.h
data_sizes.h)
if (MSVC)
list(APPEND FILES util_win32.c io_win32.c mmap_win32.c)
else()
list(APPEND FILES io_posix.c)
endif()
if (NOT CRYPTOPP_FOUND)
find_package(CryptoPP 5.6.2)
endif()
if (CRYPTOPP_FOUND)
add_definitions(-DWITH_CRYPTOPP)
include_directories( ${CRYPTOPP_INCLUDE_DIRS} )
list(APPEND FILES sha3_cryptopp.cpp sha3_cryptopp.h)
else()
list(APPEND FILES sha3.c sha3.h)
endif()
add_library(${LIBRARY} ${FILES})
if (CRYPTOPP_FOUND)
TARGET_LINK_LIBRARIES(${LIBRARY} ${CRYPTOPP_LIBRARIES})
endif()

View File

@ -0,0 +1,33 @@
/*
This file is part of cpp-ethereum.
cpp-ethereum is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
cpp-ethereum is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file compiler.h
* @date 2014
*/
#pragma once
// Visual Studio doesn't support the inline keyword in C mode
#if defined(_MSC_VER) && !defined(__cplusplus)
#define inline __inline
#endif
// pretend restrict is a standard keyword
#if defined(_MSC_VER)
#define restrict __restrict
#else
#define restrict __restrict__
#endif

View File

@ -0,0 +1,812 @@
/*
This file is part of cpp-ethereum.
cpp-ethereum is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software FoundationUUU,either version 3 of the LicenseUUU,or
(at your option) any later version.
cpp-ethereum is distributed in the hope that it will be usefulU,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with cpp-ethereum. If notUUU,see <http://www.gnu.org/licenses/>.
*/
/** @file data_sizes.h
* @author Matthew Wampler-Doty <negacthulhu@gmail.com>
* @date 2015
*/
#pragma once
#include <stdint.h>
#include "compiler.h"
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
// 2048 Epochs (~20 years) worth of tabulated DAG sizes
// Generated with the following Mathematica Code:
// GetCacheSizes[n_] := Module[{
// CacheSizeBytesInit = 2^24,
// CacheGrowth = 2^17,
// HashBytes = 64,
// j = 0},
// Reap[
// While[j < n,
// Module[{i =
// Floor[(CacheSizeBytesInit + CacheGrowth * j) / HashBytes]},
// While[! PrimeQ[i], i--];
// Sow[i*HashBytes]; j++]]]][[2]][[1]]
static const uint64_t dag_sizes[2048] = {
1073739904U, 1082130304U, 1090514816U, 1098906752U, 1107293056U,
1115684224U, 1124070016U, 1132461952U, 1140849536U, 1149232768U,
1157627776U, 1166013824U, 1174404736U, 1182786944U, 1191180416U,
1199568512U, 1207958912U, 1216345216U, 1224732032U, 1233124736U,
1241513344U, 1249902464U, 1258290304U, 1266673792U, 1275067264U,
1283453312U, 1291844992U, 1300234112U, 1308619904U, 1317010048U,
1325397376U, 1333787776U, 1342176128U, 1350561664U, 1358954368U,
1367339392U, 1375731584U, 1384118144U, 1392507008U, 1400897408U,
1409284736U, 1417673344U, 1426062464U, 1434451072U, 1442839168U,
1451229056U, 1459615616U, 1468006016U, 1476394112U, 1484782976U,
1493171584U, 1501559168U, 1509948032U, 1518337664U, 1526726528U,
1535114624U, 1543503488U, 1551892096U, 1560278656U, 1568669056U,
1577056384U, 1585446272U, 1593831296U, 1602219392U, 1610610304U,
1619000192U, 1627386752U, 1635773824U, 1644164224U, 1652555648U,
1660943488U, 1669332608U, 1677721216U, 1686109312U, 1694497664U,
1702886272U, 1711274624U, 1719661184U, 1728047744U, 1736434816U,
1744829056U, 1753218944U, 1761606272U, 1769995904U, 1778382464U,
1786772864U, 1795157888U, 1803550592U, 1811937664U, 1820327552U,
1828711552U, 1837102976U, 1845488768U, 1853879936U, 1862269312U,
1870656896U, 1879048064U, 1887431552U, 1895825024U, 1904212096U,
1912601216U, 1920988544U, 1929379456U, 1937765504U, 1946156672U,
1954543232U, 1962932096U, 1971321728U, 1979707264U, 1988093056U,
1996487552U, 2004874624U, 2013262208U, 2021653888U, 2030039936U,
2038430848U, 2046819968U, 2055208576U, 2063596672U, 2071981952U,
2080373632U, 2088762752U, 2097149056U, 2105539712U, 2113928576U,
2122315136U, 2130700672U, 2139092608U, 2147483264U, 2155872128U,
2164257664U, 2172642176U, 2181035392U, 2189426048U, 2197814912U,
2206203008U, 2214587264U, 2222979712U, 2231367808U, 2239758208U,
2248145024U, 2256527744U, 2264922752U, 2273312128U, 2281701248U,
2290086272U, 2298476672U, 2306867072U, 2315251072U, 2323639168U,
2332032128U, 2340420224U, 2348808064U, 2357196416U, 2365580416U,
2373966976U, 2382363008U, 2390748544U, 2399139968U, 2407530368U,
2415918976U, 2424307328U, 2432695424U, 2441084288U, 2449472384U,
2457861248U, 2466247808U, 2474637184U, 2483026816U, 2491414144U,
2499803776U, 2508191872U, 2516582272U, 2524970368U, 2533359232U,
2541743488U, 2550134144U, 2558525056U, 2566913408U, 2575301504U,
2583686528U, 2592073856U, 2600467328U, 2608856192U, 2617240448U,
2625631616U, 2634022016U, 2642407552U, 2650796416U, 2659188352U,
2667574912U, 2675965312U, 2684352896U, 2692738688U, 2701130624U,
2709518464U, 2717907328U, 2726293376U, 2734685056U, 2743073152U,
2751462016U, 2759851648U, 2768232832U, 2776625536U, 2785017728U,
2793401984U, 2801794432U, 2810182016U, 2818571648U, 2826959488U,
2835349376U, 2843734144U, 2852121472U, 2860514432U, 2868900992U,
2877286784U, 2885676928U, 2894069632U, 2902451584U, 2910843008U,
2919234688U, 2927622784U, 2936011648U, 2944400768U, 2952789376U,
2961177728U, 2969565568U, 2977951616U, 2986338944U, 2994731392U,
3003120256U, 3011508352U, 3019895936U, 3028287104U, 3036675968U,
3045063808U, 3053452928U, 3061837696U, 3070228352U, 3078615424U,
3087003776U, 3095394944U, 3103782272U, 3112173184U, 3120562048U,
3128944768U, 3137339264U, 3145725056U, 3154109312U, 3162505088U,
3170893184U, 3179280256U, 3187669376U, 3196056704U, 3204445568U,
3212836736U, 3221224064U, 3229612928U, 3238002304U, 3246391168U,
3254778496U, 3263165824U, 3271556224U, 3279944576U, 3288332416U,
3296719232U, 3305110912U, 3313500032U, 3321887104U, 3330273152U,
3338658944U, 3347053184U, 3355440512U, 3363827072U, 3372220288U,
3380608384U, 3388997504U, 3397384576U, 3405774208U, 3414163072U,
3422551936U, 3430937984U, 3439328384U, 3447714176U, 3456104576U,
3464493952U, 3472883584U, 3481268864U, 3489655168U, 3498048896U,
3506434432U, 3514826368U, 3523213952U, 3531603584U, 3539987072U,
3548380288U, 3556763264U, 3565157248U, 3573545344U, 3581934464U,
3590324096U, 3598712704U, 3607098752U, 3615488384U, 3623877248U,
3632265856U, 3640646528U, 3649043584U, 3657430144U, 3665821568U,
3674207872U, 3682597504U, 3690984832U, 3699367808U, 3707764352U,
3716152448U, 3724541056U, 3732925568U, 3741318016U, 3749706368U,
3758091136U, 3766481536U, 3774872704U, 3783260032U, 3791650432U,
3800036224U, 3808427648U, 3816815488U, 3825204608U, 3833592704U,
3841981568U, 3850370432U, 3858755968U, 3867147904U, 3875536256U,
3883920512U, 3892313728U, 3900702592U, 3909087872U, 3917478784U,
3925868416U, 3934256512U, 3942645376U, 3951032192U, 3959422336U,
3967809152U, 3976200064U, 3984588416U, 3992974976U, 4001363584U,
4009751168U, 4018141312U, 4026530432U, 4034911616U, 4043308928U,
4051695488U, 4060084352U, 4068472448U, 4076862848U, 4085249408U,
4093640576U, 4102028416U, 4110413696U, 4118805632U, 4127194496U,
4135583104U, 4143971968U, 4152360832U, 4160746112U, 4169135744U,
4177525888U, 4185912704U, 4194303616U, 4202691968U, 4211076736U,
4219463552U, 4227855488U, 4236246656U, 4244633728U, 4253022848U,
4261412224U, 4269799808U, 4278184832U, 4286578048U, 4294962304U,
4303349632U, 4311743104U, 4320130432U, 4328521088U, 4336909184U,
4345295488U, 4353687424U, 4362073472U, 4370458496U, 4378852736U,
4387238528U, 4395630208U, 4404019072U, 4412407424U, 4420790656U,
4429182848U, 4437571456U, 4445962112U, 4454344064U, 4462738048U,
4471119232U, 4479516544U, 4487904128U, 4496289664U, 4504682368U,
4513068416U, 4521459584U, 4529846144U, 4538232704U, 4546619776U,
4555010176U, 4563402112U, 4571790208U, 4580174464U, 4588567936U,
4596957056U, 4605344896U, 4613734016U, 4622119808U, 4630511488U,
4638898816U, 4647287936U, 4655675264U, 4664065664U, 4672451968U,
4680842624U, 4689231488U, 4697620352U, 4706007424U, 4714397056U,
4722786176U, 4731173248U, 4739562368U, 4747951744U, 4756340608U,
4764727936U, 4773114496U, 4781504384U, 4789894784U, 4798283648U,
4806667648U, 4815059584U, 4823449472U, 4831835776U, 4840226176U,
4848612224U, 4857003392U, 4865391488U, 4873780096U, 4882169728U,
4890557312U, 4898946944U, 4907333248U, 4915722368U, 4924110976U,
4932499328U, 4940889728U, 4949276032U, 4957666432U, 4966054784U,
4974438016U, 4982831488U, 4991221376U, 4999607168U, 5007998848U,
5016386432U, 5024763776U, 5033164672U, 5041544576U, 5049941888U,
5058329728U, 5066717056U, 5075107456U, 5083494272U, 5091883904U,
5100273536U, 5108662144U, 5117048192U, 5125436032U, 5133827456U,
5142215296U, 5150605184U, 5158993024U, 5167382144U, 5175769472U,
5184157568U, 5192543872U, 5200936064U, 5209324928U, 5217711232U,
5226102656U, 5234490496U, 5242877312U, 5251263872U, 5259654016U,
5268040832U, 5276434304U, 5284819328U, 5293209728U, 5301598592U,
5309986688U, 5318374784U, 5326764416U, 5335151488U, 5343542144U,
5351929472U, 5360319872U, 5368706944U, 5377096576U, 5385484928U,
5393871232U, 5402263424U, 5410650496U, 5419040384U, 5427426944U,
5435816576U, 5444205952U, 5452594816U, 5460981376U, 5469367936U,
5477760896U, 5486148736U, 5494536832U, 5502925952U, 5511315328U,
5519703424U, 5528089984U, 5536481152U, 5544869504U, 5553256064U,
5561645696U, 5570032768U, 5578423936U, 5586811264U, 5595193216U,
5603585408U, 5611972736U, 5620366208U, 5628750464U, 5637143936U,
5645528192U, 5653921408U, 5662310272U, 5670694784U, 5679082624U,
5687474048U, 5695864448U, 5704251008U, 5712641408U, 5721030272U,
5729416832U, 5737806208U, 5746194304U, 5754583936U, 5762969984U,
5771358592U, 5779748224U, 5788137856U, 5796527488U, 5804911232U,
5813300608U, 5821692544U, 5830082176U, 5838468992U, 5846855552U,
5855247488U, 5863636096U, 5872024448U, 5880411008U, 5888799872U,
5897186432U, 5905576832U, 5913966976U, 5922352768U, 5930744704U,
5939132288U, 5947522432U, 5955911296U, 5964299392U, 5972688256U,
5981074304U, 5989465472U, 5997851008U, 6006241408U, 6014627968U,
6023015552U, 6031408256U, 6039796096U, 6048185216U, 6056574848U,
6064963456U, 6073351808U, 6081736064U, 6090128768U, 6098517632U,
6106906496U, 6115289216U, 6123680896U, 6132070016U, 6140459648U,
6148849024U, 6157237376U, 6165624704U, 6174009728U, 6182403712U,
6190792064U, 6199176064U, 6207569792U, 6215952256U, 6224345216U,
6232732544U, 6241124224U, 6249510272U, 6257899136U, 6266287744U,
6274676864U, 6283065728U, 6291454336U, 6299843456U, 6308232064U,
6316620928U, 6325006208U, 6333395584U, 6341784704U, 6350174848U,
6358562176U, 6366951296U, 6375337856U, 6383729536U, 6392119168U,
6400504192U, 6408895616U, 6417283456U, 6425673344U, 6434059136U,
6442444672U, 6450837376U, 6459223424U, 6467613056U, 6476004224U,
6484393088U, 6492781952U, 6501170048U, 6509555072U, 6517947008U,
6526336384U, 6534725504U, 6543112832U, 6551500672U, 6559888768U,
6568278656U, 6576662912U, 6585055616U, 6593443456U, 6601834112U,
6610219648U, 6618610304U, 6626999168U, 6635385472U, 6643777408U,
6652164224U, 6660552832U, 6668941952U, 6677330048U, 6685719424U,
6694107776U, 6702493568U, 6710882176U, 6719274112U, 6727662976U,
6736052096U, 6744437632U, 6752825984U, 6761213824U, 6769604224U,
6777993856U, 6786383488U, 6794770816U, 6803158144U, 6811549312U,
6819937664U, 6828326528U, 6836706176U, 6845101696U, 6853491328U,
6861880448U, 6870269312U, 6878655104U, 6887046272U, 6895433344U,
6903822208U, 6912212864U, 6920596864U, 6928988288U, 6937377152U,
6945764992U, 6954149248U, 6962544256U, 6970928768U, 6979317376U,
6987709312U, 6996093824U, 7004487296U, 7012875392U, 7021258624U,
7029652352U, 7038038912U, 7046427776U, 7054818944U, 7063207808U,
7071595136U, 7079980928U, 7088372608U, 7096759424U, 7105149824U,
7113536896U, 7121928064U, 7130315392U, 7138699648U, 7147092352U,
7155479168U, 7163865728U, 7172249984U, 7180648064U, 7189036672U,
7197424768U, 7205810816U, 7214196608U, 7222589824U, 7230975104U,
7239367552U, 7247755904U, 7256145536U, 7264533376U, 7272921472U,
7281308032U, 7289694848U, 7298088832U, 7306471808U, 7314864512U,
7323253888U, 7331643008U, 7340029568U, 7348419712U, 7356808832U,
7365196672U, 7373585792U, 7381973888U, 7390362752U, 7398750592U,
7407138944U, 7415528576U, 7423915648U, 7432302208U, 7440690304U,
7449080192U, 7457472128U, 7465860992U, 7474249088U, 7482635648U,
7491023744U, 7499412608U, 7507803008U, 7516192384U, 7524579968U,
7532967296U, 7541358464U, 7549745792U, 7558134656U, 7566524032U,
7574912896U, 7583300992U, 7591690112U, 7600075136U, 7608466816U,
7616854912U, 7625244544U, 7633629824U, 7642020992U, 7650410368U,
7658794112U, 7667187328U, 7675574912U, 7683961984U, 7692349568U,
7700739712U, 7709130368U, 7717519232U, 7725905536U, 7734295424U,
7742683264U, 7751069056U, 7759457408U, 7767849088U, 7776238208U,
7784626816U, 7793014912U, 7801405312U, 7809792128U, 7818179968U,
7826571136U, 7834957184U, 7843347328U, 7851732352U, 7860124544U,
7868512384U, 7876902016U, 7885287808U, 7893679744U, 7902067072U,
7910455936U, 7918844288U, 7927230848U, 7935622784U, 7944009344U,
7952400256U, 7960786048U, 7969176704U, 7977565312U, 7985953408U,
7994339968U, 8002730368U, 8011119488U, 8019508096U, 8027896192U,
8036285056U, 8044674688U, 8053062272U, 8061448832U, 8069838464U,
8078227328U, 8086616704U, 8095006592U, 8103393664U, 8111783552U,
8120171392U, 8128560256U, 8136949376U, 8145336704U, 8153726848U,
8162114944U, 8170503296U, 8178891904U, 8187280768U, 8195669632U,
8204058496U, 8212444544U, 8220834176U, 8229222272U, 8237612672U,
8246000768U, 8254389376U, 8262775168U, 8271167104U, 8279553664U,
8287944064U, 8296333184U, 8304715136U, 8313108352U, 8321497984U,
8329885568U, 8338274432U, 8346663296U, 8355052928U, 8363441536U,
8371828352U, 8380217984U, 8388606592U, 8396996224U, 8405384576U,
8413772672U, 8422161536U, 8430549376U, 8438939008U, 8447326592U,
8455715456U, 8464104832U, 8472492928U, 8480882048U, 8489270656U,
8497659776U, 8506045312U, 8514434944U, 8522823808U, 8531208832U,
8539602304U, 8547990656U, 8556378752U, 8564768384U, 8573154176U,
8581542784U, 8589933952U, 8598322816U, 8606705024U, 8615099264U,
8623487872U, 8631876992U, 8640264064U, 8648653952U, 8657040256U,
8665430656U, 8673820544U, 8682209152U, 8690592128U, 8698977152U,
8707374464U, 8715763328U, 8724151424U, 8732540032U, 8740928384U,
8749315712U, 8757704576U, 8766089344U, 8774480768U, 8782871936U,
8791260032U, 8799645824U, 8808034432U, 8816426368U, 8824812928U,
8833199488U, 8841591424U, 8849976448U, 8858366336U, 8866757248U,
8875147136U, 8883532928U, 8891923328U, 8900306816U, 8908700288U,
8917088384U, 8925478784U, 8933867392U, 8942250368U, 8950644608U,
8959032704U, 8967420544U, 8975809664U, 8984197504U, 8992584064U,
9000976256U, 9009362048U, 9017752448U, 9026141312U, 9034530688U,
9042917504U, 9051307904U, 9059694208U, 9068084864U, 9076471424U,
9084861824U, 9093250688U, 9101638528U, 9110027648U, 9118416512U,
9126803584U, 9135188096U, 9143581312U, 9151969664U, 9160356224U,
9168747136U, 9177134464U, 9185525632U, 9193910144U, 9202302848U,
9210690688U, 9219079552U, 9227465344U, 9235854464U, 9244244864U,
9252633472U, 9261021824U, 9269411456U, 9277799296U, 9286188928U,
9294574208U, 9302965888U, 9311351936U, 9319740032U, 9328131968U,
9336516736U, 9344907392U, 9353296768U, 9361685888U, 9370074752U,
9378463616U, 9386849408U, 9395239808U, 9403629184U, 9412016512U,
9420405376U, 9428795008U, 9437181568U, 9445570688U, 9453960832U,
9462346624U, 9470738048U, 9479121536U, 9487515008U, 9495903616U,
9504289664U, 9512678528U, 9521067904U, 9529456256U, 9537843584U,
9546233728U, 9554621312U, 9563011456U, 9571398784U, 9579788672U,
9588178304U, 9596567168U, 9604954496U, 9613343104U, 9621732992U,
9630121856U, 9638508416U, 9646898816U, 9655283584U, 9663675776U,
9672061312U, 9680449664U, 9688840064U, 9697230464U, 9705617536U,
9714003584U, 9722393984U, 9730772608U, 9739172224U, 9747561088U,
9755945344U, 9764338816U, 9772726144U, 9781116544U, 9789503872U,
9797892992U, 9806282624U, 9814670464U, 9823056512U, 9831439232U,
9839833984U, 9848224384U, 9856613504U, 9865000576U, 9873391232U,
9881772416U, 9890162816U, 9898556288U, 9906940544U, 9915333248U,
9923721088U, 9932108672U, 9940496512U, 9948888448U, 9957276544U,
9965666176U, 9974048384U, 9982441088U, 9990830464U, 9999219584U,
10007602816U, 10015996544U, 10024385152U, 10032774016U, 10041163648U,
10049548928U, 10057940096U, 10066329472U, 10074717824U, 10083105152U,
10091495296U, 10099878784U, 10108272256U, 10116660608U, 10125049216U,
10133437312U, 10141825664U, 10150213504U, 10158601088U, 10166991232U,
10175378816U, 10183766144U, 10192157312U, 10200545408U, 10208935552U,
10217322112U, 10225712768U, 10234099328U, 10242489472U, 10250876032U,
10259264896U, 10267656064U, 10276042624U, 10284429184U, 10292820352U,
10301209472U, 10309598848U, 10317987712U, 10326375296U, 10334763392U,
10343153536U, 10351541632U, 10359930752U, 10368318592U, 10376707456U,
10385096576U, 10393484672U, 10401867136U, 10410262144U, 10418647424U,
10427039104U, 10435425664U, 10443810176U, 10452203648U, 10460589952U,
10468982144U, 10477369472U, 10485759104U, 10494147712U, 10502533504U,
10510923392U, 10519313536U, 10527702656U, 10536091264U, 10544478592U,
10552867712U, 10561255808U, 10569642368U, 10578032768U, 10586423168U,
10594805632U, 10603200128U, 10611588992U, 10619976064U, 10628361344U,
10636754048U, 10645143424U, 10653531776U, 10661920384U, 10670307968U,
10678696832U, 10687086464U, 10695475072U, 10703863168U, 10712246144U,
10720639616U, 10729026688U, 10737414784U, 10745806208U, 10754190976U,
10762581376U, 10770971264U, 10779356288U, 10787747456U, 10796135552U,
10804525184U, 10812915584U, 10821301888U, 10829692288U, 10838078336U,
10846469248U, 10854858368U, 10863247232U, 10871631488U, 10880023424U,
10888412032U, 10896799616U, 10905188992U, 10913574016U, 10921964672U,
10930352768U, 10938742912U, 10947132544U, 10955518592U, 10963909504U,
10972298368U, 10980687488U, 10989074816U, 10997462912U, 11005851776U,
11014241152U, 11022627712U, 11031017344U, 11039403904U, 11047793024U,
11056184704U, 11064570752U, 11072960896U, 11081343872U, 11089737856U,
11098128256U, 11106514816U, 11114904448U, 11123293568U, 11131680128U,
11140065152U, 11148458368U, 11156845696U, 11165236864U, 11173624192U,
11182013824U, 11190402688U, 11198790784U, 11207179136U, 11215568768U,
11223957376U, 11232345728U, 11240734592U, 11249122688U, 11257511296U,
11265899648U, 11274285952U, 11282675584U, 11291065472U, 11299452544U,
11307842432U, 11316231296U, 11324616832U, 11333009024U, 11341395584U,
11349782656U, 11358172288U, 11366560384U, 11374950016U, 11383339648U,
11391721856U, 11400117376U, 11408504192U, 11416893568U, 11425283456U,
11433671552U, 11442061184U, 11450444672U, 11458837888U, 11467226752U,
11475611776U, 11484003968U, 11492392064U, 11500780672U, 11509169024U,
11517550976U, 11525944448U, 11534335616U, 11542724224U, 11551111808U,
11559500672U, 11567890304U, 11576277376U, 11584667008U, 11593056128U,
11601443456U, 11609830016U, 11618221952U, 11626607488U, 11634995072U,
11643387776U, 11651775104U, 11660161664U, 11668552576U, 11676940928U,
11685330304U, 11693718656U, 11702106496U, 11710496128U, 11718882688U,
11727273088U, 11735660416U, 11744050048U, 11752437376U, 11760824704U,
11769216128U, 11777604736U, 11785991296U, 11794381952U, 11802770048U,
11811157888U, 11819548544U, 11827932544U, 11836324736U, 11844713344U,
11853100928U, 11861486464U, 11869879936U, 11878268032U, 11886656896U,
11895044992U, 11903433088U, 11911822976U, 11920210816U, 11928600448U,
11936987264U, 11945375872U, 11953761152U, 11962151296U, 11970543488U,
11978928512U, 11987320448U, 11995708288U, 12004095104U, 12012486272U,
12020875136U, 12029255552U, 12037652096U, 12046039168U, 12054429568U,
12062813824U, 12071206528U, 12079594624U, 12087983744U, 12096371072U,
12104759936U, 12113147264U, 12121534592U, 12129924992U, 12138314624U,
12146703232U, 12155091584U, 12163481216U, 12171864704U, 12180255872U,
12188643968U, 12197034112U, 12205424512U, 12213811328U, 12222199424U,
12230590336U, 12238977664U, 12247365248U, 12255755392U, 12264143488U,
12272531584U, 12280920448U, 12289309568U, 12297694592U, 12306086528U,
12314475392U, 12322865024U, 12331253632U, 12339640448U, 12348029312U,
12356418944U, 12364805248U, 12373196672U, 12381580928U, 12389969024U,
12398357632U, 12406750592U, 12415138432U, 12423527552U, 12431916416U,
12440304512U, 12448692352U, 12457081216U, 12465467776U, 12473859968U,
12482245504U, 12490636672U, 12499025536U, 12507411584U, 12515801728U,
12524190592U, 12532577152U, 12540966272U, 12549354368U, 12557743232U,
12566129536U, 12574523264U, 12582911872U, 12591299456U, 12599688064U,
12608074624U, 12616463488U, 12624845696U, 12633239936U, 12641631616U,
12650019968U, 12658407296U, 12666795136U, 12675183232U, 12683574656U,
12691960192U, 12700350592U, 12708740224U, 12717128576U, 12725515904U,
12733906816U, 12742295168U, 12750680192U, 12759071872U, 12767460736U,
12775848832U, 12784236928U, 12792626816U, 12801014656U, 12809404288U,
12817789312U, 12826181504U, 12834568832U, 12842954624U, 12851345792U,
12859732352U, 12868122496U, 12876512128U, 12884901248U, 12893289088U,
12901672832U, 12910067584U, 12918455168U, 12926842496U, 12935232896U,
12943620736U, 12952009856U, 12960396928U, 12968786816U, 12977176192U,
12985563776U, 12993951104U, 13002341504U, 13010730368U, 13019115392U,
13027506304U, 13035895168U, 13044272512U, 13052673152U, 13061062528U,
13069446272U, 13077838976U, 13086227072U, 13094613632U, 13103000192U,
13111393664U, 13119782528U, 13128157568U, 13136559232U, 13144945024U,
13153329536U, 13161724288U, 13170111872U, 13178502784U, 13186884736U,
13195279744U, 13203667072U, 13212057472U, 13220445824U, 13228832128U,
13237221248U, 13245610624U, 13254000512U, 13262388352U, 13270777472U,
13279166336U, 13287553408U, 13295943296U, 13304331904U, 13312719488U,
13321108096U, 13329494656U, 13337885824U, 13346274944U, 13354663808U,
13363051136U, 13371439232U, 13379825024U, 13388210816U, 13396605056U,
13404995456U, 13413380224U, 13421771392U, 13430159744U, 13438546048U,
13446937216U, 13455326848U, 13463708288U, 13472103808U, 13480492672U,
13488875648U, 13497269888U, 13505657728U, 13514045312U, 13522435712U,
13530824576U, 13539210112U, 13547599232U, 13555989376U, 13564379008U,
13572766336U, 13581154432U, 13589544832U, 13597932928U, 13606320512U,
13614710656U, 13623097472U, 13631477632U, 13639874944U, 13648264064U,
13656652928U, 13665041792U, 13673430656U, 13681818496U, 13690207616U,
13698595712U, 13706982272U, 13715373184U, 13723762048U, 13732150144U,
13740536704U, 13748926592U, 13757316224U, 13765700992U, 13774090112U,
13782477952U, 13790869376U, 13799259008U, 13807647872U, 13816036736U,
13824425344U, 13832814208U, 13841202304U, 13849591424U, 13857978752U,
13866368896U, 13874754688U, 13883145344U, 13891533184U, 13899919232U,
13908311168U, 13916692096U, 13925085056U, 13933473152U, 13941866368U,
13950253696U, 13958643584U, 13967032192U, 13975417216U, 13983807616U,
13992197504U, 14000582272U, 14008973696U, 14017363072U, 14025752192U,
14034137984U, 14042528384U, 14050918016U, 14059301504U, 14067691648U,
14076083584U, 14084470144U, 14092852352U, 14101249664U, 14109635968U,
14118024832U, 14126407552U, 14134804352U, 14143188608U, 14151577984U,
14159968384U, 14168357248U, 14176741504U, 14185127296U, 14193521024U,
14201911424U, 14210301824U, 14218685056U, 14227067264U, 14235467392U,
14243855488U, 14252243072U, 14260630144U, 14269021568U, 14277409408U,
14285799296U, 14294187904U, 14302571392U, 14310961792U, 14319353728U,
14327738752U, 14336130944U, 14344518784U, 14352906368U, 14361296512U,
14369685376U, 14378071424U, 14386462592U, 14394848128U, 14403230848U,
14411627392U, 14420013952U, 14428402304U, 14436793472U, 14445181568U,
14453569664U, 14461959808U, 14470347904U, 14478737024U, 14487122816U,
14495511424U, 14503901824U, 14512291712U, 14520677504U, 14529064832U,
14537456768U, 14545845632U, 14554234496U, 14562618496U, 14571011456U,
14579398784U, 14587789184U, 14596172672U, 14604564608U, 14612953984U,
14621341312U, 14629724288U, 14638120832U, 14646503296U, 14654897536U,
14663284864U, 14671675264U, 14680061056U, 14688447616U, 14696835968U,
14705228416U, 14713616768U, 14722003328U, 14730392192U, 14738784128U,
14747172736U, 14755561088U, 14763947648U, 14772336512U, 14780725376U,
14789110144U, 14797499776U, 14805892736U, 14814276992U, 14822670208U,
14831056256U, 14839444352U, 14847836032U, 14856222848U, 14864612992U,
14872997504U, 14881388672U, 14889775744U, 14898165376U, 14906553472U,
14914944896U, 14923329664U, 14931721856U, 14940109696U, 14948497024U,
14956887424U, 14965276544U, 14973663616U, 14982053248U, 14990439808U,
14998830976U, 15007216768U, 15015605888U, 15023995264U, 15032385152U,
15040768384U, 15049154944U, 15057549184U, 15065939072U, 15074328448U,
15082715008U, 15091104128U, 15099493504U, 15107879296U, 15116269184U,
15124659584U, 15133042304U, 15141431936U, 15149824384U, 15158214272U,
15166602368U, 15174991232U, 15183378304U, 15191760512U, 15200154496U,
15208542592U, 15216931712U, 15225323392U, 15233708416U, 15242098048U,
15250489216U, 15258875264U, 15267265408U, 15275654528U, 15284043136U,
15292431488U, 15300819584U, 15309208192U, 15317596544U, 15325986176U,
15334374784U, 15342763648U, 15351151744U, 15359540608U, 15367929728U,
15376318336U, 15384706432U, 15393092992U, 15401481856U, 15409869952U,
15418258816U, 15426649984U, 15435037568U, 15443425664U, 15451815296U,
15460203392U, 15468589184U, 15476979328U, 15485369216U, 15493755776U,
15502146944U, 15510534272U, 15518924416U, 15527311232U, 15535699072U,
15544089472U, 15552478336U, 15560866688U, 15569254528U, 15577642624U,
15586031488U, 15594419072U, 15602809472U, 15611199104U, 15619586432U,
15627975296U, 15636364928U, 15644753792U, 15653141888U, 15661529216U,
15669918848U, 15678305152U, 15686696576U, 15695083136U, 15703474048U,
15711861632U, 15720251264U, 15728636288U, 15737027456U, 15745417088U,
15753804928U, 15762194048U, 15770582656U, 15778971008U, 15787358336U,
15795747712U, 15804132224U, 15812523392U, 15820909696U, 15829300096U,
15837691264U, 15846071936U, 15854466944U, 15862855808U, 15871244672U,
15879634816U, 15888020608U, 15896409728U, 15904799104U, 15913185152U,
15921577088U, 15929966464U, 15938354816U, 15946743424U, 15955129472U,
15963519872U, 15971907968U, 15980296064U, 15988684928U, 15997073024U,
16005460864U, 16013851264U, 16022241152U, 16030629248U, 16039012736U,
16047406976U, 16055794816U, 16064181376U, 16072571264U, 16080957824U,
16089346688U, 16097737856U, 16106125184U, 16114514816U, 16122904192U,
16131292544U, 16139678848U, 16148066944U, 16156453504U, 16164839552U,
16173236096U, 16181623424U, 16190012032U, 16198401152U, 16206790528U,
16215177344U, 16223567744U, 16231956352U, 16240344704U, 16248731008U,
16257117824U, 16265504384U, 16273898624U, 16282281856U, 16290668672U,
16299064192U, 16307449216U, 16315842176U, 16324230016U, 16332613504U,
16341006464U, 16349394304U, 16357783168U, 16366172288U, 16374561664U,
16382951296U, 16391337856U, 16399726208U, 16408116352U, 16416505472U,
16424892032U, 16433282176U, 16441668224U, 16450058624U, 16458448768U,
16466836864U, 16475224448U, 16483613056U, 16492001408U, 16500391808U,
16508779648U, 16517166976U, 16525555328U, 16533944192U, 16542330752U,
16550719616U, 16559110528U, 16567497088U, 16575888512U, 16584274816U,
16592665472U, 16601051008U, 16609442944U, 16617832064U, 16626218624U,
16634607488U, 16642996096U, 16651385728U, 16659773824U, 16668163712U,
16676552576U, 16684938112U, 16693328768U, 16701718144U, 16710095488U,
16718492288U, 16726883968U, 16735272832U, 16743661184U, 16752049792U,
16760436608U, 16768827008U, 16777214336U, 16785599104U, 16793992832U,
16802381696U, 16810768768U, 16819151744U, 16827542656U, 16835934848U,
16844323712U, 16852711552U, 16861101952U, 16869489536U, 16877876864U,
16886265728U, 16894653056U, 16903044736U, 16911431296U, 16919821696U,
16928207488U, 16936592768U, 16944987776U, 16953375616U, 16961763968U,
16970152832U, 16978540928U, 16986929536U, 16995319168U, 17003704448U,
17012096896U, 17020481152U, 17028870784U, 17037262208U, 17045649536U,
17054039936U, 17062426496U, 17070814336U, 17079205504U, 17087592064U,
17095978112U, 17104369024U, 17112759424U, 17121147776U, 17129536384U,
17137926016U, 17146314368U, 17154700928U, 17163089792U, 17171480192U,
17179864192U, 17188256896U, 17196644992U, 17205033856U, 17213423488U,
17221811072U, 17230198912U, 17238588032U, 17246976896U, 17255360384U,
17263754624U, 17272143232U, 17280530048U, 17288918912U, 17297309312U,
17305696384U, 17314085504U, 17322475136U, 17330863744U, 17339252096U,
17347640192U, 17356026496U, 17364413824U, 17372796544U, 17381190016U,
17389583488U, 17397972608U, 17406360704U, 17414748544U, 17423135872U,
17431527296U, 17439915904U, 17448303232U, 17456691584U, 17465081728U,
17473468288U, 17481857408U, 17490247552U, 17498635904U, 17507022464U,
17515409024U, 17523801728U, 17532189824U, 17540577664U, 17548966016U,
17557353344U, 17565741184U, 17574131584U, 17582519168U, 17590907008U,
17599296128U, 17607687808U, 17616076672U, 17624455808U, 17632852352U,
17641238656U, 17649630848U, 17658018944U, 17666403968U, 17674794112U,
17683178368U, 17691573376U, 17699962496U, 17708350592U, 17716739968U,
17725126528U, 17733517184U, 17741898112U, 17750293888U, 17758673024U,
17767070336U, 17775458432U, 17783848832U, 17792236928U, 17800625536U,
17809012352U, 17817402752U, 17825785984U, 17834178944U, 17842563968U,
17850955648U, 17859344512U, 17867732864U, 17876119424U, 17884511872U,
17892900224U, 17901287296U, 17909677696U, 17918058112U, 17926451072U,
17934843776U, 17943230848U, 17951609216U, 17960008576U, 17968397696U,
17976784256U, 17985175424U, 17993564032U, 18001952128U, 18010339712U,
18018728576U, 18027116672U, 18035503232U, 18043894144U, 18052283264U,
18060672128U, 18069056384U, 18077449856U, 18085837184U, 18094225792U,
18102613376U, 18111004544U, 18119388544U, 18127781248U, 18136170368U,
18144558976U, 18152947328U, 18161336192U, 18169724288U, 18178108544U,
18186498944U, 18194886784U, 18203275648U, 18211666048U, 18220048768U,
18228444544U, 18236833408U, 18245220736U
};
// Generated with the following Mathematica Code:
// GetCacheSizes[n_] := Module[{
// DataSetSizeBytesInit = 2^30,
// MixBytes = 128,
// DataSetGrowth = 2^23,
// HashBytes = 64,
// CacheMultiplier = 1024,
// j = 0},
// Reap[
// While[j < n,
// Module[{i = Floor[(DataSetSizeBytesInit + DataSetGrowth * j) / (CacheMultiplier * HashBytes)]},
// While[! PrimeQ[i], i--];
// Sow[i*HashBytes]; j++]]]][[2]][[1]]
const uint64_t cache_sizes[2048] = {
16776896U, 16907456U, 17039296U, 17170112U, 17301056U, 17432512U, 17563072U,
17693888U, 17824192U, 17955904U, 18087488U, 18218176U, 18349504U, 18481088U,
18611392U, 18742336U, 18874304U, 19004224U, 19135936U, 19267264U, 19398208U,
19529408U, 19660096U, 19791424U, 19922752U, 20053952U, 20184896U, 20315968U,
20446912U, 20576576U, 20709184U, 20840384U, 20971072U, 21102272U, 21233216U,
21364544U, 21494848U, 21626816U, 21757376U, 21887552U, 22019392U, 22151104U,
22281536U, 22412224U, 22543936U, 22675264U, 22806464U, 22935872U, 23068096U,
23198272U, 23330752U, 23459008U, 23592512U, 23723968U, 23854912U, 23986112U,
24116672U, 24247616U, 24378688U, 24509504U, 24640832U, 24772544U, 24903488U,
25034432U, 25165376U, 25296704U, 25427392U, 25558592U, 25690048U, 25820096U,
25951936U, 26081728U, 26214208U, 26345024U, 26476096U, 26606656U, 26737472U,
26869184U, 26998208U, 27131584U, 27262528U, 27393728U, 27523904U, 27655744U,
27786688U, 27917888U, 28049344U, 28179904U, 28311488U, 28441792U, 28573504U,
28700864U, 28835648U, 28966208U, 29096768U, 29228608U, 29359808U, 29490752U,
29621824U, 29752256U, 29882816U, 30014912U, 30144448U, 30273728U, 30406976U,
30538432U, 30670784U, 30799936U, 30932672U, 31063744U, 31195072U, 31325248U,
31456192U, 31588288U, 31719232U, 31850432U, 31981504U, 32110784U, 32243392U,
32372672U, 32505664U, 32636608U, 32767808U, 32897344U, 33029824U, 33160768U,
33289664U, 33423296U, 33554368U, 33683648U, 33816512U, 33947456U, 34076992U,
34208704U, 34340032U, 34471744U, 34600256U, 34734016U, 34864576U, 34993984U,
35127104U, 35258176U, 35386688U, 35518528U, 35650624U, 35782336U, 35910976U,
36044608U, 36175808U, 36305728U, 36436672U, 36568384U, 36699968U, 36830656U,
36961984U, 37093312U, 37223488U, 37355072U, 37486528U, 37617472U, 37747904U,
37879232U, 38009792U, 38141888U, 38272448U, 38403392U, 38535104U, 38660672U,
38795584U, 38925632U, 39059264U, 39190336U, 39320768U, 39452096U, 39581632U,
39713984U, 39844928U, 39974848U, 40107968U, 40238144U, 40367168U, 40500032U,
40631744U, 40762816U, 40894144U, 41023552U, 41155904U, 41286208U, 41418304U,
41547712U, 41680448U, 41811904U, 41942848U, 42073792U, 42204992U, 42334912U,
42467008U, 42597824U, 42729152U, 42860096U, 42991552U, 43122368U, 43253696U,
43382848U, 43515712U, 43646912U, 43777088U, 43907648U, 44039104U, 44170432U,
44302144U, 44433344U, 44564288U, 44694976U, 44825152U, 44956864U, 45088448U,
45219008U, 45350464U, 45481024U, 45612608U, 45744064U, 45874496U, 46006208U,
46136768U, 46267712U, 46399424U, 46529344U, 46660672U, 46791488U, 46923328U,
47053504U, 47185856U, 47316928U, 47447872U, 47579072U, 47710144U, 47839936U,
47971648U, 48103232U, 48234176U, 48365248U, 48496192U, 48627136U, 48757312U,
48889664U, 49020736U, 49149248U, 49283008U, 49413824U, 49545152U, 49675712U,
49807168U, 49938368U, 50069056U, 50200256U, 50331584U, 50462656U, 50593472U,
50724032U, 50853952U, 50986048U, 51117632U, 51248576U, 51379904U, 51510848U,
51641792U, 51773248U, 51903296U, 52035136U, 52164032U, 52297664U, 52427968U,
52557376U, 52690112U, 52821952U, 52952896U, 53081536U, 53213504U, 53344576U,
53475776U, 53608384U, 53738816U, 53870528U, 54000832U, 54131776U, 54263744U,
54394688U, 54525248U, 54655936U, 54787904U, 54918592U, 55049152U, 55181248U,
55312064U, 55442752U, 55574336U, 55705024U, 55836224U, 55967168U, 56097856U,
56228672U, 56358592U, 56490176U, 56621888U, 56753728U, 56884928U, 57015488U,
57146816U, 57278272U, 57409216U, 57540416U, 57671104U, 57802432U, 57933632U,
58064576U, 58195264U, 58326976U, 58457408U, 58588864U, 58720192U, 58849984U,
58981696U, 59113024U, 59243456U, 59375552U, 59506624U, 59637568U, 59768512U,
59897792U, 60030016U, 60161984U, 60293056U, 60423872U, 60554432U, 60683968U,
60817216U, 60948032U, 61079488U, 61209664U, 61341376U, 61471936U, 61602752U,
61733696U, 61865792U, 61996736U, 62127808U, 62259136U, 62389568U, 62520512U,
62651584U, 62781632U, 62910784U, 63045056U, 63176128U, 63307072U, 63438656U,
63569216U, 63700928U, 63831616U, 63960896U, 64093888U, 64225088U, 64355392U,
64486976U, 64617664U, 64748608U, 64879424U, 65009216U, 65142464U, 65273792U,
65402816U, 65535424U, 65666752U, 65797696U, 65927744U, 66060224U, 66191296U,
66321344U, 66453056U, 66584384U, 66715328U, 66846656U, 66977728U, 67108672U,
67239104U, 67370432U, 67501888U, 67631296U, 67763776U, 67895104U, 68026304U,
68157248U, 68287936U, 68419264U, 68548288U, 68681408U, 68811968U, 68942912U,
69074624U, 69205568U, 69337024U, 69467584U, 69599168U, 69729472U, 69861184U,
69989824U, 70122944U, 70253888U, 70385344U, 70515904U, 70647232U, 70778816U,
70907968U, 71040832U, 71171648U, 71303104U, 71432512U, 71564992U, 71695168U,
71826368U, 71958464U, 72089536U, 72219712U, 72350144U, 72482624U, 72613568U,
72744512U, 72875584U, 73006144U, 73138112U, 73268672U, 73400128U, 73530944U,
73662272U, 73793344U, 73924544U, 74055104U, 74185792U, 74316992U, 74448832U,
74579392U, 74710976U, 74841664U, 74972864U, 75102784U, 75233344U, 75364544U,
75497024U, 75627584U, 75759296U, 75890624U, 76021696U, 76152256U, 76283072U,
76414144U, 76545856U, 76676672U, 76806976U, 76937792U, 77070016U, 77200832U,
77331392U, 77462464U, 77593664U, 77725376U, 77856448U, 77987776U, 78118336U,
78249664U, 78380992U, 78511424U, 78642496U, 78773056U, 78905152U, 79033664U,
79166656U, 79297472U, 79429568U, 79560512U, 79690816U, 79822784U, 79953472U,
80084672U, 80214208U, 80346944U, 80477632U, 80608576U, 80740288U, 80870848U,
81002048U, 81133504U, 81264448U, 81395648U, 81525952U, 81657536U, 81786304U,
81919808U, 82050112U, 82181312U, 82311616U, 82443968U, 82573376U, 82705984U,
82835776U, 82967744U, 83096768U, 83230528U, 83359552U, 83491264U, 83622464U,
83753536U, 83886016U, 84015296U, 84147776U, 84277184U, 84409792U, 84540608U,
84672064U, 84803008U, 84934336U, 85065152U, 85193792U, 85326784U, 85458496U,
85589312U, 85721024U, 85851968U, 85982656U, 86112448U, 86244416U, 86370112U,
86506688U, 86637632U, 86769344U, 86900672U, 87031744U, 87162304U, 87293632U,
87424576U, 87555392U, 87687104U, 87816896U, 87947968U, 88079168U, 88211264U,
88341824U, 88473152U, 88603712U, 88735424U, 88862912U, 88996672U, 89128384U,
89259712U, 89390272U, 89521984U, 89652544U, 89783872U, 89914816U, 90045376U,
90177088U, 90307904U, 90438848U, 90569152U, 90700096U, 90832832U, 90963776U,
91093696U, 91223744U, 91356992U, 91486784U, 91618496U, 91749824U, 91880384U,
92012224U, 92143552U, 92273344U, 92405696U, 92536768U, 92666432U, 92798912U,
92926016U, 93060544U, 93192128U, 93322816U, 93453632U, 93583936U, 93715136U,
93845056U, 93977792U, 94109504U, 94240448U, 94371776U, 94501184U, 94632896U,
94764224U, 94895552U, 95023424U, 95158208U, 95287744U, 95420224U, 95550016U,
95681216U, 95811904U, 95943872U, 96075328U, 96203584U, 96337856U, 96468544U,
96599744U, 96731072U, 96860992U, 96992576U, 97124288U, 97254848U, 97385536U,
97517248U, 97647808U, 97779392U, 97910464U, 98041408U, 98172608U, 98303168U,
98434496U, 98565568U, 98696768U, 98827328U, 98958784U, 99089728U, 99220928U,
99352384U, 99482816U, 99614272U, 99745472U, 99876416U, 100007104U,
100138048U, 100267072U, 100401088U, 100529984U, 100662592U, 100791872U,
100925248U, 101056064U, 101187392U, 101317952U, 101449408U, 101580608U,
101711296U, 101841728U, 101973824U, 102104896U, 102235712U, 102366016U,
102498112U, 102628672U, 102760384U, 102890432U, 103021888U, 103153472U,
103284032U, 103415744U, 103545152U, 103677248U, 103808576U, 103939648U,
104070976U, 104201792U, 104332736U, 104462528U, 104594752U, 104725952U,
104854592U, 104988608U, 105118912U, 105247808U, 105381184U, 105511232U,
105643072U, 105774784U, 105903296U, 106037056U, 106167872U, 106298944U,
106429504U, 106561472U, 106691392U, 106822592U, 106954304U, 107085376U,
107216576U, 107346368U, 107478464U, 107609792U, 107739712U, 107872192U,
108003136U, 108131392U, 108265408U, 108396224U, 108527168U, 108657344U,
108789568U, 108920384U, 109049792U, 109182272U, 109312576U, 109444928U,
109572928U, 109706944U, 109837888U, 109969088U, 110099648U, 110230976U,
110362432U, 110492992U, 110624704U, 110755264U, 110886208U, 111017408U,
111148864U, 111279296U, 111410752U, 111541952U, 111673024U, 111803456U,
111933632U, 112066496U, 112196416U, 112328512U, 112457792U, 112590784U,
112715968U, 112852672U, 112983616U, 113114944U, 113244224U, 113376448U,
113505472U, 113639104U, 113770304U, 113901376U, 114031552U, 114163264U,
114294592U, 114425536U, 114556864U, 114687424U, 114818624U, 114948544U,
115080512U, 115212224U, 115343296U, 115473472U, 115605184U, 115736128U,
115867072U, 115997248U, 116128576U, 116260288U, 116391488U, 116522944U,
116652992U, 116784704U, 116915648U, 117046208U, 117178304U, 117308608U,
117440192U, 117569728U, 117701824U, 117833024U, 117964096U, 118094656U,
118225984U, 118357312U, 118489024U, 118617536U, 118749632U, 118882112U,
119012416U, 119144384U, 119275328U, 119406016U, 119537344U, 119668672U,
119798464U, 119928896U, 120061376U, 120192832U, 120321728U, 120454336U,
120584512U, 120716608U, 120848192U, 120979136U, 121109056U, 121241408U,
121372352U, 121502912U, 121634752U, 121764416U, 121895744U, 122027072U,
122157632U, 122289088U, 122421184U, 122550592U, 122682944U, 122813888U,
122945344U, 123075776U, 123207488U, 123338048U, 123468736U, 123600704U,
123731264U, 123861952U, 123993664U, 124124608U, 124256192U, 124386368U,
124518208U, 124649024U, 124778048U, 124911296U, 125041088U, 125173696U,
125303744U, 125432896U, 125566912U, 125696576U, 125829056U, 125958592U,
126090304U, 126221248U, 126352832U, 126483776U, 126615232U, 126746432U,
126876608U, 127008704U, 127139392U, 127270336U, 127401152U, 127532224U,
127663552U, 127794752U, 127925696U, 128055232U, 128188096U, 128319424U,
128449856U, 128581312U, 128712256U, 128843584U, 128973632U, 129103808U,
129236288U, 129365696U, 129498944U, 129629888U, 129760832U, 129892288U,
130023104U, 130154048U, 130283968U, 130416448U, 130547008U, 130678336U,
130807616U, 130939456U, 131071552U, 131202112U, 131331776U, 131464384U,
131594048U, 131727296U, 131858368U, 131987392U, 132120256U, 132250816U,
132382528U, 132513728U, 132644672U, 132774976U, 132905792U, 133038016U,
133168832U, 133299392U, 133429312U, 133562048U, 133692992U, 133823296U,
133954624U, 134086336U, 134217152U, 134348608U, 134479808U, 134607296U,
134741056U, 134872384U, 135002944U, 135134144U, 135265472U, 135396544U,
135527872U, 135659072U, 135787712U, 135921472U, 136052416U, 136182848U,
136313792U, 136444864U, 136576448U, 136707904U, 136837952U, 136970048U,
137099584U, 137232064U, 137363392U, 137494208U, 137625536U, 137755712U,
137887424U, 138018368U, 138149824U, 138280256U, 138411584U, 138539584U,
138672832U, 138804928U, 138936128U, 139066688U, 139196864U, 139328704U,
139460032U, 139590208U, 139721024U, 139852864U, 139984576U, 140115776U,
140245696U, 140376512U, 140508352U, 140640064U, 140769856U, 140902336U,
141032768U, 141162688U, 141294016U, 141426496U, 141556544U, 141687488U,
141819584U, 141949888U, 142080448U, 142212544U, 142342336U, 142474432U,
142606144U, 142736192U, 142868288U, 142997824U, 143129408U, 143258944U,
143392448U, 143523136U, 143653696U, 143785024U, 143916992U, 144045632U,
144177856U, 144309184U, 144440768U, 144570688U, 144701888U, 144832448U,
144965056U, 145096384U, 145227584U, 145358656U, 145489856U, 145620928U,
145751488U, 145883072U, 146011456U, 146144704U, 146275264U, 146407232U,
146538176U, 146668736U, 146800448U, 146931392U, 147062336U, 147193664U,
147324224U, 147455936U, 147586624U, 147717056U, 147848768U, 147979456U,
148110784U, 148242368U, 148373312U, 148503232U, 148635584U, 148766144U,
148897088U, 149028416U, 149159488U, 149290688U, 149420224U, 149551552U,
149683136U, 149814976U, 149943616U, 150076352U, 150208064U, 150338624U,
150470464U, 150600256U, 150732224U, 150862784U, 150993088U, 151125952U,
151254976U, 151388096U, 151519168U, 151649728U, 151778752U, 151911104U,
152042944U, 152174144U, 152304704U, 152435648U, 152567488U, 152698816U,
152828992U, 152960576U, 153091648U, 153222976U, 153353792U, 153484096U,
153616192U, 153747008U, 153878336U, 154008256U, 154139968U, 154270912U,
154402624U, 154533824U, 154663616U, 154795712U, 154926272U, 155057984U,
155188928U, 155319872U, 155450816U, 155580608U, 155712064U, 155843392U,
155971136U, 156106688U, 156237376U, 156367424U, 156499264U, 156630976U,
156761536U, 156892352U, 157024064U, 157155008U, 157284416U, 157415872U,
157545536U, 157677248U, 157810496U, 157938112U, 158071744U, 158203328U,
158334656U, 158464832U, 158596288U, 158727616U, 158858048U, 158988992U,
159121216U, 159252416U, 159381568U, 159513152U, 159645632U, 159776192U,
159906496U, 160038464U, 160169536U, 160300352U, 160430656U, 160563008U,
160693952U, 160822208U, 160956352U, 161086784U, 161217344U, 161349184U,
161480512U, 161611456U, 161742272U, 161873216U, 162002752U, 162135872U,
162266432U, 162397888U, 162529216U, 162660032U, 162790976U, 162922048U,
163052096U, 163184576U, 163314752U, 163446592U, 163577408U, 163707968U,
163839296U, 163969984U, 164100928U, 164233024U, 164364224U, 164494912U,
164625856U, 164756672U, 164887616U, 165019072U, 165150016U, 165280064U,
165412672U, 165543104U, 165674944U, 165805888U, 165936832U, 166067648U,
166198336U, 166330048U, 166461248U, 166591552U, 166722496U, 166854208U,
166985408U, 167116736U, 167246656U, 167378368U, 167508416U, 167641024U,
167771584U, 167903168U, 168034112U, 168164032U, 168295744U, 168427456U,
168557632U, 168688448U, 168819136U, 168951616U, 169082176U, 169213504U,
169344832U, 169475648U, 169605952U, 169738048U, 169866304U, 169999552U,
170131264U, 170262464U, 170393536U, 170524352U, 170655424U, 170782016U,
170917696U, 171048896U, 171179072U, 171310784U, 171439936U, 171573184U,
171702976U, 171835072U, 171966272U, 172097216U, 172228288U, 172359232U,
172489664U, 172621376U, 172747712U, 172883264U, 173014208U, 173144512U,
173275072U, 173407424U, 173539136U, 173669696U, 173800768U, 173931712U,
174063424U, 174193472U, 174325696U, 174455744U, 174586816U, 174718912U,
174849728U, 174977728U, 175109696U, 175242688U, 175374272U, 175504832U,
175636288U, 175765696U, 175898432U, 176028992U, 176159936U, 176291264U,
176422592U, 176552512U, 176684864U, 176815424U, 176946496U, 177076544U,
177209152U, 177340096U, 177470528U, 177600704U, 177731648U, 177864256U,
177994816U, 178126528U, 178257472U, 178387648U, 178518464U, 178650176U,
178781888U, 178912064U, 179044288U, 179174848U, 179305024U, 179436736U,
179568448U, 179698496U, 179830208U, 179960512U, 180092608U, 180223808U,
180354752U, 180485696U, 180617152U, 180748096U, 180877504U, 181009984U,
181139264U, 181272512U, 181402688U, 181532608U, 181663168U, 181795136U,
181926592U, 182057536U, 182190016U, 182320192U, 182451904U, 182582336U,
182713792U, 182843072U, 182976064U, 183107264U, 183237056U, 183368384U,
183494848U, 183631424U, 183762752U, 183893824U, 184024768U, 184154816U,
184286656U, 184417984U, 184548928U, 184680128U, 184810816U, 184941248U,
185072704U, 185203904U, 185335616U, 185465408U, 185596352U, 185727296U,
185859904U, 185989696U, 186121664U, 186252992U, 186383552U, 186514112U,
186645952U, 186777152U, 186907328U, 187037504U, 187170112U, 187301824U,
187429184U, 187562048U, 187693504U, 187825472U, 187957184U, 188087104U,
188218304U, 188349376U, 188481344U, 188609728U, 188743616U, 188874304U,
189005248U, 189136448U, 189265088U, 189396544U, 189528128U, 189660992U,
189791936U, 189923264U, 190054208U, 190182848U, 190315072U, 190447424U,
190577984U, 190709312U, 190840768U, 190971328U, 191102656U, 191233472U,
191364032U, 191495872U, 191626816U, 191758016U, 191888192U, 192020288U,
192148928U, 192282176U, 192413504U, 192542528U, 192674752U, 192805952U,
192937792U, 193068608U, 193198912U, 193330496U, 193462208U, 193592384U,
193723456U, 193854272U, 193985984U, 194116672U, 194247232U, 194379712U,
194508352U, 194641856U, 194772544U, 194900672U, 195035072U, 195166016U,
195296704U, 195428032U, 195558592U, 195690304U, 195818176U, 195952576U,
196083392U, 196214336U, 196345792U, 196476736U, 196607552U, 196739008U,
196869952U, 197000768U, 197130688U, 197262784U, 197394368U, 197523904U,
197656384U, 197787584U, 197916608U, 198049472U, 198180544U, 198310208U,
198442432U, 198573632U, 198705088U, 198834368U, 198967232U, 199097792U,
199228352U, 199360192U, 199491392U, 199621696U, 199751744U, 199883968U,
200014016U, 200146624U, 200276672U, 200408128U, 200540096U, 200671168U,
200801984U, 200933312U, 201062464U, 201194944U, 201326144U, 201457472U,
201588544U, 201719744U, 201850816U, 201981632U, 202111552U, 202244032U,
202374464U, 202505152U, 202636352U, 202767808U, 202898368U, 203030336U,
203159872U, 203292608U, 203423296U, 203553472U, 203685824U, 203816896U,
203947712U, 204078272U, 204208192U, 204341056U, 204472256U, 204603328U,
204733888U, 204864448U, 204996544U, 205125568U, 205258304U, 205388864U,
205517632U, 205650112U, 205782208U, 205913536U, 206044736U, 206176192U,
206307008U, 206434496U, 206569024U, 206700224U, 206831168U, 206961856U,
207093056U, 207223616U, 207355328U, 207486784U, 207616832U, 207749056U,
207879104U, 208010048U, 208141888U, 208273216U, 208404032U, 208534336U,
208666048U, 208796864U, 208927424U, 209059264U, 209189824U, 209321792U,
209451584U, 209582656U, 209715136U, 209845568U, 209976896U, 210106432U,
210239296U, 210370112U, 210501568U, 210630976U, 210763712U, 210894272U,
211024832U, 211156672U, 211287616U, 211418176U, 211549376U, 211679296U,
211812032U, 211942592U, 212074432U, 212204864U, 212334016U, 212467648U,
212597824U, 212727616U, 212860352U, 212991424U, 213120832U, 213253952U,
213385024U, 213515584U, 213645632U, 213777728U, 213909184U, 214040128U,
214170688U, 214302656U, 214433728U, 214564544U, 214695232U, 214826048U,
214956992U, 215089088U, 215219776U, 215350592U, 215482304U, 215613248U,
215743552U, 215874752U, 216005312U, 216137024U, 216267328U, 216399296U,
216530752U, 216661696U, 216790592U, 216923968U, 217054528U, 217183168U,
217316672U, 217448128U, 217579072U, 217709504U, 217838912U, 217972672U,
218102848U, 218233024U, 218364736U, 218496832U, 218627776U, 218759104U,
218888896U, 219021248U, 219151936U, 219281728U, 219413056U, 219545024U,
219675968U, 219807296U, 219938624U, 220069312U, 220200128U, 220331456U,
220461632U, 220592704U, 220725184U, 220855744U, 220987072U, 221117888U,
221249216U, 221378368U, 221510336U, 221642048U, 221772736U, 221904832U,
222031808U, 222166976U, 222297536U, 222428992U, 222559936U, 222690368U,
222820672U, 222953152U, 223083968U, 223213376U, 223345984U, 223476928U,
223608512U, 223738688U, 223869376U, 224001472U, 224132672U, 224262848U,
224394944U, 224524864U, 224657344U, 224788288U, 224919488U, 225050432U,
225181504U, 225312704U, 225443776U, 225574592U, 225704768U, 225834176U,
225966784U, 226097216U, 226229824U, 226360384U, 226491712U, 226623424U,
226754368U, 226885312U, 227015104U, 227147456U, 227278528U, 227409472U,
227539904U, 227669696U, 227802944U, 227932352U, 228065216U, 228196288U,
228326464U, 228457792U, 228588736U, 228720064U, 228850112U, 228981056U,
229113152U, 229243328U, 229375936U, 229505344U, 229636928U, 229769152U,
229894976U, 230030272U, 230162368U, 230292416U, 230424512U, 230553152U,
230684864U, 230816704U, 230948416U, 231079616U, 231210944U, 231342016U,
231472448U, 231603776U, 231733952U, 231866176U, 231996736U, 232127296U,
232259392U, 232388672U, 232521664U, 232652608U, 232782272U, 232914496U,
233043904U, 233175616U, 233306816U, 233438528U, 233569984U, 233699776U,
233830592U, 233962688U, 234092224U, 234221888U, 234353984U, 234485312U,
234618304U, 234749888U, 234880832U, 235011776U, 235142464U, 235274048U,
235403456U, 235535936U, 235667392U, 235797568U, 235928768U, 236057152U,
236190272U, 236322752U, 236453312U, 236583616U, 236715712U, 236846528U,
236976448U, 237108544U, 237239104U, 237371072U, 237501632U, 237630784U,
237764416U, 237895232U, 238026688U, 238157632U, 238286912U, 238419392U,
238548032U, 238681024U, 238812608U, 238941632U, 239075008U, 239206336U,
239335232U, 239466944U, 239599168U, 239730496U, 239861312U, 239992384U,
240122816U, 240254656U, 240385856U, 240516928U, 240647872U, 240779072U,
240909632U, 241040704U, 241171904U, 241302848U, 241433408U, 241565248U,
241696192U, 241825984U, 241958848U, 242088256U, 242220224U, 242352064U,
242481856U, 242611648U, 242744896U, 242876224U, 243005632U, 243138496U,
243268672U, 243400384U, 243531712U, 243662656U, 243793856U, 243924544U,
244054592U, 244187072U, 244316608U, 244448704U, 244580032U, 244710976U,
244841536U, 244972864U, 245104448U, 245233984U, 245365312U, 245497792U,
245628736U, 245759936U, 245889856U, 246021056U, 246152512U, 246284224U,
246415168U, 246545344U, 246675904U, 246808384U, 246939584U, 247070144U,
247199552U, 247331648U, 247463872U, 247593536U, 247726016U, 247857088U,
247987648U, 248116928U, 248249536U, 248380736U, 248512064U, 248643008U,
248773312U, 248901056U, 249036608U, 249167552U, 249298624U, 249429184U,
249560512U, 249692096U, 249822784U, 249954112U, 250085312U, 250215488U,
250345792U, 250478528U, 250608704U, 250739264U, 250870976U, 251002816U,
251133632U, 251263552U, 251395136U, 251523904U, 251657792U, 251789248U,
251919424U, 252051392U, 252182464U, 252313408U, 252444224U, 252575552U,
252706624U, 252836032U, 252968512U, 253099712U, 253227584U, 253361728U,
253493056U, 253623488U, 253754432U, 253885504U, 254017216U, 254148032U,
254279488U, 254410432U, 254541376U, 254672576U, 254803264U, 254933824U,
255065792U, 255196736U, 255326528U, 255458752U, 255589952U, 255721408U,
255851072U, 255983296U, 256114624U, 256244416U, 256374208U, 256507712U,
256636096U, 256768832U, 256900544U, 257031616U, 257162176U, 257294272U,
257424448U, 257555776U, 257686976U, 257818432U, 257949632U, 258079552U,
258211136U, 258342464U, 258473408U, 258603712U, 258734656U, 258867008U,
258996544U, 259127744U, 259260224U, 259391296U, 259522112U, 259651904U,
259784384U, 259915328U, 260045888U, 260175424U, 260308544U, 260438336U,
260570944U, 260700992U, 260832448U, 260963776U, 261092672U, 261226304U,
261356864U, 261487936U, 261619648U, 261750592U, 261879872U, 262011968U,
262143424U, 262274752U, 262404416U, 262537024U, 262667968U, 262799296U,
262928704U, 263061184U, 263191744U, 263322944U, 263454656U, 263585216U,
263716672U, 263847872U, 263978944U, 264108608U, 264241088U, 264371648U,
264501184U, 264632768U, 264764096U, 264895936U, 265024576U, 265158464U,
265287488U, 265418432U, 265550528U, 265681216U, 265813312U, 265943488U,
266075968U, 266206144U, 266337728U, 266468032U, 266600384U, 266731072U,
266862272U, 266993344U, 267124288U, 267255616U, 267386432U, 267516992U,
267648704U, 267777728U, 267910592U, 268040512U, 268172096U, 268302784U,
268435264U, 268566208U, 268696256U, 268828096U, 268959296U, 269090368U,
269221312U, 269352256U, 269482688U, 269614784U, 269745856U, 269876416U,
270007616U, 270139328U, 270270272U, 270401216U, 270531904U, 270663616U,
270791744U, 270924736U, 271056832U, 271186112U, 271317184U, 271449536U,
271580992U, 271711936U, 271843136U, 271973056U, 272105408U, 272236352U,
272367296U, 272498368U, 272629568U, 272759488U, 272891456U, 273022784U,
273153856U, 273284672U, 273415616U, 273547072U, 273677632U, 273808448U,
273937088U, 274071488U, 274200896U, 274332992U, 274463296U, 274595392U,
274726208U, 274857536U, 274988992U, 275118656U, 275250496U, 275382208U,
275513024U, 275643968U, 275775296U, 275906368U, 276037184U, 276167872U,
276297664U, 276429376U, 276560576U, 276692672U, 276822976U, 276955072U,
277085632U, 277216832U, 277347008U, 277478848U, 277609664U, 277740992U,
277868608U, 278002624U, 278134336U, 278265536U, 278395328U, 278526784U,
278657728U, 278789824U, 278921152U, 279052096U, 279182912U, 279313088U,
279443776U, 279576256U, 279706048U, 279838528U, 279969728U, 280099648U,
280230976U, 280361408U, 280493632U, 280622528U, 280755392U, 280887104U,
281018176U, 281147968U, 281278912U, 281411392U, 281542592U, 281673152U,
281803712U, 281935552U, 282066496U, 282197312U, 282329024U, 282458816U,
282590272U, 282720832U, 282853184U, 282983744U, 283115072U, 283246144U,
283377344U, 283508416U, 283639744U, 283770304U, 283901504U, 284032576U,
284163136U, 284294848U, 284426176U, 284556992U, 284687296U, 284819264U,
284950208U, 285081536U
};
#ifdef __cplusplus
}
#endif

View File

@ -0,0 +1,75 @@
#pragma once
#include <stdint.h>
#include "compiler.h"
#if defined(__MINGW32__) || defined(_WIN32)
# define LITTLE_ENDIAN 1234
# define BYTE_ORDER LITTLE_ENDIAN
#elif defined(__FreeBSD__) || defined(__DragonFly__) || defined(__NetBSD__)
# include <sys/endian.h>
#elif defined(__OpenBSD__) || defined(__SVR4)
# include <sys/types.h>
#elif defined(__APPLE__)
# include <machine/endian.h>
#elif defined( BSD ) && (BSD >= 199103)
# include <machine/endian.h>
#elif defined( __QNXNTO__ ) && defined( __LITTLEENDIAN__ )
# define LITTLE_ENDIAN 1234
# define BYTE_ORDER LITTLE_ENDIAN
#elif defined( __QNXNTO__ ) && defined( __BIGENDIAN__ )
# define BIG_ENDIAN 1234
# define BYTE_ORDER BIG_ENDIAN
#else
# include <endian.h>
#endif
#if defined(_WIN32)
#include <stdlib.h>
#define ethash_swap_u32(input_) _byteswap_ulong(input_)
#define ethash_swap_u64(input_) _byteswap_uint64(input_)
#elif defined(__APPLE__)
#include <libkern/OSByteOrder.h>
#define ethash_swap_u32(input_) OSSwapInt32(input_)
#define ethash_swap_u64(input_) OSSwapInt64(input_)
#elif defined(__FreeBSD__) || defined(__DragonFly__) || defined(__NetBSD__)
#define ethash_swap_u32(input_) bswap32(input_)
#define ethash_swap_u64(input_) bswap64(input_)
#else // posix
#include <byteswap.h>
#define ethash_swap_u32(input_) __bswap_32(input_)
#define ethash_swap_u64(input_) __bswap_64(input_)
#endif
#if LITTLE_ENDIAN == BYTE_ORDER
#define fix_endian32(dst_ ,src_) dst_ = src_
#define fix_endian32_same(val_)
#define fix_endian64(dst_, src_) dst_ = src_
#define fix_endian64_same(val_)
#define fix_endian_arr32(arr_, size_)
#define fix_endian_arr64(arr_, size_)
#elif BIG_ENDIAN == BYTE_ORDER
#define fix_endian32(dst_, src_) dst_ = ethash_swap_u32(src_)
#define fix_endian32_same(val_) val_ = ethash_swap_u32(val_)
#define fix_endian64(dst_, src_) dst_ = ethash_swap_u64(src_
#define fix_endian64_same(val_) val_ = ethash_swap_u64(val_)
#define fix_endian_arr32(arr_, size_) \
do { \
for (unsigned i_ = 0; i_ < (size_), ++i_) { \
arr_[i_] = ethash_swap_u32(arr_[i_]); \
} \
while (0)
#define fix_endian_arr64(arr_, size_) \
do { \
for (unsigned i_ = 0; i_ < (size_), ++i_) { \
arr_[i_] = ethash_swap_u64(arr_[i_]); \
} \
while (0) \
#else
# error "endian not supported"
#endif // BYTE_ORDER

View File

@ -0,0 +1,147 @@
/*
This file is part of ethash.
ethash is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ethash is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with ethash. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file ethash.h
* @date 2015
*/
#pragma once
#include <stdint.h>
#include <stdbool.h>
#include <string.h>
#include <stddef.h>
#include "compiler.h"
#define ETHASH_REVISION 23
#define ETHASH_DATASET_BYTES_INIT 1073741824U // 2**30
#define ETHASH_DATASET_BYTES_GROWTH 8388608U // 2**23
#define ETHASH_CACHE_BYTES_INIT 1073741824U // 2**24
#define ETHASH_CACHE_BYTES_GROWTH 131072U // 2**17
#define ETHASH_EPOCH_LENGTH 30000U
#define ETHASH_MIX_BYTES 128
#define ETHASH_HASH_BYTES 64
#define ETHASH_DATASET_PARENTS 256
#define ETHASH_CACHE_ROUNDS 3
#define ETHASH_ACCESSES 64
#define ETHASH_DAG_MAGIC_NUM_SIZE 8
#define ETHASH_DAG_MAGIC_NUM 0xFEE1DEADBADDCAFE
#ifdef __cplusplus
extern "C" {
#endif
/// Type of a seedhash/blockhash e.t.c.
typedef struct ethash_h256 { uint8_t b[32]; } ethash_h256_t;
// convenience macro to statically initialize an h256_t
// usage:
// ethash_h256_t a = ethash_h256_static_init(1, 2, 3, ... )
// have to provide all 32 values. If you don't provide all the rest
// will simply be unitialized (not guranteed to be 0)
#define ethash_h256_static_init(...) \
{ {__VA_ARGS__} }
struct ethash_light;
typedef struct ethash_light* ethash_light_t;
struct ethash_full;
typedef struct ethash_full* ethash_full_t;
typedef int(*ethash_callback_t)(unsigned);
typedef struct ethash_return_value {
ethash_h256_t result;
ethash_h256_t mix_hash;
bool success;
} ethash_return_value_t;
/**
* Allocate and initialize a new ethash_light handler
*
* @param block_number The block number for which to create the handler
* @return Newly allocated ethash_light handler or NULL in case of
* ERRNOMEM or invalid parameters used for @ref ethash_compute_cache_nodes()
*/
ethash_light_t ethash_light_new(uint64_t block_number);
/**
* Frees a previously allocated ethash_light handler
* @param light The light handler to free
*/
void ethash_light_delete(ethash_light_t light);
/**
* Calculate the light client data
*
* @param light The light client handler
* @param header_hash The header hash to pack into the mix
* @param nonce The nonce to pack into the mix
* @return an object of ethash_return_value_t holding the return values
*/
ethash_return_value_t ethash_light_compute(
ethash_light_t light,
ethash_h256_t const header_hash,
uint64_t nonce
);
/**
* Allocate and initialize a new ethash_full handler
*
* @param light The light handler containing the cache.
* @param callback A callback function with signature of @ref ethash_callback_t
* It accepts an unsigned with which a progress of DAG calculation
* can be displayed. If all goes well the callback should return 0.
* If a non-zero value is returned then DAG generation will stop.
* Be advised. A progress value of 100 means that DAG creation is
* almost complete and that this function will soon return succesfully.
* It does not mean that the function has already had a succesfull return.
* @return Newly allocated ethash_full handler or NULL in case of
* ERRNOMEM or invalid parameters used for @ref ethash_compute_full_data()
*/
ethash_full_t ethash_full_new(ethash_light_t light, ethash_callback_t callback);
/**
* Frees a previously allocated ethash_full handler
* @param full The light handler to free
*/
void ethash_full_delete(ethash_full_t full);
/**
* Calculate the full client data
*
* @param full The full client handler
* @param header_hash The header hash to pack into the mix
* @param nonce The nonce to pack into the mix
* @return An object of ethash_return_value to hold the return value
*/
ethash_return_value_t ethash_full_compute(
ethash_full_t full,
ethash_h256_t const header_hash,
uint64_t nonce
);
/**
* Get a pointer to the full DAG data
*/
void const* ethash_full_dag(ethash_full_t full);
/**
* Get the size of the DAG data
*/
uint64_t ethash_full_dag_size(ethash_full_t full);
/**
* Calculate the seedhash for a given block number
*/
ethash_h256_t ethash_get_seedhash(uint64_t block_number);
#ifdef __cplusplus
}
#endif

View File

@ -0,0 +1,39 @@
/*
This file is part of cpp-ethereum.
cpp-ethereum is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
cpp-ethereum is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file fnv.h
* @author Matthew Wampler-Doty <negacthulhu@gmail.com>
* @date 2015
*/
#pragma once
#include <stdint.h>
#include "compiler.h"
#ifdef __cplusplus
extern "C" {
#endif
#define FNV_PRIME 0x01000193
static inline uint32_t fnv_hash(uint32_t const x, uint32_t const y)
{
return x * FNV_PRIME ^ y;
}
#ifdef __cplusplus
}
#endif

View File

@ -0,0 +1,507 @@
/*
This file is part of ethash.
ethash is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ethash is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file internal.c
* @author Tim Hughes <tim@twistedfury.com>
* @author Matthew Wampler-Doty
* @date 2015
*/
#include <assert.h>
#include <inttypes.h>
#include <stddef.h>
#include <errno.h>
#include <math.h>
#include "mmap.h"
#include "ethash.h"
#include "fnv.h"
#include "endian.h"
#include "internal.h"
#include "data_sizes.h"
#include "io.h"
#ifdef WITH_CRYPTOPP
#include "sha3_cryptopp.h"
#else
#include "sha3.h"
#endif // WITH_CRYPTOPP
uint64_t ethash_get_datasize(uint64_t const block_number)
{
assert(block_number / ETHASH_EPOCH_LENGTH < 2048);
return dag_sizes[block_number / ETHASH_EPOCH_LENGTH];
}
uint64_t ethash_get_cachesize(uint64_t const block_number)
{
assert(block_number / ETHASH_EPOCH_LENGTH < 2048);
return cache_sizes[block_number / ETHASH_EPOCH_LENGTH];
}
// Follows Sergio's "STRICT MEMORY HARD HASHING FUNCTIONS" (2014)
// https://bitslog.files.wordpress.com/2013/12/memohash-v0-3.pdf
// SeqMemoHash(s, R, N)
bool static ethash_compute_cache_nodes(
node* const nodes,
uint64_t cache_size,
ethash_h256_t const* seed
)
{
if (cache_size % sizeof(node) != 0) {
return false;
}
uint32_t const num_nodes = (uint32_t) (cache_size / sizeof(node));
SHA3_512(nodes[0].bytes, (uint8_t*)seed, 32);
for (uint32_t i = 1; i != num_nodes; ++i) {
SHA3_512(nodes[i].bytes, nodes[i - 1].bytes, 64);
}
for (uint32_t j = 0; j != ETHASH_CACHE_ROUNDS; j++) {
for (uint32_t i = 0; i != num_nodes; i++) {
uint32_t const idx = nodes[i].words[0] % num_nodes;
node data;
data = nodes[(num_nodes - 1 + i) % num_nodes];
for (uint32_t w = 0; w != NODE_WORDS; ++w) {
data.words[w] ^= nodes[idx].words[w];
}
SHA3_512(nodes[i].bytes, data.bytes, sizeof(data));
}
}
// now perform endian conversion
fix_endian_arr32(nodes->words, num_nodes * NODE_WORDS);
return true;
}
void ethash_calculate_dag_item(
node* const ret,
uint32_t node_index,
ethash_light_t const light
)
{
uint32_t num_parent_nodes = (uint32_t) (light->cache_size / sizeof(node));
node const* cache_nodes = (node const *) light->cache;
node const* init = &cache_nodes[node_index % num_parent_nodes];
memcpy(ret, init, sizeof(node));
ret->words[0] ^= node_index;
SHA3_512(ret->bytes, ret->bytes, sizeof(node));
#if defined(_M_X64) && ENABLE_SSE
__m128i const fnv_prime = _mm_set1_epi32(FNV_PRIME);
__m128i xmm0 = ret->xmm[0];
__m128i xmm1 = ret->xmm[1];
__m128i xmm2 = ret->xmm[2];
__m128i xmm3 = ret->xmm[3];
#endif
for (uint32_t i = 0; i != ETHASH_DATASET_PARENTS; ++i) {
uint32_t parent_index = fnv_hash(node_index ^ i, ret->words[i % NODE_WORDS]) % num_parent_nodes;
node const *parent = &cache_nodes[parent_index];
#if defined(_M_X64) && ENABLE_SSE
{
xmm0 = _mm_mullo_epi32(xmm0, fnv_prime);
xmm1 = _mm_mullo_epi32(xmm1, fnv_prime);
xmm2 = _mm_mullo_epi32(xmm2, fnv_prime);
xmm3 = _mm_mullo_epi32(xmm3, fnv_prime);
xmm0 = _mm_xor_si128(xmm0, parent->xmm[0]);
xmm1 = _mm_xor_si128(xmm1, parent->xmm[1]);
xmm2 = _mm_xor_si128(xmm2, parent->xmm[2]);
xmm3 = _mm_xor_si128(xmm3, parent->xmm[3]);
// have to write to ret as values are used to compute index
ret->xmm[0] = xmm0;
ret->xmm[1] = xmm1;
ret->xmm[2] = xmm2;
ret->xmm[3] = xmm3;
}
#else
{
for (unsigned w = 0; w != NODE_WORDS; ++w) {
ret->words[w] = fnv_hash(ret->words[w], parent->words[w]);
}
}
#endif
}
SHA3_512(ret->bytes, ret->bytes, sizeof(node));
}
bool ethash_compute_full_data(
void* mem,
uint64_t full_size,
ethash_light_t const light,
ethash_callback_t callback
)
{
if (full_size % (sizeof(uint32_t) * MIX_WORDS) != 0 ||
(full_size % sizeof(node)) != 0) {
return false;
}
uint32_t const max_n = (uint32_t)(full_size / sizeof(node));
node* full_nodes = mem;
double const progress_change = 1.0f / max_n;
double progress = 0.0f;
// now compute full nodes
for (uint32_t n = 0; n != max_n; ++n) {
if (callback &&
n % (max_n / 100) == 0 &&
callback((unsigned int)(ceil(progress * 100.0f))) != 0) {
return false;
}
progress += progress_change;
ethash_calculate_dag_item(&(full_nodes[n]), n, light);
}
return true;
}
static bool ethash_hash(
ethash_return_value_t* ret,
node const* full_nodes,
ethash_light_t const light,
uint64_t full_size,
ethash_h256_t const header_hash,
uint64_t const nonce
)
{
if (full_size % MIX_WORDS != 0) {
return false;
}
// pack hash and nonce together into first 40 bytes of s_mix
assert(sizeof(node) * 8 == 512);
node s_mix[MIX_NODES + 1];
memcpy(s_mix[0].bytes, &header_hash, 32);
fix_endian64(s_mix[0].double_words[4], nonce);
// compute sha3-512 hash and replicate across mix
SHA3_512(s_mix->bytes, s_mix->bytes, 40);
fix_endian_arr32(s_mix[0].words, 16);
node* const mix = s_mix + 1;
for (uint32_t w = 0; w != MIX_WORDS; ++w) {
mix->words[w] = s_mix[0].words[w % NODE_WORDS];
}
unsigned const page_size = sizeof(uint32_t) * MIX_WORDS;
unsigned const num_full_pages = (unsigned) (full_size / page_size);
for (unsigned i = 0; i != ETHASH_ACCESSES; ++i) {
uint32_t const index = fnv_hash(s_mix->words[0] ^ i, mix->words[i % MIX_WORDS]) % num_full_pages;
for (unsigned n = 0; n != MIX_NODES; ++n) {
node const* dag_node;
if (full_nodes) {
dag_node = &full_nodes[MIX_NODES * index + n];
} else {
node tmp_node;
ethash_calculate_dag_item(&tmp_node, index * MIX_NODES + n, light);
dag_node = &tmp_node;
}
#if defined(_M_X64) && ENABLE_SSE
{
__m128i fnv_prime = _mm_set1_epi32(FNV_PRIME);
__m128i xmm0 = _mm_mullo_epi32(fnv_prime, mix[n].xmm[0]);
__m128i xmm1 = _mm_mullo_epi32(fnv_prime, mix[n].xmm[1]);
__m128i xmm2 = _mm_mullo_epi32(fnv_prime, mix[n].xmm[2]);
__m128i xmm3 = _mm_mullo_epi32(fnv_prime, mix[n].xmm[3]);
mix[n].xmm[0] = _mm_xor_si128(xmm0, dag_node->xmm[0]);
mix[n].xmm[1] = _mm_xor_si128(xmm1, dag_node->xmm[1]);
mix[n].xmm[2] = _mm_xor_si128(xmm2, dag_node->xmm[2]);
mix[n].xmm[3] = _mm_xor_si128(xmm3, dag_node->xmm[3]);
}
#else
{
for (unsigned w = 0; w != NODE_WORDS; ++w) {
mix[n].words[w] = fnv_hash(mix[n].words[w], dag_node->words[w]);
}
}
#endif
}
}
// compress mix
for (uint32_t w = 0; w != MIX_WORDS; w += 4) {
uint32_t reduction = mix->words[w + 0];
reduction = reduction * FNV_PRIME ^ mix->words[w + 1];
reduction = reduction * FNV_PRIME ^ mix->words[w + 2];
reduction = reduction * FNV_PRIME ^ mix->words[w + 3];
mix->words[w / 4] = reduction;
}
fix_endian_arr32(mix->words, MIX_WORDS / 4);
memcpy(&ret->mix_hash, mix->bytes, 32);
// final Keccak hash
SHA3_256(&ret->result, s_mix->bytes, 64 + 32); // Keccak-256(s + compressed_mix)
return true;
}
void ethash_quick_hash(
ethash_h256_t* return_hash,
ethash_h256_t const* header_hash,
uint64_t const nonce,
ethash_h256_t const* mix_hash
)
{
uint8_t buf[64 + 32];
memcpy(buf, header_hash, 32);
fix_endian64_same(nonce);
memcpy(&(buf[32]), &nonce, 8);
SHA3_512(buf, buf, 40);
memcpy(&(buf[64]), mix_hash, 32);
SHA3_256(return_hash, buf, 64 + 32);
}
ethash_h256_t ethash_get_seedhash(uint64_t block_number)
{
ethash_h256_t ret;
ethash_h256_reset(&ret);
uint64_t const epochs = block_number / ETHASH_EPOCH_LENGTH;
for (uint32_t i = 0; i < epochs; ++i)
SHA3_256(&ret, (uint8_t*)&ret, 32);
return ret;
}
bool ethash_quick_check_difficulty(
ethash_h256_t const* header_hash,
uint64_t const nonce,
ethash_h256_t const* mix_hash,
ethash_h256_t const* boundary
)
{
ethash_h256_t return_hash;
ethash_quick_hash(&return_hash, header_hash, nonce, mix_hash);
return ethash_check_difficulty(&return_hash, boundary);
}
ethash_light_t ethash_light_new_internal(uint64_t cache_size, ethash_h256_t const* seed)
{
struct ethash_light *ret;
ret = calloc(sizeof(*ret), 1);
if (!ret) {
return NULL;
}
ret->cache = malloc((size_t)cache_size);
if (!ret->cache) {
goto fail_free_light;
}
node* nodes = (node*)ret->cache;
if (!ethash_compute_cache_nodes(nodes, cache_size, seed)) {
goto fail_free_cache_mem;
}
ret->cache_size = cache_size;
return ret;
fail_free_cache_mem:
free(ret->cache);
fail_free_light:
free(ret);
return NULL;
}
ethash_light_t ethash_light_new(uint64_t block_number)
{
ethash_h256_t seedhash = ethash_get_seedhash(block_number);
ethash_light_t ret;
ret = ethash_light_new_internal(ethash_get_cachesize(block_number), &seedhash);
ret->block_number = block_number;
return ret;
}
void ethash_light_delete(ethash_light_t light)
{
if (light->cache) {
free(light->cache);
}
free(light);
}
ethash_return_value_t ethash_light_compute_internal(
ethash_light_t light,
uint64_t full_size,
ethash_h256_t const header_hash,
uint64_t nonce
)
{
ethash_return_value_t ret;
ret.success = true;
if (!ethash_hash(&ret, NULL, light, full_size, header_hash, nonce)) {
ret.success = false;
}
return ret;
}
ethash_return_value_t ethash_light_compute(
ethash_light_t light,
ethash_h256_t const header_hash,
uint64_t nonce
)
{
uint64_t full_size = ethash_get_datasize(light->block_number);
return ethash_light_compute_internal(light, full_size, header_hash, nonce);
}
static bool ethash_mmap(struct ethash_full* ret, FILE* f)
{
int fd;
char* mmapped_data;
errno = 0;
ret->file = f;
if ((fd = ethash_fileno(ret->file)) == -1) {
return false;
}
mmapped_data= mmap(
NULL,
(size_t)ret->file_size + ETHASH_DAG_MAGIC_NUM_SIZE,
PROT_READ | PROT_WRITE,
MAP_SHARED,
fd,
0
);
if (mmapped_data == MAP_FAILED) {
return false;
}
ret->data = (node*)(mmapped_data + ETHASH_DAG_MAGIC_NUM_SIZE);
return true;
}
ethash_full_t ethash_full_new_internal(
char const* dirname,
ethash_h256_t const seed_hash,
uint64_t full_size,
ethash_light_t const light,
ethash_callback_t callback
)
{
struct ethash_full* ret;
FILE *f = NULL;
ret = calloc(sizeof(*ret), 1);
if (!ret) {
return NULL;
}
ret->file_size = (size_t)full_size;
switch (ethash_io_prepare(dirname, seed_hash, &f, (size_t)full_size, false)) {
case ETHASH_IO_FAIL:
// ethash_io_prepare will do all ETHASH_CRITICAL() logging in fail case
goto fail_free_full;
case ETHASH_IO_MEMO_MATCH:
if (!ethash_mmap(ret, f)) {
ETHASH_CRITICAL("mmap failure()");
goto fail_close_file;
}
return ret;
case ETHASH_IO_MEMO_SIZE_MISMATCH:
// if a DAG of same filename but unexpected size is found, silently force new file creation
if (ethash_io_prepare(dirname, seed_hash, &f, (size_t)full_size, true) != ETHASH_IO_MEMO_MISMATCH) {
ETHASH_CRITICAL("Could not recreate DAG file after finding existing DAG with unexpected size.");
goto fail_free_full;
}
// fallthrough to the mismatch case here, DO NOT go through match
case ETHASH_IO_MEMO_MISMATCH:
if (!ethash_mmap(ret, f)) {
ETHASH_CRITICAL("mmap failure()");
goto fail_close_file;
}
break;
}
if (!ethash_compute_full_data(ret->data, full_size, light, callback)) {
ETHASH_CRITICAL("Failure at computing DAG data.");
goto fail_free_full_data;
}
// after the DAG has been filled then we finalize it by writting the magic number at the beginning
if (fseek(f, 0, SEEK_SET) != 0) {
ETHASH_CRITICAL("Could not seek to DAG file start to write magic number.");
goto fail_free_full_data;
}
uint64_t const magic_num = ETHASH_DAG_MAGIC_NUM;
if (fwrite(&magic_num, ETHASH_DAG_MAGIC_NUM_SIZE, 1, f) != 1) {
ETHASH_CRITICAL("Could not write magic number to DAG's beginning.");
goto fail_free_full_data;
}
if (fflush(f) != 0) {// make sure the magic number IS there
ETHASH_CRITICAL("Could not flush memory mapped data to DAG file. Insufficient space?");
goto fail_free_full_data;
}
return ret;
fail_free_full_data:
// could check that munmap(..) == 0 but even if it did not can't really do anything here
munmap(ret->data, (size_t)full_size);
fail_close_file:
fclose(ret->file);
fail_free_full:
free(ret);
return NULL;
}
ethash_full_t ethash_full_new(ethash_light_t light, ethash_callback_t callback)
{
char strbuf[256];
if (!ethash_get_default_dirname(strbuf, 256)) {
return NULL;
}
uint64_t full_size = ethash_get_datasize(light->block_number);
ethash_h256_t seedhash = ethash_get_seedhash(light->block_number);
return ethash_full_new_internal(strbuf, seedhash, full_size, light, callback);
}
void ethash_full_delete(ethash_full_t full)
{
// could check that munmap(..) == 0 but even if it did not can't really do anything here
munmap(full->data, (size_t)full->file_size);
if (full->file) {
fclose(full->file);
}
free(full);
}
ethash_return_value_t ethash_full_compute(
ethash_full_t full,
ethash_h256_t const header_hash,
uint64_t nonce
)
{
ethash_return_value_t ret;
ret.success = true;
if (!ethash_hash(
&ret,
(node const*)full->data,
NULL,
full->file_size,
header_hash,
nonce)) {
ret.success = false;
}
return ret;
}
void const* ethash_full_dag(ethash_full_t full)
{
return full->data;
}
uint64_t ethash_full_dag_size(ethash_full_t full)
{
return full->file_size;
}

View File

@ -0,0 +1,179 @@
#pragma once
#include "compiler.h"
#include "endian.h"
#include "ethash.h"
#include <stdio.h>
#define ENABLE_SSE 0
#if defined(_M_X64) && ENABLE_SSE
#include <smmintrin.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
// compile time settings
#define NODE_WORDS (64/4)
#define MIX_WORDS (ETHASH_MIX_BYTES/4)
#define MIX_NODES (MIX_WORDS / NODE_WORDS)
#include <stdint.h>
typedef union node {
uint8_t bytes[NODE_WORDS * 4];
uint32_t words[NODE_WORDS];
uint64_t double_words[NODE_WORDS / 2];
#if defined(_M_X64) && ENABLE_SSE
__m128i xmm[NODE_WORDS/4];
#endif
} node;
static inline uint8_t ethash_h256_get(ethash_h256_t const* hash, unsigned int i)
{
return hash->b[i];
}
static inline void ethash_h256_set(ethash_h256_t* hash, unsigned int i, uint8_t v)
{
hash->b[i] = v;
}
static inline void ethash_h256_reset(ethash_h256_t* hash)
{
memset(hash, 0, 32);
}
// Returns if hash is less than or equal to boundary (2^256/difficulty)
static inline bool ethash_check_difficulty(
ethash_h256_t const* hash,
ethash_h256_t const* boundary
)
{
// Boundary is big endian
for (int i = 0; i < 32; i++) {
if (ethash_h256_get(hash, i) == ethash_h256_get(boundary, i)) {
continue;
}
return ethash_h256_get(hash, i) < ethash_h256_get(boundary, i);
}
return true;
}
/**
* Difficulty quick check for POW preverification
*
* @param header_hash The hash of the header
* @param nonce The block's nonce
* @param mix_hash The mix digest hash
* @param boundary The boundary is defined as (2^256 / difficulty)
* @return true for succesful pre-verification and false otherwise
*/
bool ethash_quick_check_difficulty(
ethash_h256_t const* header_hash,
uint64_t const nonce,
ethash_h256_t const* mix_hash,
ethash_h256_t const* boundary
);
struct ethash_light {
void* cache;
uint64_t cache_size;
uint64_t block_number;
};
/**
* Allocate and initialize a new ethash_light handler. Internal version
*
* @param cache_size The size of the cache in bytes
* @param seed Block seedhash to be used during the computation of the
* cache nodes
* @return Newly allocated ethash_light handler or NULL in case of
* ERRNOMEM or invalid parameters used for @ref ethash_compute_cache_nodes()
*/
ethash_light_t ethash_light_new_internal(uint64_t cache_size, ethash_h256_t const* seed);
/**
* Calculate the light client data. Internal version.
*
* @param light The light client handler
* @param full_size The size of the full data in bytes.
* @param header_hash The header hash to pack into the mix
* @param nonce The nonce to pack into the mix
* @return The resulting hash.
*/
ethash_return_value_t ethash_light_compute_internal(
ethash_light_t light,
uint64_t full_size,
ethash_h256_t const header_hash,
uint64_t nonce
);
struct ethash_full {
FILE* file;
uint64_t file_size;
node* data;
};
/**
* Allocate and initialize a new ethash_full handler. Internal version.
*
* @param dirname The directory in which to put the DAG file.
* @param seedhash The seed hash of the block. Used in the DAG file naming.
* @param full_size The size of the full data in bytes.
* @param cache A cache object to use that was allocated with @ref ethash_cache_new().
* Iff this function succeeds the ethash_full_t will take memory
* memory ownership of the cache and free it at deletion. If
* not then the user still has to handle freeing of the cache himself.
* @param callback A callback function with signature of @ref ethash_callback_t
* It accepts an unsigned with which a progress of DAG calculation
* can be displayed. If all goes well the callback should return 0.
* If a non-zero value is returned then DAG generation will stop.
* @return Newly allocated ethash_full handler or NULL in case of
* ERRNOMEM or invalid parameters used for @ref ethash_compute_full_data()
*/
ethash_full_t ethash_full_new_internal(
char const* dirname,
ethash_h256_t const seed_hash,
uint64_t full_size,
ethash_light_t const light,
ethash_callback_t callback
);
void ethash_calculate_dag_item(
node* const ret,
uint32_t node_index,
ethash_light_t const cache
);
void ethash_quick_hash(
ethash_h256_t* return_hash,
ethash_h256_t const* header_hash,
const uint64_t nonce,
ethash_h256_t const* mix_hash
);
uint64_t ethash_get_datasize(uint64_t const block_number);
uint64_t ethash_get_cachesize(uint64_t const block_number);
/**
* Compute the memory data for a full node's memory
*
* @param mem A pointer to an ethash full's memory
* @param full_size The size of the full data in bytes
* @param cache A cache object to use in the calculation
* @param callback The callback function. Check @ref ethash_full_new() for details.
* @return true if all went fine and false for invalid parameters
*/
bool ethash_compute_full_data(
void* mem,
uint64_t full_size,
ethash_light_t const light,
ethash_callback_t callback
);
#ifdef __cplusplus
}
#endif

View File

@ -0,0 +1,119 @@
/*
This file is part of ethash.
ethash is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ethash is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with ethash. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file io.c
* @author Lefteris Karapetsas <lefteris@ethdev.com>
* @date 2015
*/
#include "io.h"
#include <string.h>
#include <stdio.h>
#include <errno.h>
enum ethash_io_rc ethash_io_prepare(
char const* dirname,
ethash_h256_t const seedhash,
FILE** output_file,
uint64_t file_size,
bool force_create
)
{
char mutable_name[DAG_MUTABLE_NAME_MAX_SIZE];
enum ethash_io_rc ret = ETHASH_IO_FAIL;
// reset errno before io calls
errno = 0;
// assert directory exists
if (!ethash_mkdir(dirname)) {
ETHASH_CRITICAL("Could not create the ethash directory");
goto end;
}
ethash_io_mutable_name(ETHASH_REVISION, &seedhash, mutable_name);
char* tmpfile = ethash_io_create_filename(dirname, mutable_name, strlen(mutable_name));
if (!tmpfile) {
ETHASH_CRITICAL("Could not create the full DAG pathname");
goto end;
}
FILE *f;
if (!force_create) {
// try to open the file
f = ethash_fopen(tmpfile, "rb+");
if (f) {
size_t found_size;
if (!ethash_file_size(f, &found_size)) {
fclose(f);
ETHASH_CRITICAL("Could not query size of DAG file: \"%s\"", tmpfile);
goto free_memo;
}
if (file_size != found_size - ETHASH_DAG_MAGIC_NUM_SIZE) {
fclose(f);
ret = ETHASH_IO_MEMO_SIZE_MISMATCH;
goto free_memo;
}
// compare the magic number, no need to care about endianess since it's local
uint64_t magic_num;
if (fread(&magic_num, ETHASH_DAG_MAGIC_NUM_SIZE, 1, f) != 1) {
// I/O error
fclose(f);
ETHASH_CRITICAL("Could not read from DAG file: \"%s\"", tmpfile);
ret = ETHASH_IO_MEMO_SIZE_MISMATCH;
goto free_memo;
}
if (magic_num != ETHASH_DAG_MAGIC_NUM) {
fclose(f);
ret = ETHASH_IO_MEMO_SIZE_MISMATCH;
goto free_memo;
}
ret = ETHASH_IO_MEMO_MATCH;
goto set_file;
}
}
// file does not exist, will need to be created
f = ethash_fopen(tmpfile, "wb+");
if (!f) {
ETHASH_CRITICAL("Could not create DAG file: \"%s\"", tmpfile);
goto free_memo;
}
// make sure it's of the proper size
if (fseek(f, (long int)(file_size + ETHASH_DAG_MAGIC_NUM_SIZE - 1), SEEK_SET) != 0) {
fclose(f);
ETHASH_CRITICAL("Could not seek to the end of DAG file: \"%s\". Insufficient space?", tmpfile);
goto free_memo;
}
if (fputc('\n', f) == EOF) {
fclose(f);
ETHASH_CRITICAL("Could not write in the end of DAG file: \"%s\". Insufficient space?", tmpfile);
goto free_memo;
}
if (fflush(f) != 0) {
fclose(f);
ETHASH_CRITICAL("Could not flush at end of DAG file: \"%s\". Insufficient space?", tmpfile);
goto free_memo;
}
ret = ETHASH_IO_MEMO_MISMATCH;
goto set_file;
ret = ETHASH_IO_MEMO_MATCH;
set_file:
*output_file = f;
free_memo:
free(tmpfile);
end:
return ret;
}

View File

@ -0,0 +1,202 @@
/*
This file is part of ethash.
ethash is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ethash is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with ethash. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file io.h
* @author Lefteris Karapetsas <lefteris@ethdev.com>
* @date 2015
*/
#pragma once
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include <stdio.h>
#ifdef __cplusplus
#define __STDC_FORMAT_MACROS 1
#endif
#include <inttypes.h>
#include "endian.h"
#include "ethash.h"
#ifdef __cplusplus
extern "C" {
#endif
// Maximum size for mutable part of DAG file name
// 6 is for "full-R", the suffix of the filename
// 10 is for maximum number of digits of a uint32_t (for REVISION)
// 1 is for - and 16 is for the first 16 hex digits for first 8 bytes of
// the seedhash and last 1 is for the null terminating character
// Reference: https://github.com/ethereum/wiki/wiki/Ethash-DAG
#define DAG_MUTABLE_NAME_MAX_SIZE (6 + 10 + 1 + 16 + 1)
/// Possible return values of @see ethash_io_prepare
enum ethash_io_rc {
ETHASH_IO_FAIL = 0, ///< There has been an IO failure
ETHASH_IO_MEMO_SIZE_MISMATCH, ///< DAG with revision/hash match, but file size was wrong.
ETHASH_IO_MEMO_MISMATCH, ///< The DAG file did not exist or there was revision/hash mismatch
ETHASH_IO_MEMO_MATCH, ///< DAG file existed and revision/hash matched. No need to do anything
};
// small hack for windows. I don't feel I should use va_args and forward just
// to have this one function properly cross-platform abstracted
#if defined(_WIN32) && !defined(__GNUC__)
#define snprintf(...) sprintf_s(__VA_ARGS__)
#endif
/**
* Logs a critical error in important parts of ethash. Should mostly help
* figure out what kind of problem (I/O, memory e.t.c.) causes a NULL
* ethash_full_t
*/
#ifdef ETHASH_PRINT_CRITICAL_OUTPUT
#define ETHASH_CRITICAL(...) \
do \
{ \
printf("ETHASH CRITICAL ERROR: "__VA_ARGS__); \
printf("\n"); \
fflush(stdout); \
} while (0)
#else
#define ETHASH_CRITICAL(...)
#endif
/**
* Prepares io for ethash
*
* Create the DAG directory and the DAG file if they don't exist.
*
* @param[in] dirname A null terminated c-string of the path of the ethash
* data directory. If it does not exist it's created.
* @param[in] seedhash The seedhash of the current block number, used in the
* naming of the file as can be seen from the spec at:
* https://github.com/ethereum/wiki/wiki/Ethash-DAG
* @param[out] output_file If there was no failure then this will point to an open
* file descriptor. User is responsible for closing it.
* In the case of memo match then the file is open on read
* mode, while on the case of mismatch a new file is created
* on write mode
* @param[in] file_size The size that the DAG file should have on disk
* @param[out] force_create If true then there is no check to see if the file
* already exists
* @return For possible return values @see enum ethash_io_rc
*/
enum ethash_io_rc ethash_io_prepare(
char const* dirname,
ethash_h256_t const seedhash,
FILE** output_file,
uint64_t file_size,
bool force_create
);
/**
* An fopen wrapper for no-warnings crossplatform fopen.
*
* Msvc compiler considers fopen to be insecure and suggests to use their
* alternative. This is a wrapper for this alternative. Another way is to
* #define _CRT_SECURE_NO_WARNINGS, but disabling all security warnings does
* not sound like a good idea.
*
* @param file_name The path to the file to open
* @param mode Opening mode. Check fopen()
* @return The FILE* or NULL in failure
*/
FILE* ethash_fopen(char const* file_name, char const* mode);
/**
* An strncat wrapper for no-warnings crossplatform strncat.
*
* Msvc compiler considers strncat to be insecure and suggests to use their
* alternative. This is a wrapper for this alternative. Another way is to
* #define _CRT_SECURE_NO_WARNINGS, but disabling all security warnings does
* not sound like a good idea.
*
* @param des Destination buffer
* @param dest_size Maximum size of the destination buffer. This is the
* extra argument for the MSVC secure strncat
* @param src Souce buffer
* @param count Number of bytes to copy from source
* @return If all is well returns the dest buffer. If there is an
* error returns NULL
*/
char* ethash_strncat(char* dest, size_t dest_size, char const* src, size_t count);
/**
* A cross-platform mkdir wrapper to create a directory or assert it's there
*
* @param dirname The full path of the directory to create
* @return true if the directory was created or if it already
* existed
*/
bool ethash_mkdir(char const* dirname);
/**
* Get a file's size
*
* @param[in] f The open file stream whose size to get
* @param[out] size Pass a size_t by reference to contain the file size
* @return true in success and false if there was a failure
*/
bool ethash_file_size(FILE* f, size_t* ret_size);
/**
* Get a file descriptor number from a FILE stream
*
* @param f The file stream whose fd to get
* @return Platform specific fd handler
*/
int ethash_fileno(FILE* f);
/**
* Create the filename for the DAG.
*
* @param dirname The directory name in which the DAG file should reside
* If it does not end with a directory separator it is appended.
* @param filename The actual name of the file
* @param filename_length The length of the filename in bytes
* @return A char* containing the full name. User must deallocate.
*/
char* ethash_io_create_filename(
char const* dirname,
char const* filename,
size_t filename_length
);
/**
* Gets the default directory name for the DAG depending on the system
*
* The spec defining this directory is here: https://github.com/ethereum/wiki/wiki/Ethash-DAG
*
* @param[out] strbuf A string buffer of sufficient size to keep the
* null termninated string of the directory name
* @param[in] buffsize Size of @a strbuf in bytes
* @return true for success and false otherwise
*/
bool ethash_get_default_dirname(char* strbuf, size_t buffsize);
static inline bool ethash_io_mutable_name(
uint32_t revision,
ethash_h256_t const* seed_hash,
char* output
)
{
uint64_t hash = *((uint64_t*)seed_hash);
#if LITTLE_ENDIAN == BYTE_ORDER
hash = ethash_swap_u64(hash);
#endif
return snprintf(output, DAG_MUTABLE_NAME_MAX_SIZE, "full-R%u-%016" PRIx64, revision, hash) >= 0;
}
#ifdef __cplusplus
}
#endif

View File

@ -0,0 +1,111 @@
/*
This file is part of ethash.
ethash is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ethash is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with ethash. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file io_posix.c
* @author Lefteris Karapetsas <lefteris@ethdev.com>
* @date 2015
*/
#include "io.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
#include <libgen.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <pwd.h>
FILE* ethash_fopen(char const* file_name, char const* mode)
{
return fopen(file_name, mode);
}
char* ethash_strncat(char* dest, size_t dest_size, char const* src, size_t count)
{
return strlen(dest) + count + 1 <= dest_size ? strncat(dest, src, count) : NULL;
}
bool ethash_mkdir(char const* dirname)
{
int rc = mkdir(dirname, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
return rc != -1 || errno == EEXIST;
}
int ethash_fileno(FILE *f)
{
return fileno(f);
}
char* ethash_io_create_filename(
char const* dirname,
char const* filename,
size_t filename_length
)
{
size_t dirlen = strlen(dirname);
size_t dest_size = dirlen + filename_length + 1;
if (dirname[dirlen] != '/') {
dest_size += 1;
}
char* name = malloc(dest_size);
if (!name) {
return NULL;
}
name[0] = '\0';
ethash_strncat(name, dest_size, dirname, dirlen);
if (dirname[dirlen] != '/') {
ethash_strncat(name, dest_size, "/", 1);
}
ethash_strncat(name, dest_size, filename, filename_length);
return name;
}
bool ethash_file_size(FILE* f, size_t* ret_size)
{
struct stat st;
int fd;
if ((fd = fileno(f)) == -1 || fstat(fd, &st) != 0) {
return false;
}
*ret_size = st.st_size;
return true;
}
bool ethash_get_default_dirname(char* strbuf, size_t buffsize)
{
static const char dir_suffix[] = ".ethash/";
strbuf[0] = '\0';
char* home_dir = getenv("HOME");
if (!home_dir || strlen(home_dir) == 0)
{
struct passwd* pwd = getpwuid(getuid());
if (pwd)
home_dir = pwd->pw_dir;
}
size_t len = strlen(home_dir);
if (!ethash_strncat(strbuf, buffsize, home_dir, len)) {
return false;
}
if (home_dir[len] != '/') {
if (!ethash_strncat(strbuf, buffsize, "/", 1)) {
return false;
}
}
return ethash_strncat(strbuf, buffsize, dir_suffix, sizeof(dir_suffix));
}

View File

@ -0,0 +1,100 @@
/*
This file is part of ethash.
ethash is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ethash is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with ethash. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file io_win32.c
* @author Lefteris Karapetsas <lefteris@ethdev.com>
* @date 2015
*/
#include "io.h"
#include <direct.h>
#include <errno.h>
#include <stdio.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <shlobj.h>
FILE* ethash_fopen(char const* file_name, char const* mode)
{
FILE* f;
return fopen_s(&f, file_name, mode) == 0 ? f : NULL;
}
char* ethash_strncat(char* dest, size_t dest_size, char const* src, size_t count)
{
return strncat_s(dest, dest_size, src, count) == 0 ? dest : NULL;
}
bool ethash_mkdir(char const* dirname)
{
int rc = _mkdir(dirname);
return rc != -1 || errno == EEXIST;
}
int ethash_fileno(FILE* f)
{
return _fileno(f);
}
char* ethash_io_create_filename(
char const* dirname,
char const* filename,
size_t filename_length
)
{
size_t dirlen = strlen(dirname);
size_t dest_size = dirlen + filename_length + 1;
if (dirname[dirlen] != '\\' || dirname[dirlen] != '/') {
dest_size += 1;
}
char* name = malloc(dest_size);
if (!name) {
return NULL;
}
name[0] = '\0';
ethash_strncat(name, dest_size, dirname, dirlen);
if (dirname[dirlen] != '\\' || dirname[dirlen] != '/') {
ethash_strncat(name, dest_size, "\\", 1);
}
ethash_strncat(name, dest_size, filename, filename_length);
return name;
}
bool ethash_file_size(FILE* f, size_t* ret_size)
{
struct _stat st;
int fd;
if ((fd = _fileno(f)) == -1 || _fstat(fd, &st) != 0) {
return false;
}
*ret_size = st.st_size;
return true;
}
bool ethash_get_default_dirname(char* strbuf, size_t buffsize)
{
static const char dir_suffix[] = "Ethash\\";
strbuf[0] = '\0';
if (!SUCCEEDED(SHGetFolderPathA(NULL, CSIDL_LOCAL_APPDATA, NULL, 0, (CHAR*)strbuf))) {
return false;
}
if (!ethash_strncat(strbuf, buffsize, "\\", 1)) {
return false;
}
return ethash_strncat(strbuf, buffsize, dir_suffix, sizeof(dir_suffix));
}

View File

@ -0,0 +1,47 @@
/*
This file is part of ethash.
ethash is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ethash is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with ethash. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file mmap.h
* @author Lefteris Karapetsas <lefteris@ethdev.com>
* @date 2015
*/
#pragma once
#if defined(__MINGW32__) || defined(_WIN32)
#include <sys/types.h>
#define PROT_READ 0x1
#define PROT_WRITE 0x2
/* This flag is only available in WinXP+ */
#ifdef FILE_MAP_EXECUTE
#define PROT_EXEC 0x4
#else
#define PROT_EXEC 0x0
#define FILE_MAP_EXECUTE 0
#endif
#define MAP_SHARED 0x01
#define MAP_PRIVATE 0x02
#define MAP_ANONYMOUS 0x20
#define MAP_ANON MAP_ANONYMOUS
#define MAP_FAILED ((void *) -1)
void* mmap(void* start, size_t length, int prot, int flags, int fd, off_t offset);
void munmap(void* addr, size_t length);
#else // posix, yay! ^_^
#include <sys/mman.h>
#endif

View File

@ -0,0 +1,84 @@
/* mmap() replacement for Windows
*
* Author: Mike Frysinger <vapier@gentoo.org>
* Placed into the public domain
*/
/* References:
* CreateFileMapping: http://msdn.microsoft.com/en-us/library/aa366537(VS.85).aspx
* CloseHandle: http://msdn.microsoft.com/en-us/library/ms724211(VS.85).aspx
* MapViewOfFile: http://msdn.microsoft.com/en-us/library/aa366761(VS.85).aspx
* UnmapViewOfFile: http://msdn.microsoft.com/en-us/library/aa366882(VS.85).aspx
*/
#include <io.h>
#include <windows.h>
#include "mmap.h"
#ifdef __USE_FILE_OFFSET64
# define DWORD_HI(x) (x >> 32)
# define DWORD_LO(x) ((x) & 0xffffffff)
#else
# define DWORD_HI(x) (0)
# define DWORD_LO(x) (x)
#endif
void* mmap(void* start, size_t length, int prot, int flags, int fd, off_t offset)
{
if (prot & ~(PROT_READ | PROT_WRITE | PROT_EXEC))
return MAP_FAILED;
if (fd == -1) {
if (!(flags & MAP_ANON) || offset)
return MAP_FAILED;
} else if (flags & MAP_ANON)
return MAP_FAILED;
DWORD flProtect;
if (prot & PROT_WRITE) {
if (prot & PROT_EXEC)
flProtect = PAGE_EXECUTE_READWRITE;
else
flProtect = PAGE_READWRITE;
} else if (prot & PROT_EXEC) {
if (prot & PROT_READ)
flProtect = PAGE_EXECUTE_READ;
else if (prot & PROT_EXEC)
flProtect = PAGE_EXECUTE;
} else
flProtect = PAGE_READONLY;
off_t end = length + offset;
HANDLE mmap_fd, h;
if (fd == -1)
mmap_fd = INVALID_HANDLE_VALUE;
else
mmap_fd = (HANDLE)_get_osfhandle(fd);
h = CreateFileMapping(mmap_fd, NULL, flProtect, DWORD_HI(end), DWORD_LO(end), NULL);
if (h == NULL)
return MAP_FAILED;
DWORD dwDesiredAccess;
if (prot & PROT_WRITE)
dwDesiredAccess = FILE_MAP_WRITE;
else
dwDesiredAccess = FILE_MAP_READ;
if (prot & PROT_EXEC)
dwDesiredAccess |= FILE_MAP_EXECUTE;
if (flags & MAP_PRIVATE)
dwDesiredAccess |= FILE_MAP_COPY;
void *ret = MapViewOfFile(h, dwDesiredAccess, DWORD_HI(offset), DWORD_LO(offset), length);
if (ret == NULL) {
ret = MAP_FAILED;
}
// since we are handling the file ourselves with fd, close the Windows Handle here
CloseHandle(h);
return ret;
}
void munmap(void* addr, size_t length)
{
UnmapViewOfFile(addr);
}
#undef DWORD_HI
#undef DWORD_LO

View File

@ -0,0 +1,151 @@
/** libkeccak-tiny
*
* A single-file implementation of SHA-3 and SHAKE.
*
* Implementor: David Leon Gil
* License: CC0, attribution kindly requested. Blame taken too,
* but not liability.
*/
#include "sha3.h"
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/******** The Keccak-f[1600] permutation ********/
/*** Constants. ***/
static const uint8_t rho[24] = \
{ 1, 3, 6, 10, 15, 21,
28, 36, 45, 55, 2, 14,
27, 41, 56, 8, 25, 43,
62, 18, 39, 61, 20, 44};
static const uint8_t pi[24] = \
{10, 7, 11, 17, 18, 3,
5, 16, 8, 21, 24, 4,
15, 23, 19, 13, 12, 2,
20, 14, 22, 9, 6, 1};
static const uint64_t RC[24] = \
{1ULL, 0x8082ULL, 0x800000000000808aULL, 0x8000000080008000ULL,
0x808bULL, 0x80000001ULL, 0x8000000080008081ULL, 0x8000000000008009ULL,
0x8aULL, 0x88ULL, 0x80008009ULL, 0x8000000aULL,
0x8000808bULL, 0x800000000000008bULL, 0x8000000000008089ULL, 0x8000000000008003ULL,
0x8000000000008002ULL, 0x8000000000000080ULL, 0x800aULL, 0x800000008000000aULL,
0x8000000080008081ULL, 0x8000000000008080ULL, 0x80000001ULL, 0x8000000080008008ULL};
/*** Helper macros to unroll the permutation. ***/
#define rol(x, s) (((x) << s) | ((x) >> (64 - s)))
#define REPEAT6(e) e e e e e e
#define REPEAT24(e) REPEAT6(e e e e)
#define REPEAT5(e) e e e e e
#define FOR5(v, s, e) \
v = 0; \
REPEAT5(e; v += s;)
/*** Keccak-f[1600] ***/
static inline void keccakf(void* state) {
uint64_t* a = (uint64_t*)state;
uint64_t b[5] = {0};
uint64_t t = 0;
uint8_t x, y;
for (int i = 0; i < 24; i++) {
// Theta
FOR5(x, 1,
b[x] = 0;
FOR5(y, 5,
b[x] ^= a[x + y]; ))
FOR5(x, 1,
FOR5(y, 5,
a[y + x] ^= b[(x + 4) % 5] ^ rol(b[(x + 1) % 5], 1); ))
// Rho and pi
t = a[1];
x = 0;
REPEAT24(b[0] = a[pi[x]];
a[pi[x]] = rol(t, rho[x]);
t = b[0];
x++; )
// Chi
FOR5(y,
5,
FOR5(x, 1,
b[x] = a[y + x];)
FOR5(x, 1,
a[y + x] = b[x] ^ ((~b[(x + 1) % 5]) & b[(x + 2) % 5]); ))
// Iota
a[0] ^= RC[i];
}
}
/******** The FIPS202-defined functions. ********/
/*** Some helper macros. ***/
#define _(S) do { S } while (0)
#define FOR(i, ST, L, S) \
_(for (size_t i = 0; i < L; i += ST) { S; })
#define mkapply_ds(NAME, S) \
static inline void NAME(uint8_t* dst, \
const uint8_t* src, \
size_t len) { \
FOR(i, 1, len, S); \
}
#define mkapply_sd(NAME, S) \
static inline void NAME(const uint8_t* src, \
uint8_t* dst, \
size_t len) { \
FOR(i, 1, len, S); \
}
mkapply_ds(xorin, dst[i] ^= src[i]) // xorin
mkapply_sd(setout, dst[i] = src[i]) // setout
#define P keccakf
#define Plen 200
// Fold P*F over the full blocks of an input.
#define foldP(I, L, F) \
while (L >= rate) { \
F(a, I, rate); \
P(a); \
I += rate; \
L -= rate; \
}
/** The sponge-based hash construction. **/
static inline int hash(uint8_t* out, size_t outlen,
const uint8_t* in, size_t inlen,
size_t rate, uint8_t delim) {
if ((out == NULL) || ((in == NULL) && inlen != 0) || (rate >= Plen)) {
return -1;
}
uint8_t a[Plen] = {0};
// Absorb input.
foldP(in, inlen, xorin);
// Xor in the DS and pad frame.
a[inlen] ^= delim;
a[rate - 1] ^= 0x80;
// Xor in the last block.
xorin(a, in, inlen);
// Apply P
P(a);
// Squeeze output.
foldP(out, outlen, setout);
setout(a, out, outlen);
memset(a, 0, 200);
return 0;
}
#define defsha3(bits) \
int sha3_##bits(uint8_t* out, size_t outlen, \
const uint8_t* in, size_t inlen) { \
if (outlen > (bits/8)) { \
return -1; \
} \
return hash(out, outlen, in, inlen, 200 - (bits / 4), 0x01); \
}
/*** FIPS202 SHA3 FOFs ***/
defsha3(256)
defsha3(512)

View File

@ -0,0 +1,31 @@
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
#include "compiler.h"
#include <stdint.h>
#include <stdlib.h>
struct ethash_h256;
#define decsha3(bits) \
int sha3_##bits(uint8_t*, size_t, uint8_t const*, size_t);
decsha3(256)
decsha3(512)
static inline void SHA3_256(struct ethash_h256 const* ret, uint8_t const* data, size_t const size)
{
sha3_256((uint8_t*)ret, 32, data, size);
}
static inline void SHA3_512(uint8_t* ret, uint8_t const* data, size_t const size)
{
sha3_512(ret, 64, data, size);
}
#ifdef __cplusplus
}
#endif

View File

@ -0,0 +1,37 @@
/*
This file is part of ethash.
ethash is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ethash is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with ethash. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file sha3.cpp
* @author Tim Hughes <tim@twistedfury.com>
* @date 2015
*/
#include <stdint.h>
#include <cryptopp/sha3.h>
extern "C" {
struct ethash_h256;
typedef struct ethash_h256 ethash_h256_t;
void SHA3_256(ethash_h256_t const* ret, uint8_t const* data, size_t size)
{
CryptoPP::SHA3_256().CalculateDigest((uint8_t*)ret, data, size);
}
void SHA3_512(uint8_t* const ret, uint8_t const* data, size_t size)
{
CryptoPP::SHA3_512().CalculateDigest(ret, data, size);
}
}

View File

@ -0,0 +1,18 @@
#pragma once
#include "compiler.h"
#include <stdint.h>
#include <stdlib.h>
#ifdef __cplusplus
extern "C" {
#endif
struct ethash_h256;
void SHA3_256(struct ethash_h256 const* ret, uint8_t const* data, size_t size);
void SHA3_512(uint8_t* const ret, uint8_t const* data, size_t size);
#ifdef __cplusplus
}
#endif

View File

@ -0,0 +1,47 @@
/*
This file is part of ethash.
ethash is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ethash is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with ethash. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file util.h
* @author Tim Hughes <tim@twistedfury.com>
* @date 2015
*/
#pragma once
#include <stdint.h>
#include "compiler.h"
#ifdef __cplusplus
extern "C" {
#endif
#ifdef _MSC_VER
void debugf(char const* str, ...);
#else
#define debugf printf
#endif
static inline uint32_t min_u32(uint32_t a, uint32_t b)
{
return a < b ? a : b;
}
static inline uint32_t clamp_u32(uint32_t x, uint32_t min_, uint32_t max_)
{
return x < min_ ? min_ : (x > max_ ? max_ : x);
}
#ifdef __cplusplus
}
#endif

View File

@ -0,0 +1,38 @@
/*
This file is part of cpp-ethereum.
cpp-ethereum is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
cpp-ethereum is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file util.c
* @author Tim Hughes <tim@twistedfury.com>
* @date 2015
*/
#include <stdarg.h>
#include <stdio.h>
#include "util.h"
// foward declare without all of Windows.h
__declspec(dllimport) void __stdcall OutputDebugStringA(char const* lpOutputString);
void debugf(char const* str, ...)
{
va_list args;
va_start(args, str);
char buf[1<<16];
_vsnprintf_s(buf, sizeof(buf), sizeof(buf), str, args);
buf[sizeof(buf)-1] = '\0';
OutputDebugStringA(buf);
}

View File

@ -0,0 +1,267 @@
#include <Python.h>
#include <alloca.h>
#include <stdint.h>
#include <stdlib.h>
#include <time.h>
#include "../libethash/ethash.h"
#include "../libethash/internal.h"
#if PY_MAJOR_VERSION >= 3
#define PY_STRING_FORMAT "y#"
#define PY_CONST_STRING_FORMAT "y"
#else
#define PY_STRING_FORMAT "s#"
#define PY_CONST_STRING_FORMAT "s"
#endif
#define MIX_WORDS (ETHASH_MIX_BYTES/4)
static PyObject *
mkcache_bytes(PyObject *self, PyObject *args) {
unsigned long block_number;
unsigned long cache_size;
if (!PyArg_ParseTuple(args, "k", &block_number))
return 0;
ethash_light_t L = ethash_light_new(block_number);
PyObject * val = Py_BuildValue(PY_STRING_FORMAT, L->cache, L->cache_size);
free(L->cache);
return val;
}
/*
static PyObject *
calc_dataset_bytes(PyObject *self, PyObject *args) {
char *cache_bytes;
unsigned long full_size;
int cache_size;
if (!PyArg_ParseTuple(args, "k" PY_STRING_FORMAT, &full_size, &cache_bytes, &cache_size))
return 0;
if (full_size % MIX_WORDS != 0) {
char error_message[1024];
sprintf(error_message, "The size of data set must be a multiple of %i bytes (was %lu)", MIX_WORDS, full_size);
PyErr_SetString(PyExc_ValueError, error_message);
return 0;
}
if (cache_size % ETHASH_HASH_BYTES != 0) {
char error_message[1024];
sprintf(error_message, "The size of the cache must be a multiple of %i bytes (was %i)", ETHASH_HASH_BYTES, cache_size);
PyErr_SetString(PyExc_ValueError, error_message);
return 0;
}
ethash_params params;
params.cache_size = (size_t) cache_size;
params.full_size = (size_t) full_size;
ethash_cache cache;
cache.mem = (void *) cache_bytes;
void *mem = malloc(params.full_size);
ethash_compute_full_data(mem, &params, &cache);
PyObject * val = Py_BuildValue(PY_STRING_FORMAT, (char *) mem, full_size);
free(mem);
return val;
}*/
// hashimoto_light(full_size, cache, header, nonce)
static PyObject *
hashimoto_light(PyObject *self, PyObject *args) {
char *cache_bytes;
char *header;
unsigned long block_number;
unsigned long long nonce;
int cache_size, header_size;
if (!PyArg_ParseTuple(args, "k" PY_STRING_FORMAT PY_STRING_FORMAT "K", &block_number, &cache_bytes, &cache_size, &header, &header_size, &nonce))
return 0;
if (header_size != 32) {
char error_message[1024];
sprintf(error_message, "Seed must be 32 bytes long (was %i)", header_size);
PyErr_SetString(PyExc_ValueError, error_message);
return 0;
}
struct ethash_light *s;
s = calloc(sizeof(*s), 1);
s->cache = cache_bytes;
s->cache_size = cache_size;
s->block_number = block_number;
struct ethash_h256 *h;
h = calloc(sizeof(*h), 1);
for (int i = 0; i < 32; i++) h->b[i] = header[i];
struct ethash_return_value out = ethash_light_compute(s, *h, nonce);
return Py_BuildValue("{" PY_CONST_STRING_FORMAT ":" PY_STRING_FORMAT "," PY_CONST_STRING_FORMAT ":" PY_STRING_FORMAT "}",
"mix digest", &out.mix_hash, 32,
"result", &out.result, 32);
}
/*
// hashimoto_full(dataset, header, nonce)
static PyObject *
hashimoto_full(PyObject *self, PyObject *args) {
char *full_bytes;
char *header;
unsigned long long nonce;
int full_size, header_size;
if (!PyArg_ParseTuple(args, PY_STRING_FORMAT PY_STRING_FORMAT "K", &full_bytes, &full_size, &header, &header_size, &nonce))
return 0;
if (full_size % MIX_WORDS != 0) {
char error_message[1024];
sprintf(error_message, "The size of data set must be a multiple of %i bytes (was %i)", MIX_WORDS, full_size);
PyErr_SetString(PyExc_ValueError, error_message);
return 0;
}
if (header_size != 32) {
char error_message[1024];
sprintf(error_message, "Header must be 32 bytes long (was %i)", header_size);
PyErr_SetString(PyExc_ValueError, error_message);
return 0;
}
ethash_return_value out;
ethash_params params;
params.full_size = (size_t) full_size;
ethash_full(&out, (void *) full_bytes, &params, (ethash_h256_t *) header, nonce);
return Py_BuildValue("{" PY_CONST_STRING_FORMAT ":" PY_STRING_FORMAT ", " PY_CONST_STRING_FORMAT ":" PY_STRING_FORMAT "}",
"mix digest", &out.mix_hash, 32,
"result", &out.result, 32);
}
// mine(dataset_bytes, header, difficulty_bytes)
static PyObject *
mine(PyObject *self, PyObject *args) {
char *full_bytes;
char *header;
char *difficulty;
srand(time(0));
uint64_t nonce = ((uint64_t) rand()) << 32 | rand();
int full_size, header_size, difficulty_size;
if (!PyArg_ParseTuple(args, PY_STRING_FORMAT PY_STRING_FORMAT PY_STRING_FORMAT, &full_bytes, &full_size, &header, &header_size, &difficulty, &difficulty_size))
return 0;
if (full_size % MIX_WORDS != 0) {
char error_message[1024];
sprintf(error_message, "The size of data set must be a multiple of %i bytes (was %i)", MIX_WORDS, full_size);
PyErr_SetString(PyExc_ValueError, error_message);
return 0;
}
if (header_size != 32) {
char error_message[1024];
sprintf(error_message, "Header must be 32 bytes long (was %i)", header_size);
PyErr_SetString(PyExc_ValueError, error_message);
return 0;
}
if (difficulty_size != 32) {
char error_message[1024];
sprintf(error_message, "Difficulty must be an array of 32 bytes (only had %i)", difficulty_size);
PyErr_SetString(PyExc_ValueError, error_message);
return 0;
}
ethash_return_value out;
ethash_params params;
params.full_size = (size_t) full_size;
// TODO: Multi threading?
do {
ethash_full(&out, (void *) full_bytes, &params, (const ethash_h256_t *) header, nonce++);
// TODO: disagrees with the spec https://github.com/ethereum/wiki/wiki/Ethash#mining
} while (!ethash_check_difficulty(&out.result, (const ethash_h256_t *) difficulty));
return Py_BuildValue("{" PY_CONST_STRING_FORMAT ":" PY_STRING_FORMAT ", " PY_CONST_STRING_FORMAT ":" PY_STRING_FORMAT ", " PY_CONST_STRING_FORMAT ":K}",
"mix digest", &out.mix_hash, 32,
"result", &out.result, 32,
"nonce", nonce);
}
*/
//get_seedhash(block_number)
static PyObject *
get_seedhash(PyObject *self, PyObject *args) {
unsigned long block_number;
if (!PyArg_ParseTuple(args, "k", &block_number))
return 0;
if (block_number >= ETHASH_EPOCH_LENGTH * 2048) {
char error_message[1024];
sprintf(error_message, "Block number must be less than %i (was %lu)", ETHASH_EPOCH_LENGTH * 2048, block_number);
PyErr_SetString(PyExc_ValueError, error_message);
return 0;
}
ethash_h256_t seedhash = ethash_get_seedhash(block_number);
return Py_BuildValue(PY_STRING_FORMAT, (char *) &seedhash, 32);
}
static PyMethodDef PyethashMethods[] =
{
{"get_seedhash", get_seedhash, METH_VARARGS,
"get_seedhash(block_number)\n\n"
"Gets the seedhash for a block."},
{"mkcache_bytes", mkcache_bytes, METH_VARARGS,
"mkcache_bytes(block_number)\n\n"
"Makes a byte array for the cache for given block number\n"},
/*{"calc_dataset_bytes", calc_dataset_bytes, METH_VARARGS,
"calc_dataset_bytes(full_size, cache_bytes)\n\n"
"Makes a byte array for the dataset for a given size given cache bytes"},*/
{"hashimoto_light", hashimoto_light, METH_VARARGS,
"hashimoto_light(block_number, cache_bytes, header, nonce)\n\n"
"Runs the hashimoto hashing function just using cache bytes. Takes an int (full_size), byte array (cache_bytes), another byte array (header), and an int (nonce). Returns an object containing the mix digest, and hash result."},
/*{"hashimoto_full", hashimoto_full, METH_VARARGS,
"hashimoto_full(dataset_bytes, header, nonce)\n\n"
"Runs the hashimoto hashing function using the dataset bytes. Useful for testing. Returns an object containing the mix digest (byte array), and hash result (another byte array)."},
{"mine", mine, METH_VARARGS,
"mine(dataset_bytes, header, difficulty_bytes)\n\n"
"Mine for an adequate header. Returns an object containing the mix digest (byte array), hash result (another byte array) and nonce (an int)."},*/
{NULL, NULL, 0, NULL}
};
#if PY_MAJOR_VERSION >= 3
static struct PyModuleDef PyethashModule = {
PyModuleDef_HEAD_INIT,
"pyethash",
"...",
-1,
PyethashMethods
};
PyMODINIT_FUNC PyInit_pyethash(void) {
PyObject *module = PyModule_Create(&PyethashModule);
// Following Spec: https://github.com/ethereum/wiki/wiki/Ethash#definitions
PyModule_AddIntConstant(module, "REVISION", (long) ETHASH_REVISION);
PyModule_AddIntConstant(module, "DATASET_BYTES_INIT", (long) ETHASH_DATASET_BYTES_INIT);
PyModule_AddIntConstant(module, "DATASET_BYTES_GROWTH", (long) ETHASH_DATASET_BYTES_GROWTH);
PyModule_AddIntConstant(module, "CACHE_BYTES_INIT", (long) ETHASH_CACHE_BYTES_INIT);
PyModule_AddIntConstant(module, "CACHE_BYTES_GROWTH", (long) ETHASH_CACHE_BYTES_GROWTH);
PyModule_AddIntConstant(module, "EPOCH_LENGTH", (long) ETHASH_EPOCH_LENGTH);
PyModule_AddIntConstant(module, "MIX_BYTES", (long) ETHASH_MIX_BYTES);
PyModule_AddIntConstant(module, "HASH_BYTES", (long) ETHASH_HASH_BYTES);
PyModule_AddIntConstant(module, "DATASET_PARENTS", (long) ETHASH_DATASET_PARENTS);
PyModule_AddIntConstant(module, "CACHE_ROUNDS", (long) ETHASH_CACHE_ROUNDS);
PyModule_AddIntConstant(module, "ACCESSES", (long) ETHASH_ACCESSES);
return module;
}
#else
PyMODINIT_FUNC
initpyethash(void) {
PyObject *module = Py_InitModule("pyethash", PyethashMethods);
// Following Spec: https://github.com/ethereum/wiki/wiki/Ethash#definitions
PyModule_AddIntConstant(module, "REVISION", (long) ETHASH_REVISION);
PyModule_AddIntConstant(module, "DATASET_BYTES_INIT", (long) ETHASH_DATASET_BYTES_INIT);
PyModule_AddIntConstant(module, "DATASET_BYTES_GROWTH", (long) ETHASH_DATASET_BYTES_GROWTH);
PyModule_AddIntConstant(module, "CACHE_BYTES_INIT", (long) ETHASH_CACHE_BYTES_INIT);
PyModule_AddIntConstant(module, "CACHE_BYTES_GROWTH", (long) ETHASH_CACHE_BYTES_GROWTH);
PyModule_AddIntConstant(module, "EPOCH_LENGTH", (long) ETHASH_EPOCH_LENGTH);
PyModule_AddIntConstant(module, "MIX_BYTES", (long) ETHASH_MIX_BYTES);
PyModule_AddIntConstant(module, "HASH_BYTES", (long) ETHASH_HASH_BYTES);
PyModule_AddIntConstant(module, "DATASET_PARENTS", (long) ETHASH_DATASET_PARENTS);
PyModule_AddIntConstant(module, "CACHE_ROUNDS", (long) ETHASH_CACHE_ROUNDS);
PyModule_AddIntConstant(module, "ACCESSES", (long) ETHASH_ACCESSES);
}
#endif

View File

@ -0,0 +1,66 @@
if (MSVC)
if (NOT BOOST_ROOT)
set (BOOST_ROOT "$ENV{BOOST_ROOT}")
endif()
set (CMAKE_PREFIX_PATH BOOST_ROOT)
endif()
IF( NOT Boost_FOUND )
# use multithreaded boost libraries, with -mt suffix
set(Boost_USE_MULTITHREADED ON)
if (MSVC)
# TODO handle other msvc versions or it will fail find them
set(Boost_COMPILER -vc120)
# use static boost libraries *.lib
set(Boost_USE_STATIC_LIBS ON)
elseif (APPLE)
# use static boost libraries *.a
set(Boost_USE_STATIC_LIBS ON)
elseif (UNIX)
# use dynamic boost libraries .dll
set(Boost_USE_STATIC_LIBS OFF)
endif()
find_package(Boost 1.48.0 COMPONENTS unit_test_framework system filesystem)
ENDIF()
IF (Boost_FOUND)
message(STATUS "boost header: ${Boost_INCLUDE_DIRS}")
message(STATUS "boost libs : ${Boost_LIBRARIES}")
include_directories( ${Boost_INCLUDE_DIR} )
include_directories(../../src)
link_directories(${Boost_LIBRARY_DIRS})
file(GLOB HEADERS "*.h")
if ((NOT MSVC) AND (NOT APPLE))
ADD_DEFINITIONS(-DBOOST_TEST_DYN_LINK)
endif()
if (NOT CRYPTOPP_FOUND)
find_package (CryptoPP)
endif()
if (CRYPTOPP_FOUND)
add_definitions(-DWITH_CRYPTOPP)
endif()
if (NOT MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 ")
endif()
add_executable (Test "./test.cpp" ${HEADERS})
target_link_libraries(Test ${ETHHASH_LIBS})
target_link_libraries(Test ${Boost_FILESYSTEM_LIBRARIES})
target_link_libraries(Test ${Boost_SYSTEM_LIBRARIES})
target_link_libraries(Test ${Boost_UNIT_TEST_FRAMEWORK_LIBRARIES})
if (CRYPTOPP_FOUND)
TARGET_LINK_LIBRARIES(Test ${CRYPTOPP_LIBRARIES})
endif()
enable_testing ()
add_test(NAME ethash COMMAND Test)
ENDIF()

View File

@ -0,0 +1,669 @@
#include <iomanip>
#include <libethash/fnv.h>
#include <libethash/ethash.h>
#include <libethash/internal.h>
#include <libethash/io.h>
#ifdef WITH_CRYPTOPP
#include <libethash/sha3_cryptopp.h>
#else
#include <libethash/sha3.h>
#endif // WITH_CRYPTOPP
#ifdef _WIN32
#include <windows.h>
#include <Shlobj.h>
#endif
#define BOOST_TEST_MODULE Daggerhashimoto
#define BOOST_TEST_MAIN
#include <iostream>
#include <fstream>
#include <vector>
#include <boost/filesystem.hpp>
#include <boost/test/unit_test.hpp>
using namespace std;
using byte = uint8_t;
using bytes = std::vector<byte>;
namespace fs = boost::filesystem;
// Just an alloca "wrapper" to silence uint64_t to size_t conversion warnings in windows
// consider replacing alloca calls with something better though!
#define our_alloca(param__) alloca((size_t)(param__))
// some functions taken from eth::dev for convenience.
std::string bytesToHexString(const uint8_t *str, const uint64_t s)
{
std::ostringstream ret;
for (size_t i = 0; i < s; ++i)
ret << std::hex << std::setfill('0') << std::setw(2) << std::nouppercase << (int) str[i];
return ret.str();
}
std::string blockhashToHexString(ethash_h256_t* _hash)
{
return bytesToHexString((uint8_t*)_hash, 32);
}
int fromHex(char _i)
{
if (_i >= '0' && _i <= '9')
return _i - '0';
if (_i >= 'a' && _i <= 'f')
return _i - 'a' + 10;
if (_i >= 'A' && _i <= 'F')
return _i - 'A' + 10;
BOOST_REQUIRE_MESSAGE(false, "should never get here");
return -1;
}
bytes hexStringToBytes(std::string const& _s)
{
unsigned s = (_s[0] == '0' && _s[1] == 'x') ? 2 : 0;
std::vector<uint8_t> ret;
ret.reserve((_s.size() - s + 1) / 2);
if (_s.size() % 2)
try
{
ret.push_back(fromHex(_s[s++]));
}
catch (...)
{
ret.push_back(0);
}
for (unsigned i = s; i < _s.size(); i += 2)
try
{
ret.push_back((byte)(fromHex(_s[i]) * 16 + fromHex(_s[i + 1])));
}
catch (...){
ret.push_back(0);
}
return ret;
}
ethash_h256_t stringToBlockhash(std::string const& _s)
{
ethash_h256_t ret;
bytes b = hexStringToBytes(_s);
memcpy(&ret, b.data(), b.size());
return ret;
}
BOOST_AUTO_TEST_CASE(fnv_hash_check) {
uint32_t x = 1235U;
const uint32_t
y = 9999999U,
expected = (FNV_PRIME * x) ^y;
x = fnv_hash(x, y);
BOOST_REQUIRE_MESSAGE(x == expected,
"\nexpected: " << expected << "\n"
<< "actual: " << x << "\n");
}
BOOST_AUTO_TEST_CASE(SHA256_check) {
ethash_h256_t input;
ethash_h256_t out;
memcpy(&input, "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~", 32);
SHA3_256(&out, (uint8_t*)&input, 32);
const std::string
expected = "2b5ddf6f4d21c23de216f44d5e4bdc68e044b71897837ea74c83908be7037cd7",
actual = bytesToHexString((uint8_t*)&out, 32);
BOOST_REQUIRE_MESSAGE(expected == actual,
"\nexpected: " << expected.c_str() << "\n"
<< "actual: " << actual.c_str() << "\n");
}
BOOST_AUTO_TEST_CASE(SHA512_check) {
uint8_t input[64], out[64];
memcpy(input, "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~", 64);
SHA3_512(out, input, 64);
const std::string
expected = "0be8a1d334b4655fe58c6b38789f984bb13225684e86b20517a55ab2386c7b61c306f25e0627c60064cecd6d80cd67a82b3890bd1289b7ceb473aad56a359405",
actual = bytesToHexString(out, 64);
BOOST_REQUIRE_MESSAGE(expected == actual,
"\nexpected: " << expected.c_str() << "\n"
<< "actual: " << actual.c_str() << "\n");
}
BOOST_AUTO_TEST_CASE(test_swap_endian32) {
uint32_t v32 = (uint32_t)0xBAADF00D;
v32 = ethash_swap_u32(v32);
BOOST_REQUIRE_EQUAL(v32, (uint32_t)0x0DF0ADBA);
}
BOOST_AUTO_TEST_CASE(test_swap_endian64) {
uint64_t v64 = (uint64_t)0xFEE1DEADDEADBEEF;
v64 = ethash_swap_u64(v64);
BOOST_REQUIRE_EQUAL(v64, (uint64_t)0xEFBEADDEADDEE1FE);
}
BOOST_AUTO_TEST_CASE(ethash_params_init_genesis_check) {
uint64_t full_size = ethash_get_datasize(0);
uint64_t cache_size = ethash_get_cachesize(0);
BOOST_REQUIRE_MESSAGE(full_size < ETHASH_DATASET_BYTES_INIT,
"\nfull size: " << full_size << "\n"
<< "should be less than or equal to: " << ETHASH_DATASET_BYTES_INIT << "\n");
BOOST_REQUIRE_MESSAGE(full_size + 20 * ETHASH_MIX_BYTES >= ETHASH_DATASET_BYTES_INIT,
"\nfull size + 20*MIX_BYTES: " << full_size + 20 * ETHASH_MIX_BYTES << "\n"
<< "should be greater than or equal to: " << ETHASH_DATASET_BYTES_INIT << "\n");
BOOST_REQUIRE_MESSAGE(cache_size < ETHASH_DATASET_BYTES_INIT / 32,
"\ncache size: " << cache_size << "\n"
<< "should be less than or equal to: " << ETHASH_DATASET_BYTES_INIT / 32 << "\n");
}
BOOST_AUTO_TEST_CASE(ethash_params_init_genesis_calcifide_check) {
uint64_t full_size = ethash_get_datasize(0);
uint64_t cache_size = ethash_get_cachesize(0);
const uint32_t expected_full_size = 1073739904;
const uint32_t expected_cache_size = 16776896;
BOOST_REQUIRE_MESSAGE(full_size == expected_full_size,
"\nexpected: " << expected_cache_size << "\n"
<< "actual: " << full_size << "\n");
BOOST_REQUIRE_MESSAGE(cache_size == expected_cache_size,
"\nexpected: " << expected_cache_size << "\n"
<< "actual: " << cache_size << "\n");
}
BOOST_AUTO_TEST_CASE(ethash_check_difficulty_check) {
ethash_h256_t hash;
ethash_h256_t target;
memcpy(&hash, "11111111111111111111111111111111", 32);
memcpy(&target, "22222222222222222222222222222222", 32);
BOOST_REQUIRE_MESSAGE(
ethash_check_difficulty(&hash, &target),
"\nexpected \"" << std::string((char *) &hash, 32).c_str() << "\" to have the same or less difficulty than \"" << std::string((char *) &target, 32).c_str() << "\"\n");
BOOST_REQUIRE_MESSAGE(
ethash_check_difficulty(&hash, &hash), "");
// "\nexpected \"" << hash << "\" to have the same or less difficulty than \"" << hash << "\"\n");
memcpy(&target, "11111111111111111111111111111112", 32);
BOOST_REQUIRE_MESSAGE(
ethash_check_difficulty(&hash, &target), "");
// "\nexpected \"" << hash << "\" to have the same or less difficulty than \"" << target << "\"\n");
memcpy(&target, "11111111111111111111111111111110", 32);
BOOST_REQUIRE_MESSAGE(
!ethash_check_difficulty(&hash, &target), "");
// "\nexpected \"" << hash << "\" to have more difficulty than \"" << target << "\"\n");
}
BOOST_AUTO_TEST_CASE(test_ethash_io_mutable_name) {
char mutable_name[DAG_MUTABLE_NAME_MAX_SIZE];
// should have at least 8 bytes provided since this is what we test :)
ethash_h256_t seed1 = ethash_h256_static_init(0, 10, 65, 255, 34, 55, 22, 8);
ethash_io_mutable_name(1, &seed1, mutable_name);
BOOST_REQUIRE_EQUAL(0, strcmp(mutable_name, "full-R1-000a41ff22371608"));
ethash_h256_t seed2 = ethash_h256_static_init(0, 0, 0, 0, 0, 0, 0, 0);
ethash_io_mutable_name(44, &seed2, mutable_name);
BOOST_REQUIRE_EQUAL(0, strcmp(mutable_name, "full-R44-0000000000000000"));
}
BOOST_AUTO_TEST_CASE(test_ethash_dir_creation) {
ethash_h256_t seedhash;
FILE *f = NULL;
memset(&seedhash, 0, 32);
BOOST_REQUIRE_EQUAL(
ETHASH_IO_MEMO_MISMATCH,
ethash_io_prepare("./test_ethash_directory/", seedhash, &f, 64, false)
);
BOOST_REQUIRE(f);
// let's make sure that the directory was created
BOOST_REQUIRE(fs::is_directory(fs::path("./test_ethash_directory/")));
// cleanup
fclose(f);
fs::remove_all("./test_ethash_directory/");
}
BOOST_AUTO_TEST_CASE(test_ethash_io_memo_file_match) {
uint64_t full_size;
uint64_t cache_size;
ethash_h256_t seed;
ethash_h256_t hash;
FILE* f;
memcpy(&seed, "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~", 32);
memcpy(&hash, "~~~X~~~~~~~~~~~~~~~~~~~~~~~~~~~~", 32);
cache_size = 1024;
full_size = 1024 * 32;
ethash_light_t light = ethash_light_new_internal(cache_size, &seed);
ethash_full_t full = ethash_full_new_internal(
"./test_ethash_directory/",
seed,
full_size,
light,
NULL
);
BOOST_ASSERT(full);
// let's make sure that the directory was created
BOOST_REQUIRE(fs::is_directory(fs::path("./test_ethash_directory/")));
// delete the full here so that memory is properly unmapped and FILE handler freed
ethash_full_delete(full);
// and check that we have a match when checking again
BOOST_REQUIRE_EQUAL(
ETHASH_IO_MEMO_MATCH,
ethash_io_prepare("./test_ethash_directory/", seed, &f, full_size, false)
);
BOOST_REQUIRE(f);
// cleanup
fclose(f);
ethash_light_delete(light);
fs::remove_all("./test_ethash_directory/");
}
BOOST_AUTO_TEST_CASE(test_ethash_io_memo_file_size_mismatch) {
static const int blockn = 0;
ethash_h256_t seedhash = ethash_get_seedhash(blockn);
FILE *f = NULL;
BOOST_REQUIRE_EQUAL(
ETHASH_IO_MEMO_MISMATCH,
ethash_io_prepare("./test_ethash_directory/", seedhash, &f, 64, false)
);
BOOST_REQUIRE(f);
fclose(f);
// let's make sure that the directory was created
BOOST_REQUIRE(fs::is_directory(fs::path("./test_ethash_directory/")));
// and check that we get the size mismatch detected if we request diffferent size
BOOST_REQUIRE_EQUAL(
ETHASH_IO_MEMO_SIZE_MISMATCH,
ethash_io_prepare("./test_ethash_directory/", seedhash, &f, 65, false)
);
// cleanup
fs::remove_all("./test_ethash_directory/");
}
BOOST_AUTO_TEST_CASE(test_ethash_get_default_dirname) {
char result[256];
// this is really not an easy thing to test for in a unit test
// TODO: Improve this test ...
#ifdef _WIN32
char homedir[256];
BOOST_REQUIRE(SUCCEEDED(SHGetFolderPathA(NULL, CSIDL_PROFILE, NULL, 0, (CHAR*)homedir)));
BOOST_REQUIRE(ethash_get_default_dirname(result, 256));
std::string res = std::string(homedir) + std::string("\\AppData\\Local\\Ethash\\");
#else
char* homedir = getenv("HOME");
BOOST_REQUIRE(ethash_get_default_dirname(result, 256));
std::string res = std::string(homedir) + std::string("/.ethash/");
#endif
BOOST_CHECK_MESSAGE(strcmp(res.c_str(), result) == 0,
"Expected \"" + res + "\" but got \"" + std::string(result) + "\""
);
}
BOOST_AUTO_TEST_CASE(light_and_full_client_checks) {
uint64_t full_size;
uint64_t cache_size;
ethash_h256_t seed;
ethash_h256_t hash;
ethash_h256_t difficulty;
ethash_return_value_t light_out;
ethash_return_value_t full_out;
memcpy(&seed, "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~", 32);
memcpy(&hash, "~~~X~~~~~~~~~~~~~~~~~~~~~~~~~~~~", 32);
// Set the difficulty
ethash_h256_set(&difficulty, 0, 197);
ethash_h256_set(&difficulty, 1, 90);
for (int i = 2; i < 32; i++)
ethash_h256_set(&difficulty, i, 255);
cache_size = 1024;
full_size = 1024 * 32;
ethash_light_t light = ethash_light_new_internal(cache_size, &seed);
ethash_full_t full = ethash_full_new_internal(
"./test_ethash_directory/",
seed,
full_size,
light,
NULL
);
BOOST_ASSERT(full);
{
const std::string
expected = "2da2b506f21070e1143d908e867962486d6b0a02e31d468fd5e3a7143aafa76a14201f63374314e2a6aaf84ad2eb57105dea3378378965a1b3873453bb2b78f9a8620b2ebeca41fbc773bb837b5e724d6eb2de570d99858df0d7d97067fb8103b21757873b735097b35d3bea8fd1c359a9e8a63c1540c76c9784cf8d975e995ca8620b2ebeca41fbc773bb837b5e724d6eb2de570d99858df0d7d97067fb8103b21757873b735097b35d3bea8fd1c359a9e8a63c1540c76c9784cf8d975e995ca8620b2ebeca41fbc773bb837b5e724d6eb2de570d99858df0d7d97067fb8103b21757873b735097b35d3bea8fd1c359a9e8a63c1540c76c9784cf8d975e995c259440b89fa3481c2c33171477c305c8e1e421f8d8f6d59585449d0034f3e421808d8da6bbd0b6378f567647cc6c4ba6c434592b198ad444e7284905b7c6adaf70bf43ec2daa7bd5e8951aa609ab472c124cf9eba3d38cff5091dc3f58409edcc386c743c3bd66f92408796ee1e82dd149eaefbf52b00ce33014a6eb3e50625413b072a58bc01da28262f42cbe4f87d4abc2bf287d15618405a1fe4e386fcdafbb171064bd99901d8f81dd6789396ce5e364ac944bbbd75a7827291c70b42d26385910cd53ca535ab29433dd5c5714d26e0dce95514c5ef866329c12e958097e84462197c2b32087849dab33e88b11da61d52f9dbc0b92cc61f742c07dbbf751c49d7678624ee60dfbe62e5e8c47a03d8247643f3d16ad8c8e663953bcda1f59d7e2d4a9bf0768e789432212621967a8f41121ad1df6ae1fa78782530695414c6213942865b2730375019105cae91a4c17a558d4b63059661d9f108362143107babe0b848de412e4da59168cce82bfbff3c99e022dd6ac1e559db991f2e3f7bb910cefd173e65ed00a8d5d416534e2c8416ff23977dbf3eb7180b75c71580d08ce95efeb9b0afe904ea12285a392aff0c8561ff79fca67f694a62b9e52377485c57cc3598d84cac0a9d27960de0cc31ff9bbfe455acaa62c8aa5d2cce96f345da9afe843d258a99c4eaf3650fc62efd81c7b81cd0d534d2d71eeda7a6e315d540b4473c80f8730037dc2ae3e47b986240cfc65ccc565f0d8cde0bc68a57e39a271dda57440b3598bee19f799611d25731a96b5dbbbefdff6f4f656161462633030d62560ea4e9c161cf78fc96a2ca5aaa32453a6c5dea206f766244e8c9d9a8dc61185ce37f1fc804459c5f07434f8ecb34141b8dcae7eae704c950b55556c5f40140c3714b45eddb02637513268778cbf937a33e4e33183685f9deb31ef54e90161e76d969587dd782eaa94e289420e7c2ee908517f5893a26fdb5873d68f92d118d4bcf98d7a4916794d6ab290045e30f9ea00ca547c584b8482b0331ba1539a0f2714fddc3a0b06b0cfbb6a607b8339c39bcfd6640b1f653e9d70ef6c985b",
actual = bytesToHexString((uint8_t const *) light->cache, cache_size);
BOOST_REQUIRE_MESSAGE(expected == actual,
"\nexpected: " << expected.c_str() << "\n"
<< "actual: " << actual.c_str() << "\n");
}
{
node node;
ethash_calculate_dag_item(&node, 0, light);
const std::string
actual = bytesToHexString((uint8_t const *) &node, sizeof(node)),
expected = "b1698f829f90b35455804e5185d78f549fcb1bdce2bee006d4d7e68eb154b596be1427769eb1c3c3e93180c760af75f81d1023da6a0ffbe321c153a7c0103597";
BOOST_REQUIRE_MESSAGE(actual == expected,
"\n" << "expected: " << expected.c_str() << "\n"
<< "actual: " << actual.c_str() << "\n");
}
{
for (int i = 0; i < full_size / sizeof(node); ++i) {
for (uint32_t j = 0; j < 32; ++j) {
node expected_node;
ethash_calculate_dag_item(&expected_node, j, light);
const std::string
actual = bytesToHexString((uint8_t const *) &(full->data[j]), sizeof(node)),
expected = bytesToHexString((uint8_t const *) &expected_node, sizeof(node));
BOOST_REQUIRE_MESSAGE(actual == expected,
"\ni: " << j << "\n"
<< "expected: " << expected.c_str() << "\n"
<< "actual: " << actual.c_str() << "\n");
}
}
}
{
uint64_t nonce = 0x7c7c597c;
full_out = ethash_full_compute(full, hash, nonce);
BOOST_REQUIRE(full_out.success);
light_out = ethash_light_compute_internal(light, full_size, hash, nonce);
BOOST_REQUIRE(light_out.success);
const std::string
light_result_string = blockhashToHexString(&light_out.result),
full_result_string = blockhashToHexString(&full_out.result);
BOOST_REQUIRE_MESSAGE(light_result_string == full_result_string,
"\nlight result: " << light_result_string.c_str() << "\n"
<< "full result: " << full_result_string.c_str() << "\n");
const std::string
light_mix_hash_string = blockhashToHexString(&light_out.mix_hash),
full_mix_hash_string = blockhashToHexString(&full_out.mix_hash);
BOOST_REQUIRE_MESSAGE(full_mix_hash_string == light_mix_hash_string,
"\nlight mix hash: " << light_mix_hash_string.c_str() << "\n"
<< "full mix hash: " << full_mix_hash_string.c_str() << "\n");
ethash_h256_t check_hash;
ethash_quick_hash(&check_hash, &hash, nonce, &full_out.mix_hash);
const std::string check_hash_string = blockhashToHexString(&check_hash);
BOOST_REQUIRE_MESSAGE(check_hash_string == full_result_string,
"\ncheck hash string: " << check_hash_string.c_str() << "\n"
<< "full result: " << full_result_string.c_str() << "\n");
}
{
full_out = ethash_full_compute(full, hash, 5);
BOOST_REQUIRE(full_out.success);
std::string
light_result_string = blockhashToHexString(&light_out.result),
full_result_string = blockhashToHexString(&full_out.result);
BOOST_REQUIRE_MESSAGE(light_result_string != full_result_string,
"\nlight result and full result should differ: " << light_result_string.c_str() << "\n");
light_out = ethash_light_compute_internal(light, full_size, hash, 5);
BOOST_REQUIRE(light_out.success);
light_result_string = blockhashToHexString(&light_out.result);
BOOST_REQUIRE_MESSAGE(light_result_string == full_result_string,
"\nlight result and full result should be the same\n"
<< "light result: " << light_result_string.c_str() << "\n"
<< "full result: " << full_result_string.c_str() << "\n");
std::string
light_mix_hash_string = blockhashToHexString(&light_out.mix_hash),
full_mix_hash_string = blockhashToHexString(&full_out.mix_hash);
BOOST_REQUIRE_MESSAGE(full_mix_hash_string == light_mix_hash_string,
"\nlight mix hash: " << light_mix_hash_string.c_str() << "\n"
<< "full mix hash: " << full_mix_hash_string.c_str() << "\n");
BOOST_REQUIRE_MESSAGE(ethash_check_difficulty(&full_out.result, &difficulty),
"ethash_check_difficulty failed"
);
BOOST_REQUIRE_MESSAGE(ethash_quick_check_difficulty(&hash, 5U, &full_out.mix_hash, &difficulty),
"ethash_quick_check_difficulty failed"
);
}
ethash_light_delete(light);
ethash_full_delete(full);
fs::remove_all("./test_ethash_directory/");
}
BOOST_AUTO_TEST_CASE(ethash_full_new_when_dag_exists_with_wrong_size) {
uint64_t full_size;
uint64_t cache_size;
ethash_h256_t seed;
ethash_h256_t hash;
ethash_return_value_t full_out;
ethash_return_value_t light_out;
memcpy(&seed, "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~", 32);
memcpy(&hash, "~~~X~~~~~~~~~~~~~~~~~~~~~~~~~~~~", 32);
cache_size = 1024;
full_size = 1024 * 32;
// first make a DAG file of "wrong size"
FILE *f;
BOOST_REQUIRE_EQUAL(
ETHASH_IO_MEMO_MISMATCH,
ethash_io_prepare("./test_ethash_directory/", seed, &f, 64, false)
);
fclose(f);
// then create new DAG, which should detect the wrong size and force create a new file
ethash_light_t light = ethash_light_new_internal(cache_size, &seed);
BOOST_ASSERT(light);
ethash_full_t full = ethash_full_new_internal(
"./test_ethash_directory/",
seed,
full_size,
light,
NULL
);
BOOST_ASSERT(full);
{
uint64_t nonce = 0x7c7c597c;
full_out = ethash_full_compute(full, hash, nonce);
BOOST_REQUIRE(full_out.success);
light_out = ethash_light_compute_internal(light, full_size, hash, nonce);
BOOST_REQUIRE(light_out.success);
const std::string
light_result_string = blockhashToHexString(&light_out.result),
full_result_string = blockhashToHexString(&full_out.result);
BOOST_REQUIRE_MESSAGE(light_result_string == full_result_string,
"\nlight result: " << light_result_string.c_str() << "\n"
<< "full result: " << full_result_string.c_str() << "\n");
const std::string
light_mix_hash_string = blockhashToHexString(&light_out.mix_hash),
full_mix_hash_string = blockhashToHexString(&full_out.mix_hash);
BOOST_REQUIRE_MESSAGE(full_mix_hash_string == light_mix_hash_string,
"\nlight mix hash: " << light_mix_hash_string.c_str() << "\n"
<< "full mix hash: " << full_mix_hash_string.c_str() << "\n");
ethash_h256_t check_hash;
ethash_quick_hash(&check_hash, &hash, nonce, &full_out.mix_hash);
const std::string check_hash_string = blockhashToHexString(&check_hash);
BOOST_REQUIRE_MESSAGE(check_hash_string == full_result_string,
"\ncheck hash string: " << check_hash_string.c_str() << "\n"
<< "full result: " << full_result_string.c_str() << "\n");
}
ethash_light_delete(light);
ethash_full_delete(full);
fs::remove_all("./test_ethash_directory/");
}
static bool g_executed = false;
static unsigned g_prev_progress = 0;
static int test_full_callback(unsigned _progress)
{
g_executed = true;
BOOST_CHECK(_progress >= g_prev_progress);
g_prev_progress = _progress;
return 0;
}
static int test_full_callback_that_fails(unsigned _progress)
{
return 1;
}
static int test_full_callback_create_incomplete_dag(unsigned _progress)
{
if (_progress >= 30) {
return 1;
}
return 0;
}
BOOST_AUTO_TEST_CASE(full_client_callback) {
uint64_t full_size;
uint64_t cache_size;
ethash_h256_t seed;
ethash_h256_t hash;
memcpy(&seed, "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~", 32);
memcpy(&hash, "~~~X~~~~~~~~~~~~~~~~~~~~~~~~~~~~", 32);
cache_size = 1024;
full_size = 1024 * 32;
ethash_light_t light = ethash_light_new_internal(cache_size, &seed);
ethash_full_t full = ethash_full_new_internal(
"./test_ethash_directory/",
seed,
full_size,
light,
test_full_callback
);
BOOST_ASSERT(full);
BOOST_CHECK(g_executed);
BOOST_REQUIRE_EQUAL(g_prev_progress, 100);
ethash_full_delete(full);
ethash_light_delete(light);
fs::remove_all("./test_ethash_directory/");
}
BOOST_AUTO_TEST_CASE(failing_full_client_callback) {
uint64_t full_size;
uint64_t cache_size;
ethash_h256_t seed;
ethash_h256_t hash;
memcpy(&seed, "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~", 32);
memcpy(&hash, "~~~X~~~~~~~~~~~~~~~~~~~~~~~~~~~~", 32);
cache_size = 1024;
full_size = 1024 * 32;
ethash_light_t light = ethash_light_new_internal(cache_size, &seed);
ethash_full_t full = ethash_full_new_internal(
"./test_ethash_directory/",
seed,
full_size,
light,
test_full_callback_that_fails
);
BOOST_ASSERT(!full);
ethash_light_delete(light);
fs::remove_all("./test_ethash_directory/");
}
BOOST_AUTO_TEST_CASE(test_incomplete_dag_file) {
uint64_t full_size;
uint64_t cache_size;
ethash_h256_t seed;
ethash_h256_t hash;
memcpy(&seed, "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~", 32);
memcpy(&hash, "~~~X~~~~~~~~~~~~~~~~~~~~~~~~~~~~", 32);
cache_size = 1024;
full_size = 1024 * 32;
ethash_light_t light = ethash_light_new_internal(cache_size, &seed);
// create a full but stop at 30%, so no magic number is written
ethash_full_t full = ethash_full_new_internal(
"./test_ethash_directory/",
seed,
full_size,
light,
test_full_callback_create_incomplete_dag
);
BOOST_ASSERT(!full);
FILE *f = NULL;
// confirm that we get a size_mismatch because the magic number is missing
BOOST_REQUIRE_EQUAL(
ETHASH_IO_MEMO_SIZE_MISMATCH,
ethash_io_prepare("./test_ethash_directory/", seed, &f, full_size, false)
);
ethash_light_delete(light);
fs::remove_all("./test_ethash_directory/");
}
BOOST_AUTO_TEST_CASE(test_block22_verification) {
// from POC-9 testnet, epoch 0
ethash_light_t light = ethash_light_new(22);
ethash_h256_t seedhash = stringToBlockhash("372eca2454ead349c3df0ab5d00b0b706b23e49d469387db91811cee0358fc6d");
BOOST_ASSERT(light);
ethash_return_value_t ret = ethash_light_compute(
light,
seedhash,
0x495732e0ed7a801cU
);
BOOST_REQUIRE_EQUAL(blockhashToHexString(&ret.result), "00000b184f1fdd88bfd94c86c39e65db0c36144d5e43f745f722196e730cb614");
ethash_h256_t difficulty = ethash_h256_static_init(0x2, 0x5, 0x40);
BOOST_REQUIRE(ethash_check_difficulty(&ret.result, &difficulty));
ethash_light_delete(light);
}
BOOST_AUTO_TEST_CASE(test_block30001_verification) {
// from POC-9 testnet, epoch 1
ethash_light_t light = ethash_light_new(30001);
ethash_h256_t seedhash = stringToBlockhash("7e44356ee3441623bc72a683fd3708fdf75e971bbe294f33e539eedad4b92b34");
BOOST_ASSERT(light);
ethash_return_value_t ret = ethash_light_compute(
light,
seedhash,
0x318df1c8adef7e5eU
);
ethash_h256_t difficulty = ethash_h256_static_init(0x17, 0x62, 0xff);
BOOST_REQUIRE(ethash_check_difficulty(&ret.result, &difficulty));
ethash_light_delete(light);
}
BOOST_AUTO_TEST_CASE(test_block60000_verification) {
// from POC-9 testnet, epoch 2
ethash_light_t light = ethash_light_new(60000);
ethash_h256_t seedhash = stringToBlockhash("5fc898f16035bf5ac9c6d9077ae1e3d5fc1ecc3c9fd5bee8bb00e810fdacbaa0");
BOOST_ASSERT(light);
ethash_return_value_t ret = ethash_light_compute(
light,
seedhash,
0x50377003e5d830caU
);
ethash_h256_t difficulty = ethash_h256_static_init(0x25, 0xa6, 0x1e);
BOOST_REQUIRE(ethash_check_difficulty(&ret.result, &difficulty));
ethash_light_delete(light);
}
// Test of Full DAG creation with the minimal ethash.h API.
// Commented out since travis tests would take too much time.
// Uncomment and run on your own machine if you want to confirm
// it works fine.
#if 0
static int progress_cb(unsigned _progress)
{
printf("CREATING DAG. PROGRESS: %u\n", _progress);
fflush(stdout);
return 0;
}
BOOST_AUTO_TEST_CASE(full_dag_test) {
ethash_light_t light = ethash_light_new(55);
BOOST_ASSERT(light);
ethash_full_t full = ethash_full_new(light, progress_cb);
BOOST_ASSERT(full);
ethash_light_delete(light);
ethash_full_delete(full);
}
#endif

View File

@ -0,0 +1,32 @@
#!/bin/bash
# Strict mode
set -e
VALGRIND_ARGS="--tool=memcheck"
VALGRIND_ARGS+=" --leak-check=yes"
VALGRIND_ARGS+=" --track-origins=yes"
VALGRIND_ARGS+=" --show-reachable=yes"
VALGRIND_ARGS+=" --num-callers=20"
VALGRIND_ARGS+=" --track-fds=yes"
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE"
done
TEST_DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
rm -rf $TEST_DIR/build
mkdir -p $TEST_DIR/build
cd $TEST_DIR/build ;
cmake ../../.. > /dev/null
make Test
./test/c/Test
# If we have valgrind also run memory check tests
if hash valgrind 2>/dev/null; then
echo "======== Running tests under valgrind ========";
cd $TEST_DIR/build/ && valgrind $VALGRIND_ARGS ./test/c/Test
fi

View File

@ -0,0 +1 @@
python-virtual-env/

View File

@ -0,0 +1,3 @@
pyethereum==0.7.522
nose==1.3.4
pysha3==0.3

View File

@ -0,0 +1,30 @@
#!/bin/bash
# Strict mode
set -e
if [ -x "$(which virtualenv2)" ] ; then
VIRTUALENV_EXEC=virtualenv2
elif [ -x "$(which virtualenv)" ] ; then
VIRTUALENV_EXEC=virtualenv
else
echo "Could not find a suitable version of virtualenv"
false
fi
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE"
done
TEST_DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
[ -d $TEST_DIR/python-virtual-env ] || $VIRTUALENV_EXEC --system-site-packages $TEST_DIR/python-virtual-env
source $TEST_DIR/python-virtual-env/bin/activate
pip install -r $TEST_DIR/requirements.txt > /dev/null
# force installation of nose in virtualenv even if existing in thereuser's system
pip install nose -I
pip install --upgrade --no-deps --force-reinstall -e $TEST_DIR/../..
cd $TEST_DIR
nosetests --with-doctest -v --nocapture

View File

@ -0,0 +1,105 @@
import pyethash
from random import randint
def test_get_cache_size_not_None():
for _ in range(100):
block_num = randint(0,12456789)
out = pyethash.get_cache_size(block_num)
assert out != None
def test_get_full_size_not_None():
for _ in range(100):
block_num = randint(0,12456789)
out = pyethash.get_full_size(block_num)
assert out != None
def test_get_cache_size_based_on_EPOCH():
for _ in range(100):
block_num = randint(0,12456789)
out1 = pyethash.get_cache_size(block_num)
out2 = pyethash.get_cache_size((block_num // pyethash.EPOCH_LENGTH) * pyethash.EPOCH_LENGTH)
assert out1 == out2
def test_get_full_size_based_on_EPOCH():
for _ in range(100):
block_num = randint(0,12456789)
out1 = pyethash.get_full_size(block_num)
out2 = pyethash.get_full_size((block_num // pyethash.EPOCH_LENGTH) * pyethash.EPOCH_LENGTH)
assert out1 == out2
# See light_and_full_client_checks in test.cpp
def test_mkcache_is_as_expected():
actual = pyethash.mkcache_bytes(
1024,
"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~").encode('hex')
expected = "2da2b506f21070e1143d908e867962486d6b0a02e31d468fd5e3a7143aafa76a14201f63374314e2a6aaf84ad2eb57105dea3378378965a1b3873453bb2b78f9a8620b2ebeca41fbc773bb837b5e724d6eb2de570d99858df0d7d97067fb8103b21757873b735097b35d3bea8fd1c359a9e8a63c1540c76c9784cf8d975e995ca8620b2ebeca41fbc773bb837b5e724d6eb2de570d99858df0d7d97067fb8103b21757873b735097b35d3bea8fd1c359a9e8a63c1540c76c9784cf8d975e995ca8620b2ebeca41fbc773bb837b5e724d6eb2de570d99858df0d7d97067fb8103b21757873b735097b35d3bea8fd1c359a9e8a63c1540c76c9784cf8d975e995c259440b89fa3481c2c33171477c305c8e1e421f8d8f6d59585449d0034f3e421808d8da6bbd0b6378f567647cc6c4ba6c434592b198ad444e7284905b7c6adaf70bf43ec2daa7bd5e8951aa609ab472c124cf9eba3d38cff5091dc3f58409edcc386c743c3bd66f92408796ee1e82dd149eaefbf52b00ce33014a6eb3e50625413b072a58bc01da28262f42cbe4f87d4abc2bf287d15618405a1fe4e386fcdafbb171064bd99901d8f81dd6789396ce5e364ac944bbbd75a7827291c70b42d26385910cd53ca535ab29433dd5c5714d26e0dce95514c5ef866329c12e958097e84462197c2b32087849dab33e88b11da61d52f9dbc0b92cc61f742c07dbbf751c49d7678624ee60dfbe62e5e8c47a03d8247643f3d16ad8c8e663953bcda1f59d7e2d4a9bf0768e789432212621967a8f41121ad1df6ae1fa78782530695414c6213942865b2730375019105cae91a4c17a558d4b63059661d9f108362143107babe0b848de412e4da59168cce82bfbff3c99e022dd6ac1e559db991f2e3f7bb910cefd173e65ed00a8d5d416534e2c8416ff23977dbf3eb7180b75c71580d08ce95efeb9b0afe904ea12285a392aff0c8561ff79fca67f694a62b9e52377485c57cc3598d84cac0a9d27960de0cc31ff9bbfe455acaa62c8aa5d2cce96f345da9afe843d258a99c4eaf3650fc62efd81c7b81cd0d534d2d71eeda7a6e315d540b4473c80f8730037dc2ae3e47b986240cfc65ccc565f0d8cde0bc68a57e39a271dda57440b3598bee19f799611d25731a96b5dbbbefdff6f4f656161462633030d62560ea4e9c161cf78fc96a2ca5aaa32453a6c5dea206f766244e8c9d9a8dc61185ce37f1fc804459c5f07434f8ecb34141b8dcae7eae704c950b55556c5f40140c3714b45eddb02637513268778cbf937a33e4e33183685f9deb31ef54e90161e76d969587dd782eaa94e289420e7c2ee908517f5893a26fdb5873d68f92d118d4bcf98d7a4916794d6ab290045e30f9ea00ca547c584b8482b0331ba1539a0f2714fddc3a0b06b0cfbb6a607b8339c39bcfd6640b1f653e9d70ef6c985b"
assert actual == expected
def test_calc_dataset_is_not_None():
cache = pyethash.mkcache_bytes(
1024,
"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
assert pyethash.calc_dataset_bytes(1024 * 32, cache) != None
def test_light_and_full_agree():
cache = pyethash.mkcache_bytes(
1024,
"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
full_size = 1024 * 32
header = "~~~~~X~~~~~~~~~~~~~~~~~~~~~~~~~~"
light_result = pyethash.hashimoto_light(full_size, cache, header, 0)
dataset = pyethash.calc_dataset_bytes(full_size, cache)
full_result = pyethash.hashimoto_full(dataset, header, 0)
assert light_result["mix digest"] != None
assert len(light_result["mix digest"]) == 32
assert light_result["mix digest"] == full_result["mix digest"]
assert light_result["result"] != None
assert len(light_result["result"]) == 32
assert light_result["result"] == full_result["result"]
def int_to_bytes(i):
b = []
for _ in range(32):
b.append(chr(i & 0xff))
i >>= 8
b.reverse()
return "".join(b)
def test_mining_basic():
easy_difficulty = int_to_bytes(2**256 - 1)
assert easy_difficulty.encode('hex') == 'f' * 64
cache = pyethash.mkcache_bytes(
1024,
"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
full_size = 1024 * 32
header = "~~~~~X~~~~~~~~~~~~~~~~~~~~~~~~~~"
dataset = pyethash.calc_dataset_bytes(full_size, cache)
# Check type of outputs
assert type(pyethash.mine(dataset,header,easy_difficulty)) == dict
assert type(pyethash.mine(dataset,header,easy_difficulty)["nonce"]) == long
assert type(pyethash.mine(dataset,header,easy_difficulty)["mix digest"]) == str
assert type(pyethash.mine(dataset,header,easy_difficulty)["result"]) == str
def test_mining_doesnt_always_return_the_same_value():
easy_difficulty1 = int_to_bytes(int(2**256 * 0.999))
# 1 in 1000 difficulty
easy_difficulty2 = int_to_bytes(int(2**256 * 0.001))
assert easy_difficulty1 != easy_difficulty2
cache = pyethash.mkcache_bytes(
1024,
"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
full_size = 1024 * 32
header = "~~~~~X~~~~~~~~~~~~~~~~~~~~~~~~~~"
dataset = pyethash.calc_dataset_bytes(full_size, cache)
# Check type of outputs
assert pyethash.mine(dataset, header, easy_difficulty1)['nonce'] != pyethash.mine(dataset, header, easy_difficulty2)['nonce']
def test_get_seedhash():
assert pyethash.get_seedhash(0).encode('hex') == '0' * 64
import hashlib, sha3
expected = pyethash.get_seedhash(0)
#print "checking seed hashes:",
for i in range(0, 30000*2048, 30000):
#print i // 30000,
assert pyethash.get_seedhash(i) == expected
expected = hashlib.sha3_256(expected).digest()

View File

@ -0,0 +1,32 @@
#!/bin/bash
# Strict mode
set -e
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE"
done
TEST_DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
echo -e "\n################# Testing JS ##################"
# TODO: Use mocha and real testing tools instead of rolling our own
cd $TEST_DIR/../js
if [ -x "$(which nodejs)" ] ; then
nodejs test.js
fi
if [ -x "$(which node)" ] ; then
node test.js
fi
echo -e "\n################# Testing C ##################"
$TEST_DIR/c/test.sh
# Temporarily commenting out python tests until they conform to the API
#echo -e "\n################# Testing Python ##################"
#$TEST_DIR/python/test.sh
echo "################# Testing Go ##################"
cd $TEST_DIR/.. && go test -timeout 9999s

Some files were not shown because too many files have changed in this diff Show More