Skip to content

Commit

Permalink
CR yorhodes
Browse files Browse the repository at this point in the history
Signed-off-by: Paul Balaji <[email protected]>
  • Loading branch information
paulbalaji committed Feb 13, 2024
1 parent bd1e2df commit 7c42a80
Show file tree
Hide file tree
Showing 14 changed files with 39 additions and 160 deletions.
1 change: 0 additions & 1 deletion solidity/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
"clean": "hardhat clean && rm -rf ./dist ./cache ./types ./coverage",
"coverage": "./coverage.sh",
"docs": "forge doc",
"flatten": "./flatten.sh",
"storage": "./storage.sh",
"prettier": "prettier --write ./contracts ./test",
"test": "hardhat test && forge test -vvv",
Expand Down
8 changes: 1 addition & 7 deletions typescript/helloworld/src/app/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,7 @@ export class HelloWorldApp extends RouterApp<HelloWorldFactories> {
multiProvider: MultiProvider,
foreignDeployments: ChainMap<Address> = {},
) {
super(
contractsMap,
multiProvider,
undefined,
undefined,
foreignDeployments,
);
super(contractsMap, multiProvider, undefined, foreignDeployments);
}

router(contracts: HyperlaneContracts<HelloWorldFactories>): HelloWorld {
Expand Down
34 changes: 4 additions & 30 deletions typescript/infra/scripts/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ import {
import { objMap } from '@hyperlane-xyz/utils';

import { Contexts } from '../config/contexts';
import { supportedChainNames as mainnet3Chains } from '../config/environments/mainnet3/chains';
import { supportedChainNames as testnet4Chains } from '../config/environments/testnet4/chains';
import { deployEnvToSdkEnv } from '../src/config/environment';
import { deployWithArtifacts } from '../src/deployment/deploy';
import { TestQuerySenderDeployer } from '../src/deployment/testcontracts/testquerysender';
Expand Down Expand Up @@ -48,13 +46,6 @@ async function main() {
const envConfig = getEnvironmentConfig(environment);
const env = deployEnvToSdkEnv[environment];

const supportedChainNames =
environment === 'mainnet3'
? mainnet3Chains
: environment === 'testnet4'
? testnet4Chains
: undefined;

let multiProvider = await envConfig.getMultiProvider();

if (fork) {
Expand All @@ -77,7 +68,6 @@ async function main() {
const ismFactory = HyperlaneIsmFactory.fromAddressesMap(
getAddresses(environment, Modules.PROXY_FACTORY),
multiProvider,
supportedChainNames,
);
deployer = new HyperlaneCoreDeployer(multiProvider, ismFactory);
} else if (module === Modules.WARP) {
Expand All @@ -89,27 +79,15 @@ async function main() {
};
deployer = new HyperlaneIgpDeployer(multiProvider);
} else if (module === Modules.INTERCHAIN_ACCOUNTS) {
const core = HyperlaneCore.fromEnvironment(
env,
multiProvider,
supportedChainNames,
);
const core = HyperlaneCore.fromEnvironment(env, multiProvider);
config = core.getRouterConfig(envConfig.owners);
deployer = new InterchainAccountDeployer(multiProvider);
} else if (module === Modules.INTERCHAIN_QUERY_SYSTEM) {
const core = HyperlaneCore.fromEnvironment(
env,
multiProvider,
supportedChainNames,
);
const core = HyperlaneCore.fromEnvironment(env, multiProvider);
config = core.getRouterConfig(envConfig.owners);
deployer = new InterchainQueryDeployer(multiProvider);
} else if (module === Modules.LIQUIDITY_LAYER) {
const core = HyperlaneCore.fromEnvironment(
env,
multiProvider,
supportedChainNames,
);
const core = HyperlaneCore.fromEnvironment(env, multiProvider);
const routerConfig = core.getRouterConfig(envConfig.owners);
if (!envConfig.liquidityLayerConfig) {
throw new Error(`No liquidity layer config for ${environment}`);
Expand All @@ -135,11 +113,7 @@ async function main() {
}));
deployer = new TestQuerySenderDeployer(multiProvider);
} else if (module === Modules.HELLO_WORLD) {
const core = HyperlaneCore.fromEnvironment(
env,
multiProvider,
supportedChainNames,
);
const core = HyperlaneCore.fromEnvironment(env, multiProvider);
config = core.getRouterConfig(envConfig.owners);
deployer = new HelloWorldDeployer(multiProvider);
} else {
Expand Down
55 changes: 16 additions & 39 deletions typescript/infra/scripts/verify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,23 @@ import {
VerificationInput,
} from '@hyperlane-xyz/sdk';

import { supportedChainNames as mainnet3Chains } from '../config/environments/mainnet3/chains';
import { supportedChainNames as testnet4Chains } from '../config/environments/testnet4/chains';
import { fetchGCPSecret } from '../src/utils/gcloud';
import { execCmd, readFileAtPath, readJSONAtPath } from '../src/utils/utils';
import { readJSONAtPath } from '../src/utils/utils';

import { assertEnvironment, getArgs } from './agent-utils';
import { getEnvironmentConfig } from './core-utils';

// Requires https://github.com/crytic/solc-select to be installed and
// present in your $PATH. The current solc compiler version should
// already be installed via `solc-select install $VERSION`
async function main() {
const argv = await getArgs()
// This file can be generated by running `flatten.sh` from the solidity directory
.string('source')
.describe('source', 'flattened solidity source file or standard input json')
.describe(
'source',
'Path to hardhat build artifact containing standard input JSON',
)
.demandOption('source')
.string('artifacts')
.describe('artifacts', 'verification artifacts JSON file')
.demandOption('artifacts')
.boolean('disableOptimizations')
.describe(
'disableOptimizations',
'flag to indicate optimization was not used in compilation',
)
.default('disableOptimizations', false)
.string('network')
.describe('network', 'optional target network').argv;

Expand All @@ -41,30 +32,23 @@ async function main() {
const verification: ChainMap<VerificationInput> = readJSONAtPath(
argv.artifacts!,
);
const supportedChainNames =
environment === 'mainnet3'
? mainnet3Chains
: environment === 'testnet4'
? testnet4Chains
: undefined;

const sourcePath = argv.source!;
const isStandardJson = sourcePath.endsWith('.json');
if (!sourcePath.endsWith('.json')) {
throw new Error('Source must be a JSON file.');
}

const source = isStandardJson
? readJSONAtPath(sourcePath).input
: readFileAtPath(sourcePath);
const buildArtifactJson = readJSONAtPath(sourcePath);
const source = buildArtifactJson.input;
const solcLongVersion = buildArtifactJson.solcLongVersion;

// codeformat is required always
// other options are only used when source is flattened solidity
// codeformat always json
// compiler version inferred from build artifact
// always use MIT license
const compilerOptions: CompilerOptions = {
codeformat: isStandardJson
? 'solidity-standard-json-input'
: 'solidity-single-file',
compilerversion: 'v0.8.19+commit.7dd6d404',
codeformat: 'solidity-standard-json-input',
compilerversion: `v${solcLongVersion}`,
licenseType: '3',
optimizationUsed: argv.disableOptimizations ? '0' : '1',
...(argv.disableOptimizations ? {} : { runs: '999999' }),
};

const versionRegex = /v(\d.\d.\d+)\+commit.\w+/;
Expand All @@ -75,12 +59,6 @@ async function main() {
);
}

// ensures flattened source is compilable
if (!isStandardJson) {
await execCmd(`solc-select use ${matches[1]}`);
await execCmd(`solc ${sourcePath}`);
}

const apiKeys: ChainMap<string> = (await fetchGCPSecret(
'explorer-api-keys',
true,
Expand All @@ -92,7 +70,6 @@ async function main() {
apiKeys,
source,
compilerOptions,
supportedChainNames,
);

const failedResults = (
Expand Down
3 changes: 1 addition & 2 deletions typescript/sdk/src/app/HyperlaneApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,12 @@ export class HyperlaneApp<
constructor(
contractsMap: HyperlaneContractsMap<Factories>,
public readonly multiProvider: MultiProvider,
supportedChainNames?: string[],
public readonly logger = debug('hyperlane:App'),
) {
const connectedContractsMap = objMap(contractsMap, (chain, contracts) =>
connectContracts(contracts, multiProvider.getSignerOrProvider(chain)),
);
super(connectedContractsMap, supportedChainNames);
super(connectedContractsMap);
this.contractsMap = connectedContractsMap;
}

Expand Down
15 changes: 1 addition & 14 deletions typescript/sdk/src/contracts/contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,26 +189,13 @@ export async function filterOwnableContracts(
}

export function appFromAddressesMapHelper<F extends HyperlaneFactories>(
unfilteredAddressesMap: HyperlaneAddressesMap<any>,
addressesMap: HyperlaneAddressesMap<any>,
factories: F,
multiProvider: MultiProvider,
supportedChainNames?: string[],
): {
contractsMap: HyperlaneContractsMap<F>;
multiProvider: MultiProvider;
} {
let addressesMap;
if (supportedChainNames) {
addressesMap = objFilter(
unfilteredAddressesMap,
(chain, _): _ is HyperlaneAddresses<any> => {
return supportedChainNames.includes(chain);
},
);
} else {
addressesMap = unfilteredAddressesMap;
}

// Hack to accommodate non-Ethereum artifacts, while still retaining their
// presence in the addressesMap so that they are included in the list of chains
// on the MultiProvider (needed for getting metadata). A non-Ethereum-style address
Expand Down
15 changes: 2 additions & 13 deletions typescript/sdk/src/core/HyperlaneCore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,35 +33,24 @@ export class HyperlaneCore extends HyperlaneApp<CoreFactories> {
static fromEnvironment<Env extends HyperlaneEnvironment>(
env: Env,
multiProvider: MultiProvider,
supportedChainNames?: string[],
): HyperlaneCore {
const envAddresses = hyperlaneEnvironments[env];
if (!envAddresses) {
throw new Error(`No addresses found for ${env}`);
}
return HyperlaneCore.fromAddressesMap(
envAddresses,
multiProvider,
supportedChainNames,
);
return HyperlaneCore.fromAddressesMap(envAddresses, multiProvider);
}

static fromAddressesMap(
addressesMap: HyperlaneAddressesMap<any>,
multiProvider: MultiProvider,
supportedChainNames?: string[],
): HyperlaneCore {
const helper = appFromAddressesMapHelper(
addressesMap,
coreFactories,
multiProvider,
supportedChainNames,
);
return new HyperlaneCore(
helper.contractsMap,
helper.multiProvider,
supportedChainNames,
);
return new HyperlaneCore(helper.contractsMap, helper.multiProvider);
}

getRouterConfig = (
Expand Down
12 changes: 3 additions & 9 deletions typescript/sdk/src/deploy/verify/ContractVerifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,10 @@ export class ContractVerifier extends MultiGeneric<VerificationInput> {
verificationInputs: ChainMap<VerificationInput>,
protected readonly multiProvider: MultiProvider,
protected readonly apiKeys: ChainMap<string>,
protected readonly source: string, // source e.g. either standard input json or flattened solidity
protected readonly source: string, // solidity standard input json
protected readonly compilerOptions: CompilerOptions,
supportedChainNames?: string[],
) {
super(verificationInputs, supportedChainNames);
super(verificationInputs);
this.logger = debug('hyperlane:ContractVerifier');
}

Expand Down Expand Up @@ -242,18 +241,13 @@ export class ContractVerifier extends MultiGeneric<VerificationInput> {
`[${chain}] [${input.name}] Verifying implementation at ${input.address}`,
);

const { codeformat, compilerversion, ...otherCompilerOptions } =
this.compilerOptions;

const data = {
sourceCode: this.source,
contractname: input.name,
contractaddress: input.address,
// TYPO IS ENFORCED BY API
constructorArguements: strip0x(input.constructorArguments ?? ''),
codeformat,
compilerversion,
...(codeformat === 'solidity-single-file' ? otherCompilerOptions : {}),
...this.compilerOptions,
};

const guid = await this.submitForm(
Expand Down
6 changes: 2 additions & 4 deletions typescript/sdk/src/deploy/verify/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@ export type ContractVerificationInput = {
export type VerificationInput = ContractVerificationInput[];

export type CompilerOptions = {
codeformat: 'solidity-single-file' | 'solidity-standard-json-input'; //solidity-single-file (default) or solidity-standard-json-input (for std-input-json-format support
compilerversion: string; // see https://etherscan.io/solcversions for list of support versions
optimizationUsed: '0' | '1'; //0 = No Optimization, 1 = Optimization used (applicable when codeformat=solidity-single-file)
runs?: string; //set to 200 as default unless otherwise (applicable when codeformat=solidity-single-file)
codeformat: 'solidity-standard-json-input';
compilerversion: string; // see https://etherscan.io/solcversions for list of support versions, inferred from build artifact
licenseType:
| '1'
| '2'
Expand Down
15 changes: 2 additions & 13 deletions typescript/sdk/src/gas/HyperlaneIgp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,36 +19,25 @@ export class HyperlaneIgp extends HyperlaneApp<IgpFactories> {
static fromEnvironment<Env extends HyperlaneEnvironment>(
env: Env,
multiProvider: MultiProvider,
supportedChainNames?: string[],
): HyperlaneIgp {
const envAddresses = hyperlaneEnvironments[env];
if (!envAddresses) {
throw new Error(`No addresses found for ${env}`);
}
/// @ts-ignore
return HyperlaneIgp.fromAddressesMap(
envAddresses,
multiProvider,
supportedChainNames,
);
return HyperlaneIgp.fromAddressesMap(envAddresses, multiProvider);
}

static fromAddressesMap(
addressesMap: HyperlaneAddressesMap<any>,
multiProvider: MultiProvider,
supportedChainNames?: string[],
): HyperlaneIgp {
const helper = appFromAddressesMapHelper(
addressesMap,
igpFactories,
multiProvider,
supportedChainNames,
);
return new HyperlaneIgp(
helper.contractsMap,
helper.multiProvider,
supportedChainNames,
);
return new HyperlaneIgp(helper.contractsMap, helper.multiProvider);
}

/**
Expand Down
Loading

0 comments on commit 7c42a80

Please sign in to comment.