forked from erigontech/erigon
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1298 acl access control list augmentation (#1303)
* feat: adding list command to check ACL status on acl folder. also function can be reused by other parts of the code. * feat: adding ListComponent calls in cdk-erigon added call to the function for it to log in parts of the code, this will be reviewed. * docs: adding readme updates on acl, making it more clear on how to use. * feat: acl transaction history buildup creating functions to interact with table as binary, and other helper functions that we may need. * feat: build up transaction inserter, second part. * feat: enhance ACL listing with policy transaction logging and refactor logging imports changing log structure, cause it's failing. changed the function at txpool so I can get the string to put in the log at the CLI level since it doesn't log too. * chore: changing call to log it. * feat: update logging for policy transactions and fix a transaction insertion error * feat: add update operation to policy transactions and log updates in UpdatePolicies * feat: insert policy refactor and fix update error. fixing update method which was exiting on panic, also improved the function of insert to be able to insert an array improving code quality * feat: adding log count setup to the mode acl function ( which basically is the config updater now) * chore: changing config value on key to string, for easier reading when debugging// looking for it. not an issue for usage, only a improvement. * docs: update README to include optional log_count parameter for acl mode command * chore: adding logging level part back. * fix: we had an issue in the test when running in parallel it could either remove or add the policy at the same time someone else was checking for another scenario to fix I added the adding flow, to updating/changing tx before making the update with the same asserting checks for correct adding.
- Loading branch information
Showing
9 changed files
with
600 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package list | ||
|
||
import ( | ||
"github.com/ledgerwatch/erigon/cmd/utils" | ||
"github.com/ledgerwatch/erigon/zk/txpool" | ||
"github.com/ledgerwatch/erigon/zkevm/log" | ||
"github.com/urfave/cli/v2" | ||
) | ||
|
||
var Command = cli.Command{ | ||
Action: run, | ||
Name: "list", | ||
Usage: "List the content at the ACL", | ||
Flags: []cli.Flag{ | ||
&utils.DataDirFlag, | ||
}, | ||
} | ||
|
||
func run(cliCtx *cli.Context) error { | ||
dataDir := cliCtx.String(utils.DataDirFlag.Name) | ||
log.Info("Listing ", "dataDir:", dataDir) | ||
|
||
aclDB, err := txpool.OpenACLDB(cliCtx.Context, dataDir) | ||
if err != nil { | ||
log.Error("Failed to open ACL database", "err", err) | ||
return err | ||
} | ||
|
||
content, _ := txpool.ListContentAtACL(cliCtx.Context, aclDB) | ||
log.Info(content) | ||
pts, _ := txpool.LastPolicyTransactions(cliCtx.Context, aclDB) | ||
if len(pts) == 0 { | ||
log.Info("No policy transactions found") | ||
return nil | ||
} | ||
for i, pt := range pts { | ||
log.Info("Policy transaction - ", "index:", i, "pt:", pt.ToString()) | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.