11import { getEventLogs , getTransactionsWithNEvents , getUniqueLogs } from "../utils/rpc.js" ;
22import { getAverageMetrics , saveGasMetrics } from "../utils/utils.js" ;
33
4- import { MAX_OF_LOGS , NUMBER_OF_SHIELD_EVENTS , RAILGUN_SMART_WALLET_PROXY , SHIELD_EVENT_ABI } from "./constants.js" ;
4+ import {
5+ MAX_OF_LOGS ,
6+ NULLIFIED_EVENT_ABI ,
7+ NUMBER_OF_SHIELD_EVENTS ,
8+ NUMBER_OF_TRANSFER_EVENTS ,
9+ NUMBER_OF_UNSHIELD_EVENTS ,
10+ RAILGUN_SMART_WALLET_PROXY ,
11+ SHIELD_EVENT_ABI ,
12+ UNSHIELD_EVENT_ABI ,
13+ } from "./constants.js" ;
514
615export class Railgun {
716 readonly name = "railgun" ;
@@ -10,6 +19,8 @@ export class Railgun {
1019
1120 async benchmark ( ) : Promise < void > {
1221 await this . benchmarkShield ( ) ;
22+ await this . benchmarkUnshield ( ) ;
23+ await this . benchmarkTransfer ( ) ;
1324 }
1425
1526 async benchmarkShield ( ) : Promise < void > {
@@ -25,4 +36,32 @@ export class Railgun {
2536
2637 await saveGasMetrics ( metrics , `${ this . name } _${ this . version } ` , "shield" ) ;
2738 }
39+
40+ async benchmarkUnshield ( ) : Promise < void > {
41+ const logs = await getEventLogs ( {
42+ contractAddress : RAILGUN_SMART_WALLET_PROXY ,
43+ event : UNSHIELD_EVENT_ABI ,
44+ maxLogs : MAX_OF_LOGS ,
45+ } ) ;
46+ const uniqueLogs = getUniqueLogs ( logs ) ;
47+
48+ const txs = await getTransactionsWithNEvents ( uniqueLogs , NUMBER_OF_UNSHIELD_EVENTS ) ;
49+ const metrics = getAverageMetrics ( txs ) ;
50+
51+ await saveGasMetrics ( metrics , `${ this . name } _${ this . version } ` , "unshield" ) ;
52+ }
53+
54+ async benchmarkTransfer ( ) : Promise < void > {
55+ const logs = await getEventLogs ( {
56+ contractAddress : RAILGUN_SMART_WALLET_PROXY ,
57+ event : NULLIFIED_EVENT_ABI ,
58+ maxLogs : MAX_OF_LOGS ,
59+ } ) ;
60+ const uniqueLogs = getUniqueLogs ( logs ) ;
61+
62+ const txs = await getTransactionsWithNEvents ( uniqueLogs , NUMBER_OF_TRANSFER_EVENTS ) ;
63+ const metrics = getAverageMetrics ( txs ) ;
64+
65+ await saveGasMetrics ( metrics , `${ this . name } _${ this . version } ` , "transfer" ) ;
66+ }
2867}
0 commit comments