From e5a24bdf698f8861d68a0c41cd6796a11d0857bd Mon Sep 17 00:00:00 2001 From: Your Name Date: Tue, 23 Apr 2024 12:32:40 +0900 Subject: [PATCH] all: fix packages and comments --- accounts/abi/abi_test.go | 34 ++-- accounts/abi/bind/backends/simulated_test.go | 27 ++- accounts/abi/bind/base.go | 4 +- accounts/abi/bind/base_test.go | 2 +- accounts/abi/type_test.go | 4 +- accounts/accounts.go | 6 +- accounts/keystore/account_cache_test.go | 4 +- accounts/scwallet/wallet.go | 1 - accounts/usbwallet/ledger.go | 162 +++++++++--------- accounts/usbwallet/trezor.go | 18 +- build/ci.go | 4 +- cmd/devp2p/internal/ethtest/transaction.go | 2 +- cmd/ethkey/run_test.go | 4 +- cmd/evm/internal/t8ntool/block.go | 1 + cmd/evm/internal/t8ntool/transition.go | 5 +- cmd/evm/t8n_test.go | 4 +- cmd/evm/testdata/21/readme.md | 2 + cmd/p2psim/main.go | 21 +-- common/prque/lazyqueue.go | 7 +- consensus/clique/clique.go | 1 + consensus/ethash/api.go | 9 +- consensus/ethash/sealer.go | 9 +- consensus/misc/dao.go | 9 +- consensus/misc/eip1559_test.go | 2 +- console/bridge_test.go | 4 +- core/beacon/gen_ed.go | 17 ++ core/beacon/types.go | 20 ++- core/blockchain.go | 2 +- core/blockchain_test.go | 44 ++--- core/genesis_test.go | 4 +- core/mkalloc.go | 2 + core/rawdb/freezer.go | 14 +- core/rawdb/freezer_table_test.go | 2 +- core/state/pruner/pruner.go | 6 +- core/state/snapshot/generate_test.go | 2 - core/state/snapshot/snapshot.go | 8 +- core/state/statedb.go | 4 +- core/state_transition.go | 16 +- core/types/block.go | 2 +- core/types/log_test.go | 4 +- core/vm/contracts.go | 7 +- core/vm/gas_table.go | 18 +- core/vm/instructions.go | 19 +- crypto/crypto.go | 2 +- eth/api_backend.go | 2 +- eth/api_test.go | 4 +- eth/catalyst/api_test.go | 5 +- eth/downloader/api.go | 4 +- eth/downloader/downloader.go | 12 +- eth/downloader/downloader_test.go | 4 +- eth/downloader/queue.go | 7 +- eth/downloader/resultstore.go | 9 +- eth/ethconfig/config.go | 1 + eth/fetcher/tx_fetcher.go | 4 +- eth/filters/api.go | 4 +- eth/filters/filter_system.go | 2 +- eth/filters/filter_system_test.go | 4 +- eth/gasprice/feehistory.go | 9 +- eth/handler.go | 1 + eth/protocols/eth/peer.go | 4 +- eth/protocols/snap/sync_test.go | 3 +- ethclient/gethclient/gethclient.go | 2 +- ethclient/gethclient/gethclient_test.go | 4 +- ethdb/leveldb/leveldb.go | 15 +- ethstats/ethstats.go | 15 +- graphql/graphql.go | 2 +- internal/ethapi/api.go | 8 +- internal/ethapi/transaction_args_test.go | 4 +- internal/flags/helpers.go | 4 +- les/api.go | 16 +- les/api_backend.go | 2 +- les/catalyst/api.go | 15 +- les/downloader/api.go | 4 +- les/downloader/downloader.go | 44 +++-- les/downloader/queue.go | 7 +- les/downloader/resultstore.go | 9 +- les/fetcher.go | 21 ++- light/postprocess.go | 4 +- light/trie_test.go | 4 +- light/txpool.go | 9 +- log/format.go | 6 +- metrics/influxdb/influxdbv2.go | 1 + mobile/big.go | 1 + mobile/discover.go | 6 +- mobile/ethereum.go | 2 +- node/node_example_test.go | 4 +- p2p/dial.go | 11 +- p2p/discover/v4wire/v4wire_test.go | 4 +- p2p/discover/v5wire/encoding_test.go | 7 +- p2p/dnsdisc/client_test.go | 4 +- p2p/dnsdisc/tree_test.go | 4 +- p2p/enode/urlv4.go | 6 +- p2p/enr/enr.go | 2 +- p2p/message.go | 5 +- p2p/nat/nat.go | 12 +- p2p/rlpx/rlpx_test.go | 2 +- p2p/simulations/adapters/exec.go | 2 +- p2p/simulations/adapters/types.go | 3 +- p2p/simulations/mocker.go | 22 +-- p2p/transport_test.go | 4 +- rlp/decode.go | 2 +- rpc/client_test.go | 4 +- rpc/doc.go | 7 +- rpc/handler.go | 15 +- signer/core/api_test.go | 2 +- signer/core/apitypes/types.go | 2 +- tests/fuzzers/bls12381/precompile_fuzzer.go | 6 +- tests/fuzzers/difficulty/difficulty-fuzz.go | 6 +- tests/fuzzers/rangeproof/rangeproof-fuzzer.go | 6 +- tests/fuzzers/stacktrie/trie_fuzzer.go | 6 +- tests/fuzzers/trie/trie-fuzzer.go | 6 +- tests/init_test.go | 1 - trie/hasher.go | 4 +- trie/proof.go | 20 +-- trie/secure_trie.go | 18 +- trie/stacktrie.go | 9 +- trie/trie_test.go | 2 +- 117 files changed, 506 insertions(+), 525 deletions(-) diff --git a/accounts/abi/abi_test.go b/accounts/abi/abi_test.go index 33ff0bec35..d33e8cebe6 100644 --- a/accounts/abi/abi_test.go +++ b/accounts/abi/abi_test.go @@ -165,9 +165,8 @@ func TestInvalidABI(t *testing.T) { // TestConstructor tests a constructor function. // The test is based on the following contract: -// -// contract TestConstructor { -// constructor(uint256 a, uint256 b) public{} +// contract TestConstructor { +// constructor(uint256 a, uint256 b) public{} // } func TestConstructor(t *testing.T) { json := `[{ "inputs": [{"internalType": "uint256","name": "a","type": "uint256" },{ "internalType": "uint256","name": "b","type": "uint256"}],"stateMutability": "nonpayable","type": "constructor"}]` @@ -725,19 +724,16 @@ func TestBareEvents(t *testing.T) { } // TestUnpackEvent is based on this contract: -// -// contract T { -// event received(address sender, uint amount, bytes memo); -// event receivedAddr(address sender); -// function receive(bytes memo) external payable { -// received(msg.sender, msg.value, memo); -// receivedAddr(msg.sender); -// } -// } -// +// contract T { +// event received(address sender, uint amount, bytes memo); +// event receivedAddr(address sender); +// function receive(bytes memo) external payable { +// received(msg.sender, msg.value, memo); +// receivedAddr(msg.sender); +// } +// } // When receive("X") is called with sender 0x00... and value 1, it produces this tx receipt: -// -// receipt{status=1 cgas=23949 bloom=00000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000040200000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 logs=[log: b6818c8064f645cd82d99b59a1a267d6d61117ef [75fd880d39c1daf53b6547ab6cb59451fc6452d27caa90e5b6649dd8293b9eed] 000000000000000000000000376c47978271565f56deb45495afa69e59c16ab200000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000158 9ae378b6d4409eada347a5dc0c180f186cb62dc68fcc0f043425eb917335aa28 0 95d429d309bb9d753954195fe2d69bd140b4ae731b9b5b605c34323de162cf00 0]} +// receipt{status=1 cgas=23949 bloom=00000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000040200000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 logs=[log: b6818c8064f645cd82d99b59a1a267d6d61117ef [75fd880d39c1daf53b6547ab6cb59451fc6452d27caa90e5b6649dd8293b9eed] 000000000000000000000000376c47978271565f56deb45495afa69e59c16ab200000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000158 9ae378b6d4409eada347a5dc0c180f186cb62dc68fcc0f043425eb917335aa28 0 95d429d309bb9d753954195fe2d69bd140b4ae731b9b5b605c34323de162cf00 0]} func TestUnpackEvent(t *testing.T) { const abiJSON = `[{"constant":false,"inputs":[{"name":"memo","type":"bytes"}],"name":"receive","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"anonymous":false,"inputs":[{"indexed":false,"name":"sender","type":"address"},{"indexed":false,"name":"amount","type":"uint256"},{"indexed":false,"name":"memo","type":"bytes"}],"name":"received","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"sender","type":"address"}],"name":"receivedAddr","type":"event"}]` abi, err := JSON(strings.NewReader(abiJSON)) @@ -1082,9 +1078,8 @@ func TestDoubleDuplicateMethodNames(t *testing.T) { // TestDoubleDuplicateEventNames checks that if send0 already exists, there won't be a name // conflict and that the second send event will be renamed send1. // The test runs the abi of the following contract. -// -// contract DuplicateEvent { -// event send(uint256 a); +// contract DuplicateEvent { +// event send(uint256 a); // event send0(); // event send(); // } @@ -1111,8 +1106,7 @@ func TestDoubleDuplicateEventNames(t *testing.T) { // TestUnnamedEventParam checks that an event with unnamed parameters is // correctly handled. // The test runs the abi of the following contract. -// -// contract TestEvent { +// contract TestEvent { // event send(uint256, uint256); // } func TestUnnamedEventParam(t *testing.T) { diff --git a/accounts/abi/bind/backends/simulated_test.go b/accounts/abi/bind/backends/simulated_test.go index 3d36a31af3..fa99eed6a8 100644 --- a/accounts/abi/bind/backends/simulated_test.go +++ b/accounts/abi/bind/backends/simulated_test.go @@ -27,7 +27,7 @@ import ( "testing" "time" - ethereum "github.com/cryptoecc/ETH-ECC" + "github.com/cryptoecc/ETH-ECC" "github.com/cryptoecc/ETH-ECC/accounts/abi" "github.com/cryptoecc/ETH-ECC/accounts/abi/bind" "github.com/cryptoecc/ETH-ECC/common" @@ -93,17 +93,17 @@ func TestSimulatedBackend(t *testing.T) { var testKey, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291") -// the following is based on this contract: -// contract T { -// event received(address sender, uint amount, bytes memo); -// event receivedAddr(address sender); +// the following is based on this contract: +// contract T { +// event received(address sender, uint amount, bytes memo); +// event receivedAddr(address sender); // -// function receive(bytes calldata memo) external payable returns (string memory res) { -// emit received(msg.sender, msg.value, memo); -// emit receivedAddr(msg.sender); -// return "hello world"; -// } -// } +// function receive(bytes calldata memo) external payable returns (string memory res) { +// emit received(msg.sender, msg.value, memo); +// emit receivedAddr(msg.sender); +// return "hello world"; +// } +// } const abiJSON = `[ { "constant": false, "inputs": [ { "name": "memo", "type": "bytes" } ], "name": "receive", "outputs": [ { "name": "res", "type": "string" } ], "payable": true, "stateMutability": "payable", "type": "function" }, { "anonymous": false, "inputs": [ { "indexed": false, "name": "sender", "type": "address" }, { "indexed": false, "name": "amount", "type": "uint256" }, { "indexed": false, "name": "memo", "type": "bytes" } ], "name": "received", "type": "event" }, { "anonymous": false, "inputs": [ { "indexed": false, "name": "sender", "type": "address" } ], "name": "receivedAddr", "type": "event" } ]` const abiBin = `0x608060405234801561001057600080fd5b506102a0806100206000396000f3fe60806040526004361061003b576000357c010000000000000000000000000000000000000000000000000000000090048063a69b6ed014610040575b600080fd5b6100b76004803603602081101561005657600080fd5b810190808035906020019064010000000081111561007357600080fd5b82018360208201111561008557600080fd5b803590602001918460018302840111640100000000831117156100a757600080fd5b9091929391929390505050610132565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100f75780820151818401526020810190506100dc565b50505050905090810190601f1680156101245780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b60607f75fd880d39c1daf53b6547ab6cb59451fc6452d27caa90e5b6649dd8293b9eed33348585604051808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001848152602001806020018281038252848482818152602001925080828437600081840152601f19601f8201169050808301925050509550505050505060405180910390a17f46923992397eac56cf13058aced2a1871933622717e27b24eabc13bf9dd329c833604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390a16040805190810160405280600b81526020017f68656c6c6f20776f726c6400000000000000000000000000000000000000000081525090509291505056fea165627a7a72305820ff0c57dad254cfeda48c9cfb47f1353a558bccb4d1bc31da1dae69315772d29e0029` const deployedCode = `60806040526004361061003b576000357c010000000000000000000000000000000000000000000000000000000090048063a69b6ed014610040575b600080fd5b6100b76004803603602081101561005657600080fd5b810190808035906020019064010000000081111561007357600080fd5b82018360208201111561008557600080fd5b803590602001918460018302840111640100000000831117156100a757600080fd5b9091929391929390505050610132565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100f75780820151818401526020810190506100dc565b50505050905090810190601f1680156101245780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b60607f75fd880d39c1daf53b6547ab6cb59451fc6452d27caa90e5b6649dd8293b9eed33348585604051808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001848152602001806020018281038252848482818152602001925080828437600081840152601f19601f8201169050808301925050509550505050505060405180910390a17f46923992397eac56cf13058aced2a1871933622717e27b24eabc13bf9dd329c833604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390a16040805190810160405280600b81526020017f68656c6c6f20776f726c6400000000000000000000000000000000000000000081525090509291505056fea165627a7a72305820ff0c57dad254cfeda48c9cfb47f1353a558bccb4d1bc31da1dae69315772d29e0029` @@ -994,8 +994,7 @@ func TestCodeAt(t *testing.T) { } // When receive("X") is called with sender 0x00... and value 1, it produces this tx receipt: -// -// receipt{status=1 cgas=23949 bloom=00000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000040200000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 logs=[log: b6818c8064f645cd82d99b59a1a267d6d61117ef [75fd880d39c1daf53b6547ab6cb59451fc6452d27caa90e5b6649dd8293b9eed] 000000000000000000000000376c47978271565f56deb45495afa69e59c16ab200000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000158 9ae378b6d4409eada347a5dc0c180f186cb62dc68fcc0f043425eb917335aa28 0 95d429d309bb9d753954195fe2d69bd140b4ae731b9b5b605c34323de162cf00 0]} +// receipt{status=1 cgas=23949 bloom=00000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000040200000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 logs=[log: b6818c8064f645cd82d99b59a1a267d6d61117ef [75fd880d39c1daf53b6547ab6cb59451fc6452d27caa90e5b6649dd8293b9eed] 000000000000000000000000376c47978271565f56deb45495afa69e59c16ab200000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000158 9ae378b6d4409eada347a5dc0c180f186cb62dc68fcc0f043425eb917335aa28 0 95d429d309bb9d753954195fe2d69bd140b4ae731b9b5b605c34323de162cf00 0]} func TestPendingAndCallContract(t *testing.T) { testAddr := crypto.PubkeyToAddress(testKey.PublicKey) sim := simTestBackend(testAddr) @@ -1206,7 +1205,6 @@ func TestFork(t *testing.T) { Example contract to test event emission: pragma solidity >=0.7.0 <0.9.0; - contract Callable { event Called(); function Call() public { emit Called(); } @@ -1228,7 +1226,6 @@ const callableBin = "6080604052348015600f57600080fd5b5060998061001e6000396000f3f // 7. Mine two blocks to trigger a reorg. // 8. Check that the event was removed. // 9. Re-send the transaction and mine a block. -// // 10. Check that the event was reborn. func TestForkLogsReborn(t *testing.T) { testAddr := crypto.PubkeyToAddress(testKey.PublicKey) diff --git a/accounts/abi/bind/base.go b/accounts/abi/bind/base.go index 6d65f819b8..67e4db5715 100644 --- a/accounts/abi/bind/base.go +++ b/accounts/abi/bind/base.go @@ -24,13 +24,13 @@ import ( "strings" "sync" +ethereum "github.com/cryptoecc/ETH-ECC" "github.com/cryptoecc/ETH-ECC/accounts/abi" "github.com/cryptoecc/ETH-ECC/common" "github.com/cryptoecc/ETH-ECC/core/types" "github.com/cryptoecc/ETH-ECC/crypto" "github.com/cryptoecc/ETH-ECC/event" - "github.com/ethereum/go-ethereum" -) + ) const basefeeWiggleMultiplier = 2 diff --git a/accounts/abi/bind/base_test.go b/accounts/abi/bind/base_test.go index 58323fe9d0..88aa318fd2 100644 --- a/accounts/abi/bind/base_test.go +++ b/accounts/abi/bind/base_test.go @@ -24,6 +24,7 @@ import ( "strings" "testing" + "github.com/cryptoecc/ETH-ECC" "github.com/cryptoecc/ETH-ECC/accounts/abi" "github.com/cryptoecc/ETH-ECC/accounts/abi/bind" "github.com/cryptoecc/ETH-ECC/common" @@ -31,7 +32,6 @@ import ( "github.com/cryptoecc/ETH-ECC/core/types" "github.com/cryptoecc/ETH-ECC/crypto" "github.com/cryptoecc/ETH-ECC/rlp" - "github.com/ethereum/go-ethereum" "github.com/stretchr/testify/assert" ) diff --git a/accounts/abi/type_test.go b/accounts/abi/type_test.go index b1f4a4f107..93db9a51af 100644 --- a/accounts/abi/type_test.go +++ b/accounts/abi/type_test.go @@ -21,9 +21,9 @@ import ( "reflect" "testing" - "github.com/cryptoecc/ETH-ECC/common" "github.com/davecgh/go-spew/spew" -) + "github.com/cryptoecc/ETH-ECC/common" + ) // typeWithoutStringer is a alias for the Type type which simply doesn't implement // the stringer interface to allow printing type details in the tests below. diff --git a/accounts/accounts.go b/accounts/accounts.go index 343088d62b..b1e59e552e 100644 --- a/accounts/accounts.go +++ b/accounts/accounts.go @@ -177,8 +177,7 @@ type Backend interface { // safely used to calculate a signature from. // // The hash is calculated as -// -// keccak256("\x19Ethereum Signed Message:\n"${message length}${message}). +// keccak256("\x19Ethereum Signed Message:\n"${message length}${message}). // // This gives context to the signed message and prevents signing of transactions. func TextHash(data []byte) []byte { @@ -190,8 +189,7 @@ func TextHash(data []byte) []byte { // safely used to calculate a signature from. // // The hash is calculated as -// -// keccak256("\x19Ethereum Signed Message:\n"${message length}${message}). +// keccak256("\x19Ethereum Signed Message:\n"${message length}${message}). // // This gives context to the signed message and prevents signing of transactions. func TextAndHash(data []byte) ([]byte, string) { diff --git a/accounts/keystore/account_cache_test.go b/accounts/keystore/account_cache_test.go index 6045df3070..aed192fe39 100644 --- a/accounts/keystore/account_cache_test.go +++ b/accounts/keystore/account_cache_test.go @@ -27,10 +27,10 @@ import ( "time" "github.com/cespare/cp" + "github.com/davecgh/go-spew/spew" "github.com/cryptoecc/ETH-ECC/accounts" "github.com/cryptoecc/ETH-ECC/common" - "github.com/davecgh/go-spew/spew" -) + ) var ( cachetestDir, _ = filepath.Abs(filepath.Join("testdata", "keystore")) diff --git a/accounts/scwallet/wallet.go b/accounts/scwallet/wallet.go index dbcbaa5304..4a56840b9d 100644 --- a/accounts/scwallet/wallet.go +++ b/accounts/scwallet/wallet.go @@ -879,7 +879,6 @@ func (s *Session) walletStatus() (*walletStatus, error) { } // derivationPath fetches the wallet's current derivation path from the card. -// //lint:ignore U1000 needs to be added to the console interface func (s *Session) derivationPath() (accounts.DerivationPath, error) { response, err := s.Channel.transmitEncrypted(claSCWallet, insStatus, statusP1Path, 0, nil) diff --git a/accounts/usbwallet/ledger.go b/accounts/usbwallet/ledger.go index 3810b15e99..1f2a4ac8f3 100644 --- a/accounts/usbwallet/ledger.go +++ b/accounts/usbwallet/ledger.go @@ -195,18 +195,18 @@ func (w *ledgerDriver) SignTypedMessage(path accounts.DerivationPath, domainHash // // The version retrieval protocol is defined as follows: // -// CLA | INS | P1 | P2 | Lc | Le -// ----+-----+----+----+----+--- -// E0 | 06 | 00 | 00 | 00 | 04 +// CLA | INS | P1 | P2 | Lc | Le +// ----+-----+----+----+----+--- +// E0 | 06 | 00 | 00 | 00 | 04 // // With no input data, and the output data being: // -// Description | Length -// ---------------------------------------------------+-------- -// Flags 01: arbitrary data signature enabled by user | 1 byte -// Application major version | 1 byte -// Application minor version | 1 byte -// Application patch version | 1 byte +// Description | Length +// ---------------------------------------------------+-------- +// Flags 01: arbitrary data signature enabled by user | 1 byte +// Application major version | 1 byte +// Application minor version | 1 byte +// Application patch version | 1 byte func (w *ledgerDriver) ledgerVersion() ([3]byte, error) { // Send the request and wait for the response reply, err := w.ledgerExchange(ledgerOpGetConfiguration, 0, 0, nil) @@ -227,32 +227,32 @@ func (w *ledgerDriver) ledgerVersion() ([3]byte, error) { // // The address derivation protocol is defined as follows: // -// CLA | INS | P1 | P2 | Lc | Le -// ----+-----+----+----+-----+--- -// E0 | 02 | 00 return address -// 01 display address and confirm before returning -// | 00: do not return the chain code -// | 01: return the chain code -// | var | 00 +// CLA | INS | P1 | P2 | Lc | Le +// ----+-----+----+----+-----+--- +// E0 | 02 | 00 return address +// 01 display address and confirm before returning +// | 00: do not return the chain code +// | 01: return the chain code +// | var | 00 // // Where the input data is: // -// Description | Length -// -------------------------------------------------+-------- -// Number of BIP 32 derivations to perform (max 10) | 1 byte -// First derivation index (big endian) | 4 bytes -// ... | 4 bytes -// Last derivation index (big endian) | 4 bytes +// Description | Length +// -------------------------------------------------+-------- +// Number of BIP 32 derivations to perform (max 10) | 1 byte +// First derivation index (big endian) | 4 bytes +// ... | 4 bytes +// Last derivation index (big endian) | 4 bytes // // And the output data is: // -// Description | Length -// ------------------------+------------------- -// Public Key length | 1 byte -// Uncompressed Public Key | arbitrary -// Ethereum address length | 1 byte -// Ethereum address | 40 bytes hex ascii -// Chain code if requested | 32 bytes +// Description | Length +// ------------------------+------------------- +// Public Key length | 1 byte +// Uncompressed Public Key | arbitrary +// Ethereum address length | 1 byte +// Ethereum address | 40 bytes hex ascii +// Chain code if requested | 32 bytes func (w *ledgerDriver) ledgerDerive(derivationPath []uint32) (common.Address, error) { // Flatten the derivation path into the Ledger request path := make([]byte, 1+4*len(derivationPath)) @@ -290,35 +290,35 @@ func (w *ledgerDriver) ledgerDerive(derivationPath []uint32) (common.Address, er // // The transaction signing protocol is defined as follows: // -// CLA | INS | P1 | P2 | Lc | Le -// ----+-----+----+----+-----+--- -// E0 | 04 | 00: first transaction data block -// 80: subsequent transaction data block -// | 00 | variable | variable +// CLA | INS | P1 | P2 | Lc | Le +// ----+-----+----+----+-----+--- +// E0 | 04 | 00: first transaction data block +// 80: subsequent transaction data block +// | 00 | variable | variable // // Where the input for the first transaction block (first 255 bytes) is: // -// Description | Length -// -------------------------------------------------+---------- -// Number of BIP 32 derivations to perform (max 10) | 1 byte -// First derivation index (big endian) | 4 bytes -// ... | 4 bytes -// Last derivation index (big endian) | 4 bytes -// RLP transaction chunk | arbitrary +// Description | Length +// -------------------------------------------------+---------- +// Number of BIP 32 derivations to perform (max 10) | 1 byte +// First derivation index (big endian) | 4 bytes +// ... | 4 bytes +// Last derivation index (big endian) | 4 bytes +// RLP transaction chunk | arbitrary // // And the input for subsequent transaction blocks (first 255 bytes) are: // -// Description | Length -// ----------------------+---------- -// RLP transaction chunk | arbitrary +// Description | Length +// ----------------------+---------- +// RLP transaction chunk | arbitrary // // And the output data is: // -// Description | Length -// ------------+--------- -// signature V | 1 byte -// signature R | 32 bytes -// signature S | 32 bytes +// Description | Length +// ------------+--------- +// signature V | 1 byte +// signature R | 32 bytes +// signature S | 32 bytes func (w *ledgerDriver) ledgerSign(derivationPath []uint32, tx *types.Transaction, chainID *big.Int) (common.Address, *types.Transaction, error) { // Flatten the derivation path into the Ledger request path := make([]byte, 1+4*len(derivationPath)) @@ -392,28 +392,30 @@ func (w *ledgerDriver) ledgerSign(derivationPath []uint32, tx *types.Transaction // // The signing protocol is defined as follows: // -// CLA | INS | P1 | P2 | Lc | Le -// ----+-----+----+-----------------------------+-----+--- -// E0 | 0C | 00 | implementation version : 00 | variable | variable +// CLA | INS | P1 | P2 | Lc | Le +// ----+-----+----+-----------------------------+-----+--- +// E0 | 0C | 00 | implementation version : 00 | variable | variable // // Where the input is: // -// Description | Length -// -------------------------------------------------+---------- -// Number of BIP 32 derivations to perform (max 10) | 1 byte -// First derivation index (big endian) | 4 bytes -// ... | 4 bytes -// Last derivation index (big endian) | 4 bytes -// domain hash | 32 bytes -// message hash | 32 bytes +// Description | Length +// -------------------------------------------------+---------- +// Number of BIP 32 derivations to perform (max 10) | 1 byte +// First derivation index (big endian) | 4 bytes +// ... | 4 bytes +// Last derivation index (big endian) | 4 bytes +// domain hash | 32 bytes +// message hash | 32 bytes +// +// // // And the output data is: // -// Description | Length -// ------------+--------- -// signature V | 1 byte -// signature R | 32 bytes -// signature S | 32 bytes +// Description | Length +// ------------+--------- +// signature V | 1 byte +// signature R | 32 bytes +// signature S | 32 bytes func (w *ledgerDriver) ledgerSignTypedMessage(derivationPath []uint32, domainHash []byte, messageHash []byte) ([]byte, error) { // Flatten the derivation path into the Ledger request path := make([]byte, 1+4*len(derivationPath)) @@ -452,12 +454,12 @@ func (w *ledgerDriver) ledgerSignTypedMessage(derivationPath []uint32, domainHas // // The common transport header is defined as follows: // -// Description | Length -// --------------------------------------+---------- -// Communication channel ID (big endian) | 2 bytes -// Command tag | 1 byte -// Packet sequence index (big endian) | 2 bytes -// Payload | arbitrary +// Description | Length +// --------------------------------------+---------- +// Communication channel ID (big endian) | 2 bytes +// Command tag | 1 byte +// Packet sequence index (big endian) | 2 bytes +// Payload | arbitrary // // The Communication channel ID allows commands multiplexing over the same // physical link. It is not used for the time being, and should be set to 0101 @@ -471,15 +473,15 @@ func (w *ledgerDriver) ledgerSignTypedMessage(derivationPath []uint32, domainHas // // APDU Command payloads are encoded as follows: // -// Description | Length -// ----------------------------------- -// APDU length (big endian) | 2 bytes -// APDU CLA | 1 byte -// APDU INS | 1 byte -// APDU P1 | 1 byte -// APDU P2 | 1 byte -// APDU length | 1 byte -// Optional APDU data | arbitrary +// Description | Length +// ----------------------------------- +// APDU length (big endian) | 2 bytes +// APDU CLA | 1 byte +// APDU INS | 1 byte +// APDU P1 | 1 byte +// APDU P2 | 1 byte +// APDU length | 1 byte +// Optional APDU data | arbitrary func (w *ledgerDriver) ledgerExchange(opcode ledgerOpcode, p1 ledgerParam1, p2 ledgerParam2, data []byte) ([]byte, error) { // Construct the message payload, possibly split into multiple chunks apdu := make([]byte, 2, 7+len(data)) diff --git a/accounts/usbwallet/trezor.go b/accounts/usbwallet/trezor.go index 81afe7b85d..63c9fe3353 100644 --- a/accounts/usbwallet/trezor.go +++ b/accounts/usbwallet/trezor.go @@ -84,15 +84,15 @@ func (w *trezorDriver) Status() (string, error) { // Open implements usbwallet.driver, attempting to initialize the connection to // the Trezor hardware wallet. Initializing the Trezor is a two or three phase operation: -// - The first phase is to initialize the connection and read the wallet's -// features. This phase is invoked if the provided passphrase is empty. The -// device will display the pinpad as a result and will return an appropriate -// error to notify the user that a second open phase is needed. -// - The second phase is to unlock access to the Trezor, which is done by the -// user actually providing a passphrase mapping a keyboard keypad to the pin -// number of the user (shuffled according to the pinpad displayed). -// - If needed the device will ask for passphrase which will require calling -// open again with the actual passphrase (3rd phase) +// * The first phase is to initialize the connection and read the wallet's +// features. This phase is invoked if the provided passphrase is empty. The +// device will display the pinpad as a result and will return an appropriate +// error to notify the user that a second open phase is needed. +// * The second phase is to unlock access to the Trezor, which is done by the +// user actually providing a passphrase mapping a keyboard keypad to the pin +// number of the user (shuffled according to the pinpad displayed). +// * If needed the device will ask for passphrase which will require calling +// open again with the actual passphrase (3rd phase) func (w *trezorDriver) Open(device io.ReadWriter, passphrase string) error { w.device, w.failure = device, nil diff --git a/build/ci.go b/build/ci.go index 5fec1e9d6e..51c0eb7a83 100644 --- a/build/ci.go +++ b/build/ci.go @@ -959,9 +959,9 @@ func doWindowsInstaller(cmdline []string) { // Render NSIS scripts: Installer NSIS contains two installer sections, // first section contains the worldland binary, second section holds the dev tools. templateData := map[string]interface{}{ - "License": "COPYING", + "License": "COPYING", "Worldland": gethTool, - "DevTools": devTools, + "DevTools": devTools, } build.Render("build/nsis.worldland.nsi", filepath.Join(*workdir, "worldland.nsi"), 0644, nil) build.Render("build/nsis.install.nsh", filepath.Join(*workdir, "install.nsh"), 0644, templateData) diff --git a/cmd/devp2p/internal/ethtest/transaction.go b/cmd/devp2p/internal/ethtest/transaction.go index cebd3632fe..584026c5cb 100644 --- a/cmd/devp2p/internal/ethtest/transaction.go +++ b/cmd/devp2p/internal/ethtest/transaction.go @@ -29,7 +29,7 @@ import ( "github.com/cryptoecc/ETH-ECC/params" ) -// var faucetAddr = common.HexToAddress("0x71562b71999873DB5b286dF957af199Ec94617F7") +//var faucetAddr = common.HexToAddress("0x71562b71999873DB5b286dF957af199Ec94617F7") var faucetKey, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291") func (s *Suite) sendSuccessfulTxs(t *utesting.T) error { diff --git a/cmd/ethkey/run_test.go b/cmd/ethkey/run_test.go index c7ae94fc2d..3265073b1c 100644 --- a/cmd/ethkey/run_test.go +++ b/cmd/ethkey/run_test.go @@ -21,9 +21,9 @@ import ( "os" "testing" - "github.com/cryptoecc/ETH-ECC/internal/cmdtest" "github.com/docker/docker/pkg/reexec" -) + "github.com/cryptoecc/ETH-ECC/internal/cmdtest" + ) type testEthkey struct { *cmdtest.TestCmd diff --git a/cmd/evm/internal/t8ntool/block.go b/cmd/evm/internal/t8ntool/block.go index 544027ab6f..8f9156330c 100644 --- a/cmd/evm/internal/t8ntool/block.go +++ b/cmd/evm/internal/t8ntool/block.go @@ -28,6 +28,7 @@ import ( "github.com/cryptoecc/ETH-ECC/common/hexutil" "github.com/cryptoecc/ETH-ECC/common/math" "github.com/cryptoecc/ETH-ECC/consensus/clique" + "github.com/cryptoecc/ETH-ECC/consensus/eccpow" "github.com/cryptoecc/ETH-ECC/consensus/ethash" "github.com/cryptoecc/ETH-ECC/core/types" "github.com/cryptoecc/ETH-ECC/crypto" diff --git a/cmd/evm/internal/t8ntool/transition.go b/cmd/evm/internal/t8ntool/transition.go index 37117fddda..0cf6861aae 100644 --- a/cmd/evm/internal/t8ntool/transition.go +++ b/cmd/evm/internal/t8ntool/transition.go @@ -334,9 +334,8 @@ func (t *txWithKey) UnmarshalJSON(input []byte) error { // signUnsignedTransactions converts the input txs to canonical transactions. // // The transactions can have two forms, either -// 1. unsigned or -// 2. signed -// +// 1. unsigned or +// 2. signed // For (1), r, s, v, need so be zero, and the `secretKey` needs to be set. // If so, we sign it here and now, with the given `secretKey` // If the condition above is not met, then it's considered a signed transaction. diff --git a/cmd/evm/t8n_test.go b/cmd/evm/t8n_test.go index 048821807b..71feb2602a 100644 --- a/cmd/evm/t8n_test.go +++ b/cmd/evm/t8n_test.go @@ -24,10 +24,10 @@ import ( "strings" "testing" + "github.com/docker/docker/pkg/reexec" "github.com/cryptoecc/ETH-ECC/cmd/evm/internal/t8ntool" "github.com/cryptoecc/ETH-ECC/internal/cmdtest" - "github.com/docker/docker/pkg/reexec" -) + ) func TestMain(m *testing.M) { // Run the app if we've been exec'd as "ethkey-test" in runEthkey. diff --git a/cmd/evm/testdata/21/readme.md b/cmd/evm/testdata/21/readme.md index b70f106ffc..477710faa0 100644 --- a/cmd/evm/testdata/21/readme.md +++ b/cmd/evm/testdata/21/readme.md @@ -21,3 +21,5 @@ $ go run . b11r --input.header=testdata/21/header.json --input.txs=testdata/21/t "hash": "0x71c59102cc805dbe8741e1210ebe229a321eff144ac7276006fefe39e8357dc7" } ``` + +## Eccpow(working...) diff --git a/cmd/p2psim/main.go b/cmd/p2psim/main.go index 94aadce82c..7e998bfb61 100644 --- a/cmd/p2psim/main.go +++ b/cmd/p2psim/main.go @@ -19,20 +19,21 @@ // Here is an example of creating a 2 node network with the first node // connected to the second: // -// $ p2psim node create -// Created node01 +// $ p2psim node create +// Created node01 // -// $ p2psim node start node01 -// Started node01 +// $ p2psim node start node01 +// Started node01 // -// $ p2psim node create -// Created node02 +// $ p2psim node create +// Created node02 // -// $ p2psim node start node02 -// Started node02 +// $ p2psim node start node02 +// Started node02 +// +// $ p2psim node connect node01 node02 +// Connected node01 to node02 // -// $ p2psim node connect node01 node02 -// Connected node01 to node02 package main import ( diff --git a/common/prque/lazyqueue.go b/common/prque/lazyqueue.go index c87affc6d1..3f85d90442 100644 --- a/common/prque/lazyqueue.go +++ b/common/prque/lazyqueue.go @@ -26,10 +26,9 @@ import ( // LazyQueue is a priority queue data structure where priorities can change over // time and are only evaluated on demand. // Two callbacks are required: -// - priority evaluates the actual priority of an item -// - maxPriority gives an upper estimate for the priority in any moment between -// now and the given absolute time -// +// - priority evaluates the actual priority of an item +// - maxPriority gives an upper estimate for the priority in any moment between +// now and the given absolute time // If the upper estimate is exceeded then Update should be called for that item. // A global Refresh function should also be called periodically. type LazyQueue struct { diff --git a/consensus/clique/clique.go b/consensus/clique/clique.go index d51074de25..c3bcfb1e34 100644 --- a/consensus/clique/clique.go +++ b/consensus/clique/clique.go @@ -740,6 +740,7 @@ func encodeSigHeader(w io.Writer, header *types.Header) { header.MixDigest, header.Nonce, } + if header.BaseFee != nil { enc = append(enc, header.BaseFee) } diff --git a/consensus/ethash/api.go b/consensus/ethash/api.go index d0c2a14563..3b4bcd30e8 100644 --- a/consensus/ethash/api.go +++ b/consensus/ethash/api.go @@ -34,11 +34,10 @@ type API struct { // GetWork returns a work package for external miner. // // The work package consists of 3 strings: -// -// result[0] - 32 bytes hex encoded current block header pow-hash -// result[1] - 32 bytes hex encoded seed hash used for DAG -// result[2] - 32 bytes hex encoded boundary condition ("target"), 2^256/difficulty -// result[3] - hex encoded block number +// result[0] - 32 bytes hex encoded current block header pow-hash +// result[1] - 32 bytes hex encoded seed hash used for DAG +// result[2] - 32 bytes hex encoded boundary condition ("target"), 2^256/difficulty +// result[3] - hex encoded block number func (api *API) GetWork() ([4]string, error) { if api.ethash.remote == nil { return [4]string{}, errors.New("not supported") diff --git a/consensus/ethash/sealer.go b/consensus/ethash/sealer.go index 2b27c614be..220ed24041 100644 --- a/consensus/ethash/sealer.go +++ b/consensus/ethash/sealer.go @@ -339,11 +339,10 @@ func (s *remoteSealer) loop() { // makeWork creates a work package for external miner. // // The work package consists of 3 strings: -// -// result[0], 32 bytes hex encoded current block header pow-hash -// result[1], 32 bytes hex encoded seed hash used for DAG -// result[2], 32 bytes hex encoded boundary condition ("target"), 2^256/difficulty -// result[3], hex encoded block number +// result[0], 32 bytes hex encoded current block header pow-hash +// result[1], 32 bytes hex encoded seed hash used for DAG +// result[2], 32 bytes hex encoded boundary condition ("target"), 2^256/difficulty +// result[3], hex encoded block number func (s *remoteSealer) makeWork(block *types.Block) { hash := s.ethash.SealHash(block.Header()) s.currentWork[0] = hash.Hex() diff --git a/consensus/misc/dao.go b/consensus/misc/dao.go index 62bc267a91..d61c288c2e 100644 --- a/consensus/misc/dao.go +++ b/consensus/misc/dao.go @@ -40,11 +40,10 @@ var ( // ensure it conforms to DAO hard-fork rules. // // DAO hard-fork extension to the header validity: -// -// a) if the node is no-fork, do not accept blocks in the [fork, fork+10) range -// with the fork specific extra-data set -// b) if the node is pro-fork, require blocks in the specific range to have the -// unique extra-data set. +// a) if the node is no-fork, do not accept blocks in the [fork, fork+10) range +// with the fork specific extra-data set +// b) if the node is pro-fork, require blocks in the specific range to have the +// unique extra-data set. func VerifyDAOHeaderExtraData(config *params.ChainConfig, header *types.Header) error { // Short circuit validation if the node doesn't care about the DAO fork if config.DAOForkBlock == nil { diff --git a/consensus/misc/eip1559_test.go b/consensus/misc/eip1559_test.go index 730955a38c..06b8baf6d9 100644 --- a/consensus/misc/eip1559_test.go +++ b/consensus/misc/eip1559_test.go @@ -47,7 +47,7 @@ func copyConfig(original *params.ChainConfig) *params.ChainConfig { TerminalTotalDifficulty: original.TerminalTotalDifficulty, Ethash: original.Ethash, Clique: original.Clique, - } + } } func config() *params.ChainConfig { diff --git a/console/bridge_test.go b/console/bridge_test.go index ca6af9c2eb..f84cca8b5d 100644 --- a/console/bridge_test.go +++ b/console/bridge_test.go @@ -19,9 +19,9 @@ package console import ( "testing" - "github.com/cryptoecc/ETH-ECC/internal/jsre" "github.com/dop251/goja" -) + "github.com/cryptoecc/ETH-ECC/internal/jsre" + ) // TestUndefinedAsParam ensures that personal functions can receive // `undefined` as a parameter. diff --git a/core/beacon/gen_ed.go b/core/beacon/gen_ed.go index 135d5c7d63..270f8f3de3 100644 --- a/core/beacon/gen_ed.go +++ b/core/beacon/gen_ed.go @@ -30,6 +30,8 @@ func (e ExecutableDataV1) MarshalJSON() ([]byte, error) { BaseFeePerGas *hexutil.Big `json:"baseFeePerGas" gencodec:"required"` BlockHash common.Hash `json:"blockHash" gencodec:"required"` Transactions []hexutil.Bytes `json:"transactions" gencodec:"required"` + //Codeword hexutil.Bytes `json:"codeword" gencodec:"required"` + //CodeLength hexutil.Uint64 `json:"codelength" gencodec:"required"` } var enc ExecutableDataV1 enc.ParentHash = e.ParentHash @@ -44,6 +46,8 @@ func (e ExecutableDataV1) MarshalJSON() ([]byte, error) { enc.Timestamp = hexutil.Uint64(e.Timestamp) enc.ExtraData = e.ExtraData enc.BaseFeePerGas = (*hexutil.Big)(e.BaseFeePerGas) + //enc.Codeword = e.Codeword + //enc.CodeLength = hexutil.Uint64(e.CodeLength) enc.BlockHash = e.BlockHash if e.Transactions != nil { enc.Transactions = make([]hexutil.Bytes, len(e.Transactions)) @@ -71,6 +75,8 @@ func (e *ExecutableDataV1) UnmarshalJSON(input []byte) error { BaseFeePerGas *hexutil.Big `json:"baseFeePerGas" gencodec:"required"` BlockHash *common.Hash `json:"blockHash" gencodec:"required"` Transactions []hexutil.Bytes `json:"transactions" gencodec:"required"` + //Codeword *hexutil.Bytes `json:"codeword" gencodec:"required"` + //CodeLength *hexutil.Uint64 `json:"codelength" gencodec:"required"` } var dec ExecutableDataV1 if err := json.Unmarshal(input, &dec); err != nil { @@ -128,6 +134,17 @@ func (e *ExecutableDataV1) UnmarshalJSON(input []byte) error { return errors.New("missing required field 'blockHash' for ExecutableDataV1") } e.BlockHash = *dec.BlockHash + + /*if dec.Codeword == nil { + return errors.New("missing required field 'Codeword' for ExecutableDataV1") + } + e.Codeword = *dec.Codeword + + if dec.CodeLength == nil { + return errors.New("missing required field 'Codelength' for ExecutableDataV1") + } + e.CodeLength = uint64(*dec.CodeLength)*/ + if dec.Transactions == nil { return errors.New("missing required field 'transactions' for ExecutableDataV1") } diff --git a/core/beacon/types.go b/core/beacon/types.go index b9c080cabe..d53680a56a 100644 --- a/core/beacon/types.go +++ b/core/beacon/types.go @@ -58,6 +58,9 @@ type ExecutableDataV1 struct { BaseFeePerGas *big.Int `json:"baseFeePerGas" gencodec:"required"` BlockHash common.Hash `json:"blockHash" gencodec:"required"` Transactions [][]byte `json:"transactions" gencodec:"required"` + //Codeword []byte `json:"codeword" gencodec:"required"` + //CodeLength uint64 `json:"codelength" gencodec:"required"` + } // JSON type overrides for executableData. @@ -136,11 +139,9 @@ func decodeTransactions(enc [][]byte) ([]*types.Transaction, error) { // ExecutableDataToBlock constructs a block from executable data. // It verifies that the following fields: -// -// len(extraData) <= 32 -// uncleHash = emptyUncleHash -// difficulty = 0 -// +// len(extraData) <= 32 +// uncleHash = emptyUncleHash +// difficulty = 0 // and that the blockhash of the constructed block matches the parameters. func ExecutableDataToBlock(params ExecutableDataV1) (*types.Block, error) { txs, err := decodeTransactions(params.Transactions) @@ -150,6 +151,11 @@ func ExecutableDataToBlock(params ExecutableDataV1) (*types.Block, error) { if len(params.ExtraData) > 32 { return nil, fmt.Errorf("invalid extradata length: %v", len(params.ExtraData)) } +/* + if len(params.Codeword) > 32 { + return nil, fmt.Errorf("invalid extradata length: %v", len(params.Codeword)) + }*/ + if len(params.LogsBloom) != 256 { return nil, fmt.Errorf("invalid logsBloom length: %v", len(params.LogsBloom)) } @@ -173,6 +179,8 @@ func ExecutableDataToBlock(params ExecutableDataV1) (*types.Block, error) { BaseFee: params.BaseFeePerGas, Extra: params.ExtraData, MixDigest: params.Random, + //Codeword: params.Codeword, + //CodeLength: params.CodeLength, } block := types.NewBlockWithHeader(header).WithBody(txs, nil /* uncles */) if block.Hash() != params.BlockHash { @@ -199,5 +207,7 @@ func BlockToExecutableData(block *types.Block) *ExecutableDataV1 { Transactions: encodeTransactions(block.Transactions()), Random: block.MixDigest(), ExtraData: block.Extra(), + //Codeword: block.Codeword(), + //CodeLength: block.CodeLength(), } } diff --git a/core/blockchain.go b/core/blockchain.go index b4013a7e65..111d81df1e 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -27,7 +27,6 @@ import ( "sync" "sync/atomic" "time" - "github.com/cryptoecc/ETH-ECC/common" "github.com/cryptoecc/ETH-ECC/common/mclock" "github.com/cryptoecc/ETH-ECC/common/prque" @@ -926,6 +925,7 @@ func (bc *BlockChain) Stop() { triedb.SaveCache(bc.cacheConfig.TrieCleanJournal) } log.Info("Blockchain stopped") + } // StopInsert interrupts all insertion methods, causing them to return diff --git a/core/blockchain_test.go b/core/blockchain_test.go index a89f32b7d7..e0843d2944 100644 --- a/core/blockchain_test.go +++ b/core/blockchain_test.go @@ -1882,8 +1882,8 @@ func TestInsertReceiptChainRollback(t *testing.T) { // overtake the 'canon' chain until after it's passed canon by about 200 blocks. // // Details at: -// - https://github.com/cryptoecc/ETH-ECC/issues/18977 -// - https://github.com/cryptoecc/ETH-ECC/pull/18988 +// - https://github.com/cryptoecc/ETH-ECC/issues/18977 +// - https://github.com/cryptoecc/ETH-ECC/pull/18988 func TestLowDiffLongChain(t *testing.T) { // Generate a canonical chain to act as the main dataset engine := ethash.NewFaker() @@ -2050,8 +2050,7 @@ func testSideImport(t *testing.T, numCanonBlocksInSidechain, blocksBetweenCommon // That is: the sidechain for import contains some blocks already present in canon chain. // So the blocks are // [ Cn, Cn+1, Cc, Sn+3 ... Sm] -// -// ^ ^ ^ pruned +// ^ ^ ^ pruned func TestPrunedImportSide(t *testing.T) { //glogger := log.NewGlogHandler(log.StreamHandler(os.Stdout, log.TerminalFormat(false))) //glogger.Verbosity(3) @@ -2844,9 +2843,9 @@ func BenchmarkBlockChain_1x1000Executions(b *testing.B) { // This internally leads to a sidechain import, since the blocks trigger an // ErrPrunedAncestor error. // This may e.g. happen if -// 1. Downloader rollbacks a batch of inserted blocks and exits -// 2. Downloader starts to sync again -// 3. The blocks fetched are all known and canonical blocks +// 1. Downloader rollbacks a batch of inserted blocks and exits +// 2. Downloader starts to sync again +// 3. The blocks fetched are all known and canonical blocks func TestSideImportPrunedBlocks(t *testing.T) { // Generate a canonical chain to act as the main dataset engine := ethash.NewFaker() @@ -3363,19 +3362,20 @@ func TestDeleteRecreateSlotsAcrossManyBlocks(t *testing.T) { // TestInitThenFailCreateContract tests a pretty notorious case that happened // on mainnet over blocks 7338108, 7338110 and 7338115. -// - Block 7338108: address e771789f5cccac282f23bb7add5690e1f6ca467c is initiated -// with 0.001 ether (thus created but no code) -// - Block 7338110: a CREATE2 is attempted. The CREATE2 would deploy code on -// the same address e771789f5cccac282f23bb7add5690e1f6ca467c. However, the -// deployment fails due to OOG during initcode execution -// - Block 7338115: another tx checks the balance of -// e771789f5cccac282f23bb7add5690e1f6ca467c, and the snapshotter returned it as -// zero. +// - Block 7338108: address e771789f5cccac282f23bb7add5690e1f6ca467c is initiated +// with 0.001 ether (thus created but no code) +// - Block 7338110: a CREATE2 is attempted. The CREATE2 would deploy code on +// the same address e771789f5cccac282f23bb7add5690e1f6ca467c. However, the +// deployment fails due to OOG during initcode execution +// - Block 7338115: another tx checks the balance of +// e771789f5cccac282f23bb7add5690e1f6ca467c, and the snapshotter returned it as +// zero. // // The problem being that the snapshotter maintains a destructset, and adds items // to the destructset in case something is created "onto" an existing item. // We need to either roll back the snapDestructs, or not place it into snapDestructs // in the first place. +// func TestInitThenFailCreateContract(t *testing.T) { var ( // Generate a canonical chain to act as the main dataset @@ -3563,13 +3563,13 @@ func TestEIP2718Transition(t *testing.T) { // TestEIP1559Transition tests the following: // -// 1. A transaction whose gasFeeCap is greater than the baseFee is valid. -// 2. Gas accounting for access lists on EIP-1559 transactions is correct. -// 3. Only the transaction's tip will be received by the coinbase. -// 4. The transaction sender pays for both the tip and baseFee. -// 5. The coinbase receives only the partially realized tip when -// gasFeeCap - gasTipCap < baseFee. -// 6. Legacy transaction behave as expected (e.g. gasPrice = gasFeeCap = gasTipCap). +// 1. A transaction whose gasFeeCap is greater than the baseFee is valid. +// 2. Gas accounting for access lists on EIP-1559 transactions is correct. +// 3. Only the transaction's tip will be received by the coinbase. +// 4. The transaction sender pays for both the tip and baseFee. +// 5. The coinbase receives only the partially realized tip when +// gasFeeCap - gasTipCap < baseFee. +// 6. Legacy transaction behave as expected (e.g. gasPrice = gasFeeCap = gasTipCap). func TestEIP1559Transition(t *testing.T) { var ( aa = common.HexToAddress("0x000000000000000000000000000000000000aaaa") diff --git a/core/genesis_test.go b/core/genesis_test.go index 3076a9fb73..dc9a1e0736 100644 --- a/core/genesis_test.go +++ b/core/genesis_test.go @@ -21,14 +21,14 @@ import ( "reflect" "testing" + "github.com/davecgh/go-spew/spew" "github.com/cryptoecc/ETH-ECC/common" "github.com/cryptoecc/ETH-ECC/consensus/ethash" "github.com/cryptoecc/ETH-ECC/core/rawdb" "github.com/cryptoecc/ETH-ECC/core/vm" "github.com/cryptoecc/ETH-ECC/ethdb" "github.com/cryptoecc/ETH-ECC/params" - "github.com/davecgh/go-spew/spew" -) + ) func TestInvalidCliqueConfig(t *testing.T) { block := DefaultGoerliGenesisBlock() diff --git a/core/mkalloc.go b/core/mkalloc.go index a3430b88e3..7ad2a0a162 100644 --- a/core/mkalloc.go +++ b/core/mkalloc.go @@ -18,10 +18,12 @@ // +build none /* + The mkalloc tool creates the genesis allocation constants in genesis_alloc.go It outputs a const declaration that contains an RLP-encoded list of (address, balance) tuples. go run mkalloc.go genesis.json + */ package main diff --git a/core/rawdb/freezer.go b/core/rawdb/freezer.go index c1c7e7a2e3..fb2f8e73f8 100644 --- a/core/rawdb/freezer.go +++ b/core/rawdb/freezer.go @@ -57,10 +57,10 @@ const freezerTableSize = 2 * 1000 * 1000 * 1000 // Freezer is a memory mapped append-only database to store immutable ordered // data into flat files: // -// - The append-only nature ensures that disk writes are minimized. -// - The memory mapping ensures we can max out system memory for caching without -// reserving it for go-ethereum. This would also reduce the memory requirements -// of Geth, and thus also GC overhead. +// - The append-only nature ensures that disk writes are minimized. +// - The memory mapping ensures we can max out system memory for caching without +// reserving it for go-ethereum. This would also reduce the memory requirements +// of Geth, and thus also GC overhead. type Freezer struct { // WARNING: The `frozen` and `tail` fields are accessed atomically. On 32 bit platforms, only // 64-bit aligned fields can be atomic. The struct is guaranteed to be so aligned, @@ -188,9 +188,9 @@ func (f *Freezer) Ancient(kind string, number uint64) ([]byte, error) { // AncientRange retrieves multiple items in sequence, starting from the index 'start'. // It will return -// - at most 'max' items, -// - at least 1 item (even if exceeding the maxByteSize), but will otherwise -// return as many items as fit into maxByteSize. +// - at most 'max' items, +// - at least 1 item (even if exceeding the maxByteSize), but will otherwise +// return as many items as fit into maxByteSize. func (f *Freezer) AncientRange(kind string, start, count, maxBytes uint64) ([][]byte, error) { if table := f.tables[kind]; table != nil { return table.RetrieveItems(start, count, maxBytes) diff --git a/core/rawdb/freezer_table_test.go b/core/rawdb/freezer_table_test.go index aa42b61109..fe002205e8 100644 --- a/core/rawdb/freezer_table_test.go +++ b/core/rawdb/freezer_table_test.go @@ -29,8 +29,8 @@ import ( "testing/quick" "time" - "github.com/cryptoecc/ETH-ECC/metrics" "github.com/davecgh/go-spew/spew" + "github.com/cryptoecc/ETH-ECC/metrics" "github.com/stretchr/testify/require" ) diff --git a/core/state/pruner/pruner.go b/core/state/pruner/pruner.go index a683696215..06b3957dfe 100644 --- a/core/state/pruner/pruner.go +++ b/core/state/pruner/pruner.go @@ -66,9 +66,9 @@ var ( // Pruner is an offline tool to prune the stale state with the // help of the snapshot. The workflow of pruner is very simple: // -// - iterate the snapshot, reconstruct the relevant state -// - iterate the database, delete all other state entries which -// don't belong to the target state and the genesis state +// - iterate the snapshot, reconstruct the relevant state +// - iterate the database, delete all other state entries which +// don't belong to the target state and the genesis state // // It can take several hours(around 2 hours for mainnet) to finish // the whole pruning work. It's recommended to run this offline tool diff --git a/core/state/snapshot/generate_test.go b/core/state/snapshot/generate_test.go index e935e811aa..a533f8b27d 100644 --- a/core/state/snapshot/generate_test.go +++ b/core/state/snapshot/generate_test.go @@ -220,12 +220,10 @@ func (t *testHelper) CommitAndGenerate() (common.Hash, *diskLayer) { // - miss in the beginning // - miss in the middle // - miss in the end -// // - the contract(non-empty storage) has wrong storage slots // - wrong slots in the beginning // - wrong slots in the middle // - wrong slots in the end -// // - the contract(non-empty storage) has extra storage slots // - extra slots in the beginning // - extra slots in the middle diff --git a/core/state/snapshot/snapshot.go b/core/state/snapshot/snapshot.go index 3c26acb815..00ef09f579 100644 --- a/core/state/snapshot/snapshot.go +++ b/core/state/snapshot/snapshot.go @@ -179,10 +179,10 @@ type Tree struct { // If the memory layers in the journal do not match the disk layer (e.g. there is // a gap) or the journal is missing, there are two repair cases: // -// - if the 'recovery' parameter is true, all memory diff-layers will be discarded. -// This case happens when the snapshot is 'ahead' of the state trie. -// - otherwise, the entire snapshot is considered invalid and will be recreated on -// a background thread. +// - if the 'recovery' parameter is true, all memory diff-layers will be discarded. +// This case happens when the snapshot is 'ahead' of the state trie. +// - otherwise, the entire snapshot is considered invalid and will be recreated on +// a background thread. func New(diskdb ethdb.KeyValueStore, triedb *trie.Database, cache int, root common.Hash, async bool, rebuild bool, recovery bool) (*Tree, error) { // Create a new, empty snapshot tree snap := &Tree{ diff --git a/core/state/statedb.go b/core/state/statedb.go index 9482de1b2e..bf8a929400 100644 --- a/core/state/statedb.go +++ b/core/state/statedb.go @@ -600,8 +600,8 @@ func (s *StateDB) createObject(addr common.Address) (newobj, prev *stateObject) // CreateAccount is called during the EVM CREATE operation. The situation might arise that // a contract does the following: // -// 1. sends funds to sha(account ++ (nonce + 1)) -// 2. tx_create(sha(account ++ nonce)) (note that this gets the address of 1) +// 1. sends funds to sha(account ++ (nonce + 1)) +// 2. tx_create(sha(account ++ nonce)) (note that this gets the address of 1) // // Carrying over the balance ensures that Ether doesn't disappear. func (s *StateDB) CreateAccount(addr common.Address) { diff --git a/core/state_transition.go b/core/state_transition.go index 253f7e3cd4..97dd6e7ba3 100644 --- a/core/state_transition.go +++ b/core/state_transition.go @@ -42,10 +42,8 @@ The state transitioning model does all the necessary work to work out a valid ne 3) Create a new state object if the recipient is \0*32 4) Value transfer == If contract creation == - 4a) Attempt to run transaction data 4b) If valid, use result as code for the new state object - == end == 5) Run Script section 6) Derive new state root @@ -264,13 +262,13 @@ func (st *StateTransition) preCheck() error { // TransitionDb will transition the state by applying the current message and // returning the evm execution result with following fields. // -// - used gas: -// total gas used (including gas being refunded) -// - returndata: -// the returned data from evm -// - concrete execution error: -// various **EVM** error which aborts the execution, -// e.g. ErrOutOfGas, ErrExecutionReverted +// - used gas: +// total gas used (including gas being refunded) +// - returndata: +// the returned data from evm +// - concrete execution error: +// various **EVM** error which aborts the execution, +// e.g. ErrOutOfGas, ErrExecutionReverted // // However if any consensus issue encountered, return the error directly with // nil evm execution result. diff --git a/core/types/block.go b/core/types/block.go index 7c27f843fe..dc53b1df06 100644 --- a/core/types/block.go +++ b/core/types/block.go @@ -85,7 +85,7 @@ type Header struct { Nonce BlockNonce `json:"nonce"` // BaseFee was added by EIP-1559 and is ignored in legacy headers. - BaseFee *big.Int `json:"baseFeePerGas" rlp:"optional"` + BaseFee *big.Int `json:"baseFeePerGas" rlp:"optional"` /* TODO (MariusVanDerWijden) Add this field once needed diff --git a/core/types/log_test.go b/core/types/log_test.go index 4ee94269ad..413c2ebbbc 100644 --- a/core/types/log_test.go +++ b/core/types/log_test.go @@ -22,10 +22,10 @@ import ( "reflect" "testing" + "github.com/davecgh/go-spew/spew" "github.com/cryptoecc/ETH-ECC/common" "github.com/cryptoecc/ETH-ECC/common/hexutil" - "github.com/davecgh/go-spew/spew" -) + ) var unmarshalLogTests = map[string]struct { input string diff --git a/core/vm/contracts.go b/core/vm/contracts.go index 05bde72162..6765bdb885 100644 --- a/core/vm/contracts.go +++ b/core/vm/contracts.go @@ -264,10 +264,9 @@ var ( // modexpMultComplexity implements bigModexp multComplexity formula, as defined in EIP-198 // // def mult_complexity(x): -// -// if x <= 64: return x ** 2 -// elif x <= 1024: return x ** 2 // 4 + 96 * x - 3072 -// else: return x ** 2 // 16 + 480 * x - 199680 +// if x <= 64: return x ** 2 +// elif x <= 1024: return x ** 2 // 4 + 96 * x - 3072 +// else: return x ** 2 // 16 + 480 * x - 199680 // // where is x is max(length_of_MODULUS, length_of_BASE) func modexpMultComplexity(x *big.Int) *big.Int { diff --git a/core/vm/gas_table.go b/core/vm/gas_table.go index 92e858271f..cc01a96808 100644 --- a/core/vm/gas_table.go +++ b/core/vm/gas_table.go @@ -162,19 +162,19 @@ func gasSStore(evm *EVM, contract *Contract, stack *Stack, mem *Memory, memorySi return params.NetSstoreDirtyGas, nil } -// 0. If *gasleft* is less than or equal to 2300, fail the current call. -// 1. If current value equals new value (this is a no-op), SLOAD_GAS is deducted. -// 2. If current value does not equal new value: -// 2.1. If original value equals current value (this storage slot has not been changed by the current execution context): +// 0. If *gasleft* is less than or equal to 2300, fail the current call. +// 1. If current value equals new value (this is a no-op), SLOAD_GAS is deducted. +// 2. If current value does not equal new value: +// 2.1. If original value equals current value (this storage slot has not been changed by the current execution context): // 2.1.1. If original value is 0, SSTORE_SET_GAS (20K) gas is deducted. // 2.1.2. Otherwise, SSTORE_RESET_GAS gas is deducted. If new value is 0, add SSTORE_CLEARS_SCHEDULE to refund counter. -// 2.2. If original value does not equal current value (this storage slot is dirty), SLOAD_GAS gas is deducted. Apply both of the following clauses: +// 2.2. If original value does not equal current value (this storage slot is dirty), SLOAD_GAS gas is deducted. Apply both of the following clauses: // 2.2.1. If original value is not 0: -// 2.2.1.1. If current value is 0 (also means that new value is not 0), subtract SSTORE_CLEARS_SCHEDULE gas from refund counter. -// 2.2.1.2. If new value is 0 (also means that current value is not 0), add SSTORE_CLEARS_SCHEDULE gas to refund counter. +// 2.2.1.1. If current value is 0 (also means that new value is not 0), subtract SSTORE_CLEARS_SCHEDULE gas from refund counter. +// 2.2.1.2. If new value is 0 (also means that current value is not 0), add SSTORE_CLEARS_SCHEDULE gas to refund counter. // 2.2.2. If original value equals new value (this storage slot is reset): -// 2.2.2.1. If original value is 0, add SSTORE_SET_GAS - SLOAD_GAS to refund counter. -// 2.2.2.2. Otherwise, add SSTORE_RESET_GAS - SLOAD_GAS gas to refund counter. +// 2.2.2.1. If original value is 0, add SSTORE_SET_GAS - SLOAD_GAS to refund counter. +// 2.2.2.2. Otherwise, add SSTORE_RESET_GAS - SLOAD_GAS gas to refund counter. func gasSStoreEIP2200(evm *EVM, contract *Contract, stack *Stack, mem *Memory, memorySize uint64) (uint64, error) { // If we fail the minimum gas availability invariant, fail (0) if contract.Gas <= params.SstoreSentryGasEIP2200 { diff --git a/core/vm/instructions.go b/core/vm/instructions.go index 1a95473a0a..c80937722e 100644 --- a/core/vm/instructions.go +++ b/core/vm/instructions.go @@ -392,21 +392,16 @@ func opExtCodeCopy(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) // opExtCodeHash returns the code hash of a specified account. // There are several cases when the function is called, while we can relay everything // to `state.GetCodeHash` function to ensure the correctness. -// -// (1) Caller tries to get the code hash of a normal contract account, state -// +// (1) Caller tries to get the code hash of a normal contract account, state // should return the relative code hash and set it as the result. // -// (2) Caller tries to get the code hash of a non-existent account, state should -// +// (2) Caller tries to get the code hash of a non-existent account, state should // return common.Hash{} and zero will be set as the result. // -// (3) Caller tries to get the code hash for an account without contract code, -// +// (3) Caller tries to get the code hash for an account without contract code, // state should return emptyCodeHash(0xc5d246...) as the result. // -// (4) Caller tries to get the code hash of a precompiled account, the result -// +// (4) Caller tries to get the code hash of a precompiled account, the result // should be zero or emptyCodeHash. // // It is worth noting that in order to avoid unnecessary create and clean, @@ -415,12 +410,10 @@ func opExtCodeCopy(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) // If the precompile account is not transferred any amount on a private or // customized chain, the return value will be zero. // -// (5) Caller tries to get the code hash for an account which is marked as suicided -// +// (5) Caller tries to get the code hash for an account which is marked as suicided // in the current transaction, the code hash of this account should be returned. // -// (6) Caller tries to get the code hash for an account which is marked as deleted, -// +// (6) Caller tries to get the code hash for an account which is marked as deleted, // this account should be regarded as a non-existent account and zero should be returned. func opExtCodeHash(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) { slot := scope.Stack.peek() diff --git a/crypto/crypto.go b/crypto/crypto.go index dbc3c504f4..6a8fd7bace 100644 --- a/crypto/crypto.go +++ b/crypto/crypto.go @@ -35,7 +35,7 @@ import ( "golang.org/x/crypto/sha3" ) -// SignatureLength indicates the byte length required to carry a signature with recovery id. +//SignatureLength indicates the byte length required to carry a signature with recovery id. const SignatureLength = 64 + 1 // 64 bytes ECDSA signature + 1 byte recovery id // RecoveryIDOffset points to the byte offset within the signature that contains the recovery id. diff --git a/eth/api_backend.go b/eth/api_backend.go index 6b2a65344d..8db523f300 100644 --- a/eth/api_backend.go +++ b/eth/api_backend.go @@ -22,7 +22,7 @@ import ( "math/big" "time" - ethereum "github.com/cryptoecc/ETH-ECC" + "github.com/cryptoecc/ETH-ECC" "github.com/cryptoecc/ETH-ECC/accounts" "github.com/cryptoecc/ETH-ECC/common" "github.com/cryptoecc/ETH-ECC/consensus" diff --git a/eth/api_test.go b/eth/api_test.go index cb3737b065..719d350a8a 100644 --- a/eth/api_test.go +++ b/eth/api_test.go @@ -24,13 +24,13 @@ import ( "sort" "testing" + "github.com/davecgh/go-spew/spew" "github.com/cryptoecc/ETH-ECC/common" "github.com/cryptoecc/ETH-ECC/core/rawdb" "github.com/cryptoecc/ETH-ECC/core/state" "github.com/cryptoecc/ETH-ECC/crypto" "github.com/cryptoecc/ETH-ECC/trie" - "github.com/davecgh/go-spew/spew" -) + ) var dumper = spew.ConfigState{Indent: " "} diff --git a/eth/catalyst/api_test.go b/eth/catalyst/api_test.go index 43a1ab1b87..b0fc260332 100644 --- a/eth/catalyst/api_test.go +++ b/eth/catalyst/api_test.go @@ -523,7 +523,7 @@ func TestExchangeTransitionConfig(t *testing.T) { TestNewPayloadOnInvalidChain sets up a valid chain and tries to feed blocks from an invalid chain to test if latestValidHash (LVH) works correctly. -We set up the following chain where P1 ... Pn and P1” are valid while +We set up the following chain where P1 ... Pn and P1'' are valid while P1' is invalid. We expect (1) The LVH to point to the current inserted payload if it was valid. @@ -531,7 +531,6 @@ We expect (3) If the parent is unavailable, the LVH should not be set. CommonAncestor◄─▲── P1 ◄── P2 ◄─ P3 ◄─ ... ◄─ Pn - │ └── P1' ◄─ P2' ◄─ P3' ◄─ ... ◄─ Pn' │ @@ -707,6 +706,8 @@ func setBlockhash(data *beacon.ExecutableDataV1) *beacon.ExecutableDataV1 { BaseFee: data.BaseFeePerGas, Extra: data.ExtraData, MixDigest: data.Random, + //Codeword: data.Codeword, + //CodeLength: data.CodeLength, } block := types.NewBlockWithHeader(header).WithBody(txs, nil /* uncles */) data.BlockHash = block.Hash() diff --git a/eth/downloader/api.go b/eth/downloader/api.go index 5a3e2a6b22..ebdc895472 100644 --- a/eth/downloader/api.go +++ b/eth/downloader/api.go @@ -20,10 +20,10 @@ import ( "context" "sync" + "github.com/cryptoecc/ETH-ECC" "github.com/cryptoecc/ETH-ECC/event" "github.com/cryptoecc/ETH-ECC/rpc" - "github.com/ethereum/go-ethereum" -) + ) // DownloaderAPI provides an API which gives information about the current synchronisation status. // It offers only methods that operates on data that can be available to anyone without security risks. diff --git a/eth/downloader/downloader.go b/eth/downloader/downloader.go index ae9ea684b7..bb20b3faa9 100644 --- a/eth/downloader/downloader.go +++ b/eth/downloader/downloader.go @@ -25,6 +25,7 @@ import ( "sync/atomic" "time" + "github.com/cryptoecc/ETH-ECC" "github.com/cryptoecc/ETH-ECC/common" "github.com/cryptoecc/ETH-ECC/core/rawdb" "github.com/cryptoecc/ETH-ECC/core/state/snapshot" @@ -34,8 +35,7 @@ import ( "github.com/cryptoecc/ETH-ECC/event" "github.com/cryptoecc/ETH-ECC/log" "github.com/cryptoecc/ETH-ECC/params" - "github.com/ethereum/go-ethereum" -) + ) var ( MaxBlockFetch = 128 // Amount of blocks to be fetched per retrieval request @@ -741,11 +741,9 @@ func (d *Downloader) fetchHead(p *peerConnection) (head *types.Header, pivot *ty // calculateRequestSpan calculates what headers to request from a peer when trying to determine the // common ancestor. // It returns parameters to be used for peer.RequestHeadersByNumber: -// -// from - starting block number -// count - number of headers to request -// skip - number of headers to skip -// +// from - starting block number +// count - number of headers to request +// skip - number of headers to skip // and also returns 'max', the last block which is expected to be returned by the remote peers, // given the (from,count,skip) func calculateRequestSpan(remoteHeight, localHeight uint64) (int64, int, int, uint64) { diff --git a/eth/downloader/downloader_test.go b/eth/downloader/downloader_test.go index 00b90831fd..c2ac662ce0 100644 --- a/eth/downloader/downloader_test.go +++ b/eth/downloader/downloader_test.go @@ -27,6 +27,7 @@ import ( "testing" "time" + "github.com/cryptoecc/ETH-ECC" "github.com/cryptoecc/ETH-ECC/common" "github.com/cryptoecc/ETH-ECC/consensus/ethash" "github.com/cryptoecc/ETH-ECC/core" @@ -40,8 +41,7 @@ import ( "github.com/cryptoecc/ETH-ECC/params" "github.com/cryptoecc/ETH-ECC/rlp" "github.com/cryptoecc/ETH-ECC/trie" - "github.com/ethereum/go-ethereum" -) + ) // downloadTester is a test simulator for mocking out local block chain. type downloadTester struct { diff --git a/eth/downloader/queue.go b/eth/downloader/queue.go index c17e3afd80..ae15c17566 100644 --- a/eth/downloader/queue.go +++ b/eth/downloader/queue.go @@ -480,10 +480,9 @@ func (q *queue) ReserveReceipts(p *peerConnection, count int) (*fetchRequest, bo // to access the queue, so they already need a lock anyway. // // Returns: -// -// item - the fetchRequest -// progress - whether any progress was made -// throttle - if the caller should throttle for a while +// item - the fetchRequest +// progress - whether any progress was made +// throttle - if the caller should throttle for a while func (q *queue) reserveHeaders(p *peerConnection, count int, taskPool map[common.Hash]*types.Header, taskQueue *prque.Prque, pendPool map[string]*fetchRequest, kind uint) (*fetchRequest, bool, bool) { // Short circuit if the pool has been depleted, or if the peer's already diff --git a/eth/downloader/resultstore.go b/eth/downloader/resultstore.go index 1e4d1ff6b6..17b8ae3af3 100644 --- a/eth/downloader/resultstore.go +++ b/eth/downloader/resultstore.go @@ -71,11 +71,10 @@ func (r *resultStore) SetThrottleThreshold(threshold uint64) uint64 { // wants to reserve headers for fetching. // // It returns the following: -// -// stale - if true, this item is already passed, and should not be requested again -// throttled - if true, the store is at capacity, this particular header is not prio now -// item - the result to store data into -// err - any error that occurred +// stale - if true, this item is already passed, and should not be requested again +// throttled - if true, the store is at capacity, this particular header is not prio now +// item - the result to store data into +// err - any error that occurred func (r *resultStore) AddFetch(header *types.Header, fastSync bool) (stale, throttled bool, item *fetchResult, err error) { r.lock.Lock() defer r.lock.Unlock() diff --git a/eth/ethconfig/config.go b/eth/ethconfig/config.go index 3daf9032e9..cf8f452485 100644 --- a/eth/ethconfig/config.go +++ b/eth/ethconfig/config.go @@ -29,6 +29,7 @@ import ( "github.com/cryptoecc/ETH-ECC/consensus" "github.com/cryptoecc/ETH-ECC/consensus/beacon" "github.com/cryptoecc/ETH-ECC/consensus/clique" + "github.com/cryptoecc/ETH-ECC/consensus/eccpow" "github.com/cryptoecc/ETH-ECC/consensus/ethash" "github.com/cryptoecc/ETH-ECC/core" "github.com/cryptoecc/ETH-ECC/eth/downloader" diff --git a/eth/fetcher/tx_fetcher.go b/eth/fetcher/tx_fetcher.go index 5a24e4e913..8d1b62e16d 100644 --- a/eth/fetcher/tx_fetcher.go +++ b/eth/fetcher/tx_fetcher.go @@ -24,14 +24,14 @@ import ( "sort" "time" + mapset "github.com/deckarep/golang-set" "github.com/cryptoecc/ETH-ECC/common" "github.com/cryptoecc/ETH-ECC/common/mclock" "github.com/cryptoecc/ETH-ECC/core" "github.com/cryptoecc/ETH-ECC/core/types" "github.com/cryptoecc/ETH-ECC/log" "github.com/cryptoecc/ETH-ECC/metrics" - mapset "github.com/deckarep/golang-set" -) + ) const ( // maxTxAnnounces is the maximum number of unique transaction a peer diff --git a/eth/filters/api.go b/eth/filters/api.go index 4be6f6f681..a3645dd812 100644 --- a/eth/filters/api.go +++ b/eth/filters/api.go @@ -25,12 +25,12 @@ import ( "sync" "time" + "github.com/cryptoecc/ETH-ECC" "github.com/cryptoecc/ETH-ECC/common" "github.com/cryptoecc/ETH-ECC/common/hexutil" "github.com/cryptoecc/ETH-ECC/core/types" "github.com/cryptoecc/ETH-ECC/rpc" - "github.com/ethereum/go-ethereum" -) + ) // filter is a helper struct that holds meta information over the filter type // and associated subscription in the event system. diff --git a/eth/filters/filter_system.go b/eth/filters/filter_system.go index d94f5d4768..ba20748093 100644 --- a/eth/filters/filter_system.go +++ b/eth/filters/filter_system.go @@ -24,6 +24,7 @@ import ( "sync" "time" + "github.com/cryptoecc/ETH-ECC" "github.com/cryptoecc/ETH-ECC/common" "github.com/cryptoecc/ETH-ECC/core" "github.com/cryptoecc/ETH-ECC/core/bloombits" @@ -33,7 +34,6 @@ import ( "github.com/cryptoecc/ETH-ECC/event" "github.com/cryptoecc/ETH-ECC/log" "github.com/cryptoecc/ETH-ECC/rpc" - "github.com/ethereum/go-ethereum" lru "github.com/hashicorp/golang-lru" ) diff --git a/eth/filters/filter_system_test.go b/eth/filters/filter_system_test.go index faa29d9a42..0aa9a98ad7 100644 --- a/eth/filters/filter_system_test.go +++ b/eth/filters/filter_system_test.go @@ -26,6 +26,7 @@ import ( "testing" "time" + "github.com/cryptoecc/ETH-ECC" "github.com/cryptoecc/ETH-ECC/common" "github.com/cryptoecc/ETH-ECC/consensus/ethash" "github.com/cryptoecc/ETH-ECC/core" @@ -36,8 +37,7 @@ import ( "github.com/cryptoecc/ETH-ECC/event" "github.com/cryptoecc/ETH-ECC/params" "github.com/cryptoecc/ETH-ECC/rpc" - "github.com/ethereum/go-ethereum" -) + ) type testBackend struct { db ethdb.Database diff --git a/eth/gasprice/feehistory.go b/eth/gasprice/feehistory.go index 32dee8dabc..013492e9e9 100644 --- a/eth/gasprice/feehistory.go +++ b/eth/gasprice/feehistory.go @@ -208,11 +208,10 @@ func (oracle *Oracle) resolveBlockRange(ctx context.Context, reqEnd rpc.BlockNum // actually processed range is returned to avoid ambiguity when parts of the requested range // are not available or when the head has changed during processing this request. // Three arrays are returned based on the processed blocks: -// - reward: the requested percentiles of effective priority fees per gas of transactions in each -// block, sorted in ascending order and weighted by gas used. -// - baseFee: base fee per gas in the given block -// - gasUsedRatio: gasUsed/gasLimit in the given block -// +// - reward: the requested percentiles of effective priority fees per gas of transactions in each +// block, sorted in ascending order and weighted by gas used. +// - baseFee: base fee per gas in the given block +// - gasUsedRatio: gasUsed/gasLimit in the given block // Note: baseFee includes the next block after the newest of the returned range, because this // value can be derived from the newest block. func (oracle *Oracle) FeeHistory(ctx context.Context, blocks int, unresolvedLastBlock rpc.BlockNumber, rewardPercentiles []float64) (*big.Int, [][]*big.Int, []*big.Int, []float64, error) { diff --git a/eth/handler.go b/eth/handler.go index e937f62994..eb40486973 100644 --- a/eth/handler.go +++ b/eth/handler.go @@ -411,6 +411,7 @@ func (h *handler) runEthPeer(peer *eth.Peer, handler eth.Handler) error { res.Done <- errors.New("unsynced node cannot serve sync") return } + res.Done <- nil return } diff --git a/eth/protocols/eth/peer.go b/eth/protocols/eth/peer.go index 59647bb8b0..816de3ab22 100644 --- a/eth/protocols/eth/peer.go +++ b/eth/protocols/eth/peer.go @@ -21,12 +21,12 @@ import ( "math/rand" "sync" + mapset "github.com/deckarep/golang-set" "github.com/cryptoecc/ETH-ECC/common" "github.com/cryptoecc/ETH-ECC/core/types" "github.com/cryptoecc/ETH-ECC/p2p" "github.com/cryptoecc/ETH-ECC/rlp" - mapset "github.com/deckarep/golang-set" -) + ) const ( // maxKnownTxs is the maximum transactions hashes to keep in the known list diff --git a/eth/protocols/snap/sync_test.go b/eth/protocols/snap/sync_test.go index 0e721d3766..361c997f78 100644 --- a/eth/protocols/snap/sync_test.go +++ b/eth/protocols/snap/sync_test.go @@ -368,8 +368,7 @@ func createStorageRequestResponse(t *testPeer, root common.Hash, accounts []comm return hashes, slots, proofs } -// the createStorageRequestResponseAlwaysProve tests a cornercase, where it always -// +// the createStorageRequestResponseAlwaysProve tests a cornercase, where it always // supplies the proof for the last account, even if it is 'complete'.h func createStorageRequestResponseAlwaysProve(t *testPeer, root common.Hash, accounts []common.Hash, bOrigin, bLimit []byte, max uint64) (hashes [][]common.Hash, slots [][][]byte, proofs [][]byte) { var size uint64 diff --git a/ethclient/gethclient/gethclient.go b/ethclient/gethclient/gethclient.go index a8a0f90b40..2be5cbefd3 100644 --- a/ethclient/gethclient/gethclient.go +++ b/ethclient/gethclient/gethclient.go @@ -23,7 +23,7 @@ import ( "runtime" "runtime/debug" - ethereum "github.com/cryptoecc/ETH-ECC" + "github.com/cryptoecc/ETH-ECC" "github.com/cryptoecc/ETH-ECC/common" "github.com/cryptoecc/ETH-ECC/common/hexutil" "github.com/cryptoecc/ETH-ECC/core/types" diff --git a/ethclient/gethclient/gethclient_test.go b/ethclient/gethclient/gethclient_test.go index a17fdb8a39..6c80507d85 100644 --- a/ethclient/gethclient/gethclient_test.go +++ b/ethclient/gethclient/gethclient_test.go @@ -22,6 +22,7 @@ import ( "math/big" "testing" + "github.com/cryptoecc/ETH-ECC" "github.com/cryptoecc/ETH-ECC/common" "github.com/cryptoecc/ETH-ECC/consensus/ethash" "github.com/cryptoecc/ETH-ECC/core" @@ -35,8 +36,7 @@ import ( "github.com/cryptoecc/ETH-ECC/node" "github.com/cryptoecc/ETH-ECC/params" "github.com/cryptoecc/ETH-ECC/rpc" - "github.com/ethereum/go-ethereum" -) + ) var ( testKey, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291") diff --git a/ethdb/leveldb/leveldb.go b/ethdb/leveldb/leveldb.go index 4b2484f346..da6cf8590f 100644 --- a/ethdb/leveldb/leveldb.go +++ b/ethdb/leveldb/leveldb.go @@ -266,14 +266,13 @@ func (db *Database) Path() string { // the metrics subsystem. // // This is how a LevelDB stats table looks like (currently): -// -// Compactions -// Level | Tables | Size(MB) | Time(sec) | Read(MB) | Write(MB) -// -------+------------+---------------+---------------+---------------+--------------- -// 0 | 0 | 0.00000 | 1.27969 | 0.00000 | 12.31098 -// 1 | 85 | 109.27913 | 28.09293 | 213.92493 | 214.26294 -// 2 | 523 | 1000.37159 | 7.26059 | 66.86342 | 66.77884 -// 3 | 570 | 1113.18458 | 0.00000 | 0.00000 | 0.00000 +// Compactions +// Level | Tables | Size(MB) | Time(sec) | Read(MB) | Write(MB) +// -------+------------+---------------+---------------+---------------+--------------- +// 0 | 0 | 0.00000 | 1.27969 | 0.00000 | 12.31098 +// 1 | 85 | 109.27913 | 28.09293 | 213.92493 | 214.26294 +// 2 | 523 | 1000.37159 | 7.26059 | 66.86342 | 66.77884 +// 3 | 570 | 1113.18458 | 0.00000 | 0.00000 | 0.00000 // // This is how the write delay look like (currently): // DelayN:5 Delay:406.604657ms Paused: false diff --git a/ethstats/ethstats.go b/ethstats/ethstats.go index b74b46eb06..26f9ac0ce6 100644 --- a/ethstats/ethstats.go +++ b/ethstats/ethstats.go @@ -102,14 +102,13 @@ type Service struct { // websocket. // // From Gorilla websocket docs: -// -// Connections support one concurrent reader and one concurrent writer. -// Applications are responsible for ensuring that no more than one goroutine calls the write methods -// - NextWriter, SetWriteDeadline, WriteMessage, WriteJSON, EnableWriteCompression, SetCompressionLevel -// concurrently and that no more than one goroutine calls the read methods -// - NextReader, SetReadDeadline, ReadMessage, ReadJSON, SetPongHandler, SetPingHandler -// concurrently. -// The Close and WriteControl methods can be called concurrently with all other methods. +// Connections support one concurrent reader and one concurrent writer. +// Applications are responsible for ensuring that no more than one goroutine calls the write methods +// - NextWriter, SetWriteDeadline, WriteMessage, WriteJSON, EnableWriteCompression, SetCompressionLevel +// concurrently and that no more than one goroutine calls the read methods +// - NextReader, SetReadDeadline, ReadMessage, ReadJSON, SetPongHandler, SetPingHandler +// concurrently. +// The Close and WriteControl methods can be called concurrently with all other methods. type connWrapper struct { conn *websocket.Conn diff --git a/graphql/graphql.go b/graphql/graphql.go index 1ca78a0874..a0b1423ae6 100644 --- a/graphql/graphql.go +++ b/graphql/graphql.go @@ -25,7 +25,7 @@ import ( "sort" "strconv" - ethereum "github.com/cryptoecc/ETH-ECC" + "github.com/cryptoecc/ETH-ECC" "github.com/cryptoecc/ETH-ECC/common" "github.com/cryptoecc/ETH-ECC/common/hexutil" "github.com/cryptoecc/ETH-ECC/common/math" diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index 9d7593ed50..152a8e70cd 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -731,10 +731,10 @@ func (s *BlockChainAPI) GetHeaderByHash(ctx context.Context, hash common.Hash) m } // GetBlockByNumber returns the requested canonical block. -// - When blockNr is -1 the chain head is returned. -// - When blockNr is -2 the pending chain head is returned. -// - When fullTx is true all transactions in the block are returned, otherwise -// only the transaction hash is returned. +// * When blockNr is -1 the chain head is returned. +// * When blockNr is -2 the pending chain head is returned. +// * When fullTx is true all transactions in the block are returned, otherwise +// only the transaction hash is returned. func (s *BlockChainAPI) GetBlockByNumber(ctx context.Context, number rpc.BlockNumber, fullTx bool) (map[string]interface{}, error) { block, err := s.b.BlockByNumber(ctx, number) if block != nil && err == nil { diff --git a/internal/ethapi/transaction_args_test.go b/internal/ethapi/transaction_args_test.go index fbf2d1b9d6..dc19a0926a 100644 --- a/internal/ethapi/transaction_args_test.go +++ b/internal/ethapi/transaction_args_test.go @@ -24,6 +24,7 @@ import ( "testing" "time" + "github.com/cryptoecc/ETH-ECC" "github.com/cryptoecc/ETH-ECC/accounts" "github.com/cryptoecc/ETH-ECC/common" "github.com/cryptoecc/ETH-ECC/common/hexutil" @@ -37,8 +38,7 @@ import ( "github.com/cryptoecc/ETH-ECC/event" "github.com/cryptoecc/ETH-ECC/params" "github.com/cryptoecc/ETH-ECC/rpc" - "github.com/ethereum/go-ethereum" -) + ) // TestSetFeeDefaults tests the logic for filling in default fee values works as expected. func TestSetFeeDefaults(t *testing.T) { diff --git a/internal/flags/helpers.go b/internal/flags/helpers.go index 8f9c6ce750..2168a0bff2 100644 --- a/internal/flags/helpers.go +++ b/internal/flags/helpers.go @@ -54,11 +54,11 @@ var migrationApplied = map[*cli.Command]struct{}{} // // Example: // -// geth account new --keystore /tmp/mykeystore --lightkdf +// geth account new --keystore /tmp/mykeystore --lightkdf // // is equivalent after calling this method with: // -// geth --keystore /tmp/mykeystore --lightkdf account new +// geth --keystore /tmp/mykeystore --lightkdf account new // // i.e. in the subcommand Action function of 'account new', ctx.Bool("lightkdf) // will return true even if --lightkdf is set as a global option. diff --git a/les/api.go b/les/api.go index f75837453e..d2a94ab642 100644 --- a/les/api.go +++ b/les/api.go @@ -366,11 +366,10 @@ func NewLightAPI(backend *lesCommons) *LightAPI { // LatestCheckpoint returns the latest local checkpoint package. // // The checkpoint package consists of 4 strings: -// -// result[0], hex encoded latest section index -// result[1], 32 bytes hex encoded latest section head hash -// result[2], 32 bytes hex encoded latest section canonical hash trie root hash -// result[3], 32 bytes hex encoded latest section bloom trie root hash +// result[0], hex encoded latest section index +// result[1], 32 bytes hex encoded latest section head hash +// result[2], 32 bytes hex encoded latest section canonical hash trie root hash +// result[3], 32 bytes hex encoded latest section bloom trie root hash func (api *LightAPI) LatestCheckpoint() ([4]string, error) { var res [4]string cp := api.backend.latestLocalCheckpoint() @@ -385,10 +384,9 @@ func (api *LightAPI) LatestCheckpoint() ([4]string, error) { // GetLocalCheckpoint returns the specific local checkpoint package. // // The checkpoint package consists of 3 strings: -// -// result[0], 32 bytes hex encoded latest section head hash -// result[1], 32 bytes hex encoded latest section canonical hash trie root hash -// result[2], 32 bytes hex encoded latest section bloom trie root hash +// result[0], 32 bytes hex encoded latest section head hash +// result[1], 32 bytes hex encoded latest section canonical hash trie root hash +// result[2], 32 bytes hex encoded latest section bloom trie root hash func (api *LightAPI) GetCheckpoint(index uint64) ([3]string, error) { var res [3]string cp := api.backend.localCheckpoint(index) diff --git a/les/api_backend.go b/les/api_backend.go index b11ecf51ea..34e92d1c75 100644 --- a/les/api_backend.go +++ b/les/api_backend.go @@ -22,7 +22,7 @@ import ( "math/big" "time" - ethereum "github.com/cryptoecc/ETH-ECC" + "github.com/cryptoecc/ETH-ECC" "github.com/cryptoecc/ETH-ECC/accounts" "github.com/cryptoecc/ETH-ECC/common" "github.com/cryptoecc/ETH-ECC/consensus" diff --git a/les/catalyst/api.go b/les/catalyst/api.go index e152f46ba6..604eb6c9b1 100644 --- a/les/catalyst/api.go +++ b/les/catalyst/api.go @@ -57,21 +57,14 @@ func NewConsensusAPI(les *les.LightEthereum) *ConsensusAPI { // ForkchoiceUpdatedV1 has several responsibilities: // If the method is called with an empty head block: -// -// we return success, which can be used to check if the catalyst mode is enabled -// +// we return success, which can be used to check if the catalyst mode is enabled // If the total difficulty was not reached: -// -// we return INVALID -// +// we return INVALID // If the finalizedBlockHash is set: -// -// we check if we have the finalizedBlockHash in our db, if not we start a sync -// +// we check if we have the finalizedBlockHash in our db, if not we start a sync // We try to set our blockchain to the headBlock // If there are payloadAttributes: -// -// we return an error since block creation is not supported in les mode +// we return an error since block creation is not supported in les mode func (api *ConsensusAPI) ForkchoiceUpdatedV1(heads beacon.ForkchoiceStateV1, payloadAttributes *beacon.PayloadAttributesV1) (beacon.ForkChoiceResponse, error) { if heads.HeadBlockHash == (common.Hash{}) { log.Warn("Forkchoice requested update to zero hash") diff --git a/les/downloader/api.go b/les/downloader/api.go index 9f0eba077f..008ca9eb7a 100644 --- a/les/downloader/api.go +++ b/les/downloader/api.go @@ -20,10 +20,10 @@ import ( "context" "sync" + "github.com/cryptoecc/ETH-ECC" "github.com/cryptoecc/ETH-ECC/event" "github.com/cryptoecc/ETH-ECC/rpc" - "github.com/ethereum/go-ethereum" -) + ) // DownloaderAPI provides an API which gives information about the current synchronisation status. // It offers only methods that operates on data that can be available to anyone without security risks. diff --git a/les/downloader/downloader.go b/les/downloader/downloader.go index 5bb908e886..b31eff054d 100644 --- a/les/downloader/downloader.go +++ b/les/downloader/downloader.go @@ -28,6 +28,7 @@ import ( "sync/atomic" "time" + "github.com/cryptoecc/ETH-ECC" "github.com/cryptoecc/ETH-ECC/common" "github.com/cryptoecc/ETH-ECC/core/rawdb" "github.com/cryptoecc/ETH-ECC/core/state/snapshot" @@ -39,8 +40,7 @@ import ( "github.com/cryptoecc/ETH-ECC/log" "github.com/cryptoecc/ETH-ECC/metrics" "github.com/cryptoecc/ETH-ECC/params" - "github.com/ethereum/go-ethereum" -) + ) var ( MaxBlockFetch = 128 // Amount of blocks to be fetched per retrieval request @@ -693,11 +693,9 @@ func (d *Downloader) fetchHead(p *peerConnection) (head *types.Header, pivot *ty // calculateRequestSpan calculates what headers to request from a peer when trying to determine the // common ancestor. // It returns parameters to be used for peer.RequestHeadersByNumber: -// -// from - starting block number -// count - number of headers to request -// skip - number of headers to skip -// +// from - starting block number +// count - number of headers to request +// skip - number of headers to skip // and also returns 'max', the last block which is expected to be returned by the remote peers, // given the (from,count,skip) func calculateRequestSpan(remoteHeight, localHeight uint64) (int64, int, int, uint64) { @@ -1312,22 +1310,22 @@ func (d *Downloader) fetchReceipts(from uint64) error { // various callbacks to handle the slight differences between processing them. // // The instrumentation parameters: -// - errCancel: error type to return if the fetch operation is cancelled (mostly makes logging nicer) -// - deliveryCh: channel from which to retrieve downloaded data packets (merged from all concurrent peers) -// - deliver: processing callback to deliver data packets into type specific download queues (usually within `queue`) -// - wakeCh: notification channel for waking the fetcher when new tasks are available (or sync completed) -// - expire: task callback method to abort requests that took too long and return the faulty peers (traffic shaping) -// - pending: task callback for the number of requests still needing download (detect completion/non-completability) -// - inFlight: task callback for the number of in-progress requests (wait for all active downloads to finish) -// - throttle: task callback to check if the processing queue is full and activate throttling (bound memory use) -// - reserve: task callback to reserve new download tasks to a particular peer (also signals partial completions) -// - fetchHook: tester callback to notify of new tasks being initiated (allows testing the scheduling logic) -// - fetch: network callback to actually send a particular download request to a physical remote peer -// - cancel: task callback to abort an in-flight download request and allow rescheduling it (in case of lost peer) -// - capacity: network callback to retrieve the estimated type-specific bandwidth capacity of a peer (traffic shaping) -// - idle: network callback to retrieve the currently (type specific) idle peers that can be assigned tasks -// - setIdle: network callback to set a peer back to idle and update its estimated capacity (traffic shaping) -// - kind: textual label of the type being downloaded to display in log messages +// - errCancel: error type to return if the fetch operation is cancelled (mostly makes logging nicer) +// - deliveryCh: channel from which to retrieve downloaded data packets (merged from all concurrent peers) +// - deliver: processing callback to deliver data packets into type specific download queues (usually within `queue`) +// - wakeCh: notification channel for waking the fetcher when new tasks are available (or sync completed) +// - expire: task callback method to abort requests that took too long and return the faulty peers (traffic shaping) +// - pending: task callback for the number of requests still needing download (detect completion/non-completability) +// - inFlight: task callback for the number of in-progress requests (wait for all active downloads to finish) +// - throttle: task callback to check if the processing queue is full and activate throttling (bound memory use) +// - reserve: task callback to reserve new download tasks to a particular peer (also signals partial completions) +// - fetchHook: tester callback to notify of new tasks being initiated (allows testing the scheduling logic) +// - fetch: network callback to actually send a particular download request to a physical remote peer +// - cancel: task callback to abort an in-flight download request and allow rescheduling it (in case of lost peer) +// - capacity: network callback to retrieve the estimated type-specific bandwidth capacity of a peer (traffic shaping) +// - idle: network callback to retrieve the currently (type specific) idle peers that can be assigned tasks +// - setIdle: network callback to set a peer back to idle and update its estimated capacity (traffic shaping) +// - kind: textual label of the type being downloaded to display in log messages func (d *Downloader) fetchParts(deliveryCh chan dataPack, deliver func(dataPack) (int, error), wakeCh chan bool, expire func() map[string]int, pending func() int, inFlight func() bool, reserve func(*peerConnection, int) (*fetchRequest, bool, bool), fetchHook func([]*types.Header), fetch func(*peerConnection, *fetchRequest) error, cancel func(*fetchRequest), capacity func(*peerConnection) int, diff --git a/les/downloader/queue.go b/les/downloader/queue.go index 6bba0efef1..3485f93927 100644 --- a/les/downloader/queue.go +++ b/les/downloader/queue.go @@ -477,10 +477,9 @@ func (q *queue) ReserveReceipts(p *peerConnection, count int) (*fetchRequest, bo // to access the queue, so they already need a lock anyway. // // Returns: -// -// item - the fetchRequest -// progress - whether any progress was made -// throttle - if the caller should throttle for a while +// item - the fetchRequest +// progress - whether any progress was made +// throttle - if the caller should throttle for a while func (q *queue) reserveHeaders(p *peerConnection, count int, taskPool map[common.Hash]*types.Header, taskQueue *prque.Prque, pendPool map[string]*fetchRequest, kind uint) (*fetchRequest, bool, bool) { // Short circuit if the pool has been depleted, or if the peer's already diff --git a/les/downloader/resultstore.go b/les/downloader/resultstore.go index 1e4d1ff6b6..17b8ae3af3 100644 --- a/les/downloader/resultstore.go +++ b/les/downloader/resultstore.go @@ -71,11 +71,10 @@ func (r *resultStore) SetThrottleThreshold(threshold uint64) uint64 { // wants to reserve headers for fetching. // // It returns the following: -// -// stale - if true, this item is already passed, and should not be requested again -// throttled - if true, the store is at capacity, this particular header is not prio now -// item - the result to store data into -// err - any error that occurred +// stale - if true, this item is already passed, and should not be requested again +// throttled - if true, the store is at capacity, this particular header is not prio now +// item - the result to store data into +// err - any error that occurred func (r *resultStore) AddFetch(header *types.Header, fastSync bool) (stale, throttled bool, item *fetchResult, err error) { r.lock.Lock() defer r.lock.Unlock() diff --git a/les/fetcher.go b/les/fetcher.go index b057cdec4f..b0a42841ab 100644 --- a/les/fetcher.go +++ b/les/fetcher.go @@ -242,19 +242,18 @@ func (f *lightFetcher) forEachPeer(check func(id enode.ID, p *fetcherPeer) bool) } // mainloop is the main event loop of the light fetcher, which is responsible for +// - announcement maintenance(ulc) +// If we are running in ultra light client mode, then all announcements from +// the trusted servers are maintained. If the same announcements from trusted +// servers reach the threshold, then the relevant header is requested for retrieval. // -// - announcement maintenance(ulc) -// If we are running in ultra light client mode, then all announcements from -// the trusted servers are maintained. If the same announcements from trusted -// servers reach the threshold, then the relevant header is requested for retrieval. +// - block header retrieval +// Whenever we receive announce with higher td compared with local chain, the +// request will be made for header retrieval. // -// - block header retrieval -// Whenever we receive announce with higher td compared with local chain, the -// request will be made for header retrieval. -// -// - re-sync trigger -// If the local chain lags too much, then the fetcher will enter "synchronise" -// mode to retrieve missing headers in batch. +// - re-sync trigger +// If the local chain lags too much, then the fetcher will enter "synchronise" +// mode to retrieve missing headers in batch. func (f *lightFetcher) mainloop() { defer f.wg.Done() diff --git a/light/postprocess.go b/light/postprocess.go index b49a64b417..3e6283d0e0 100644 --- a/light/postprocess.go +++ b/light/postprocess.go @@ -25,6 +25,7 @@ import ( "math/big" "time" + mapset "github.com/deckarep/golang-set" "github.com/cryptoecc/ETH-ECC/common" "github.com/cryptoecc/ETH-ECC/common/bitutil" "github.com/cryptoecc/ETH-ECC/core" @@ -35,8 +36,7 @@ import ( "github.com/cryptoecc/ETH-ECC/params" "github.com/cryptoecc/ETH-ECC/rlp" "github.com/cryptoecc/ETH-ECC/trie" - mapset "github.com/deckarep/golang-set" -) + ) // IndexerConfig includes a set of configs for chain indexers. type IndexerConfig struct { diff --git a/light/trie_test.go b/light/trie_test.go index 13f35c9b90..85b43991af 100644 --- a/light/trie_test.go +++ b/light/trie_test.go @@ -23,6 +23,7 @@ import ( "math/big" "testing" + "github.com/davecgh/go-spew/spew" "github.com/cryptoecc/ETH-ECC/consensus/ethash" "github.com/cryptoecc/ETH-ECC/core" "github.com/cryptoecc/ETH-ECC/core/rawdb" @@ -30,8 +31,7 @@ import ( "github.com/cryptoecc/ETH-ECC/core/vm" "github.com/cryptoecc/ETH-ECC/params" "github.com/cryptoecc/ETH-ECC/trie" - "github.com/davecgh/go-spew/spew" -) + ) func TestNodeIterator(t *testing.T) { var ( diff --git a/light/txpool.go b/light/txpool.go index 7281bfa9e8..e6d0fe1452 100644 --- a/light/txpool.go +++ b/light/txpool.go @@ -76,13 +76,10 @@ type TxPool struct { // // Send instructs backend to forward new transactions // NewHead notifies backend about a new head after processed by the tx pool, -// -// including mined and rolled back transactions since the last event -// +// including mined and rolled back transactions since the last event // Discard notifies backend about transactions that should be discarded either -// -// because they have been replaced by a re-send or because they have been mined -// long ago and no rollback is expected +// because they have been replaced by a re-send or because they have been mined +// long ago and no rollback is expected type TxRelayBackend interface { Send(txs types.Transactions) NewHead(head common.Hash, mined []common.Hash, rollback []common.Hash) diff --git a/log/format.go b/log/format.go index ffb96077df..9ff7e49526 100644 --- a/log/format.go +++ b/log/format.go @@ -79,11 +79,12 @@ type TerminalStringer interface { // a terminal with color-coded level output and terser human friendly timestamp. // This format should only be used for interactive programs or while developing. // -// [LEVEL] [TIME] MESSAGE key=value key=value ... +// [LEVEL] [TIME] MESSAGE key=value key=value ... // // Example: // -// [DBUG] [May 16 20:58:45] remove route ns=haproxy addr=127.0.0.1:50002 +// [DBUG] [May 16 20:58:45] remove route ns=haproxy addr=127.0.0.1:50002 +// func TerminalFormat(usecolor bool) Format { return FormatFunc(func(r *Record) []byte { var color = 0 @@ -148,6 +149,7 @@ func TerminalFormat(usecolor bool) Format { // format for key/value pairs. // // For more details see: http://godoc.org/github.com/kr/logfmt +// func LogfmtFormat() Format { return FormatFunc(func(r *Record) []byte { common := []interface{}{r.KeyNames.Time, r.Time, r.KeyNames.Lvl, r.Lvl, r.KeyNames.Msg, r.Msg} diff --git a/metrics/influxdb/influxdbv2.go b/metrics/influxdb/influxdbv2.go index c973941d40..b1b0964d2c 100644 --- a/metrics/influxdb/influxdbv2.go +++ b/metrics/influxdb/influxdbv2.go @@ -1,3 +1,4 @@ +// // The go-ethereum library 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 diff --git a/mobile/big.go b/mobile/big.go index 46b4ccab30..78a89101a3 100644 --- a/mobile/big.go +++ b/mobile/big.go @@ -77,6 +77,7 @@ func (bi *BigInt) SetInt64(x int64) { // -1 if x < 0 // 0 if x == 0 // +1 if x > 0 +// func (bi *BigInt) Sign() int { return bi.bigint.Sign() } diff --git a/mobile/discover.go b/mobile/discover.go index f8c42e4fab..a3bacd3d7c 100644 --- a/mobile/discover.go +++ b/mobile/discover.go @@ -38,8 +38,8 @@ type Enode struct { // // For incomplete nodes, the designator must look like one of these // -// enode:// -// +// enode:// +// // // For complete nodes, the node ID is encoded in the username portion // of the URL, separated from the host by an @ sign. The hostname can @@ -52,7 +52,7 @@ type Enode struct { // a node with IP address 10.3.58.6, TCP listening port 30303 // and UDP discovery port 30301. // -// enode://@10.3.58.6:30303?discport=30301 +// enode://@10.3.58.6:30303?discport=30301 func NewEnode(rawurl string) (*Enode, error) { node, err := enode.Parse(enode.ValidSchemes, rawurl) if err != nil { diff --git a/mobile/ethereum.go b/mobile/ethereum.go index 3758042607..a99ef37a3d 100644 --- a/mobile/ethereum.go +++ b/mobile/ethereum.go @@ -21,7 +21,7 @@ package geth import ( "errors" - ethereum "github.com/cryptoecc/ETH-ECC" + "github.com/cryptoecc/ETH-ECC" "github.com/cryptoecc/ETH-ECC/common" ) diff --git a/node/node_example_test.go b/node/node_example_test.go index 2d7c9c1de0..b6ceaf6d2e 100644 --- a/node/node_example_test.go +++ b/node/node_example_test.go @@ -27,8 +27,8 @@ import ( // life cycle management. // // The following methods are needed to implement a node.Lifecycle: -// - Start() error - method invoked when the node is ready to start the service -// - Stop() error - method invoked when the node terminates the service +// - Start() error - method invoked when the node is ready to start the service +// - Stop() error - method invoked when the node terminates the service type SampleLifecycle struct{} func (s *SampleLifecycle) Start() error { fmt.Println("Service starting..."); return nil } diff --git a/p2p/dial.go b/p2p/dial.go index 316fbee2bf..fc1f36293e 100644 --- a/p2p/dial.go +++ b/p2p/dial.go @@ -84,12 +84,13 @@ var ( // dialer creates outbound connections and submits them into Server. // Two types of peer connections can be created: // -// - static dials are pre-configured connections. The dialer attempts -// keep these nodes connected at all times. +// - static dials are pre-configured connections. The dialer attempts +// keep these nodes connected at all times. +// +// - dynamic dials are created from node discovery results. The dialer +// continuously reads candidate nodes from its input iterator and attempts +// to create peer connections to nodes arriving through the iterator. // -// - dynamic dials are created from node discovery results. The dialer -// continuously reads candidate nodes from its input iterator and attempts -// to create peer connections to nodes arriving through the iterator. type dialScheduler struct { dialConfig setupFunc dialSetupFunc diff --git a/p2p/discover/v4wire/v4wire_test.go b/p2p/discover/v4wire/v4wire_test.go index 595eb00ed8..0761bd6a9a 100644 --- a/p2p/discover/v4wire/v4wire_test.go +++ b/p2p/discover/v4wire/v4wire_test.go @@ -22,10 +22,10 @@ import ( "reflect" "testing" + "github.com/davecgh/go-spew/spew" "github.com/cryptoecc/ETH-ECC/crypto" "github.com/cryptoecc/ETH-ECC/rlp" - "github.com/davecgh/go-spew/spew" -) + ) // EIP-8 test vectors. var testPackets = []struct { diff --git a/p2p/discover/v5wire/encoding_test.go b/p2p/discover/v5wire/encoding_test.go index d22618d332..d512007273 100644 --- a/p2p/discover/v5wire/encoding_test.go +++ b/p2p/discover/v5wire/encoding_test.go @@ -29,16 +29,17 @@ import ( "strings" "testing" + "github.com/davecgh/go-spew/spew" "github.com/cryptoecc/ETH-ECC/common/hexutil" "github.com/cryptoecc/ETH-ECC/common/mclock" "github.com/cryptoecc/ETH-ECC/crypto" "github.com/cryptoecc/ETH-ECC/p2p/enode" - "github.com/davecgh/go-spew/spew" -) + ) // To regenerate discv5 test vectors, run // -// go test -run TestVectors -write-test-vectors +// go test -run TestVectors -write-test-vectors +// var writeTestVectorsFlag = flag.Bool("write-test-vectors", false, "Overwrite discv5 test vectors in testdata/") var ( diff --git a/p2p/dnsdisc/client_test.go b/p2p/dnsdisc/client_test.go index 7cf6c636a4..eb038bfabc 100644 --- a/p2p/dnsdisc/client_test.go +++ b/p2p/dnsdisc/client_test.go @@ -25,14 +25,14 @@ import ( "testing" "time" + "github.com/davecgh/go-spew/spew" "github.com/cryptoecc/ETH-ECC/common/mclock" "github.com/cryptoecc/ETH-ECC/crypto" "github.com/cryptoecc/ETH-ECC/internal/testlog" "github.com/cryptoecc/ETH-ECC/log" "github.com/cryptoecc/ETH-ECC/p2p/enode" "github.com/cryptoecc/ETH-ECC/p2p/enr" - "github.com/davecgh/go-spew/spew" -) + ) const ( signingKeySeed = 0x111111 diff --git a/p2p/dnsdisc/tree_test.go b/p2p/dnsdisc/tree_test.go index 4b2586bd49..d35ff0f4e9 100644 --- a/p2p/dnsdisc/tree_test.go +++ b/p2p/dnsdisc/tree_test.go @@ -20,10 +20,10 @@ import ( "reflect" "testing" + "github.com/davecgh/go-spew/spew" "github.com/cryptoecc/ETH-ECC/common/hexutil" "github.com/cryptoecc/ETH-ECC/p2p/enode" - "github.com/davecgh/go-spew/spew" -) + ) func TestParseRoot(t *testing.T) { tests := []struct { diff --git a/p2p/enode/urlv4.go b/p2p/enode/urlv4.go index dd6402382d..9825ea76df 100644 --- a/p2p/enode/urlv4.go +++ b/p2p/enode/urlv4.go @@ -54,8 +54,8 @@ func MustParseV4(rawurl string) *Node { // // For incomplete nodes, the designator must look like one of these // -// enode:// -// +// enode:// +// // // For complete nodes, the node ID is encoded in the username portion // of the URL, separated from the host by an @ sign. The hostname can @@ -68,7 +68,7 @@ func MustParseV4(rawurl string) *Node { // a node with IP address 10.3.58.6, TCP listening port 30303 // and UDP discovery port 30301. // -// enode://@10.3.58.6:30303?discport=30301 +// enode://@10.3.58.6:30303?discport=30301 func ParseV4(rawurl string) (*Node, error) { if m := incompleteNodeURL.FindStringSubmatch(rawurl); m != nil { id, err := parsePubkey(m[1]) diff --git a/p2p/enr/enr.go b/p2p/enr/enr.go index 6624c01c70..5e2a0e2847 100644 --- a/p2p/enr/enr.go +++ b/p2p/enr/enr.go @@ -19,7 +19,7 @@ // stored in key/value pairs. To store and retrieve key/values in a record, use the Entry // interface. // -// # Signature Handling +// Signature Handling // // Records must be signed before transmitting them to another node. // diff --git a/p2p/message.go b/p2p/message.go index 9e6ab9d922..82c3386e71 100644 --- a/p2p/message.go +++ b/p2p/message.go @@ -107,11 +107,12 @@ func Send(w MsgWriter, msgcode uint64, data interface{}) error { // SendItems writes an RLP with the given code and data elements. // For a call such as: // -// SendItems(w, code, e1, e2, e3) +// SendItems(w, code, e1, e2, e3) // // the message payload will be an RLP list containing the items: // -// [e1, e2, e3] +// [e1, e2, e3] +// func SendItems(w MsgWriter, msgcode uint64, elems ...interface{}) error { return Send(w, msgcode, elems) } diff --git a/p2p/nat/nat.go b/p2p/nat/nat.go index 908f005fb3..52c435ddf9 100644 --- a/p2p/nat/nat.go +++ b/p2p/nat/nat.go @@ -53,12 +53,12 @@ type Interface interface { // The following formats are currently accepted. // Note that mechanism names are not case-sensitive. // -// "" or "none" return nil -// "extip:77.12.33.4" will assume the local machine is reachable on the given IP -// "any" uses the first auto-detected mechanism -// "upnp" uses the Universal Plug and Play protocol -// "pmp" uses NAT-PMP with an auto-detected gateway address -// "pmp:192.168.0.1" uses NAT-PMP with the given gateway address +// "" or "none" return nil +// "extip:77.12.33.4" will assume the local machine is reachable on the given IP +// "any" uses the first auto-detected mechanism +// "upnp" uses the Universal Plug and Play protocol +// "pmp" uses NAT-PMP with an auto-detected gateway address +// "pmp:192.168.0.1" uses NAT-PMP with the given gateway address func Parse(spec string) (Interface, error) { var ( parts = strings.SplitN(spec, ":", 2) diff --git a/p2p/rlpx/rlpx_test.go b/p2p/rlpx/rlpx_test.go index 6732168059..b0d187173c 100644 --- a/p2p/rlpx/rlpx_test.go +++ b/p2p/rlpx/rlpx_test.go @@ -28,11 +28,11 @@ import ( "strings" "testing" + "github.com/davecgh/go-spew/spew" "github.com/cryptoecc/ETH-ECC/crypto" "github.com/cryptoecc/ETH-ECC/crypto/ecies" "github.com/cryptoecc/ETH-ECC/p2p/simulations/pipes" "github.com/cryptoecc/ETH-ECC/rlp" - "github.com/davecgh/go-spew/spew" "github.com/stretchr/testify/assert" ) diff --git a/p2p/simulations/adapters/exec.go b/p2p/simulations/adapters/exec.go index 78e9871737..ace847592d 100644 --- a/p2p/simulations/adapters/exec.go +++ b/p2p/simulations/adapters/exec.go @@ -34,12 +34,12 @@ import ( "syscall" "time" + "github.com/docker/docker/pkg/reexec" "github.com/cryptoecc/ETH-ECC/log" "github.com/cryptoecc/ETH-ECC/node" "github.com/cryptoecc/ETH-ECC/p2p" "github.com/cryptoecc/ETH-ECC/p2p/enode" "github.com/cryptoecc/ETH-ECC/rpc" - "github.com/docker/docker/pkg/reexec" "github.com/gorilla/websocket" ) diff --git a/p2p/simulations/adapters/types.go b/p2p/simulations/adapters/types.go index 626590bc6f..a1a5864ea4 100644 --- a/p2p/simulations/adapters/types.go +++ b/p2p/simulations/adapters/types.go @@ -25,6 +25,7 @@ import ( "os" "strconv" + "github.com/docker/docker/pkg/reexec" "github.com/cryptoecc/ETH-ECC/crypto" "github.com/cryptoecc/ETH-ECC/log" "github.com/cryptoecc/ETH-ECC/node" @@ -32,7 +33,6 @@ import ( "github.com/cryptoecc/ETH-ECC/p2p/enode" "github.com/cryptoecc/ETH-ECC/p2p/enr" "github.com/cryptoecc/ETH-ECC/rpc" - "github.com/docker/docker/pkg/reexec" "github.com/gorilla/websocket" ) @@ -42,6 +42,7 @@ import ( // * SimNode - An in-memory node // * ExecNode - A child process node // * DockerNode - A Docker container node +// type Node interface { // Addr returns the node's address (e.g. an Enode URL) Addr() []byte diff --git a/p2p/simulations/mocker.go b/p2p/simulations/mocker.go index d40c41e0ca..8c32fd22aa 100644 --- a/p2p/simulations/mocker.go +++ b/p2p/simulations/mocker.go @@ -29,20 +29,20 @@ import ( "github.com/cryptoecc/ETH-ECC/p2p/simulations/adapters" ) -// a map of mocker names to its function +//a map of mocker names to its function var mockerList = map[string]func(net *Network, quit chan struct{}, nodeCount int){ "startStop": startStop, "probabilistic": probabilistic, "boot": boot, } -// Lookup a mocker by its name, returns the mockerFn +//Lookup a mocker by its name, returns the mockerFn func LookupMocker(mockerType string) func(net *Network, quit chan struct{}, nodeCount int) { return mockerList[mockerType] } -// Get a list of mockers (keys of the map) -// Useful for frontend to build available mocker selection +//Get a list of mockers (keys of the map) +//Useful for frontend to build available mocker selection func GetMockerList() []string { list := make([]string, 0, len(mockerList)) for k := range mockerList { @@ -51,7 +51,7 @@ func GetMockerList() []string { return list } -// The boot mockerFn only connects the node in a ring and doesn't do anything else +//The boot mockerFn only connects the node in a ring and doesn't do anything else func boot(net *Network, quit chan struct{}, nodeCount int) { _, err := connectNodesInRing(net, nodeCount) if err != nil { @@ -59,7 +59,7 @@ func boot(net *Network, quit chan struct{}, nodeCount int) { } } -// The startStop mockerFn stops and starts nodes in a defined period (ticker) +//The startStop mockerFn stops and starts nodes in a defined period (ticker) func startStop(net *Network, quit chan struct{}, nodeCount int) { nodes, err := connectNodesInRing(net, nodeCount) if err != nil { @@ -96,10 +96,10 @@ func startStop(net *Network, quit chan struct{}, nodeCount int) { } } -// The probabilistic mocker func has a more probabilistic pattern -// (the implementation could probably be improved): -// nodes are connected in a ring, then a varying number of random nodes is selected, -// mocker then stops and starts them in random intervals, and continues the loop +//The probabilistic mocker func has a more probabilistic pattern +//(the implementation could probably be improved): +//nodes are connected in a ring, then a varying number of random nodes is selected, +//mocker then stops and starts them in random intervals, and continues the loop func probabilistic(net *Network, quit chan struct{}, nodeCount int) { nodes, err := connectNodesInRing(net, nodeCount) if err != nil { @@ -159,7 +159,7 @@ func probabilistic(net *Network, quit chan struct{}, nodeCount int) { } } -// connect nodeCount number of nodes in a ring +//connect nodeCount number of nodes in a ring func connectNodesInRing(net *Network, nodeCount int) ([]enode.ID, error) { ids := make([]enode.ID, nodeCount) for i := 0; i < nodeCount; i++ { diff --git a/p2p/transport_test.go b/p2p/transport_test.go index b34633592d..c1413b7b08 100644 --- a/p2p/transport_test.go +++ b/p2p/transport_test.go @@ -22,10 +22,10 @@ import ( "sync" "testing" + "github.com/davecgh/go-spew/spew" "github.com/cryptoecc/ETH-ECC/crypto" "github.com/cryptoecc/ETH-ECC/p2p/simulations/pipes" - "github.com/davecgh/go-spew/spew" -) + ) func TestProtocolHandshake(t *testing.T) { var ( diff --git a/rlp/decode.go b/rlp/decode.go index e2fca56c91..03f353ea95 100644 --- a/rlp/decode.go +++ b/rlp/decode.go @@ -76,7 +76,7 @@ type Decoder interface { // Note that Decode does not set an input limit for all readers and may be vulnerable to // panics cause by huge value sizes. If you need an input limit, use // -// NewStream(r, limit).Decode(val) +// NewStream(r, limit).Decode(val) func Decode(r io.Reader, val interface{}) error { stream := streamPool.Get().(*Stream) defer streamPool.Put(stream) diff --git a/rpc/client_test.go b/rpc/client_test.go index 87813c8bfa..749af2df7d 100644 --- a/rpc/client_test.go +++ b/rpc/client_test.go @@ -32,9 +32,9 @@ import ( "testing" "time" - "github.com/cryptoecc/ETH-ECC/log" "github.com/davecgh/go-spew/spew" -) + "github.com/cryptoecc/ETH-ECC/log" + ) func TestClientRequest(t *testing.T) { server := newTestServer() diff --git a/rpc/doc.go b/rpc/doc.go index 8d19d7dcbe..7145282974 100644 --- a/rpc/doc.go +++ b/rpc/doc.go @@ -15,6 +15,7 @@ // along with the go-ethereum library. If not, see . /* + Package rpc implements bi-directional JSON-RPC 2.0 on multiple transports. It provides access to the exported methods of an object across a network or other I/O @@ -22,7 +23,7 @@ connection. After creating a server or client instance, objects can be registere them visible as 'services'. Exported methods that follow specific conventions can be called remotely. It also has support for the publish/subscribe pattern. -# RPC Methods +RPC Methods Methods that satisfy the following criteria are made available for remote access: @@ -74,7 +75,7 @@ An example server which uses the JSON codec: l, _ := net.ListenUnix("unix", &net.UnixAddr{Net: "unix", Name: "/tmp/calculator.sock"}) server.ServeListener(l) -# Subscriptions +Subscriptions The package also supports the publish subscribe pattern through the use of subscriptions. A method that is considered eligible for notifications must satisfy the following @@ -100,7 +101,7 @@ the client and server. The server will close the connection for any write error. For more information about subscriptions, see https://github.com/cryptoecc/ETH-ECC/wiki/RPC-PUB-SUB. -# Reverse Calls +Reverse Calls In any method handler, an instance of rpc.Client can be accessed through the ClientFromContext method. Using this client instance, server-to-client method calls can be diff --git a/rpc/handler.go b/rpc/handler.go index 4b379b3415..4433b7f249 100644 --- a/rpc/handler.go +++ b/rpc/handler.go @@ -34,20 +34,21 @@ import ( // // The entry points for incoming messages are: // -// h.handleMsg(message) -// h.handleBatch(message) +// h.handleMsg(message) +// h.handleBatch(message) // // Outgoing calls use the requestOp struct. Register the request before sending it // on the connection: // -// op := &requestOp{ids: ...} -// h.addRequestOp(op) +// op := &requestOp{ids: ...} +// h.addRequestOp(op) // // Now send the request, then wait for the reply to be delivered through handleMsg: // -// if err := op.wait(...); err != nil { -// h.removeRequestOp(op) // timeout, etc. -// } +// if err := op.wait(...); err != nil { +// h.removeRequestOp(op) // timeout, etc. +// } +// type handler struct { reg *serviceRegistry unsubscribeCb *callback diff --git a/signer/core/api_test.go b/signer/core/api_test.go index 89f25015fe..817ac760a1 100644 --- a/signer/core/api_test.go +++ b/signer/core/api_test.go @@ -39,7 +39,7 @@ import ( "github.com/cryptoecc/ETH-ECC/signer/storage" ) -// Used for testing +//Used for testing type headlessUi struct { approveCh chan string // to send approve/deny inputCh chan string // to send password diff --git a/signer/core/apitypes/types.go b/signer/core/apitypes/types.go index 11a19d12fe..637a82d412 100644 --- a/signer/core/apitypes/types.go +++ b/signer/core/apitypes/types.go @@ -64,7 +64,7 @@ func (vs *ValidationMessages) Info(msg string) { vs.Messages = append(vs.Messages, ValidationInfo{INFO, msg}) } -// / getWarnings returns an error with all messages of type WARN of above, or nil if no warnings were present +/// getWarnings returns an error with all messages of type WARN of above, or nil if no warnings were present func (v *ValidationMessages) GetWarnings() error { var messages []string for _, msg := range v.Messages { diff --git a/tests/fuzzers/bls12381/precompile_fuzzer.go b/tests/fuzzers/bls12381/precompile_fuzzer.go index 3c51fa8c4b..8eae0d5d4c 100644 --- a/tests/fuzzers/bls12381/precompile_fuzzer.go +++ b/tests/fuzzers/bls12381/precompile_fuzzer.go @@ -72,10 +72,8 @@ func checkInput(id byte, inputLen int) bool { // The fuzzer functions must return // 1 if the fuzzer should increase priority of the -// -// given input during subsequent fuzzing (for example, the input is lexically -// correct and was parsed successfully); -// +// given input during subsequent fuzzing (for example, the input is lexically +// correct and was parsed successfully); // -1 if the input must not be added to corpus even if gives new coverage; and // 0 otherwise // other values are reserved for future use. diff --git a/tests/fuzzers/difficulty/difficulty-fuzz.go b/tests/fuzzers/difficulty/difficulty-fuzz.go index 448fcfbbfc..1bc213d3b9 100644 --- a/tests/fuzzers/difficulty/difficulty-fuzz.go +++ b/tests/fuzzers/difficulty/difficulty-fuzz.go @@ -68,10 +68,8 @@ func (f *fuzzer) readBool() bool { // The function must return // 1 if the fuzzer should increase priority of the -// -// given input during subsequent fuzzing (for example, the input is lexically -// correct and was parsed successfully); -// +// given input during subsequent fuzzing (for example, the input is lexically +// correct and was parsed successfully); // -1 if the input must not be added to corpus even if gives new coverage; and // 0 otherwise // other values are reserved for future use. diff --git a/tests/fuzzers/rangeproof/rangeproof-fuzzer.go b/tests/fuzzers/rangeproof/rangeproof-fuzzer.go index ff0362a008..84585658d0 100644 --- a/tests/fuzzers/rangeproof/rangeproof-fuzzer.go +++ b/tests/fuzzers/rangeproof/rangeproof-fuzzer.go @@ -181,10 +181,8 @@ func (f *fuzzer) fuzz() int { // The function must return // 1 if the fuzzer should increase priority of the -// -// given input during subsequent fuzzing (for example, the input is lexically -// correct and was parsed successfully); -// +// given input during subsequent fuzzing (for example, the input is lexically +// correct and was parsed successfully); // -1 if the input must not be added to corpus even if gives new coverage; and // 0 otherwise; other values are reserved for future use. func Fuzz(input []byte) int { diff --git a/tests/fuzzers/stacktrie/trie_fuzzer.go b/tests/fuzzers/stacktrie/trie_fuzzer.go index 59b379d817..cc3bd29291 100644 --- a/tests/fuzzers/stacktrie/trie_fuzzer.go +++ b/tests/fuzzers/stacktrie/trie_fuzzer.go @@ -115,10 +115,8 @@ func (k kvs) Swap(i, j int) { // The function must return // 1 if the fuzzer should increase priority of the -// -// given input during subsequent fuzzing (for example, the input is lexically -// correct and was parsed successfully); -// +// given input during subsequent fuzzing (for example, the input is lexically +// correct and was parsed successfully); // -1 if the input must not be added to corpus even if gives new coverage; and // 0 otherwise // other values are reserved for future use. diff --git a/tests/fuzzers/trie/trie-fuzzer.go b/tests/fuzzers/trie/trie-fuzzer.go index 3e6f6dad02..9a680ef111 100644 --- a/tests/fuzzers/trie/trie-fuzzer.go +++ b/tests/fuzzers/trie/trie-fuzzer.go @@ -120,10 +120,8 @@ func Generate(input []byte) randTest { // The function must return // 1 if the fuzzer should increase priority of the -// -// given input during subsequent fuzzing (for example, the input is lexically -// correct and was parsed successfully); -// +// given input during subsequent fuzzing (for example, the input is lexically +// correct and was parsed successfully); // -1 if the input must not be added to corpus even if gives new coverage; and // 0 otherwise // other values are reserved for future use. diff --git a/tests/init_test.go b/tests/init_test.go index 4bca0f7ca8..496532d9df 100644 --- a/tests/init_test.go +++ b/tests/init_test.go @@ -116,7 +116,6 @@ func (tm *testMatcher) skipLoad(pattern string) { } // fails adds an expected failure for tests matching the pattern. -// //nolint:unused func (tm *testMatcher) fails(pattern string, reason string) { if reason == "" { diff --git a/trie/hasher.go b/trie/hasher.go index 10c5ac1e6c..1f3309e8b6 100644 --- a/trie/hasher.go +++ b/trie/hasher.go @@ -170,8 +170,8 @@ func (h *hasher) fullnodeToHash(n *fullNode, force bool) node { // // All node encoding must be done like this: // -// node.encode(h.encbuf) -// enc := h.encodedBytes() +// node.encode(h.encbuf) +// enc := h.encodedBytes() // // This convention exists because node.encode can only be inlined/escape-analyzed when // called on a concrete receiver type. diff --git a/trie/proof.go b/trie/proof.go index f5bbfbb4cf..9a83d9ba94 100644 --- a/trie/proof.go +++ b/trie/proof.go @@ -339,9 +339,9 @@ findFork: // unset removes all internal node references either the left most or right most. // It can meet these scenarios: // -// - The given path is existent in the trie, unset the associated nodes with the -// specific direction -// - The given path is non-existent in the trie +// - The given path is existent in the trie, unset the associated nodes with the +// specific direction +// - The given path is non-existent in the trie // - the fork point is a fullnode, the corresponding child pointed by path // is nil, return // - the fork point is a shortnode, the shortnode is included in the range, @@ -458,15 +458,15 @@ func hasRightElement(node node, key []byte) bool { // Expect the normal case, this function can also be used to verify the following // range proofs: // -// - All elements proof. In this case the proof can be nil, but the range should -// be all the leaves in the trie. +// - All elements proof. In this case the proof can be nil, but the range should +// be all the leaves in the trie. // -// - One element proof. In this case no matter the edge proof is a non-existent -// proof or not, we can always verify the correctness of the proof. +// - One element proof. In this case no matter the edge proof is a non-existent +// proof or not, we can always verify the correctness of the proof. // -// - Zero element proof. In this case a single non-existent proof is enough to prove. -// Besides, if there are still some other leaves available on the right side, then -// an error will be returned. +// - Zero element proof. In this case a single non-existent proof is enough to prove. +// Besides, if there are still some other leaves available on the right side, then +// an error will be returned. // // Except returning the error to indicate the proof is valid or not, the function will // also return a flag to indicate whether there exists more accounts/slots in the trie. diff --git a/trie/secure_trie.go b/trie/secure_trie.go index 78227f6675..2d4fdfed4d 100644 --- a/trie/secure_trie.go +++ b/trie/secure_trie.go @@ -35,14 +35,14 @@ func NewSecure(owner common.Hash, root common.Hash, db *Database) (*SecureTrie, return NewStateTrie(owner, root, db) } -// StateTrie wraps a trie with key hashing. In a secure trie, all +// StateTrie wraps a trie with key hashing. In a stateTrie trie, all // access operations hash the key using keccak256. This prevents // calling code from creating long chains of nodes that // increase the access time. // // Contrary to a regular trie, a StateTrie can only be created with // New and must have an attached database. The database also stores -// the preimage of each key. +// the preimage of each key if preimage recording is enabled. // // StateTrie is not safe for concurrent use. type StateTrie struct { @@ -53,17 +53,11 @@ type StateTrie struct { secKeyCacheOwner *StateTrie // Pointer to self, replace the key cache on mismatch } -// NewStateTrie creates a trie with an existing root node from a backing database -// and optional intermediate in-memory node pool. +// NewStateTrie creates a trie with an existing root node from a backing database. // // If root is the zero hash or the sha3 hash of an empty string, the // trie is initially empty. Otherwise, New will panic if db is nil // and returns MissingNodeError if the root node cannot be found. -// -// Accessing the trie loads nodes from the database or node pool on demand. -// Loaded nodes are kept around until their 'cache generation' expires. -// A new cache generation is created by each call to Commit. -// cachelimit sets the number of past cache generations to keep. func NewStateTrie(owner common.Hash, root common.Hash, db *Database) (*StateTrie, error) { if db == nil { panic("trie.NewSecure called without a database") @@ -87,11 +81,15 @@ func (t *StateTrie) Get(key []byte) []byte { // TryGet returns the value for key stored in the trie. // The value bytes must not be modified by the caller. -// If a node was not found in the database, a MissingNodeError is returned. +// If the specified node is not in the trie, nil will be returned. +// If a trie node is not found in the database, a MissingNodeError is returned. func (t *StateTrie) TryGet(key []byte) ([]byte, error) { return t.trie.TryGet(t.hashKey(key)) } +// TryGetAccount attempts to retrieve an account with provided trie path. +// If the specified account is not in the trie, nil will be returned. +// If a trie node is not found in the database, a MissingNodeError is returned. func (t *StateTrie) TryGetAccount(key []byte) (*types.StateAccount, error) { var ret types.StateAccount res, err := t.trie.TryGet(t.hashKey(key)) diff --git a/trie/stacktrie.go b/trie/stacktrie.go index 04a21aa2f0..0fb83d2cfe 100644 --- a/trie/stacktrie.go +++ b/trie/stacktrie.go @@ -376,12 +376,11 @@ func (st *StackTrie) insert(key, value []byte) { // hash converts st into a 'hashedNode', if possible. Possible outcomes: // // 1. The rlp-encoded value was >= 32 bytes: -// - Then the 32-byte `hash` will be accessible in `st.val`. -// - And the 'st.type' will be 'hashedNode' -// +// - Then the 32-byte `hash` will be accessible in `st.val`. +// - And the 'st.type' will be 'hashedNode' // 2. The rlp-encoded value was < 32 bytes -// - Then the <32 byte rlp-encoded value will be accessible in 'st.val'. -// - And the 'st.type' will be 'hashedNode' AGAIN +// - Then the <32 byte rlp-encoded value will be accessible in 'st.val'. +// - And the 'st.type' will be 'hashedNode' AGAIN // // This method also sets 'st.type' to hashedNode, and clears 'st.key'. func (st *StackTrie) hash() { diff --git a/trie/trie_test.go b/trie/trie_test.go index cd084fbfcf..45740edf7e 100644 --- a/trie/trie_test.go +++ b/trie/trie_test.go @@ -28,6 +28,7 @@ import ( "testing" "testing/quick" + "github.com/davecgh/go-spew/spew" "github.com/cryptoecc/ETH-ECC/common" "github.com/cryptoecc/ETH-ECC/core/rawdb" "github.com/cryptoecc/ETH-ECC/core/types" @@ -35,7 +36,6 @@ import ( "github.com/cryptoecc/ETH-ECC/ethdb" "github.com/cryptoecc/ETH-ECC/ethdb/memorydb" "github.com/cryptoecc/ETH-ECC/rlp" - "github.com/davecgh/go-spew/spew" "golang.org/x/crypto/sha3" )