-
Notifications
You must be signed in to change notification settings - Fork 1
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
Don't be notified about account nonces, don't store them; get them at selection-time #57
Merged
Merged
Changes from 35 commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
2231c3d
Don't notify about account nonces, don't forget etc.
andreibancioiu b22177e
When selecting transactions, receive an account nonce provider.
andreibancioiu 3714684
Refactor, pass "AccountNonceProvider" in constructor.
andreibancioiu 74e7ac5
Quick sketch of selection changes.
andreibancioiu d583eae
Fix tests and comments.
andreibancioiu 94131c7
Refactoring.
andreibancioiu 4ca46fd
Refactor, optimize.
andreibancioiu 20d4ba4
Fix after self-review.
andreibancioiu ee6476d
Update readme.
andreibancioiu 4f94f63
Merge branch 'selection-by-ppu' into MX-16107-no-more-notify
andreibancioiu 0f01e5c
Additional tests.
andreibancioiu 80b4979
Fix after review.
andreibancioiu f97351c
Receive the nonce provider in SelectTransactions, instead of receivin…
andreibancioiu 0db9d39
Break the selection loop if it takes too long.
andreibancioiu 3bbf408
AccountNonceProvider becomes AccountStateProvider (more information f…
andreibancioiu bae6b43
Additional logs on cross tx cache.
andreibancioiu 613f5ba
Hold fee on tx, handle accumulated fees. Avoid non-executable transac…
andreibancioiu 95a888a
Reference new core-go.
andreibancioiu ebe0e12
Handle guarded transactions with same nonce.
andreibancioiu c61ce2a
Better readme etc.
andreibancioiu 26f0189
Fix tests.
andreibancioiu 03c5adb
Better handling of not-executable transactions.
andreibancioiu 679a465
A few optimizations.
andreibancioiu de2620b
Fix fee exceeded balance detection. Refactoring.
andreibancioiu fe1bd09
Additional unit tests.
andreibancioiu 67c1c6e
Adjust benchmark output.
andreibancioiu e20d2e5
Fix tests.
andreibancioiu b2fa1ce
Additional unit tests.
andreibancioiu 48853fb
Fix after self review.
andreibancioiu f159f60
Fix after self review.
andreibancioiu d5ef41b
Remove out-of-reality test.
andreibancioiu 457c06c
Update readme.
andreibancioiu 1b8274d
Merge branch 'feat/mempool' into MX-16107-no-more-notify
andreibancioiu 92d0476
Fix linter issues.
andreibancioiu 93c958a
Fix after review (part 1).
andreibancioiu 8a0cb50
Fix after review (part 2).
andreibancioiu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
package txcachemocks | ||
|
||
import ( | ||
"math/big" | ||
"sync" | ||
|
||
"github.com/multiversx/mx-chain-storage-go/types" | ||
) | ||
|
||
// AccountStateProviderMock - | ||
type AccountStateProviderMock struct { | ||
mutex sync.Mutex | ||
|
||
AccountStateByAddress map[string]*types.AccountState | ||
GetAccountStateCalled func(address []byte) (*types.AccountState, error) | ||
} | ||
|
||
// NewAccountStateProviderMock - | ||
func NewAccountStateProviderMock() *AccountStateProviderMock { | ||
return &AccountStateProviderMock{ | ||
AccountStateByAddress: make(map[string]*types.AccountState), | ||
} | ||
} | ||
|
||
// SetNonce - | ||
func (mock *AccountStateProviderMock) SetNonce(address []byte, nonce uint64) { | ||
mock.mutex.Lock() | ||
defer mock.mutex.Unlock() | ||
|
||
key := string(address) | ||
|
||
if mock.AccountStateByAddress[key] == nil { | ||
mock.AccountStateByAddress[key] = newDefaultAccountState() | ||
} | ||
|
||
mock.AccountStateByAddress[key].Nonce = nonce | ||
} | ||
|
||
// SetBalance - | ||
func (mock *AccountStateProviderMock) SetBalance(address []byte, balance *big.Int) { | ||
mock.mutex.Lock() | ||
defer mock.mutex.Unlock() | ||
|
||
key := string(address) | ||
|
||
if mock.AccountStateByAddress[key] == nil { | ||
mock.AccountStateByAddress[key] = newDefaultAccountState() | ||
} | ||
|
||
mock.AccountStateByAddress[key].Balance = balance | ||
} | ||
|
||
// GetAccountState - | ||
func (mock *AccountStateProviderMock) GetAccountState(address []byte) (*types.AccountState, error) { | ||
mock.mutex.Lock() | ||
defer mock.mutex.Unlock() | ||
|
||
if mock.GetAccountStateCalled != nil { | ||
return mock.GetAccountStateCalled(address) | ||
} | ||
|
||
state, ok := mock.AccountStateByAddress[string(address)] | ||
if ok { | ||
return state, nil | ||
} | ||
|
||
return newDefaultAccountState(), nil | ||
} | ||
|
||
// IsInterfaceNil - | ||
func (mock *AccountStateProviderMock) IsInterfaceNil() bool { | ||
return mock == nil | ||
} | ||
|
||
func newDefaultAccountState() *types.AccountState { | ||
return &types.AccountState{ | ||
Nonce: 0, | ||
Balance: big.NewInt(1000000000000000000), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package txcache | ||
|
||
import "errors" | ||
|
||
var errNilTxGasHandler = errors.New("nil tx gas handler") | ||
var errNilAccountStateProvider = errors.New("nil account state provider") | ||
var errItemAlreadyInCache = errors.New("item already in cache") | ||
var errEmptyBunchOfTransactions = errors.New("empty bunch of transactions") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Forgot to update before.