-
Notifications
You must be signed in to change notification settings - Fork 196
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(cli): improve performance of linked library resolution during dep…
…loyment (#3197)
- Loading branch information
Showing
9 changed files
with
86 additions
and
37 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"@latticexyz/cli": patch | ||
--- | ||
|
||
Significantly improved the deployment performance for large projects with public libraries by implementing a more efficient algorithm to resolve public libraries during deployment. | ||
The local deployment time on a large reference project was reduced from over 10 minutes to 4 seconds. |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { Address } from "viem"; | ||
import { Library } from "./common"; | ||
|
||
export type LibraryMap = { | ||
getAddress: (opts: { path: string; name: string; deployer: Address }) => Address; | ||
}; | ||
|
||
function getLibraryKey({ path, name }: { path: string; name: string }): string { | ||
return `${path}:${name}`; | ||
} | ||
|
||
type LibraryCache = { | ||
[key: string]: Library & { | ||
address?: { | ||
[deployer: Address]: Address; | ||
}; | ||
}; | ||
}; | ||
|
||
export function getLibraryMap(libraries: readonly Library[]): LibraryMap { | ||
const cache: LibraryCache = Object.fromEntries(libraries.map((library) => [getLibraryKey(library), library])); | ||
const libraryMap = { | ||
getAddress: ({ path, name, deployer }) => { | ||
const library = cache[getLibraryKey({ path, name })]; | ||
if (!library) { | ||
throw new Error(`Could not find library for bytecode placeholder ${path}:${name}`); | ||
} | ||
library.address ??= {}; | ||
// Store the prepared address in the library cache to avoid preparing the same library twice | ||
library.address[deployer] ??= library.prepareDeploy(deployer, libraryMap).address; | ||
return library.address[deployer]; | ||
}, | ||
} satisfies LibraryMap; | ||
return libraryMap; | ||
} |
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