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

add modifier to EntitlementChecker to only allow registered operator to be checkers #80

Merged
merged 13 commits into from
Jun 5, 2024

Conversation

giuseppecrj
Copy link
Contributor

@giuseppecrj giuseppecrj commented May 28, 2024

@giuseppecrj giuseppecrj marked this pull request as ready for review May 31, 2024 21:26
Copy link
Contributor

@clemire clemire left a comment

Choose a reason for hiding this comment

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

At a v high level, this looks fine to me - but I don't know what's going on in a lot of / most of this PR, so I'm not sure I'm the best person to approve it. If you can't get someone else, let me know if you want to jump on a call.

request for changes for a nit.

@giuseppecrj
Copy link
Contributor Author

At a v high level, this looks fine to me - but I don't know what's going on in a lot of / most of this PR, so I'm not sure I'm the best person to approve it. If you can't get someone else, let me know if you want to jump on a call.

request for changes for a nit.

@clemire The main component that's either missing or I'm not able to asses is whether or not we're registering operators prior to calling registerNode on the entitlement checker contract. If not, any calls to registerNode will fail on tests.

cc. @brianathere

@giuseppecrj giuseppecrj requested a review from clemire June 3, 2024 15:20
@clemire clemire requested a review from sergekh2 as a code owner June 3, 2024 16:58
@giuseppecrj giuseppecrj requested a review from brianathere June 4, 2024 00:39
@@ -53,7 +53,7 @@ contract EntitlementChecker is IEntitlementChecker, Facet {
* @param node The address of the node to register
* @dev Only valid operators can register a node
*/
function registerNode(address node) external {
function registerNode(address node) external onlyRegisteredOperator {
Copy link
Contributor

Choose a reason for hiding this comment

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

You'll need to change files like core/node/crypto/chain_txpool_test.go to work with this modifier. Specifically lines like:

return tc.NodeRegistry.RegisterNode(opts, nodeWallet.Address, url, 2)

need to use the operator wallet instead of the deployer wallet:

txPool, err := crypto.NewTransactionPoolWithPolicies(
ctx, tc.Client(), tc.DeployerBlockchain.Wallet, resubmitPolicy, repricePolicy, tc.ChainMonitor)
require.NoError(err, "unable to construct transaction pool")

@@ -59,6 +59,8 @@ BASE_DIR="./run_files/${RUN_ENV}"

mkdir -p "${BASE_DIR}"

source ../../contracts/.env.localhost
Copy link
Contributor

Choose a reason for hiding this comment

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

@brianathere I made the following changes to get xchain to properly register itself on startup, to mimic how stream node registers when the service is being launched (using the same wallet as the operator address), but was unsuccessful.

Copy link
Contributor

@clemire clemire Jun 4, 2024

Choose a reason for hiding this comment

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

Right now xchain isn't launching, and it's failing on the registration step. This is why the sdk tests for space admission that require xchain in the loop are failing.

@bas-vk
Copy link
Contributor

bas-vk commented Jun 5, 2024

I have added 2 steps that first register a node operator and that operator than registeres the xchain nodes. Not sure if this is the best place for it because running the script a second time will now give an error because it tries to register an operator/node for the second time. For CI that isn't an issue, for development it can be annoying.

BASE_DIR="${RUN_FILES_DIR}/${RUN_ENV}"
BASE_REGISTRY_ADDRESS=$(jq -r '.address' ../../packages/generated/deployments/local_single/base/addresses/baseRegistry.json)
OPERATOR_ADDRESS=$(cast wallet addr $LOCAL_PRIVATE_KEY)
Copy link
Contributor

@texuf texuf Jun 5, 2024

Choose a reason for hiding this comment

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

you can't hard code local_single here - you need to respect the RUN_ENV

Copy link
Contributor

Choose a reason for hiding this comment

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

just change this to

BASE_REGISTRY_ADDRESS=$(jq -r '.address' ../../packages/generated/deployments/${RIVER_ENV}/base/addresses/baseRegistry.json)

but it doesn't seem to fix it

Copy link
Contributor

@texuf texuf left a comment

Choose a reason for hiding this comment

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

i can look through this in more detail after 9:00

@texuf
Copy link
Contributor

texuf commented Jun 5, 2024

I have added 2 steps that first register a node operator and that operator than registeres the xchain nodes. Not sure if this is the best place for it because running the script a second time will now give an error because it tries to register an operator/node for the second time. For CI that isn't an issue, for development it can be annoying.

yes, can you move these calls to the create_multi.sh script and fix the hard coded local_single (change to ${RIVER_ENV})?

@texuf
Copy link
Contributor

texuf commented Jun 5, 2024

I have added 2 steps that first register a node operator and that operator than registeres the xchain nodes. Not sure if this is the best place for it because running the script a second time will now give an error because it tries to register an operator/node for the second time. For CI that isn't an issue, for development it can be annoying.

yes, can you move these calls to the create_multi.sh script and fix the hard coded local_single (change to ${RIVER_ENV})?

Actually there are several things that need to happen for this to work, i will update this pr

@giuseppecrj giuseppecrj merged commit c1854e4 into main Jun 5, 2024
9 checks passed
@giuseppecrj giuseppecrj deleted the g/gate-entitlementchecker-register branch June 5, 2024 21:10
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.

5 participants