Skip to content

Commit

Permalink
fix: re-set gasPrice explicitly to get tx type 1
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastiendan committed Dec 27, 2023
1 parent 45d0fe0 commit a590209
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
8 changes: 6 additions & 2 deletions test/topos-core/ToposMessaging.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,10 @@ describe('ToposMessaging', () => {
await toposCoreProxy.waitForDeployment()
const toposCoreProxyAddress = await toposCoreProxy.getAddress()

const toposCore = await ToposCore__factory.connect(toposCoreProxyAddress)
const toposCore = await ToposCore__factory.connect(
toposCoreProxyAddress,
admin
)
await toposCore.initialize(adminAddresses, adminThreshold)

const erc20Messaging = await new ERC20Messaging__factory(admin).deploy(
Expand Down Expand Up @@ -764,8 +767,9 @@ describe('ToposMessaging', () => {
TxUnsigned.gasLimit = estimatedGasLimit
const address = await signer.getAddress()
const nonce = await provider.getTransactionCount(address)
const feeData = await provider.getFeeData()
TxUnsigned.nonce = nonce
// TxUnsigned.gasPrice = BigInt(await provider.getGasPrice()) // SEDTOBO: verify that the test works without this
TxUnsigned.gasPrice = BigInt(feeData.gasPrice!)

const submittedTx = await signer.sendTransaction(TxUnsigned)
const receipt = await submittedTx.wait()
Expand Down
18 changes: 9 additions & 9 deletions test/topos-core/shared/utils/mpt_proof.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,15 @@ export async function getReceiptMptProof(
tx: TransactionResponse,
provider: JsonRpcProvider
) {
const receipt = await provider.getTransactionReceipt(tx.hash)
const prefectTxs = true
const block = await provider.getBlock(receipt!.blockHash, prefectTxs)
const prefetchTxs = true
const block = await provider.getBlock(tx.blockHash!, prefetchTxs)
const rawBlock = await provider.send('eth_getBlockByHash', [
receipt!.blockHash,
true,
tx.blockHash,
prefetchTxs,
])

const receiptsRoot = rawBlock.receiptsRoot
const trie = await createTrie(block!, provider)
const trie = await createTrie(block!)
const trieRoot = trie.root()
if ('0x' + trieRoot.toString('hex') !== receiptsRoot) {
throw new Error(
Expand All @@ -41,20 +40,21 @@ export async function getReceiptMptProof(
return { proofBlob, receiptsRoot }
}

async function createTrie(block: Block, provider: JsonRpcProvider) {
async function createTrie(block: Block) {
const trie = new Trie()
await Promise.all(
block.prefetchedTransactions.map(async (tx, index) => {
const receipt = await provider.getTransactionReceipt(tx.hash)
const receipt = await tx.wait()
const { cumulativeGasUsed, logs, logsBloom, status } = receipt!

return trie.put(
Buffer.from(RLP.encode(index)),
Buffer.from(
RLP.encode([
status,
Number(cumulativeGasUsed),
logsBloom,
logs.map((l) => [l.address, <string[]>l.topics, l.data]),
logs.map((l) => [l.address, l.topics as string[], l.data]),
])
)
)
Expand Down

0 comments on commit a590209

Please sign in to comment.