Skip to content

Commit

Permalink
Merge pull request #144 from skalenetwork/fix-validator-id-by-address
Browse files Browse the repository at this point in the history
Fix validator id by address
  • Loading branch information
badrogger authored Apr 16, 2020
2 parents 7748953 + 0617262 commit a937df2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
ETH_PRIVATE_KEY: ${{ secrets.ETH_PRIVATE_KEY }}
ENDPOINT: ${{ secrets.ENDPOINT }}
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
MANAGER_BRANCH: "beta"
MANAGER_TAG: "1.1.1-stable.0"
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
Expand Down
6 changes: 3 additions & 3 deletions scripts/deploy_manager.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
set -e

: "${ETH_PRIVATE_KEY?Need to set ETH_PRIVATE_KEY}"
: "${MANAGER_BRANCH?Need to set MANAGER_BRANCH}"
: "${MANAGER_TAG?Need to set MANAGER_TAG}"

export DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
export DOCKER_NETWORK_ENDPOINT=http://ganache:8545
Expand All @@ -15,13 +15,13 @@ docker run -d --network testnet -p 8545:8545 -p 8546:8546 \
--name ganache trufflesuite/ganache-cli:beta \
--account="0x${ETH_PRIVATE_KEY},100000000000000000000000000" -l 80000000 -b 1

docker pull skalenetwork/skale-manager:$MANAGER_BRANCH-latest
docker pull skalenetwork/skale-manager:$MANAGER_TAG
docker run \
-v $DIR/contracts_data:/usr/src/manager/data \
--network testnet \
-e ENDPOINT=$DOCKER_NETWORK_ENDPOINT \
-e PRIVATE_KEY=$ETH_PRIVATE_KEY \
skalenetwork/skale-manager:$MANAGER_BRANCH-latest \
skalenetwork/skale-manager:$MANAGER_TAG \
npx truffle migrate --network unique

cp $DIR/contracts_data/unique.json $DIR/../test_abi.json
14 changes: 11 additions & 3 deletions skale/contracts/delegation/validator_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,16 @@ def is_main_address(self, validator_address: str) -> bool:
:returns: True if provided address is the main validator address, otherwise False
:rtype: bool
"""
validator_id = self.validator_id_by_address(validator_address)
validator = self.get(validator_id)
if not self.validator_address_exists(validator_address):
return False

try:
# TODO: handle address that is not main in a proper way
validator_id = self.validator_id_by_address(validator_address)
validator = self.get(validator_id)
except Exception:
return False

return validator_address == validator['validator_address']

def validator_address_exists(self, validator_address: str) -> bool:
Expand All @@ -127,7 +135,7 @@ def validator_id_by_address(self, validator_address: str) -> int:
:returns: Validator ID
:rtype: int
"""
return self.contract.functions.getValidatorIdByNodeAddress(validator_address).call()
return self.contract.functions.getValidatorId(validator_address).call()

def get_trusted_validator_ids(self) -> list:
"""Returns list of trusted validators id.
Expand Down

0 comments on commit a937df2

Please sign in to comment.