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

feat: Adds validator qgb checks #137

Conversation

rach-id
Copy link
Member

@rach-id rach-id commented May 5, 2022

Adds to #114

@rach-id rach-id added enhancement New feature or request C: QGB labels May 5, 2022
@rach-id rach-id self-assigned this May 5, 2022
@rach-id rach-id marked this pull request as draft May 5, 2022 22:29
@rach-id rach-id changed the title Adds validator qgb checks feat: WIP Adds validator qgb checks May 5, 2022
@rach-id rach-id force-pushed the adds_validator_qgb_checks branch from 44be9c7 to b6fbf3a Compare May 6, 2022 12:46
…ecks

# Conflicts:
#	client/flags/flags.go
#	simapp/simd/cmd/testnet.go
#	x/staking/simulation/operations.go
@rach-id rach-id requested a review from evan-forbes May 6, 2022 15:49
@rach-id rach-id marked this pull request as ready for review May 6, 2022 15:49
@rach-id rach-id changed the title feat: WIP Adds validator qgb checks feat: Adds validator qgb checks May 6, 2022
@rach-id rach-id force-pushed the adds_validator_qgb_checks branch 3 times, most recently from 580e41c to 0ff3aed Compare May 7, 2022 07:50
Copy link
Member Author

@rach-id rach-id left a comment

Choose a reason for hiding this comment

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

🤔

@@ -14,7 +14,7 @@ import (

// SimAppChainID hardcoded chainID for simulation
const (
DefaultGenTxGas = 1000000
DefaultGenTxGas = 4000000 // An increase is needed when adding checks to staking/msg_server.go
Copy link
Member Author

@rach-id rach-id May 7, 2022

Choose a reason for hiding this comment

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

a 2.6x increase in gas for couple fields and few checks doesn't look so right to me. What do you think?

@rach-id
Copy link
Member Author

rach-id commented May 7, 2022

@evan-forbes When you have time, please take a look on: https://github.com/celestiaorg/cosmos-sdk/runs/6333164562?check_suite_focus=true why it is failing. I can't understand why the app hash changes while running the same app.

@adlerjohn
Copy link
Member

The app hash isn't just different, it's not even valid hex!

"\xceX\xfb|\\|\x97F\x10\xc6\xf5\x12i7\xd6\x17S\x98\r\xc9\x130\x03R\xc1\x97\xad\xb7R\x01\xb8\xfa"

if msg.Orchestrator != "" {
_, err := k.validateOrchestratorAddress(ctx, msg.Orchestrator)
Copy link
Member

Choose a reason for hiding this comment

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

Are you sure you want to error when a validator exists if you're trying to edit it?

Copy link
Member Author

Choose a reason for hiding this comment

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

We don't want to have duplicate orchestrator or Ethereum address. If some other validatore has that address, we shouldnt continue. No?

Copy link
Member

Choose a reason for hiding this comment

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

For inserting a new validator, yes. But editing a validator (not sure what that even means?) requires the validator to exist prior to being edited, no?

Copy link
Member Author

@rach-id rach-id May 9, 2022

Choose a reason for hiding this comment

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

We look first if the validator exists by its address. Then, we start checking if the new orchestrator address has been given to some other validator.
So, that one is looking for a validator by orchestrator address. If any other validator has that orchestrator address, we stop.
Or I am missing something

Copy link
Member

@evan-forbes evan-forbes May 9, 2022

Choose a reason for hiding this comment

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

I think this makes sense, we want to throw an error if someone is trying to update their vaildator with an invalid orchestrator address. If we don't, then we won't be able to verify their attestations, and while it wouldn't be protocol breaking, I think it would be a terrible UX, as they'd have to debug why they can't submit signatures.

we're also checking that the validator exists on line 143

Copy link
Member Author

@rach-id rach-id left a comment

Choose a reason for hiding this comment

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

The latest commits are for debugging purposes (mainly commenting code to find the problematic change). The history will be cleaned with a force push.

@@ -146,7 +148,9 @@ func SimulateMsgCreateValidator(ak types.AccountKeeper, bk types.BankKeeper, k k
simtypes.RandomDecAmount(r, maxCommission),
)

ethAddr, _ := types.NewEthAddress("0x91DEd26b5f38B065FC0204c7929Da6b2A21277Cd")
ethPrivateKey, _ := crypto.GenerateKey()
Copy link
Member Author

Choose a reason for hiding this comment

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

This is probably what's making the app hash fail. Investigating more.

@rach-id rach-id force-pushed the adds_validator_qgb_checks branch from a40e31b to fd79550 Compare May 9, 2022 11:40
@rach-id
Copy link
Member Author

rach-id commented May 9, 2022

@evan-forbes If you agree on the eth address fix. we can merge.

ethAddr, _ := types.NewEthAddress("0x" + fmt.Sprintf("%X", doubleOrchAddressBytes[:(types.ETHContractAddressLen/2)-2]))
ethAddr, _ := types.NewEthAddress("0x" + fmt.Sprintf("%X", doubleOrchAddressBytes[:(types.ETHContractAddressLen/2)-1]))
Copy link
Member

Choose a reason for hiding this comment

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

evan is confused why we are making doubleOrchAddress in the first place?

Copy link
Member

Choose a reason for hiding this comment

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

and perhaps we should not be using the golang's hex formatting tooling, and instead be using geth's

Copy link
Member Author

Choose a reason for hiding this comment

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

Great catch. fix coming.

Copy link
Member Author

Choose a reason for hiding this comment

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

and perhaps we should not be using the golang's hex formatting tooling, and instead be using geth's

It is the same. Just creating a hex string from a bytes array

Copy link
Member Author

Choose a reason for hiding this comment

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

check now again please.

Copy link
Member

@evan-forbes evan-forbes left a comment

Choose a reason for hiding this comment

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

After a quick sync with @sweexordious, the main issue is simply that we are randomly generating the address each time, which cause the non-determinism issue. It also doesn't help that the gravity bridge code uses their own custom type for an eth address instead of using a wrapper around geth's Address type.

@sweexordious is currently writing an issue or two with a bit more context. With those reminders in place, I'm comfortable with merging, as we might not even use this method to keep track of orchestrator/eth addresses, so making another huge PR(s) just to properly fix the tests seems wasteful atm.

great work debugging @sweexordious !!

@rach-id
Copy link
Member Author

rach-id commented May 9, 2022

Issues created: #143 and #144

@rach-id rach-id merged commit d9dc2cd into celestiaorg:rachid/orchestrator-address May 9, 2022
@rach-id rach-id deleted the adds_validator_qgb_checks branch May 9, 2022 14:48
rach-id added a commit to rach-id/cosmos-sdk that referenced this pull request May 9, 2022
* first pass on tests fixes

* fixes the rest of unit tests

* remove unnecessary comments

* uses default eth address when starting sim network

* cosmetics

* comments failing test

* comments failing test

* adds orchestrator/ethereum address checks for validators when creating and editing

* uses correct error codes for eth/orch address errors

* uncomments test and fixes it from commit 434b308

* adds zero eth address check when creating/updating validator

* attempts to fix duplicate eth address in sim network

* revert squashed changes

* uses unwrapped context for msg_server orch/eth validation

* increase DefaultGenTxGas to accomodate new qgb validator changes

* scaffolds an ethereum address from orchestrator address in staking simulation to have a deterministic way of creating it

* fix eth address creation from orch address in operations

* increase DefaultGenTxGas

* increase DefaultGenTxGas

* simpler way of creating an eth address from orch address in operations
rach-id added a commit to rach-id/cosmos-sdk that referenced this pull request Jul 27, 2022
* first pass on tests fixes

* fixes the rest of unit tests

* remove unnecessary comments

* uses default eth address when starting sim network

* cosmetics

* comments failing test

* comments failing test

* adds orchestrator/ethereum address checks for validators when creating and editing

* uses correct error codes for eth/orch address errors

* uncomments test and fixes it from commit 434b308

* adds zero eth address check when creating/updating validator

* attempts to fix duplicate eth address in sim network

* revert squashed changes

* uses unwrapped context for msg_server orch/eth validation

* increase DefaultGenTxGas to accomodate new qgb validator changes

* scaffolds an ethereum address from orchestrator address in staking simulation to have a deterministic way of creating it

* fix eth address creation from orch address in operations

* increase DefaultGenTxGas

* increase DefaultGenTxGas

* simpler way of creating an eth address from orch address in operations
rach-id added a commit to rach-id/cosmos-sdk that referenced this pull request Aug 4, 2022
* first pass on tests fixes

* fixes the rest of unit tests

* remove unnecessary comments

* uses default eth address when starting sim network

* cosmetics

* comments failing test

* comments failing test

* adds orchestrator/ethereum address checks for validators when creating and editing

* uses correct error codes for eth/orch address errors

* uncomments test and fixes it from commit 434b308

* adds zero eth address check when creating/updating validator

* attempts to fix duplicate eth address in sim network

* revert squashed changes

* uses unwrapped context for msg_server orch/eth validation

* increase DefaultGenTxGas to accomodate new qgb validator changes

* scaffolds an ethereum address from orchestrator address in staking simulation to have a deterministic way of creating it

* fix eth address creation from orch address in operations

* increase DefaultGenTxGas

* increase DefaultGenTxGas

* simpler way of creating an eth address from orch address in operations
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: QGB enhancement New feature or request
Projects
No open projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants