Skip to content

Commit

Permalink
Release/v0.7.1 (#876)
Browse files Browse the repository at this point in the history
* [AA] First draft defaults (#837)

* first draft defaults

* feedback, defaults

* bundler fix: number<>string defaults

---------

Co-authored-by: Ino Murko <[email protected]>
(cherry picked from commit 41a6aff)

* [AA] optimization: paymasterAndData for aa-sdk (#871)

* paymaster api

* switch-to-signed

* generalized, tests adapted

(cherry picked from commit 710270e)

* fix for crash on wallet page (#873)

(cherry picked from commit e93822d)

* remove unused vars (#875)

(cherry picked from commit fbb0a89)

---------

Co-authored-by: Riedl Kevin, Bsc <[email protected]>
Co-authored-by: Sahil K <[email protected]>
  • Loading branch information
3 people authored Jun 2, 2023
1 parent 9963ad1 commit b12808e
Show file tree
Hide file tree
Showing 18 changed files with 145 additions and 204 deletions.
2 changes: 1 addition & 1 deletion integration-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
"@boba/accountabstraction": "1.0.0",
"@boba/api": "0.0.1",
"@boba/contracts": "0.0.1",
"@bobanetwork/bundler_sdk": "*",
"@eth-optimism/contracts": "^0.5.11",
"@bobanetwork/bundler_sdk": "file:../packages/boba/bundler_sdk",
"@eth-optimism/core-utils": "0.8.1",
"@eth-optimism/sdk": "1.0.1",
"@ethersproject/abstract-provider": "^5.5.0",
Expand Down
14 changes: 6 additions & 8 deletions integration-tests/test/alt-l2/boba_aa_alt_fee_token.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { OptimismEnv } from './shared/env'
import { hexConcat, hexZeroPad, parseEther } from 'ethers/lib/utils'
import { predeploys } from '@eth-optimism/contracts'
// use local sdk
import { SimpleAccountAPI } from '@bobanetwork/bundler_sdk'
import { PaymasterAPI, SimpleAccountAPI } from "@bobanetwork/bundler_sdk";
import SimpleAccountJson from '@boba/accountabstraction/artifacts/contracts/samples/SimpleAccount.sol/SimpleAccount.json'
import SimpleAccountFactoryJson from '@boba/accountabstraction/artifacts/contracts/samples/SimpleAccountFactory.sol/SimpleAccountFactory.json'
import L2StandardERC20Json from '@eth-optimism/contracts/artifacts/contracts/standards/L2StandardERC20.sol/L2StandardERC20.json'
Expand Down Expand Up @@ -153,17 +153,15 @@ describe('AA Alt-L1 Alt Token as Paymaster Fee Test\n', async () => {
})

it('should be able to submit a userOp including the paymaster to the bundler and trigger tx', async () => {
const op = await accountAPI.createUnsignedUserOp({

accountAPI.paymasterAPI = new PaymasterAPI({
paymasterAndData: GPODepositPaymaster.address,
})
signedOp = await accountAPI.createSignedUserOp({
target: recipient.address,
data: recipient.interface.encodeFunctionData('something', ['hello']),
})


op.paymasterAndData = GPODepositPaymaster.address
op.preVerificationGas = await accountAPI.getPreVerificationGas(op)

signedOp = await accountAPI.signUserOp(op)

const requestId = await bundlerProvider.sendUserOpToBundler(signedOp)
const txid = await accountAPI.getUserOpReceipt(requestId)
console.log('reqId', requestId, 'txid=', txid)
Expand Down
17 changes: 8 additions & 9 deletions integration-tests/test/eth-l2/boba_aa_fee_alt_token.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { getFilteredLogIndex } from './shared/utils'
import { OptimismEnv } from './shared/env'
import { hexConcat, hexZeroPad, parseEther } from 'ethers/lib/utils'
// use local sdk
import { SimpleAccountAPI } from '@bobanetwork/bundler_sdk'
import { PaymasterAPI, SimpleAccountAPI } from "@bobanetwork/bundler_sdk";
import SenderCreatorJson from '@boba/accountabstraction/artifacts/contracts/core/SenderCreator.sol/SenderCreator.json'
import SimpleAccountFactoryJson from '@boba/accountabstraction/artifacts/contracts/samples/SimpleAccountFactory.sol/SimpleAccountFactory.json'
import L2StandardERC20Json from '@eth-optimism/contracts/artifacts/contracts/standards/L2StandardERC20.sol/L2StandardERC20.json'
Expand Down Expand Up @@ -210,17 +210,16 @@ describe('AA Alt Fee Token Test\n', async () => {
)

it('should be able to submit a userOp including the paymaster to the bundler and trigger tx', async () => {
const op = await accountAPI.createUnsignedUserOp({
accountAPI.paymasterAPI = new PaymasterAPI({
paymasterAndData: hexConcat([
ManualDepositPaymaster.address,
hexZeroPad(L2ERC20Token.address, 20),
]),
})
signedOp = await accountAPI.createSignedUserOp({
target: recipient.address,
data: recipient.interface.encodeFunctionData('something', ['hello']),
})
op.paymasterAndData = hexConcat([
ManualDepositPaymaster.address,
hexZeroPad(L2ERC20Token.address, 20),
])
op.preVerificationGas = await accountAPI.getPreVerificationGas(op)

signedOp = await accountAPI.signUserOp(op)

const requestId = await bundlerProvider.sendUserOpToBundler(signedOp)
const txid = await accountAPI.getUserOpReceipt(requestId)
Expand Down
21 changes: 9 additions & 12 deletions integration-tests/test/eth-l2/boba_aa_fee_boba.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ import { getFilteredLogIndex } from './shared/utils'
import { OptimismEnv } from './shared/env'
import { hexConcat, hexZeroPad, parseEther } from 'ethers/lib/utils'
// use local sdk
import { SimpleAccountAPI } from '@bobanetwork/bundler_sdk'
import SenderCreatorJson from '@boba/accountabstraction/artifacts/contracts/core/SenderCreator.sol/SenderCreator.json'
import { PaymasterAPI, SimpleAccountAPI } from '@bobanetwork/bundler_sdk'
import SimpleAccountFactoryJson from '@boba/accountabstraction/artifacts/contracts/samples/SimpleAccountFactory.sol/SimpleAccountFactory.json'
import MockFeedRegistryJson from '@boba/accountabstraction/artifacts/contracts/test/mocks/MockFeedRegistry.sol/MockFeedRegistry.json'
import L2GovernanceERC20Json from '@boba/contracts/artifacts/contracts/standards/L2GovernanceERC20.sol/L2GovernanceERC20.json'
Expand Down Expand Up @@ -193,20 +192,18 @@ describe('AA Boba as Fee token Test\n', async () => {
}
)
it('should be able to submit a userOp including the paymaster to the bundler and trigger tx', async () => {
const op = await accountAPI.createUnsignedUserOp({
accountAPI.paymasterAPI = new PaymasterAPI({
paymasterAndData: hexConcat([
BobaDepositPaymaster.address,
hexZeroPad(L2BOBAToken.address, 20),
])
})

signedOp = await accountAPI.createSignedUserOp({
target: recipient.address,
data: recipient.interface.encodeFunctionData('something', ['hello']),
})

// TODO: check why paymasterAndData does not work when added to the walletAPI
op.paymasterAndData = hexConcat([
BobaDepositPaymaster.address,
hexZeroPad(L2BOBAToken.address, 20),
])
op.preVerificationGas = await accountAPI.getPreVerificationGas(op)

signedOp = await accountAPI.signUserOp(op)

const requestId = await bundlerProvider.sendUserOpToBundler(signedOp)
const txid = await accountAPI.getUserOpReceipt(requestId)
console.log('reqId', requestId, 'txid=', txid)
Expand Down
2 changes: 1 addition & 1 deletion packages/boba/bundler/bundler.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
set -e

node --trace-warnings --no-deprecation bundler.js --minBalance $MIN_BALANCE --mnemonic $MNEMONIC_OR_PK --network $L2_NODE_WEB3_URL --beneficiary $BENEFICIARY --addressManager $ADDRESS_MANAGER_ADDRESS --l1NodeWeb3Url $L1_NODE_WEB3_URL --maxBundleGas $MAX_BUNDLE_GAS --unsafe $UNSAFE
node --trace-warnings --no-deprecation bundler.js --minBalance $MIN_BALANCE --mnemonic $MNEMONIC_OR_PK --network $L2_NODE_WEB3_URL --beneficiary $BENEFICIARY --addressManager $ADDRESS_MANAGER_ADDRESS --l1NodeWeb3Url $L1_NODE_WEB3_URL --maxBundleGas $MAX_BUNDLE_GAS --unsafe $UNSAFE --minStake 0.2 --minUnstakeDelay 86400
18 changes: 9 additions & 9 deletions packages/boba/bundler/src/BundlerConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import ow from 'ow'

export interface BundlerConfig {
beneficiary: string
entryPoint: string
entryPoint?: string
entryPointWrapper?: string
gasFactor: string
minBalance: string
Expand All @@ -29,7 +29,7 @@ export interface BundlerConfig {
// TODO: implement merging config (args -> config.js -> default) and runtime shape validation
export const BundlerConfigShape = {
beneficiary: ow.string,
entryPoint: ow.string,
entryPoint: ow.optional.string,
entryPointWrapper: ow.optional.string,
gasFactor: ow.string,
minBalance: ow.string,
Expand All @@ -52,18 +52,18 @@ export const BundlerConfigShape = {
logsChunkSize: ow.optional.number,
}

// TODO: consider if we want any default fields at all
// TODO: implement merging config (args -> config.js -> default) and runtime shape validation
// Defaults taken from eth-infinitism repo
export const bundlerConfigDefault: Partial<BundlerConfig> = {
port: '3000',
entryPoint: '0x1306b01bC3e4AD202612D3843387e94737673F53',
entryPoint: '0xa6e2cbb294d3b84e7900daf0052ffe26bb1328ff',
unsafe: false,
conditionalRpc: false,
minStake: '1',
minUnstakeDelay: 60,
autoBundleInterval: 1,
autoBundleMempoolSize: 1,
minStake: '0.0001', // testnet default
minUnstakeDelay: 5 * 60, // in seconds, testnet default (5 min)
autoBundleInterval: 3,
autoBundleMempoolSize: 10,
enableDebugMethods: false,
gasFactor: '1',
l2Offset: 0,
logsChunkSize: 5000,
}
3 changes: 3 additions & 0 deletions packages/boba/bundler/src/Config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ function getCommandLineParams (programOpts: any): Partial<BundlerConfig> {
}
console.log(params['maxBundleGas'])
params['maxBundleGas'] = parseInt(params['maxBundleGas'], 10)
params['minUnstakeDelay'] = parseInt(params['minUnstakeDelay'], 10)
params['autoBundleInterval'] = parseInt(params['autoBundleInterval'], 10)
params['autoBundleMempoolSize'] = parseInt(params['autoBundleMempoolSize'], 10)
return params as BundlerConfig
}

Expand Down
6 changes: 5 additions & 1 deletion packages/boba/bundler/src/runBundler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,11 @@ export async function runBundler(
.option('--addressManager <string>', 'address of the Address Manager', '')
.option('--l1NodeWeb3Url <string>', 'L1 network url for Address Manager', '')
.option('--maxBundleGas <number>', 'Max Bundle Gas available to use', '5000000')
.option('--enableDebugMethods', 'debug_* methods available', false)
.option('--enableDebugMethods <boolean>', 'debug_* methods available', false)
.option('--minStake <string>', 'Min stake for Entrypoint', '0.0001')
.option('--minUnstakeDelay <number>', 'Minimum unstake delay in seconds', '300')
.option('--autoBundleInterval <number>', 'Auto Bundle interval', '3')
.option('--autoBundleMempoolSize <number>', 'Auto Bundle Mempool Size', '10')
.option('--l2Offset <number>', 'l2 Offset to start from')
.option('--logsChunkSize <number>', 'eth_getLogs range supported by network')

Expand Down
9 changes: 8 additions & 1 deletion packages/boba/bundler_sdk/src/PaymasterAPI.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
import { UserOperationStruct } from '@boba/accountabstraction'
import { hexConcat, hexZeroPad } from 'ethers/lib/utils'

export interface IPaymasterAPIConfig {
paymasterAndData?: string
}

/**
* an API to external a UserOperation with paymaster info
*/
export class PaymasterAPI {
constructor(private config?: IPaymasterAPIConfig) {}

/**
* @param userOp a partially-filled UserOperation (without signature and paymasterAndData
* note that the "preVerificationGas" is incomplete: it can't account for the
* paymasterAndData value, which will only be returned by this method..
* @returns the value to put into the PaymasterAndData, undefined to leave it empty
*/
async getPaymasterAndData (userOp: Partial<UserOperationStruct>): Promise<string | undefined> {
return '0x'
return this.config.paymasterAndData ?? '0x'
}
}
61 changes: 61 additions & 0 deletions packages/boba/gateway/src/components/PulseBadge/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import React, { ReactNode } from 'react'
import styled from 'styled-components'

type VariantType = 'info' | 'success' | 'danger' | 'warning'

const Badge = styled.span<{ variant: VariantType }>(({ theme, variant }) => ({
display: 'inline-block',
color: `${theme.colors[variant]}`,
borderRadius: '100%',
margin: '0 10px',
border: `1px solid ${theme.colors[variant]}`,
}))

const Circle = styled.span<{ variant: VariantType }>(({ theme, variant }) => ({
margin: 5,
display: 'block',
width: 8,
height: 8,
borderRadius: '50%',
backgroundColor: `${theme.colors[variant]}`,
boxShadow: `0 0 0 ${theme.colors[variant]}`,
animation: `pulsing 1500ms ease-in-out infinite`,
'@keyframes pulsing': {
'0%': {
boxShadow: `0 0 0 0 ${theme.colors[variant]}`,
},
'70%': {
boxShadow: `0 0 0 4px ${theme.colors[variant]}`,
},
'100%': {
boxShadow: `0 0 0 0 ${theme.colors[variant]}`,
},
},
}))

const PulseContainer = styled.span`
display: flex;
justify-content: center;
align-items: center;
`

interface PulseBadgeProps {
children: ReactNode
variant: VariantType
}

export const PulseBadge: React.FC<PulseBadgeProps> = ({
children,
variant = 'info',
}) => {
return (
<PulseContainer>
<Badge variant={variant}>
<Circle variant={variant} />
</Badge>
{children}
</PulseContainer>
)
}

export default PulseBadge
Loading

0 comments on commit b12808e

Please sign in to comment.