Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upgrade tx pool #533

Merged
merged 18 commits into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
19fb610
fix: rename func AddRemoteSync to addRemoteSync
gzliudan May 11, 2024
656f2a6
core: smaller txpool status locking (#20080)
holiman Sep 17, 2019
bef2c34
core: dedup known transactions without global lock, track metrics (#2…
gzliudan May 11, 2024
d141583
core: fix tx dedup return error count (#20085)
karalabe Sep 18, 2019
b7f4362
core: count tx size in slots, bump max size ot 4x32KB (#20352)
gzliudan May 11, 2024
d972bbd
core: set max tx size down to 2 slots (64KB)
holiman Jan 14, 2020
7179efd
core: announce based transaction propagation (#20234)
gzliudan May 11, 2024
6243714
core: fix typos in comments (#21118)
gzliudan May 11, 2024
cf41742
core: collect NewTxsEvent items without holding reorg lock (#21145)
cheng762 Jun 2, 2020
1776bf1
core: filter out txs with invalid signatures as soon as possible (#21…
duanhao0814 Jun 3, 2020
48f9bbe
core: types: less allocations when hashing and tx handling (#21265)
gzliudan May 13, 2024
ff24635
core: transaction pool optimizations (#21328)
holiman Jul 14, 2020
b9f373f
core: fix queued transaction eviction #21300
gzliudan May 13, 2024
28baf9f
core: avoid modification of accountSet cache in tx_pool (#21159)
duanhao0814 Aug 4, 2020
6935687
core: more detailed metering for reorgs (#21420)
MariusVanDerWijden Aug 20, 2020
a6d591b
core: fix txpool off-by-one error (#21683)
holiman Oct 9, 2020
289304f
core/txpool: remove "local" notion from the txpool price heap (#21478)
rjl493456442 Dec 11, 2020
76b29b2
core: reset txpool state on sethead (#22247)
MariusVanDerWijden Feb 3, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions accounts/accounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@
package accounts

import (
"fmt"
"math/big"

ethereum "github.com/XinFinOrg/XDPoSChain"
"github.com/XinFinOrg/XDPoSChain/common"
"github.com/XinFinOrg/XDPoSChain/core/types"
"github.com/XinFinOrg/XDPoSChain/event"
"golang.org/x/crypto/sha3"
)

// Account represents an Ethereum account located at a specific location defined
Expand Down Expand Up @@ -148,6 +150,34 @@ type Backend interface {
Subscribe(sink chan<- WalletEvent) event.Subscription
}

// TextHash is a helper function that calculates a hash for the given message that can be
// safely used to calculate a signature from.
//
// The hash is calulcated as
//
// keccak256("\x19Ethereum Signed Message:\n"${message length}${message}).
//
// This gives context to the signed message and prevents signing of transactions.
func TextHash(data []byte) []byte {
hash, _ := TextAndHash(data)
return hash
}

// TextAndHash is a helper function that calculates a hash for the given message that can be
// safely used to calculate a signature from.
//
// The hash is calulcated as
//
// keccak256("\x19Ethereum Signed Message:\n"${message length}${message}).
//
// This gives context to the signed message and prevents signing of transactions.
func TextAndHash(data []byte) ([]byte, string) {
msg := fmt.Sprintf("\x19Ethereum Signed Message:\n%d%s", len(data), string(data))
hasher := sha3.NewLegacyKeccak256()
hasher.Write([]byte(msg))
return hasher.Sum(nil), msg
}

// WalletEventType represents the different event types that can be fired by
// the wallet subscription subsystem.
type WalletEventType int
Expand Down
9 changes: 4 additions & 5 deletions cmd/wnode/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ func processArgs() {
}

if *asymmetricMode && len(*argPub) > 0 {
pub = crypto.ToECDSAPub(common.FromHex(*argPub))
if !isKeyValid(pub) {
var err error
if pub, err = crypto.UnmarshalPubkey(common.FromHex(*argPub)); err != nil {
utils.Fatalf("invalid public key")
}
}
Expand Down Expand Up @@ -337,9 +337,8 @@ func configureNode() {
if b == nil {
utils.Fatalf("Error: can not convert hexadecimal string")
}
pub = crypto.ToECDSAPub(b)
if !isKeyValid(pub) {
utils.Fatalf("Error: invalid public key")
if pub, err = crypto.UnmarshalPubkey(b); err != nil {
utils.Fatalf("Error: invalid peer public key")
}
}
}
Expand Down
8 changes: 8 additions & 0 deletions core/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ var (
blockInsertTimer = metrics.NewRegisteredTimer("chain/inserts", nil)
CheckpointCh = make(chan int)
ErrNoGenesis = errors.New("Genesis not found in chain")

blockReorgMeter = metrics.NewRegisteredMeter("chain/reorg/executes", nil)
blockReorgAddMeter = metrics.NewRegisteredMeter("chain/reorg/add", nil)
blockReorgDropMeter = metrics.NewRegisteredMeter("chain/reorg/drop", nil)
blockReorgInvalidatedTx = metrics.NewRegisteredMeter("chain/reorg/invalidTx", nil)
)

const (
Expand Down Expand Up @@ -2245,6 +2250,9 @@ func (bc *BlockChain) reorg(oldBlock, newBlock *types.Block) error {
}
logFn("Chain split detected", "number", commonBlock.Number(), "hash", commonBlock.Hash(),
"drop", len(oldChain), "dropfrom", oldChain[0].Hash(), "add", len(newChain), "addfrom", newChain[0].Hash())
blockReorgAddMeter.Mark(int64(len(newChain)))
blockReorgDropMeter.Mark(int64(len(oldChain)))
blockReorgMeter.Mark(1)
} else {
log.Error("Impossible reorg, please file an issue", "oldnum", oldBlock.Number(), "oldhash", oldBlock.Hash(), "newnum", newBlock.Number(), "newhash", newBlock.Hash())
}
Expand Down
2 changes: 1 addition & 1 deletion core/blockchain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1167,7 +1167,7 @@ func TestEIP161AccountRemoval(t *testing.T) {
t.Error("account should not exist")
}

// account musn't be created post eip 161
// account mustn't be created post eip 161
if _, err := blockchain.InsertChain(types.Blocks{blocks[2]}); err != nil {
t.Fatal(err)
}
Expand Down
Loading