From 1ad1a36f6537a6b28716c30b3a0920bd5e3266f9 Mon Sep 17 00:00:00 2001 From: David Date: Fri, 17 Feb 2023 15:11:30 +0800 Subject: [PATCH 1/2] fix(proposer): fix a proposer nonce order issue --- pkg/rpc/methods.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/pkg/rpc/methods.go b/pkg/rpc/methods.go index b8d9526e5..40b6c31b5 100644 --- a/pkg/rpc/methods.go +++ b/pkg/rpc/methods.go @@ -4,6 +4,7 @@ import ( "context" "fmt" "math/big" + "sort" "time" ethereum "github.com/ethereum/go-ethereum" @@ -183,13 +184,26 @@ func (pc PoolContent) ToTxsByPriceAndNonce( remotes *types.TransactionsByPriceAndNonce, ) { var ( + allTxs = map[common.Address]types.Transactions{} localTxs = map[common.Address]types.Transactions{} remoteTxs = map[common.Address]types.Transactions{} ) for address, txsWithNonce := range pc { - out: + idx := 0 for _, tx := range txsWithNonce { + allTxs[address] = append(allTxs[address], tx) + idx += 1 + + if idx == len(txsWithNonce) { + sort.Sort(types.TxByNonce(allTxs[address])) + } + } + } + +out: + for address, txs := range allTxs { + for _, tx := range txs { for _, localAddress := range localAddresses { if address == localAddress { localTxs[address] = append(localTxs[address], tx) From 24f770d3ecdb18890f14604f5957797187ab81b5 Mon Sep 17 00:00:00 2001 From: David Date: Fri, 17 Feb 2023 15:42:36 +0800 Subject: [PATCH 2/2] fix: fix test error --- pkg/rpc/methods.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/rpc/methods.go b/pkg/rpc/methods.go index 40b6c31b5..299006737 100644 --- a/pkg/rpc/methods.go +++ b/pkg/rpc/methods.go @@ -201,8 +201,8 @@ func (pc PoolContent) ToTxsByPriceAndNonce( } } -out: for address, txs := range allTxs { + out: for _, tx := range txs { for _, localAddress := range localAddresses { if address == localAddress {