mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 02:42:27 +00:00
all: fix packages and comments
This commit is contained in:
parent
c2fc306206
commit
e5a24bdf69
117 changed files with 506 additions and 525 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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"))
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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))
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
2
cmd/evm/testdata/21/readme.md
vendored
2
cmd/evm/testdata/21/readme.md
vendored
|
|
@ -21,3 +21,5 @@ $ go run . b11r --input.header=testdata/21/header.json --input.txs=testdata/21/t
|
|||
"hash": "0x71c59102cc805dbe8741e1210ebe229a321eff144ac7276006fefe39e8357dc7"
|
||||
}
|
||||
```
|
||||
|
||||
## Eccpow(working...)
|
||||
|
|
|
|||
|
|
@ -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 (
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ func copyConfig(original *params.ChainConfig) *params.ChainConfig {
|
|||
TerminalTotalDifficulty: original.TerminalTotalDifficulty,
|
||||
Ethash: original.Ethash,
|
||||
Clique: original.Clique,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func config() *params.ChainConfig {
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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(),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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{
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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: " "}
|
||||
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
16
les/api.go
16
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)
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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 (
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,8 +38,8 @@ type Enode struct {
|
|||
//
|
||||
// For incomplete nodes, the designator must look like one of these
|
||||
//
|
||||
// enode://<hex node id>
|
||||
// <hex node id>
|
||||
// enode://<hex node id>
|
||||
// <hex node id>
|
||||
//
|
||||
// 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://<hex node id>@10.3.58.6:30303?discport=30301
|
||||
// enode://<hex node id>@10.3.58.6:30303?discport=30301
|
||||
func NewEnode(rawurl string) (*Enode, error) {
|
||||
node, err := enode.Parse(enode.ValidSchemes, rawurl)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -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 }
|
||||
|
|
|
|||
11
p2p/dial.go
11
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
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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 (
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -54,8 +54,8 @@ func MustParseV4(rawurl string) *Node {
|
|||
//
|
||||
// For incomplete nodes, the designator must look like one of these
|
||||
//
|
||||
// enode://<hex node id>
|
||||
// <hex node id>
|
||||
// enode://<hex node id>
|
||||
// <hex node id>
|
||||
//
|
||||
// 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://<hex node id>@10.3.58.6:30303?discport=30301
|
||||
// enode://<hex node id>@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])
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
//
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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++ {
|
||||
|
|
|
|||
|
|
@ -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 (
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue