-
Notifications
You must be signed in to change notification settings - Fork 29
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
Improve contract recompilation #475
Changes from 1 commit
4517d45
708c0cf
05ba0a7
d0aa6fb
bb531ff
d51b0bd
53828bf
35cb7d7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,7 +39,7 @@ import { promises as fsPromises } from 'fs' | |
import { parseError } from './error' | ||
|
||
const crypto = new WebCrypto() | ||
const mainnetNodeUrl = 'https://node.mainnet.alephium.org' | ||
const defaultMainnetNodeUrl = 'https://node.mainnet.alephium.org' | ||
|
||
class TypedMatcher<T extends SourceKind> { | ||
matcher: RegExp | ||
|
@@ -590,8 +590,12 @@ export class Project { | |
} | ||
} | ||
|
||
private static async getDeployedContracts(sourceInfos: SourceInfo[], artifactsRootDir: string): Promise<string[]> { | ||
const nodeProvider = new NodeProvider(mainnetNodeUrl) | ||
private static async getDeployedContracts( | ||
mainnetNodeUrl: string | undefined, | ||
sourceInfos: SourceInfo[], | ||
artifactsRootDir: string | ||
): Promise<string[]> { | ||
const nodeProvider = new NodeProvider(mainnetNodeUrl ?? defaultMainnetNodeUrl) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We support both There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. okay |
||
const result: string[] = [] | ||
for (const sourceInfo of sourceInfos) { | ||
const artifactPath = sourceInfo.getArtifactPath(artifactsRootDir) | ||
|
@@ -611,6 +615,7 @@ export class Project { | |
} | ||
|
||
private static async filterChangedContracts( | ||
mainnetNodeUrl: string | undefined, | ||
sourceInfos: SourceInfo[], | ||
artifactsRootDir: string, | ||
changedContracts: string[], | ||
|
@@ -622,7 +627,7 @@ export class Project { | |
const remainSourceInfo = sourceInfos.filter( | ||
(s) => s.type === SourceKind.Contract && !skipRecompileContracts.includes(s.name) | ||
) | ||
deployedContracts = await this.getDeployedContracts(remainSourceInfo, artifactsRootDir) | ||
deployedContracts = await this.getDeployedContracts(mainnetNodeUrl, remainSourceInfo, artifactsRootDir) | ||
} else { | ||
deployedContracts = [] | ||
} | ||
|
@@ -658,7 +663,8 @@ export class Project { | |
changedContracts: string[], | ||
forceRecompile: boolean, | ||
skipRecompileIfDeployedOnMainnet: boolean, | ||
skipRecompileContracts: string[] | ||
skipRecompileContracts: string[], | ||
mainnetNodeUrl: string | undefined | ||
): Promise<Project> { | ||
const removeDuplicates = sourceInfos.reduce((acc: SourceInfo[], sourceInfo: SourceInfo) => { | ||
if (acc.find((info) => info.sourceCodeHash === sourceInfo.sourceCodeHash) === undefined) { | ||
|
@@ -720,6 +726,7 @@ export class Project { | |
projectArtifact | ||
) | ||
const filteredChangedContracts = await Project.filterChangedContracts( | ||
mainnetNodeUrl, | ||
sourceInfos, | ||
artifactsRootDir, | ||
changedContracts, | ||
|
@@ -741,7 +748,8 @@ export class Project { | |
changedContracts: string[], | ||
forceRecompile: boolean, | ||
skipRecompileIfDeployedOnMainnet: boolean, | ||
skipRecompileContracts: string[] | ||
skipRecompileContracts: string[], | ||
mainnetNodeUrl: string | undefined | ||
): Promise<Project> { | ||
const projectArtifact = await ProjectArtifact.from(projectRootDir) | ||
if (projectArtifact === undefined) { | ||
|
@@ -797,7 +805,8 @@ export class Project { | |
changedContracts, | ||
forceRecompile, | ||
skipRecompileIfDeployedOnMainnet, | ||
skipRecompileContracts | ||
skipRecompileContracts, | ||
mainnetNodeUrl | ||
) | ||
} | ||
} | ||
|
@@ -929,7 +938,8 @@ export class Project { | |
defaultFullNodeVersion: string | undefined = undefined, | ||
forceRecompile = false, | ||
skipRecompileIfDeployedOnMainnet = false, | ||
skipRecompileContracts: string[] = [] | ||
skipRecompileContracts: string[] = [], | ||
mainnetNodeUrl: string | undefined = undefined | ||
): Promise<Project> { | ||
const provider = web3.getCurrentNodeProvider() | ||
const fullNodeVersion = defaultFullNodeVersion ?? (await provider.infos.getInfosVersion()).version | ||
|
@@ -959,7 +969,8 @@ export class Project { | |
changedContracts, | ||
forceRecompile, | ||
skipRecompileIfDeployedOnMainnet, | ||
skipRecompileContracts | ||
skipRecompileContracts, | ||
mainnetNodeUrl | ||
) | ||
} | ||
// we need to reload those contracts that did not regenerate bytecode | ||
|
@@ -974,7 +985,8 @@ export class Project { | |
changedContracts, | ||
forceRecompile, | ||
skipRecompileIfDeployedOnMainnet, | ||
skipRecompileContracts | ||
skipRecompileContracts, | ||
mainnetNodeUrl | ||
) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's check NetworkID to ensure that it's mainnet. It might be other networks by accident.