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

fix(e2e): fix challenge e2e tests not working properly #273

Merged
merged 1 commit into from
Mar 19, 2024

Conversation

seolaoh
Copy link
Contributor

@seolaoh seolaoh commented Mar 18, 2024

Description

Fixed below issues of challenge e2e tests.

  • Due to a change in the way L1 contracts are set up in e2e, some historical variables related to guardians were being set after when the guardian should have been acting in the challenge test scenario.
  • In the e2e actions test, the guardian was not checking the conditions for sending the confirmation transaction.
  • In the e2e setup, the challenger was unable to get the trace because the L2 node settings were not allowed to call kroma_getBlockTraceByNumberOrHash.
  • In e2e challenge test, the logic to check that the guardian does nothing because the deleted output is invalid was poor, so it didn't check it properly.

Summary by CodeRabbit

  • New Features
    • Introduced new functionality for manipulating storage in specific contracts.
    • Enhanced validation processes for challenges, including checks before rolling back.
    • Added support for the "kroma" module in node configurations.
  • Refactor
    • Updated logic for ownership transfer and storage key changes in the blockchain network.
    • Renamed and restructured methods within the Guardian structure for clarity.
    • Refactored handling of Geth clients and block waiting logic in system configuration.
  • Bug Fixes
    • Adjusted error handling and return values in validation methods to enhance reliability.

@seolaoh seolaoh requested a review from a team March 18, 2024 01:00
@seolaoh seolaoh self-assigned this Mar 18, 2024
Copy link
Contributor

coderabbitai bot commented Mar 18, 2024

Walkthrough

The changes span across multiple components of a blockchain system, focusing on enhancing the functionality and reliability of the network. Key updates include the improvement of logic for ownership transfer and storage manipulation in smart contracts, refining validation and challenge processes in the layer 2 environment, and extending support for a new module in Geth configurations. Additionally, the updates aim to improve code clarity and consistency through method renaming and error handling adjustments.

Changes

Files Change Summary
kroma-chain-ops/genesis/layer_one.go Introduced additional package imports, updated logging and ownership transfer logic, modified storage keys, added storage manipulation functionality, and improved handling of storage layout and checkpoints.
kroma-validator/guardian.go Renamed and restructured method calls within the Guardian struct for better clarity and uniformity.
op-e2e/actions/l2_challenger_test.go, op-e2e/actions/l2_guardian.go, op-e2e/actions/l2_runtime.go Updated validation and challenge processes, added and modified methods for better error handling and confirmation checks in layer 2 validation.
op-e2e/e2eutils/geth/geth.go, op-e2e/setup.go Extended Geth configuration to include a new module and refactored Geth client handling in system setup.
op-e2e/system_test.go Imported kroma-bindings, adjusted challenge timeouts, added transaction ID finding function, and refined challenge testing logic.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share

Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit-tests for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit tests for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 7

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 646eb95 and adf74ec.
Files selected for processing (7)
  • kroma-chain-ops/genesis/layer_one.go (3 hunks)
  • kroma-validator/guardian.go (7 hunks)
  • op-e2e/actions/l2_challenger_test.go (1 hunks)
  • op-e2e/actions/l2_guardian.go (1 hunks)
  • op-e2e/actions/l2_runtime.go (1 hunks)
  • op-e2e/setup.go (1 hunks)
  • op-e2e/system_test.go (5 hunks)
Additional comments: 10
kroma-chain-ops/genesis/layer_one.go (3)
  • 124-124: The added logging messages enhance transparency and are helpful for debugging purposes.
  • 121-130: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [127-145]

Ownership transfer logic for SystemConfig appears correctly implemented. Ensure the ProxyAdmin address is correctly set and assess potential security implications.

  • 147-206: Modifications to storage keys for UpgradeGovernor and SecurityCouncilToken are carefully implemented. It's crucial to review these changes in the context of the contract behavior to ensure consistency and avoid unintended consequences.
op-e2e/actions/l2_runtime.go (1)
  • 62-62: The addition of defaultRuntime simplifies the setup for l2_challenger_test. Ensure this function is used exclusively in testing contexts and not in production code paths.
kroma-validator/guardian.go (1)
  • 291-291: Renaming and restructuring methods within the Guardian struct for clarity and consistency is a positive change. However, ensure that all references to these methods are updated accordingly across the codebase to prevent any broken functionality. Additionally, consider adding unit tests or enhancing existing ones to cover the changes in method behavior and ensure that the Guardian's functionality remains intact.
Verification successful

The verification process has confirmed that the renaming and restructuring of methods within the Guardian struct, specifically isOutputFinalized, CheckConfirmCondition, ValidateL2Output, and ConfirmTransaction, have been correctly reflected across the codebase. The changes are consistent with the review comment, indicating that all references to these methods have been updated accordingly.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify that all references to renamed methods are updated.
rg --type go "isOutputFinalized|CheckConfirmCondition|ValidateL2Output|ConfirmTransaction"

Length of output: 21752

op-e2e/system_test.go (5)
  • 46-47: The import statements for kroma-network/kroma/kroma-bindings/bindings and kroma-network/kroma/kroma-bindings/predeploys are added. Ensure that these packages are correctly referenced and accessible within the project's dependency management system.
  • 1472-1473: The retrieval of the SecurityCouncil ABI using bindings.SecurityCouncilMetaData.GetAbi() is a critical step for further operations. Ensure that the ABI is correctly loaded and matches the deployed contract's interface to avoid runtime errors.
  • 1501-1523: The function findTransactionId is used to find a specific transaction ID based on the ValidationRequested event. It's important to ensure that this logic correctly filters and retrieves the intended transaction ID, considering potential edge cases where multiple events might be found.
  • 1498-1546: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [1521-1557]

The logic within the loop that waits for the challenge status to become READY_TO_PROVE and then checks for the challenge's success is crucial. Ensure that the timeout and retry logic is appropriately set to handle scenarios where the expected status might take longer than anticipated or might not be reached due to unforeseen issues.

  • 1498-1546: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [1501-1557]

The entire challenge test logic, including waiting for the challenge status to change and verifying the outcome, is complex and involves multiple external calls and state checks. It's essential to ensure that error handling is robust and that the test accurately reflects the intended behavior of the system under test.

Consider adding more detailed error messages and checks for intermediate states to improve the test's diagnostic capability in case of failures.

op-e2e/setup.go Outdated Show resolved Hide resolved
op-e2e/actions/l2_challenger_test.go Show resolved Hide resolved
kroma-validator/guardian.go Show resolved Hide resolved
kroma-validator/guardian.go Show resolved Hide resolved
kroma-validator/guardian.go Show resolved Hide resolved
op-e2e/actions/l2_guardian.go Show resolved Hide resolved
op-e2e/actions/l2_guardian.go Show resolved Hide resolved
@seolaoh seolaoh force-pushed the fix/fix-challenge-e2e branch from adf74ec to fa0f72d Compare March 18, 2024 02:31
kroma-chain-ops/genesis/layer_one.go Outdated Show resolved Hide resolved
kroma-validator/guardian.go Show resolved Hide resolved
kroma-validator/guardian.go Show resolved Hide resolved
kroma-validator/guardian.go Show resolved Hide resolved
op-e2e/setup.go Outdated Show resolved Hide resolved
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 646eb95 and fa0f72d.
Files selected for processing (7)
  • kroma-chain-ops/genesis/layer_one.go (3 hunks)
  • kroma-validator/guardian.go (7 hunks)
  • op-e2e/actions/l2_challenger_test.go (1 hunks)
  • op-e2e/actions/l2_guardian.go (1 hunks)
  • op-e2e/actions/l2_runtime.go (1 hunks)
  • op-e2e/setup.go (3 hunks)
  • op-e2e/system_test.go (5 hunks)
Files skipped from review as they are similar to previous changes (7)
  • kroma-chain-ops/genesis/layer_one.go
  • kroma-validator/guardian.go
  • op-e2e/actions/l2_challenger_test.go
  • op-e2e/actions/l2_guardian.go
  • op-e2e/actions/l2_runtime.go
  • op-e2e/setup.go
  • op-e2e/system_test.go

@seolaoh seolaoh force-pushed the fix/fix-challenge-e2e branch from fa0f72d to 8382b98 Compare March 18, 2024 02:43
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 646eb95 and 8382b98.
Files selected for processing (7)
  • kroma-chain-ops/genesis/layer_one.go (3 hunks)
  • kroma-validator/guardian.go (8 hunks)
  • op-e2e/actions/l2_challenger_test.go (1 hunks)
  • op-e2e/actions/l2_guardian.go (1 hunks)
  • op-e2e/actions/l2_runtime.go (1 hunks)
  • op-e2e/setup.go (3 hunks)
  • op-e2e/system_test.go (5 hunks)
Files skipped from review as they are similar to previous changes (7)
  • kroma-chain-ops/genesis/layer_one.go
  • kroma-validator/guardian.go
  • op-e2e/actions/l2_challenger_test.go
  • op-e2e/actions/l2_guardian.go
  • op-e2e/actions/l2_runtime.go
  • op-e2e/setup.go
  • op-e2e/system_test.go

@seolaoh seolaoh force-pushed the fix/fix-challenge-e2e branch 2 times, most recently from e5235e4 to 8907e09 Compare March 18, 2024 05:14
@seolaoh seolaoh requested a review from Pangssu March 18, 2024 05:15
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 646eb95 and e5235e4.
Files selected for processing (8)
  • kroma-chain-ops/genesis/layer_one.go (3 hunks)
  • kroma-validator/guardian.go (8 hunks)
  • op-e2e/actions/l2_challenger_test.go (1 hunks)
  • op-e2e/actions/l2_guardian.go (1 hunks)
  • op-e2e/actions/l2_runtime.go (1 hunks)
  • op-e2e/e2eutils/geth/geth.go (1 hunks)
  • op-e2e/setup.go (1 hunks)
  • op-e2e/system_test.go (5 hunks)
Files skipped from review as they are similar to previous changes (6)
  • kroma-validator/guardian.go
  • op-e2e/actions/l2_challenger_test.go
  • op-e2e/actions/l2_guardian.go
  • op-e2e/actions/l2_runtime.go
  • op-e2e/setup.go
  • op-e2e/system_test.go
Additional comments: 5
op-e2e/e2eutils/geth/geth.go (1)
  • 78-79: Adding "kroma" to both WSModules and HTTPModules arrays extends the capabilities of the WebSocket and HTTP interfaces, enabling additional interactions with the Kroma module. This change is crucial for achieving the PR objective of allowing challengers to retrieve trace information from L2 nodes. Ensure that the Kroma module is fully implemented and tested to handle the expected interactions without introducing security or performance issues.
kroma-chain-ops/genesis/layer_one.go (4)
  • 124-124: The logging statement after updating the storage for KromaPortal provides transparency about the changes made during the post-processing of the L1 developer genesis state. This is a good practice for debugging and auditing purposes. However, ensure that logging at this level of detail is appropriate for the production environment, as excessive logging can lead to performance issues and log bloat.
  • 145-145: The logging statement after transferring ownership of SystemConfig to ProxyAdminOwner is useful for tracking changes. Similar to the previous comment, consider the appropriateness of this level of logging in production environments.
  • 173-173: Logging the before and after values of the storage update for UpgradeGovernor is beneficial for understanding the impact of the post-processing steps. As with previous logging comments, evaluate the necessity and frequency of such logs in a production setting.
  • 205-205: The detailed logging for the SecurityCouncilToken updates provides insight into the changes made to the contract's storage. This consistency in logging practices across different contract updates is commendable. Again, consider the impact of detailed logging on the system's performance and storage.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 646eb95 and 8907e09.
Files selected for processing (7)
  • kroma-chain-ops/genesis/layer_one.go (3 hunks)
  • kroma-validator/guardian.go (8 hunks)
  • op-e2e/actions/l2_challenger_test.go (1 hunks)
  • op-e2e/actions/l2_guardian.go (1 hunks)
  • op-e2e/actions/l2_runtime.go (1 hunks)
  • op-e2e/e2eutils/geth/geth.go (1 hunks)
  • op-e2e/system_test.go (5 hunks)
Files skipped from review as they are similar to previous changes (6)
  • kroma-validator/guardian.go
  • op-e2e/actions/l2_challenger_test.go
  • op-e2e/actions/l2_guardian.go
  • op-e2e/actions/l2_runtime.go
  • op-e2e/e2eutils/geth/geth.go
  • op-e2e/system_test.go
Additional comments: 6
kroma-chain-ops/genesis/layer_one.go (6)
  • 14-14: The addition of the crypto package suggests new cryptographic operations are being introduced. Ensure that these operations are secure and necessary for the intended functionality.
  • 17-17: The introduction of kroma-network/kroma/kroma-bindings/bindings indicates new bindings are being utilized. Verify that these bindings are up-to-date and correctly implemented to avoid potential integration issues.
  • 124-124: Logging the post-process update for KromaPortal is good for transparency and debugging. However, ensure that logging does not expose sensitive information that could be exploited.
  • 121-130: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [127-145]

Transferring ownership of SystemConfig to ProxyAdminOwner for testing is a significant change. Confirm that this ownership transfer is reversible or appropriate for the testing environment to avoid unintended access control issues.

  • 147-173: The manipulation of _quorumNumeratorHistory in UpgradeGovernor for testing purposes is noted. It's crucial to ensure that such changes do not affect the integrity of the governance process in a production environment.
  • 175-205: Changing the keys of _totalCheckpoints in SecurityCouncilToken for testing is a critical operation. Verify that these changes are isolated to the testing environment and do not impact the token's security or functionality in production.

Comment on lines 152 to 160
layout, err = bindings.GetStorageLayout("UpgradeGovernor")
if err != nil {
return errors.New("failed to get storage layout for UpgradeGovernor")
}

entry, err = layout.GetStorageLayoutEntry("_quorumNumeratorHistory")
if err != nil {
return errors.New("failed to get storage layout entry for UpgradeGovernor._quorumNumeratorHistory")
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I suggest making this code block a function.

func getStorageLayerEntity(contractName, fieldName string) (solc.StorageLayoutEntry, error) {
	layout, err := bindings.GetStorageLayout(contractName)
	if err != nil {
		return solc.StorageLayoutEntry{}, fmt.Errorf("failed to get storage layout for %s", contractName)
	}
	entry, err := layout.GetStorageLayoutEntry(fieldName)
	if err != nil {
		return solc.StorageLayoutEntry{}, fmt.Errorf("failed to get storage layout for %s.%s", contractName, fieldName)
	}
	return entry, nil
}

kroma-chain-ops/genesis/layer_one.go Show resolved Hide resolved
Comment on lines 171 to 172
stateDB.SetState(deployments.UpgradeGovernorProxy, slot, val)
afterVal := stateDB.GetState(deployments.UpgradeGovernorProxy, slot)
Copy link
Contributor

Choose a reason for hiding this comment

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

What does this code mean?
stateDB.SetState alone seems like it should be enough.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's because to log the difference between before value and after value below line 173.

Copy link
Contributor

Choose a reason for hiding this comment

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

I understand that the values are different, but isn't that the val variable? I don't understand assigning the afterVal variable with getState.

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree with Logan that using val is sufficient.

@@ -1496,24 +1498,49 @@ func TestChallenge(t *testing.T) {
}
cancel()

// set a timeout for security council to validate output
ctx, cancel = context.WithTimeout(context.Background(), 10*time.Second)
findTransactionId := func() *big.Int {
Copy link
Contributor

@jyc228 jyc228 Mar 18, 2024

Choose a reason for hiding this comment

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

I can understand why you named it findTransactionId since it's obvious what it does in the for loop underneath, but looking at that function alone, I don't understand what transaction you're trying to find or what output you want.
Also, using the auto-generated code in bindings would eliminate the need to reference the "ValidationRequested" field as a string.

Considering these two points, I would suggest removing findTransactionId and doing it this way.

securityCouncil, err := bindings.NewSecurityCouncil(cfg.L1Deployments.SecurityCouncilProxy, l1Client)
if challengeStatus == chal.StatusNone {
    // check validation request tx exists and not executed
    toBlock := latestBlock(t, l1Client)
    iter, _ := securityCouncil.FilterValidationRequested(&bind.FilterOpts{End: &toBlock}, nil)
    iter.Next()
    tx, err := securityCouncil.Transactions(&bind.CallOpts{}, iter.Event.TransactionId)
    iter.Close()
    ....
}

defer cancel()

numCheck := 0
for ; ; <-ticker.C {
Copy link
Contributor

Choose a reason for hiding this comment

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

even though the for loop is the last piece of code. This avoids referencing variables outside of the for loop.

for numCheck := 0; ; <-ticker.C {

@@ -1522,15 +1549,17 @@ func TestChallenge(t *testing.T) {
require.Equal(t, output.Submitter, cfg.Secrets.Addresses().Challenger1)
outputDeleted := val.IsOutputDeleted(output.OutputRoot)
require.True(t, outputDeleted)
Copy link
Contributor

Choose a reason for hiding this comment

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

I suppose it's a matter of taste, but I think the val.IsOutputDeleted function is so clear that you don't need to do local variable assignments.

require.True(t, val.IsOutputDeleted(output.OutputRoot))

Copy link
Contributor

@sm-stack sm-stack left a comment

Choose a reason for hiding this comment

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

LGTM

@seolaoh seolaoh force-pushed the fix/fix-challenge-e2e branch from 8907e09 to ced1cf6 Compare March 19, 2024 05:10
@seolaoh seolaoh requested a review from jyc228 March 19, 2024 05:14
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 1

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 646eb95 and ced1cf6.
Files selected for processing (7)
  • kroma-chain-ops/genesis/layer_one.go (2 hunks)
  • kroma-validator/guardian.go (8 hunks)
  • op-e2e/actions/l2_challenger_test.go (1 hunks)
  • op-e2e/actions/l2_guardian.go (1 hunks)
  • op-e2e/actions/l2_runtime.go (1 hunks)
  • op-e2e/e2eutils/geth/geth.go (1 hunks)
  • op-e2e/system_test.go (5 hunks)
Files skipped from review as they are similar to previous changes (6)
  • kroma-validator/guardian.go
  • op-e2e/actions/l2_challenger_test.go
  • op-e2e/actions/l2_guardian.go
  • op-e2e/actions/l2_runtime.go
  • op-e2e/e2eutils/geth/geth.go
  • op-e2e/system_test.go
Additional comments: 5
kroma-chain-ops/genesis/layer_one.go (5)
  • 8-14: Imports have been added for several packages. Ensure that these new dependencies are necessary and correctly used within the file to avoid unnecessary bloat and potential conflicts.
  • 111-118: Introduced a new functionality related to storage manipulation for the KromaPortal contract. It's crucial to ensure that the getStorageSlot function is robust and handles errors appropriately, as it directly interacts with contract storage.
Verification successful

The getStorageSlot function in kroma-chain-ops/genesis/layer_one.go is implemented with robust error handling. It properly checks for errors at each critical step, such as when retrieving the storage layout for a contract and when fetching a specific entry within that layout. Errors are returned appropriately, ensuring that any issues encountered are communicated back to the caller. This approach allows for effective error management and contributes to the function's overall robustness in interacting with contract storage.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify the implementation of getStorageSlot function for robustness and error handling
rg "func getStorageSlot" --type go

Length of output: 148



Script:

#!/bin/bash
# Examine the implementation of getStorageSlot function in layer_one.go
fd "layer_one.go" --exec cat {}

Length of output: 7325

* 120-132: The ownership transfer logic for `SystemConfig` to `ProxyAdminOwner` is updated. It's important to validate that the new ownership is correctly set and that this change does not introduce any unintended permissions or access control issues. * 134-153: The logic for modifying the storage key `_quorumNumeratorHistory` in `UpgradeGovernor` is complex and involves manipulating bytes directly. Ensure that this manipulation is accurate and does not introduce potential data corruption or unintended side effects. * 155-179: Updates to the keys of `_totalCheckpoints` in `SecurityCouncilToken` involve iterating over minted numbers and modifying storage slots. This operation seems to be critical and should be thoroughly tested to ensure it behaves as expected under all conditions, especially considering the direct manipulation of storage slots.

Comment on lines +183 to +195
func getStorageSlot(contractName, entryName string) (common.Hash, error) {
layout, err := bindings.GetStorageLayout(contractName)
if err != nil {
return common.Hash{}, fmt.Errorf("failed to get storage layout for %s", contractName)
}

entry, err := layout.GetStorageLayoutEntry(entryName)
if err != nil {
return common.Hash{}, fmt.Errorf("failed to get storage layout entry for %s.%s", contractName, entryName)
}

return common.BigToHash(big.NewInt(int64(entry.Slot))), nil
}
Copy link
Contributor

Choose a reason for hiding this comment

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

The getStorageSlot function is central to several storage manipulation operations. It's essential to ensure that this function is implemented correctly, especially error handling and the accuracy of slot calculations. Consider adding unit tests for this function to cover various scenarios and edge cases.

Would you like me to help with creating unit tests for the getStorageSlot function?

Copy link
Contributor

@0xHansLee 0xHansLee left a comment

Choose a reason for hiding this comment

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

lgtm

@jyc228
Copy link
Contributor

jyc228 commented Mar 19, 2024

lgtm

@seolaoh seolaoh merged commit 84c11c5 into dev Mar 19, 2024
2 checks passed
@seolaoh seolaoh deleted the fix/fix-challenge-e2e branch March 19, 2024 06:35
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