Skip to content

fix: some fixes and refactoring for stabilizing same-block execution#451

Merged
shotonoff merged 31 commits intoproof-of-concept-same-block-executionfrom
same-block-execution-stabilizing
Sep 8, 2022
Merged

fix: some fixes and refactoring for stabilizing same-block execution#451
shotonoff merged 31 commits intoproof-of-concept-same-block-executionfrom
same-block-execution-stabilizing

Conversation

@shotonoff
Copy link
Collaborator

Issue being fixed or feature implemented

What was done?

How Has This Been Tested?

Breaking Changes

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have made corresponding changes to the documentation

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone


target.NextValidatorsHash = candidate.NextValidators.Hash()
if candidate.NextValidators != nil {
target.NextValidatorsHash = candidate.NextValidators.Hash()
Copy link
Collaborator

Choose a reason for hiding this comment

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

The idea here was that all fields of Candidate contain final values and already apply reasonable defaults.

It means this if should be handled somehow in populateValsetUpdates.

Maybe the issue is that populateValsetUpdates() was not called at all? Otherwise NextValidators should be derived from current state.

count int,
) (*quorumData, error) {
switch operation {
case "add":
Copy link
Collaborator

Choose a reason for hiding this comment

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

use enum or const

Copy link
Collaborator Author

@shotonoff shotonoff left a comment

Choose a reason for hiding this comment

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

feedback work done


kvVals, err = kvstore.ValidatorSet()
require.Equal(t, initVals.QuorumHash, resp.ValidatorSetUpdate.QuorumHash)
_, err = kvstore.FinalizeBlock(ctx, &types.RequestFinalizeBlock{Height: 1, AppHash: resp.AppHash})
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I didn't use makeApplyBlock because of I need a process proposal response to check a quorum-hash.
I a bit refactored makeApplyBlock to return responses of process-proposal and finalize-block

cfg: cfg,
nPeers: nPeers,
nVals: nVals,
testName: "replay_test",
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I removed testName field, instead I use t.Name() inside generate method

logger: logger.With("module", "kvstore"),
lastCommittedState: loadState(db),
roundStates: map[string]State{},
validatorSetUpdates: make(map[int64]types.ValidatorSetUpdate),
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

as I see storing validator-set-updates in memory is enough to pass tests (so far), let's postpone it until it will be necessary, wdyt?

target.LastResultsHash = candidate.ResultsHash

target.ConsensusParams = candidate.NextConsensusParams
if !candidate.NextConsensusParams.IsZero() {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

good thoughts for investigation

@shotonoff shotonoff requested a review from lklimek September 7, 2022 13:10
status := ResponseVerifyVoteExtension_REJECT
if ok {
status = ResponseVerifyVoteExtension_ACCEPT
func (m *ValidatorSetUpdate) MarshalJSON() ([]byte, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe for m==nil, we should return json.Marshal(nil) ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

not necessary, if a pointer is nill then a result of marshalling will be nil as well

Copy link
Collaborator

Choose a reason for hiding this comment

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

got "marshaling error: json: error calling MarshalJSON for type *types.ValidatorSetUpdate: fromproto: key is nil"

NodeAddress string `json:"node_address"`
}

func (m *ValidatorUpdate) MarshalJSON() ([]byte, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe for m==nil, we should return json.Marshal(nil) ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

answered above

func (g *nodeGen) initApp(ctx context.Context, t *testing.T) {
if g.app == nil {
g.app = kvstore.NewApplication()
g.app = kvstore.NewApplication(kvstore.WithLogger(log.NewNopLogger()))
Copy link
Collaborator

Choose a reason for hiding this comment

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

NewNopLogger should be a default value, no need to use WithLogger in this case.

And, I think it should be NewTestLogger()

lklimek and others added 7 commits September 7, 2022 17:13
Co-authored-by: lklimek <842586+lklimek@users.noreply.github.com>
Co-authored-by: lklimek <842586+lklimek@users.noreply.github.com>
Co-authored-by: lklimek <842586+lklimek@users.noreply.github.com>
@shotonoff shotonoff merged commit 74c0aac into proof-of-concept-same-block-execution Sep 8, 2022
@shotonoff shotonoff deleted the same-block-execution-stabilizing branch September 8, 2022 07:57
lklimek added a commit that referenced this pull request Sep 9, 2022
* refactor: decouple dash parameters from a MakeBlock function to a Block.SetDashParams method

* feat: add node's pro-rtx-hash into a context

* feat: add proTxHash into context for consensus/reactor_test.go

* feat: some modifications for PoC same-block execution

* feat: change an updated struct from round state on uncommitted-state

* feat: support next-validators as for next-block execution mode

* feat: support next-validators for same-block execution mode

* feat: some modifications for next-core-lock

* chore: same block execution state/state_test.go (WIP)

* test(state): fix TestManyValidatorChangesSaveLoad()

* fix(state): panic on empty consensus params load

* chore(state): remove state.NextValidators

* chore(proto/abci): same block execution protobuf changes

* refactor(types): centralize generation of ResultsHash

* refactor(state): consolidate redundant code in block execution

* chore(state) execution fix for new data structures

* test(state): adapt TestProposerPriorityProposerAlternates for same block exec

* test(state): same block exec TestFourAddFourMinusOneGenesisValidators

* test(state): same block exec TestStoreLoadValidatorsIncrementsProposerPriority

* test(state): same block exec for TestManyValidatorChangesSaveLoad

* fix(state): same block exec TestConsensusParamsChangesSaveLoad

* test(state): fix TestProcessProposal

* chore(state): correct handling of ApplyBlock etc

* test(mempool): builds but fails

* refactor(state): UncommittedState now holds final values instead of updates

This was needed for clean implementation of NextValidatorsHash

* refactor(state): rename UncommittedChanges to Changeset

* chore: same block exec - block

* chore(state): state ID - start of work

* chore: SBE - block fields (WIP)

* chore: SBE chainlocks and proposed app version (WIP)

* test(state): SBE green (execution|state|validation)_test

* chore(abci): improve validation of prepare/process proposal responses

* chore(state): apphash defaults to array containing zeros

* test(state): TestStoreLoadValidators fixed for SBE

* chore(state): AppHash defaults to slice of 0s instead of nil

* chore(state): fix invalid state.LastStateID

* test(state): SBE TestPruneStates

* test(state): fix rollback_test

* fix(abci): correct handling of AppHash in Application

* test(store): update for SBE

* chore(types): rename stateID.LastAppHash to AppHash

* refactor(statesync): state provider returns AppHash as HexBytes

* test(statesync): fix for SBE

* test(consensus): show test logs on console

* test(consensus): fix byzantine test

* test(blocksync): update for SBE

* fix(state): events fired twice

* fix(consensus): proposal contains invalid chainlock height

* test(consensus): correct chainlock in initial block in SBE

* Update abci/example/kvstore/kvstore.go

Co-authored-by: lklimek <842586+lklimek@users.noreply.github.com>

* Update abci/example/kvstore/kvstore.go

Co-authored-by: lklimek <842586+lklimek@users.noreply.github.com>

* fix(state): double commits during replay

* test(consensus): fix replay handshake* tests (WIP)

* fix: evidence package

* fix: validator_conn_executor_test.go

* refactor: executing kvstore

* feat!(kvstore): same-block-execution KV store (#447)

* feat!(kvstore): same-block-execution KV store

* fix(kvstore): dstIter not closed correctly

* fix(kvstore): AppHash at genesis should be zero

* fix(kvstore): SBE support for persistent KV store (#452)

* test(proxy): fix test of Info()

* fix: some fixes and refactoring for stabilizing same-block execution (#451)

* fix: some fixes and refactoring for stabilizing same-block execution

* refactor: merge kvstore.App with kvstore.Application and remove kvstore_v2.go

* fix: kvstore_test.go

* fix: TestValUpdates

* fix: TestValUpdates

* fix: TestKVStore

* fix: rpc/client tests

* fix: make stable some tests affected by kvstore refactoring

* fix: update uncommitted state if a validator out of quorum set and a node has proposal block for the height

* Update internal/consensus/replay_test.go

Co-authored-by: lklimek <842586+lklimek@users.noreply.github.com>

* refactor: changes according to PR feedback

* fix: blocking wal_test.go because of default context

* fix: code style issues

* fix: abci-cli test

* fix: typo in struct name CurentRoundState => CurrentRoundState

* fix: a few data race issues

* fix: TestHandshakeReplayNone

* fix: ValidatorUpdate.MarshalJSON

* fix: ValidatorUpdate.UnmarshalJSON

* chore(e2e): prototype e2e test app for same-block execution

* fix(consensus): state is nil on genesis

* fix(state): invalid stateID height on genesis

* chore: improve logging

* Update abci/tests/server/client.go

Co-authored-by: lklimek <842586+lklimek@users.noreply.github.com>

* Update abci/tests/server/client.go

Co-authored-by: lklimek <842586+lklimek@users.noreply.github.com>

* Update internal/proxy/client_test.go

Co-authored-by: lklimek <842586+lklimek@users.noreply.github.com>

* refactor: changes according to PR feedback

Co-authored-by: lklimek <842586+lklimek@users.noreply.github.com>

* fix: stabilize codebase after merge / resolve conflicts

Co-authored-by: Lukasz Klimek <842586+lklimek@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants