all: fix packages and comments

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

View file

@ -165,9 +165,8 @@ func TestInvalidABI(t *testing.T) {
// TestConstructor tests a constructor function. // TestConstructor tests a constructor function.
// The test is based on the following contract: // The test is based on the following contract:
// // contract TestConstructor {
// contract TestConstructor { // constructor(uint256 a, uint256 b) public{}
// constructor(uint256 a, uint256 b) public{}
// } // }
func TestConstructor(t *testing.T) { func TestConstructor(t *testing.T) {
json := `[{ "inputs": [{"internalType": "uint256","name": "a","type": "uint256" },{ "internalType": "uint256","name": "b","type": "uint256"}],"stateMutability": "nonpayable","type": "constructor"}]` 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: // TestUnpackEvent is based on this contract:
// // contract T {
// contract T { // event received(address sender, uint amount, bytes memo);
// event received(address sender, uint amount, bytes memo); // event receivedAddr(address sender);
// event receivedAddr(address sender); // function receive(bytes memo) external payable {
// function receive(bytes memo) external payable { // received(msg.sender, msg.value, memo);
// received(msg.sender, msg.value, memo); // receivedAddr(msg.sender);
// receivedAddr(msg.sender); // }
// } // }
// }
//
// When receive("X") is called with sender 0x00... and value 1, it produces this tx receipt: // 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) { 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"}]` 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)) 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 // TestDoubleDuplicateEventNames checks that if send0 already exists, there won't be a name
// conflict and that the second send event will be renamed send1. // conflict and that the second send event will be renamed send1.
// The test runs the abi of the following contract. // The test runs the abi of the following contract.
// // contract DuplicateEvent {
// contract DuplicateEvent { // event send(uint256 a);
// event send(uint256 a);
// event send0(); // event send0();
// event send(); // event send();
// } // }
@ -1111,8 +1106,7 @@ func TestDoubleDuplicateEventNames(t *testing.T) {
// TestUnnamedEventParam checks that an event with unnamed parameters is // TestUnnamedEventParam checks that an event with unnamed parameters is
// correctly handled. // correctly handled.
// The test runs the abi of the following contract. // The test runs the abi of the following contract.
// // contract TestEvent {
// contract TestEvent {
// event send(uint256, uint256); // event send(uint256, uint256);
// } // }
func TestUnnamedEventParam(t *testing.T) { func TestUnnamedEventParam(t *testing.T) {

View file

@ -27,7 +27,7 @@ import (
"testing" "testing"
"time" "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"
"github.com/cryptoecc/ETH-ECC/accounts/abi/bind" "github.com/cryptoecc/ETH-ECC/accounts/abi/bind"
"github.com/cryptoecc/ETH-ECC/common" "github.com/cryptoecc/ETH-ECC/common"
@ -93,17 +93,17 @@ func TestSimulatedBackend(t *testing.T) {
var testKey, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291") var testKey, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
// the following is based on this contract: // the following is based on this contract:
// contract T { // contract T {
// event received(address sender, uint amount, bytes memo); // event received(address sender, uint amount, bytes memo);
// event receivedAddr(address sender); // event receivedAddr(address sender);
// //
// function receive(bytes calldata memo) external payable returns (string memory res) { // function receive(bytes calldata memo) external payable returns (string memory res) {
// emit received(msg.sender, msg.value, memo); // emit received(msg.sender, msg.value, memo);
// emit receivedAddr(msg.sender); // emit receivedAddr(msg.sender);
// return "hello world"; // 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 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 abiBin = `0x608060405234801561001057600080fd5b506102a0806100206000396000f3fe60806040526004361061003b576000357c010000000000000000000000000000000000000000000000000000000090048063a69b6ed014610040575b600080fd5b6100b76004803603602081101561005657600080fd5b810190808035906020019064010000000081111561007357600080fd5b82018360208201111561008557600080fd5b803590602001918460018302840111640100000000831117156100a757600080fd5b9091929391929390505050610132565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100f75780820151818401526020810190506100dc565b50505050905090810190601f1680156101245780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b60607f75fd880d39c1daf53b6547ab6cb59451fc6452d27caa90e5b6649dd8293b9eed33348585604051808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001848152602001806020018281038252848482818152602001925080828437600081840152601f19601f8201169050808301925050509550505050505060405180910390a17f46923992397eac56cf13058aced2a1871933622717e27b24eabc13bf9dd329c833604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390a16040805190810160405280600b81526020017f68656c6c6f20776f726c6400000000000000000000000000000000000000000081525090509291505056fea165627a7a72305820ff0c57dad254cfeda48c9cfb47f1353a558bccb4d1bc31da1dae69315772d29e0029`
const deployedCode = `60806040526004361061003b576000357c010000000000000000000000000000000000000000000000000000000090048063a69b6ed014610040575b600080fd5b6100b76004803603602081101561005657600080fd5b810190808035906020019064010000000081111561007357600080fd5b82018360208201111561008557600080fd5b803590602001918460018302840111640100000000831117156100a757600080fd5b9091929391929390505050610132565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100f75780820151818401526020810190506100dc565b50505050905090810190601f1680156101245780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b60607f75fd880d39c1daf53b6547ab6cb59451fc6452d27caa90e5b6649dd8293b9eed33348585604051808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001848152602001806020018281038252848482818152602001925080828437600081840152601f19601f8201169050808301925050509550505050505060405180910390a17f46923992397eac56cf13058aced2a1871933622717e27b24eabc13bf9dd329c833604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390a16040805190810160405280600b81526020017f68656c6c6f20776f726c6400000000000000000000000000000000000000000081525090509291505056fea165627a7a72305820ff0c57dad254cfeda48c9cfb47f1353a558bccb4d1bc31da1dae69315772d29e0029` 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: // 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) { func TestPendingAndCallContract(t *testing.T) {
testAddr := crypto.PubkeyToAddress(testKey.PublicKey) testAddr := crypto.PubkeyToAddress(testKey.PublicKey)
sim := simTestBackend(testAddr) sim := simTestBackend(testAddr)
@ -1206,7 +1205,6 @@ func TestFork(t *testing.T) {
Example contract to test event emission: Example contract to test event emission:
pragma solidity >=0.7.0 <0.9.0; pragma solidity >=0.7.0 <0.9.0;
contract Callable { contract Callable {
event Called(); event Called();
function Call() public { emit Called(); } function Call() public { emit Called(); }
@ -1228,7 +1226,6 @@ const callableBin = "6080604052348015600f57600080fd5b5060998061001e6000396000f3f
// 7. Mine two blocks to trigger a reorg. // 7. Mine two blocks to trigger a reorg.
// 8. Check that the event was removed. // 8. Check that the event was removed.
// 9. Re-send the transaction and mine a block. // 9. Re-send the transaction and mine a block.
//
// 10. Check that the event was reborn. // 10. Check that the event was reborn.
func TestForkLogsReborn(t *testing.T) { func TestForkLogsReborn(t *testing.T) {
testAddr := crypto.PubkeyToAddress(testKey.PublicKey) testAddr := crypto.PubkeyToAddress(testKey.PublicKey)

View file

@ -24,13 +24,13 @@ import (
"strings" "strings"
"sync" "sync"
ethereum "github.com/cryptoecc/ETH-ECC"
"github.com/cryptoecc/ETH-ECC/accounts/abi" "github.com/cryptoecc/ETH-ECC/accounts/abi"
"github.com/cryptoecc/ETH-ECC/common" "github.com/cryptoecc/ETH-ECC/common"
"github.com/cryptoecc/ETH-ECC/core/types" "github.com/cryptoecc/ETH-ECC/core/types"
"github.com/cryptoecc/ETH-ECC/crypto" "github.com/cryptoecc/ETH-ECC/crypto"
"github.com/cryptoecc/ETH-ECC/event" "github.com/cryptoecc/ETH-ECC/event"
"github.com/ethereum/go-ethereum" )
)
const basefeeWiggleMultiplier = 2 const basefeeWiggleMultiplier = 2

View file

@ -24,6 +24,7 @@ import (
"strings" "strings"
"testing" "testing"
"github.com/cryptoecc/ETH-ECC"
"github.com/cryptoecc/ETH-ECC/accounts/abi" "github.com/cryptoecc/ETH-ECC/accounts/abi"
"github.com/cryptoecc/ETH-ECC/accounts/abi/bind" "github.com/cryptoecc/ETH-ECC/accounts/abi/bind"
"github.com/cryptoecc/ETH-ECC/common" "github.com/cryptoecc/ETH-ECC/common"
@ -31,7 +32,6 @@ import (
"github.com/cryptoecc/ETH-ECC/core/types" "github.com/cryptoecc/ETH-ECC/core/types"
"github.com/cryptoecc/ETH-ECC/crypto" "github.com/cryptoecc/ETH-ECC/crypto"
"github.com/cryptoecc/ETH-ECC/rlp" "github.com/cryptoecc/ETH-ECC/rlp"
"github.com/ethereum/go-ethereum"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
) )

View file

@ -21,9 +21,9 @@ import (
"reflect" "reflect"
"testing" "testing"
"github.com/cryptoecc/ETH-ECC/common"
"github.com/davecgh/go-spew/spew" "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 // 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. // the stringer interface to allow printing type details in the tests below.

View file

@ -177,8 +177,7 @@ type Backend interface {
// safely used to calculate a signature from. // safely used to calculate a signature from.
// //
// The hash is calculated as // 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. // This gives context to the signed message and prevents signing of transactions.
func TextHash(data []byte) []byte { func TextHash(data []byte) []byte {
@ -190,8 +189,7 @@ func TextHash(data []byte) []byte {
// safely used to calculate a signature from. // safely used to calculate a signature from.
// //
// The hash is calculated as // 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. // This gives context to the signed message and prevents signing of transactions.
func TextAndHash(data []byte) ([]byte, string) { func TextAndHash(data []byte) ([]byte, string) {

View file

@ -27,10 +27,10 @@ import (
"time" "time"
"github.com/cespare/cp" "github.com/cespare/cp"
"github.com/davecgh/go-spew/spew"
"github.com/cryptoecc/ETH-ECC/accounts" "github.com/cryptoecc/ETH-ECC/accounts"
"github.com/cryptoecc/ETH-ECC/common" "github.com/cryptoecc/ETH-ECC/common"
"github.com/davecgh/go-spew/spew" )
)
var ( var (
cachetestDir, _ = filepath.Abs(filepath.Join("testdata", "keystore")) cachetestDir, _ = filepath.Abs(filepath.Join("testdata", "keystore"))

View file

@ -879,7 +879,6 @@ func (s *Session) walletStatus() (*walletStatus, error) {
} }
// derivationPath fetches the wallet's current derivation path from the card. // derivationPath fetches the wallet's current derivation path from the card.
//
//lint:ignore U1000 needs to be added to the console interface //lint:ignore U1000 needs to be added to the console interface
func (s *Session) derivationPath() (accounts.DerivationPath, error) { func (s *Session) derivationPath() (accounts.DerivationPath, error) {
response, err := s.Channel.transmitEncrypted(claSCWallet, insStatus, statusP1Path, 0, nil) response, err := s.Channel.transmitEncrypted(claSCWallet, insStatus, statusP1Path, 0, nil)

View file

@ -195,18 +195,18 @@ func (w *ledgerDriver) SignTypedMessage(path accounts.DerivationPath, domainHash
// //
// The version retrieval protocol is defined as follows: // The version retrieval protocol is defined as follows:
// //
// CLA | INS | P1 | P2 | Lc | Le // CLA | INS | P1 | P2 | Lc | Le
// ----+-----+----+----+----+--- // ----+-----+----+----+----+---
// E0 | 06 | 00 | 00 | 00 | 04 // E0 | 06 | 00 | 00 | 00 | 04
// //
// With no input data, and the output data being: // With no input data, and the output data being:
// //
// Description | Length // Description | Length
// ---------------------------------------------------+-------- // ---------------------------------------------------+--------
// Flags 01: arbitrary data signature enabled by user | 1 byte // Flags 01: arbitrary data signature enabled by user | 1 byte
// Application major version | 1 byte // Application major version | 1 byte
// Application minor version | 1 byte // Application minor version | 1 byte
// Application patch version | 1 byte // Application patch version | 1 byte
func (w *ledgerDriver) ledgerVersion() ([3]byte, error) { func (w *ledgerDriver) ledgerVersion() ([3]byte, error) {
// Send the request and wait for the response // Send the request and wait for the response
reply, err := w.ledgerExchange(ledgerOpGetConfiguration, 0, 0, nil) 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: // The address derivation protocol is defined as follows:
// //
// CLA | INS | P1 | P2 | Lc | Le // CLA | INS | P1 | P2 | Lc | Le
// ----+-----+----+----+-----+--- // ----+-----+----+----+-----+---
// E0 | 02 | 00 return address // E0 | 02 | 00 return address
// 01 display address and confirm before returning // 01 display address and confirm before returning
// | 00: do not return the chain code // | 00: do not return the chain code
// | 01: return the chain code // | 01: return the chain code
// | var | 00 // | var | 00
// //
// Where the input data is: // Where the input data is:
// //
// Description | Length // Description | Length
// -------------------------------------------------+-------- // -------------------------------------------------+--------
// Number of BIP 32 derivations to perform (max 10) | 1 byte // Number of BIP 32 derivations to perform (max 10) | 1 byte
// First derivation index (big endian) | 4 bytes // First derivation index (big endian) | 4 bytes
// ... | 4 bytes // ... | 4 bytes
// Last derivation index (big endian) | 4 bytes // Last derivation index (big endian) | 4 bytes
// //
// And the output data is: // And the output data is:
// //
// Description | Length // Description | Length
// ------------------------+------------------- // ------------------------+-------------------
// Public Key length | 1 byte // Public Key length | 1 byte
// Uncompressed Public Key | arbitrary // Uncompressed Public Key | arbitrary
// Ethereum address length | 1 byte // Ethereum address length | 1 byte
// Ethereum address | 40 bytes hex ascii // Ethereum address | 40 bytes hex ascii
// Chain code if requested | 32 bytes // Chain code if requested | 32 bytes
func (w *ledgerDriver) ledgerDerive(derivationPath []uint32) (common.Address, error) { func (w *ledgerDriver) ledgerDerive(derivationPath []uint32) (common.Address, error) {
// Flatten the derivation path into the Ledger request // Flatten the derivation path into the Ledger request
path := make([]byte, 1+4*len(derivationPath)) 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: // The transaction signing protocol is defined as follows:
// //
// CLA | INS | P1 | P2 | Lc | Le // CLA | INS | P1 | P2 | Lc | Le
// ----+-----+----+----+-----+--- // ----+-----+----+----+-----+---
// E0 | 04 | 00: first transaction data block // E0 | 04 | 00: first transaction data block
// 80: subsequent transaction data block // 80: subsequent transaction data block
// | 00 | variable | variable // | 00 | variable | variable
// //
// Where the input for the first transaction block (first 255 bytes) is: // Where the input for the first transaction block (first 255 bytes) is:
// //
// Description | Length // Description | Length
// -------------------------------------------------+---------- // -------------------------------------------------+----------
// Number of BIP 32 derivations to perform (max 10) | 1 byte // Number of BIP 32 derivations to perform (max 10) | 1 byte
// First derivation index (big endian) | 4 bytes // First derivation index (big endian) | 4 bytes
// ... | 4 bytes // ... | 4 bytes
// Last derivation index (big endian) | 4 bytes // Last derivation index (big endian) | 4 bytes
// RLP transaction chunk | arbitrary // RLP transaction chunk | arbitrary
// //
// And the input for subsequent transaction blocks (first 255 bytes) are: // And the input for subsequent transaction blocks (first 255 bytes) are:
// //
// Description | Length // Description | Length
// ----------------------+---------- // ----------------------+----------
// RLP transaction chunk | arbitrary // RLP transaction chunk | arbitrary
// //
// And the output data is: // And the output data is:
// //
// Description | Length // Description | Length
// ------------+--------- // ------------+---------
// signature V | 1 byte // signature V | 1 byte
// signature R | 32 bytes // signature R | 32 bytes
// signature S | 32 bytes // signature S | 32 bytes
func (w *ledgerDriver) ledgerSign(derivationPath []uint32, tx *types.Transaction, chainID *big.Int) (common.Address, *types.Transaction, error) { 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 // Flatten the derivation path into the Ledger request
path := make([]byte, 1+4*len(derivationPath)) 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: // The signing protocol is defined as follows:
// //
// CLA | INS | P1 | P2 | Lc | Le // CLA | INS | P1 | P2 | Lc | Le
// ----+-----+----+-----------------------------+-----+--- // ----+-----+----+-----------------------------+-----+---
// E0 | 0C | 00 | implementation version : 00 | variable | variable // E0 | 0C | 00 | implementation version : 00 | variable | variable
// //
// Where the input is: // Where the input is:
// //
// Description | Length // Description | Length
// -------------------------------------------------+---------- // -------------------------------------------------+----------
// Number of BIP 32 derivations to perform (max 10) | 1 byte // Number of BIP 32 derivations to perform (max 10) | 1 byte
// First derivation index (big endian) | 4 bytes // First derivation index (big endian) | 4 bytes
// ... | 4 bytes // ... | 4 bytes
// Last derivation index (big endian) | 4 bytes // Last derivation index (big endian) | 4 bytes
// domain hash | 32 bytes // domain hash | 32 bytes
// message hash | 32 bytes // message hash | 32 bytes
//
//
// //
// And the output data is: // And the output data is:
// //
// Description | Length // Description | Length
// ------------+--------- // ------------+---------
// signature V | 1 byte // signature V | 1 byte
// signature R | 32 bytes // signature R | 32 bytes
// signature S | 32 bytes // signature S | 32 bytes
func (w *ledgerDriver) ledgerSignTypedMessage(derivationPath []uint32, domainHash []byte, messageHash []byte) ([]byte, error) { func (w *ledgerDriver) ledgerSignTypedMessage(derivationPath []uint32, domainHash []byte, messageHash []byte) ([]byte, error) {
// Flatten the derivation path into the Ledger request // Flatten the derivation path into the Ledger request
path := make([]byte, 1+4*len(derivationPath)) 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: // The common transport header is defined as follows:
// //
// Description | Length // Description | Length
// --------------------------------------+---------- // --------------------------------------+----------
// Communication channel ID (big endian) | 2 bytes // Communication channel ID (big endian) | 2 bytes
// Command tag | 1 byte // Command tag | 1 byte
// Packet sequence index (big endian) | 2 bytes // Packet sequence index (big endian) | 2 bytes
// Payload | arbitrary // Payload | arbitrary
// //
// The Communication channel ID allows commands multiplexing over the same // 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 // 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: // APDU Command payloads are encoded as follows:
// //
// Description | Length // Description | Length
// ----------------------------------- // -----------------------------------
// APDU length (big endian) | 2 bytes // APDU length (big endian) | 2 bytes
// APDU CLA | 1 byte // APDU CLA | 1 byte
// APDU INS | 1 byte // APDU INS | 1 byte
// APDU P1 | 1 byte // APDU P1 | 1 byte
// APDU P2 | 1 byte // APDU P2 | 1 byte
// APDU length | 1 byte // APDU length | 1 byte
// Optional APDU data | arbitrary // Optional APDU data | arbitrary
func (w *ledgerDriver) ledgerExchange(opcode ledgerOpcode, p1 ledgerParam1, p2 ledgerParam2, data []byte) ([]byte, error) { func (w *ledgerDriver) ledgerExchange(opcode ledgerOpcode, p1 ledgerParam1, p2 ledgerParam2, data []byte) ([]byte, error) {
// Construct the message payload, possibly split into multiple chunks // Construct the message payload, possibly split into multiple chunks
apdu := make([]byte, 2, 7+len(data)) apdu := make([]byte, 2, 7+len(data))

View file

@ -84,15 +84,15 @@ func (w *trezorDriver) Status() (string, error) {
// Open implements usbwallet.driver, attempting to initialize the connection to // 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 Trezor hardware wallet. Initializing the Trezor is a two or three phase operation:
// - The first phase is to initialize the connection and read the wallet's // * The first phase is to initialize the connection and read the wallet's
// features. This phase is invoked if the provided passphrase is empty. The // 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 // 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. // error to notify the user that a second open phase is needed.
// - The second phase is to unlock access to the Trezor, which is done by the // * The second phase is to unlock access to the Trezor, which is done by the
// user actually providing a passphrase mapping a keyboard keypad to the pin // user actually providing a passphrase mapping a keyboard keypad to the pin
// number of the user (shuffled according to the pinpad displayed). // number of the user (shuffled according to the pinpad displayed).
// - If needed the device will ask for passphrase which will require calling // * If needed the device will ask for passphrase which will require calling
// open again with the actual passphrase (3rd phase) // open again with the actual passphrase (3rd phase)
func (w *trezorDriver) Open(device io.ReadWriter, passphrase string) error { func (w *trezorDriver) Open(device io.ReadWriter, passphrase string) error {
w.device, w.failure = device, nil w.device, w.failure = device, nil

View file

@ -959,9 +959,9 @@ func doWindowsInstaller(cmdline []string) {
// Render NSIS scripts: Installer NSIS contains two installer sections, // Render NSIS scripts: Installer NSIS contains two installer sections,
// first section contains the worldland binary, second section holds the dev tools. // first section contains the worldland binary, second section holds the dev tools.
templateData := map[string]interface{}{ templateData := map[string]interface{}{
"License": "COPYING", "License": "COPYING",
"Worldland": gethTool, "Worldland": gethTool,
"DevTools": devTools, "DevTools": devTools,
} }
build.Render("build/nsis.worldland.nsi", filepath.Join(*workdir, "worldland.nsi"), 0644, nil) 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) build.Render("build/nsis.install.nsh", filepath.Join(*workdir, "install.nsh"), 0644, templateData)

View file

@ -29,7 +29,7 @@ import (
"github.com/cryptoecc/ETH-ECC/params" "github.com/cryptoecc/ETH-ECC/params"
) )
// var faucetAddr = common.HexToAddress("0x71562b71999873DB5b286dF957af199Ec94617F7") //var faucetAddr = common.HexToAddress("0x71562b71999873DB5b286dF957af199Ec94617F7")
var faucetKey, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291") var faucetKey, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
func (s *Suite) sendSuccessfulTxs(t *utesting.T) error { func (s *Suite) sendSuccessfulTxs(t *utesting.T) error {

View file

@ -21,9 +21,9 @@ import (
"os" "os"
"testing" "testing"
"github.com/cryptoecc/ETH-ECC/internal/cmdtest"
"github.com/docker/docker/pkg/reexec" "github.com/docker/docker/pkg/reexec"
) "github.com/cryptoecc/ETH-ECC/internal/cmdtest"
)
type testEthkey struct { type testEthkey struct {
*cmdtest.TestCmd *cmdtest.TestCmd

View file

@ -28,6 +28,7 @@ import (
"github.com/cryptoecc/ETH-ECC/common/hexutil" "github.com/cryptoecc/ETH-ECC/common/hexutil"
"github.com/cryptoecc/ETH-ECC/common/math" "github.com/cryptoecc/ETH-ECC/common/math"
"github.com/cryptoecc/ETH-ECC/consensus/clique" "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/consensus/ethash"
"github.com/cryptoecc/ETH-ECC/core/types" "github.com/cryptoecc/ETH-ECC/core/types"
"github.com/cryptoecc/ETH-ECC/crypto" "github.com/cryptoecc/ETH-ECC/crypto"

View file

@ -334,9 +334,8 @@ func (t *txWithKey) UnmarshalJSON(input []byte) error {
// signUnsignedTransactions converts the input txs to canonical transactions. // signUnsignedTransactions converts the input txs to canonical transactions.
// //
// The transactions can have two forms, either // The transactions can have two forms, either
// 1. unsigned or // 1. unsigned or
// 2. signed // 2. signed
//
// For (1), r, s, v, need so be zero, and the `secretKey` needs to be set. // 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 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. // If the condition above is not met, then it's considered a signed transaction.

View file

@ -24,10 +24,10 @@ import (
"strings" "strings"
"testing" "testing"
"github.com/docker/docker/pkg/reexec"
"github.com/cryptoecc/ETH-ECC/cmd/evm/internal/t8ntool" "github.com/cryptoecc/ETH-ECC/cmd/evm/internal/t8ntool"
"github.com/cryptoecc/ETH-ECC/internal/cmdtest" "github.com/cryptoecc/ETH-ECC/internal/cmdtest"
"github.com/docker/docker/pkg/reexec" )
)
func TestMain(m *testing.M) { func TestMain(m *testing.M) {
// Run the app if we've been exec'd as "ethkey-test" in runEthkey. // Run the app if we've been exec'd as "ethkey-test" in runEthkey.

View file

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

View file

@ -19,20 +19,21 @@
// Here is an example of creating a 2 node network with the first node // Here is an example of creating a 2 node network with the first node
// connected to the second: // connected to the second:
// //
// $ p2psim node create // $ p2psim node create
// Created node01 // Created node01
// //
// $ p2psim node start node01 // $ p2psim node start node01
// Started node01 // Started node01
// //
// $ p2psim node create // $ p2psim node create
// Created node02 // Created node02
// //
// $ p2psim node start node02 // $ p2psim node start node02
// Started node02 // Started node02
//
// $ p2psim node connect node01 node02
// Connected node01 to node02
// //
// $ p2psim node connect node01 node02
// Connected node01 to node02
package main package main
import ( import (

View file

@ -26,10 +26,9 @@ import (
// LazyQueue is a priority queue data structure where priorities can change over // LazyQueue is a priority queue data structure where priorities can change over
// time and are only evaluated on demand. // time and are only evaluated on demand.
// Two callbacks are required: // Two callbacks are required:
// - priority evaluates the actual priority of an item // - priority evaluates the actual priority of an item
// - maxPriority gives an upper estimate for the priority in any moment between // - maxPriority gives an upper estimate for the priority in any moment between
// now and the given absolute time // now and the given absolute time
//
// If the upper estimate is exceeded then Update should be called for that item. // If the upper estimate is exceeded then Update should be called for that item.
// A global Refresh function should also be called periodically. // A global Refresh function should also be called periodically.
type LazyQueue struct { type LazyQueue struct {

View file

@ -740,6 +740,7 @@ func encodeSigHeader(w io.Writer, header *types.Header) {
header.MixDigest, header.MixDigest,
header.Nonce, header.Nonce,
} }
if header.BaseFee != nil { if header.BaseFee != nil {
enc = append(enc, header.BaseFee) enc = append(enc, header.BaseFee)
} }

View file

@ -34,11 +34,10 @@ type API struct {
// GetWork returns a work package for external miner. // GetWork returns a work package for external miner.
// //
// The work package consists of 3 strings: // The work package consists of 3 strings:
// // result[0] - 32 bytes hex encoded current block header pow-hash
// result[0] - 32 bytes hex encoded current block header pow-hash // result[1] - 32 bytes hex encoded seed hash used for DAG
// result[1] - 32 bytes hex encoded seed hash used for DAG // result[2] - 32 bytes hex encoded boundary condition ("target"), 2^256/difficulty
// result[2] - 32 bytes hex encoded boundary condition ("target"), 2^256/difficulty // result[3] - hex encoded block number
// result[3] - hex encoded block number
func (api *API) GetWork() ([4]string, error) { func (api *API) GetWork() ([4]string, error) {
if api.ethash.remote == nil { if api.ethash.remote == nil {
return [4]string{}, errors.New("not supported") return [4]string{}, errors.New("not supported")

View file

@ -339,11 +339,10 @@ func (s *remoteSealer) loop() {
// makeWork creates a work package for external miner. // makeWork creates a work package for external miner.
// //
// The work package consists of 3 strings: // The work package consists of 3 strings:
// // result[0], 32 bytes hex encoded current block header pow-hash
// result[0], 32 bytes hex encoded current block header pow-hash // result[1], 32 bytes hex encoded seed hash used for DAG
// result[1], 32 bytes hex encoded seed hash used for DAG // result[2], 32 bytes hex encoded boundary condition ("target"), 2^256/difficulty
// result[2], 32 bytes hex encoded boundary condition ("target"), 2^256/difficulty // result[3], hex encoded block number
// result[3], hex encoded block number
func (s *remoteSealer) makeWork(block *types.Block) { func (s *remoteSealer) makeWork(block *types.Block) {
hash := s.ethash.SealHash(block.Header()) hash := s.ethash.SealHash(block.Header())
s.currentWork[0] = hash.Hex() s.currentWork[0] = hash.Hex()

View file

@ -40,11 +40,10 @@ var (
// ensure it conforms to DAO hard-fork rules. // ensure it conforms to DAO hard-fork rules.
// //
// DAO hard-fork extension to the header validity: // 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
// a) if the node is no-fork, do not accept blocks in the [fork, fork+10) range // with the fork specific extra-data set
// with the fork specific extra-data set // b) if the node is pro-fork, require blocks in the specific range to have the
// b) if the node is pro-fork, require blocks in the specific range to have the // unique extra-data set.
// unique extra-data set.
func VerifyDAOHeaderExtraData(config *params.ChainConfig, header *types.Header) error { func VerifyDAOHeaderExtraData(config *params.ChainConfig, header *types.Header) error {
// Short circuit validation if the node doesn't care about the DAO fork // Short circuit validation if the node doesn't care about the DAO fork
if config.DAOForkBlock == nil { if config.DAOForkBlock == nil {

View file

@ -47,7 +47,7 @@ func copyConfig(original *params.ChainConfig) *params.ChainConfig {
TerminalTotalDifficulty: original.TerminalTotalDifficulty, TerminalTotalDifficulty: original.TerminalTotalDifficulty,
Ethash: original.Ethash, Ethash: original.Ethash,
Clique: original.Clique, Clique: original.Clique,
} }
} }
func config() *params.ChainConfig { func config() *params.ChainConfig {

View file

@ -19,9 +19,9 @@ package console
import ( import (
"testing" "testing"
"github.com/cryptoecc/ETH-ECC/internal/jsre"
"github.com/dop251/goja" "github.com/dop251/goja"
) "github.com/cryptoecc/ETH-ECC/internal/jsre"
)
// TestUndefinedAsParam ensures that personal functions can receive // TestUndefinedAsParam ensures that personal functions can receive
// `undefined` as a parameter. // `undefined` as a parameter.

View file

@ -30,6 +30,8 @@ func (e ExecutableDataV1) MarshalJSON() ([]byte, error) {
BaseFeePerGas *hexutil.Big `json:"baseFeePerGas" gencodec:"required"` BaseFeePerGas *hexutil.Big `json:"baseFeePerGas" gencodec:"required"`
BlockHash common.Hash `json:"blockHash" gencodec:"required"` BlockHash common.Hash `json:"blockHash" gencodec:"required"`
Transactions []hexutil.Bytes `json:"transactions" 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 var enc ExecutableDataV1
enc.ParentHash = e.ParentHash enc.ParentHash = e.ParentHash
@ -44,6 +46,8 @@ func (e ExecutableDataV1) MarshalJSON() ([]byte, error) {
enc.Timestamp = hexutil.Uint64(e.Timestamp) enc.Timestamp = hexutil.Uint64(e.Timestamp)
enc.ExtraData = e.ExtraData enc.ExtraData = e.ExtraData
enc.BaseFeePerGas = (*hexutil.Big)(e.BaseFeePerGas) enc.BaseFeePerGas = (*hexutil.Big)(e.BaseFeePerGas)
//enc.Codeword = e.Codeword
//enc.CodeLength = hexutil.Uint64(e.CodeLength)
enc.BlockHash = e.BlockHash enc.BlockHash = e.BlockHash
if e.Transactions != nil { if e.Transactions != nil {
enc.Transactions = make([]hexutil.Bytes, len(e.Transactions)) 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"` BaseFeePerGas *hexutil.Big `json:"baseFeePerGas" gencodec:"required"`
BlockHash *common.Hash `json:"blockHash" gencodec:"required"` BlockHash *common.Hash `json:"blockHash" gencodec:"required"`
Transactions []hexutil.Bytes `json:"transactions" 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 var dec ExecutableDataV1
if err := json.Unmarshal(input, &dec); err != nil { 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") return errors.New("missing required field 'blockHash' for ExecutableDataV1")
} }
e.BlockHash = *dec.BlockHash 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 { if dec.Transactions == nil {
return errors.New("missing required field 'transactions' for ExecutableDataV1") return errors.New("missing required field 'transactions' for ExecutableDataV1")
} }

View file

@ -58,6 +58,9 @@ type ExecutableDataV1 struct {
BaseFeePerGas *big.Int `json:"baseFeePerGas" gencodec:"required"` BaseFeePerGas *big.Int `json:"baseFeePerGas" gencodec:"required"`
BlockHash common.Hash `json:"blockHash" gencodec:"required"` BlockHash common.Hash `json:"blockHash" gencodec:"required"`
Transactions [][]byte `json:"transactions" 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. // JSON type overrides for executableData.
@ -136,11 +139,9 @@ func decodeTransactions(enc [][]byte) ([]*types.Transaction, error) {
// ExecutableDataToBlock constructs a block from executable data. // ExecutableDataToBlock constructs a block from executable data.
// It verifies that the following fields: // It verifies that the following fields:
// // len(extraData) <= 32
// len(extraData) <= 32 // uncleHash = emptyUncleHash
// uncleHash = emptyUncleHash // difficulty = 0
// difficulty = 0
//
// and that the blockhash of the constructed block matches the parameters. // and that the blockhash of the constructed block matches the parameters.
func ExecutableDataToBlock(params ExecutableDataV1) (*types.Block, error) { func ExecutableDataToBlock(params ExecutableDataV1) (*types.Block, error) {
txs, err := decodeTransactions(params.Transactions) txs, err := decodeTransactions(params.Transactions)
@ -150,6 +151,11 @@ func ExecutableDataToBlock(params ExecutableDataV1) (*types.Block, error) {
if len(params.ExtraData) > 32 { if len(params.ExtraData) > 32 {
return nil, fmt.Errorf("invalid extradata length: %v", len(params.ExtraData)) 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 { if len(params.LogsBloom) != 256 {
return nil, fmt.Errorf("invalid logsBloom length: %v", len(params.LogsBloom)) 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, BaseFee: params.BaseFeePerGas,
Extra: params.ExtraData, Extra: params.ExtraData,
MixDigest: params.Random, MixDigest: params.Random,
//Codeword: params.Codeword,
//CodeLength: params.CodeLength,
} }
block := types.NewBlockWithHeader(header).WithBody(txs, nil /* uncles */) block := types.NewBlockWithHeader(header).WithBody(txs, nil /* uncles */)
if block.Hash() != params.BlockHash { if block.Hash() != params.BlockHash {
@ -199,5 +207,7 @@ func BlockToExecutableData(block *types.Block) *ExecutableDataV1 {
Transactions: encodeTransactions(block.Transactions()), Transactions: encodeTransactions(block.Transactions()),
Random: block.MixDigest(), Random: block.MixDigest(),
ExtraData: block.Extra(), ExtraData: block.Extra(),
//Codeword: block.Codeword(),
//CodeLength: block.CodeLength(),
} }
} }

View file

@ -27,7 +27,6 @@ import (
"sync" "sync"
"sync/atomic" "sync/atomic"
"time" "time"
"github.com/cryptoecc/ETH-ECC/common" "github.com/cryptoecc/ETH-ECC/common"
"github.com/cryptoecc/ETH-ECC/common/mclock" "github.com/cryptoecc/ETH-ECC/common/mclock"
"github.com/cryptoecc/ETH-ECC/common/prque" "github.com/cryptoecc/ETH-ECC/common/prque"
@ -926,6 +925,7 @@ func (bc *BlockChain) Stop() {
triedb.SaveCache(bc.cacheConfig.TrieCleanJournal) triedb.SaveCache(bc.cacheConfig.TrieCleanJournal)
} }
log.Info("Blockchain stopped") log.Info("Blockchain stopped")
} }
// StopInsert interrupts all insertion methods, causing them to return // StopInsert interrupts all insertion methods, causing them to return

View file

@ -1882,8 +1882,8 @@ func TestInsertReceiptChainRollback(t *testing.T) {
// overtake the 'canon' chain until after it's passed canon by about 200 blocks. // overtake the 'canon' chain until after it's passed canon by about 200 blocks.
// //
// Details at: // Details at:
// - https://github.com/cryptoecc/ETH-ECC/issues/18977 // - https://github.com/cryptoecc/ETH-ECC/issues/18977
// - https://github.com/cryptoecc/ETH-ECC/pull/18988 // - https://github.com/cryptoecc/ETH-ECC/pull/18988
func TestLowDiffLongChain(t *testing.T) { func TestLowDiffLongChain(t *testing.T) {
// Generate a canonical chain to act as the main dataset // Generate a canonical chain to act as the main dataset
engine := ethash.NewFaker() 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. // That is: the sidechain for import contains some blocks already present in canon chain.
// So the blocks are // So the blocks are
// [ Cn, Cn+1, Cc, Sn+3 ... Sm] // [ Cn, Cn+1, Cc, Sn+3 ... Sm]
// // ^ ^ ^ pruned
// ^ ^ ^ pruned
func TestPrunedImportSide(t *testing.T) { func TestPrunedImportSide(t *testing.T) {
//glogger := log.NewGlogHandler(log.StreamHandler(os.Stdout, log.TerminalFormat(false))) //glogger := log.NewGlogHandler(log.StreamHandler(os.Stdout, log.TerminalFormat(false)))
//glogger.Verbosity(3) //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 // This internally leads to a sidechain import, since the blocks trigger an
// ErrPrunedAncestor error. // ErrPrunedAncestor error.
// This may e.g. happen if // This may e.g. happen if
// 1. Downloader rollbacks a batch of inserted blocks and exits // 1. Downloader rollbacks a batch of inserted blocks and exits
// 2. Downloader starts to sync again // 2. Downloader starts to sync again
// 3. The blocks fetched are all known and canonical blocks // 3. The blocks fetched are all known and canonical blocks
func TestSideImportPrunedBlocks(t *testing.T) { func TestSideImportPrunedBlocks(t *testing.T) {
// Generate a canonical chain to act as the main dataset // Generate a canonical chain to act as the main dataset
engine := ethash.NewFaker() engine := ethash.NewFaker()
@ -3363,19 +3362,20 @@ func TestDeleteRecreateSlotsAcrossManyBlocks(t *testing.T) {
// TestInitThenFailCreateContract tests a pretty notorious case that happened // TestInitThenFailCreateContract tests a pretty notorious case that happened
// on mainnet over blocks 7338108, 7338110 and 7338115. // on mainnet over blocks 7338108, 7338110 and 7338115.
// - Block 7338108: address e771789f5cccac282f23bb7add5690e1f6ca467c is initiated // - Block 7338108: address e771789f5cccac282f23bb7add5690e1f6ca467c is initiated
// with 0.001 ether (thus created but no code) // with 0.001 ether (thus created but no code)
// - Block 7338110: a CREATE2 is attempted. The CREATE2 would deploy code on // - Block 7338110: a CREATE2 is attempted. The CREATE2 would deploy code on
// the same address e771789f5cccac282f23bb7add5690e1f6ca467c. However, the // the same address e771789f5cccac282f23bb7add5690e1f6ca467c. However, the
// deployment fails due to OOG during initcode execution // deployment fails due to OOG during initcode execution
// - Block 7338115: another tx checks the balance of // - Block 7338115: another tx checks the balance of
// e771789f5cccac282f23bb7add5690e1f6ca467c, and the snapshotter returned it as // e771789f5cccac282f23bb7add5690e1f6ca467c, and the snapshotter returned it as
// zero. // zero.
// //
// The problem being that the snapshotter maintains a destructset, and adds items // The problem being that the snapshotter maintains a destructset, and adds items
// to the destructset in case something is created "onto" an existing item. // 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 // We need to either roll back the snapDestructs, or not place it into snapDestructs
// in the first place. // in the first place.
//
func TestInitThenFailCreateContract(t *testing.T) { func TestInitThenFailCreateContract(t *testing.T) {
var ( var (
// Generate a canonical chain to act as the main dataset // Generate a canonical chain to act as the main dataset
@ -3563,13 +3563,13 @@ func TestEIP2718Transition(t *testing.T) {
// TestEIP1559Transition tests the following: // TestEIP1559Transition tests the following:
// //
// 1. A transaction whose gasFeeCap is greater than the baseFee is valid. // 1. A transaction whose gasFeeCap is greater than the baseFee is valid.
// 2. Gas accounting for access lists on EIP-1559 transactions is correct. // 2. Gas accounting for access lists on EIP-1559 transactions is correct.
// 3. Only the transaction's tip will be received by the coinbase. // 3. Only the transaction's tip will be received by the coinbase.
// 4. The transaction sender pays for both the tip and baseFee. // 4. The transaction sender pays for both the tip and baseFee.
// 5. The coinbase receives only the partially realized tip when // 5. The coinbase receives only the partially realized tip when
// gasFeeCap - gasTipCap < baseFee. // gasFeeCap - gasTipCap < baseFee.
// 6. Legacy transaction behave as expected (e.g. gasPrice = gasFeeCap = gasTipCap). // 6. Legacy transaction behave as expected (e.g. gasPrice = gasFeeCap = gasTipCap).
func TestEIP1559Transition(t *testing.T) { func TestEIP1559Transition(t *testing.T) {
var ( var (
aa = common.HexToAddress("0x000000000000000000000000000000000000aaaa") aa = common.HexToAddress("0x000000000000000000000000000000000000aaaa")

View file

@ -21,14 +21,14 @@ import (
"reflect" "reflect"
"testing" "testing"
"github.com/davecgh/go-spew/spew"
"github.com/cryptoecc/ETH-ECC/common" "github.com/cryptoecc/ETH-ECC/common"
"github.com/cryptoecc/ETH-ECC/consensus/ethash" "github.com/cryptoecc/ETH-ECC/consensus/ethash"
"github.com/cryptoecc/ETH-ECC/core/rawdb" "github.com/cryptoecc/ETH-ECC/core/rawdb"
"github.com/cryptoecc/ETH-ECC/core/vm" "github.com/cryptoecc/ETH-ECC/core/vm"
"github.com/cryptoecc/ETH-ECC/ethdb" "github.com/cryptoecc/ETH-ECC/ethdb"
"github.com/cryptoecc/ETH-ECC/params" "github.com/cryptoecc/ETH-ECC/params"
"github.com/davecgh/go-spew/spew" )
)
func TestInvalidCliqueConfig(t *testing.T) { func TestInvalidCliqueConfig(t *testing.T) {
block := DefaultGoerliGenesisBlock() block := DefaultGoerliGenesisBlock()

View file

@ -18,10 +18,12 @@
// +build none // +build none
/* /*
The mkalloc tool creates the genesis allocation constants in genesis_alloc.go 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. It outputs a const declaration that contains an RLP-encoded list of (address, balance) tuples.
go run mkalloc.go genesis.json go run mkalloc.go genesis.json
*/ */
package main package main

View file

@ -57,10 +57,10 @@ const freezerTableSize = 2 * 1000 * 1000 * 1000
// Freezer is a memory mapped append-only database to store immutable ordered // Freezer is a memory mapped append-only database to store immutable ordered
// data into flat files: // data into flat files:
// //
// - The append-only nature ensures that disk writes are minimized. // - The append-only nature ensures that disk writes are minimized.
// - The memory mapping ensures we can max out system memory for caching without // - 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 // reserving it for go-ethereum. This would also reduce the memory requirements
// of Geth, and thus also GC overhead. // of Geth, and thus also GC overhead.
type Freezer struct { type Freezer struct {
// WARNING: The `frozen` and `tail` fields are accessed atomically. On 32 bit platforms, only // 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, // 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'. // AncientRange retrieves multiple items in sequence, starting from the index 'start'.
// It will return // It will return
// - at most 'max' items, // - at most 'max' items,
// - at least 1 item (even if exceeding the maxByteSize), but will otherwise // - at least 1 item (even if exceeding the maxByteSize), but will otherwise
// return as many items as fit into maxByteSize. // return as many items as fit into maxByteSize.
func (f *Freezer) AncientRange(kind string, start, count, maxBytes uint64) ([][]byte, error) { func (f *Freezer) AncientRange(kind string, start, count, maxBytes uint64) ([][]byte, error) {
if table := f.tables[kind]; table != nil { if table := f.tables[kind]; table != nil {
return table.RetrieveItems(start, count, maxBytes) return table.RetrieveItems(start, count, maxBytes)

View file

@ -29,8 +29,8 @@ import (
"testing/quick" "testing/quick"
"time" "time"
"github.com/cryptoecc/ETH-ECC/metrics"
"github.com/davecgh/go-spew/spew" "github.com/davecgh/go-spew/spew"
"github.com/cryptoecc/ETH-ECC/metrics"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
) )

View file

@ -66,9 +66,9 @@ var (
// Pruner is an offline tool to prune the stale state with the // Pruner is an offline tool to prune the stale state with the
// help of the snapshot. The workflow of pruner is very simple: // help of the snapshot. The workflow of pruner is very simple:
// //
// - iterate the snapshot, reconstruct the relevant state // - iterate the snapshot, reconstruct the relevant state
// - iterate the database, delete all other state entries which // - iterate the database, delete all other state entries which
// don't belong to the target state and the genesis state // don't belong to the target state and the genesis state
// //
// It can take several hours(around 2 hours for mainnet) to finish // It can take several hours(around 2 hours for mainnet) to finish
// the whole pruning work. It's recommended to run this offline tool // the whole pruning work. It's recommended to run this offline tool

View file

@ -220,12 +220,10 @@ func (t *testHelper) CommitAndGenerate() (common.Hash, *diskLayer) {
// - miss in the beginning // - miss in the beginning
// - miss in the middle // - miss in the middle
// - miss in the end // - miss in the end
//
// - the contract(non-empty storage) has wrong storage slots // - the contract(non-empty storage) has wrong storage slots
// - wrong slots in the beginning // - wrong slots in the beginning
// - wrong slots in the middle // - wrong slots in the middle
// - wrong slots in the end // - wrong slots in the end
//
// - the contract(non-empty storage) has extra storage slots // - the contract(non-empty storage) has extra storage slots
// - extra slots in the beginning // - extra slots in the beginning
// - extra slots in the middle // - extra slots in the middle

View file

@ -179,10 +179,10 @@ type Tree struct {
// If the memory layers in the journal do not match the disk layer (e.g. there is // 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: // 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. // - 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. // This case happens when the snapshot is 'ahead' of the state trie.
// - otherwise, the entire snapshot is considered invalid and will be recreated on // - otherwise, the entire snapshot is considered invalid and will be recreated on
// a background thread. // a background thread.
func New(diskdb ethdb.KeyValueStore, triedb *trie.Database, cache int, root common.Hash, async bool, rebuild bool, recovery bool) (*Tree, error) { 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 // Create a new, empty snapshot tree
snap := &Tree{ snap := &Tree{

View file

@ -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 // CreateAccount is called during the EVM CREATE operation. The situation might arise that
// a contract does the following: // a contract does the following:
// //
// 1. sends funds to sha(account ++ (nonce + 1)) // 1. sends funds to sha(account ++ (nonce + 1))
// 2. tx_create(sha(account ++ nonce)) (note that this gets the address of 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. // Carrying over the balance ensures that Ether doesn't disappear.
func (s *StateDB) CreateAccount(addr common.Address) { func (s *StateDB) CreateAccount(addr common.Address) {

View file

@ -42,10 +42,8 @@ The state transitioning model does all the necessary work to work out a valid ne
3) Create a new state object if the recipient is \0*32 3) Create a new state object if the recipient is \0*32
4) Value transfer 4) Value transfer
== If contract creation == == If contract creation ==
4a) Attempt to run transaction data 4a) Attempt to run transaction data
4b) If valid, use result as code for the new state object 4b) If valid, use result as code for the new state object
== end == == end ==
5) Run Script section 5) Run Script section
6) Derive new state root 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 // TransitionDb will transition the state by applying the current message and
// returning the evm execution result with following fields. // returning the evm execution result with following fields.
// //
// - used gas: // - used gas:
// total gas used (including gas being refunded) // total gas used (including gas being refunded)
// - returndata: // - returndata:
// the returned data from evm // the returned data from evm
// - concrete execution error: // - concrete execution error:
// various **EVM** error which aborts the execution, // various **EVM** error which aborts the execution,
// e.g. ErrOutOfGas, ErrExecutionReverted // e.g. ErrOutOfGas, ErrExecutionReverted
// //
// However if any consensus issue encountered, return the error directly with // However if any consensus issue encountered, return the error directly with
// nil evm execution result. // nil evm execution result.

View file

@ -85,7 +85,7 @@ type Header struct {
Nonce BlockNonce `json:"nonce"` Nonce BlockNonce `json:"nonce"`
// BaseFee was added by EIP-1559 and is ignored in legacy headers. // 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 TODO (MariusVanDerWijden) Add this field once needed

View file

@ -22,10 +22,10 @@ import (
"reflect" "reflect"
"testing" "testing"
"github.com/davecgh/go-spew/spew"
"github.com/cryptoecc/ETH-ECC/common" "github.com/cryptoecc/ETH-ECC/common"
"github.com/cryptoecc/ETH-ECC/common/hexutil" "github.com/cryptoecc/ETH-ECC/common/hexutil"
"github.com/davecgh/go-spew/spew" )
)
var unmarshalLogTests = map[string]struct { var unmarshalLogTests = map[string]struct {
input string input string

View file

@ -264,10 +264,9 @@ var (
// modexpMultComplexity implements bigModexp multComplexity formula, as defined in EIP-198 // modexpMultComplexity implements bigModexp multComplexity formula, as defined in EIP-198
// //
// def mult_complexity(x): // def mult_complexity(x):
// // if x <= 64: return x ** 2
// if x <= 64: return x ** 2 // elif x <= 1024: return x ** 2 // 4 + 96 * x - 3072
// elif x <= 1024: return x ** 2 // 4 + 96 * x - 3072 // else: return x ** 2 // 16 + 480 * x - 199680
// else: return x ** 2 // 16 + 480 * x - 199680
// //
// where is x is max(length_of_MODULUS, length_of_BASE) // where is x is max(length_of_MODULUS, length_of_BASE)
func modexpMultComplexity(x *big.Int) *big.Int { func modexpMultComplexity(x *big.Int) *big.Int {

View file

@ -162,19 +162,19 @@ func gasSStore(evm *EVM, contract *Contract, stack *Stack, mem *Memory, memorySi
return params.NetSstoreDirtyGas, nil return params.NetSstoreDirtyGas, nil
} }
// 0. If *gasleft* is less than or equal to 2300, fail the current call. // 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. // 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. 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. 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.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.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. 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.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.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. 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.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.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) { 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 we fail the minimum gas availability invariant, fail (0)
if contract.Gas <= params.SstoreSentryGasEIP2200 { if contract.Gas <= params.SstoreSentryGasEIP2200 {

View file

@ -392,21 +392,16 @@ func opExtCodeCopy(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext)
// opExtCodeHash returns the code hash of a specified account. // opExtCodeHash returns the code hash of a specified account.
// There are several cases when the function is called, while we can relay everything // There are several cases when the function is called, while we can relay everything
// to `state.GetCodeHash` function to ensure the correctness. // 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. // 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. // 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. // 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. // should be zero or emptyCodeHash.
// //
// It is worth noting that in order to avoid unnecessary create and clean, // 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 // If the precompile account is not transferred any amount on a private or
// customized chain, the return value will be zero. // 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. // 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. // 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) { func opExtCodeHash(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
slot := scope.Stack.peek() slot := scope.Stack.peek()

View file

@ -35,7 +35,7 @@ import (
"golang.org/x/crypto/sha3" "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 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. // RecoveryIDOffset points to the byte offset within the signature that contains the recovery id.

View file

@ -22,7 +22,7 @@ import (
"math/big" "math/big"
"time" "time"
ethereum "github.com/cryptoecc/ETH-ECC" "github.com/cryptoecc/ETH-ECC"
"github.com/cryptoecc/ETH-ECC/accounts" "github.com/cryptoecc/ETH-ECC/accounts"
"github.com/cryptoecc/ETH-ECC/common" "github.com/cryptoecc/ETH-ECC/common"
"github.com/cryptoecc/ETH-ECC/consensus" "github.com/cryptoecc/ETH-ECC/consensus"

View file

@ -24,13 +24,13 @@ import (
"sort" "sort"
"testing" "testing"
"github.com/davecgh/go-spew/spew"
"github.com/cryptoecc/ETH-ECC/common" "github.com/cryptoecc/ETH-ECC/common"
"github.com/cryptoecc/ETH-ECC/core/rawdb" "github.com/cryptoecc/ETH-ECC/core/rawdb"
"github.com/cryptoecc/ETH-ECC/core/state" "github.com/cryptoecc/ETH-ECC/core/state"
"github.com/cryptoecc/ETH-ECC/crypto" "github.com/cryptoecc/ETH-ECC/crypto"
"github.com/cryptoecc/ETH-ECC/trie" "github.com/cryptoecc/ETH-ECC/trie"
"github.com/davecgh/go-spew/spew" )
)
var dumper = spew.ConfigState{Indent: " "} var dumper = spew.ConfigState{Indent: " "}

View file

@ -523,7 +523,7 @@ func TestExchangeTransitionConfig(t *testing.T) {
TestNewPayloadOnInvalidChain sets up a valid chain and tries to feed blocks TestNewPayloadOnInvalidChain sets up a valid chain and tries to feed blocks
from an invalid chain to test if latestValidHash (LVH) works correctly. 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. P1' is invalid.
We expect We expect
(1) The LVH to point to the current inserted payload if it was valid. (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. (3) If the parent is unavailable, the LVH should not be set.
CommonAncestor P1 P2 P3 ... Pn CommonAncestor P1 P2 P3 ... Pn
P1' P2' P3' ... Pn' P1' P2' P3' ... Pn'
@ -707,6 +706,8 @@ func setBlockhash(data *beacon.ExecutableDataV1) *beacon.ExecutableDataV1 {
BaseFee: data.BaseFeePerGas, BaseFee: data.BaseFeePerGas,
Extra: data.ExtraData, Extra: data.ExtraData,
MixDigest: data.Random, MixDigest: data.Random,
//Codeword: data.Codeword,
//CodeLength: data.CodeLength,
} }
block := types.NewBlockWithHeader(header).WithBody(txs, nil /* uncles */) block := types.NewBlockWithHeader(header).WithBody(txs, nil /* uncles */)
data.BlockHash = block.Hash() data.BlockHash = block.Hash()

View file

@ -20,10 +20,10 @@ import (
"context" "context"
"sync" "sync"
"github.com/cryptoecc/ETH-ECC"
"github.com/cryptoecc/ETH-ECC/event" "github.com/cryptoecc/ETH-ECC/event"
"github.com/cryptoecc/ETH-ECC/rpc" "github.com/cryptoecc/ETH-ECC/rpc"
"github.com/ethereum/go-ethereum" )
)
// DownloaderAPI provides an API which gives information about the current synchronisation status. // 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. // It offers only methods that operates on data that can be available to anyone without security risks.

View file

@ -25,6 +25,7 @@ import (
"sync/atomic" "sync/atomic"
"time" "time"
"github.com/cryptoecc/ETH-ECC"
"github.com/cryptoecc/ETH-ECC/common" "github.com/cryptoecc/ETH-ECC/common"
"github.com/cryptoecc/ETH-ECC/core/rawdb" "github.com/cryptoecc/ETH-ECC/core/rawdb"
"github.com/cryptoecc/ETH-ECC/core/state/snapshot" "github.com/cryptoecc/ETH-ECC/core/state/snapshot"
@ -34,8 +35,7 @@ import (
"github.com/cryptoecc/ETH-ECC/event" "github.com/cryptoecc/ETH-ECC/event"
"github.com/cryptoecc/ETH-ECC/log" "github.com/cryptoecc/ETH-ECC/log"
"github.com/cryptoecc/ETH-ECC/params" "github.com/cryptoecc/ETH-ECC/params"
"github.com/ethereum/go-ethereum" )
)
var ( var (
MaxBlockFetch = 128 // Amount of blocks to be fetched per retrieval request 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 // calculateRequestSpan calculates what headers to request from a peer when trying to determine the
// common ancestor. // common ancestor.
// It returns parameters to be used for peer.RequestHeadersByNumber: // It returns parameters to be used for peer.RequestHeadersByNumber:
// // from - starting block number
// from - starting block number // count - number of headers to request
// count - number of headers to request // skip - number of headers to skip
// skip - number of headers to skip
//
// and also returns 'max', the last block which is expected to be returned by the remote peers, // and also returns 'max', the last block which is expected to be returned by the remote peers,
// given the (from,count,skip) // given the (from,count,skip)
func calculateRequestSpan(remoteHeight, localHeight uint64) (int64, int, int, uint64) { func calculateRequestSpan(remoteHeight, localHeight uint64) (int64, int, int, uint64) {

View file

@ -27,6 +27,7 @@ import (
"testing" "testing"
"time" "time"
"github.com/cryptoecc/ETH-ECC"
"github.com/cryptoecc/ETH-ECC/common" "github.com/cryptoecc/ETH-ECC/common"
"github.com/cryptoecc/ETH-ECC/consensus/ethash" "github.com/cryptoecc/ETH-ECC/consensus/ethash"
"github.com/cryptoecc/ETH-ECC/core" "github.com/cryptoecc/ETH-ECC/core"
@ -40,8 +41,7 @@ import (
"github.com/cryptoecc/ETH-ECC/params" "github.com/cryptoecc/ETH-ECC/params"
"github.com/cryptoecc/ETH-ECC/rlp" "github.com/cryptoecc/ETH-ECC/rlp"
"github.com/cryptoecc/ETH-ECC/trie" "github.com/cryptoecc/ETH-ECC/trie"
"github.com/ethereum/go-ethereum" )
)
// downloadTester is a test simulator for mocking out local block chain. // downloadTester is a test simulator for mocking out local block chain.
type downloadTester struct { type downloadTester struct {

View file

@ -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. // to access the queue, so they already need a lock anyway.
// //
// Returns: // Returns:
// // item - the fetchRequest
// item - the fetchRequest // progress - whether any progress was made
// progress - whether any progress was made // throttle - if the caller should throttle for a while
// 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, 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) { pendPool map[string]*fetchRequest, kind uint) (*fetchRequest, bool, bool) {
// Short circuit if the pool has been depleted, or if the peer's already // Short circuit if the pool has been depleted, or if the peer's already

View file

@ -71,11 +71,10 @@ func (r *resultStore) SetThrottleThreshold(threshold uint64) uint64 {
// wants to reserve headers for fetching. // wants to reserve headers for fetching.
// //
// It returns the following: // It returns the following:
// // stale - if true, this item is already passed, and should not be requested again
// 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
// throttled - if true, the store is at capacity, this particular header is not prio now // item - the result to store data into
// item - the result to store data into // err - any error that occurred
// err - any error that occurred
func (r *resultStore) AddFetch(header *types.Header, fastSync bool) (stale, throttled bool, item *fetchResult, err error) { func (r *resultStore) AddFetch(header *types.Header, fastSync bool) (stale, throttled bool, item *fetchResult, err error) {
r.lock.Lock() r.lock.Lock()
defer r.lock.Unlock() defer r.lock.Unlock()

View file

@ -29,6 +29,7 @@ import (
"github.com/cryptoecc/ETH-ECC/consensus" "github.com/cryptoecc/ETH-ECC/consensus"
"github.com/cryptoecc/ETH-ECC/consensus/beacon" "github.com/cryptoecc/ETH-ECC/consensus/beacon"
"github.com/cryptoecc/ETH-ECC/consensus/clique" "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/consensus/ethash"
"github.com/cryptoecc/ETH-ECC/core" "github.com/cryptoecc/ETH-ECC/core"
"github.com/cryptoecc/ETH-ECC/eth/downloader" "github.com/cryptoecc/ETH-ECC/eth/downloader"

View file

@ -24,14 +24,14 @@ import (
"sort" "sort"
"time" "time"
mapset "github.com/deckarep/golang-set"
"github.com/cryptoecc/ETH-ECC/common" "github.com/cryptoecc/ETH-ECC/common"
"github.com/cryptoecc/ETH-ECC/common/mclock" "github.com/cryptoecc/ETH-ECC/common/mclock"
"github.com/cryptoecc/ETH-ECC/core" "github.com/cryptoecc/ETH-ECC/core"
"github.com/cryptoecc/ETH-ECC/core/types" "github.com/cryptoecc/ETH-ECC/core/types"
"github.com/cryptoecc/ETH-ECC/log" "github.com/cryptoecc/ETH-ECC/log"
"github.com/cryptoecc/ETH-ECC/metrics" "github.com/cryptoecc/ETH-ECC/metrics"
mapset "github.com/deckarep/golang-set" )
)
const ( const (
// maxTxAnnounces is the maximum number of unique transaction a peer // maxTxAnnounces is the maximum number of unique transaction a peer

View file

@ -25,12 +25,12 @@ import (
"sync" "sync"
"time" "time"
"github.com/cryptoecc/ETH-ECC"
"github.com/cryptoecc/ETH-ECC/common" "github.com/cryptoecc/ETH-ECC/common"
"github.com/cryptoecc/ETH-ECC/common/hexutil" "github.com/cryptoecc/ETH-ECC/common/hexutil"
"github.com/cryptoecc/ETH-ECC/core/types" "github.com/cryptoecc/ETH-ECC/core/types"
"github.com/cryptoecc/ETH-ECC/rpc" "github.com/cryptoecc/ETH-ECC/rpc"
"github.com/ethereum/go-ethereum" )
)
// filter is a helper struct that holds meta information over the filter type // filter is a helper struct that holds meta information over the filter type
// and associated subscription in the event system. // and associated subscription in the event system.

View file

@ -24,6 +24,7 @@ import (
"sync" "sync"
"time" "time"
"github.com/cryptoecc/ETH-ECC"
"github.com/cryptoecc/ETH-ECC/common" "github.com/cryptoecc/ETH-ECC/common"
"github.com/cryptoecc/ETH-ECC/core" "github.com/cryptoecc/ETH-ECC/core"
"github.com/cryptoecc/ETH-ECC/core/bloombits" "github.com/cryptoecc/ETH-ECC/core/bloombits"
@ -33,7 +34,6 @@ import (
"github.com/cryptoecc/ETH-ECC/event" "github.com/cryptoecc/ETH-ECC/event"
"github.com/cryptoecc/ETH-ECC/log" "github.com/cryptoecc/ETH-ECC/log"
"github.com/cryptoecc/ETH-ECC/rpc" "github.com/cryptoecc/ETH-ECC/rpc"
"github.com/ethereum/go-ethereum"
lru "github.com/hashicorp/golang-lru" lru "github.com/hashicorp/golang-lru"
) )

View file

@ -26,6 +26,7 @@ import (
"testing" "testing"
"time" "time"
"github.com/cryptoecc/ETH-ECC"
"github.com/cryptoecc/ETH-ECC/common" "github.com/cryptoecc/ETH-ECC/common"
"github.com/cryptoecc/ETH-ECC/consensus/ethash" "github.com/cryptoecc/ETH-ECC/consensus/ethash"
"github.com/cryptoecc/ETH-ECC/core" "github.com/cryptoecc/ETH-ECC/core"
@ -36,8 +37,7 @@ import (
"github.com/cryptoecc/ETH-ECC/event" "github.com/cryptoecc/ETH-ECC/event"
"github.com/cryptoecc/ETH-ECC/params" "github.com/cryptoecc/ETH-ECC/params"
"github.com/cryptoecc/ETH-ECC/rpc" "github.com/cryptoecc/ETH-ECC/rpc"
"github.com/ethereum/go-ethereum" )
)
type testBackend struct { type testBackend struct {
db ethdb.Database db ethdb.Database

View file

@ -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 // 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. // are not available or when the head has changed during processing this request.
// Three arrays are returned based on the processed blocks: // Three arrays are returned based on the processed blocks:
// - reward: the requested percentiles of effective priority fees per gas of transactions in each // - reward: the requested percentiles of effective priority fees per gas of transactions in each
// block, sorted in ascending order and weighted by gas used. // block, sorted in ascending order and weighted by gas used.
// - baseFee: base fee per gas in the given block // - baseFee: base fee per gas in the given block
// - gasUsedRatio: gasUsed/gasLimit 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 // Note: baseFee includes the next block after the newest of the returned range, because this
// value can be derived from the newest block. // 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) { func (oracle *Oracle) FeeHistory(ctx context.Context, blocks int, unresolvedLastBlock rpc.BlockNumber, rewardPercentiles []float64) (*big.Int, [][]*big.Int, []*big.Int, []float64, error) {

View file

@ -411,6 +411,7 @@ func (h *handler) runEthPeer(peer *eth.Peer, handler eth.Handler) error {
res.Done <- errors.New("unsynced node cannot serve sync") res.Done <- errors.New("unsynced node cannot serve sync")
return return
} }
res.Done <- nil res.Done <- nil
return return
} }

View file

@ -21,12 +21,12 @@ import (
"math/rand" "math/rand"
"sync" "sync"
mapset "github.com/deckarep/golang-set"
"github.com/cryptoecc/ETH-ECC/common" "github.com/cryptoecc/ETH-ECC/common"
"github.com/cryptoecc/ETH-ECC/core/types" "github.com/cryptoecc/ETH-ECC/core/types"
"github.com/cryptoecc/ETH-ECC/p2p" "github.com/cryptoecc/ETH-ECC/p2p"
"github.com/cryptoecc/ETH-ECC/rlp" "github.com/cryptoecc/ETH-ECC/rlp"
mapset "github.com/deckarep/golang-set" )
)
const ( const (
// maxKnownTxs is the maximum transactions hashes to keep in the known list // maxKnownTxs is the maximum transactions hashes to keep in the known list

View file

@ -368,8 +368,7 @@ func createStorageRequestResponse(t *testPeer, root common.Hash, accounts []comm
return hashes, slots, proofs 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 // 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) { 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 var size uint64

View file

@ -23,7 +23,7 @@ import (
"runtime" "runtime"
"runtime/debug" "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"
"github.com/cryptoecc/ETH-ECC/common/hexutil" "github.com/cryptoecc/ETH-ECC/common/hexutil"
"github.com/cryptoecc/ETH-ECC/core/types" "github.com/cryptoecc/ETH-ECC/core/types"

View file

@ -22,6 +22,7 @@ import (
"math/big" "math/big"
"testing" "testing"
"github.com/cryptoecc/ETH-ECC"
"github.com/cryptoecc/ETH-ECC/common" "github.com/cryptoecc/ETH-ECC/common"
"github.com/cryptoecc/ETH-ECC/consensus/ethash" "github.com/cryptoecc/ETH-ECC/consensus/ethash"
"github.com/cryptoecc/ETH-ECC/core" "github.com/cryptoecc/ETH-ECC/core"
@ -35,8 +36,7 @@ import (
"github.com/cryptoecc/ETH-ECC/node" "github.com/cryptoecc/ETH-ECC/node"
"github.com/cryptoecc/ETH-ECC/params" "github.com/cryptoecc/ETH-ECC/params"
"github.com/cryptoecc/ETH-ECC/rpc" "github.com/cryptoecc/ETH-ECC/rpc"
"github.com/ethereum/go-ethereum" )
)
var ( var (
testKey, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291") testKey, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")

View file

@ -266,14 +266,13 @@ func (db *Database) Path() string {
// the metrics subsystem. // the metrics subsystem.
// //
// This is how a LevelDB stats table looks like (currently): // This is how a LevelDB stats table looks like (currently):
// // Compactions
// Compactions // Level | Tables | Size(MB) | Time(sec) | Read(MB) | Write(MB)
// Level | Tables | Size(MB) | Time(sec) | Read(MB) | Write(MB) // -------+------------+---------------+---------------+---------------+---------------
// -------+------------+---------------+---------------+---------------+--------------- // 0 | 0 | 0.00000 | 1.27969 | 0.00000 | 12.31098
// 0 | 0 | 0.00000 | 1.27969 | 0.00000 | 12.31098 // 1 | 85 | 109.27913 | 28.09293 | 213.92493 | 214.26294
// 1 | 85 | 109.27913 | 28.09293 | 213.92493 | 214.26294 // 2 | 523 | 1000.37159 | 7.26059 | 66.86342 | 66.77884
// 2 | 523 | 1000.37159 | 7.26059 | 66.86342 | 66.77884 // 3 | 570 | 1113.18458 | 0.00000 | 0.00000 | 0.00000
// 3 | 570 | 1113.18458 | 0.00000 | 0.00000 | 0.00000
// //
// This is how the write delay look like (currently): // This is how the write delay look like (currently):
// DelayN:5 Delay:406.604657ms Paused: false // DelayN:5 Delay:406.604657ms Paused: false

View file

@ -102,14 +102,13 @@ type Service struct {
// websocket. // websocket.
// //
// From Gorilla websocket docs: // From Gorilla websocket docs:
// // Connections support one concurrent reader and one concurrent writer.
// Connections support one concurrent reader and one concurrent writer. // Applications are responsible for ensuring that no more than one goroutine calls the write methods
// Applications are responsible for ensuring that no more than one goroutine calls the write methods // - NextWriter, SetWriteDeadline, WriteMessage, WriteJSON, EnableWriteCompression, SetCompressionLevel
// - NextWriter, SetWriteDeadline, WriteMessage, WriteJSON, EnableWriteCompression, SetCompressionLevel // concurrently and that no more than one goroutine calls the read methods
// concurrently and that no more than one goroutine calls the read methods // - NextReader, SetReadDeadline, ReadMessage, ReadJSON, SetPongHandler, SetPingHandler
// - NextReader, SetReadDeadline, ReadMessage, ReadJSON, SetPongHandler, SetPingHandler // concurrently.
// concurrently. // The Close and WriteControl methods can be called concurrently with all other methods.
// The Close and WriteControl methods can be called concurrently with all other methods.
type connWrapper struct { type connWrapper struct {
conn *websocket.Conn conn *websocket.Conn

View file

@ -25,7 +25,7 @@ import (
"sort" "sort"
"strconv" "strconv"
ethereum "github.com/cryptoecc/ETH-ECC" "github.com/cryptoecc/ETH-ECC"
"github.com/cryptoecc/ETH-ECC/common" "github.com/cryptoecc/ETH-ECC/common"
"github.com/cryptoecc/ETH-ECC/common/hexutil" "github.com/cryptoecc/ETH-ECC/common/hexutil"
"github.com/cryptoecc/ETH-ECC/common/math" "github.com/cryptoecc/ETH-ECC/common/math"

View file

@ -731,10 +731,10 @@ func (s *BlockChainAPI) GetHeaderByHash(ctx context.Context, hash common.Hash) m
} }
// GetBlockByNumber returns the requested canonical block. // GetBlockByNumber returns the requested canonical block.
// - When blockNr is -1 the chain head is returned. // * When blockNr is -1 the chain head is returned.
// - When blockNr is -2 the pending chain head is returned. // * When blockNr is -2 the pending chain head is returned.
// - When fullTx is true all transactions in the block are returned, otherwise // * When fullTx is true all transactions in the block are returned, otherwise
// only the transaction hash is returned. // only the transaction hash is returned.
func (s *BlockChainAPI) GetBlockByNumber(ctx context.Context, number rpc.BlockNumber, fullTx bool) (map[string]interface{}, error) { func (s *BlockChainAPI) GetBlockByNumber(ctx context.Context, number rpc.BlockNumber, fullTx bool) (map[string]interface{}, error) {
block, err := s.b.BlockByNumber(ctx, number) block, err := s.b.BlockByNumber(ctx, number)
if block != nil && err == nil { if block != nil && err == nil {

View file

@ -24,6 +24,7 @@ import (
"testing" "testing"
"time" "time"
"github.com/cryptoecc/ETH-ECC"
"github.com/cryptoecc/ETH-ECC/accounts" "github.com/cryptoecc/ETH-ECC/accounts"
"github.com/cryptoecc/ETH-ECC/common" "github.com/cryptoecc/ETH-ECC/common"
"github.com/cryptoecc/ETH-ECC/common/hexutil" "github.com/cryptoecc/ETH-ECC/common/hexutil"
@ -37,8 +38,7 @@ import (
"github.com/cryptoecc/ETH-ECC/event" "github.com/cryptoecc/ETH-ECC/event"
"github.com/cryptoecc/ETH-ECC/params" "github.com/cryptoecc/ETH-ECC/params"
"github.com/cryptoecc/ETH-ECC/rpc" "github.com/cryptoecc/ETH-ECC/rpc"
"github.com/ethereum/go-ethereum" )
)
// TestSetFeeDefaults tests the logic for filling in default fee values works as expected. // TestSetFeeDefaults tests the logic for filling in default fee values works as expected.
func TestSetFeeDefaults(t *testing.T) { func TestSetFeeDefaults(t *testing.T) {

View file

@ -54,11 +54,11 @@ var migrationApplied = map[*cli.Command]struct{}{}
// //
// Example: // Example:
// //
// geth account new --keystore /tmp/mykeystore --lightkdf // geth account new --keystore /tmp/mykeystore --lightkdf
// //
// is equivalent after calling this method with: // 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) // 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. // will return true even if --lightkdf is set as a global option.

View file

@ -366,11 +366,10 @@ func NewLightAPI(backend *lesCommons) *LightAPI {
// LatestCheckpoint returns the latest local checkpoint package. // LatestCheckpoint returns the latest local checkpoint package.
// //
// The checkpoint package consists of 4 strings: // The checkpoint package consists of 4 strings:
// // result[0], hex encoded latest section index
// result[0], hex encoded latest section index // result[1], 32 bytes hex encoded latest section head hash
// result[1], 32 bytes hex encoded latest section head hash // result[2], 32 bytes hex encoded latest section canonical hash trie root 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[3], 32 bytes hex encoded latest section bloom trie root hash
func (api *LightAPI) LatestCheckpoint() ([4]string, error) { func (api *LightAPI) LatestCheckpoint() ([4]string, error) {
var res [4]string var res [4]string
cp := api.backend.latestLocalCheckpoint() cp := api.backend.latestLocalCheckpoint()
@ -385,10 +384,9 @@ func (api *LightAPI) LatestCheckpoint() ([4]string, error) {
// GetLocalCheckpoint returns the specific local checkpoint package. // GetLocalCheckpoint returns the specific local checkpoint package.
// //
// The checkpoint package consists of 3 strings: // The checkpoint package consists of 3 strings:
// // result[0], 32 bytes hex encoded latest section head 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[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[2], 32 bytes hex encoded latest section bloom trie root hash
func (api *LightAPI) GetCheckpoint(index uint64) ([3]string, error) { func (api *LightAPI) GetCheckpoint(index uint64) ([3]string, error) {
var res [3]string var res [3]string
cp := api.backend.localCheckpoint(index) cp := api.backend.localCheckpoint(index)

View file

@ -22,7 +22,7 @@ import (
"math/big" "math/big"
"time" "time"
ethereum "github.com/cryptoecc/ETH-ECC" "github.com/cryptoecc/ETH-ECC"
"github.com/cryptoecc/ETH-ECC/accounts" "github.com/cryptoecc/ETH-ECC/accounts"
"github.com/cryptoecc/ETH-ECC/common" "github.com/cryptoecc/ETH-ECC/common"
"github.com/cryptoecc/ETH-ECC/consensus" "github.com/cryptoecc/ETH-ECC/consensus"

View file

@ -57,21 +57,14 @@ func NewConsensusAPI(les *les.LightEthereum) *ConsensusAPI {
// ForkchoiceUpdatedV1 has several responsibilities: // ForkchoiceUpdatedV1 has several responsibilities:
// If the method is called with an empty head block: // 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: // If the total difficulty was not reached:
// // we return INVALID
// we return INVALID
//
// If the finalizedBlockHash is set: // 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 // We try to set our blockchain to the headBlock
// If there are payloadAttributes: // 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) { func (api *ConsensusAPI) ForkchoiceUpdatedV1(heads beacon.ForkchoiceStateV1, payloadAttributes *beacon.PayloadAttributesV1) (beacon.ForkChoiceResponse, error) {
if heads.HeadBlockHash == (common.Hash{}) { if heads.HeadBlockHash == (common.Hash{}) {
log.Warn("Forkchoice requested update to zero hash") log.Warn("Forkchoice requested update to zero hash")

View file

@ -20,10 +20,10 @@ import (
"context" "context"
"sync" "sync"
"github.com/cryptoecc/ETH-ECC"
"github.com/cryptoecc/ETH-ECC/event" "github.com/cryptoecc/ETH-ECC/event"
"github.com/cryptoecc/ETH-ECC/rpc" "github.com/cryptoecc/ETH-ECC/rpc"
"github.com/ethereum/go-ethereum" )
)
// DownloaderAPI provides an API which gives information about the current synchronisation status. // 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. // It offers only methods that operates on data that can be available to anyone without security risks.

View file

@ -28,6 +28,7 @@ import (
"sync/atomic" "sync/atomic"
"time" "time"
"github.com/cryptoecc/ETH-ECC"
"github.com/cryptoecc/ETH-ECC/common" "github.com/cryptoecc/ETH-ECC/common"
"github.com/cryptoecc/ETH-ECC/core/rawdb" "github.com/cryptoecc/ETH-ECC/core/rawdb"
"github.com/cryptoecc/ETH-ECC/core/state/snapshot" "github.com/cryptoecc/ETH-ECC/core/state/snapshot"
@ -39,8 +40,7 @@ import (
"github.com/cryptoecc/ETH-ECC/log" "github.com/cryptoecc/ETH-ECC/log"
"github.com/cryptoecc/ETH-ECC/metrics" "github.com/cryptoecc/ETH-ECC/metrics"
"github.com/cryptoecc/ETH-ECC/params" "github.com/cryptoecc/ETH-ECC/params"
"github.com/ethereum/go-ethereum" )
)
var ( var (
MaxBlockFetch = 128 // Amount of blocks to be fetched per retrieval request 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 // calculateRequestSpan calculates what headers to request from a peer when trying to determine the
// common ancestor. // common ancestor.
// It returns parameters to be used for peer.RequestHeadersByNumber: // It returns parameters to be used for peer.RequestHeadersByNumber:
// // from - starting block number
// from - starting block number // count - number of headers to request
// count - number of headers to request // skip - number of headers to skip
// skip - number of headers to skip
//
// and also returns 'max', the last block which is expected to be returned by the remote peers, // and also returns 'max', the last block which is expected to be returned by the remote peers,
// given the (from,count,skip) // given the (from,count,skip)
func calculateRequestSpan(remoteHeight, localHeight uint64) (int64, int, int, uint64) { 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. // various callbacks to handle the slight differences between processing them.
// //
// The instrumentation parameters: // The instrumentation parameters:
// - errCancel: error type to return if the fetch operation is cancelled (mostly makes logging nicer) // - 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) // - 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`) // - 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) // - 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) // - 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) // - 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) // - 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) // - 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) // - 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) // - 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 // - 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) // - 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) // - 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 // - 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) // - 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 // - 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, 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), 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, fetchHook func([]*types.Header), fetch func(*peerConnection, *fetchRequest) error, cancel func(*fetchRequest), capacity func(*peerConnection) int,

View file

@ -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. // to access the queue, so they already need a lock anyway.
// //
// Returns: // Returns:
// // item - the fetchRequest
// item - the fetchRequest // progress - whether any progress was made
// progress - whether any progress was made // throttle - if the caller should throttle for a while
// 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, 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) { pendPool map[string]*fetchRequest, kind uint) (*fetchRequest, bool, bool) {
// Short circuit if the pool has been depleted, or if the peer's already // Short circuit if the pool has been depleted, or if the peer's already

View file

@ -71,11 +71,10 @@ func (r *resultStore) SetThrottleThreshold(threshold uint64) uint64 {
// wants to reserve headers for fetching. // wants to reserve headers for fetching.
// //
// It returns the following: // It returns the following:
// // stale - if true, this item is already passed, and should not be requested again
// 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
// throttled - if true, the store is at capacity, this particular header is not prio now // item - the result to store data into
// item - the result to store data into // err - any error that occurred
// err - any error that occurred
func (r *resultStore) AddFetch(header *types.Header, fastSync bool) (stale, throttled bool, item *fetchResult, err error) { func (r *resultStore) AddFetch(header *types.Header, fastSync bool) (stale, throttled bool, item *fetchResult, err error) {
r.lock.Lock() r.lock.Lock()
defer r.lock.Unlock() defer r.lock.Unlock()

View file

@ -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 // 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) // - block header retrieval
// If we are running in ultra light client mode, then all announcements from // Whenever we receive announce with higher td compared with local chain, the
// the trusted servers are maintained. If the same announcements from trusted // request will be made for header retrieval.
// servers reach the threshold, then the relevant header is requested for retrieval.
// //
// - block header retrieval // - re-sync trigger
// Whenever we receive announce with higher td compared with local chain, the // If the local chain lags too much, then the fetcher will enter "synchronise"
// request will be made for header retrieval. // 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() { func (f *lightFetcher) mainloop() {
defer f.wg.Done() defer f.wg.Done()

View file

@ -25,6 +25,7 @@ import (
"math/big" "math/big"
"time" "time"
mapset "github.com/deckarep/golang-set"
"github.com/cryptoecc/ETH-ECC/common" "github.com/cryptoecc/ETH-ECC/common"
"github.com/cryptoecc/ETH-ECC/common/bitutil" "github.com/cryptoecc/ETH-ECC/common/bitutil"
"github.com/cryptoecc/ETH-ECC/core" "github.com/cryptoecc/ETH-ECC/core"
@ -35,8 +36,7 @@ import (
"github.com/cryptoecc/ETH-ECC/params" "github.com/cryptoecc/ETH-ECC/params"
"github.com/cryptoecc/ETH-ECC/rlp" "github.com/cryptoecc/ETH-ECC/rlp"
"github.com/cryptoecc/ETH-ECC/trie" "github.com/cryptoecc/ETH-ECC/trie"
mapset "github.com/deckarep/golang-set" )
)
// IndexerConfig includes a set of configs for chain indexers. // IndexerConfig includes a set of configs for chain indexers.
type IndexerConfig struct { type IndexerConfig struct {

View file

@ -23,6 +23,7 @@ import (
"math/big" "math/big"
"testing" "testing"
"github.com/davecgh/go-spew/spew"
"github.com/cryptoecc/ETH-ECC/consensus/ethash" "github.com/cryptoecc/ETH-ECC/consensus/ethash"
"github.com/cryptoecc/ETH-ECC/core" "github.com/cryptoecc/ETH-ECC/core"
"github.com/cryptoecc/ETH-ECC/core/rawdb" "github.com/cryptoecc/ETH-ECC/core/rawdb"
@ -30,8 +31,7 @@ import (
"github.com/cryptoecc/ETH-ECC/core/vm" "github.com/cryptoecc/ETH-ECC/core/vm"
"github.com/cryptoecc/ETH-ECC/params" "github.com/cryptoecc/ETH-ECC/params"
"github.com/cryptoecc/ETH-ECC/trie" "github.com/cryptoecc/ETH-ECC/trie"
"github.com/davecgh/go-spew/spew" )
)
func TestNodeIterator(t *testing.T) { func TestNodeIterator(t *testing.T) {
var ( var (

View file

@ -76,13 +76,10 @@ type TxPool struct {
// //
// Send instructs backend to forward new transactions // Send instructs backend to forward new transactions
// NewHead notifies backend about a new head after processed by the tx pool, // 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 // 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
// because they have been replaced by a re-send or because they have been mined // long ago and no rollback is expected
// long ago and no rollback is expected
type TxRelayBackend interface { type TxRelayBackend interface {
Send(txs types.Transactions) Send(txs types.Transactions)
NewHead(head common.Hash, mined []common.Hash, rollback []common.Hash) NewHead(head common.Hash, mined []common.Hash, rollback []common.Hash)

View file

@ -79,11 +79,12 @@ type TerminalStringer interface {
// a terminal with color-coded level output and terser human friendly timestamp. // a terminal with color-coded level output and terser human friendly timestamp.
// This format should only be used for interactive programs or while developing. // 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: // 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 { func TerminalFormat(usecolor bool) Format {
return FormatFunc(func(r *Record) []byte { return FormatFunc(func(r *Record) []byte {
var color = 0 var color = 0
@ -148,6 +149,7 @@ func TerminalFormat(usecolor bool) Format {
// format for key/value pairs. // format for key/value pairs.
// //
// For more details see: http://godoc.org/github.com/kr/logfmt // For more details see: http://godoc.org/github.com/kr/logfmt
//
func LogfmtFormat() Format { func LogfmtFormat() Format {
return FormatFunc(func(r *Record) []byte { return FormatFunc(func(r *Record) []byte {
common := []interface{}{r.KeyNames.Time, r.Time, r.KeyNames.Lvl, r.Lvl, r.KeyNames.Msg, r.Msg} common := []interface{}{r.KeyNames.Time, r.Time, r.KeyNames.Lvl, r.Lvl, r.KeyNames.Msg, r.Msg}

View file

@ -1,3 +1,4 @@
//
// The go-ethereum library is distributed in the hope that it will be useful, // The go-ethereum library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the

View file

@ -77,6 +77,7 @@ func (bi *BigInt) SetInt64(x int64) {
// -1 if x < 0 // -1 if x < 0
// 0 if x == 0 // 0 if x == 0
// +1 if x > 0 // +1 if x > 0
//
func (bi *BigInt) Sign() int { func (bi *BigInt) Sign() int {
return bi.bigint.Sign() return bi.bigint.Sign()
} }

View file

@ -38,8 +38,8 @@ type Enode struct {
// //
// For incomplete nodes, the designator must look like one of these // For incomplete nodes, the designator must look like one of these
// //
// enode://<hex node id> // enode://<hex node id>
// <hex node id> // <hex node id>
// //
// For complete nodes, the node ID is encoded in the username portion // 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 // 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 // a node with IP address 10.3.58.6, TCP listening port 30303
// and UDP discovery port 30301. // 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) { func NewEnode(rawurl string) (*Enode, error) {
node, err := enode.Parse(enode.ValidSchemes, rawurl) node, err := enode.Parse(enode.ValidSchemes, rawurl)
if err != nil { if err != nil {

View file

@ -21,7 +21,7 @@ package geth
import ( import (
"errors" "errors"
ethereum "github.com/cryptoecc/ETH-ECC" "github.com/cryptoecc/ETH-ECC"
"github.com/cryptoecc/ETH-ECC/common" "github.com/cryptoecc/ETH-ECC/common"
) )

View file

@ -27,8 +27,8 @@ import (
// life cycle management. // life cycle management.
// //
// The following methods are needed to implement a node.Lifecycle: // The following methods are needed to implement a node.Lifecycle:
// - Start() error - method invoked when the node is ready to start 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 // - Stop() error - method invoked when the node terminates the service
type SampleLifecycle struct{} type SampleLifecycle struct{}
func (s *SampleLifecycle) Start() error { fmt.Println("Service starting..."); return nil } func (s *SampleLifecycle) Start() error { fmt.Println("Service starting..."); return nil }

View file

@ -84,12 +84,13 @@ var (
// dialer creates outbound connections and submits them into Server. // dialer creates outbound connections and submits them into Server.
// Two types of peer connections can be created: // Two types of peer connections can be created:
// //
// - static dials are pre-configured connections. The dialer attempts // - static dials are pre-configured connections. The dialer attempts
// keep these nodes connected at all times. // 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 { type dialScheduler struct {
dialConfig dialConfig
setupFunc dialSetupFunc setupFunc dialSetupFunc

View file

@ -22,10 +22,10 @@ import (
"reflect" "reflect"
"testing" "testing"
"github.com/davecgh/go-spew/spew"
"github.com/cryptoecc/ETH-ECC/crypto" "github.com/cryptoecc/ETH-ECC/crypto"
"github.com/cryptoecc/ETH-ECC/rlp" "github.com/cryptoecc/ETH-ECC/rlp"
"github.com/davecgh/go-spew/spew" )
)
// EIP-8 test vectors. // EIP-8 test vectors.
var testPackets = []struct { var testPackets = []struct {

View file

@ -29,16 +29,17 @@ import (
"strings" "strings"
"testing" "testing"
"github.com/davecgh/go-spew/spew"
"github.com/cryptoecc/ETH-ECC/common/hexutil" "github.com/cryptoecc/ETH-ECC/common/hexutil"
"github.com/cryptoecc/ETH-ECC/common/mclock" "github.com/cryptoecc/ETH-ECC/common/mclock"
"github.com/cryptoecc/ETH-ECC/crypto" "github.com/cryptoecc/ETH-ECC/crypto"
"github.com/cryptoecc/ETH-ECC/p2p/enode" "github.com/cryptoecc/ETH-ECC/p2p/enode"
"github.com/davecgh/go-spew/spew" )
)
// To regenerate discv5 test vectors, run // 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 writeTestVectorsFlag = flag.Bool("write-test-vectors", false, "Overwrite discv5 test vectors in testdata/")
var ( var (

View file

@ -25,14 +25,14 @@ import (
"testing" "testing"
"time" "time"
"github.com/davecgh/go-spew/spew"
"github.com/cryptoecc/ETH-ECC/common/mclock" "github.com/cryptoecc/ETH-ECC/common/mclock"
"github.com/cryptoecc/ETH-ECC/crypto" "github.com/cryptoecc/ETH-ECC/crypto"
"github.com/cryptoecc/ETH-ECC/internal/testlog" "github.com/cryptoecc/ETH-ECC/internal/testlog"
"github.com/cryptoecc/ETH-ECC/log" "github.com/cryptoecc/ETH-ECC/log"
"github.com/cryptoecc/ETH-ECC/p2p/enode" "github.com/cryptoecc/ETH-ECC/p2p/enode"
"github.com/cryptoecc/ETH-ECC/p2p/enr" "github.com/cryptoecc/ETH-ECC/p2p/enr"
"github.com/davecgh/go-spew/spew" )
)
const ( const (
signingKeySeed = 0x111111 signingKeySeed = 0x111111

View file

@ -20,10 +20,10 @@ import (
"reflect" "reflect"
"testing" "testing"
"github.com/davecgh/go-spew/spew"
"github.com/cryptoecc/ETH-ECC/common/hexutil" "github.com/cryptoecc/ETH-ECC/common/hexutil"
"github.com/cryptoecc/ETH-ECC/p2p/enode" "github.com/cryptoecc/ETH-ECC/p2p/enode"
"github.com/davecgh/go-spew/spew" )
)
func TestParseRoot(t *testing.T) { func TestParseRoot(t *testing.T) {
tests := []struct { tests := []struct {

View file

@ -54,8 +54,8 @@ func MustParseV4(rawurl string) *Node {
// //
// For incomplete nodes, the designator must look like one of these // For incomplete nodes, the designator must look like one of these
// //
// enode://<hex node id> // enode://<hex node id>
// <hex node id> // <hex node id>
// //
// For complete nodes, the node ID is encoded in the username portion // 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 // 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 // a node with IP address 10.3.58.6, TCP listening port 30303
// and UDP discovery port 30301. // 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) { func ParseV4(rawurl string) (*Node, error) {
if m := incompleteNodeURL.FindStringSubmatch(rawurl); m != nil { if m := incompleteNodeURL.FindStringSubmatch(rawurl); m != nil {
id, err := parsePubkey(m[1]) id, err := parsePubkey(m[1])

View file

@ -19,7 +19,7 @@
// stored in key/value pairs. To store and retrieve key/values in a record, use the Entry // stored in key/value pairs. To store and retrieve key/values in a record, use the Entry
// interface. // interface.
// //
// # Signature Handling // Signature Handling
// //
// Records must be signed before transmitting them to another node. // Records must be signed before transmitting them to another node.
// //

View file

@ -107,11 +107,12 @@ func Send(w MsgWriter, msgcode uint64, data interface{}) error {
// SendItems writes an RLP with the given code and data elements. // SendItems writes an RLP with the given code and data elements.
// For a call such as: // 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: // 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 { func SendItems(w MsgWriter, msgcode uint64, elems ...interface{}) error {
return Send(w, msgcode, elems) return Send(w, msgcode, elems)
} }

View file

@ -53,12 +53,12 @@ type Interface interface {
// The following formats are currently accepted. // The following formats are currently accepted.
// Note that mechanism names are not case-sensitive. // Note that mechanism names are not case-sensitive.
// //
// "" or "none" return nil // "" or "none" return nil
// "extip:77.12.33.4" will assume the local machine is reachable on the given IP // "extip:77.12.33.4" will assume the local machine is reachable on the given IP
// "any" uses the first auto-detected mechanism // "any" uses the first auto-detected mechanism
// "upnp" uses the Universal Plug and Play protocol // "upnp" uses the Universal Plug and Play protocol
// "pmp" uses NAT-PMP with an auto-detected gateway address // "pmp" uses NAT-PMP with an auto-detected gateway address
// "pmp:192.168.0.1" uses NAT-PMP with the given gateway address // "pmp:192.168.0.1" uses NAT-PMP with the given gateway address
func Parse(spec string) (Interface, error) { func Parse(spec string) (Interface, error) {
var ( var (
parts = strings.SplitN(spec, ":", 2) parts = strings.SplitN(spec, ":", 2)

View file

@ -28,11 +28,11 @@ import (
"strings" "strings"
"testing" "testing"
"github.com/davecgh/go-spew/spew"
"github.com/cryptoecc/ETH-ECC/crypto" "github.com/cryptoecc/ETH-ECC/crypto"
"github.com/cryptoecc/ETH-ECC/crypto/ecies" "github.com/cryptoecc/ETH-ECC/crypto/ecies"
"github.com/cryptoecc/ETH-ECC/p2p/simulations/pipes" "github.com/cryptoecc/ETH-ECC/p2p/simulations/pipes"
"github.com/cryptoecc/ETH-ECC/rlp" "github.com/cryptoecc/ETH-ECC/rlp"
"github.com/davecgh/go-spew/spew"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
) )

View file

@ -34,12 +34,12 @@ import (
"syscall" "syscall"
"time" "time"
"github.com/docker/docker/pkg/reexec"
"github.com/cryptoecc/ETH-ECC/log" "github.com/cryptoecc/ETH-ECC/log"
"github.com/cryptoecc/ETH-ECC/node" "github.com/cryptoecc/ETH-ECC/node"
"github.com/cryptoecc/ETH-ECC/p2p" "github.com/cryptoecc/ETH-ECC/p2p"
"github.com/cryptoecc/ETH-ECC/p2p/enode" "github.com/cryptoecc/ETH-ECC/p2p/enode"
"github.com/cryptoecc/ETH-ECC/rpc" "github.com/cryptoecc/ETH-ECC/rpc"
"github.com/docker/docker/pkg/reexec"
"github.com/gorilla/websocket" "github.com/gorilla/websocket"
) )

View file

@ -25,6 +25,7 @@ import (
"os" "os"
"strconv" "strconv"
"github.com/docker/docker/pkg/reexec"
"github.com/cryptoecc/ETH-ECC/crypto" "github.com/cryptoecc/ETH-ECC/crypto"
"github.com/cryptoecc/ETH-ECC/log" "github.com/cryptoecc/ETH-ECC/log"
"github.com/cryptoecc/ETH-ECC/node" "github.com/cryptoecc/ETH-ECC/node"
@ -32,7 +33,6 @@ import (
"github.com/cryptoecc/ETH-ECC/p2p/enode" "github.com/cryptoecc/ETH-ECC/p2p/enode"
"github.com/cryptoecc/ETH-ECC/p2p/enr" "github.com/cryptoecc/ETH-ECC/p2p/enr"
"github.com/cryptoecc/ETH-ECC/rpc" "github.com/cryptoecc/ETH-ECC/rpc"
"github.com/docker/docker/pkg/reexec"
"github.com/gorilla/websocket" "github.com/gorilla/websocket"
) )
@ -42,6 +42,7 @@ import (
// * SimNode - An in-memory node // * SimNode - An in-memory node
// * ExecNode - A child process node // * ExecNode - A child process node
// * DockerNode - A Docker container node // * DockerNode - A Docker container node
//
type Node interface { type Node interface {
// Addr returns the node's address (e.g. an Enode URL) // Addr returns the node's address (e.g. an Enode URL)
Addr() []byte Addr() []byte

View file

@ -29,20 +29,20 @@ import (
"github.com/cryptoecc/ETH-ECC/p2p/simulations/adapters" "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){ var mockerList = map[string]func(net *Network, quit chan struct{}, nodeCount int){
"startStop": startStop, "startStop": startStop,
"probabilistic": probabilistic, "probabilistic": probabilistic,
"boot": boot, "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) { func LookupMocker(mockerType string) func(net *Network, quit chan struct{}, nodeCount int) {
return mockerList[mockerType] return mockerList[mockerType]
} }
// Get a list of mockers (keys of the map) //Get a list of mockers (keys of the map)
// Useful for frontend to build available mocker selection //Useful for frontend to build available mocker selection
func GetMockerList() []string { func GetMockerList() []string {
list := make([]string, 0, len(mockerList)) list := make([]string, 0, len(mockerList))
for k := range mockerList { for k := range mockerList {
@ -51,7 +51,7 @@ func GetMockerList() []string {
return list 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) { func boot(net *Network, quit chan struct{}, nodeCount int) {
_, err := connectNodesInRing(net, nodeCount) _, err := connectNodesInRing(net, nodeCount)
if err != nil { 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) { func startStop(net *Network, quit chan struct{}, nodeCount int) {
nodes, err := connectNodesInRing(net, nodeCount) nodes, err := connectNodesInRing(net, nodeCount)
if err != nil { 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 probabilistic mocker func has a more probabilistic pattern
// (the implementation could probably be improved): //(the implementation could probably be improved):
// nodes are connected in a ring, then a varying number of random nodes is selected, //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 //mocker then stops and starts them in random intervals, and continues the loop
func probabilistic(net *Network, quit chan struct{}, nodeCount int) { func probabilistic(net *Network, quit chan struct{}, nodeCount int) {
nodes, err := connectNodesInRing(net, nodeCount) nodes, err := connectNodesInRing(net, nodeCount)
if err != nil { 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) { func connectNodesInRing(net *Network, nodeCount int) ([]enode.ID, error) {
ids := make([]enode.ID, nodeCount) ids := make([]enode.ID, nodeCount)
for i := 0; i < nodeCount; i++ { for i := 0; i < nodeCount; i++ {

View file

@ -22,10 +22,10 @@ import (
"sync" "sync"
"testing" "testing"
"github.com/davecgh/go-spew/spew"
"github.com/cryptoecc/ETH-ECC/crypto" "github.com/cryptoecc/ETH-ECC/crypto"
"github.com/cryptoecc/ETH-ECC/p2p/simulations/pipes" "github.com/cryptoecc/ETH-ECC/p2p/simulations/pipes"
"github.com/davecgh/go-spew/spew" )
)
func TestProtocolHandshake(t *testing.T) { func TestProtocolHandshake(t *testing.T) {
var ( var (

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