Repository navigation
core block height consensus - #3
QuantumExplorer wants to merge 2 commits into
Conversation
| SetOptionAsync(types.RequestSetOption) *ReqRes | ||
| DeliverTxAsync(types.RequestDeliverTx) *ReqRes | ||
| CheckTxAsync(types.RequestCheckTx) *ReqRes | ||
| CheckQuorumSignatureAsync(types.RequestCheckQuorumSignature) *ReqRes |
There was a problem hiding this comment.
We agreed to use the existing query connection and query method.
There was a problem hiding this comment.
As I was going through the code, I just can't bring myself to use the query method, it just doesn't seem clean enough to me and I couldn't find a way to make it feel clean. I switched to query connection though. If anyone feels really strongly about this please just do a PR to this branch.
There was a problem hiding this comment.
No problem. I'll do PR tomorrow.
| Signature []byte `json:"signature"` | ||
| Type tmproto.SignedMsgType | ||
| Height int64 `json:"height"` | ||
| CoreChainLockedHeight uint32 `json:"coreHeight"` |
There was a problem hiding this comment.
For JSON I do not think we should have such a long string, it seems wasteful. However it should be snake_case I think.
There was a problem hiding this comment.
I'm ok to keep it short. But you right, it must be a snake case.
BTW, I feel like it's better to add our fields to the end of structures so it will be easier to merge with upstream and see changes from our side. Any thoughts?
| func DefaultConsensusParams() *tmproto.ConsensusParams { | ||
| return &tmproto.ConsensusParams{ | ||
| Block: DefaultBlockParams(), | ||
| ChainLock: DefaultChainLockParams(), |
There was a problem hiding this comment.
We decided to move out ChainLock from ConsenusParams to just EndBlockResponse.
| AppState json.RawMessage `json:"app_state,omitempty"` | ||
| GenesisTime time.Time `json:"genesis_time"` | ||
| ChainID string `json:"chain_id"` | ||
| GenesisChainLock tmproto.ChainLock `json:"genesis_chain_lock"` |
There was a problem hiding this comment.
We define genesis params currently in JSON config file. How we should put chain lock there? https://github.com/dashevo/mn-bootstrap/blob/4275cdf8d9bc5253413c6fc087308d648e0fcffc/configs/evonet/drive/tendermint/genesis.json
| defer eventBus.Stop() | ||
|
|
||
| block := MakeBlock(0, []Tx{}, nil, []Evidence{}) | ||
| block := MakeBlock(0, 0,nil, []Tx{}, nil, []Evidence{}) |
| defer eventBus.Stop() | ||
|
|
||
| block := MakeBlock(0, []Tx{}, nil, []Evidence{}) | ||
| block := MakeBlock(0,0, nil, []Tx{}, nil, []Evidence{}) |
| tmproto "github.com/tendermint/tendermint/proto/tendermint/types" | ||
| ) | ||
|
|
||
| type ChainLock struct { |
There was a problem hiding this comment.
Hmmm, it's a chain lock, no need to say it's core.
There was a problem hiding this comment.
There are 2 chains, Tendermint and Core. Just to represent that's Core feature, not Tendermint. No?
| ) | ||
|
|
||
| type ChainLock struct { | ||
| CoreBlockHeight uint32 `json:"core_block_height,string,omitempty"` // height of Chain Lock. |
There was a problem hiding this comment.
There are 2 block heights, one core and one platform, expressing which one I think makes this more easy to understand.
There was a problem hiding this comment.
But it's a field in ChainLock structure, so it already namespaced by Core, right? It's like when you have an object core you don't name properties like core.coreBlockHeight, core.coreBestChainLock or something like this.
|
|
||
| type ChainLock struct { | ||
| CoreBlockHeight uint32 `json:"core_block_height,string,omitempty"` // height of Chain Lock. | ||
| CoreBlockHash []byte `json:"core_block_hash,string,omitempty"` // hash of Chain Lock. |
There was a problem hiding this comment.
There are 2 block hashes, one core and one platform, expressing which one I think makes this more easy to understand.
| return cl, cl.ValidateBasic() | ||
| } | ||
|
|
||
| func NewMockChainLock() ChainLock { |
There was a problem hiding this comment.
It's a chain lock, we only have 1 type in Dash
| BlockID: BlockID{block.Hash(), blockParts.Header()}, | ||
| BlockSize: block.Size(), | ||
| Header: block.Header, | ||
| HasChainLock: block.ChainLock != nil, |
|
|
||
| Header `json:"header"` | ||
| Data `json:"data"` | ||
| ChainLock *ChainLock `json:"chain_lock"` |
| // MaxHeaderBytes is a maximum header size. | ||
| MaxHeaderBytes int64 = 626 | ||
| MaxHeaderBytes int64 = 632 | ||
| MaxChainLockSize int64 = 132 |
|
|
||
| test100: | ||
| @for i in {1..100}; do make test; done | ||
| @for i in {1..100}; do make test; go clean -testcache; done |
There was a problem hiding this comment.
Have you run this test? @shumkov ? It does not work without it.
There was a problem hiding this comment.
@alexanderbez did you guys just forgot to add it in Tendermint?
| } | ||
| } | ||
|
|
||
| //if block.Header.CoreChainLockedHeight < state.LastCoreBlockHeight { |
|
|
||
| // Swap the first validator with a new one (validator set size stays the same). | ||
| header, blockID, responses := makeHeaderPartsResponsesValPubKeyChange(state, pubkey) | ||
| header, chainLock, blockID, responses := makeHeaderPartsResponsesValPubKeyChange(state, pubkey) |
| LastBlockID: types.BlockID{}, | ||
| LastBlockTime: genDoc.GenesisTime, | ||
|
|
||
| LastChainLock: lastChainLock, |
|
|
||
| // Update the state with the block and responses. | ||
| state, err = updateState(state, blockID, &block.Header, abciResponses, validatorUpdates) | ||
| state, err = updateState(state, blockID, &block.Header, block.ChainLock, abciResponses, validatorUpdates) |
There was a problem hiding this comment.
I thought we update state from EndBlockResponse.lastestChainLock, do we?
| int64 block_size = 2; | ||
| Header header = 3 [(gogoproto.nullable) = false]; | ||
| int64 num_txs = 4; | ||
| bool has_chain_lock = 5; |
There was a problem hiding this comment.
has_core_chain_lock? Btw, why do we need it meta?
| tendermint.version.Consensus version = 1 [(gogoproto.nullable) = false]; | ||
| string chain_id = 2 [(gogoproto.customname) = "ChainID"]; | ||
| int64 height = 3; | ||
| uint32 core_chain_locked_height = 4; |
There was a problem hiding this comment.
Let's do not change fields order so Tendermint headers will be still compatible which could be important for IBC. We could add our fields with some gap in indices, like since 10000
There was a problem hiding this comment.
Yes, please! Proto fields should be appended only or removed entirely.
| SetOptionAsync(types.RequestSetOption) *ReqRes | ||
| DeliverTxAsync(types.RequestDeliverTx) *ReqRes | ||
| CheckTxAsync(types.RequestCheckTx) *ReqRes | ||
| CheckQuorumSignatureAsync(types.RequestCheckQuorumSignature) *ReqRes |
|
|
||
| // ApplyBlock on the proxyApp with the last block. | ||
| func (h *Handshaker) replayBlock(state sm.State, height int64, proxyApp proxy.AppConnConsensus) (sm.State, error) { | ||
| func (h *Handshaker) replayBlock(state sm.State, height int64, proxyApp proxy.AppConnConsensus, proxyAppValidation proxy.AppConnValidation) (sm.State, error) { |
There was a problem hiding this comment.
What's the motivation for needing this argument?
There was a problem hiding this comment.
We need to pass a connection to make a query. Probably it's better to just pass the whole proxyApp since we need two connections there?
|
|
||
| lastCommit := makeCommit(height-1, valAddr) | ||
| block := types.MakeBlock(height, []types.Tx{}, lastCommit, []types.Evidence{}) | ||
| block := types.MakeBlock(height,chainLock.CoreBlockHeight, &chainLock, []types.Tx{}, lastCommit, []types.Evidence{}) |
There was a problem hiding this comment.
Why not just pass chainLock in as a single variable?
There was a problem hiding this comment.
We pass ChainLock only in case if we want to update it, otherwise, we just pass core block height from the previous block.
| // VoteInfo | ||
| message ChainLockParam { | ||
| // Note: must be greater than 0 | ||
| uint32 chain_lock_height = 1; |
There was a problem hiding this comment.
These names clobber a bit. Consider removing chain_lock prefixes from the fields.
| tendermint.version.Consensus version = 1 [(gogoproto.nullable) = false]; | ||
| string chain_id = 2 [(gogoproto.customname) = "ChainID"]; | ||
| int64 height = 3; | ||
| uint32 core_chain_locked_height = 4; |
There was a problem hiding this comment.
Yes, please! Proto fields should be appended only or removed entirely.
| LastBlockID: types.BlockID{}, | ||
| LastBlockTime: genDoc.GenesisTime, | ||
|
|
||
| LastChainLock: lastChainLock, |
|
This is being replaced by PR 5 |
Improvement/core signer2
Description
This is the initial implementation of core chain locks in Tenderdash. Core chain locks add an external source of truth to the tendermint consensus and allow for Platform Data to reference Core Chain block heights.