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: add service provider address to config #93

Merged
merged 7 commits into from
Nov 22, 2024

Conversation

jahabeebs
Copy link
Collaborator

🤖 Linear

Closes GRT-229

Description

  • Protocol provider config schema includes accessControl.serviceProviderAddress object + property.
    -serviceProviderAddress can be unspecified/undefined.
  • If serviceProviderAddress is unspecified, the address can be derived from the PROTOCOL_PROVIDER_PRIVATE_KEY value
  • ProtocolProvider stores the new address within its instance to use it later

Tests for now don't cover the actual use of this value as that will come next

@jahabeebs jahabeebs self-assigned this Nov 20, 2024
Copy link

linear bot commented Nov 20, 2024

Copy link
Collaborator

@0xyaco 0xyaco left a comment

Choose a reason for hiding this comment

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

Left some comments! I strongly suggest reading them all before addressing them one by one, they are all kinda linked so it might be more helpful to do so.

As a short summary:

  • No env var needed for this
  • ProtocolProvider instances should get the new address via its constructor
  • You'll probably have to update ProtocolProvider instantiation in the agent + scripts

Comment on lines 187 to 188
const account = privateKeyToAccount(privateKey);
this.serviceProviderAddress = account.address;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nice 😎

Comment on lines 74 to 76
accessControl?: {
serviceProviderAddress: Address;
};
Copy link
Collaborator

Choose a reason for hiding this comment

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

The service provider address should be a ProtocolProvider constructor stand-alone argument, like the private key (but optional in this case).

The value per se is not related with the RPCs' configuration.

@@ -55,6 +68,7 @@ const protocolProviderConfigSchema = z.object({
bondEscalationModule: addressSchema,
horizonAccountingExtension: addressSchema,
}),
accessControl: accessControlSchema.optional(),
Copy link
Collaborator

Choose a reason for hiding this comment

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

If we specify the accessControl property here (which is good, it's what we want), the user needs to include the accessControl object within the protocolProvider object in the config YAML file.

protocolProvider:
  rpcsConfig: ...
  contracts: ...
  accessControl:
    serviceProviderAddress: 0x....

Thus we don't need the env var.

Remember that as a general approach, we generally want public values to be in the config YAML file and secrets to be in env vars.

Comment on lines 71 to 73
accessControl: envData.SERVICE_PROVIDER_ADDRESS
? { serviceProviderAddress: envData.SERVICE_PROVIDER_ADDRESS }
: undefined,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Given that the service provider address will already be in configData, we won't be using envData anymore. You should be able to safely remove this!

@@ -38,6 +38,7 @@ cp .env.example .env
| `BLOCK_NUMBER_BLOCKMETA_TOKEN` | Bearer token for the Blockmeta service (see notes below on how to obtain) | Yes |
| `EBO_AGENT_CONFIG_FILE_PATH` | Path to the agent YAML configuration file | Yes |
| `DISCORD_WEBHOOK` | Your Discord channel webhook for notifications [Learn how to create a Discord webhook](https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks) | No |
| `SERVICE_PROVIDER_ADDRESS` | Service provider address to use with access control modules | No |
Copy link
Collaborator

Choose a reason for hiding this comment

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

No need for this if we are not going to use the env var

Comment on lines 21 to 24

# Optional: Service Provider Address for Access Control Modules
# If not specified, it will be derived from PROTOCOL_PROVIDER_PRIVATE_KEY
SERVICE_PROVIDER_ADDRESS=0xYourServiceProviderAddressHere
Copy link
Collaborator

Choose a reason for hiding this comment

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

No need for this neither if we are not going to use the env var

@@ -31,9 +38,11 @@ export const envSchema = z.object({
BLOCK_NUMBER_BLOCKMETA_TOKEN: z.string(),
EBO_AGENT_CONFIG_FILE_PATH: z.string(),
DISCORD_WEBHOOK: z.string().optional(),
SERVICE_PROVIDER_ADDRESS: serviceProviderAddressSchema,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Env var related stuff

Comment on lines +73 to +78
SERVICE_PROVIDER_ADDRESS: z
.string()
.refine((val) => isAddress(val), {
message: "SERVICE_PROVIDER_ADDRESS must be a valid blockchain address",
})
.optional(),
Copy link
Collaborator

Choose a reason for hiding this comment

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

This env var is fine, it can stay as we are not using yaml config files for the scripts.

Comment on lines 6 to 19
accessControl: z
.object({
/**
* The service provider address used with access control modules.
* This is an optional field. If not provided, it will be derived from the PROTOCOL_PROVIDER_PRIVATE_KEY.
*/
serviceProviderAddress: z
.string()
.refine((val) => isAddress(val), {
message: "serviceProviderAddress must be a valid blockchain address",
})
.optional(),
})
.optional(),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this property being used somewhere? 🤔

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

deleted

Copy link
Collaborator

@0xnigir1 0xnigir1 left a comment

Choose a reason for hiding this comment

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

good to go after addressing Yaco's comments 🫡

@jahabeebs jahabeebs requested a review from 0xyaco November 20, 2024 23:44
@jahabeebs
Copy link
Collaborator Author

@0xyaco addressed your comments--I think this is what you mean by passing it in the constructor (as part of the yaml
config rather than as a separate variable) right?

0xyaco
0xyaco previously approved these changes Nov 21, 2024
Copy link
Collaborator

@0xyaco 0xyaco left a comment

Choose a reason for hiding this comment

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

Just one small change and it's good to go!

Comment on lines 131 to 134
private readonly rpcConfig: ProtocolRpcConfig,
private readonly config: ProtocolProviderConfig,
contracts: ProtocolContractsAddresses,
privateKey: Hex,
Copy link
Collaborator

Choose a reason for hiding this comment

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

The service provider address needs to go below this line. The service provider address is not part of the RpcConfig.

privateKey: Hex,
serviceProviderAddress: Address | undefined

When initializing the agent, you'll need to explicitly pass that address (that you'll have in the config).

This might be useful as an example:

new ProtocolProvider(
 config.protocolProvider.rpcConfig,
 config.protocolProvider.contracts,
 config.privateKey,
 config.protocolProvider.accessControl.serviceProviderAddress
 ...
)

@jahabeebs jahabeebs merged commit 09c4dcd into dev Nov 22, 2024
5 checks passed
@jahabeebs jahabeebs deleted the feat/grt-229-add-service-prov-address-to-config branch November 22, 2024 14:01
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.

3 participants