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
node: implement ADR-52 Tendermint Mode (reopened) #6061
node: implement ADR-52 Tendermint Mode (reopened) #6061
Conversation
Codecov Report
@@ Coverage Diff @@
## master #6061 +/- ##
==========================================
+ Coverage 60.76% 60.77% +0.01%
==========================================
Files 275 275
Lines 25345 25455 +110
==========================================
+ Hits 15401 15471 +70
- Misses 8341 8371 +30
- Partials 1603 1613 +10
|
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.
great work 👍 left a few comments
@@ -89,7 +89,7 @@ func WALGenerateNBlocks(t *testing.T, wr io.Writer, numBlocks int) (err error) { | |||
consensusState := NewState(config.Consensus, state.Copy(), blockExec, blockStore, mempool, evpool) | |||
consensusState.SetLogger(logger) | |||
consensusState.SetEventBus(eventBus) | |||
if privValidator != nil { | |||
if privValidator != nil && privValidator != (*privval.FilePV)(nil) { |
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.
???
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.
I was trying just checking nil for "no validator", but there were cases privValidator != nil
even though privValidator is empty with ModeFullNode
, maybe interface typecasting issue
so originally I added the Empty() function to the interface PrivValidator
for checking "no validator"
func (pv *FilePV) Empty() bool {
return pv == (*FilePV)(nil)
}
but then changed it simply to using config because there were too many relevant correction codes.
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.
What is the use case for having a FilePV
as empty?
privValAddress := env.PubKey.Address() | ||
_, val := vals.GetByAddress(privValAddress) | ||
|
||
// If we're still at height h, search in the current validator set. |
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.
why do we need to change this? is there a separate issue for this?
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.
this logic is for return empty ValidatorInfo
when fullnode
mode call rpc /status
I'm not implying that one or the other is necessary the right default but are we sure we want to default with |
Co-authored-by: Anton Kaliaev <anton.kalyaev@gmail.com>
That's right. So the default is fullnode mode, but |
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.
Am I missing something or are all the mode types already implemented? Or does this PR just handle the configuration aspect of it?
cmd/tendermint/commands/run_node.go
Outdated
@@ -102,6 +105,9 @@ func NewRunNodeCmd(nodeProvider nm.Provider) *cobra.Command { | |||
Use: "start", | |||
Aliases: []string{"node", "run"}, | |||
Short: "Run the tendermint node", | |||
Long: `Run the tendermint node | |||
|
|||
need to set "--mode validator" to run the node as validator`, |
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.
I do no think this additional comment is necessary. If we want to describe mode we should have a more elaborate description of all the possible values.
Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>
Thanks for the review, @alexanderbez |
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.
Hey, this is great work 🚀 . Looking forward to getting this over the line.
@@ -561,6 +586,7 @@ type P2PConfig struct { //nolint: maligned | |||
// peers. If another node asks it for addresses, it responds and disconnects. | |||
// | |||
// Does not work if the peer-exchange reactor is disabled. | |||
// automatically set true if Mode of the node is seednode | |||
SeedMode bool `mapstructure:"seed-mode"` |
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.
Do we want to consider removing this variable. I feel with the introduction of mode
, this has been made redundant. Of course you could have a validator with seed mode on but I'm leaning towards separating these i.e. either you're a validator or a seed node. What do people think?
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.
I think this depends on the p2p refactor. Did we decide to pull out the seed mode in a different binary 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.
I believe that is still up for discussion, but from the last conversations I heard, moving it to a separate binary is strong contender and there is a possibility that some part of this PR will have to adjusted for that.
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.
Hey @dongsam, we had a call yesterday and briefly discussed this, coming to the agreement that we would like to remove the SeedMode
config parameter and rely only on the new mode
parameter. This will help draw a clearer distinction between operating a seed node and a full node.
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.
As to the decision about having it as a separate binary, I'm not too familiar with what the advantages and disadvantages would be. Is it just so that is of a smaller size?
If so, then I'm on board with this. However, I would also want to keep it as part of the main Tendermint binary as convenience to me when I am spinning up test nets and what not. Since we are down this road, is there any argument for the light client to also have its own binary?
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.
I think the idea is that it's the same binary, but it runs in either a completely isolated mode -- full-node, validator, or seed-mode, but not any combo. i.e. if seed-mode is enabled, it will only run in seed-mode without full-node functionality.
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.
thanks for the discussion and the feedback, I'll make an additional commit to remove the SeedMode
config parameter and rely only on the new mode
parameter
@@ -89,7 +89,7 @@ func WALGenerateNBlocks(t *testing.T, wr io.Writer, numBlocks int) (err error) { | |||
consensusState := NewState(config.Consensus, state.Copy(), blockExec, blockStore, mempool, evpool) | |||
consensusState.SetLogger(logger) | |||
consensusState.SetEventBus(eventBus) | |||
if privValidator != nil { | |||
if privValidator != nil && privValidator != (*privval.FilePV)(nil) { |
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.
What is the use case for having a FilePV
as empty?
_, stateDB, err := initDBs(config, dbProvider) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
state, genDoc, err := LoadStateFromDBOrGenesisDocProvider(stateDB, genesisDocProvider) | ||
if err != nil { | ||
return nil, err | ||
} |
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.
_, stateDB, err := initDBs(config, dbProvider) | |
if err != nil { | |
return nil, err | |
} | |
state, genDoc, err := LoadStateFromDBOrGenesisDocProvider(stateDB, genesisDocProvider) | |
if err != nil { | |
return nil, err | |
} | |
genDoc, err := genesisDocProvider() | |
if err != nil { | |
return nil, err | |
} | |
state, err := sm.MakeGenesisState(genDoc) | |
if err != nil { | |
return nil, err | |
} |
IMO, I don't think it makes sense to have a db that just takes the state derived from genesis and is never updated so I would remove dbProvider
and just have it like this
state.Version.Consensus.Block, | ||
state.Version.Consensus.App, |
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.
I'm not too sure how full nodes handle this, but AFAICS, state is never updated. I can foresee then that there might be a problem if there is a change to the Block and/or App version where the seed node doesn't get updated and can thus no longer communicate with the block chain. I guess this would mean that the operator would also need to stop their seed node and update their genesis.
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.
Is it possible to increase the total amount of peers a seed node can have? By default, we limit it to 50 because more would use high amounts of memory, but since the seed nodes are already running with reduced memory we could increase this amount.
@marbar3778 Does the default limit value 50 mean |
Yeah I would just leave the defaults as is. If we really wanted to, we could create a default seed node config with adjusted params that gets used when starting a seed node through the command line. But for now I would just leave it. As a more general comment, I would like to get this PR in soon. @dongsam when do you think you will be able to work on this. Would be happy to help you with it if you wanted. |
@cmwaters Thank you for your words and sorry for the delay. It is being delayed because it overlaps with the Liquidity module schedule. I think I can proceed next weekend, I'd appreciate your help. |
I have created a new PR (#6241) to supersede this as I unfortunately am unable to push to the forked branch |
Description
Implementation spec of Tendermint Mode ADR-52 by B-Harvest
Add Tendermint mode
--mode
flag ontendermint node
andmode
onconfig.toml
fullnode
,validator
,seednode
]fullnode
, except testnetRefs
reopened the PR #5212
Since the last commit of the previous PR, added the following commits according to the review