Skip to content

Commit

Permalink
Fjord (#573)
Browse files Browse the repository at this point in the history
* snapshot, p256-verifier update

* deploy send verifier using precompile

* include fjord send verifier fixture

forgot to use fork in submodule
more submodules

* save verifier upgrade

* version base sepolia verifier deploy

* add UpgradeSendVerifier script

* fixup home activity spec

* fix up specs

* fix up tiltfiles
  • Loading branch information
0xBigBoss authored Jul 12, 2024
1 parent 7281ea3 commit c47bd56
Show file tree
Hide file tree
Showing 22 changed files with 482 additions and 169 deletions.
2 changes: 2 additions & 0 deletions .env.local.template
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@ SUPABASE_DB_URL=postgresql://postgres:postgres@localhost:54322/postgres
SUPABASE_JWT_SECRET=super-secret-jwt-token-with-at-least-32-characters-long
SUPABASE_SERVICE_ROLE=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImV4cCI6MTk4MzgxMjk5Nn0.EGIM96RAZx35lJzdJsyH-qQwv8Hdp7fsn3W0YpN81IU
# NEXT_PUBLIC_ENABLE_QUERY_DEV_TOOLS=1
# Enables more logging for sendapp
# DEBUG="api:*,app:*,test:*,-test:fixtures:snaplet:*"
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ jobs:

steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Setup Environment
uses: ./.github/actions/setup-env
with:
Expand All @@ -37,6 +39,8 @@ jobs:

steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Setup Environment
uses: ./.github/actions/setup-env
env:
Expand Down
20 changes: 10 additions & 10 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
[submodule "packages/contracts/lib/forge-std"]
path = packages/contracts/lib/forge-std
url = https://github.com/foundry-rs/forge-std
path = packages/contracts/lib/forge-std
url = https://github.com/foundry-rs/forge-std
[submodule "packages/contracts/lib/openzeppelin-contracts"]
path = packages/contracts/lib/openzeppelin-contracts
url = https://github.com/OpenZeppelin/openzeppelin-contracts
path = packages/contracts/lib/openzeppelin-contracts
url = https://github.com/OpenZeppelin/openzeppelin-contracts
[submodule "packages/contracts/lib/account-abstraction"]
path = packages/contracts/lib/account-abstraction
url = https://github.com/eth-infinitism/account-abstraction
path = packages/contracts/lib/account-abstraction
url = https://github.com/eth-infinitism/account-abstraction
[submodule "packages/contracts/lib/openzeppelin-contracts-upgradeable"]
path = packages/contracts/lib/openzeppelin-contracts-upgradeable
url = https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable
path = packages/contracts/lib/openzeppelin-contracts-upgradeable
url = https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable
[submodule "packages/contracts/lib/p256-verifier"]
path = packages/contracts/lib/p256-verifier
url = https://github.com/daimo-eth/p256-verifier
path = packages/contracts/lib/p256-verifier
url = https://github.com/0xbigboss/p256-verifier
25 changes: 13 additions & 12 deletions Tiltfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,19 @@ if CI:
if not os.path.exists(".env.local"):
local("cp .env.local.template .env.local")
print(color.green("📝 Created .env.local"))
if CFG.dockerize:
sed = str(local("which gsed || which sed")).strip()
if sed == "":
print(color.red("Could not find sed. Please install it and try again."))
exit(1)

# replace NEXT_PUBLIC_SUPABASE_URL with the dockerized supabase url
local(sed + " -i 's/localhost/host.docker.internal/' .env.local")

# except NEXT_PUBLIC_URL
local(sed + " -i 's/NEXT_PUBLIC_URL=http:\\/\\/host.docker.internal/NEXT_PUBLIC_URL=http:\\/\\/localhost/' .env.local")
print(color.green("📝 Dockerized .env.local"))

if CFG.dockerize:
print(color.green("📝 Dockerizing .env.local"))
sed = str(local("which gsed || which sed")).strip()
if sed == "":
print(color.red("Could not find sed. Please install it and try again."))
exit(1)

# replace NEXT_PUBLIC_SUPABASE_URL with the dockerized supabase url
local(sed + " -i 's/localhost/host.docker.internal/' .env.local")

# except NEXT_PUBLIC_URL
local(sed + " -i 's/NEXT_PUBLIC_URL=http:\\/\\/host.docker.internal/NEXT_PUBLIC_URL=http:\\/\\/localhost/' .env.local")

for dotfile in [
".env",
Expand Down
6 changes: 4 additions & 2 deletions packages/api/src/routers/sendAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,8 @@ export const sendAccountRouter = createTRPCRouter({
})
}

log('createAccount', `hash=${hash}`)

await withRetry(
async function waitForTransactionReceipt() {
const { count, error } = await supabaseAdmin
Expand All @@ -261,7 +263,7 @@ export const sendAccountRouter = createTRPCRouter({
.eq('account', hexToBytea(senderAddress))
.single()
throwIf(error)
log('waitForTransactionReceipt', `count=${count}`)
log('waitForTransactionReceipt', `hash=${hash}`, `count=${count}`)
return count
},
{
Expand All @@ -273,7 +275,7 @@ export const sendAccountRouter = createTRPCRouter({
},
shouldRetry({ count, error }) {
// @todo handle other errors like balance not enough, invalid nonce, etc
console.error('waitForTransactionReceipt failed', count, error)
console.error('waitForTransactionReceipt failed', { count, error, hash })
if (error.message.includes('Failed to create send account')) {
return false
}
Expand Down
70 changes: 70 additions & 0 deletions packages/contracts/.gas-snapshot
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
AccountFactoryTest:testDeploy() (gas: 240957)
AccountSendUseropTest:testETHTransferOp() (gas: 952654)
AccountSendUseropTest:testSignP256() (gas: 346060)
AccountSendUseropTest:testSimpleOp() (gas: 3135283)
AccountSendUseropTest:testValidUntil() (gas: 1174209)
AccountSigningKeysTest:testAddingAndRemovingKeys() (gas: 251599)
AccountSigningKeysTest:testGetSigningKeys() (gas: 941870)
AccountVerify1271Test:testSignatureMalleability() (gas: 500496)
AccountVerify1271Test:testVerifySig() (gas: 471635)
BaseSepoliaTokenPaymasterTest:testItDoesNotFailOOG() (gas: 2651338)
BaseSepoliaTokenPaymasterTest:testItFails() (gas: 2571863)
BaseSepoliaTokenPaymasterTest:testItFailsOOG() (gas: 2657060)
DeploySendAccountFactoryTest:testItRuns() (gas: 7951846)
DeploySendMerkleDropTest:testItRuns() (gas: 2941015)
DeploySendVerifierTest:testItRuns() (gas: 4011929)
OracleHelperTest:testCannotDeployAsTokenToNativeOracleWithNonZeroAddress() (gas: 261294)
OracleHelperTest:testPriceConversionExamples() (gas: 146743)
OracleHelperTest:testWithOneHopDirectPriceEthToToken() (gas: 107306)
OracleHelperTest:testWithOneHopReversePriceTokenToEth() (gas: 110385)
OracleHelperTest:testWithTwoHopPriceUsdToTokenAndUsdToEth() (gas: 141354)
OracleHelperTest:testWithTwoHopPriceUsdcToTokenAndUsdcToEth() (gas: 141380)
SendCheckHelper:testECDSA(address) (runs: 256, μ: 12083, ~: 12083)
SendCheckTest:testAuthorizedFlow() (gas: 184566)
SendCheckTest:testCannotClaimNonExistentCheck() (gas: 168782)
SendCheckTest:testCannotClaimRedeemedCheck() (gas: 187676)
SendCheckTest:testCannotClaimSelf() (gas: 293872)
SendCheckTest:testCannotCreateCheck() (gas: 152176)
SendCheckTest:testClaimSelf() (gas: 175527)
SendCheckTest:testCreateCheck() (gas: 155899)
SendCheckTest:testECDSA(address) (runs: 256, μ: 12083, ~: 12083)
SendCheckTest:testUnauthorizedFlow() (gas: 182451)
SendMerkleDropTest:test_AllowSingleTrancheClaim() (gas: 104486)
SendMerkleDropTest:test_DenyDoubleClaim() (gas: 35711)
TestUSDCTest:testCoin() (gas: 607178)
TokenPaymaster6Test:testCall() (gas: 154373)
TokenPaymaster6Test:testDeploy() (gas: 15084)
TokenPaymaster6Test:testFuzzTransfersCorrectAmountRewardPool(uint40,uint256) (runs: 256, μ: 303153, ~: 304920)
TokenPaymaster6Test:testFuzz_UpdateOracleConfigSuccess(uint48,uint48,uint256) (runs: 256, μ: 51124, ~: 51237)
TokenPaymaster6Test:testFuzz_UpdatePrice(uint256) (runs: 256, μ: 57659, ~: 57659)
TokenPaymaster6Test:testFuzz_UpdateTokenPaymasterConfigFailMarkupTooHigh(uint256,uint40) (runs: 256, μ: 20723, ~: 21004)
TokenPaymaster6Test:testFuzz_UpdateTokenPaymasterConfigFailMarkupTooLow(uint256,uint40) (runs: 256, μ: 20550, ~: 20289)
TokenPaymaster6Test:testFuzz_UpdateTokenPaymasterConfigSuccess(uint256,uint128,uint48,uint48,uint40,address) (runs: 256, μ: 39579, ~: 39599)
TokenPaymaster6Test:testFuzz_UpdateUniswapConfigSuccess(uint256,uint24,uint8) (runs: 256, μ: 26748, ~: 26913)
TokenPaymaster6Test:testFuzz_WithdrawNativeAsset(uint256) (runs: 256, μ: 47675, ~: 48295)
TokenPaymaster6Test:testFuzz_WithdrawToken(uint256) (runs: 256, μ: 59475, ~: 59919)
TokenPaymaster6Test:testInvalidDataLength() (gas: 100859)
TokenPaymaster6Test:testOnlyOwnerCanUpdateOracleConfig() (gas: 19668)
TokenPaymaster6Test:testOnlyOwnerCanUpdateTokenPaymasterConfig() (gas: 17156)
TokenPaymaster6Test:testOnlyOwnerCanUpdateUniswapConfig() (gas: 14354)
TokenPaymaster6Test:testOwnershipTransfer() (gas: 21890)
TokenPaymaster6Test:testPaymasterShouldRejectIfPostOpGasLimitIsTooLow() (gas: 105175)
TokenPaymaster6Test:testRewardShareTransfersCorrectAmount() (gas: 307242)
TokenPaymaster6Test:testShouldBeAbleToSponsorTheUserOpWhileChargingCorrectAmountOfERC20Tokens() (gas: 302918)
TokenPaymaster6Test:testShouldChargeTheOverdraftTokensIfThePreChargeEndedUpLowerThanTheFinalTransactionCost() (gas: 345595)
TokenPaymaster6Test:testShouldRejectIfAccountDoesNotHaveEnoughTokensOrAllowance() (gas: 151612)
TokenPaymaster6Test:testShouldRevertIfCachedTokenPriceIsExpired() (gas: 200451)
TokenPaymaster6Test:testShouldRevertInTheFirstPostOpRunIfThePreChargeEndedUpLowerThanTheFinalTransactionCostButTheClientHasNoTokensToCoverTheOverdraft() (gas: 375311)
TokenPaymaster6Test:testShouldSponserUserOperationExample() (gas: 345737)
TokenPaymaster6Test:testShouldSponsorUserOperationWithInitCode() (gas: 442183)
TokenPaymaster6Test:testShouldSwapTokensForEtherIfItFallsBelowConfiguredValueAndDepositIt() (gas: 398338)
TokenPaymaster6Test:testShouldUpdateCachedTokenPriceIfTheChangeIsAboveConfiguredPercentage() (gas: 346125)
TokenPaymaster6Test:testShouldUpdateTokenPriceIfCacheIsExpired() (gas: 321959)
TokenPaymaster6Test:testShouldUseCachedTokenPriceIfTheOneSuppliedByTheClientIsWorse() (gas: 297841)
TokenPaymaster6Test:testShouldUseTokenPriceSuppliedByTheClientIfItIsBetterThanCached() (gas: 297489)
TokenPaymaster6Test:testUpdatePrice() (gas: 56938)
TokenPaymaster6Test:testWithdrawNativeAsset() (gas: 52675)
TokenPaymaster6Test:testWithdrawToken(uint256) (runs: 256, μ: 63163, ~: 63607)
UpgradeableVerifierBrick:test() (gas: 184)
VerifierBrick:test() (gas: 120)
VerifierTest:testUpgrade() (gas: 1680407)
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
{
"transactions": [
{
"hash": "0x7ccd2d7f386faf63521eb57987e3db26a729a504c54afad2d097d868f0d3f954",
"transactionType": "CALL",
"contractName": null,
"contractAddress": "0x6c38612d3f645711dd080711021fc1ba998a5628",
"function": "upgradeTo(address)",
"arguments": [
"0xe46056eBA301069A9E5a166b424b5Cb86b0Cf6E6"
],
"transaction": {
"from": "0x647eb43401e13e995d89cf26cd87e68890ee3f89",
"to": "0x6c38612d3f645711dd080711021fc1ba998a5628",
"gas": "0xd23d",
"value": "0x0",
"input": "0x3659cfe6000000000000000000000000e46056eba301069a9e5a166b424b5cb86b0cf6e6",
"nonce": "0xc",
"chainId": "0x14a34"
},
"additionalContracts": [],
"isFixedGasLimit": false
}
],
"receipts": [
{
"status": "0x1",
"cumulativeGasUsed": "0x5fc22",
"logs": [
{
"address": "0x6c38612d3f645711dd080711021fc1ba998a5628",
"topics": [
"0xbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b",
"0x000000000000000000000000e46056eba301069a9e5a166b424b5cb86b0cf6e6"
],
"data": "0x",
"blockHash": "0x2ddc8ebef959db8d081ecc4f9c82c8b148e6d76729d0bdc80dffbb96b29eb930",
"blockNumber": "0xbe69c0",
"transactionHash": "0x7ccd2d7f386faf63521eb57987e3db26a729a504c54afad2d097d868f0d3f954",
"transactionIndex": "0x3",
"logIndex": "0x6",
"removed": false
}
],
"logsBloom": "0x00000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000004020000000000000000000000000000004000000020000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"type": "0x2",
"transactionHash": "0x7ccd2d7f386faf63521eb57987e3db26a729a504c54afad2d097d868f0d3f954",
"transactionIndex": "0x3",
"blockHash": "0x2ddc8ebef959db8d081ecc4f9c82c8b148e6d76729d0bdc80dffbb96b29eb930",
"blockNumber": "0xbe69c0",
"gasUsed": "0x8fc1",
"effectiveGasPrice": "0x499b6",
"from": "0x647eb43401e13e995d89cf26cd87e68890ee3f89",
"to": "0x6c38612d3f645711dd080711021fc1ba998a5628",
"contractAddress": null,
"l1BaseFeeScalar": "0x44d",
"l1BlobBaseFee": "0x1",
"l1BlobBaseFeeScalar": "0xa118b",
"l1Fee": "0xbdc1dc33",
"l1GasPrice": "0x6bb7fcbd",
"l1GasUsed": "0x640"
}
],
"libraries": [],
"pending": [],
"returns": {},
"timestamp": 1720726138,
"chain": 84532,
"commit": "2850a3b1"
}
Loading

0 comments on commit c47bd56

Please sign in to comment.