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: support for adding interop contracts to forked networks #87

Merged
merged 1 commit into from
Aug 13, 2024

Conversation

tremarkley
Copy link
Contributor

@tremarkley tremarkley commented Aug 7, 2024

Closes #69

@tremarkley
Copy link
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @tremarkley and the rest of your teammates on Graphite Graphite

@tremarkley tremarkley force-pushed the harry/apply_interop_contracts_to_fork_on_start branch 15 times, most recently from e37e0e6 to a623ea3 Compare August 13, 2024 01:08
@tremarkley tremarkley force-pushed the harry/apply_interop_contracts_to_fork_on_start branch from a623ea3 to 291d114 Compare August 13, 2024 01:13
@tremarkley tremarkley marked this pull request as ready for review August 13, 2024 01:13
@tremarkley tremarkley requested a review from a team as a code owner August 13, 2024 01:13
Copy link
Contributor

@jakim929 jakim929 left a comment

Choose a reason for hiding this comment

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

looks good! some minor suggestions

we should add tests to sanity check that the contracts work, but can be in separate PR

Comment on lines 121 to 123
opSim.startStartupTasks()
if err := opSim.startupTasks.Wait(); err != nil {
return fmt.Errorf("failed to start opsimulator: %w", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: wdyt about putting the for loop inside a single startupTask? The main point of the startupTasks field was to better separate tasks that are run before the opsim returns ready vs. ones that can run after opsim returns ready.

That way in a separate entrypoint, a caller can just wait on startupTasks to see if opsim is ready

opSim.startupTasks.Go(func() error {
    for chain in ...
        addDependencySet
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sounds good, I updated the startupTasks to include configureInteropForChain and addDependencies

orchestrator/fork.go Outdated Show resolved Hide resolved
Comment on lines 49 to 50
namespaceBigInt := new(big.Int).SetBytes(common.FromHex("0xc0D3C0d3C0d3C0D3c0d3C0d3c0D3C0d3c0d30000"))
resultBigInt := new(big.Int).Or(new(big.Int).And(addrBigInt, big.NewInt(0xffff)), namespaceBigInt)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: might make sense to just hard code the impl addresses as well. since there's only 3, and this is temporary code

Copy link
Contributor Author

@tremarkley tremarkley Aug 13, 2024

Choose a reason for hiding this comment

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

I think this function is useful if we ever need to add more contracts or if the proxy addresses were ever changed for some reason. Is there a reason you prefer to hardcode the values?


func fetchAllocForAddr(addr common.Address, allocsJSON []byte) (*alloc, error) {
var allocs allocs
err := json.Unmarshal(allocsJSON, &allocs)
Copy link
Contributor

Choose a reason for hiding this comment

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

we can prob memoize the result of the unmarshal and store in memory so we don't have to unmarshal everytime. esp since this is called at the startup we should try to reduce latency as much possible

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good call, memoized it at the top level call opsimulator.configureInteropForChain

@tremarkley tremarkley force-pushed the harry/apply_interop_contracts_to_fork_on_start branch 9 times, most recently from 9f27a5b to a54af04 Compare August 13, 2024 21:33
@tremarkley tremarkley force-pushed the harry/apply_interop_contracts_to_fork_on_start branch from a54af04 to 7377a66 Compare August 13, 2024 21:35
@tremarkley tremarkley merged commit 92996f7 into main Aug 13, 2024
3 checks passed
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.

interop contracts for forked networks
2 participants