mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 02:42:27 +00:00
all: fix packages and comments
This commit is contained in:
parent
c2fc306206
commit
e5a24bdf69
117 changed files with 506 additions and 525 deletions
|
|
@ -165,7 +165,6 @@ 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{}
|
||||||
// }
|
// }
|
||||||
|
|
@ -725,7 +724,6 @@ 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);
|
||||||
|
|
@ -734,9 +732,7 @@ func TestBareEvents(t *testing.T) {
|
||||||
// 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"}]`
|
||||||
|
|
@ -1082,7 +1078,6 @@ 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();
|
||||||
|
|
@ -1111,7 +1106,6 @@ 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);
|
||||||
// }
|
// }
|
||||||
|
|
|
||||||
|
|
@ -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"
|
||||||
|
|
@ -994,7 +994,6 @@ func TestCodeAt(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// When receive("X") is called with sender 0x00... and value 1, it produces this tx receipt:
|
// 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)
|
||||||
|
|
@ -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)
|
||||||
|
|
|
||||||
|
|
@ -24,12 +24,12 @@ 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
|
||||||
|
|
|
||||||
|
|
@ -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"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,8 +21,8 @@ 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
|
||||||
|
|
|
||||||
|
|
@ -177,7 +177,6 @@ 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.
|
||||||
|
|
@ -190,7 +189,6 @@ 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.
|
||||||
|
|
|
||||||
|
|
@ -27,9 +27,9 @@ 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 (
|
||||||
|
|
|
||||||
|
|
@ -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)
|
||||||
|
|
|
||||||
|
|
@ -407,6 +407,8 @@ func (w *ledgerDriver) ledgerSign(derivationPath []uint32, tx *types.Transaction
|
||||||
// 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
|
||||||
|
|
|
||||||
|
|
@ -84,14 +84,14 @@ 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
|
||||||
|
|
|
||||||
|
|
@ -21,8 +21,8 @@ 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 {
|
||||||
|
|
|
||||||
|
|
@ -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"
|
||||||
|
|
|
||||||
|
|
@ -336,7 +336,6 @@ func (t *txWithKey) UnmarshalJSON(input []byte) error {
|
||||||
// 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.
|
||||||
|
|
|
||||||
|
|
@ -24,9 +24,9 @@ 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) {
|
||||||
|
|
|
||||||
2
cmd/evm/testdata/21/readme.md
vendored
2
cmd/evm/testdata/21/readme.md
vendored
|
|
@ -21,3 +21,5 @@ $ go run . b11r --input.header=testdata/21/header.json --input.txs=testdata/21/t
|
||||||
"hash": "0x71c59102cc805dbe8741e1210ebe229a321eff144ac7276006fefe39e8357dc7"
|
"hash": "0x71c59102cc805dbe8741e1210ebe229a321eff144ac7276006fefe39e8357dc7"
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Eccpow(working...)
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@
|
||||||
//
|
//
|
||||||
// $ p2psim node connect node01 node02
|
// $ p2psim node connect node01 node02
|
||||||
// Connected node01 to node02
|
// Connected node01 to node02
|
||||||
|
//
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,6 @@ import (
|
||||||
// - 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 {
|
||||||
|
|
|
||||||
|
|
@ -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)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,6 @@ 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
|
||||||
|
|
|
||||||
|
|
@ -339,7 +339,6 @@ 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
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,6 @@ 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
|
||||||
|
|
|
||||||
|
|
@ -19,8 +19,8 @@ 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
|
||||||
|
|
|
||||||
|
|
@ -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")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -2050,7 +2050,6 @@ func testSideImport(t *testing.T, numCanonBlocksInSidechain, blocksBetweenCommon
|
||||||
// That is: the sidechain for import contains some blocks already present in canon chain.
|
// 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)))
|
||||||
|
|
@ -3376,6 +3375,7 @@ func TestDeleteRecreateSlotsAcrossManyBlocks(t *testing.T) {
|
||||||
// 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
|
||||||
|
|
|
||||||
|
|
@ -21,13 +21,13 @@ 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) {
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -22,9 +22,9 @@ 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 {
|
||||||
|
|
|
||||||
|
|
@ -264,7 +264,6 @@ 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
|
||||||
|
|
|
||||||
|
|
@ -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,
|
||||||
|
|
@ -416,11 +411,9 @@ func opExtCodeCopy(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext)
|
||||||
// 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()
|
||||||
|
|
|
||||||
|
|
@ -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"
|
||||||
|
|
|
||||||
|
|
@ -24,12 +24,12 @@ 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: " "}
|
||||||
|
|
|
||||||
|
|
@ -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()
|
||||||
|
|
|
||||||
|
|
@ -20,9 +20,9 @@ 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.
|
||||||
|
|
|
||||||
|
|
@ -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,7 +35,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/params"
|
"github.com/cryptoecc/ETH-ECC/params"
|
||||||
"github.com/ethereum/go-ethereum"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|
@ -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) {
|
||||||
|
|
|
||||||
|
|
@ -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,7 +41,6 @@ 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.
|
||||||
|
|
|
||||||
|
|
@ -480,7 +480,6 @@ func (q *queue) ReserveReceipts(p *peerConnection, count int) (*fetchRequest, bo
|
||||||
// to access the queue, so they already need a lock anyway.
|
// 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
|
||||||
|
|
|
||||||
|
|
@ -71,7 +71,6 @@ 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
|
||||||
|
|
|
||||||
|
|
@ -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"
|
||||||
|
|
|
||||||
|
|
@ -24,13 +24,13 @@ 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 (
|
||||||
|
|
|
||||||
|
|
@ -25,11 +25,11 @@ 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
|
||||||
|
|
|
||||||
|
|
@ -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"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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,7 +37,6 @@ 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 {
|
||||||
|
|
|
||||||
|
|
@ -212,7 +212,6 @@ func (oracle *Oracle) resolveBlockRange(ctx context.Context, reqEnd rpc.BlockNum
|
||||||
// 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) {
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,11 +21,11 @@ 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 (
|
||||||
|
|
|
||||||
|
|
@ -369,7 +369,6 @@ func createStorageRequestResponse(t *testPeer, root common.Hash, accounts []comm
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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
|
||||||
|
|
|
||||||
|
|
@ -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"
|
||||||
|
|
|
||||||
|
|
@ -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,7 +36,6 @@ 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 (
|
||||||
|
|
|
||||||
|
|
@ -266,7 +266,6 @@ 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)
|
||||||
// -------+------------+---------------+---------------+---------------+---------------
|
// -------+------------+---------------+---------------+---------------+---------------
|
||||||
|
|
|
||||||
|
|
@ -102,7 +102,6 @@ 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
|
||||||
|
|
|
||||||
|
|
@ -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"
|
||||||
|
|
|
||||||
|
|
@ -731,9 +731,9 @@ 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)
|
||||||
|
|
|
||||||
|
|
@ -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,7 +38,6 @@ 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.
|
||||||
|
|
|
||||||
|
|
@ -366,7 +366,6 @@ 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
|
||||||
|
|
@ -385,7 +384,6 @@ 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
|
||||||
|
|
|
||||||
|
|
@ -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"
|
||||||
|
|
|
||||||
|
|
@ -57,20 +57,13 @@ 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{}) {
|
||||||
|
|
|
||||||
|
|
@ -20,9 +20,9 @@ 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.
|
||||||
|
|
|
||||||
|
|
@ -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,7 +40,6 @@ 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 (
|
||||||
|
|
@ -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) {
|
||||||
|
|
|
||||||
|
|
@ -477,7 +477,6 @@ func (q *queue) ReserveReceipts(p *peerConnection, count int) (*fetchRequest, bo
|
||||||
// to access the queue, so they already need a lock anyway.
|
// 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
|
||||||
|
|
|
||||||
|
|
@ -71,7 +71,6 @@ 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
|
||||||
|
|
|
||||||
|
|
@ -242,7 +242,6 @@ func (f *lightFetcher) forEachPeer(check func(id enode.ID, p *fetcherPeer) bool)
|
||||||
}
|
}
|
||||||
|
|
||||||
// mainloop is the main event loop of the light fetcher, which is responsible for
|
// mainloop is the main event loop of the light fetcher, which is responsible for
|
||||||
//
|
|
||||||
// - announcement maintenance(ulc)
|
// - announcement maintenance(ulc)
|
||||||
// If we are running in ultra light client mode, then all announcements from
|
// If we are running in ultra light client mode, then all announcements from
|
||||||
// the trusted servers are maintained. If the same announcements from trusted
|
// the trusted servers are maintained. If the same announcements from trusted
|
||||||
|
|
|
||||||
|
|
@ -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,7 +36,6 @@ 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.
|
||||||
|
|
|
||||||
|
|
@ -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,7 +31,6 @@ 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) {
|
||||||
|
|
|
||||||
|
|
@ -76,11 +76,8 @@ 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 {
|
||||||
|
|
|
||||||
|
|
@ -84,6 +84,7 @@ type TerminalStringer interface {
|
||||||
// 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}
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -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()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -90,6 +90,7 @@ var (
|
||||||
// - dynamic dials are created from node discovery results. The dialer
|
// - dynamic dials are created from node discovery results. The dialer
|
||||||
// continuously reads candidate nodes from its input iterator and attempts
|
// continuously reads candidate nodes from its input iterator and attempts
|
||||||
// to create peer connections to nodes arriving through the iterator.
|
// to create peer connections to nodes arriving through the iterator.
|
||||||
|
//
|
||||||
type dialScheduler struct {
|
type dialScheduler struct {
|
||||||
dialConfig
|
dialConfig
|
||||||
setupFunc dialSetupFunc
|
setupFunc dialSetupFunc
|
||||||
|
|
|
||||||
|
|
@ -22,9 +22,9 @@ 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.
|
||||||
|
|
|
||||||
|
|
@ -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 (
|
||||||
|
|
|
||||||
|
|
@ -25,13 +25,13 @@ 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 (
|
||||||
|
|
|
||||||
|
|
@ -20,9 +20,9 @@ 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) {
|
||||||
|
|
|
||||||
|
|
@ -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.
|
||||||
//
|
//
|
||||||
|
|
|
||||||
|
|
@ -112,6 +112,7 @@ func Send(w MsgWriter, msgcode uint64, data interface{}) error {
|
||||||
// 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)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -22,9 +22,9 @@ 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) {
|
||||||
|
|
|
||||||
|
|
@ -32,8 +32,8 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/cryptoecc/ETH-ECC/log"
|
|
||||||
"github.com/davecgh/go-spew/spew"
|
"github.com/davecgh/go-spew/spew"
|
||||||
|
"github.com/cryptoecc/ETH-ECC/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestClientRequest(t *testing.T) {
|
func TestClientRequest(t *testing.T) {
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@
|
||||||
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
Package rpc implements bi-directional JSON-RPC 2.0 on multiple transports.
|
Package rpc implements bi-directional JSON-RPC 2.0 on multiple transports.
|
||||||
|
|
||||||
It provides access to the exported methods of an object across a network or other I/O
|
It provides access to the exported methods of an object across a network or other I/O
|
||||||
|
|
@ -22,7 +23,7 @@ connection. After creating a server or client instance, objects can be registere
|
||||||
them visible as 'services'. Exported methods that follow specific conventions can be
|
them visible as 'services'. Exported methods that follow specific conventions can be
|
||||||
called remotely. It also has support for the publish/subscribe pattern.
|
called remotely. It also has support for the publish/subscribe pattern.
|
||||||
|
|
||||||
# RPC Methods
|
RPC Methods
|
||||||
|
|
||||||
Methods that satisfy the following criteria are made available for remote access:
|
Methods that satisfy the following criteria are made available for remote access:
|
||||||
|
|
||||||
|
|
@ -74,7 +75,7 @@ An example server which uses the JSON codec:
|
||||||
l, _ := net.ListenUnix("unix", &net.UnixAddr{Net: "unix", Name: "/tmp/calculator.sock"})
|
l, _ := net.ListenUnix("unix", &net.UnixAddr{Net: "unix", Name: "/tmp/calculator.sock"})
|
||||||
server.ServeListener(l)
|
server.ServeListener(l)
|
||||||
|
|
||||||
# Subscriptions
|
Subscriptions
|
||||||
|
|
||||||
The package also supports the publish subscribe pattern through the use of subscriptions.
|
The package also supports the publish subscribe pattern through the use of subscriptions.
|
||||||
A method that is considered eligible for notifications must satisfy the following
|
A method that is considered eligible for notifications must satisfy the following
|
||||||
|
|
@ -100,7 +101,7 @@ the client and server. The server will close the connection for any write error.
|
||||||
|
|
||||||
For more information about subscriptions, see https://github.com/cryptoecc/ETH-ECC/wiki/RPC-PUB-SUB.
|
For more information about subscriptions, see https://github.com/cryptoecc/ETH-ECC/wiki/RPC-PUB-SUB.
|
||||||
|
|
||||||
# Reverse Calls
|
Reverse Calls
|
||||||
|
|
||||||
In any method handler, an instance of rpc.Client can be accessed through the
|
In any method handler, an instance of rpc.Client can be accessed through the
|
||||||
ClientFromContext method. Using this client instance, server-to-client method calls can be
|
ClientFromContext method. Using this client instance, server-to-client method calls can be
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,7 @@ import (
|
||||||
// if err := op.wait(...); err != nil {
|
// if err := op.wait(...); err != nil {
|
||||||
// h.removeRequestOp(op) // timeout, etc.
|
// h.removeRequestOp(op) // timeout, etc.
|
||||||
// }
|
// }
|
||||||
|
//
|
||||||
type handler struct {
|
type handler struct {
|
||||||
reg *serviceRegistry
|
reg *serviceRegistry
|
||||||
unsubscribeCb *callback
|
unsubscribeCb *callback
|
||||||
|
|
|
||||||
|
|
@ -72,10 +72,8 @@ func checkInput(id byte, inputLen int) bool {
|
||||||
|
|
||||||
// The fuzzer functions must return
|
// The fuzzer functions must return
|
||||||
// 1 if the fuzzer should increase priority of the
|
// 1 if the fuzzer should increase priority of the
|
||||||
//
|
|
||||||
// given input during subsequent fuzzing (for example, the input is lexically
|
// given input during subsequent fuzzing (for example, the input is lexically
|
||||||
// correct and was parsed successfully);
|
// correct and was parsed successfully);
|
||||||
//
|
|
||||||
// -1 if the input must not be added to corpus even if gives new coverage; and
|
// -1 if the input must not be added to corpus even if gives new coverage; and
|
||||||
// 0 otherwise
|
// 0 otherwise
|
||||||
// other values are reserved for future use.
|
// other values are reserved for future use.
|
||||||
|
|
|
||||||
|
|
@ -68,10 +68,8 @@ func (f *fuzzer) readBool() bool {
|
||||||
|
|
||||||
// The function must return
|
// The function must return
|
||||||
// 1 if the fuzzer should increase priority of the
|
// 1 if the fuzzer should increase priority of the
|
||||||
//
|
|
||||||
// given input during subsequent fuzzing (for example, the input is lexically
|
// given input during subsequent fuzzing (for example, the input is lexically
|
||||||
// correct and was parsed successfully);
|
// correct and was parsed successfully);
|
||||||
//
|
|
||||||
// -1 if the input must not be added to corpus even if gives new coverage; and
|
// -1 if the input must not be added to corpus even if gives new coverage; and
|
||||||
// 0 otherwise
|
// 0 otherwise
|
||||||
// other values are reserved for future use.
|
// other values are reserved for future use.
|
||||||
|
|
|
||||||
|
|
@ -181,10 +181,8 @@ func (f *fuzzer) fuzz() int {
|
||||||
|
|
||||||
// The function must return
|
// The function must return
|
||||||
// 1 if the fuzzer should increase priority of the
|
// 1 if the fuzzer should increase priority of the
|
||||||
//
|
|
||||||
// given input during subsequent fuzzing (for example, the input is lexically
|
// given input during subsequent fuzzing (for example, the input is lexically
|
||||||
// correct and was parsed successfully);
|
// correct and was parsed successfully);
|
||||||
//
|
|
||||||
// -1 if the input must not be added to corpus even if gives new coverage; and
|
// -1 if the input must not be added to corpus even if gives new coverage; and
|
||||||
// 0 otherwise; other values are reserved for future use.
|
// 0 otherwise; other values are reserved for future use.
|
||||||
func Fuzz(input []byte) int {
|
func Fuzz(input []byte) int {
|
||||||
|
|
|
||||||
|
|
@ -115,10 +115,8 @@ func (k kvs) Swap(i, j int) {
|
||||||
|
|
||||||
// The function must return
|
// The function must return
|
||||||
// 1 if the fuzzer should increase priority of the
|
// 1 if the fuzzer should increase priority of the
|
||||||
//
|
|
||||||
// given input during subsequent fuzzing (for example, the input is lexically
|
// given input during subsequent fuzzing (for example, the input is lexically
|
||||||
// correct and was parsed successfully);
|
// correct and was parsed successfully);
|
||||||
//
|
|
||||||
// -1 if the input must not be added to corpus even if gives new coverage; and
|
// -1 if the input must not be added to corpus even if gives new coverage; and
|
||||||
// 0 otherwise
|
// 0 otherwise
|
||||||
// other values are reserved for future use.
|
// other values are reserved for future use.
|
||||||
|
|
|
||||||
|
|
@ -120,10 +120,8 @@ func Generate(input []byte) randTest {
|
||||||
|
|
||||||
// The function must return
|
// The function must return
|
||||||
// 1 if the fuzzer should increase priority of the
|
// 1 if the fuzzer should increase priority of the
|
||||||
//
|
|
||||||
// given input during subsequent fuzzing (for example, the input is lexically
|
// given input during subsequent fuzzing (for example, the input is lexically
|
||||||
// correct and was parsed successfully);
|
// correct and was parsed successfully);
|
||||||
//
|
|
||||||
// -1 if the input must not be added to corpus even if gives new coverage; and
|
// -1 if the input must not be added to corpus even if gives new coverage; and
|
||||||
// 0 otherwise
|
// 0 otherwise
|
||||||
// other values are reserved for future use.
|
// other values are reserved for future use.
|
||||||
|
|
|
||||||
|
|
@ -116,7 +116,6 @@ func (tm *testMatcher) skipLoad(pattern string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// fails adds an expected failure for tests matching the pattern.
|
// fails adds an expected failure for tests matching the pattern.
|
||||||
//
|
|
||||||
//nolint:unused
|
//nolint:unused
|
||||||
func (tm *testMatcher) fails(pattern string, reason string) {
|
func (tm *testMatcher) fails(pattern string, reason string) {
|
||||||
if reason == "" {
|
if reason == "" {
|
||||||
|
|
|
||||||
|
|
@ -35,14 +35,14 @@ func NewSecure(owner common.Hash, root common.Hash, db *Database) (*SecureTrie,
|
||||||
return NewStateTrie(owner, root, db)
|
return NewStateTrie(owner, root, db)
|
||||||
}
|
}
|
||||||
|
|
||||||
// StateTrie wraps a trie with key hashing. In a secure trie, all
|
// StateTrie wraps a trie with key hashing. In a stateTrie trie, all
|
||||||
// access operations hash the key using keccak256. This prevents
|
// access operations hash the key using keccak256. This prevents
|
||||||
// calling code from creating long chains of nodes that
|
// calling code from creating long chains of nodes that
|
||||||
// increase the access time.
|
// increase the access time.
|
||||||
//
|
//
|
||||||
// Contrary to a regular trie, a StateTrie can only be created with
|
// Contrary to a regular trie, a StateTrie can only be created with
|
||||||
// New and must have an attached database. The database also stores
|
// New and must have an attached database. The database also stores
|
||||||
// the preimage of each key.
|
// the preimage of each key if preimage recording is enabled.
|
||||||
//
|
//
|
||||||
// StateTrie is not safe for concurrent use.
|
// StateTrie is not safe for concurrent use.
|
||||||
type StateTrie struct {
|
type StateTrie struct {
|
||||||
|
|
@ -53,17 +53,11 @@ type StateTrie struct {
|
||||||
secKeyCacheOwner *StateTrie // Pointer to self, replace the key cache on mismatch
|
secKeyCacheOwner *StateTrie // Pointer to self, replace the key cache on mismatch
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewStateTrie creates a trie with an existing root node from a backing database
|
// NewStateTrie creates a trie with an existing root node from a backing database.
|
||||||
// and optional intermediate in-memory node pool.
|
|
||||||
//
|
//
|
||||||
// If root is the zero hash or the sha3 hash of an empty string, the
|
// If root is the zero hash or the sha3 hash of an empty string, the
|
||||||
// trie is initially empty. Otherwise, New will panic if db is nil
|
// trie is initially empty. Otherwise, New will panic if db is nil
|
||||||
// and returns MissingNodeError if the root node cannot be found.
|
// and returns MissingNodeError if the root node cannot be found.
|
||||||
//
|
|
||||||
// Accessing the trie loads nodes from the database or node pool on demand.
|
|
||||||
// Loaded nodes are kept around until their 'cache generation' expires.
|
|
||||||
// A new cache generation is created by each call to Commit.
|
|
||||||
// cachelimit sets the number of past cache generations to keep.
|
|
||||||
func NewStateTrie(owner common.Hash, root common.Hash, db *Database) (*StateTrie, error) {
|
func NewStateTrie(owner common.Hash, root common.Hash, db *Database) (*StateTrie, error) {
|
||||||
if db == nil {
|
if db == nil {
|
||||||
panic("trie.NewSecure called without a database")
|
panic("trie.NewSecure called without a database")
|
||||||
|
|
@ -87,11 +81,15 @@ func (t *StateTrie) Get(key []byte) []byte {
|
||||||
|
|
||||||
// TryGet returns the value for key stored in the trie.
|
// TryGet returns the value for key stored in the trie.
|
||||||
// The value bytes must not be modified by the caller.
|
// The value bytes must not be modified by the caller.
|
||||||
// If a node was not found in the database, a MissingNodeError is returned.
|
// If the specified node is not in the trie, nil will be returned.
|
||||||
|
// If a trie node is not found in the database, a MissingNodeError is returned.
|
||||||
func (t *StateTrie) TryGet(key []byte) ([]byte, error) {
|
func (t *StateTrie) TryGet(key []byte) ([]byte, error) {
|
||||||
return t.trie.TryGet(t.hashKey(key))
|
return t.trie.TryGet(t.hashKey(key))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TryGetAccount attempts to retrieve an account with provided trie path.
|
||||||
|
// If the specified account is not in the trie, nil will be returned.
|
||||||
|
// If a trie node is not found in the database, a MissingNodeError is returned.
|
||||||
func (t *StateTrie) TryGetAccount(key []byte) (*types.StateAccount, error) {
|
func (t *StateTrie) TryGetAccount(key []byte) (*types.StateAccount, error) {
|
||||||
var ret types.StateAccount
|
var ret types.StateAccount
|
||||||
res, err := t.trie.TryGet(t.hashKey(key))
|
res, err := t.trie.TryGet(t.hashKey(key))
|
||||||
|
|
|
||||||
|
|
@ -378,7 +378,6 @@ func (st *StackTrie) insert(key, value []byte) {
|
||||||
// 1. The rlp-encoded value was >= 32 bytes:
|
// 1. The rlp-encoded value was >= 32 bytes:
|
||||||
// - Then the 32-byte `hash` will be accessible in `st.val`.
|
// - Then the 32-byte `hash` will be accessible in `st.val`.
|
||||||
// - And the 'st.type' will be 'hashedNode'
|
// - And the 'st.type' will be 'hashedNode'
|
||||||
//
|
|
||||||
// 2. The rlp-encoded value was < 32 bytes
|
// 2. The rlp-encoded value was < 32 bytes
|
||||||
// - Then the <32 byte rlp-encoded value will be accessible in 'st.val'.
|
// - Then the <32 byte rlp-encoded value will be accessible in 'st.val'.
|
||||||
// - And the 'st.type' will be 'hashedNode' AGAIN
|
// - And the 'st.type' will be 'hashedNode' AGAIN
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
"testing/quick"
|
"testing/quick"
|
||||||
|
|
||||||
|
"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/types"
|
"github.com/cryptoecc/ETH-ECC/core/types"
|
||||||
|
|
@ -35,7 +36,6 @@ import (
|
||||||
"github.com/cryptoecc/ETH-ECC/ethdb"
|
"github.com/cryptoecc/ETH-ECC/ethdb"
|
||||||
"github.com/cryptoecc/ETH-ECC/ethdb/memorydb"
|
"github.com/cryptoecc/ETH-ECC/ethdb/memorydb"
|
||||||
"github.com/cryptoecc/ETH-ECC/rlp"
|
"github.com/cryptoecc/ETH-ECC/rlp"
|
||||||
"github.com/davecgh/go-spew/spew"
|
|
||||||
"golang.org/x/crypto/sha3"
|
"golang.org/x/crypto/sha3"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue