-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Remove duplicate Solidity sig check in fullnode proxy #23
Changes from all commits
3a33626
6f73b6e
b4060c8
f11cf8f
91f68cb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -75,7 +75,8 @@ export const manuallyDeployOvmContractReturnReceipt = async ( | |
executionManager, | ||
wallet, | ||
undefined, | ||
initCode | ||
initCode, | ||
false | ||
) | ||
|
||
return internalTxReceiptToOvmTxReceipt(receipt) | ||
|
@@ -105,7 +106,8 @@ export const executeUnsignedEOACall = async ( | |
executionManager: Contract, | ||
wallet: Wallet, | ||
to: Address, | ||
data: string | ||
data: string, | ||
allowRevert: boolean | ||
): Promise<TransactionReceipt> => { | ||
Comment on lines
106
to
111
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A function comment for |
||
// Verify that the transaction is not accidentally sending to the ZERO_ADDRESS | ||
if (to === ZERO_ADDRESS) { | ||
|
@@ -121,7 +123,8 @@ export const executeUnsignedEOACall = async ( | |
0, | ||
ovmTo, | ||
data, | ||
wallet.address | ||
wallet.address, | ||
allowRevert | ||
) | ||
// Return the parsed transaction values | ||
return executionManager.provider.waitForTransaction(tx.hash) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -173,12 +173,13 @@ export class DefaultWeb3Handler implements Web3Handler, FullnodeHandler { | |
)}], defaultBlock: [${defaultBlock}]` | ||
) | ||
// First generate the internalTx calldata | ||
const internalCalldata = this.generateUnsignedCallCalldata( | ||
const internalCalldata = this.getTransactionCalldata( | ||
this.getTimestamp(), | ||
0, | ||
txObject['to'], | ||
txObject['data'], | ||
txObject['from'] | ||
txObject['from'], | ||
true | ||
) | ||
|
||
log.debug(`calldata: ${internalCalldata}`) | ||
|
@@ -188,7 +189,7 @@ export class DefaultWeb3Handler implements Web3Handler, FullnodeHandler { | |
// Then actually make the call and get the response | ||
response = await this.provider.send(Web3RpcMethods.call, [ | ||
{ | ||
from: ZERO_ADDRESS, | ||
from: this.wallet.address, | ||
to: this.executionManager.address, | ||
data: internalCalldata, | ||
}, | ||
|
@@ -222,19 +223,20 @@ export class DefaultWeb3Handler implements Web3Handler, FullnodeHandler { | |
)}], defaultBlock: [${defaultBlock}]` | ||
) | ||
// First generate the internalTx calldata | ||
const internalCalldata = this.generateUnsignedCallCalldata( | ||
const internalCalldata = this.getTransactionCalldata( | ||
this.getTimestamp(), | ||
0, | ||
txObject['to'], | ||
txObject['data'], | ||
txObject['from'] | ||
txObject['from'], | ||
true | ||
) | ||
|
||
log.debug(internalCalldata) | ||
// Then estimate the gas | ||
const response = await this.provider.send(Web3RpcMethods.estimateGas, [ | ||
{ | ||
from: ZERO_ADDRESS, | ||
from: this.wallet.address, | ||
to: this.executionManager.address, | ||
data: internalCalldata, | ||
}, | ||
|
@@ -480,16 +482,23 @@ export class DefaultWeb3Handler implements Web3Handler, FullnodeHandler { | |
// Generate the calldata which we'll use to call our internal execution manager | ||
// First pull out the `to` field (we just need to check if it's null & if so set ovmTo to the zero address as that's how we deploy contracts) | ||
const ovmTo = ovmTx.to === null ? ZERO_ADDRESS : ovmTx.to | ||
// Check the nonce | ||
const expectedNonce = ( | ||
await this.executionManager.getOvmContractNonce(ovmTx.from) | ||
).toNumber() | ||
if (expectedNonce !== ovmTx.nonce) { | ||
throw new Error( | ||
`Incorrect nonce! Expected nonce: ${expectedNonce} but received nonce: ${ovmTx.nonce}` | ||
) | ||
} | ||
// Construct the raw transaction calldata | ||
const internalCalldata = this.generateEOACallCalldata( | ||
const internalCalldata = this.getTransactionCalldata( | ||
this.getTimestamp(), | ||
0, | ||
ovmTx.nonce, | ||
ovmTo, | ||
ovmTx.data, | ||
ovmTx.v, | ||
ovmTx.r, | ||
ovmTx.s | ||
ovmTx.from, | ||
false | ||
) | ||
|
||
log.debug(`EOA calldata: [${internalCalldata}]`) | ||
|
@@ -524,50 +533,30 @@ export class DefaultWeb3Handler implements Web3Handler, FullnodeHandler { | |
return executionManager | ||
} | ||
|
||
private generateUnsignedCallCalldata( | ||
/** | ||
* Get the calldata for an EVM transaction to the ExecutionManager. | ||
*/ | ||
private getTransactionCalldata( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A short function comment would be helpful! |
||
timestamp: number, | ||
queueOrigin: number, | ||
ovmEntrypoint: string, | ||
callBytes: string, | ||
fromAddress: string | ||
fromAddress: string, | ||
allowRevert: boolean | ||
): string { | ||
// Update the ovmEntrypoint to be the ZERO_ADDRESS if this is a contract creation | ||
if (ovmEntrypoint === null || ovmEntrypoint === undefined) { | ||
ovmEntrypoint = ZERO_ADDRESS | ||
} | ||
return this.executionManager.interface.functions[ | ||
'executeUnsignedEOACall' | ||
].encode([timestamp, queueOrigin, ovmEntrypoint, callBytes, fromAddress]) | ||
} | ||
|
||
private generateEOACallCalldata( | ||
timestamp: number, | ||
queueOrigin: number, | ||
nonce: number, | ||
ovmEntrypoint: string, | ||
callBytes: string, | ||
v: number, | ||
r: string, | ||
s: string | ||
): string { | ||
// Update the ovmEntrypoint to be the ZERO_ADDRESS if this is a contract creation | ||
if (ovmEntrypoint === null || ovmEntrypoint === undefined) { | ||
ovmEntrypoint = ZERO_ADDRESS | ||
} | ||
|
||
log.debug( | ||
`Generating EOA Calldata: v: [${v}], r: [${r}], s: [${s}], nonce: [${nonce}] entrypoint: [${ovmEntrypoint}], callBytes: [${callBytes}]` | ||
) | ||
|
||
return this.executionManager.interface.functions['executeEOACall'].encode([ | ||
].encode([ | ||
timestamp, | ||
queueOrigin, | ||
nonce, | ||
ovmEntrypoint, | ||
callBytes, | ||
v, | ||
r, | ||
s, | ||
fromAddress, | ||
allowRevert, | ||
]) | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add an @param comment for _ovmTxOrigin