-
Notifications
You must be signed in to change notification settings - Fork 85
[Mempool] Implement custom mempool #587
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
Merged
Merged
Changes from all commits
Commits
Show all changes
71 commits
Select commit
Hold shift + click to select a range
3e35d61
add block sdk with default lane
colmazia 738dabd
add feeds lanes for MsgSubmitSignalPrices
colmazia 5805491
create band custom mempool
colmazia cecc2c7
refactor and add enforce one tx per signer option
colmazia 057b778
integrate cosmos mempool to store tx in lane, add unit tests
colmazia 2bd4894
Merge branch 'master' into add-block-lanes
colmazia ebb0f6e
implement tx verification by msgServer in lane insertion, use ignore …
colmazia 335cbd7
Merge branch 'master' into add-block-lanes
colmazia 70676de
use blockspace in all mempool package
colmazia 6c873b0
cleanup print
colmazia f81df6c
use signer adapter from cosmos instead of block-sdk, add comments
colmazia e6e1995
add comment
colmazia ff957c3
use noop process proposal
colmazia 0b1c9f7
Add separate lane for Oracle requests based on report limit dependency
3d10cf9
correct variables name and comment
9ae5286
fix double gas issue
colmazia 3ab0082
add and delete comments
colmazia 6ecd5f3
Merge branch 'master' into add-block-lanes
colmazia 2b58d0d
fix from comments
colmazia 9fc1a7b
make field in lane, proposal private
colmazia 0c83958
fix from comments
colmazia 40a7235
fix from comments
colmazia d07815f
fix from comments
colmazia 936f975
Merge branch 'add-block-lanes' into fix-double-gas
colmazia c5f05af
fix test
colmazia fc693ac
Merge branch 'add-block-lanes' into fix-double-gas
colmazia 4162d42
remove logic in lane match function to reduce gas used
colmazia 82b228a
add context for matchFns option
colmazia aa598c7
fix matchFn names
colmazia 497622f
Merge pull request #633 from bandprotocol/fix-double-gas
RogerKSI 7c00830
Merge branch 'add-block-lanes' into add-armageddon
5e66f6a
fix typo
7f340d4
[Fix][Mempool] Fix invalid block sequence (#614)
Marca23 2ed34e2
fix comments
colmazia 1c272b5
Merge branch 'add-block-lanes' into add-armageddon
136286c
add comments for mempool lanes
b84bf7e
fix comment
baf082d
add comment and refactor
0e49a39
refactor return order
ad929da
fix callbackAfterFillProposal comment
1424b9e
Merge pull request #613 from bandprotocol/add-armageddon
colmazia 6ddcb3f
[Mempool] Add Readme (#650)
colmazia 08e56e2
refactor lane and matchFn
taobun 4aed982
remove cdc
taobun aa0f937
fix lanes.go
taobun fc3c6e6
fix import
taobun 4256a93
rename fn and remove unused ctx
taobun 5788d63
move tx size check logic to lane insert
colmazia a663941
add test for check in insert, add test for tx bytes
colmazia ca71a2f
Merge pull request #659 from bandprotocol/refactor-match-fn
colmazia c4d58f9
Merge branch 'add-block-lanes' into fix-tx-limit
colmazia 402fe34
fix merge bug
colmazia f13a7b0
remove redundant test
colmazia 3dd7737
fix from comments
colmazia 724ead4
Merge pull request #660 from bandprotocol/fix-tx-limit
taobun 6fcbae1
Merge branch 'master' into add-block-lanes
colmazia c07158d
Merge branch 'master' into add-block-lanes
colmazia 23cf32d
Merge branch 'master' into add-block-lanes
colmazia 3b0097b
fix from comments
colmazia 20f84a7
Merge branch 'master' into add-block-lanes
colmazia 775ed36
use safesub and remove colon
colmazia adfd332
change tx cap for tss to 5%
colmazia 164c6a0
change from 20 to 10 (#687)
RogerKSI da5fdd1
fix comment
colmazia bae8fef
remove custom checktx
colmazia f25ffe7
fix from comments
colmazia 1edd95f
update readme
colmazia 037de4e
Merge branch 'master' into add-block-lanes
colmazia 4eea271
adjust tx limit size for tss and report lanes
RogerKSI 7570218
Merge branch 'master' of https://github.com/bandprotocol/chain into a…
RogerKSI c2f9455
fix from comments
colmazia 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 hidden or 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 hidden or 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 hidden or 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,113 @@ | ||
| package band | ||
|
|
||
| import ( | ||
| channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" | ||
|
|
||
| "cosmossdk.io/math" | ||
|
|
||
| sdk "github.com/cosmos/cosmos-sdk/types" | ||
| sdkmempool "github.com/cosmos/cosmos-sdk/types/mempool" | ||
|
|
||
| "github.com/bandprotocol/chain/v3/app/mempool" | ||
| feedstypes "github.com/bandprotocol/chain/v3/x/feeds/types" | ||
| oracletypes "github.com/bandprotocol/chain/v3/x/oracle/types" | ||
| tsstypes "github.com/bandprotocol/chain/v3/x/tss/types" | ||
| ) | ||
|
|
||
| // DefaultLaneMatchHandler is a function that returns the match function for the default lane. | ||
| func DefaultLaneMatchHandler() mempool.TxMatchFn { | ||
| return func(_ sdk.Context, _ sdk.Tx) bool { | ||
| return true | ||
| } | ||
| } | ||
|
|
||
| // CreateLanes creates the lanes for the Band mempool. | ||
| func CreateLanes(app *BandApp) []*mempool.Lane { | ||
| // feedsLane handles feeds submit signal price transactions. | ||
| // Each transaction has a gas limit of 2%, and the total gas limit for the lane is 50%. | ||
| // It uses SenderNonceMempool to ensure transactions are ordered by sender and nonce, with no per-sender tx limit. | ||
| feedsLane := mempool.NewLane( | ||
| app.Logger(), | ||
| app.txConfig.TxEncoder(), | ||
| "feedsLane", | ||
| mempool.NewLaneTxMatchFn([]sdk.Msg{&feedstypes.MsgSubmitSignalPrices{}}, true), | ||
| math.LegacyMustNewDecFromStr("0.02"), | ||
| math.LegacyMustNewDecFromStr("0.5"), | ||
| sdkmempool.NewSenderNonceMempool(sdkmempool.SenderNonceMaxTxOpt(0)), | ||
| nil, | ||
| ) | ||
|
|
||
| // tssLane handles TSS transactions. | ||
| // Each transaction has a gas limit of 10%, and the total gas limit for the lane is 20%. | ||
| tssLane := mempool.NewLane( | ||
| app.Logger(), | ||
| app.txConfig.TxEncoder(), | ||
| "tssLane", | ||
| mempool.NewLaneTxMatchFn( | ||
| []sdk.Msg{ | ||
| &tsstypes.MsgSubmitDKGRound1{}, | ||
| &tsstypes.MsgSubmitDKGRound2{}, | ||
| &tsstypes.MsgConfirm{}, | ||
| &tsstypes.MsgComplain{}, | ||
| &tsstypes.MsgSubmitDEs{}, | ||
| &tsstypes.MsgSubmitSignature{}, | ||
| }, | ||
| true, | ||
| ), | ||
| math.LegacyMustNewDecFromStr("0.1"), | ||
| math.LegacyMustNewDecFromStr("0.2"), | ||
| sdkmempool.DefaultPriorityMempool(), | ||
| nil, | ||
| ) | ||
|
|
||
| // oracleRequestLane handles oracle request data transactions. | ||
| // Each transaction has a gas limit of 10%, and the total gas limit for the lane is 10%. | ||
| // It is blocked if the oracle report lane exceeds its limit. | ||
| oracleRequestLane := mempool.NewLane( | ||
| app.Logger(), | ||
| app.txConfig.TxEncoder(), | ||
| "oracleRequestLane", | ||
| mempool.NewLaneTxMatchFn( | ||
| []sdk.Msg{ | ||
| &oracletypes.MsgRequestData{}, | ||
| &channeltypes.MsgRecvPacket{}, // TODO: Only match oracle request packet | ||
| }, | ||
| false, | ||
| ), | ||
| math.LegacyMustNewDecFromStr("0.1"), | ||
| math.LegacyMustNewDecFromStr("0.1"), | ||
| sdkmempool.DefaultPriorityMempool(), | ||
| nil, | ||
| ) | ||
|
|
||
| // oracleReportLane handles oracle report data transactions. | ||
| // Each transaction has a gas limit of 10%, and the total gas limit for the lane is 20%. | ||
| // It block the oracle request lane if it exceeds its limit. | ||
| oracleReportLane := mempool.NewLane( | ||
| app.Logger(), | ||
| app.txConfig.TxEncoder(), | ||
| "oracleReportLane", | ||
| mempool.NewLaneTxMatchFn([]sdk.Msg{&oracletypes.MsgReportData{}}, true), | ||
| math.LegacyMustNewDecFromStr("0.1"), | ||
| math.LegacyMustNewDecFromStr("0.2"), | ||
| sdkmempool.DefaultPriorityMempool(), | ||
| func(isLaneLimitExceeded bool) { | ||
| oracleRequestLane.SetBlocked(isLaneLimitExceeded) | ||
| }, | ||
| ) | ||
|
|
||
| // defaultLane handles all other transactions. | ||
| // Each transaction has a gas limit of 10%, and the total gas limit for the lane is 10%. | ||
| defaultLane := mempool.NewLane( | ||
| app.Logger(), | ||
| app.txConfig.TxEncoder(), | ||
| "defaultLane", | ||
| DefaultLaneMatchHandler(), | ||
| math.LegacyMustNewDecFromStr("0.1"), | ||
| math.LegacyMustNewDecFromStr("0.1"), | ||
| sdkmempool.DefaultPriorityMempool(), | ||
| nil, | ||
| ) | ||
|
|
||
| return []*mempool.Lane{feedsLane, tssLane, oracleReportLane, oracleRequestLane, defaultLane} | ||
| } |
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.
Uh oh!
There was an error while loading. Please reload this page.