mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 18:32:23 +00:00
performing a exhaustive clean up on the unused params
This commit is contained in:
parent
1098d148a5
commit
fe82808dd2
17 changed files with 77 additions and 84 deletions
|
|
@ -1239,7 +1239,7 @@ func setIPC(ctx *cli.Context, cfg *node.Config) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// setLes shows the deprecation warnings for LES flags.
|
// setLes shows the deprecation warnings for LES flags.
|
||||||
func setLes(ctx *cli.Context, cfg *ethconfig.Config) {
|
func setLes(ctx *cli.Context) {
|
||||||
if ctx.IsSet(LightServeFlag.Name) {
|
if ctx.IsSet(LightServeFlag.Name) {
|
||||||
log.Warn("The light server has been deprecated, please remove this flag", "flag", LightServeFlag.Name)
|
log.Warn("The light server has been deprecated, please remove this flag", "flag", LightServeFlag.Name)
|
||||||
}
|
}
|
||||||
|
|
@ -1648,7 +1648,7 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
|
||||||
setTxPool(ctx, &cfg.TxPool)
|
setTxPool(ctx, &cfg.TxPool)
|
||||||
setMiner(ctx, &cfg.Miner)
|
setMiner(ctx, &cfg.Miner)
|
||||||
setRequiredBlocks(ctx, cfg)
|
setRequiredBlocks(ctx, cfg)
|
||||||
setLes(ctx, cfg)
|
setLes(ctx)
|
||||||
|
|
||||||
// Cap the cache allowance and tune the garbage collector
|
// Cap the cache allowance and tune the garbage collector
|
||||||
mem, err := gopsutil.VirtualMemory()
|
mem, err := gopsutil.VirtualMemory()
|
||||||
|
|
|
||||||
|
|
@ -378,7 +378,7 @@ func (c *Clique) verifyCascadingFields(chain consensus.ChainHeaderReader, header
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// All basic checks passed, verify the seal and return
|
// All basic checks passed, verify the seal and return
|
||||||
return c.verifySeal(snap, header, parents)
|
return c.verifySeal(snap, header)
|
||||||
}
|
}
|
||||||
|
|
||||||
// snapshot retrieves the authorization snapshot at a given point in time.
|
// snapshot retrieves the authorization snapshot at a given point in time.
|
||||||
|
|
@ -388,7 +388,7 @@ func (c *Clique) snapshot(chain consensus.ChainHeaderReader, number uint64, hash
|
||||||
headers []*types.Header
|
headers []*types.Header
|
||||||
snap *Snapshot
|
snap *Snapshot
|
||||||
)
|
)
|
||||||
for snap == nil {
|
for {
|
||||||
// If an in-memory snapshot was found, use that
|
// If an in-memory snapshot was found, use that
|
||||||
if s, ok := c.recents.Get(hash); ok {
|
if s, ok := c.recents.Get(hash); ok {
|
||||||
snap = s
|
snap = s
|
||||||
|
|
@ -475,7 +475,7 @@ func (c *Clique) VerifyUncles(chain consensus.ChainReader, block *types.Block) e
|
||||||
// consensus protocol requirements. The method accepts an optional list of parent
|
// consensus protocol requirements. The method accepts an optional list of parent
|
||||||
// headers that aren't yet part of the local blockchain to generate the snapshots
|
// headers that aren't yet part of the local blockchain to generate the snapshots
|
||||||
// from.
|
// from.
|
||||||
func (c *Clique) verifySeal(snap *Snapshot, header *types.Header, parents []*types.Header) error {
|
func (c *Clique) verifySeal(snap *Snapshot, header *types.Header) error {
|
||||||
// Verifying the genesis block is not supported
|
// Verifying the genesis block is not supported
|
||||||
number := header.Number.Uint64()
|
number := header.Number.Uint64()
|
||||||
if number == 0 {
|
if number == 0 {
|
||||||
|
|
|
||||||
|
|
@ -2182,10 +2182,10 @@ func testInsertKnownChainData(t *testing.T, typ string, scheme string) {
|
||||||
genDb, blocks, receipts := GenerateChainWithGenesis(genesis, engine, 32, func(i int, b *BlockGen) { b.SetCoinbase(common.Address{1}) })
|
genDb, blocks, receipts := GenerateChainWithGenesis(genesis, engine, 32, func(i int, b *BlockGen) { b.SetCoinbase(common.Address{1}) })
|
||||||
|
|
||||||
// A longer chain but total difficulty is lower.
|
// A longer chain but total difficulty is lower.
|
||||||
blocks2, receipts2 := GenerateChain(genesis.Config, blocks[len(blocks)-1], engine, genDb, 65, func(i int, b *BlockGen) { b.SetCoinbase(common.Address{1}) })
|
blocks2, _ := GenerateChain(genesis.Config, blocks[len(blocks)-1], engine, genDb, 65, func(i int, b *BlockGen) { b.SetCoinbase(common.Address{1}) })
|
||||||
|
|
||||||
// A shorter chain but total difficulty is higher.
|
// A shorter chain but total difficulty is higher.
|
||||||
blocks3, receipts3 := GenerateChain(genesis.Config, blocks[len(blocks)-1], engine, genDb, 64, func(i int, b *BlockGen) {
|
blocks3, _ := GenerateChain(genesis.Config, blocks[len(blocks)-1], engine, genDb, 64, func(i int, b *BlockGen) {
|
||||||
b.SetCoinbase(common.Address{1})
|
b.SetCoinbase(common.Address{1})
|
||||||
b.OffsetTime(-9) // A higher difficulty
|
b.OffsetTime(-9) // A higher difficulty
|
||||||
})
|
})
|
||||||
|
|
@ -2203,11 +2203,11 @@ func testInsertKnownChainData(t *testing.T, typ string, scheme string) {
|
||||||
defer chain.Stop()
|
defer chain.Stop()
|
||||||
|
|
||||||
var (
|
var (
|
||||||
inserter func(blocks []*types.Block, receipts []types.Receipts) error
|
inserter func(blocks []*types.Block) error
|
||||||
asserter func(t *testing.T, block *types.Block)
|
asserter func(t *testing.T, block *types.Block)
|
||||||
)
|
)
|
||||||
if typ == "headers" {
|
if typ == "headers" {
|
||||||
inserter = func(blocks []*types.Block, receipts []types.Receipts) error {
|
inserter = func(blocks []*types.Block) error {
|
||||||
headers := make([]*types.Header, 0, len(blocks))
|
headers := make([]*types.Header, 0, len(blocks))
|
||||||
for _, block := range blocks {
|
for _, block := range blocks {
|
||||||
headers = append(headers, block.Header())
|
headers = append(headers, block.Header())
|
||||||
|
|
@ -2221,7 +2221,7 @@ func testInsertKnownChainData(t *testing.T, typ string, scheme string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if typ == "receipts" {
|
} else if typ == "receipts" {
|
||||||
inserter = func(blocks []*types.Block, receipts []types.Receipts) error {
|
inserter = func(blocks []*types.Block) error {
|
||||||
headers := make([]*types.Header, 0, len(blocks))
|
headers := make([]*types.Header, 0, len(blocks))
|
||||||
for _, block := range blocks {
|
for _, block := range blocks {
|
||||||
headers = append(headers, block.Header())
|
headers = append(headers, block.Header())
|
||||||
|
|
@ -2239,7 +2239,7 @@ func testInsertKnownChainData(t *testing.T, typ string, scheme string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
inserter = func(blocks []*types.Block, receipts []types.Receipts) error {
|
inserter = func(blocks []*types.Block) error {
|
||||||
_, err := chain.InsertChain(blocks)
|
_, err := chain.InsertChain(blocks)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
@ -2250,13 +2250,13 @@ func testInsertKnownChainData(t *testing.T, typ string, scheme string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := inserter(blocks, receipts); err != nil {
|
if err := inserter(blocks); err != nil {
|
||||||
t.Fatalf("failed to insert chain data: %v", err)
|
t.Fatalf("failed to insert chain data: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reimport the chain data again. All the imported
|
// Reimport the chain data again. All the imported
|
||||||
// chain data are regarded "known" data.
|
// chain data are regarded "known" data.
|
||||||
if err := inserter(blocks, receipts); err != nil {
|
if err := inserter(blocks); err != nil {
|
||||||
t.Fatalf("failed to insert chain data: %v", err)
|
t.Fatalf("failed to insert chain data: %v", err)
|
||||||
}
|
}
|
||||||
asserter(t, blocks[len(blocks)-1])
|
asserter(t, blocks[len(blocks)-1])
|
||||||
|
|
@ -2265,19 +2265,19 @@ func testInsertKnownChainData(t *testing.T, typ string, scheme string) {
|
||||||
rollback := blocks[len(blocks)/2].NumberU64()
|
rollback := blocks[len(blocks)/2].NumberU64()
|
||||||
|
|
||||||
chain.SetHead(rollback - 1)
|
chain.SetHead(rollback - 1)
|
||||||
if err := inserter(append(blocks, blocks2...), append(receipts, receipts2...)); err != nil {
|
if err := inserter(append(blocks, blocks2...)); err != nil {
|
||||||
t.Fatalf("failed to insert chain data: %v", err)
|
t.Fatalf("failed to insert chain data: %v", err)
|
||||||
}
|
}
|
||||||
asserter(t, blocks2[len(blocks2)-1])
|
asserter(t, blocks2[len(blocks2)-1])
|
||||||
|
|
||||||
// Import a heavier shorter but higher total difficulty chain with some known data as prefix.
|
// Import a heavier shorter but higher total difficulty chain with some known data as prefix.
|
||||||
if err := inserter(append(blocks, blocks3...), append(receipts, receipts3...)); err != nil {
|
if err := inserter(append(blocks, blocks3...)); err != nil {
|
||||||
t.Fatalf("failed to insert chain data: %v", err)
|
t.Fatalf("failed to insert chain data: %v", err)
|
||||||
}
|
}
|
||||||
asserter(t, blocks3[len(blocks3)-1])
|
asserter(t, blocks3[len(blocks3)-1])
|
||||||
|
|
||||||
// Import a longer but lower total difficulty chain with some known data as prefix.
|
// Import a longer but lower total difficulty chain with some known data as prefix.
|
||||||
if err := inserter(append(blocks, blocks2...), append(receipts, receipts2...)); err != nil {
|
if err := inserter(append(blocks, blocks2...)); err != nil {
|
||||||
t.Fatalf("failed to insert chain data: %v", err)
|
t.Fatalf("failed to insert chain data: %v", err)
|
||||||
}
|
}
|
||||||
// The head shouldn't change.
|
// The head shouldn't change.
|
||||||
|
|
@ -2285,7 +2285,7 @@ func testInsertKnownChainData(t *testing.T, typ string, scheme string) {
|
||||||
|
|
||||||
// Rollback the heavier chain and re-insert the longer chain again
|
// Rollback the heavier chain and re-insert the longer chain again
|
||||||
chain.SetHead(rollback - 1)
|
chain.SetHead(rollback - 1)
|
||||||
if err := inserter(append(blocks, blocks2...), append(receipts, receipts2...)); err != nil {
|
if err := inserter(append(blocks, blocks2...)); err != nil {
|
||||||
t.Fatalf("failed to insert chain data: %v", err)
|
t.Fatalf("failed to insert chain data: %v", err)
|
||||||
}
|
}
|
||||||
asserter(t, blocks2[len(blocks2)-1])
|
asserter(t, blocks2[len(blocks2)-1])
|
||||||
|
|
@ -2347,13 +2347,13 @@ func testInsertKnownChainDataWithMerging(t *testing.T, typ string, mergeHeight i
|
||||||
mergeBlock = uint64(len(blocks))
|
mergeBlock = uint64(len(blocks))
|
||||||
}
|
}
|
||||||
// Longer chain and shorter chain
|
// Longer chain and shorter chain
|
||||||
blocks2, receipts2 := GenerateChain(genesis.Config, blocks[len(blocks)-1], engine, genDb, 65, func(i int, b *BlockGen) {
|
blocks2, _ := GenerateChain(genesis.Config, blocks[len(blocks)-1], engine, genDb, 65, func(i int, b *BlockGen) {
|
||||||
b.SetCoinbase(common.Address{1})
|
b.SetCoinbase(common.Address{1})
|
||||||
if b.header.Number.Uint64() >= mergeBlock {
|
if b.header.Number.Uint64() >= mergeBlock {
|
||||||
b.SetPoS()
|
b.SetPoS()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
blocks3, receipts3 := GenerateChain(genesis.Config, blocks[len(blocks)-1], engine, genDb, 64, func(i int, b *BlockGen) {
|
blocks3, _ := GenerateChain(genesis.Config, blocks[len(blocks)-1], engine, genDb, 64, func(i int, b *BlockGen) {
|
||||||
b.SetCoinbase(common.Address{1})
|
b.SetCoinbase(common.Address{1})
|
||||||
b.OffsetTime(-9) // Time shifted, difficulty shouldn't be changed
|
b.OffsetTime(-9) // Time shifted, difficulty shouldn't be changed
|
||||||
if b.header.Number.Uint64() >= mergeBlock {
|
if b.header.Number.Uint64() >= mergeBlock {
|
||||||
|
|
@ -2374,11 +2374,11 @@ func testInsertKnownChainDataWithMerging(t *testing.T, typ string, mergeHeight i
|
||||||
defer chain.Stop()
|
defer chain.Stop()
|
||||||
|
|
||||||
var (
|
var (
|
||||||
inserter func(blocks []*types.Block, receipts []types.Receipts) error
|
inserter func(blocks []*types.Block) error
|
||||||
asserter func(t *testing.T, block *types.Block)
|
asserter func(t *testing.T, block *types.Block)
|
||||||
)
|
)
|
||||||
if typ == "headers" {
|
if typ == "headers" {
|
||||||
inserter = func(blocks []*types.Block, receipts []types.Receipts) error {
|
inserter = func(blocks []*types.Block) error {
|
||||||
headers := make([]*types.Header, 0, len(blocks))
|
headers := make([]*types.Header, 0, len(blocks))
|
||||||
for _, block := range blocks {
|
for _, block := range blocks {
|
||||||
headers = append(headers, block.Header())
|
headers = append(headers, block.Header())
|
||||||
|
|
@ -2395,7 +2395,7 @@ func testInsertKnownChainDataWithMerging(t *testing.T, typ string, mergeHeight i
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if typ == "receipts" {
|
} else if typ == "receipts" {
|
||||||
inserter = func(blocks []*types.Block, receipts []types.Receipts) error {
|
inserter = func(blocks []*types.Block) error {
|
||||||
headers := make([]*types.Header, 0, len(blocks))
|
headers := make([]*types.Header, 0, len(blocks))
|
||||||
for _, block := range blocks {
|
for _, block := range blocks {
|
||||||
headers = append(headers, block.Header())
|
headers = append(headers, block.Header())
|
||||||
|
|
@ -2413,7 +2413,7 @@ func testInsertKnownChainDataWithMerging(t *testing.T, typ string, mergeHeight i
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
inserter = func(blocks []*types.Block, receipts []types.Receipts) error {
|
inserter = func(blocks []*types.Block) error {
|
||||||
i, err := chain.InsertChain(blocks)
|
i, err := chain.InsertChain(blocks)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("index %d: %w", i, err)
|
return fmt.Errorf("index %d: %w", i, err)
|
||||||
|
|
@ -2426,13 +2426,13 @@ func testInsertKnownChainDataWithMerging(t *testing.T, typ string, mergeHeight i
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if err := inserter(blocks, receipts); err != nil {
|
if err := inserter(blocks); err != nil {
|
||||||
t.Fatalf("failed to insert chain data: %v", err)
|
t.Fatalf("failed to insert chain data: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reimport the chain data again. All the imported
|
// Reimport the chain data again. All the imported
|
||||||
// chain data are regarded "known" data.
|
// chain data are regarded "known" data.
|
||||||
if err := inserter(blocks, receipts); err != nil {
|
if err := inserter(blocks); err != nil {
|
||||||
t.Fatalf("failed to insert chain data: %v", err)
|
t.Fatalf("failed to insert chain data: %v", err)
|
||||||
}
|
}
|
||||||
asserter(t, blocks[len(blocks)-1])
|
asserter(t, blocks[len(blocks)-1])
|
||||||
|
|
@ -2440,13 +2440,13 @@ func testInsertKnownChainDataWithMerging(t *testing.T, typ string, mergeHeight i
|
||||||
// Import a long canonical chain with some known data as prefix.
|
// Import a long canonical chain with some known data as prefix.
|
||||||
rollback := blocks[len(blocks)/2].NumberU64()
|
rollback := blocks[len(blocks)/2].NumberU64()
|
||||||
chain.SetHead(rollback - 1)
|
chain.SetHead(rollback - 1)
|
||||||
if err := inserter(blocks, receipts); err != nil {
|
if err := inserter(blocks); err != nil {
|
||||||
t.Fatalf("failed to insert chain data: %v", err)
|
t.Fatalf("failed to insert chain data: %v", err)
|
||||||
}
|
}
|
||||||
asserter(t, blocks[len(blocks)-1])
|
asserter(t, blocks[len(blocks)-1])
|
||||||
|
|
||||||
// Import a longer chain with some known data as prefix.
|
// Import a longer chain with some known data as prefix.
|
||||||
if err := inserter(append(blocks, blocks2...), append(receipts, receipts2...)); err != nil {
|
if err := inserter(append(blocks, blocks2...)); err != nil {
|
||||||
t.Fatalf("failed to insert chain data: %v", err)
|
t.Fatalf("failed to insert chain data: %v", err)
|
||||||
}
|
}
|
||||||
asserter(t, blocks2[len(blocks2)-1])
|
asserter(t, blocks2[len(blocks2)-1])
|
||||||
|
|
@ -2454,7 +2454,7 @@ func testInsertKnownChainDataWithMerging(t *testing.T, typ string, mergeHeight i
|
||||||
// Import a shorter chain with some known data as prefix.
|
// Import a shorter chain with some known data as prefix.
|
||||||
// The reorg is expected since the fork choice rule is
|
// The reorg is expected since the fork choice rule is
|
||||||
// already changed.
|
// already changed.
|
||||||
if err := inserter(append(blocks, blocks3...), append(receipts, receipts3...)); err != nil {
|
if err := inserter(append(blocks, blocks3...)); err != nil {
|
||||||
t.Fatalf("failed to insert chain data: %v", err)
|
t.Fatalf("failed to insert chain data: %v", err)
|
||||||
}
|
}
|
||||||
// The head shouldn't change.
|
// The head shouldn't change.
|
||||||
|
|
@ -2462,7 +2462,7 @@ func testInsertKnownChainDataWithMerging(t *testing.T, typ string, mergeHeight i
|
||||||
|
|
||||||
// Reimport the longer chain again, the reorg is still expected
|
// Reimport the longer chain again, the reorg is still expected
|
||||||
chain.SetHead(rollback - 1)
|
chain.SetHead(rollback - 1)
|
||||||
if err := inserter(append(blocks, blocks2...), append(receipts, receipts2...)); err != nil {
|
if err := inserter(append(blocks, blocks2...)); err != nil {
|
||||||
t.Fatalf("failed to insert chain data: %v", err)
|
t.Fatalf("failed to insert chain data: %v", err)
|
||||||
}
|
}
|
||||||
asserter(t, blocks2[len(blocks2)-1])
|
asserter(t, blocks2[len(blocks2)-1])
|
||||||
|
|
@ -2618,7 +2618,7 @@ func testReorgToShorterRemovesCanonMappingHeaderChain(t *testing.T, scheme strin
|
||||||
}
|
}
|
||||||
|
|
||||||
// Benchmarks large blocks with value transfers to non-existing accounts
|
// Benchmarks large blocks with value transfers to non-existing accounts
|
||||||
func benchmarkLargeNumberOfValueToNonexisting(b *testing.B, numTxs, numBlocks int, recipientFn func(uint64) common.Address, dataFn func(uint64) []byte) {
|
func benchmarkLargeNumberOfValueToNonexisting(b *testing.B, numTxs, numBlocks int, recipientFn func(uint64) common.Address) {
|
||||||
var (
|
var (
|
||||||
signer = types.HomesteadSigner{}
|
signer = types.HomesteadSigner{}
|
||||||
testBankKey, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
|
testBankKey, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
|
||||||
|
|
@ -2681,10 +2681,8 @@ func BenchmarkBlockChain_1x1000ValueTransferToNonexisting(b *testing.B) {
|
||||||
recipientFn := func(nonce uint64) common.Address {
|
recipientFn := func(nonce uint64) common.Address {
|
||||||
return common.BigToAddress(new(big.Int).SetUint64(1337 + nonce))
|
return common.BigToAddress(new(big.Int).SetUint64(1337 + nonce))
|
||||||
}
|
}
|
||||||
dataFn := func(nonce uint64) []byte {
|
|
||||||
return nil
|
benchmarkLargeNumberOfValueToNonexisting(b, numTxs, numBlocks, recipientFn)
|
||||||
}
|
|
||||||
benchmarkLargeNumberOfValueToNonexisting(b, numTxs, numBlocks, recipientFn, dataFn)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func BenchmarkBlockChain_1x1000ValueTransferToExisting(b *testing.B) {
|
func BenchmarkBlockChain_1x1000ValueTransferToExisting(b *testing.B) {
|
||||||
|
|
@ -2698,10 +2696,8 @@ func BenchmarkBlockChain_1x1000ValueTransferToExisting(b *testing.B) {
|
||||||
recipientFn := func(nonce uint64) common.Address {
|
recipientFn := func(nonce uint64) common.Address {
|
||||||
return common.BigToAddress(new(big.Int).SetUint64(1337))
|
return common.BigToAddress(new(big.Int).SetUint64(1337))
|
||||||
}
|
}
|
||||||
dataFn := func(nonce uint64) []byte {
|
|
||||||
return nil
|
benchmarkLargeNumberOfValueToNonexisting(b, numTxs, numBlocks, recipientFn)
|
||||||
}
|
|
||||||
benchmarkLargeNumberOfValueToNonexisting(b, numTxs, numBlocks, recipientFn, dataFn)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func BenchmarkBlockChain_1x1000Executions(b *testing.B) {
|
func BenchmarkBlockChain_1x1000Executions(b *testing.B) {
|
||||||
|
|
@ -2715,10 +2711,7 @@ func BenchmarkBlockChain_1x1000Executions(b *testing.B) {
|
||||||
recipientFn := func(nonce uint64) common.Address {
|
recipientFn := func(nonce uint64) common.Address {
|
||||||
return common.BigToAddress(new(big.Int).SetUint64(0xc0de))
|
return common.BigToAddress(new(big.Int).SetUint64(0xc0de))
|
||||||
}
|
}
|
||||||
dataFn := func(nonce uint64) []byte {
|
benchmarkLargeNumberOfValueToNonexisting(b, numTxs, numBlocks, recipientFn)
|
||||||
return nil
|
|
||||||
}
|
|
||||||
benchmarkLargeNumberOfValueToNonexisting(b, numTxs, numBlocks, recipientFn, dataFn)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tests that importing a some old blocks, where all blocks are before the
|
// Tests that importing a some old blocks, where all blocks are before the
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ func NewStateSync(root common.Hash, database ethdb.KeyValueReader, onLeaf func(k
|
||||||
// Register the storage slot callback if the external callback is specified.
|
// Register the storage slot callback if the external callback is specified.
|
||||||
var onSlot func(keys [][]byte, path []byte, leaf []byte, parent common.Hash, parentPath []byte) error
|
var onSlot func(keys [][]byte, path []byte, leaf []byte, parent common.Hash, parentPath []byte) error
|
||||||
if onLeaf != nil {
|
if onLeaf != nil {
|
||||||
onSlot = func(keys [][]byte, path []byte, leaf []byte, parent common.Hash, parentPath []byte) error {
|
onSlot = func(keys [][]byte, _ []byte, leaf []byte, _ common.Hash, _ []byte) error {
|
||||||
return onLeaf(keys, leaf)
|
return onLeaf(keys, leaf)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -68,7 +68,7 @@ func (p *statePrefetcher) Prefetch(block *types.Block, statedb *state.StateDB, c
|
||||||
return // Also invalid block, bail out
|
return // Also invalid block, bail out
|
||||||
}
|
}
|
||||||
statedb.SetTxContext(tx.Hash(), i)
|
statedb.SetTxContext(tx.Hash(), i)
|
||||||
if err := precacheTransaction(msg, p.config, gaspool, statedb, header, evm); err != nil {
|
if err := precacheTransaction(msg, gaspool, statedb, evm); err != nil {
|
||||||
return // Ugh, something went horribly wrong, bail out
|
return // Ugh, something went horribly wrong, bail out
|
||||||
}
|
}
|
||||||
// If we're pre-byzantium, pre-load trie nodes for the intermediate root
|
// If we're pre-byzantium, pre-load trie nodes for the intermediate root
|
||||||
|
|
@ -85,7 +85,7 @@ func (p *statePrefetcher) Prefetch(block *types.Block, statedb *state.StateDB, c
|
||||||
// precacheTransaction attempts to apply a transaction to the given state database
|
// precacheTransaction attempts to apply a transaction to the given state database
|
||||||
// and uses the input parameters for its environment. The goal is not to execute
|
// and uses the input parameters for its environment. The goal is not to execute
|
||||||
// the transaction successfully, rather to warm up touched data slots.
|
// the transaction successfully, rather to warm up touched data slots.
|
||||||
func precacheTransaction(msg *Message, config *params.ChainConfig, gaspool *GasPool, statedb *state.StateDB, header *types.Header, evm *vm.EVM) error {
|
func precacheTransaction(msg *Message, gaspool *GasPool, statedb *state.StateDB, evm *vm.EVM) error {
|
||||||
// Update the evm with the new transaction context.
|
// Update the evm with the new transaction context.
|
||||||
evm.Reset(NewEVMTxContext(msg), statedb)
|
evm.Reset(NewEVMTxContext(msg), statedb)
|
||||||
// Add addresses to access list if applicable
|
// Add addresses to access list if applicable
|
||||||
|
|
|
||||||
|
|
@ -624,7 +624,7 @@ func (pool *LegacyPool) validateTxBasics(tx *types.Transaction, local bool) erro
|
||||||
|
|
||||||
// validateTx checks whether a transaction is valid according to the consensus
|
// validateTx checks whether a transaction is valid according to the consensus
|
||||||
// rules and adheres to some heuristic limits of the local node (price and size).
|
// rules and adheres to some heuristic limits of the local node (price and size).
|
||||||
func (pool *LegacyPool) validateTx(tx *types.Transaction, local bool) error {
|
func (pool *LegacyPool) validateTx(tx *types.Transaction) error {
|
||||||
opts := &txpool.ValidationOptionsWithState{
|
opts := &txpool.ValidationOptionsWithState{
|
||||||
State: pool.currentState,
|
State: pool.currentState,
|
||||||
|
|
||||||
|
|
@ -680,7 +680,7 @@ func (pool *LegacyPool) add(tx *types.Transaction, local bool) (replaced bool, e
|
||||||
isLocal := local || pool.locals.containsTx(tx)
|
isLocal := local || pool.locals.containsTx(tx)
|
||||||
|
|
||||||
// If the transaction fails basic validation, discard it
|
// If the transaction fails basic validation, discard it
|
||||||
if err := pool.validateTx(tx, isLocal); err != nil {
|
if err := pool.validateTx(tx); err != nil {
|
||||||
log.Trace("Discarding invalid transaction", "hash", hash, "err", err)
|
log.Trace("Discarding invalid transaction", "hash", hash, "err", err)
|
||||||
invalidTxMeter.Mark(1)
|
invalidTxMeter.Mark(1)
|
||||||
return false, err
|
return false, err
|
||||||
|
|
|
||||||
|
|
@ -273,7 +273,7 @@ func (t *jsTracer) OnTxEnd(receipt *types.Receipt, err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// onStart implements the Tracer interface to initialize the tracing operation.
|
// onStart implements the Tracer interface to initialize the tracing operation.
|
||||||
func (t *jsTracer) onStart(from common.Address, to common.Address, create bool, input []byte, gas uint64, value *big.Int) {
|
func (t *jsTracer) onStart(from common.Address, to common.Address, create bool, input []byte, value *big.Int) {
|
||||||
if t.err != nil {
|
if t.err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
@ -346,7 +346,7 @@ func (t *jsTracer) OnFault(pc uint64, op byte, gas, cost uint64, scope tracing.O
|
||||||
}
|
}
|
||||||
|
|
||||||
// onEnd is called after the call finishes to finalize the tracing.
|
// onEnd is called after the call finishes to finalize the tracing.
|
||||||
func (t *jsTracer) onEnd(output []byte, gasUsed uint64, err error, reverted bool) {
|
func (t *jsTracer) onEnd(output []byte, err error) {
|
||||||
if t.err != nil {
|
if t.err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
@ -367,7 +367,7 @@ func (t *jsTracer) OnEnter(depth int, typ byte, from common.Address, to common.A
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if depth == 0 {
|
if depth == 0 {
|
||||||
t.onStart(from, to, vm.OpCode(typ) == vm.CREATE, input, gas, value)
|
t.onStart(from, to, vm.OpCode(typ) == vm.CREATE, input, value)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if !t.traceFrame {
|
if !t.traceFrame {
|
||||||
|
|
@ -396,7 +396,7 @@ func (t *jsTracer) OnExit(depth int, output []byte, gasUsed uint64, err error, r
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if depth == 0 {
|
if depth == 0 {
|
||||||
t.onEnd(output, gasUsed, err, reverted)
|
t.onEnd(output, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if !t.traceFrame {
|
if !t.traceFrame {
|
||||||
|
|
|
||||||
|
|
@ -126,7 +126,7 @@ type callTracerConfig struct {
|
||||||
// newCallTracer returns a native go tracer which tracks
|
// newCallTracer returns a native go tracer which tracks
|
||||||
// call frames of a tx, and implements vm.EVMLogger.
|
// call frames of a tx, and implements vm.EVMLogger.
|
||||||
func newCallTracer(ctx *tracers.Context, cfg json.RawMessage) (*tracers.Tracer, error) {
|
func newCallTracer(ctx *tracers.Context, cfg json.RawMessage) (*tracers.Tracer, error) {
|
||||||
t, err := newCallTracerObject(ctx, cfg)
|
t, err := newCallTracerObject(cfg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
@ -143,7 +143,7 @@ func newCallTracer(ctx *tracers.Context, cfg json.RawMessage) (*tracers.Tracer,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func newCallTracerObject(ctx *tracers.Context, cfg json.RawMessage) (*callTracer, error) {
|
func newCallTracerObject(cfg json.RawMessage) (*callTracer, error) {
|
||||||
var config callTracerConfig
|
var config callTracerConfig
|
||||||
if cfg != nil {
|
if cfg != nil {
|
||||||
if err := json.Unmarshal(cfg, &config); err != nil {
|
if err := json.Unmarshal(cfg, &config); err != nil {
|
||||||
|
|
@ -185,7 +185,7 @@ func (t *callTracer) OnEnter(depth int, typ byte, from common.Address, to common
|
||||||
// execute any code.
|
// execute any code.
|
||||||
func (t *callTracer) OnExit(depth int, output []byte, gasUsed uint64, err error, reverted bool) {
|
func (t *callTracer) OnExit(depth int, output []byte, gasUsed uint64, err error, reverted bool) {
|
||||||
if depth == 0 {
|
if depth == 0 {
|
||||||
t.captureEnd(output, gasUsed, err, reverted)
|
t.captureEnd(output, err, reverted)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -209,7 +209,7 @@ func (t *callTracer) OnExit(depth int, output []byte, gasUsed uint64, err error,
|
||||||
t.callstack[size-1].Calls = append(t.callstack[size-1].Calls, call)
|
t.callstack[size-1].Calls = append(t.callstack[size-1].Calls, call)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *callTracer) captureEnd(output []byte, gasUsed uint64, err error, reverted bool) {
|
func (t *callTracer) captureEnd(output []byte, err error, reverted bool) {
|
||||||
if len(t.callstack) != 1 {
|
if len(t.callstack) != 1 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -135,7 +135,7 @@ func newFlatCallTracer(ctx *tracers.Context, cfg json.RawMessage) (*tracers.Trac
|
||||||
|
|
||||||
// Create inner call tracer with default configuration, don't forward
|
// Create inner call tracer with default configuration, don't forward
|
||||||
// the OnlyTopCall or WithLog to inner for now
|
// the OnlyTopCall or WithLog to inner for now
|
||||||
t, err := newCallTracerObject(ctx, nil)
|
t, err := newCallTracerObject(nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1284,7 +1284,7 @@ func RPCMarshalBlock(block *types.Block, inclTx bool, fullTx bool, config *param
|
||||||
return tx.Hash()
|
return tx.Hash()
|
||||||
}
|
}
|
||||||
if fullTx {
|
if fullTx {
|
||||||
formatTx = func(idx int, tx *types.Transaction) interface{} {
|
formatTx = func(idx int, _ *types.Transaction) interface{} {
|
||||||
return newRPCTransactionFromBlockIndex(block, uint64(idx), config)
|
return newRPCTransactionFromBlockIndex(block, uint64(idx), config)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -97,7 +97,7 @@ func (args *TransactionArgs) data() []byte {
|
||||||
|
|
||||||
// setDefaults fills in default values for unspecified tx fields.
|
// setDefaults fills in default values for unspecified tx fields.
|
||||||
func (args *TransactionArgs) setDefaults(ctx context.Context, b Backend, skipGasEstimation bool) error {
|
func (args *TransactionArgs) setDefaults(ctx context.Context, b Backend, skipGasEstimation bool) error {
|
||||||
if err := args.setBlobTxSidecar(ctx); err != nil {
|
if err := args.setBlobTxSidecar(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := args.setFeeDefaults(ctx, b); err != nil {
|
if err := args.setFeeDefaults(ctx, b); err != nil {
|
||||||
|
|
@ -189,7 +189,7 @@ func (args *TransactionArgs) setFeeDefaults(ctx context.Context, b Backend) erro
|
||||||
if args.BlobFeeCap != nil && args.BlobFeeCap.ToInt().Sign() == 0 {
|
if args.BlobFeeCap != nil && args.BlobFeeCap.ToInt().Sign() == 0 {
|
||||||
return errors.New("maxFeePerBlobGas, if specified, must be non-zero")
|
return errors.New("maxFeePerBlobGas, if specified, must be non-zero")
|
||||||
}
|
}
|
||||||
if err := args.setCancunFeeDefaults(ctx, head, b); err != nil {
|
if err := args.setCancunFeeDefaults(head); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
// If both gasPrice and at least one of the EIP-1559 fee parameters are specified, error.
|
// If both gasPrice and at least one of the EIP-1559 fee parameters are specified, error.
|
||||||
|
|
@ -243,7 +243,7 @@ func (args *TransactionArgs) setFeeDefaults(ctx context.Context, b Backend) erro
|
||||||
}
|
}
|
||||||
|
|
||||||
// setCancunFeeDefaults fills in reasonable default fee values for unspecified fields.
|
// setCancunFeeDefaults fills in reasonable default fee values for unspecified fields.
|
||||||
func (args *TransactionArgs) setCancunFeeDefaults(ctx context.Context, head *types.Header, b Backend) error {
|
func (args *TransactionArgs) setCancunFeeDefaults(head *types.Header) error {
|
||||||
// Set maxFeePerBlobGas if it is missing.
|
// Set maxFeePerBlobGas if it is missing.
|
||||||
if args.BlobHashes != nil && args.BlobFeeCap == nil {
|
if args.BlobHashes != nil && args.BlobFeeCap == nil {
|
||||||
var excessBlobGas uint64
|
var excessBlobGas uint64
|
||||||
|
|
@ -290,7 +290,7 @@ func (args *TransactionArgs) setLondonFeeDefaults(ctx context.Context, head *typ
|
||||||
}
|
}
|
||||||
|
|
||||||
// setBlobTxSidecar adds the blob tx
|
// setBlobTxSidecar adds the blob tx
|
||||||
func (args *TransactionArgs) setBlobTxSidecar(ctx context.Context) error {
|
func (args *TransactionArgs) setBlobTxSidecar() error {
|
||||||
// No blobs, we're done.
|
// No blobs, we're done.
|
||||||
if args.Blobs == nil {
|
if args.Blobs == nil {
|
||||||
return nil
|
return nil
|
||||||
|
|
|
||||||
|
|
@ -289,7 +289,7 @@ func (re *JSRE) Evaluate(code string, w io.Writer) {
|
||||||
re.Do(func(vm *goja.Runtime) {
|
re.Do(func(vm *goja.Runtime) {
|
||||||
val, err := vm.RunString(code)
|
val, err := vm.RunString(code)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
prettyError(vm, err, w)
|
prettyError(err, w)
|
||||||
} else {
|
} else {
|
||||||
prettyPrint(vm, val, w)
|
prettyPrint(vm, val, w)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@ func prettyPrint(vm *goja.Runtime, value goja.Value, w io.Writer) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// prettyError writes err to standard output.
|
// prettyError writes err to standard output.
|
||||||
func prettyError(vm *goja.Runtime, err error, w io.Writer) {
|
func prettyError(err error, w io.Writer) {
|
||||||
failure := err.Error()
|
failure := err.Error()
|
||||||
if gojaErr, ok := err.(*goja.Exception); ok {
|
if gojaErr, ok := err.(*goja.Exception); ok {
|
||||||
failure = gojaErr.String()
|
failure = gojaErr.String()
|
||||||
|
|
|
||||||
|
|
@ -79,7 +79,7 @@ func (h *TerminalHandler) format(buf []byte, r slog.Record, usecolor bool) []byt
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *TerminalHandler) formatAttributes(buf *bytes.Buffer, r slog.Record, color string) {
|
func (h *TerminalHandler) formatAttributes(buf *bytes.Buffer, r slog.Record, color string) {
|
||||||
writeAttr := func(attr slog.Attr, first, last bool) {
|
writeAttr := func(attr slog.Attr, last bool) {
|
||||||
buf.WriteByte(' ')
|
buf.WriteByte(' ')
|
||||||
|
|
||||||
if color != "" {
|
if color != "" {
|
||||||
|
|
@ -107,11 +107,11 @@ func (h *TerminalHandler) formatAttributes(buf *bytes.Buffer, r slog.Record, col
|
||||||
var n = 0
|
var n = 0
|
||||||
var nAttrs = len(h.attrs) + r.NumAttrs()
|
var nAttrs = len(h.attrs) + r.NumAttrs()
|
||||||
for _, attr := range h.attrs {
|
for _, attr := range h.attrs {
|
||||||
writeAttr(attr, n == 0, n == nAttrs-1)
|
writeAttr(attr, n == nAttrs-1)
|
||||||
n++
|
n++
|
||||||
}
|
}
|
||||||
r.Attrs(func(attr slog.Attr) bool {
|
r.Attrs(func(attr slog.Attr) bool {
|
||||||
writeAttr(attr, n == 0, n == nAttrs-1)
|
writeAttr(attr, n == nAttrs-1)
|
||||||
n++
|
n++
|
||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -753,7 +753,7 @@ func (t *UDPv5) handle(p v5wire.Packet, fromID enode.ID, fromAddr netip.AddrPort
|
||||||
case *v5wire.Unknown:
|
case *v5wire.Unknown:
|
||||||
t.handleUnknown(p, fromID, fromAddr)
|
t.handleUnknown(p, fromID, fromAddr)
|
||||||
case *v5wire.Whoareyou:
|
case *v5wire.Whoareyou:
|
||||||
t.handleWhoareyou(p, fromID, fromAddr)
|
t.handleWhoareyou(p, fromAddr)
|
||||||
case *v5wire.Ping:
|
case *v5wire.Ping:
|
||||||
t.handlePing(p, fromID, fromAddr)
|
t.handlePing(p, fromID, fromAddr)
|
||||||
case *v5wire.Pong:
|
case *v5wire.Pong:
|
||||||
|
|
@ -789,8 +789,8 @@ var (
|
||||||
)
|
)
|
||||||
|
|
||||||
// handleWhoareyou resends the active call as a handshake packet.
|
// handleWhoareyou resends the active call as a handshake packet.
|
||||||
func (t *UDPv5) handleWhoareyou(p *v5wire.Whoareyou, fromID enode.ID, fromAddr netip.AddrPort) {
|
func (t *UDPv5) handleWhoareyou(p *v5wire.Whoareyou, fromAddr netip.AddrPort) {
|
||||||
c, err := t.matchWithCall(fromID, p.Nonce)
|
c, err := t.matchWithCall(p.Nonce)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.log.Debug("Invalid "+p.Name(), "addr", fromAddr, "err", err)
|
t.log.Debug("Invalid "+p.Name(), "addr", fromAddr, "err", err)
|
||||||
return
|
return
|
||||||
|
|
@ -811,7 +811,7 @@ func (t *UDPv5) handleWhoareyou(p *v5wire.Whoareyou, fromID enode.ID, fromAddr n
|
||||||
}
|
}
|
||||||
|
|
||||||
// matchWithCall checks whether a handshake attempt matches the active call.
|
// matchWithCall checks whether a handshake attempt matches the active call.
|
||||||
func (t *UDPv5) matchWithCall(fromID enode.ID, nonce v5wire.Nonce) (*callV5, error) {
|
func (t *UDPv5) matchWithCall(nonce v5wire.Nonce) (*callV5, error) {
|
||||||
c := t.activeCallByAuth[nonce]
|
c := t.activeCallByAuth[nonce]
|
||||||
if c == nil {
|
if c == nil {
|
||||||
return nil, errChallengeNoCall
|
return nil, errChallengeNoCall
|
||||||
|
|
|
||||||
|
|
@ -189,7 +189,7 @@ func (c *Codec) Encode(id enode.ID, addr string, packet Packet, challenge *Whoar
|
||||||
)
|
)
|
||||||
switch {
|
switch {
|
||||||
case packet.Kind() == WhoareyouPacket:
|
case packet.Kind() == WhoareyouPacket:
|
||||||
head, err = c.encodeWhoareyou(id, packet.(*Whoareyou))
|
head, err = c.encodeWhoareyou(packet.(*Whoareyou))
|
||||||
case challenge != nil:
|
case challenge != nil:
|
||||||
// We have an unanswered challenge, send handshake.
|
// We have an unanswered challenge, send handshake.
|
||||||
head, session, err = c.encodeHandshakeHeader(id, addr, challenge)
|
head, session, err = c.encodeHandshakeHeader(id, addr, challenge)
|
||||||
|
|
@ -197,10 +197,10 @@ func (c *Codec) Encode(id enode.ID, addr string, packet Packet, challenge *Whoar
|
||||||
session = c.sc.session(id, addr)
|
session = c.sc.session(id, addr)
|
||||||
if session != nil {
|
if session != nil {
|
||||||
// There is a session, use it.
|
// There is a session, use it.
|
||||||
head, err = c.encodeMessageHeader(id, session)
|
head, err = c.encodeMessageHeader(session)
|
||||||
} else {
|
} else {
|
||||||
// No keys, send random data to kick off the handshake.
|
// No keys, send random data to kick off the handshake.
|
||||||
head, msgData, err = c.encodeRandom(id)
|
head, msgData, err = c.encodeRandom()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -253,7 +253,7 @@ func (c *Codec) writeHeaders(head *Header) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// makeHeader creates a packet header.
|
// makeHeader creates a packet header.
|
||||||
func (c *Codec) makeHeader(toID enode.ID, flag byte, authsizeExtra int) Header {
|
func (c *Codec) makeHeader(flag byte, authsizeExtra int) Header {
|
||||||
var authsize int
|
var authsize int
|
||||||
switch flag {
|
switch flag {
|
||||||
case flagMessage:
|
case flagMessage:
|
||||||
|
|
@ -280,8 +280,8 @@ func (c *Codec) makeHeader(toID enode.ID, flag byte, authsizeExtra int) Header {
|
||||||
}
|
}
|
||||||
|
|
||||||
// encodeRandom encodes a packet with random content.
|
// encodeRandom encodes a packet with random content.
|
||||||
func (c *Codec) encodeRandom(toID enode.ID) (Header, []byte, error) {
|
func (c *Codec) encodeRandom() (Header, []byte, error) {
|
||||||
head := c.makeHeader(toID, flagMessage, 0)
|
head := c.makeHeader(flagMessage, 0)
|
||||||
|
|
||||||
// Encode auth data.
|
// Encode auth data.
|
||||||
auth := messageAuthData{SrcID: c.localnode.ID()}
|
auth := messageAuthData{SrcID: c.localnode.ID()}
|
||||||
|
|
@ -299,14 +299,14 @@ func (c *Codec) encodeRandom(toID enode.ID) (Header, []byte, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// encodeWhoareyou encodes a WHOAREYOU packet.
|
// encodeWhoareyou encodes a WHOAREYOU packet.
|
||||||
func (c *Codec) encodeWhoareyou(toID enode.ID, packet *Whoareyou) (Header, error) {
|
func (c *Codec) encodeWhoareyou(packet *Whoareyou) (Header, error) {
|
||||||
// Sanity check node field to catch misbehaving callers.
|
// Sanity check node field to catch misbehaving callers.
|
||||||
if packet.RecordSeq > 0 && packet.Node == nil {
|
if packet.RecordSeq > 0 && packet.Node == nil {
|
||||||
panic("BUG: missing node in whoareyou with non-zero seq")
|
panic("BUG: missing node in whoareyou with non-zero seq")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create header.
|
// Create header.
|
||||||
head := c.makeHeader(toID, flagWhoareyou, 0)
|
head := c.makeHeader(flagWhoareyou, 0)
|
||||||
head.AuthData = bytesCopy(&c.buf)
|
head.AuthData = bytesCopy(&c.buf)
|
||||||
head.Nonce = packet.Nonce
|
head.Nonce = packet.Nonce
|
||||||
|
|
||||||
|
|
@ -329,7 +329,7 @@ func (c *Codec) encodeHandshakeHeader(toID enode.ID, addr string, challenge *Who
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate new secrets.
|
// Generate new secrets.
|
||||||
auth, session, err := c.makeHandshakeAuth(toID, addr, challenge)
|
auth, session, err := c.makeHandshakeAuth(toID, challenge)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return Header{}, nil, err
|
return Header{}, nil, err
|
||||||
}
|
}
|
||||||
|
|
@ -346,7 +346,7 @@ func (c *Codec) encodeHandshakeHeader(toID enode.ID, addr string, challenge *Who
|
||||||
// Encode the auth header.
|
// Encode the auth header.
|
||||||
var (
|
var (
|
||||||
authsizeExtra = len(auth.pubkey) + len(auth.signature) + len(auth.record)
|
authsizeExtra = len(auth.pubkey) + len(auth.signature) + len(auth.record)
|
||||||
head = c.makeHeader(toID, flagHandshake, authsizeExtra)
|
head = c.makeHeader(flagHandshake, authsizeExtra)
|
||||||
)
|
)
|
||||||
c.headbuf.Reset()
|
c.headbuf.Reset()
|
||||||
binary.Write(&c.headbuf, binary.BigEndian, &auth.h)
|
binary.Write(&c.headbuf, binary.BigEndian, &auth.h)
|
||||||
|
|
@ -359,7 +359,7 @@ func (c *Codec) encodeHandshakeHeader(toID enode.ID, addr string, challenge *Who
|
||||||
}
|
}
|
||||||
|
|
||||||
// makeHandshakeAuth creates the auth header on a request packet following WHOAREYOU.
|
// makeHandshakeAuth creates the auth header on a request packet following WHOAREYOU.
|
||||||
func (c *Codec) makeHandshakeAuth(toID enode.ID, addr string, challenge *Whoareyou) (*handshakeAuthData, *session, error) {
|
func (c *Codec) makeHandshakeAuth(toID enode.ID, challenge *Whoareyou) (*handshakeAuthData, *session, error) {
|
||||||
auth := new(handshakeAuthData)
|
auth := new(handshakeAuthData)
|
||||||
auth.h.SrcID = c.localnode.ID()
|
auth.h.SrcID = c.localnode.ID()
|
||||||
|
|
||||||
|
|
@ -401,8 +401,8 @@ func (c *Codec) makeHandshakeAuth(toID enode.ID, addr string, challenge *Whoarey
|
||||||
}
|
}
|
||||||
|
|
||||||
// encodeMessageHeader encodes an encrypted message packet.
|
// encodeMessageHeader encodes an encrypted message packet.
|
||||||
func (c *Codec) encodeMessageHeader(toID enode.ID, s *session) (Header, error) {
|
func (c *Codec) encodeMessageHeader(s *session) (Header, error) {
|
||||||
head := c.makeHeader(toID, flagMessage, 0)
|
head := c.makeHeader(flagMessage, 0)
|
||||||
|
|
||||||
// Create the header.
|
// Create the header.
|
||||||
nonce, err := c.sc.nextNonce(s)
|
nonce, err := c.sc.nextNonce(s)
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@ func GetMockerList() []string {
|
||||||
}
|
}
|
||||||
|
|
||||||
// The boot mockerFn only connects the node in a ring and doesn't do anything else
|
// The boot mockerFn only connects the node in a ring and doesn't do anything else
|
||||||
func boot(net *Network, quit chan struct{}, nodeCount int) {
|
func boot(net *Network, _ chan struct{}, nodeCount int) {
|
||||||
_, err := connectNodesInRing(net, nodeCount)
|
_, err := connectNodesInRing(net, nodeCount)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic("Could not startup node network for mocker")
|
panic("Could not startup node network for mocker")
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue