-
Notifications
You must be signed in to change notification settings - Fork 267
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: Implement an in-process test core node with celestia-app and custom state #824
Conversation
Codecov Report
@@ Coverage Diff @@
## main #824 +/- ##
===========================================
- Coverage 42.00% 25.20% -16.81%
===========================================
Files 42 75 +33
Lines 4378 9225 +4847
===========================================
+ Hits 1839 2325 +486
- Misses 2390 6681 +4291
- Partials 149 219 +70
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
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.
utAck. Awesome stuff 🚀 Would be really helpful for QGB tests 🔥
testutil/testnode/node_init.go
Outdated
} | ||
|
||
cparams := types.DefaultConsensusParams() | ||
cparams.Block.TimeIotaMs = 1 |
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.
[Non Blocking][Question]
Doesn't it make sense to take the consensus params as a parameter for more flexibility?
Especially the block time, I guess it makes sense to give the user the abilitiy to change it.
Then, we can for example check if the provided consensus params are null, we initialize using the default ones.
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.
good idea 903bc0b
var latestHeight int64 | ||
for { | ||
select { | ||
case <-timeout.C: |
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.
[Non Blocking][Suggestion]
Doesn't it make sense also to check if the root context was cancelled or done?
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.
👍 96cec2a
ticker := time.NewTicker(time.Second) | ||
defer ticker.Stop() | ||
|
||
timeout := time.NewTimer(t) |
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.
[Non Blocking][Suggestion]
Doesn't it make sense to use the context with timeout? to also propagate timeouts if something happens?
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.
good point, might as well 96cec2a
|
||
// create a random msg per row | ||
pfd, err := payment.BuildPayForData( | ||
context.TODO(), |
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.
[Non Blocking][Question]
Why use the TODO context when we have a context passed func (c *Context) PostData...
?
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.
nice catch! wrote this when we didn't yet have contexts 95529af
testutil/utils.go
Outdated
func RandomValidNamespace() namespace.ID { | ||
for { | ||
s := tmrand.Bytes(8) | ||
if bytes.Compare(s, appconsts.MaxReservedNamespace) > 0 { |
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.
[Non Blocking][Question]
This one is used to create a PFD. Shouldn't we also check if the namespace is not the ns of evidence or?
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.
MaxReservedNamespace
is greater than the namespace used for transactions, intermediate state roots, or evidence so this conditional will evaluate to false
if s
matches any of those namespaces.
In other words, the returned s
should only be valid message namespaces, TailPaddingNamespaceID
or ParitySharesNamespaceID
https://github.com/celestiaorg/celestia-app/blob/main/pkg/appconsts/appconsts.go#L90-L96
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.
Sorry yes, I meant tail padding or parity. Is that alright?
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.
nice catch! 6f50ff6
return nil, err | ||
} | ||
|
||
return node.Tx(context.Background(), hash, false) |
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.
[Question][Non Blocking]
Why using the background context when we have the clientCtx
?
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.
the clientCtx doesn't actually have a context.Context in it, and I didn't want to force the testnode package as a dependency. This is good point tho
testutil/testnode/full_node.go
Outdated
// note: the passed application config is currently unused atm, but we plan to | ||
// add support. |
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.
[question] which parameter corresponds to the application config?
If present, proposal to explicitly include the parameter name in the note (because I don't think it's tmCfg
).
If no longer present, proposal to remove this note.
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.
good catch 14aca81
testutil/utils.go
Outdated
func RandomValidNamespace() namespace.ID { | ||
for { | ||
s := tmrand.Bytes(8) | ||
if bytes.Compare(s, appconsts.MaxReservedNamespace) > 0 { |
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.
MaxReservedNamespace
is greater than the namespace used for transactions, intermediate state roots, or evidence so this conditional will evaluate to false
if s
matches any of those namespaces.
In other words, the returned s
should only be valid message namespaces, TailPaddingNamespaceID
or ParitySharesNamespaceID
https://github.com/celestiaorg/celestia-app/blob/main/pkg/appconsts/appconsts.go#L90-L96
Co-authored-by: Rootul P <rootulp@gmail.com>
…very fast block times
had to skip the network test while the race detector is on, exactly like what we do for the other larger network test. a376539 |
ns := tmrand.Bytes(8) | ||
isReservedNS := bytes.Compare(ns, appconsts.MaxReservedNamespace) <= 0 | ||
isParityNS := bytes.Equal(ns, appconsts.ParitySharesNamespaceID) | ||
isTailPaddingNS := bytes.Equal(ns, appconsts.TailPaddingNamespaceID) | ||
if isReservedNS || isParityNS || isTailPaddingNS { | ||
continue | ||
} | ||
return ns |
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.
[question] Nice! There are multiple implementations of this function that may benefit from similar parity / tail padding namespace checks:
- https://github.com/rootulp/celestia-app/blob/2f26c385831048808d99f4626aa3569df18c187c/app/test_util.go#L178-L185
- https://github.com/rootulp/celestia-app/blob/2f26c385831048808d99f4626aa3569df18c187c/testutil/payment/testutil.go#L134-L141
- https://github.com/rootulp/celestia-app/blob/2f26c385831048808d99f4626aa3569df18c187c/app/test/block_size_test.go#L299-L306
- https://github.com/rootulp/celestia-app/blob/2f26c385831048808d99f4626aa3569df18c187c/pkg/prove/proof_test.go#L249-L257
It's not clear to me if these should be refactored into one function definition. Were they intentionally duplicated to avoid cyclic imports / importing across package boundaries?
…stom state (celestiaorg#824) This PR is based of the [network](https://github.com/cosmos/cosmos-sdk/tree/main/testutil/network) tests in the cosmos-sdk. Those tests are focused on running multiple nodes, while this test only runs a single node validator. This node also has the full access to change the consensus parameters and the full tendermint config. This is needed to to have block times shorter than 1 second. There is also discussion to modify the sdk code to only be a mock, where we need to run a full in process node to include any changes to tendermint and to not have to apply those same changes to the new upcoming mock node in the sdk. While this does have extra features and a built in API, it does have a lot of duplicate features to our own wrapper around the linked above network tests. Eventually we should replace the usage of that code in the integrations tests with this code. closes celestiaorg#770 Co-authored-by: Rootul P <rootulp@gmail.com>
This PR is based of the network tests in the cosmos-sdk. Those tests are focused on running multiple nodes, while this test only runs a single node validator. This node also has the full access to change the consensus parameters and the full tendermint config. This is needed to to have block times shorter than 1 second. There is also discussion to modify the sdk code to only be a mock, where we need to run a full in process node to include any changes to tendermint and to not have to apply those same changes to the new upcoming mock node in the sdk.
While this does have extra features and a built in API, it does have a lot of duplicate features to our own wrapper around the linked above network tests. Eventually we should replace the usage of that code in the integrations tests with this code.
closes #770