Skip to content

Commit c1b5d14

Browse files
committed
skip hyperliquid system txs during verification
1 parent 5fe522e commit c1b5d14

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

evm/evm-rpc/src/chain-utils.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,13 @@ import {getTxHash} from './util'
1414

1515
export class ChainUtils {
1616
public isPolygonMainnet: boolean
17+
public isHyperliquidMainnet: boolean
18+
public isHyperliquidTestnet: boolean
1719

1820
constructor(chainId: Qty) {
1921
this.isPolygonMainnet = chainId == '0x89'
22+
this.isHyperliquidMainnet = chainId == '0x3e7'
23+
this.isHyperliquidTestnet = chainId == '0x3e6'
2024
}
2125

2226
calculateBlockHash(block: GetBlock) {
@@ -25,6 +29,7 @@ export class ChainUtils {
2529

2630
calculateTransactionsRoot(block: GetBlock) {
2731
let transactions = block.transactions as Transaction[]
32+
2833
if (this.isPolygonMainnet) {
2934
let stateSyncTxHash = calculateStateSyncTxHash(block.number, block.hash)
3035
let txs = []
@@ -40,6 +45,11 @@ export class ChainUtils {
4045
}
4146
}
4247
}
48+
49+
if (this.isHyperliquidMainnet || this.isHyperliquidTestnet) {
50+
transactions = transactions.filter(tx => !isHyperliquidSystemAddress(tx))
51+
}
52+
4353
return transactionsRoot(transactions)
4454
}
4555

@@ -53,6 +63,16 @@ export class ChainUtils {
5363
return tx.hash != stateSyncTxHash
5464
})
5565
}
66+
67+
if (this.isHyperliquidMainnet || this.isHyperliquidTestnet) {
68+
let transactions = block.transactions as Transaction[]
69+
let txByHash = new Map(transactions.map(tx => [getTxHash(tx), tx]))
70+
logs = logs.filter(log => {
71+
let tx = assertNotNull(txByHash.get(log.transactionHash))
72+
return !isHyperliquidSystemAddress(tx)
73+
})
74+
}
75+
5676
return logsBloom(logs)
5777
}
5878

@@ -61,10 +81,25 @@ export class ChainUtils {
6181
let stateSyncTxHash = calculateStateSyncTxHash(block.number, block.hash)
6282
receipts = receipts.filter(receipt => receipt.transactionHash != stateSyncTxHash)
6383
}
84+
85+
if (this.isHyperliquidMainnet || this.isHyperliquidTestnet) {
86+
receipts = receipts.filter(receipt => !isHyperliquidSystemAddress(receipt))
87+
}
88+
6489
return receiptsRoot(receipts)
6590
}
6691

6792
recoverTxSender(transaction: Transaction) {
93+
if (this.isHyperliquidMainnet || this.isHyperliquidTestnet) {
94+
if (isHyperliquidSystemAddress(transaction)) return
95+
}
96+
6897
return recoverTxSender(transaction)
6998
}
7099
}
100+
101+
102+
function isHyperliquidSystemAddress(txOrReceipt: Transaction | Receipt) {
103+
// https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/hyperevm/hypercore-less-than-greater-than-hyperevm-transfers#system-addresses
104+
return txOrReceipt.from == '0x2222222222222222222222222222222222222222' || txOrReceipt.from.startsWith('0x20')
105+
}

0 commit comments

Comments
 (0)