all: fix packages and comments

This commit is contained in:
Your Name 2024-04-23 12:32:40 +09:00
parent c2fc306206
commit e5a24bdf69
117 changed files with 506 additions and 525 deletions

View file

@ -165,7 +165,6 @@ 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{}
// }
@ -725,7 +724,6 @@ 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);
@ -734,9 +732,7 @@ func TestBareEvents(t *testing.T) {
// 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]}
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"}]`
@ -1082,7 +1078,6 @@ 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);
// event send0();
@ -1111,7 +1106,6 @@ 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 {
// event send(uint256, uint256);
// }

View file

@ -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"
@ -994,7 +994,6 @@ 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]}
func TestPendingAndCallContract(t *testing.T) {
testAddr := crypto.PubkeyToAddress(testKey.PublicKey)
@ -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)

View file

@ -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

View file

@ -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"
)

View file

@ -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.

View file

@ -177,7 +177,6 @@ type Backend interface {
// safely used to calculate a signature from.
//
// The hash is calculated as
//
// keccak256("\x19Ethereum Signed Message:\n"${message length}${message}).
//
// This gives context to the signed message and prevents signing of transactions.
@ -190,7 +189,6 @@ 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}).
//
// This gives context to the signed message and prevents signing of transactions.

View file

@ -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"))

View file

@ -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)

View file

@ -407,6 +407,8 @@ func (w *ledgerDriver) ledgerSign(derivationPath []uint32, tx *types.Transaction
// domain hash | 32 bytes
// message hash | 32 bytes
//
//
//
// And the output data is:
//
// Description | Length

View file

@ -84,14 +84,14 @@ 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
// * 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
// * 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
// * 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

View file

@ -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 {

View file

@ -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

View file

@ -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"

View file

@ -336,7 +336,6 @@ func (t *txWithKey) UnmarshalJSON(input []byte) error {
// The transactions can have two forms, either
// 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.

View file

@ -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.

View file

@ -21,3 +21,5 @@ $ go run . b11r --input.header=testdata/21/header.json --input.txs=testdata/21/t
"hash": "0x71c59102cc805dbe8741e1210ebe229a321eff144ac7276006fefe39e8357dc7"
}
```
## Eccpow(working...)

View file

@ -33,6 +33,7 @@
//
// $ p2psim node connect node01 node02
// Connected node01 to node02
//
package main
import (

View file

@ -29,7 +29,6 @@ import (
// - 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 {

View file

@ -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)
}

View file

@ -34,7 +34,6 @@ 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

View file

@ -339,7 +339,6 @@ 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

View file

@ -40,7 +40,6 @@ 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

View file

@ -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.

View file

@ -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")
}

View file

@ -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
//
// 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(),
}
}

View file

@ -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

View file

@ -2050,7 +2050,6 @@ 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
func TestPrunedImportSide(t *testing.T) {
//glogger := log.NewGlogHandler(log.StreamHandler(os.Stdout, log.TerminalFormat(false)))
@ -3376,6 +3375,7 @@ func TestDeleteRecreateSlotsAcrossManyBlocks(t *testing.T) {
// 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

View file

@ -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()

View file

@ -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

View file

@ -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"
)

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -264,7 +264,6 @@ 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

View file

@ -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
//
// 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
//
// 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,
//
// state should return emptyCodeHash(0xc5d246...) as 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,
@ -416,11 +411,9 @@ func opExtCodeCopy(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext)
// customized chain, the return value will be zero.
//
// (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,
//
// 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()

View file

@ -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.

View file

@ -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"

View file

@ -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: " "}

View file

@ -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()

View file

@ -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.

View file

@ -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
//
// 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) {

View file

@ -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 {

View file

@ -480,7 +480,6 @@ 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

View file

@ -71,7 +71,6 @@ 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

View file

@ -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"

View file

@ -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

View file

@ -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.

View file

@ -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"
)

View file

@ -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

View file

@ -212,7 +212,6 @@ func (oracle *Oracle) resolveBlockRange(ctx context.Context, reqEnd rpc.BlockNum
// 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) {

View file

@ -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
}

View file

@ -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

View file

@ -369,7 +369,6 @@ func createStorageRequestResponse(t *testPeer, root common.Hash, accounts []comm
}
// 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

View file

@ -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"

View file

@ -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")

View file

@ -266,7 +266,6 @@ 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)
// -------+------------+---------------+---------------+---------------+---------------

View file

@ -102,7 +102,6 @@ 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

View file

@ -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"

View file

@ -731,9 +731,9 @@ 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
// * 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)

View file

@ -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) {

View file

@ -366,7 +366,6 @@ 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
@ -385,7 +384,6 @@ 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

View file

@ -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"

View file

@ -57,20 +57,13 @@ 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
//
// If the total difficulty was not reached:
//
// 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 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
func (api *ConsensusAPI) ForkchoiceUpdatedV1(heads beacon.ForkchoiceStateV1, payloadAttributes *beacon.PayloadAttributesV1) (beacon.ForkChoiceResponse, error) {
if heads.HeadBlockHash == (common.Hash{}) {

View file

@ -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.

View file

@ -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
//
// 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) {

View file

@ -477,7 +477,6 @@ 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

View file

@ -71,7 +71,6 @@ 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

View file

@ -242,7 +242,6 @@ 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

View file

@ -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 {

View file

@ -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 (

View file

@ -76,11 +76,8 @@ 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
//
// 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
type TxRelayBackend interface {

View file

@ -84,6 +84,7 @@ type TerminalStringer interface {
// Example:
//
// [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}

View file

@ -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

View file

@ -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()
}

View file

@ -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"
)

View file

@ -90,6 +90,7 @@ var (
// - 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

View file

@ -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 {

View file

@ -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
//
var writeTestVectorsFlag = flag.Bool("write-test-vectors", false, "Overwrite discv5 test vectors in testdata/")
var (

View file

@ -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

View file

@ -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 {

View file

@ -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.
//

View file

@ -112,6 +112,7 @@ func Send(w MsgWriter, msgcode uint64, data interface{}) error {
// the message payload will be an RLP list containing the items:
//
// [e1, e2, e3]
//
func SendItems(w MsgWriter, msgcode uint64, elems ...interface{}) error {
return Send(w, msgcode, elems)
}

View file

@ -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"
)

View file

@ -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"
)

View file

@ -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

View file

@ -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++ {

View file

@ -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 (

View file

@ -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()

View file

@ -15,6 +15,7 @@
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
/*
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

View file

@ -48,6 +48,7 @@ import (
// if err := op.wait(...); err != nil {
// h.removeRequestOp(op) // timeout, etc.
// }
//
type handler struct {
reg *serviceRegistry
unsubscribeCb *callback

View file

@ -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

View file

@ -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 {

View file

@ -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);
//
// -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.

View file

@ -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);
//
// -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.

View file

@ -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);
//
// -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 {

View file

@ -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);
//
// -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.

View file

@ -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);
//
// -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.

View file

@ -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 == "" {

View file

@ -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))

View file

@ -378,7 +378,6 @@ func (st *StackTrie) insert(key, value []byte) {
// 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'
//
// 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

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