diff --git a/bigchaindb/core.py b/bigchaindb/core.py index 67b48df5..45f04824 100644 --- a/bigchaindb/core.py +++ b/bigchaindb/core.py @@ -54,7 +54,7 @@ class App(BaseApplication): validator_set = [vutils.decode_validator(v) for v in genesis.validators] block = Block(app_hash='', height=0, transactions=[]) self.bigchaindb.store_block(block._asdict()) - self.bigchaindb.store_validator_set(1, validator_set) + self.bigchaindb.store_validator_set(1, validator_set, '') return ResponseInitChain() def info(self, request): diff --git a/bigchaindb/lib.py b/bigchaindb/lib.py index e75153d5..170550ea 100644 --- a/bigchaindb/lib.py +++ b/bigchaindb/lib.py @@ -432,13 +432,14 @@ class BigchainDB(object): def store_pre_commit_state(self, state): return backend.query.store_pre_commit_state(self.connection, state) - def store_validator_set(self, height, validators): + def store_validator_set(self, height, validators, election_id): """Store validator set at a given `height`. NOTE: If the validator set already exists at that `height` then an exception will be raised. """ return backend.query.store_validator_set(self.connection, {'height': height, - 'validators': validators}) + 'validators': validators, + 'election_id': election_id}) Block = namedtuple('Block', ('app_hash', 'height', 'transactions')) diff --git a/bigchaindb/upsert_validator/validator_election.py b/bigchaindb/upsert_validator/validator_election.py index 89e60335..6509f648 100644 --- a/bigchaindb/upsert_validator/validator_election.py +++ b/bigchaindb/upsert_validator/validator_election.py @@ -227,7 +227,7 @@ class ValidatorElection(Transaction): validator_updates) updated_validator_set = [v for v in updated_validator_set if v['voting_power'] > 0] - bigchain.store_validator_set(new_height+1, updated_validator_set) + bigchain.store_validator_set(new_height+1, updated_validator_set, election.id) return [encode_validator(election.asset['data'])] return [] diff --git a/tests/tendermint/test_core.py b/tests/tendermint/test_core.py index 6887264c..40958aa2 100644 --- a/tests/tendermint/test_core.py +++ b/tests/tendermint/test_core.py @@ -237,7 +237,7 @@ def test_new_validator_set(b): validators = [node1] updates = [node1_new_power, node2] - b.store_validator_set(1, validators) + b.store_validator_set(1, validators, 'election_id') updated_validator_set = new_validator_set(b.get_validators(1), updates) updated_validators = [] diff --git a/tests/upsert_validator/conftest.py b/tests/upsert_validator/conftest.py index 4a1b6925..b5dde04e 100644 --- a/tests/upsert_validator/conftest.py +++ b/tests/upsert_validator/conftest.py @@ -71,7 +71,8 @@ def inconclusive_election(b, concluded_election, new_validator): validators = b.get_validators(height=1) validators[0]['voting_power'] = 15 validator_update = {'validators': validators, - 'height': 3} + 'height': 3, + 'election_id': 'some_other_election'} query.store_validator_set(b.connection, validator_update) return concluded_election diff --git a/tests/upsert_validator/test_validator_election_vote.py b/tests/upsert_validator/test_validator_election_vote.py index 19eacbfa..f829c853 100644 --- a/tests/upsert_validator/test_validator_election_vote.py +++ b/tests/upsert_validator/test_validator_election_vote.py @@ -368,4 +368,4 @@ def reset_validator_set(b, node_keys, height): validators.append({'pub_key': {'type': 'ed25519', 'data': node_pub}, 'voting_power': 10}) - b.store_validator_set(height, validators) + b.store_validator_set(height, validators, 'election_id') diff --git a/tests/web/test_validators.py b/tests/web/test_validators.py index 714ceee4..52420828 100644 --- a/tests/web/test_validators.py +++ b/tests/web/test_validators.py @@ -14,7 +14,7 @@ def test_get_validators_endpoint(b, client): 'pub_key': {'data': '4E2685D9016126864733225BE00F005515200727FBAB1312FC78C8B76831255A', 'type': 'ed25519'}, 'voting_power': 10}] - b.store_validator_set(23, validator_set) + b.store_validator_set(23, validator_set, 'election_id') res = client.get(VALIDATORS_ENDPOINT) assert is_validator(res.json[0])