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: Inject ACP instance into the DB instance #2633

Merged
merged 4 commits into from
May 21, 2024

Conversation

AndrewSisley
Copy link
Contributor

Relevant issue(s)

Resolves #2632

Description

Injects the ACP instance into the DB instance, like how rootstore is provided.

Also makes the acp package public, and moves the ACP options off of db and into node (similar to rootstore).

Prerequisite for #2366 (as well as being something I think we inherently wanted).

@AndrewSisley AndrewSisley added feature New feature or request area/acp Related to the acp (access control) system labels May 21, 2024
@AndrewSisley AndrewSisley added this to the DefraDB v0.12 milestone May 21, 2024
@AndrewSisley AndrewSisley self-assigned this May 21, 2024
@shahzadlone
Copy link
Member

question: Is acp in mem and non-mem usage now dependent on the path config?

@AndrewSisley
Copy link
Contributor Author

AndrewSisley commented May 21, 2024

question: Is acp in mem and non-mem usage now dependent on the path config?

As far as I could see it was always so, the todo in cli/start suggests this was at least semi-deliberate.

@AndrewSisley AndrewSisley requested a review from a team May 21, 2024 18:24
node/node.go Outdated
@@ -112,7 +121,7 @@ func NewNode(ctx context.Context, opts ...NodeOpt) (*Node, error) {
if err != nil {
return nil, err
}
db, err := db.NewDB(ctx, rootstore, options.dbOpts...)
db, err := db.NewDB(ctx, rootstore, acp.NoACP, options.dbOpts...)
Copy link
Member

@shahzadlone shahzadlone May 21, 2024

Choose a reason for hiding this comment

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

question: Why not also dependent on the default options like for rootstore above?

For example:

acp, err := NewACP(options.acpOpts...)
if err != nil {
	return nil, err
}
	
// Then use:

db, err := db.NewDB(ctx, rootstore, acp, options.dbOpts...)

Copy link
Contributor Author

@AndrewSisley AndrewSisley May 21, 2024

Choose a reason for hiding this comment

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

Because I managed to forget to actually hook it up after doing all the rest :)

  • Actually use the lovely new code you wrote

Copy link
Member

@nasdf nasdf left a comment

Choose a reason for hiding this comment

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

Two small todos, but overall looks great!

node/acp.go Outdated Show resolved Hide resolved
node/acp.go Outdated Show resolved Hide resolved
node/acp.go Show resolved Hide resolved
net/peer_test.go Outdated Show resolved Hide resolved
cli/server_dump.go Outdated Show resolved Hide resolved
Comment on lines +47 to +63
func WithACPType(acpType ACPType) ACPOpt {
return func(o *ACPOptions) {
o.acpType = acpType
}
}

// WithACPPath sets the ACP path.
//
// Note: An empty path will result in an in-memory ACP instance.
func WithACPPath(path string) ACPOpt {
return func(o *ACPOptions) {
o.path = path
}
}

// NewACP returns a new ACP module with the given options.
func NewACP(ctx context.Context, opts ...ACPOpt) (immutable.Option[acp.ACP], error) {
Copy link
Member

Choose a reason for hiding this comment

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

suggestion: Can preserve / modify the tests that were removed in internal/db/config_test.go to test the public functions in this file. Perhaps in a node/acp_test.go file or something?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I would much rather spend time fixing the integration tests to cover this properly than to add unit tests here. #2634

Copy link
Member

@shahzadlone shahzadlone May 21, 2024

Choose a reason for hiding this comment

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

Thanks for making the issue. I do believe the tests that were removed were very recently added, I forget why that extra effort was put and if there was a reason for them.

@AndrewSisley AndrewSisley requested a review from nasdf May 21, 2024 18:54
Copy link
Collaborator

@fredcarle fredcarle left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@shahzadlone shahzadlone left a comment

Choose a reason for hiding this comment

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

Cheers for the answers and doing the requested changes =) LGTM

The ACP interface is public public, and will be returned from node.New shortly, as well as several node option funcs.
The ACP instance is now exposed/injected in a similar fashion to that of the rootstore.
Annoyingly I added it exactly and only for this reason and somehow forgot/got distracted from actually using it...
@AndrewSisley AndrewSisley merged commit 148da8f into sourcenetwork:develop May 21, 2024
28 of 29 checks passed
@AndrewSisley AndrewSisley deleted the 2632-acp-to-new-db branch May 21, 2024 22:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/acp Related to the acp (access control) system feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Pass acp.ACP into db.NewDB
4 participants