-
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
Add eth_getTransactionByHash endpoint #90
Merged
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
923c26a
adding eth_getTransactionByHash endpoint and making sure receipts hav…
willmeister 1792d8c
Adding storage and retrieval for raw OVM txs by ovm tx hash
willmeister 6bf80f4
fixing broken test
willmeister 2716c63
fixing comment
willmeister 39bc4f5
fixing null case because for some reason null ends up "0x"
willmeister File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,21 @@ | ||
import '../setup' | ||
/* External Imports */ | ||
import { getLogger, numberToHexString } from '@eth-optimism/core-utils' | ||
import { | ||
add0x, | ||
getLogger, | ||
keccak256, | ||
numberToHexString, | ||
} from '@eth-optimism/core-utils' | ||
import { ethers, ContractFactory, Wallet, Contract } from 'ethers' | ||
import { resolve } from 'path' | ||
import * as rimraf from 'rimraf' | ||
import * as fs from 'fs' | ||
import assert from 'assert' | ||
|
||
/* Internal Imports */ | ||
import { | ||
FullnodeRpcServer, | ||
DefaultWeb3Handler, | ||
TestWeb3Handler, | ||
} from '../../src/app' | ||
import { FullnodeRpcServer, DefaultWeb3Handler } from '../../src/app' | ||
import * as SimpleStorage from '../contracts/build/untranspiled/SimpleStorage.json' | ||
import { Web3RpcMethods } from '../../src/types' | ||
|
||
const log = getLogger('web3-handler', true) | ||
|
||
|
@@ -68,14 +71,14 @@ const setStorage = async ( | |
simpleStorage: Contract, | ||
httpProvider, | ||
executionManagerAddress | ||
): Promise<void> => { | ||
): Promise<any> => { | ||
// Set storage with our new storage elements | ||
const tx = await simpleStorage.setStorage( | ||
executionManagerAddress, | ||
storageKey, | ||
storageValue | ||
) | ||
await httpProvider.getTransactionReceipt(tx.hash) | ||
return httpProvider.getTransactionReceipt(tx.hash) | ||
} | ||
|
||
const getAndVerifyStorage = async ( | ||
|
@@ -210,6 +213,44 @@ describe('Web3Handler', () => { | |
}) | ||
}) | ||
|
||
describe('the eth_getTransactionByHash endpoint', () => { | ||
it('should return null if no tx exists', async () => { | ||
const garbageHash = add0x( | ||
keccak256(Buffer.from('garbage').toString('hex')) | ||
) | ||
const txByHash = await httpProvider.send( | ||
Web3RpcMethods.getTransactionByHash, | ||
[garbageHash] | ||
) | ||
|
||
assert( | ||
txByHash === null, | ||
'Should not have gotten a tx for garbage hash!' | ||
) | ||
}) | ||
|
||
it.only('should return a tx by OVM hash', async () => { | ||
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. .only |
||
const executionManagerAddress = await httpProvider.send( | ||
'ovm_getExecutionManagerAddress', | ||
[] | ||
) | ||
const wallet = getWallet(httpProvider) | ||
const simpleStorage = await deploySimpleStorage(wallet) | ||
const txReceipt = await setStorage( | ||
simpleStorage, | ||
httpProvider, | ||
executionManagerAddress | ||
) | ||
|
||
const txByHash = await httpProvider.send( | ||
Web3RpcMethods.getTransactionByHash, | ||
[txReceipt.transactionHash] | ||
) | ||
|
||
assert(!!txByHash, 'Transaction should exist!') | ||
}) | ||
}) | ||
|
||
describe('SimpleStorage integration test', () => { | ||
it('should set storage & retrieve the value', async () => { | ||
const executionManagerAddress = await httpProvider.send( | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Unfortunately my guess is that just returning the internal tx is probably not going to be sufficient for many use cases of this endpoint. For example, if a dev 1. manually constructs an OVM transaction, only storing the hash 2. sends it off to the chain, and then 3. attempts to retrieve it later with this endpoint, it will not get back the original transaction constructed in step 1.