Skip to content

Commit bbeb971

Browse files
authored
Merge pull request #921 from onflow/mpeter/dry-call-apply-set-code-authorizations
Fix gas estimation insufficiency for `EIP-7702` transactions
2 parents 7e2259f + 80bd06b commit bbeb971

File tree

8 files changed

+73
-11
lines changed

8 files changed

+73
-11
lines changed

api/debug.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ func (d *DebugAPI) TraceCall(
240240
from,
241241
to,
242242
tx.Data(),
243+
tx.SetCodeAuthorizations(),
243244
tx.Value(),
244245
tx.Gas(),
245246
opts...,

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ require (
1111
github.com/holiman/uint256 v1.3.2
1212
github.com/onflow/atree v0.11.0
1313
github.com/onflow/cadence v1.8.3
14-
github.com/onflow/flow-go v0.44.0-experimental-cadence-v1.8.3.0.20251111112227-097f521427a5
14+
github.com/onflow/flow-go v0.44.0
1515
github.com/onflow/flow-go-sdk v1.9.2
1616
github.com/prometheus/client_golang v1.20.5
1717
github.com/rs/cors v1.8.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -571,8 +571,8 @@ github.com/onflow/flow-ft/lib/go/contracts v1.0.1 h1:Ts5ob+CoCY2EjEd0W6vdLJ7hLL3
571571
github.com/onflow/flow-ft/lib/go/contracts v1.0.1/go.mod h1:PwsL8fC81cjnUnTfmyL/HOIyHnyaw/JA474Wfj2tl6A=
572572
github.com/onflow/flow-ft/lib/go/templates v1.0.1 h1:FDYKAiGowABtoMNusLuRCILIZDtVqJ/5tYI4VkF5zfM=
573573
github.com/onflow/flow-ft/lib/go/templates v1.0.1/go.mod h1:uQ8XFqmMK2jxyBSVrmyuwdWjTEb+6zGjRYotfDJ5pAE=
574-
github.com/onflow/flow-go v0.44.0-experimental-cadence-v1.8.3.0.20251111112227-097f521427a5 h1:L09sNOfqIHAWD90psYCl6+sJYdx9RFDCt5IlYmgrSSY=
575-
github.com/onflow/flow-go v0.44.0-experimental-cadence-v1.8.3.0.20251111112227-097f521427a5/go.mod h1:4A34mlMMd7usjw7e0r4VrltFpZRjhYkV+T+iecTbzO0=
574+
github.com/onflow/flow-go v0.44.0 h1:I1P0t0+wUokyB4RHRLMGWy9QMf4jWg6EFcttKNtU0Rw=
575+
github.com/onflow/flow-go v0.44.0/go.mod h1:4A34mlMMd7usjw7e0r4VrltFpZRjhYkV+T+iecTbzO0=
576576
github.com/onflow/flow-go-sdk v1.9.2 h1:kMw3qShgLNIASHGMgoY+faTBQ+1MnzsNLAH+oxy9eiY=
577577
github.com/onflow/flow-go-sdk v1.9.2/go.mod h1:qVuzMGXNJBMktKnIDKLjV0/k21P2XD39dOfMW+X5Bsc=
578578
github.com/onflow/flow-nft/lib/go/contracts v1.3.0 h1:DmNop+O0EMyicZvhgdWboFG57xz5t9Qp81FKlfKyqJc=

services/requester/requester.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,7 @@ func (e *EVM) dryRunTx(
571571
from,
572572
to,
573573
tx.Data(),
574+
tx.SetCodeAuthorizations(),
574575
tx.Value(),
575576
tx.Gas(),
576577
opts...,

tests/go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ require (
77
github.com/goccy/go-json v0.10.4
88
github.com/onflow/cadence v1.8.3
99
github.com/onflow/crypto v0.25.3
10-
github.com/onflow/flow-emulator v1.12.1-0.20251112150210-ab3ddcde0cdc
10+
github.com/onflow/flow-emulator v1.13.1-0.20251120165439-67cc8cd69668
1111
github.com/onflow/flow-evm-gateway v0.0.0-20240201154855-4d4d3d3f19c7
12-
github.com/onflow/flow-go v0.44.0-experimental-cadence-v1.8.3.0.20251111112227-097f521427a5
12+
github.com/onflow/flow-go v0.44.0
1313
github.com/onflow/flow-go-sdk v1.9.2
1414
github.com/rs/zerolog v1.34.0
1515
github.com/stretchr/testify v1.11.1

tests/go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -812,16 +812,16 @@ github.com/onflow/flow-core-contracts/lib/go/contracts v1.9.2 h1:mkd1NSv74+OnCHw
812812
github.com/onflow/flow-core-contracts/lib/go/contracts v1.9.2/go.mod h1:jBDqVep0ICzhXky56YlyO4aiV2Jl/5r7wnqUPpvi7zE=
813813
github.com/onflow/flow-core-contracts/lib/go/templates v1.9.2 h1:semxeVLwC6xFG1G/7egUmaf7F1C8eBnc7NxNTVfBHTs=
814814
github.com/onflow/flow-core-contracts/lib/go/templates v1.9.2/go.mod h1:twSVyUt3rNrgzAmxtBX+1Gw64QlPemy17cyvnXYy1Ug=
815-
github.com/onflow/flow-emulator v1.12.1-0.20251112150210-ab3ddcde0cdc h1:nNjfjEurFv00RqTanfjpGGCZdPkHyrLzH8UunLwUkbI=
816-
github.com/onflow/flow-emulator v1.12.1-0.20251112150210-ab3ddcde0cdc/go.mod h1:clmz8n+gWjzcZwNBpElNY/W/SG7U628WGo6/x/9BhvI=
815+
github.com/onflow/flow-emulator v1.13.1-0.20251120165439-67cc8cd69668 h1:040Xf/99mXVDfsuPxIoaiMTFlxW7fkMJ0gq3y8Hktlk=
816+
github.com/onflow/flow-emulator v1.13.1-0.20251120165439-67cc8cd69668/go.mod h1:+MBvYoRM65uyW1+qLA324l4SB6FD3UTfFU/9caBm3W0=
817817
github.com/onflow/flow-evm-bridge v0.1.0 h1:7X2osvo4NnQgHj8aERUmbYtv9FateX8liotoLnPL9nM=
818818
github.com/onflow/flow-evm-bridge v0.1.0/go.mod h1:5UYwsnu6WcBNrwitGFxphCl5yq7fbWYGYuiCSTVF6pk=
819819
github.com/onflow/flow-ft/lib/go/contracts v1.0.1 h1:Ts5ob+CoCY2EjEd0W6vdLJ7hLL3SsEftzXG2JlmSe24=
820820
github.com/onflow/flow-ft/lib/go/contracts v1.0.1/go.mod h1:PwsL8fC81cjnUnTfmyL/HOIyHnyaw/JA474Wfj2tl6A=
821821
github.com/onflow/flow-ft/lib/go/templates v1.0.1 h1:FDYKAiGowABtoMNusLuRCILIZDtVqJ/5tYI4VkF5zfM=
822822
github.com/onflow/flow-ft/lib/go/templates v1.0.1/go.mod h1:uQ8XFqmMK2jxyBSVrmyuwdWjTEb+6zGjRYotfDJ5pAE=
823-
github.com/onflow/flow-go v0.44.0-experimental-cadence-v1.8.3.0.20251111112227-097f521427a5 h1:L09sNOfqIHAWD90psYCl6+sJYdx9RFDCt5IlYmgrSSY=
824-
github.com/onflow/flow-go v0.44.0-experimental-cadence-v1.8.3.0.20251111112227-097f521427a5/go.mod h1:4A34mlMMd7usjw7e0r4VrltFpZRjhYkV+T+iecTbzO0=
823+
github.com/onflow/flow-go v0.44.0 h1:I1P0t0+wUokyB4RHRLMGWy9QMf4jWg6EFcttKNtU0Rw=
824+
github.com/onflow/flow-go v0.44.0/go.mod h1:4A34mlMMd7usjw7e0r4VrltFpZRjhYkV+T+iecTbzO0=
825825
github.com/onflow/flow-go-sdk v1.9.2 h1:kMw3qShgLNIASHGMgoY+faTBQ+1MnzsNLAH+oxy9eiY=
826826
github.com/onflow/flow-go-sdk v1.9.2/go.mod h1:qVuzMGXNJBMktKnIDKLjV0/k21P2XD39dOfMW+X5Bsc=
827827
github.com/onflow/flow-nft/lib/go/contracts v1.3.0 h1:DmNop+O0EMyicZvhgdWboFG57xz5t9Qp81FKlfKyqJc=

tests/web3js/eth_eip_7702_sending_transactions_test.js

Lines changed: 61 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ const { encodeFunctionData } = require('viem')
33
const { privateKeyToAccount } = require('viem/accounts')
44
const { relay, walletClient, publicClient } = require('./viem/config')
55
const { abi, bytecode } = require('./viem/contract')
6+
const conf = require('./config')
7+
const helpers = require('./helpers')
8+
const web3 = conf.web3
69

710
// eoa is 0xfe847d8bebe46799FCE83eB52f38Ef4b907996A6
811
const eoa = privateKeyToAccount('0x3a0901a19a40f2041727fe1a973137ad917fc925ce716983e1376e927658b12e')
@@ -46,6 +49,33 @@ it('should send transactions with relay account', async () => {
4649
contractAddress,
4750
})
4851

52+
let txArgs = {
53+
from: relay.address,
54+
to: eoa.address,
55+
data: encodeFunctionData({
56+
abi,
57+
functionName: 'initialize',
58+
}),
59+
authorizationList: [
60+
{
61+
address: authorization.address,
62+
chainId: web3.utils.numberToHex(authorization.chainId),
63+
nonce: web3.utils.numberToHex(authorization.nonce),
64+
r: authorization.r,
65+
s: authorization.s,
66+
yParity: web3.utils.numberToHex(authorization.yParity)
67+
}
68+
]
69+
}
70+
71+
let response = await helpers.callRPCMethod(
72+
'eth_estimateGas',
73+
[txArgs, 'latest']
74+
)
75+
assert.equal(response.status, 200)
76+
assert.isDefined(response.body)
77+
assert.equal(web3.utils.hexToNumber(response.body.result), 63779n)
78+
4979
// 2. Designate the Contract on the EOA, and invoke the `initialize` function.
5080
let hash = await walletClient.sendTransaction({
5181
authorizationList: [authorization], // 3. Pass the Authorization as a parameter.
@@ -54,6 +84,7 @@ it('should send transactions with relay account', async () => {
5484
functionName: 'initialize',
5585
}),
5686
to: eoa.address,
87+
gas: web3.utils.hexToNumber(response.body.result)
5788
})
5889

5990
await new Promise((res) => setTimeout(() => res(), 1500))
@@ -108,14 +139,42 @@ it('should send self-executing transactions', async () => {
108139
executor: 'self',
109140
})
110141

142+
let txArgs = {
143+
from: relay.address,
144+
to: relay.address,
145+
data: encodeFunctionData({
146+
abi,
147+
functionName: 'initialize',
148+
}),
149+
authorizationList: [
150+
{
151+
address: authorization.address,
152+
chainId: web3.utils.numberToHex(authorization.chainId),
153+
nonce: web3.utils.numberToHex(authorization.nonce),
154+
r: authorization.r,
155+
s: authorization.s,
156+
yParity: web3.utils.numberToHex(authorization.yParity)
157+
}
158+
]
159+
}
160+
161+
let response = await helpers.callRPCMethod(
162+
'eth_estimateGas',
163+
[txArgs, 'latest']
164+
)
165+
assert.equal(response.status, 200)
166+
assert.isDefined(response.body)
167+
assert.equal(web3.utils.hexToNumber(response.body.result), 63779n)
168+
111169
// 2. Designate the Contract on the EOA, and invoke the `initialize` function.
112170
let hash = await walletClient.sendTransaction({
113171
authorizationList: [authorization], // 3. Pass the Authorization as a parameter.
114172
data: encodeFunctionData({
115173
abi,
116174
functionName: 'initialize',
117175
}),
118-
to: walletClient.account.address,
176+
to: relay.address,
177+
gas: web3.utils.hexToNumber(response.body.result),
119178
})
120179

121180
await new Promise((res) => setTimeout(() => res(), 1500))
@@ -150,7 +209,7 @@ it('should send self-executing transactions', async () => {
150209
abi,
151210
functionName: 'ping',
152211
}),
153-
to: walletClient.account.address,
212+
to: relay.address,
154213
})
155214

156215
await new Promise((res) => setTimeout(() => res(), 1500))

tests/web3js/eth_pectra_upgrade_test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ it('should not perform contract writes with relay account before Pectra', async
5757
address: eoa.address,
5858
authorizationList: [authorization], // 3. Pass the Authorization as a parameter.
5959
functionName: 'initialize',
60+
gas: 63779n
6061
})
6162
} catch (e) {
6263
errMsg = e.details

0 commit comments

Comments
 (0)