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

Optimism Dispute Game Support #45

Open
wants to merge 42 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
e067035
Fix JsonRpcSigner undefined by upgrading hardhat-deploy
Chomtana May 8, 2024
ec7b9a4
import OPProofService for dispute game verifier
Chomtana May 8, 2024
fe2f837
Complete OP dispute game verifier and gateway with single file
Chomtana May 19, 2024
e2ae2bb
Update gateway and verifier logic for a better pattern
Chomtana May 21, 2024
ca40519
Remove debug on unit test
Chomtana May 21, 2024
b5136da
Update OPProofService to use OPOutputLookup contract
Chomtana Jun 6, 2024
9890ec6
Upgrade OP Verifier to use OPOutputLookup that handle the min max age…
Chomtana Jun 7, 2024
a6cf7ce
Merge
Chomtana Jun 7, 2024
4fb8bdb
Fix evm-gateway dependency
Chomtana Jun 7, 2024
47606e4
Merge OPVerifier
Chomtana Jun 7, 2024
fb19f34
Merge branch 'main' of https://github.com/ensdomains/evmgateway into …
Chomtana Jul 15, 2024
1618d38
Directly import eth optimism and include helper code in the repo
Chomtana Jul 15, 2024
40a1791
OPOutputLookup deployment script
Chomtana Jul 15, 2024
4c01554
Merge branch 'main' of https://github.com/ensdomains/evmgateway into …
Chomtana Jul 15, 2024
eee7399
Using interpolation search
Chomtana Jul 28, 2024
9aa3023
Add document about OPOutputLookup deployment calldata
Chomtana Jul 28, 2024
65f82ac
Detect challenging game and fix interpolation search revert
Chomtana Aug 2, 2024
0c5e89c
Fix interpolation search revert
Chomtana Aug 2, 2024
85e39ff
Include build parameters
Chomtana Aug 2, 2024
e183fbb
Update OPOutputLookup contract address
Chomtana Aug 2, 2024
756cafc
Fix bug in challenging detection
Chomtana Aug 2, 2024
978e2d0
Fix maxAge underflow
Chomtana Aug 6, 2024
a24f470
Fix rounding error, division by 0
Chomtana Aug 13, 2024
348605a
L2outputOracle interpolation search
Chomtana Aug 13, 2024
509915a
Update new OPOutputLookup deployment detail
Chomtana Aug 13, 2024
256d4b6
added aws lambda op gateway code
cddrown Dec 12, 2024
0325937
fixed deployment
cddrown Dec 12, 2024
7b77bc1
update readme
cddrown Dec 12, 2024
9440e16
rewrite to use NodejsFunction
cddrown Dec 13, 2024
c62ca56
fixed server path
cddrown Dec 13, 2024
0c2fefb
small change to readme
cddrown Dec 13, 2024
1b5ac5f
routing fixes
cddrown Dec 16, 2024
a036b4b
fixes to lambda gateway
cddrown Dec 18, 2024
2a79ece
Updated contract deps
cddrown Dec 19, 2024
c91cb2f
downgrade router ethers type references
cddrown Dec 20, 2024
0203734
clean up debugging messages
cddrown Dec 20, 2024
7890226
Remove unreferenced file
cddrown Dec 20, 2024
04a19a9
clean-up
cddrown Dec 20, 2024
09ca532
Changed api gateway name
cddrown Dec 20, 2024
762487c
fix readme
cddrown Dec 20, 2024
5ef5ce4
clean-up
cddrown Dec 20, 2024
fe2788b
Merge pull request #1 from cddrown/op-fault-proof-new
Chomtana Jan 7, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ cache
typechain-types
.wrangler
.yalc
.vscode
4 changes: 2 additions & 2 deletions arb-verifier/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
"express": "^4.18.2",
"ganache": "^7.9.1",
"hardhat": "^2.16.0",
"hardhat-deploy": "^0.11.43",
"hardhat-deploy-ethers": "^0.4.1",
"hardhat-deploy": "^0.12.4",
"hardhat-deploy-ethers": "^0.4.2",
"hardhat-gas-reporter": "^1.0.8",
"solidity-bytes-utils": "^0.8.0",
"solidity-coverage": "^0.8.1",
Expand Down
Binary file modified bun.lockb
Binary file not shown.
2 changes: 1 addition & 1 deletion l1-verifier/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"typescript": "^5.2.2"
},
"dependencies": {
"@ensdomains/evm-verifier": "0.1.0-beta.4",
"@ensdomains/evm-verifier": "workspace:*",
"@eth-optimism/contracts": "^0.6.0",
"@eth-optimism/contracts-bedrock": "^0.16.2"
}
Expand Down
10 changes: 10 additions & 0 deletions op-gateway/op-gateway-lambda/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
*.js
!jest.config.js
*.d.ts
node_modules

# CDK asset staging directory
.cdk.staging
cdk.out

.env
6 changes: 6 additions & 0 deletions op-gateway/op-gateway-lambda/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
*.ts
!*.d.ts

# CDK asset staging directory
.cdk.staging
cdk.out
59 changes: 59 additions & 0 deletions op-gateway/op-gateway-lambda/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Prerequisites

## Install AWS CLI and CDK

Refer to https://docs.aws.amazon.com/cdk/v2/guide/getting_started.html for instructions.

## Configure AWS SSO

In order to give cdk functions access to your AWS account, configure AWS single sign-on (SSO) to connect to an IAM Identity Centre login.

See https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-sso.html for full details.

# Deployment

1. Log into AWS SSO if not already logged in.
```
aws sso login --profile <profile-name>
```
The --profile argument can be omitted if the profile is called 'default'.

2. Set the following environment variables or add to a .env file in this directory. Alternatively these environment variables can be set later in the AWS Lambda function console.

- L1_PROVIDER_URL
- L2_PROVIDER_URL
- L2_OPTIMISM_PORTAL
- DELAY
- GATEWAY_DOMAIN
- ENDPOINT_URL

3. Deploy with the following steps
```
cdk bootstrap
cdk synth
cdk deploy
```
The lambda url is output towards the end of the last step under 'Outputs' as follows.
```
Outputs:
OpGatewayLambdaStack.OPGatewayOpGatewayApiEndpoint... = <lambda url>
...
```
To update an existing lambda function deployment without modifying the url, only the following steps are required.
```
cdk synth
cdk deploy
```

# Removing a deployed lambda function
The lambda function can be taken down with
```
cdk destroy
```

## Other useful commands

* `npm run build` compile typescript to js
* `npm run watch` watch for changes and compile
* `npm run test` perform the jest unit tests
* `npx cdk diff` compare deployed stack with current state
11 changes: 11 additions & 0 deletions op-gateway/op-gateway-lambda/bin/op-gateway-lambda.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env node
import * as cdk from 'aws-cdk-lib';
import { OpGatewayLambdaStack } from '../lib/op-gateway-lambda-stack';

const app = new cdk.App();
new OpGatewayLambdaStack(app, 'OpGatewayLambdaStack', {
env: {
account: process.env.CDK_DEFAULT_ACCOUNT,
region: process.env.CDK_DEFAULT_REGION,
},
});
Binary file added op-gateway/op-gateway-lambda/bun.lockb
Binary file not shown.
80 changes: 80 additions & 0 deletions op-gateway/op-gateway-lambda/cdk.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
{
"app": "npx ts-node --prefer-ts-exts bin/op-gateway-lambda.ts",
"watch": {
"include": [
"**"
],
"exclude": [
"README.md",
"cdk*.json",
"**/*.d.ts",
"**/*.js",
"tsconfig.json",
"package*.json",
"yarn.lock",
"node_modules",
"test"
]
},
"context": {
"@aws-cdk/aws-lambda:recognizeLayerVersion": true,
"@aws-cdk/core:checkSecretUsage": true,
"@aws-cdk/core:target-partitions": [
"aws",
"aws-cn"
],
"@aws-cdk-containers/ecs-service-extensions:enableDefaultLogDriver": true,
"@aws-cdk/aws-ec2:uniqueImdsv2TemplateName": true,
"@aws-cdk/aws-ecs:arnFormatIncludesClusterName": true,
"@aws-cdk/aws-iam:minimizePolicies": true,
"@aws-cdk/core:validateSnapshotRemovalPolicy": true,
"@aws-cdk/aws-codepipeline:crossAccountKeyAliasStackSafeResourceName": true,
"@aws-cdk/aws-s3:createDefaultLoggingPolicy": true,
"@aws-cdk/aws-sns-subscriptions:restrictSqsDescryption": true,
"@aws-cdk/aws-apigateway:disableCloudWatchRole": true,
"@aws-cdk/core:enablePartitionLiterals": true,
"@aws-cdk/aws-events:eventsTargetQueueSameAccount": true,
"@aws-cdk/aws-ecs:disableExplicitDeploymentControllerForCircuitBreaker": true,
"@aws-cdk/aws-iam:importedRoleStackSafeDefaultPolicyName": true,
"@aws-cdk/aws-s3:serverAccessLogsUseBucketPolicy": true,
"@aws-cdk/aws-route53-patters:useCertificate": true,
"@aws-cdk/customresources:installLatestAwsSdkDefault": false,
"@aws-cdk/aws-rds:databaseProxyUniqueResourceName": true,
"@aws-cdk/aws-codedeploy:removeAlarmsFromDeploymentGroup": true,
"@aws-cdk/aws-apigateway:authorizerChangeDeploymentLogicalId": true,
"@aws-cdk/aws-ec2:launchTemplateDefaultUserData": true,
"@aws-cdk/aws-secretsmanager:useAttachedSecretResourcePolicyForSecretTargetAttachments": true,
"@aws-cdk/aws-redshift:columnId": true,
"@aws-cdk/aws-stepfunctions-tasks:enableEmrServicePolicyV2": true,
"@aws-cdk/aws-ec2:restrictDefaultSecurityGroup": true,
"@aws-cdk/aws-apigateway:requestValidatorUniqueId": true,
"@aws-cdk/aws-kms:aliasNameRef": true,
"@aws-cdk/aws-autoscaling:generateLaunchTemplateInsteadOfLaunchConfig": true,
"@aws-cdk/core:includePrefixInUniqueNameGeneration": true,
"@aws-cdk/aws-efs:denyAnonymousAccess": true,
"@aws-cdk/aws-opensearchservice:enableOpensearchMultiAzWithStandby": true,
"@aws-cdk/aws-lambda-nodejs:useLatestRuntimeVersion": true,
"@aws-cdk/aws-efs:mountTargetOrderInsensitiveLogicalId": true,
"@aws-cdk/aws-rds:auroraClusterChangeScopeOfInstanceParameterGroupWithEachParameters": true,
"@aws-cdk/aws-appsync:useArnForSourceApiAssociationIdentifier": true,
"@aws-cdk/aws-rds:preventRenderingDeprecatedCredentials": true,
"@aws-cdk/aws-codepipeline-actions:useNewDefaultBranchForCodeCommitSource": true,
"@aws-cdk/aws-cloudwatch-actions:changeLambdaPermissionLogicalIdForLambdaAction": true,
"@aws-cdk/aws-codepipeline:crossAccountKeysDefaultValueToFalse": true,
"@aws-cdk/aws-codepipeline:defaultPipelineTypeToV2": true,
"@aws-cdk/aws-kms:reduceCrossAccountRegionPolicyScope": true,
"@aws-cdk/aws-eks:nodegroupNameAttribute": true,
"@aws-cdk/aws-ec2:ebsDefaultGp3Volume": true,
"@aws-cdk/aws-ecs:removeDefaultDeploymentAlarm": true,
"@aws-cdk/custom-resources:logApiResponseDataPropertyTrueDefault": false,
"@aws-cdk/aws-s3:keepNotificationInImportedBucket": false,
"@aws-cdk/aws-ecs:reduceEc2FargateCloudWatchPermissions": true,
"@aws-cdk/aws-dynamodb:resourcePolicyPerReplica": true,
"@aws-cdk/aws-ec2:ec2SumTImeoutEnabled": true,
"@aws-cdk/aws-appsync:appSyncGraphQLAPIScopeLambdaPermission": true,
"@aws-cdk/aws-rds:setCorrectValueForDatabaseInstanceReadReplicaInstanceResourceId": true,
"@aws-cdk/core:cfnIncludeRejectComplexResourceUpdateCreatePolicyIntrinsics": true,
"@aws-cdk/aws-lambda-nodejs:sdkV3ExcludeSmithyPackages": true,
"@aws-cdk/aws-stepfunctions-tasks:fixRunEcsTaskPolicy": true
}
}
8 changes: 8 additions & 0 deletions op-gateway/op-gateway-lambda/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {
testEnvironment: 'node',
roots: ['<rootDir>/test'],
testMatch: ['**/*.test.ts'],
transform: {
'^.+\\.tsx?$': 'ts-jest'
}
};
10 changes: 10 additions & 0 deletions op-gateway/op-gateway-lambda/lib/op-gateway-lambda-stack.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import * as cdk from 'aws-cdk-lib';
import { Construct } from 'constructs';
import { OPGateway } from './op-gateway-lambda';

export class OpGatewayLambdaStack extends cdk.Stack {
constructor(scope: Construct, id: string, props?: cdk.StackProps) {
super(scope, id, props);
new OPGateway(this, 'OP-Gateway');
}
}
11 changes: 11 additions & 0 deletions op-gateway/op-gateway-lambda/lib/op-gateway-lambda.function.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Context, APIGatewayProxyResult, APIGatewayEvent } from 'aws-lambda';
import { gatewayHandler } from '../src/index';

export const handler = async (
event: APIGatewayEvent,
context: Context
): Promise<APIGatewayProxyResult> => {
console.log(`Event: ${JSON.stringify(event, null, 2)}`);
console.log(`Context: ${JSON.stringify(context, null, 2)}`);
return gatewayHandler(event, context);
};
27 changes: 27 additions & 0 deletions op-gateway/op-gateway-lambda/lib/op-gateway-lambda.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { Construct } from 'constructs';
import { NodejsFunction } from 'aws-cdk-lib/aws-lambda-nodejs';
import { LambdaRestApi } from 'aws-cdk-lib/aws-apigateway';
import { Duration } from 'aws-cdk-lib';
import dotenv from 'dotenv';

dotenv.config(); // Load environment variables from .env file

export class OPGateway extends Construct {
constructor(scope: Construct, id: string) {
super(scope, id);
const opGatewayFunction = new NodejsFunction(this, 'function', {
environment: {
l1_provider_url: process.env.L1_PROVIDER_URL || '',
l2_provider_url: process.env.L2_PROVIDER_URL || '',
l2_optimism_portal: process.env.L2_OPTIMISM_PORTAL || '',
delay: process.env.DELAY || '',
gateway_domain: process.env.GATEWAY_DOMAIN || '',
endpoint_url: process.env.ENDPOINT_URL || '',
},
timeout: Duration.seconds(15),
});
new LambdaRestApi(this, 'OpGatewayApi', {
handler: opGatewayFunction,
});
}
}
Loading