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

WIP: embeds timeouts in abci calls #1494

Draft
wants to merge 10 commits into
base: v0.34.x-celestia
Choose a base branch
from
881 changes: 614 additions & 267 deletions abci/types/types.pb.go

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions consensus/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,8 @@ func (cs *State) updateToState(state sm.State) {
cs.CommitRound = -1
cs.LastValidators = state.LastValidators
cs.TriggeredTimeoutPrecommit = false
cs.config.TimeoutPropose = state.GetTimeoutPropose()
cs.config.TimeoutCommit = state.GetTimeoutCommit()

cs.state = state

Expand Down
5 changes: 3 additions & 2 deletions node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -837,7 +837,7 @@ func NewNode(config *cfg.Config,
}

// Reload the state. It will have the Version.Consensus.App set by the
// Handshake, and may have other modifications as well (ie. depending on
// Handshake, and may have other modifications as well (i.e., depending on
// what happened during block replay).
state, err = stateStore.Load()
if err != nil {
Expand All @@ -852,7 +852,8 @@ func NewNode(config *cfg.Config,
}

// Determine whether we should do fast sync. This must happen after the handshake, since the
// app may modify the validator set, specifying ourself as the only validator.
// app may modify the validator set,
//specifying ourselves as the only validator.
fastSync := config.FastSyncMode && !onlyValidatorIsUs(state, pubKey)

logNodeStartupInfo(state, pubKey, logger, consensusLogger)
Expand Down
9 changes: 9 additions & 0 deletions proto/tendermint/abci/types.proto
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import "tendermint/crypto/keys.proto";
import "tendermint/types/params.proto";
import "google/protobuf/timestamp.proto";
import "gogoproto/gogo.proto";
import "google/protobuf/duration.proto";

// This file is copied from http://github.com/tendermint/abci
// NOTE: When using custom types, mind the warnings.
Expand Down Expand Up @@ -47,6 +48,11 @@ message RequestEcho {

message RequestFlush {}

message TimeoutsInfo {
google.protobuf.Duration timeout_propose = 1 [(gogoproto.nullable) = false, (gogoproto.stdduration) = true];
google.protobuf.Duration timeout_commit = 2 [(gogoproto.nullable) = false, (gogoproto.stdduration) = true];
}

message RequestInfo {
string version = 1;
uint64 block_version = 2;
Expand Down Expand Up @@ -193,6 +199,8 @@ message ResponseInfo {

int64 last_block_height = 4;
bytes last_block_app_hash = 5;

TimeoutsInfo timeouts = 6;
}

// nondeterministic
Expand Down Expand Up @@ -264,6 +272,7 @@ message ResponseEndBlock {
ConsensusParams consensus_param_updates = 2;
repeated Event events = 3
[(gogoproto.nullable) = false, (gogoproto.jsontag) = "events,omitempty"];
TimeoutsInfo timeouts = 4;
}

message ResponseCommit {
Expand Down
8 changes: 4 additions & 4 deletions proto/tendermint/store/types.proto
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ message BlockStoreState {
// TxInfo describes the location of a tx inside a committed block
// as well as the result of executing the transaction and the error log output.
message TxInfo {
int64 height = 1;
uint32 index = 2;
int64 height = 1;
uint32 index = 2;
// The response code of executing the tx. 0 means
// successfully executed, all others are error codes.
uint32 code = 3;
uint32 code = 3;
// The error log output generated if the transaction execution fails.
string error = 4;
string error = 4;
}
10 changes: 7 additions & 3 deletions state/execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ func updateState(
if err != nil {
return state, fmt.Errorf("error changing validator set: %v", err)
}
// Change results from this height but only applies to the next next height.
// Change results from this height but only applies to the next height.
lastHeightValsChanged = header.Height + 1 + 1
}

Expand Down Expand Up @@ -553,7 +553,7 @@ func updateState(

// NOTE: the AppHash has not been populated.
// It will be filled on state.Save.
return State{
s := State{
Version: nextVersion,
ChainID: state.ChainID,
InitialHeight: state.InitialHeight,
Expand All @@ -568,7 +568,11 @@ func updateState(
LastHeightConsensusParamsChanged: lastHeightParamsChanged,
LastResultsHash: ABCIResponsesResultsHash(abciResponses),
AppHash: nil,
}, nil
timeoutCommit: abciResponses.EndBlock.Timeouts.TimeoutCommit,
timeoutPropose: abciResponses.EndBlock.Timeouts.TimeoutPropose,
}

return s, nil
}

// Fire NewBlock, NewBlockHeader.
Expand Down
11 changes: 11 additions & 0 deletions state/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,17 @@ type State struct {

// the latest AppHash we've received from calling abci.Commit()
AppHash []byte

// timeouts received from app, after abci EndBlock call, to be used in the next height
timeoutPropose time.Duration
timeoutCommit time.Duration
}

func (state *State) GetTimeoutPropose() time.Duration {
return state.timeoutPropose
}
func (state *State) GetTimeoutCommit() time.Duration {
return state.timeoutCommit
}

// Copy makes a copy of the State for mutating.
Expand Down
Loading