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

feat: ABCI 1.0 baseapp integration #13453

Merged
merged 261 commits into from
Nov 9, 2022
Merged
Show file tree
Hide file tree
Changes from 130 commits
Commits
Show all changes
261 commits
Select commit Hold shift + click to select a range
d72d1a2
size impl
kocubinski Sep 13, 2022
01ed963
cleanup
kocubinski Sep 13, 2022
35ff6d6
fix nill pointer when checking if key exists
JeancarloBarrios Sep 14, 2022
bbd9405
add init of hashes
JeancarloBarrios Sep 14, 2022
3cc3fb1
notes
kocubinski Sep 14, 2022
9ffa994
Merge branch 'kocubinski/mempool-impl' of github.com:cosmos/cosmos-sd…
kocubinski Sep 14, 2022
aa103ef
Merge branch 'main' of github.com:cosmos/cosmos-sdk into kocubinski/m…
kocubinski Sep 14, 2022
77a9b37
btree ordering
kocubinski Sep 14, 2022
46c34ff
MauricGit/skiplist impl
kocubinski Sep 14, 2022
9a4eeac
add huandu skiplist impl
kocubinski Sep 14, 2022
09f4e6b
very rough draft of stateful ordering
kocubinski Sep 15, 2022
a6fb1e5
some notes
kocubinski Sep 16, 2022
c8931c9
fill out remove method
kocubinski Sep 16, 2022
c3746c7
some comments
kocubinski Sep 16, 2022
816dc70
mempool to own package
kocubinski Sep 18, 2022
85c5f1e
stateful mempool test passes
kocubinski Sep 18, 2022
a10b047
dfs impl in graph test passing
kocubinski Sep 19, 2022
59b2195
comment
kocubinski Sep 19, 2022
aafb4ce
add test case
kocubinski Sep 19, 2022
1798d68
runtime edge detection is a bad idea
kocubinski Sep 22, 2022
6be3812
feat(mempool): tests and benchmark for mempool (#13273)
JeancarloBarrios Sep 22, 2022
5f2b9cc
Refactor mempool impl
kocubinski Sep 22, 2022
14afa8d
Merge branch 'kocubinski/mempool-impl' of github.com:cosmos/cosmos-sd…
kocubinski Sep 22, 2022
ee97a25
tx generation
kocubinski Sep 23, 2022
bfda138
shuffle return
kocubinski Sep 23, 2022
ee2ed7e
transaction generating
kocubinski Sep 24, 2022
afc04eb
clean up tx order tests
kocubinski Sep 25, 2022
a9a8fa3
generative tests are passing
kocubinski Sep 25, 2022
9556eff
add comment
kocubinski Sep 25, 2022
87bf3b6
more iterations
kocubinski Sep 25, 2022
5b647eb
clean up
kocubinski Sep 25, 2022
6407c12
even more tests of tests
kocubinski Sep 25, 2022
629d17b
notes on multi sender handling
kocubinski Sep 25, 2022
0bd11ff
rework tests
kocubinski Sep 28, 2022
01858d2
hypothesis for multi sender
kocubinski Sep 28, 2022
ed23ead
refactoring into multi sender testing
kocubinski Sep 28, 2022
fc784dc
this approach for multi sender is not excellent
kocubinski Sep 28, 2022
1758aae
one more test case
kocubinski Sep 28, 2022
0ec9335
ate a bag of peanut butter m&ms, re-writing the graph.go impl
kocubinski Sep 29, 2022
1520b5d
rewrite graph
kocubinski Sep 29, 2022
fa7cc9a
add an interesting case which breaks current mempool impl
kocubinski Sep 29, 2022
c4495fd
all the edges
kocubinski Sep 30, 2022
f4ff6c6
work
kocubinski Sep 30, 2022
f57847d
Merge branch 'main' of github.com:cosmos/cosmos-sdk into kocubinski/m…
kocubinski Oct 2, 2022
82f701c
go mod tidy
kocubinski Oct 2, 2022
16100f9
fix graph initial conditions finding
kocubinski Oct 3, 2022
582e914
refactoring tests
kocubinski Oct 3, 2022
a8d58dd
derive sender from pubkey in signer_infos
kocubinski Oct 3, 2022
1e1be0e
refactoring
kocubinski Oct 4, 2022
b749c6f
baseapp integration
kocubinski Oct 4, 2022
26eb530
test
JeancarloBarrios Oct 4, 2022
5143d58
Merge branch 'kocubinski/mempool-impl' of github.com:cosmos/cosmos-sd…
JeancarloBarrios Oct 4, 2022
90996c7
Procees proposal base
JeancarloBarrios Oct 4, 2022
5be329f
more baseapp integration
kocubinski Oct 5, 2022
c25385a
cd simapp && go mod tidy
kocubinski Oct 5, 2022
1725e8d
fixing tests
kocubinski Oct 5, 2022
7cf3a52
remove graph impl
kocubinski Oct 5, 2022
9c44433
Default mempool implementation
kocubinski Oct 5, 2022
15834d7
Update go.mod
kocubinski Oct 5, 2022
7457271
Remove moved file
kocubinski Oct 5, 2022
b0b8b27
backporting from integration branch
kocubinski Oct 5, 2022
5eac4b7
cd tests && go mod tidy
kocubinski Oct 5, 2022
834f85f
test refactor
kocubinski Oct 5, 2022
d90ac72
Merge branch 'main' of github.com:cosmos/cosmos-sdk into kocubinski/m…
kocubinski Oct 5, 2022
fbe1bb4
resolve conflicts
kocubinski Oct 5, 2022
ffe535d
mempool tests passing
kocubinski Oct 5, 2022
056bca1
remove type conversion
kocubinski Oct 5, 2022
78b774c
test cleanup
kocubinski Oct 5, 2022
192d421
rename parallel impl
kocubinski Oct 5, 2022
7adc7bf
more cleanup
kocubinski Oct 5, 2022
bd1b55f
go imports
kocubinski Oct 5, 2022
96cd0c7
Add some godoc strings
kocubinski Oct 5, 2022
83dcbc7
typo
kocubinski Oct 5, 2022
e473bcf
more godoc
kocubinski Oct 5, 2022
613019a
comment format
kocubinski Oct 5, 2022
3099039
typo
kocubinski Oct 5, 2022
295703f
update godoc
kocubinski Oct 6, 2022
47fad32
Merge branch 'main' of github.com:cosmos/cosmos-sdk into kocubinski/m…
kocubinski Oct 6, 2022
302f81e
simple benchmark
JeancarloBarrios Oct 6, 2022
83d6320
test cleanup
kocubinski Oct 6, 2022
873cb74
Merge branch 'main' of github.com:cosmos/cosmos-sdk into kocubinski/m…
kocubinski Oct 6, 2022
5849815
Merge branch 'main' of github.com:cosmos/cosmos-sdk into kocubinski/m…
kocubinski Oct 10, 2022
e61ceea
move default implementation to default.go
kocubinski Oct 10, 2022
48ce41c
minor clean up to default impl
kocubinski Oct 10, 2022
c24a152
minor refactoring, add skip list test
kocubinski Oct 10, 2022
ad829d4
refactor away iterations tracking
kocubinski Oct 10, 2022
8d13cc2
Merge branch 'main' into kocubinski/mempool-impl
kocubinski Oct 10, 2022
869b524
begin baseapp integration
kocubinski Oct 10, 2022
47ba2c2
change not found error
kocubinski Oct 10, 2022
541f112
Merge branch 'main' of github.com:cosmos/cosmos-sdk into kocubinski/m…
kocubinski Oct 10, 2022
bae75b9
Merge branch 'kocubinski/mempool-impl' into kocubinski/mempool-baseapp
kocubinski Oct 10, 2022
af4f5bc
abci1.0 methods
kocubinski Oct 10, 2022
1d5b1d4
fix import format
kocubinski Oct 10, 2022
de40135
Merge branch 'main' into kocubinski/mempool-impl
kocubinski Oct 11, 2022
6c15d92
Merge branch 'main' into kocubinski/mempool-impl
kocubinski Oct 11, 2022
250ea90
Merge branch 'kocubinski/mempool-impl' of github.com:cosmos/cosmos-sd…
kocubinski Oct 11, 2022
5be06eb
more integration
kocubinski Oct 11, 2022
2663dc2
Merge branch 'kocubinski/mempool-baseapp' of github.com:cosmos/cosmos…
kocubinski Oct 11, 2022
c2e7069
rename default impl -> priority
kocubinski Oct 11, 2022
42d52c1
add default constructor
kocubinski Oct 11, 2022
4ecf2e2
Merge branch 'kocubinski/mempool-impl' of github.com:cosmos/cosmos-sd…
kocubinski Oct 11, 2022
58bd2ce
Merge branch 'kocubinski/mempool-impl' of github.com:cosmos/cosmos-sd…
kocubinski Oct 11, 2022
00a7a8f
default supplier in simapp
kocubinski Oct 11, 2022
be180e8
need a signature for removal in tx tests
kocubinski Oct 11, 2022
9d120c1
all tx in deliver_tx_test now have a sig
kocubinski Oct 11, 2022
4f466a4
Merge branch 'main' into kocubinski/mempool-impl
kocubinski Oct 11, 2022
abbe016
Merge branch 'main' into kocubinski/mempool-impl
kocubinski Oct 11, 2022
d2f8b21
Merge branch 'main' into kocubinski/mempool-impl
kocubinski Oct 12, 2022
63d6606
Merge branch 'main' into kocubinski/mempool-impl
kocubinski Oct 12, 2022
91e30d7
remove unused test file
kocubinski Oct 12, 2022
ea8589d
Merge branch 'kocubinski/mempool-impl' of github.com:cosmos/cosmos-sd…
kocubinski Oct 12, 2022
d02e4a9
Merge branch 'kocubinski/mempool-impl' of github.com:cosmos/cosmos-sd…
kocubinski Oct 12, 2022
7d2fd41
Update types/mempool/mempool_test.go
JeancarloBarrios Oct 12, 2022
1683445
Merge branch 'kocubinski/mempool-all' of github.com:cosmos/cosmos-sdk…
JeancarloBarrios Oct 12, 2022
b9a2e05
smiple benchmarks
JeancarloBarrios Oct 12, 2022
a1f2ae0
Use checkState
facundomedica Oct 16, 2022
5bd05f8
simple fix
JeancarloBarrios Oct 17, 2022
0c37d23
Merge branch 'main' of github.com:cosmos/cosmos-sdk into kocubinski/m…
kocubinski Oct 17, 2022
19e6e3e
update algorithm for failing test case
kocubinski Oct 18, 2022
5cc97f4
golint fix
kocubinski Oct 18, 2022
2bc00a1
Merge branch 'main' of github.com:cosmos/cosmos-sdk into kocubinski/m…
kocubinski Oct 18, 2022
e42d6a8
Merge branch 'main' of github.com:cosmos/cosmos-sdk into kocubinski/m…
kocubinski Oct 18, 2022
1366a87
fix gosec warning
kocubinski Oct 18, 2022
f2457fa
working solution
kocubinski Oct 18, 2022
d7dc83a
remove debug prints
kocubinski Oct 18, 2022
bfee335
add priority ties test
kocubinski Oct 18, 2022
b7fe34c
Merge branch 'main' of github.com:cosmos/cosmos-sdk into kocubinski/m…
kocubinski Oct 18, 2022
52e10e6
comments
kocubinski Oct 18, 2022
4e429dd
Add godoc to mempool.Size implementation
kocubinski Oct 18, 2022
5c80aaf
increment
kocubinski Oct 18, 2022
46fb8c4
add another test case
kocubinski Oct 18, 2022
a17f506
Merge branch 'main' of github.com:cosmos/cosmos-sdk into kocubinski/m…
kocubinski Oct 18, 2022
078168b
fix gosec error
kocubinski Oct 18, 2022
59cc71f
Merge branch 'main' into kocubinski/mempool-impl
kocubinski Oct 18, 2022
e321ec2
implement missing methods for tx to pass app test
JeancarloBarrios Oct 19, 2022
db1f4cd
Merge branch 'main' into kocubinski/mempool-all
JeancarloBarrios Oct 19, 2022
ba57a58
Merge branch 'main' into kocubinski/mempool-impl
kocubinski Oct 19, 2022
227ea17
Update types/mempool/priority.go
alexanderbez Oct 19, 2022
522aaab
bez: lint/godoc
alexanderbez Oct 19, 2022
7021bdd
bez: lint/godoc
alexanderbez Oct 19, 2022
81c67f7
bez: lint/godoc
alexanderbez Oct 19, 2022
af919d3
Update types/mempool/priority.go
kocubinski Oct 19, 2022
54837e8
remove line
kocubinski Oct 19, 2022
e9a7232
set txSize to 0 in tx/builder.go setters
kocubinski Oct 19, 2022
f634306
some comments
kocubinski Oct 20, 2022
6034696
Merge branch 'main' into kocubinski/mempool-impl
kocubinski Oct 20, 2022
fb6eb64
log out seeds in tests
kocubinski Oct 20, 2022
838e126
Merge branch 'kocubinski/mempool-impl' of github.com:cosmos/cosmos-sd…
kocubinski Oct 20, 2022
c043a7a
Merge branch 'main' into kocubinski/mempool-impl
kocubinski Oct 20, 2022
b07a56c
Merge branch 'main' into kocubinski/mempool-all
JeancarloBarrios Oct 20, 2022
45044bd
add a comment
kocubinski Oct 21, 2022
5ccf004
Merge branch 'main' into kocubinski/mempool-impl
kocubinski Oct 21, 2022
0528e05
Fix inconsistency in setting baseapp mempool
kocubinski Oct 21, 2022
1cb53a0
Merge branch 'main' into kocubinski/mempool-impl
kocubinski Oct 23, 2022
cc608b6
added function for abci integration
JeancarloBarrios Oct 24, 2022
2f56b6d
abci base methods for abci++
JeancarloBarrios Oct 24, 2022
bab393a
priority mempool
JeancarloBarrios Oct 24, 2022
b88614e
Merge branch 'kocubinski/mempool-all' of github.com:cosmos/cosmos-sdk…
JeancarloBarrios Oct 24, 2022
2afe7b1
Merge branch 'kocubinski/mempool-impl' of github.com:cosmos/cosmos-sd…
JeancarloBarrios Oct 24, 2022
1dfe713
Merge branch 'kocubinski/mempool-impl' into kocubinski/mempool-all
JeancarloBarrios Oct 24, 2022
5fbee38
simple for testing purposes
JeancarloBarrios Oct 24, 2022
94ddfa2
prepare and process propossal have the same logic if a tx fails they …
JeancarloBarrios Oct 24, 2022
f6c073f
small fix
JeancarloBarrios Oct 24, 2022
179869e
Merge branch 'main' into kocubinski/mempool-all
JeancarloBarrios Oct 26, 2022
b1c84cb
base abci changes
JeancarloBarrios Oct 26, 2022
e514f7b
t
JeancarloBarrios Oct 27, 2022
c834047
t
JeancarloBarrios Oct 27, 2022
4d11de2
set prepare and process like check state
JeancarloBarrios Oct 27, 2022
4d295b1
deletead simple due to it being merge to main in a separate PR
JeancarloBarrios Oct 27, 2022
46ebfc4
Merge branch 'main' of github.com:cosmos/cosmos-sdk into kocubinski/m…
kocubinski Oct 27, 2022
ffdb934
draft of select cursor
kocubinski Oct 27, 2022
55d13d7
fix reference to deleted file
kocubinski Oct 27, 2022
3f76cb6
panic
kocubinski Oct 27, 2022
cb147a3
handle empty case properly
kocubinski Oct 27, 2022
b04e051
feat: mempool select iterator (#13677)
kocubinski Oct 27, 2022
6f71213
t
JeancarloBarrios Oct 27, 2022
0cc1aaa
refactor iterator
kocubinski Oct 27, 2022
732d1b1
Merge branch 'kocubinski/mempool-select-cursor' into kocubinski/mempo…
kocubinski Oct 27, 2022
6601cf3
t
JeancarloBarrios Oct 28, 2022
96cb90b
Remove mempool.Tx interface
kocubinski Oct 31, 2022
657ce24
error handling
kocubinski Oct 31, 2022
736306c
Add sdk.Context to Mempool.Select()
kocubinski Nov 1, 2022
e907d77
Merge branch 'main' into kocubinski/mempool-all
kocubinski Nov 1, 2022
61bd98a
fix whitespace
kocubinski Nov 1, 2022
1f53170
revert simapp/app.go
kocubinski Nov 1, 2022
369c622
fix whitespace
kocubinski Nov 1, 2022
7a7504a
Merge branch 'main' into kocubinski/mempool-all
kocubinski Nov 1, 2022
32899a5
use setter for consistency
kocubinski Nov 1, 2022
ddec83e
Merge branch 'kocubinski/mempool-all' of github.com:cosmos/cosmos-sdk…
kocubinski Nov 1, 2022
3e6e1a4
Merge branch 'main' into kocubinski/mempool-all
kocubinski Nov 2, 2022
9c23184
test advances
JeancarloBarrios Nov 2, 2022
3f1dcd8
Merge branch 'kocubinski/mempool-all' of github.com:cosmos/cosmos-sdk…
JeancarloBarrios Nov 2, 2022
d4234d8
test construction
kocubinski Nov 2, 2022
580c8b3
remove prints
JeancarloBarrios Nov 2, 2022
3c8640e
fixed comment
JeancarloBarrios Nov 2, 2022
d1a1cf8
add tests exercising multiple signers with real messages
kocubinski Nov 2, 2022
0697e88
Merge branch 'main' into kocubinski/mempool-all
kocubinski Nov 2, 2022
fc4bccb
happy path test
kocubinski Nov 2, 2022
659faa3
Merge branch 'kocubinski/mempool-all' of github.com:cosmos/cosmos-sdk…
kocubinski Nov 2, 2022
10cd747
move to test suite
kocubinski Nov 2, 2022
bfe7faf
add failing antehandler test
kocubinski Nov 2, 2022
de876ca
test max byte sizae
JeancarloBarrios Nov 2, 2022
51e0da9
Merge branch 'main' into kocubinski/mempool-all
kocubinski Nov 3, 2022
7dc0684
Update baseapp/abci.go
JeancarloBarrios Nov 3, 2022
72a5c3c
Update server/types/app.go
JeancarloBarrios Nov 3, 2022
201d52e
Update baseapp/baseapp.go
JeancarloBarrios Nov 3, 2022
dea715f
Update baseapp/baseapp.go
JeancarloBarrios Nov 3, 2022
0af1899
remove interface implemantation that is no longer needed
JeancarloBarrios Nov 3, 2022
3134207
fix
JeancarloBarrios Nov 3, 2022
9e3048f
Allow applications to define process proposal
kocubinski Nov 3, 2022
41816be
Merge branch 'kocubinski/mempool-all' of github.com:cosmos/cosmos-sdk…
kocubinski Nov 3, 2022
678b555
wrapping method
kocubinski Nov 3, 2022
a75e4ef
t
JeancarloBarrios Nov 3, 2022
215d2a6
t
JeancarloBarrios Nov 3, 2022
587f0fb
Merge branch 'kocubinski/mempool-all' of github.com:cosmos/cosmos-sdk…
JeancarloBarrios Nov 3, 2022
88f574d
use a no-op message server
kocubinski Nov 3, 2022
7180e94
clean up imports
kocubinski Nov 3, 2022
97a9c76
removed unesesary state set
JeancarloBarrios Nov 3, 2022
6e5ff1c
t
JeancarloBarrios Nov 3, 2022
e1d5ed4
t
JeancarloBarrios Nov 3, 2022
8d4e97b
t
JeancarloBarrios Nov 3, 2022
99566ce
Use correct state in ProcessProposal
kocubinski Nov 4, 2022
16e98c9
Revert "removed unesesary state set"
kocubinski Nov 4, 2022
a15d9f0
Set Block height
kocubinski Nov 4, 2022
cf88b04
Fix processProposal handler
kocubinski Nov 4, 2022
5db4724
Remove context modification in BeginBlock
kocubinski Nov 4, 2022
0696b82
minor cleanup
kocubinski Nov 4, 2022
a8dd44d
Merge branch 'main' into kocubinski/mempool-all
kocubinski Nov 4, 2022
ef5a625
t
JeancarloBarrios Nov 4, 2022
3ac1d30
fix go imports
kocubinski Nov 7, 2022
deb33f5
Merge branch 'kocubinski/mempool-all' of github.com:cosmos/cosmos-sdk…
kocubinski Nov 7, 2022
74775b6
Update baseapp/baseapp.go
alexanderbez Nov 7, 2022
1e36da8
Apply suggestions from code review
alexanderbez Nov 7, 2022
a3bc195
Update baseapp/baseapp.go
JeancarloBarrios Nov 7, 2022
ccc00f1
duplicate ProcessProposal request fields into context object
kocubinski Nov 7, 2022
5595988
Merge branch 'main' into kocubinski/mempool-all
kocubinski Nov 7, 2022
26641b6
Merge branch 'main' into kocubinski/mempool-all
kocubinski Nov 7, 2022
061e68e
debug and fix bug surfaced in liveness tests
kocubinski Nov 8, 2022
e646e46
Merge branch 'main' into kocubinski/mempool-all
kocubinski Nov 8, 2022
e594b59
init prepare/process proposal state in .Init
kocubinski Nov 8, 2022
40a5b21
reject when checktx fails on process propossal
JeancarloBarrios Nov 8, 2022
e50ef7d
reject when checktx fails on process propossal
JeancarloBarrios Nov 8, 2022
5ce1d3a
Add 2 comments
kocubinski Nov 8, 2022
97f02e9
Merge branch 'main' into kocubinski/mempool-all
kocubinski Nov 8, 2022
c10e857
Update baseapp/abci.go
kocubinski Nov 8, 2022
323b9f7
fix comment
kocubinski Nov 8, 2022
3575579
Update baseapp/abci.go
alexanderbez Nov 8, 2022
348f67e
Merge branch 'main' into kocubinski/mempool-all
kocubinski Nov 8, 2022
4576305
Update baseapp/baseapp.go
kocubinski Nov 8, 2022
61e1b60
Merge branch 'main' into kocubinski/mempool-all
kocubinski Nov 9, 2022
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
32 changes: 28 additions & 4 deletions baseapp/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ import (
"syscall"
"time"

"github.com/cosmos/gogoproto/proto"
abci "github.com/tendermint/tendermint/abci/types"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
"google.golang.org/grpc/codes"
grpcstatus "google.golang.org/grpc/status"

"github.com/cosmos/gogoproto/proto"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"github.com/cosmos/gogoproto/proto"
"github.com/cosmos/gogoproto/proto"

"github.com/cosmos/cosmos-sdk/codec"
snapshottypes "github.com/cosmos/cosmos-sdk/snapshots/types"
"github.com/cosmos/cosmos-sdk/telemetry"
Expand Down Expand Up @@ -249,8 +250,19 @@ func (app *BaseApp) EndBlock(req abci.RequestEndBlock) (res abci.ResponseEndBloc
// Ref: https://github.com/cosmos/cosmos-sdk/blob/main/docs/architecture/adr-060-abci-1.0.md
// Ref: https://github.com/tendermint/tendermint/blob/main/spec/abci/abci%2B%2B_basic_concepts.md
func (app *BaseApp) PrepareProposal(req abci.RequestPrepareProposal) abci.ResponsePrepareProposal {
// TODO: Implement.
return abci.ResponsePrepareProposal{Txs: req.Txs}
memTxs, selectErr := app.mempool.Select(req.Txs, req.MaxTxBytes)
if selectErr != nil {
panic(selectErr)
}
var txs [][]byte
for _, memTx := range memTxs {
alexanderbez marked this conversation as resolved.
Show resolved Hide resolved
bz, encErr := app.txEncoder(memTx)
if encErr != nil {
panic(encErr)
}
txs = append(txs, bz)
}
return abci.ResponsePrepareProposal{Txs: txs}
alexanderbez marked this conversation as resolved.
Show resolved Hide resolved
}

// ProcessProposal implements the ProcessProposal ABCI method and returns a
Expand All @@ -266,7 +278,19 @@ func (app *BaseApp) PrepareProposal(req abci.RequestPrepareProposal) abci.Respon
// Ref: https://github.com/cosmos/cosmos-sdk/blob/main/docs/architecture/adr-060-abci-1.0.md
// Ref: https://github.com/tendermint/tendermint/blob/main/spec/abci/abci%2B%2B_basic_concepts.md
func (app *BaseApp) ProcessProposal(req abci.RequestProcessProposal) abci.ResponseProcessProposal {
// TODO: Implement.
ctx := app.checkState.ctx

for _, txBytes := range req.Txs {
anteCtx, _ := app.cacheTxContext(ctx, txBytes)
tx, err := app.txDecoder(txBytes)
if err != nil {
return abci.ResponseProcessProposal{Status: abci.ResponseProcessProposal_REJECT}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This reject looks right to me, as a TX that fails to decode is a sign that the encoder was buggy, independently of the actual App state

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I agree. If we cannot decode a tx, that indicates some malicious behavior by the proposer in PrepareProposal. One thing we have not discussed is how to handle such byzantine behavior. @sergio-mena what will Tendermint do in such a case? Should we instead response with ACCEPT and punish the proposer to avoid liveness halts?

Copy link

@peterbourgon peterbourgon Oct 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Failure to decode a tx, or any other error encountered when parsing/validating incoming data, doesn't automatically indicate Byzantine malicious behavior. It's far more likely to be the result of a bug or fault, either in the code of the participating actors, or at the network layer. You shouldn't punish a proposer if their network provider, or any other intermediary, screws something up! 😅

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alexanderbez For the moment, Tendermint will prevent that (malformed) proposal from being decided by prevoting nil. Moving forward, we'll see if there is something else to be done. In any case, ProcessProposal "rejects" are a serious condition in a production chain (it indicates a Byzantine behavior, either via a bug, or via a malicious node).

To your second question, you can and should return reject in this case

}
ctx, err = app.anteHandler(anteCtx, tx, false)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you not running this on PrepareProposal?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JeancarloBarrios this doesn't look quite correct. In the ADR, we allude to the app having full control over ProcessProposal for better customizability. This means, we shouldn't be calling anteHandler directly. We should be calling app.processProposal, where the default implementation executes the entire proposal.

@sergio-mena for the record, we call AnteHandler on CheckTx. If the tx passes, it is inserted into the app-mempool (and Tendermint's mempool too). PrepareProposal takes txs from the app-side mempool. I believe the idea we now have is that ProcessProposal executes the entire proposal, i.e. AnteHandler + Msg Execution.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I have updated this i still need to push but I updated after our conversation yesterday

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alexanderbez be careful here folks. Let me describe an example and you tell me if that can happen.

  1. Tendermint calls CheckTx on txA, SDK calls the AnteHandler on txA which uses the Apps's current state; the AnteHandler check passes and txA is added to both mempools
  2. There are many transactions and txA has low priority, so there are, say, 10 blocks decided that didn't include txA
  3. txA is finally selected in line 253 above (app.mempool.Select), PrepareProposal does not run the AnteHandler, txA makes it to the proposal
  4. ProcessProposal is run on the proposal that includes txA so it runs the AnteHandler on txA. There have been 10 blocks decided, so the state has changed. With the new state, the AnteHandler check fails on txA
  5. ProcessProposal returns reject

Can this happen?
If it can, we may be able to solve it by re-running the AnteHandler also on PrepareProposal

if err != nil {
return abci.ResponseProcessProposal{Status: abci.ResponseProcessProposal_REJECT}
}
}
return abci.ResponseProcessProposal{Status: abci.ResponseProcessProposal_ACCEPT}
}

Expand Down
25 changes: 23 additions & 2 deletions baseapp/baseapp.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package baseapp

import (
"errors"
"fmt"
"sort"
"strings"
Expand All @@ -20,6 +21,7 @@ import (
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/types/mempool"
)

const (
Expand Down Expand Up @@ -55,8 +57,9 @@ type BaseApp struct { //nolint: maligned
msgServiceRouter *MsgServiceRouter // router for redirecting Msg service messages
interfaceRegistry codectypes.InterfaceRegistry
txDecoder sdk.TxDecoder // unmarshal []byte into sdk.Tx
txEncoder sdk.TxEncoder // marshal sdk.Tx into []byte

mempool sdk.Mempool // application side mempool
mempool mempool.Mempool // application side mempool
anteHandler sdk.AnteHandler // ante handler for fee and auth
postHandler sdk.AnteHandler // post handler, optional, e.g. for tips
initChainer sdk.InitChainer // initialize state with validators and state blob
Expand Down Expand Up @@ -160,6 +163,11 @@ func NewBaseApp(
option(app)
}

// if execution of options has left certain required fields nil, let's set them to default values
if app.mempool == nil {
app.mempool = mempool.DefaultPriorityMempool()
}

if app.interBlockCache != nil {
app.cms.SetInterBlockCache(app.interBlockCache)
}
Expand Down Expand Up @@ -653,9 +661,22 @@ func (app *BaseApp) runTx(mode runTxMode, txBytes []byte) (gInfo sdk.GasInfo, re
anteEvents = events.ToABCIEvents()
}

if mode == runTxModeCheck {
err = app.mempool.Insert(ctx, tx.(mempool.Tx))
if err != nil {
return gInfo, nil, anteEvents, priority, err
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the difference between this and lines 678-683 below ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this doesn't look right @JeancarloBarrios. We should only be inserting into the app-side mempool on CheckTx once, which we already do below.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree; sorry I have not fully updated this I will push a bit later today the implementation on likes 678-683has been removed.

} else if mode == runTxModeDeliver {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for my own understanding, why is it okay to not handle other types of runTxMode?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We remove during DeliverTx (stated in ADR).

err = app.mempool.Remove(tx.(mempool.Tx))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if another node gossips a tx after it is delivered (and removed from app.mempool) ? Tendermint has a cache mechanism that, while not perfect, helps with this use case.
Will you be relying on Tendermint's cache mechanism, or will you handle this case otherwise?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sergio-mena we're not relying or assuming anything about Tendermint here.

IIRC, Tendermint reaps the txs from its mempool prior to making a block proposal. Thus, the txs should not be in its mempool and thus gossiped.

Copy link
Contributor

@sergio-mena sergio-mena Oct 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two things:

  1. "Reap" is probably a bad name for ReapMaxBytesMaxGas as the transactions are not removed from the mempool when called at proposal time... it wouldn't make sense as we don't know if that proposal will be the one decided
  2. Anyway, this is not the case I had in mind when I wrote this comment, but the following. If a node is a few heights late (and so it hasn't committed the block the transaction is part of) it's perfectly OK for that node to have that transaction in its mempool (I mean Tendermint's mempool) and still gossip it until it reaches the height that commits the transaction.

if err != nil && !errors.Is(err, mempool.ErrTxNotFound) {
return gInfo, nil, anteEvents, priority,
fmt.Errorf("failed to remove tx from mempool: %w", err)
}
}
alexanderbez marked this conversation as resolved.
Show resolved Hide resolved

// TODO remove nil check when implemented
if mode == runTxModeCheck && app.mempool != nil {
err = app.mempool.Insert(ctx, tx.(sdk.MempoolTx))
err = app.mempool.Insert(ctx, tx.(mempool.Tx))
if err != nil {
return gInfo, nil, anteEvents, priority, err
}
Expand Down
21 changes: 18 additions & 3 deletions baseapp/deliver_tx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,19 @@ import (
"time"
"unsafe"

"cosmossdk.io/depinject"
"github.com/cosmos/gogoproto/jsonpb"
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
signingtypes "github.com/cosmos/cosmos-sdk/types/tx/signing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/libs/log"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
dbm "github.com/tendermint/tm-db"

"cosmossdk.io/depinject"
"github.com/cosmos/gogoproto/jsonpb"

"github.com/cosmos/cosmos-sdk/baseapp"
baseapptestutil "github.com/cosmos/cosmos-sdk/baseapp/testutil"
"github.com/cosmos/cosmos-sdk/client"
Expand Down Expand Up @@ -129,6 +133,7 @@ func setupBaseAppWithSnapshots(t *testing.T, config *setupConfig) (*baseapp.Base

builder := txConfig.NewTxBuilder()
builder.SetMsgs(msgs...)
setTxSignature(builder, 0)

txBytes, err := txConfig.TxEncoder()(builder.GetTx())
require.NoError(t, err)
Expand Down Expand Up @@ -1061,9 +1066,9 @@ func TestCheckTx(t *testing.T) {

require.NoError(t, err)
r := app.CheckTx(abci.RequestCheckTx{Tx: txBytes})
require.True(t, r.IsOK(), fmt.Sprintf("%v", r))
require.Equal(t, testTxPriority, r.Priority)
require.Empty(t, r.GetEvents())
require.True(t, r.IsOK(), fmt.Sprintf("%v", r))
}

checkStateStore := getCheckStateCtx(app.BaseApp).KVStore(capKey1)
Expand Down Expand Up @@ -1208,6 +1213,7 @@ func TestMultiMsgDeliverTx(t *testing.T) {

builder.SetMsgs(msgs...)
builder.SetMemo(tx.GetMemo())
setTxSignature(builder, 0)

txBytes, err = txConfig.TxEncoder()(builder.GetTx())
require.NoError(t, err)
Expand Down Expand Up @@ -1389,6 +1395,7 @@ func TestRunInvalidTransaction(t *testing.T) {
{
txBuilder := txConfig.NewTxBuilder()
txBuilder.SetMsgs(&baseapptestutil.MsgCounter2{})
setTxSignature(txBuilder, 0)
unknownRouteTx := txBuilder.GetTx()

_, result, err := app.SimDeliver(txConfig.TxEncoder(), unknownRouteTx)
Expand All @@ -1401,6 +1408,7 @@ func TestRunInvalidTransaction(t *testing.T) {

txBuilder = txConfig.NewTxBuilder()
txBuilder.SetMsgs(&baseapptestutil.MsgCounter{}, &baseapptestutil.MsgCounter2{})
setTxSignature(txBuilder, 0)
unknownRouteTx = txBuilder.GetTx()
_, result, err = app.SimDeliver(txConfig.TxEncoder(), unknownRouteTx)
require.Error(t, err)
Expand Down Expand Up @@ -1989,6 +1997,7 @@ func newTxCounter(cfg client.TxConfig, counter int64, msgCounters ...int64) sign
builder := cfg.NewTxBuilder()
builder.SetMsgs(msgs...)
builder.SetMemo("counter=" + strconv.FormatInt(counter, 10) + "&failOnAnte=false")
setTxSignature(builder, uint64(counter))

return builder.GetTx()
}
Expand Down Expand Up @@ -2201,3 +2210,9 @@ func (ps paramStore) Get(ctx sdk.Context) (*tmproto.ConsensusParams, error) {

return &params, nil
}

func setTxSignature(builder client.TxBuilder, nonce uint64) {
privKey := secp256k1.GenPrivKeyFromSecret([]byte("test"))
pubKey := privKey.PubKey()
builder.SetSignatures(signingtypes.SignatureV2{PubKey: pubKey, Sequence: nonce})
}
5 changes: 5 additions & 0 deletions baseapp/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,11 @@ func (app *BaseApp) SetTxDecoder(txDecoder sdk.TxDecoder) {
app.txDecoder = txDecoder
}

// SetTxEncoder sets the TxEncoder if it wasn't provided in the BaseApp constructor.
func (app *BaseApp) SetTxEncoder(txEncoder sdk.TxEncoder) {
app.txEncoder = txEncoder
}

// SetQueryMultiStore set a alternative MultiStore implementation to support grpc query service.
//
// Ref: https://github.com/cosmos/cosmos-sdk/issues/13317
Expand Down
3 changes: 3 additions & 0 deletions baseapp/testutil/messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package testutil

import (
"github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/crypto/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/types/msgservice"
Expand All @@ -17,6 +18,8 @@ func RegisterInterfaces(registry types.InterfaceRegistry) {
msgservice.RegisterMsgServiceDesc(registry, &_Counter_serviceDesc)
msgservice.RegisterMsgServiceDesc(registry, &_Counter2_serviceDesc)
msgservice.RegisterMsgServiceDesc(registry, &_KeyValue_serviceDesc)

codec.RegisterInterfaces(registry)
}

var _ sdk.Msg = &MsgCounter{}
Expand Down
21 changes: 12 additions & 9 deletions baseapp/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"github.com/cosmos/cosmos-sdk/testutil/mock"
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/mempool"
_ "github.com/cosmos/cosmos-sdk/x/auth"
_ "github.com/cosmos/cosmos-sdk/x/auth/tx/module"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
Expand Down Expand Up @@ -148,14 +149,16 @@ func makeTestConfig() depinject.Config {
}

func makeMinimalConfig() depinject.Config {
return appconfig.Compose(&appv1alpha1.Config{
Modules: []*appv1alpha1.ModuleConfig{
{
Name: "runtime",
Config: appconfig.WrapAny(&runtimev1alpha1.Module{
AppName: "BaseAppApp",
}),
return depinject.Configs(
depinject.Supply(mempool.DefaultPriorityMempool()),
appconfig.Compose(&appv1alpha1.Config{
Modules: []*appv1alpha1.ModuleConfig{
{
Name: "runtime",
Config: appconfig.WrapAny(&runtimev1alpha1.Module{
AppName: "BaseAppApp",
}),
},
},
},
})
}))
}
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ require (
github.com/hashicorp/go-getter v1.6.2
github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d
github.com/hdevalence/ed25519consensus v0.0.0-20220222234857-c00d1f31bab3
github.com/huandu/skiplist v1.2.0
github.com/improbable-eng/grpc-web v0.15.0
github.com/jhump/protoreflect v1.12.1-0.20220721211354-060cc04fc18b
github.com/magiconair/properties v1.8.6
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,10 @@ github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/J
github.com/hdevalence/ed25519consensus v0.0.0-20220222234857-c00d1f31bab3 h1:aSVUgRRRtOrZOC1fYmY9gV0e9z/Iu+xNVSASWjsuyGU=
github.com/hdevalence/ed25519consensus v0.0.0-20220222234857-c00d1f31bab3/go.mod h1:5PC6ZNPde8bBqU/ewGZig35+UIZtw9Ytxez8/q5ZyFE=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/huandu/go-assert v1.1.5 h1:fjemmA7sSfYHJD7CUqs9qTwwfdNAx7/j2/ZlHXzNB3c=
github.com/huandu/go-assert v1.1.5/go.mod h1:yOLvuqZwmcHIC5rIzrBhT7D3Q9c3GFnd0JrPVhn/06U=
github.com/huandu/skiplist v1.2.0 h1:gox56QD77HzSC0w+Ws3MH3iie755GBJU1OER3h5VsYw=
github.com/huandu/skiplist v1.2.0/go.mod h1:7v3iFjLcSAzO4fN5B8dvebvo/qsfumiLiDXMrPiHF9w=
github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmKTg=
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
Expand Down
10 changes: 9 additions & 1 deletion server/mock/app_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package mock

import (
"math/rand"
"time"

simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
"testing"

"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -53,7 +57,11 @@ func TestDeliverTx(t *testing.T) {

key := "my-special-key"
value := "top-secret-data!!"
tx := NewTx(key, value)

r := rand.New(rand.NewSource(time.Now().UnixNano()))
randomAccounts := simtypes.RandomAccounts(r, 1)

tx := NewTx(key, value, randomAccounts[0].Address)
txBytes := tx.GetSignBytes()

header := tmproto.Header{
Expand Down
Loading