Skip to content

Commit

Permalink
Merge branch 'main' into add-rollupadminlogic-getters
Browse files Browse the repository at this point in the history
  • Loading branch information
chrstph-dvx committed Sep 18, 2024
2 parents 227c9dd + 2f33e44 commit ed86dfa
Show file tree
Hide file tree
Showing 27 changed files with 362 additions and 78 deletions.
13 changes: 13 additions & 0 deletions examples/set-new-validators/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import {
createRollupFetchTransactionHash,
createRollupPrepareTransactionReceipt,
rollupAdminLogicPublicActions,
// Uncomment it when you want to use getValidators() to get validator status
// getValidators,
} from '@arbitrum/orbit-sdk';
import { sanitizePrivateKey } from '@arbitrum/orbit-sdk/utils';
import { config } from 'dotenv';
Expand Down Expand Up @@ -76,6 +78,17 @@ async function main() {
`Before executing, the address ${newValidators[0]} status in validator list is ${beforeStatus}`,
);

/*
You can also use the following code to check validator status, it will return a list
of whitelist validators.
console.log('Fetching current validator address list in the parent chain...');
const beforeValidatorList = await getValidators(parentChainPublicClient, {
rollup: coreContracts.rollup,
});
console.log(`Before executing, the validator list is ${beforeValidatorList.validators}`);
*/

// prepare set validator transaction request
const setValidatorTransactionRequest =
await parentChainPublicClient.rollupAdminLogicPrepareTransactionRequest({
Expand Down
5 changes: 2 additions & 3 deletions examples/setup-fast-withdrawal/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -301,16 +301,15 @@ async function main() {

// Batch poster configuration
const timeDelay = getTimeDelayFromNumberOfBlocks(parentChain.id, minimumAssertionPeriod);
console.log('Your batch poster has to run at least nitro v3.1.1');
console.log('Your batch poster has to run at least nitro v3.1.2');
console.log('Add the following parameter:');
console.log(`--node.batch-poster.max-delay=${timeDelay}`);
console.log('');

// Validator configuration
console.log('Your validators have to run at least nitro v3.1.1');
console.log('Your validators have to run at least nitro v3.1.2');
console.log('Add the following parameters:');
console.log(`--node.staker.enable-fast-confirmation=true`);
console.log(`--node.staker.fast-confirm-safe-address=${safeAddress}`);
console.log(`--node.staker.make-assertion-interval=${timeDelay}`);
console.log('');

Expand Down
12 changes: 8 additions & 4 deletions src/actions/buildInvalidateKeysetHash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,24 @@ export type BuildInvalidateKeysetHashReturnType = PrepareTransactionRequestRetur

export async function buildInvalidateKeysetHash<TChain extends Chain | undefined>(
client: PublicClient<Transport, TChain>,
params: BuildInvalidateKeysetHashParameters,
{
account,
upgradeExecutor,
sequencerInbox: sequencerInboxAddress,
params,
}: BuildInvalidateKeysetHashParameters,
): Promise<BuildInvalidateKeysetHashReturnType> {
const validatedPublicClient = validateParentChainPublicClient(client);
const { account, upgradeExecutor, sequencerInbox: sequencerInboxAddress, ...args } = params;

const request = await client.prepareTransactionRequest({
chain: client.chain,
account,
...prepareUpgradeExecutorCallParameters({
to: sequencerInboxAddress,
upgradeExecutor,
args: [args.keysetHash],
args: [params.keysetHash],
abi: sequencerInboxABI,
functionName: 'setValidKeyset',
functionName: 'invalidateKeysetHash',
}),
} satisfies PrepareTransactionRequestParameters);

Expand Down
20 changes: 15 additions & 5 deletions src/actions/buildSetIsBatchPoster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,22 @@ export type BuildSetIsBatchPosterReturnType = PrepareTransactionRequestReturnTyp

export async function buildSetIsBatchPoster<TChain extends Chain | undefined>(
client: PublicClient<Transport, TChain>,
params: BuildSetIsBatchPosterParameters & { enable: boolean },
{
account,
upgradeExecutor,
sequencerInbox: sequencerInboxAddress,
params,
}: BuildSetIsBatchPosterParameters & { params: { enable: boolean } },
): Promise<BuildSetIsBatchPosterReturnType> {
const validatedPublicClient = validateParentChainPublicClient(client);
const { account, upgradeExecutor, sequencerInbox: sequencerInboxAddress, ...args } = params;

const request = await client.prepareTransactionRequest({
chain: client.chain,
account,
...prepareUpgradeExecutorCallParameters({
to: sequencerInboxAddress,
upgradeExecutor,
args: [args.batchPoster, args.enable],
args: [params.batchPoster, params.enable],
abi: sequencerInboxABI,
functionName: 'setIsBatchPoster',
}),
Expand All @@ -48,7 +52,10 @@ export async function buildEnableBatchPoster<TChain extends Chain | undefined>(
): Promise<BuildSetIsBatchPosterReturnType> {
return buildSetIsBatchPoster(client, {
...args,
enable: true,
params: {
...args.params,
enable: true,
},
});
}

Expand All @@ -58,6 +65,9 @@ export async function buildDisableBatchPoster<TChain extends Chain | undefined>(
): Promise<BuildSetIsBatchPosterReturnType> {
return buildSetIsBatchPoster(client, {
...args,
enable: false,
params: {
...args.params,
enable: false,
},
});
}
10 changes: 7 additions & 3 deletions src/actions/buildSetMaxTimeVariation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,22 @@ export type BuildSetMaxTimeVariationReturnType = PrepareTransactionRequestReturn

export async function buildSetMaxTimeVariation<TChain extends Chain | undefined>(
client: PublicClient<Transport, TChain>,
params: BuildSetMaxTimeVariationParameters,
{
account,
upgradeExecutor,
sequencerInbox: sequencerInboxAddress,
params,
}: BuildSetMaxTimeVariationParameters,
): Promise<BuildSetMaxTimeVariationReturnType> {
const validatedPublicClient = validateParentChainPublicClient(client);
const { account, upgradeExecutor, sequencerInbox: sequencerInboxAddress, ...args } = params;

const request = await client.prepareTransactionRequest({
chain: client.chain,
account,
...prepareUpgradeExecutorCallParameters({
to: sequencerInboxAddress,
upgradeExecutor,
args: [args],
args: [params],
abi: sequencerInboxABI,
functionName: 'setMaxTimeVariation',
}),
Expand Down
10 changes: 7 additions & 3 deletions src/actions/buildSetValidKeyset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,22 @@ export type BuildSetValidKeysetReturnType = PrepareTransactionRequestReturnTypeW

export async function buildSetValidKeyset<TChain extends Chain | undefined>(
client: PublicClient<Transport, TChain>,
params: BuildSetValidKeysetParameters,
{
account,
upgradeExecutor,
sequencerInbox: sequencerInboxAddress,
params,
}: BuildSetValidKeysetParameters,
): Promise<BuildSetValidKeysetReturnType> {
const validatedPublicClient = validateParentChainPublicClient(client);
const { account, upgradeExecutor, sequencerInbox: sequencerInboxAddress, ...args } = params;

const request = await client.prepareTransactionRequest({
chain: client.chain,
account,
...prepareUpgradeExecutorCallParameters({
to: sequencerInboxAddress,
upgradeExecutor,
args: [args.keyset],
args: [params.keyset],
abi: sequencerInboxABI,
functionName: 'setValidKeyset',
}),
Expand Down
4 changes: 2 additions & 2 deletions src/actions/getMaxTimeVariation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ export type GetMaxTimeVariationReturnType = {

export async function getMaxTimeVariation<TChain extends Chain | undefined>(
client: PublicClient<Transport, TChain>,
args: GetMaxTimeVariationParameters,
{ sequencerInbox }: GetMaxTimeVariationParameters,
): Promise<GetMaxTimeVariationReturnType> {
const [delayBlocks, futureBlocks, delaySeconds, futureSeconds] = await client.readContract({
abi: sequencerInboxABI,
functionName: 'maxTimeVariation',
address: args.sequencerInbox,
address: sequencerInbox,
});
return {
delayBlocks,
Expand Down
6 changes: 3 additions & 3 deletions src/actions/isBatchPoster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ export type IsBatchPosterReturnType = ReadContractReturnType<

export async function isBatchPoster<TChain extends Chain | undefined>(
client: PublicClient<Transport, TChain>,
args: IsBatchPosterParameters,
{ sequencerInbox, params }: IsBatchPosterParameters,
): Promise<IsBatchPosterReturnType> {
return client.readContract({
abi: sequencerInboxABI,
functionName: 'isBatchPoster',
address: args.sequencerInbox,
args: [args.batchPoster],
address: sequencerInbox,
args: [params.batchPoster],
});
}
6 changes: 3 additions & 3 deletions src/actions/isValidKeysetHash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ export type IsValidKeysetHashReturnType = ReadContractReturnType<

export async function isValidKeysetHash<TChain extends Chain | undefined>(
client: PublicClient<Transport, TChain>,
args: IsValidKeysetHashParameters,
{ sequencerInbox, params }: IsValidKeysetHashParameters,
): Promise<IsValidKeysetHashReturnType> {
return client.readContract({
abi: sequencerInboxABI,
functionName: 'isValidKeysetHash',
address: args.sequencerInbox,
args: [args.keysetHash],
address: sequencerInbox,
args: [params.keysetHash],
});
}
Loading

0 comments on commit ed86dfa

Please sign in to comment.