Skip to content
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

Cosmos gas multiplier params #1546

Closed
wants to merge 262 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
262 commits
Select commit Hold shift + click to select a range
8c02c0c
[EVM] add endpoints to get block transaction count (#1099)
codchen Oct 12, 2023
6f9da33
[EVM] add getTransactionReceipt (#1100)
codchen Oct 13, 2023
5c7861e
[EVM] add getTransactions endpoints (#1101)
codchen Oct 17, 2023
e0b570a
[EVM] add endpoint to get transaction count by address (#1103)
codchen Oct 17, 2023
5888b96
[EVM] fix gas logic (#1104)
codchen Oct 19, 2023
a76232b
[EVM] add endpoint to return fee history (#1106)
codchen Oct 19, 2023
8f6740c
[EVM] add info endpoints (#1107)
codchen Oct 19, 2023
daa89d4
[EVM] eth state endpoints (#1105)
jewei1997 Oct 19, 2023
b63ac6d
[EVM] add subscription utility (#1109)
codchen Oct 23, 2023
41dfe2f
[EVM] add endpoint to send transaction (#1108)
codchen Oct 23, 2023
9653567
[EVM] get simulation endpoints (#1110)
codchen Oct 25, 2023
e92bd2e
[EVM] add getProof endpoint (#1114)
codchen Oct 27, 2023
576d978
[EVM] ETH Log Filter Endpoints (#1116)
jewei1997 Oct 31, 2023
74df7ef
[EVM] return gas info in message handler correctly (#1115)
codchen Nov 1, 2023
9e555c0
EVM Module Integration (#1122)
codchen Nov 3, 2023
ed4f413
[EVM] add transaction type to associate account (#1126)
codchen Nov 7, 2023
eb9bb0e
[EVM] convert balance decimal points (#1128)
codchen Nov 7, 2023
024b551
[EVM] ETH block filter endpoint (#1127)
jewei1997 Nov 8, 2023
00eef06
[EVM] surface VM error (#1130)
codchen Nov 9, 2023
2b768c9
[EVM] add ACL dependencies (#1129)
codchen Nov 9, 2023
e72c621
[EVM] several bug fixes (#1136)
codchen Nov 13, 2023
f46b616
[EVM] add `wasmd` precompile (#1139)
codchen Nov 14, 2023
dc2a650
[EVM] add bank metadata precompile functions (#1140)
codchen Nov 14, 2023
41187f0
[EVM] subscription based eth endpoints (#1132)
jewei1997 Nov 15, 2023
98047a9
[EVM] handle gapped nonce in CheckTx (#1142)
codchen Nov 17, 2023
8d4af80
[EVM] fix getProof (#1145)
codchen Nov 17, 2023
42faea8
[EVM] add deps for EVM ante handlers (#1149)
codchen Nov 22, 2023
2523083
[EVM] denormalize intermediary and coinbase accounts (#1153)
codchen Nov 22, 2023
97de55e
EVM ERC20 Template Contract (#1146)
jewei1997 Nov 28, 2023
742b72b
[EVM] seid command to deploy erc20 contract for a native sei token (#…
jewei1997 Dec 1, 2023
7822a95
[EVM] preprocess EVM transactions and define granular access operatio…
codchen Dec 5, 2023
559abd0
[EVM] --slow config for send raw txn (#1165)
jewei1997 Dec 5, 2023
136f63d
[EVM] add ERC-721 -> CW-721 interoperability contract (#1162)
codchen Dec 6, 2023
8ce84ee
[EVM] allow passing in private key hex for address association (#1166)
codchen Dec 6, 2023
8938f04
[EVM] Sign and Accounts endpoints (#1167)
codchen Dec 12, 2023
5c5fe5a
bump base geth version (#1172)
codchen Dec 13, 2023
f5cff26
Use pending transactions to handle higher nonce txs gracefully (#1175)
codchen Dec 18, 2023
8232d17
[EVM] fix logs disappearing issue (#1178)
codchen Dec 19, 2023
4c64668
Use better error message (#1179)
codchen Dec 19, 2023
b3d1679
Fix empty uncle hash (#1183)
stevenlanders Dec 26, 2023
8bce375
Fix getTxByHash for pending txs (#1181)
codchen Dec 26, 2023
771d9e6
[EVM] show bank send in GetBlock response (#1187)
codchen Dec 26, 2023
36e513b
[EVM] add stateless checks (#1188)
codchen Dec 27, 2023
7cf4680
[EVM] call SendCoinsAndWei to support 18-decimal point precision (#1191)
codchen Dec 29, 2023
7040a78
Fix ante handler (#1198)
codchen Dec 29, 2023
1450e42
Fix ERC20 wrapper code hash not whitelisted (#1203)
codchen Jan 2, 2024
0b58ec5
Automatically query for nonce for deploy erc20 cmd (#1199)
codchen Jan 2, 2024
701deb5
Prefund eth addresses local chain (#1193)
jewei1997 Jan 2, 2024
dd7da6a
Use separate state instead of params to represent whitelist (#1205)
codchen Jan 2, 2024
890d0d5
Improve error handling (#1206)
codchen Jan 2, 2024
9dbfc87
[EVM] Fix pending nonce race issues (#1194)
stevenlanders Jan 4, 2024
d6879f6
Add EVM wasmbindings (#1210)
codchen Jan 5, 2024
8303212
rebase
codchen Jan 8, 2024
2ccd032
add CW20-ERC20 wrapper (#1215)
codchen Jan 9, 2024
7a99fb2
Remove SendFromOriginMethod from Bank precompile
yzang2019 Jan 9, 2024
6105155
ERC20 Wrapper for CW20 (#1217)
jewei1997 Jan 9, 2024
b275a17
Fix EVM unit test after removing SendFromOriginMethod (#1218)
yzang2019 Jan 9, 2024
4f89051
fix docker cluster and gen accounts evm address linking (#1226)
udpatil Jan 10, 2024
93ab04a
Add timestamp during estimateGas and add tests (#1225)
codchen Jan 11, 2024
4288c5c
Pass tip cap in evm txs CLI and take tip into account when calculatin…
codchen Jan 12, 2024
b30a8c1
[EVM] TxPool Content RPC Endpoint (#1228)
jewei1997 Jan 12, 2024
98337c1
Expose EVM rpc port (#1233)
yzang2019 Jan 12, 2024
b2d6928
Add check for eth_getBlockTransactionCountByNumber (#1220)
philipsu522 Jan 12, 2024
793e67e
add whitelist for CW code hash that can make delegatecall to EVM (#1234)
codchen Jan 16, 2024
6d69cda
Minor RPC fixes (#1237)
codchen Jan 16, 2024
b4b35a6
Revamp EVM logs (#1224)
codchen Jan 16, 2024
98cceec
Tick version for devnet (#1243)
stevenlanders Jan 17, 2024
4d76cbc
disable parallel processing (#1246)
codchen Jan 17, 2024
eac5421
EVM fix association false returning sei addr (#1240)
jewei1997 Jan 17, 2024
ceb04ad
EVM integration tests (#1241)
jewei1997 Jan 17, 2024
f4f42a4
EVM Association RPC (#1245)
jewei1997 Jan 17, 2024
f5289af
[EVM] version v4.0.1-evm-devnet (#1248)
stevenlanders Jan 17, 2024
a5ec830
Make DerivedData impossible to forge (#1239)
codchen Jan 18, 2024
0c1af99
[EVM] Add contract factory test (#1253)
stevenlanders Jan 18, 2024
3c74a0c
[EVM] Add throughput and latency metrics for all JSON-RPC endpoint (#…
yzang2019 Jan 18, 2024
1b2b21f
Add whitelisting for delegatecalls through precompile (#1251)
codchen Jan 19, 2024
27103cd
[EVM] Allow multiple txs from same account in a block (#1252)
stevenlanders Jan 19, 2024
0c883d2
Add CLI helpers for ERC/CW20/721 wrappers (#1259)
codchen Jan 21, 2024
eb81b7a
Do not adjust V for unprotected txs (#1263)
codchen Jan 22, 2024
3d83515
[EVM] fix json send evm tx for cli (#1269)
stevenlanders Jan 23, 2024
b0d6579
EVM Hardhat gas test (#1254)
jewei1997 Jan 23, 2024
34c2465
Add CW721 wrapper for ERC721 (#1264)
codchen Jan 23, 2024
dc6c71c
EVM wei usei tests (#1266)
jewei1997 Jan 23, 2024
45af011
Separate endpoint for associateTx (#1272)
codchen Jan 23, 2024
a01e07e
Handle pruned heights in RPC gracefully (#1271)
codchen Jan 23, 2024
2fc65bf
[EVM] Add new RPC endpoint eth_getBlockReceipts (#1270)
yzang2019 Jan 23, 2024
14ba16c
[EVM] Add index to logs based on order (#1273)
stevenlanders Jan 23, 2024
959f011
Add more CW20 methods to ERC20 Wrapper (#1255)
mj850 Jan 24, 2024
a72af58
Remove iterator usage in EVM (#1277)
codchen Jan 24, 2024
e54a7b2
[EVM] update version for devnet v4.0.3 (#1280)
stevenlanders Jan 24, 2024
535c6f5
add CW->ERC wrapper queries (#1281)
codchen Jan 25, 2024
5c2dd3e
[EVM] set version for v4.0.4-evm-devnet (#1288)
stevenlanders Jan 25, 2024
5e799c7
EVM tx receipt test (#1274)
jewei1997 Jan 25, 2024
0001213
Wildcard vhosts to allow for dns rpc (#1289)
philipsu522 Jan 25, 2024
b6e603c
[EVM] Add evm to loadtest client (#1258)
yzang2019 Jan 26, 2024
0d23f44
Use memstore to hold deferred TX info (#1291)
codchen Jan 26, 2024
9b4cc59
Test CW wrappers (#1292)
codchen Jan 29, 2024
304da76
Edge case fixes for height-based queries (#1282)
codchen Jan 29, 2024
bdb8f95
[EVM] tick version for v4.0.5-evm-devnet (#1298)
stevenlanders Jan 29, 2024
a32b121
Clear txDeferredInfo in EndBlock (#1299)
udpatil Jan 30, 2024
ff99ff9
refactor block gas meter usages to ignore block gas meter in preparat…
udpatil Jan 30, 2024
113fddf
[EVM] Test Contract Address (#1296)
Kbhat1 Jan 30, 2024
0fccb32
remove msgSend from evm block tx filtering (#1303)
udpatil Jan 30, 2024
8ff566a
fix lint (#1305)
udpatil Jan 30, 2024
ac2a52d
[EVM] Tick upgrades v4.0.6-evm-devnet (#1306)
stevenlanders Jan 30, 2024
c0ad842
EVM get logs test (#1275)
jewei1997 Jan 30, 2024
0e1cbd5
EVM upgradeable smart contract (#1267)
jewei1997 Jan 31, 2024
a9419c2
Allow display info to be configured in native ERC-20 wrappers (#1302)
codchen Jan 31, 2024
de34fe5
Bump seidb and cosmos version to latest (#1309)
yzang2019 Jan 31, 2024
a2d733c
Add helper CLIs for ERC20 (#1308)
codchen Feb 1, 2024
48978e3
Bump cosmos to remove cachekv events (#1313)
yzang2019 Feb 1, 2024
bc8ffc9
[EVM] Tick upgrade for v4.0.8-evm-devnet (#1315)
stevenlanders Feb 1, 2024
5c26b7d
Fix log index (#1316)
codchen Feb 2, 2024
a79b50c
Tick version for v4.0.9-evm-devnet (#1319)
stevenlanders Feb 2, 2024
f34e627
Add staking precompile (#1318)
codchen Feb 4, 2024
f22572f
Simplify pending nonce logics (#1322)
codchen Feb 5, 2024
4d42a82
[EVM] update go.mod for candidate v4.1.0 (#1324)
stevenlanders Feb 5, 2024
456e6e4
[EVM] Update with rebased sei-cosmos (#1328)
stevenlanders Feb 6, 2024
caab2c5
Add Gov/Distribution precompiles (#1323)
codchen Feb 7, 2024
7c5b707
[EVM] Update loadtest client receipt polling (#1330)
stevenlanders Feb 8, 2024
8fd15ed
[EVM] merge main into evm (#1333)
stevenlanders Feb 8, 2024
3bb45de
Add cast support for docker and integration test (#1334)
yzang2019 Feb 9, 2024
2a02e4a
[EVM] update upgrades.go to include the 4.1.2 version (#1337)
stevenlanders Feb 10, 2024
fac5484
Use in-memory data structure for transient state (#1331)
codchen Feb 12, 2024
abc28ef
[EVM] Add erc20 to load test (#1342)
stevenlanders Feb 12, 2024
42b4892
[EVM] Add v4.1.3-evm-devnet to upgrades go (#1347)
stevenlanders Feb 12, 2024
b101ca9
Use in-memory map for deferred info (#1345)
codchen Feb 13, 2024
76f029d
Use per-tx escrow for Wei balance (#1314)
codchen Feb 13, 2024
aac0ed8
Hardcode things that dont need to be params (#1348)
codchen Feb 13, 2024
8bbc97c
[EVM] debug_traceTransaction endpoint (#1336)
jewei1997 Feb 14, 2024
565369a
[Loadtest] Optimize loadtest client throughput calculation (#1351)
yzang2019 Feb 15, 2024
41b0726
Add/sub balance directly without middleman (#1349)
codchen Feb 19, 2024
17ef3bc
handle nil code (#1360)
codchen Feb 20, 2024
f7512f9
Fix subscribe endpoints (#1359)
philipsu522 Feb 20, 2024
2067b73
[EVM] Fix tx index in tx receipt (#1354)
jewei1997 Feb 20, 2024
778f4ef
[EVM] historical query test (#1362)
jewei1997 Feb 21, 2024
17aec0e
[EVM] Remove eth_getPendingNonces (#1361)
stevenlanders Feb 21, 2024
0792562
V4.1.4 evm devnet branch (#1366)
philipsu522 Feb 21, 2024
c26b20d
fix comma (#1367)
stevenlanders Feb 21, 2024
28c887a
Fix debug trace tx (#1370)
philipsu522 Feb 22, 2024
a6c9fe2
[EVM] fix gas tip calculation related to priority (#1368)
stevenlanders Feb 22, 2024
b9a340e
Add two debug endpoints for trace (#1372)
yzang2019 Feb 23, 2024
dbc8dfe
rename pointer contracts (#1365)
codchen Feb 23, 2024
0d6ddef
Make certain precompile functions payable (#1376)
codchen Feb 26, 2024
7fe54af
Add tx type in tx hydration functions (#1381)
codchen Feb 26, 2024
7eb00ac
Fix error handling for non-existent block (#1382)
yzang2019 Feb 26, 2024
497f86d
Update evm tx cli to remove non-existent flag (#1386)
philipsu522 Feb 26, 2024
d6da4a3
[EVM] Tx Priority to be Effective Gas Price (#1385)
jewei1997 Feb 27, 2024
2c78e5a
EVM Precompile Send to Native address (#1332)
Kbhat1 Feb 27, 2024
e08e46e
evm-occ compatibility fixes
udpatil Jan 31, 2024
eb38ad7
Add evm resource types to resource to store key map
udpatil Jan 26, 2024
abd8686
update unit tests
udpatil Jan 26, 2024
d0fa1db
update deliverTxEntry
udpatil Feb 9, 2024
d4c0f1b
Fix mnemonic for populate accounts (#1401)
philipsu522 Mar 1, 2024
e53a645
[EVM] fix empty tx root value (#1405)
stevenlanders Mar 5, 2024
5be6869
[EVM] set default block to latest for eth_getLogs (#1417)
stevenlanders Mar 8, 2024
2623247
Integrate with tendermint EVM tx replacement logic (#1411)
codchen Mar 10, 2024
5458e4f
Set address association for Cosmos tx (#1425)
codchen Mar 12, 2024
a418e60
Remove command output that breaks loadtest deploying (#1424)
philipsu522 Mar 12, 2024
713ae0a
[EVM] Add erc721 to loadtest (#1428)
stevenlanders Mar 12, 2024
09260ad
Add funding logic to erc721 deploy script (#1429)
philipsu522 Mar 13, 2024
db4a6f4
[EVM] univ2 loadtest (#1423)
jewei1997 Mar 13, 2024
4b9e3bf
Pass `.git` folder to Docker context (#1432)
maoueh Mar 13, 2024
81b1a0b
Add deny list config for EVM RPC (#1427)
yzang2019 Mar 13, 2024
878cf3b
V4.1.5 evm devnet release (#1434)
philipsu522 Mar 14, 2024
919a8be
Transfer wei when account is associated (#1435)
codchen Mar 15, 2024
d4bf713
Handle unprotected TXs properly (#1443)
codchen Mar 18, 2024
4338c90
Add utils to replay ETH mainnet txs (#1426)
codchen Mar 18, 2024
d0b4e02
Set association and account for EVM contracts (#1447)
codchen Mar 19, 2024
1efefd9
change eth replay config names (#1451)
codchen Mar 19, 2024
171a166
Associate Tx Prefix Fix (#1442)
Kbhat1 Mar 19, 2024
ceef861
Precompile Integration Tests (#1440)
Kbhat1 Mar 19, 2024
accdb0c
[OCC] tick cosmos version to v0.2.78-seiv2 (#1453)
stevenlanders Mar 20, 2024
44740d4
EVM Module Panic + Error Metrics (#1458)
Kbhat1 Mar 21, 2024
3de8cf5
loadtest throughput metrics (#1452)
jewei1997 Mar 22, 2024
781dbbd
Account for withdrawals in replay (#1449)
codchen Mar 22, 2024
b5f5465
Parallelize tx decoding/EVM preprocessing (#1461)
codchen Mar 22, 2024
1effb0e
Remove redundant signature decoding (#1462)
codchen Mar 22, 2024
75b0c40
Set big int constants (#1465)
codchen Mar 25, 2024
81743f6
Add wasm binding for getting associated addresses (#1466)
codchen Mar 26, 2024
949980d
EVM Blockchain tests (#1455)
jewei1997 Mar 26, 2024
befeaac
Not override log index (#1469)
codchen Mar 26, 2024
081d1c8
bump sei-cosmos
udpatil Mar 27, 2024
29c996e
Oracle Precompile (#1445)
Kbhat1 Mar 26, 2024
2ac02eb
[seiv2] fix golint (#1481)
stevenlanders Mar 26, 2024
d90e144
Add cosmos send to EVM addr transaction type (#1470)
codchen Mar 27, 2024
42948cc
cache block during eth replay (#1471)
codchen Mar 27, 2024
3d9c95e
Add EVM panic stack trace (#1482)
codchen Mar 27, 2024
195fe7f
bump sei-tendermint
udpatil Mar 27, 2024
10c4b3f
Update EVMFeeCheckDecorator to run in Deliver Mode (#1474)
Kbhat1 Mar 27, 2024
63f89a5
Ante Handler: Nested Evm Messages within Authz (#1472)
Kbhat1 Mar 27, 2024
3e4db93
[EVM] Fix timestamp in evm read calls (#1486)
stevenlanders Mar 27, 2024
01f00b3
IBC transfer precompile (#1485)
dssei Mar 28, 2024
6e0c934
v4.1.7 evm devnet release (#1488)
philipsu522 Mar 28, 2024
c635641
Add ERC pointer registry (#1490)
codchen Mar 29, 2024
eb2080b
Update that brings `go-ethereum` with live tracer support (#1375)
maoueh Mar 29, 2024
4c225f4
Add gov proposal types for registering pointers (#1496)
codchen Apr 1, 2024
1127dbd
[EVM] cancun valid block tests (#1487)
jewei1997 Apr 1, 2024
548078b
[EVM] Reject blob txs (#1498)
stevenlanders Apr 2, 2024
109c324
Emit tendermint event upon address association (#1501)
codchen Apr 2, 2024
d4d1f70
mock beacon root (#1502)
codchen Apr 2, 2024
1f3798c
Add CW->ERC pointer registry (#1499)
codchen Apr 3, 2024
8be5846
Add WSEI contract and cmd for deployment (#1500)
codchen Apr 3, 2024
465eaf3
[SeiV2] Add EVM txs to OCC test library (#1503)
stevenlanders Apr 3, 2024
5442e03
Optimize replay (#1505)
codchen Apr 4, 2024
51b4587
Update EVM Basic Ante (#1491)
Kbhat1 Apr 4, 2024
41bb27b
Update Precompiles Input Method Parse + Evm Exists (#1494)
Kbhat1 Apr 4, 2024
ead66f7
Precompile Remove Panics + Add More Validation (#1504)
Kbhat1 Apr 4, 2024
507ab0b
Add gas limit for EVM static call query (#1509)
codchen Apr 4, 2024
0c08270
Precompiles Raise Error over Panic (#1507)
Kbhat1 Apr 4, 2024
f87a819
Add query for pointer in registry (#1508)
codchen Apr 5, 2024
a1e7beb
EVM Invalid block tests (#1497)
jewei1997 Apr 5, 2024
05ec7c1
Lower Evm max priority (#1511)
Kbhat1 Apr 5, 2024
fe9ca68
Replace MustGetEVMAddressFromBech32OrDefault (#1510)
Kbhat1 Apr 5, 2024
cc2d088
Fix Int rounding issues (#1514)
codchen Apr 7, 2024
424c8d9
Clear self-destructed account state at the end of tx (#1513)
codchen Apr 7, 2024
54b90cf
Write receipt for txs with non VM errors (#1512)
codchen Apr 8, 2024
9186601
Use registry instead of code hash to determine precompile whitelist (…
codchen Apr 8, 2024
86006f0
Require `from` in TransferFrom in CW721 pointer to be the owner (#1516)
codchen Apr 8, 2024
2f54f96
add comments (#1520)
codchen Apr 9, 2024
a0e38d4
Set unknown method call on precompiles to be non-zero (#1519)
codchen Apr 9, 2024
2b16fd7
Fix extractAsBytesList in json precompile (#1521)
codchen Apr 9, 2024
1d380cc
Disallow balance change for self-destructed address (#1522)
codchen Apr 9, 2024
75d5210
Bump geth and add checks for staticcall/delegatecall (#1524)
codchen Apr 9, 2024
a75cd92
fix precompile remaining gas calculation (#1525)
codchen Apr 9, 2024
e2440de
Emit event for contract registration (#1518)
codchen Apr 10, 2024
e8d0ce4
[EVM] Avoid internal events for send_native (#1523)
stevenlanders Apr 10, 2024
e504a25
Add mechanism for benchmarking EVM queries (#1530)
codchen Apr 11, 2024
37251b2
Use random string filter ID instead of incrementing ints (#1527)
codchen Apr 11, 2024
94af302
Add unit test for x/evm/state (#1532)
yzang2019 Apr 11, 2024
cec5ad5
Check wei balance in associate tx handling (#1534)
codchen Apr 11, 2024
e2514a8
Fix balance behavior for selfdestructed accounts (#1526)
codchen Apr 11, 2024
95e381f
Bank precompile get balances (#1533)
udpatil Apr 11, 2024
c125f6f
Add ante error handler for EVM msgs (#1535)
codchen Apr 12, 2024
51f7ac0
Fix unit test (#1540)
yzang2019 Apr 12, 2024
a34deba
V4.1.8 evm devnet release 2 (#1517)
philipsu522 Apr 12, 2024
ac8be0d
Add x/evm/types unit tests (#1537)
philipsu522 Apr 12, 2024
2f9f8f5
Bump SeiDB (Seiv2) (#1542)
Kbhat1 Apr 15, 2024
78eb1d6
Disallow unassociated EOA addresses from using precompiles (#1538)
codchen Apr 15, 2024
5caa031
[EVM] update sei-tendermint v0.2.41-seiv2 (#1544)
stevenlanders Apr 15, 2024
7470aae
Add wasmd execute batch to precompile (#1529)
udpatil Apr 15, 2024
0693fff
Cosmos Gas Multiplier Params
Kbhat1 Apr 16, 2024
bb1b958
Add comments
Kbhat1 Apr 16, 2024
4e5a009
Update unit tests
Kbhat1 Apr 16, 2024
4da62e4
Update tests
Kbhat1 Apr 16, 2024
757db6d
Update sei-cosmos
Kbhat1 Apr 17, 2024
2c6e284
bump sei-cosmos
Kbhat1 Apr 17, 2024
4afbda8
Update sei-cosmos
Kbhat1 Apr 17, 2024
d4f67e9
Infinite Multiplier Gas Meter for simulation
Kbhat1 Apr 17, 2024
0a82d4d
Add dep test
Kbhat1 Apr 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[EVM] ETH Log Filter Endpoints (#1116)
* [EVM] add subscription utility

* finished new filter

* finished tests for new filter

* finished uninstall filter

* query tendermint for events

* in progress

* got first couple of tests done

* finished tests for get logs

* get filter logs and get filter changes

* refactor

* get filter logs accepts multiple addresses

* use multiple addresses and use cursor map

* remove bad test

* remove prints and todos

* minor fix

* fix lint errors and failing test

* poc to pass filtercriteria into JSON RPC

* made topics 2d array and adjusted regex

* GetLogs tests work

* Finished other functions

* remove unncessary inputs from NewFilterAPI

* add expiration/timeouts for filters

* removed error from UninstallFilter

* minor fix

* appease linter

---------

Co-authored-by: codchen <codchen03@gmail.com>
2 people authored and udpatil committed Mar 26, 2024
commit 576d97872e557d238d26976903391cda48f75932
268 changes: 268 additions & 0 deletions evmrpc/filter.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,268 @@
package evmrpc

import (
"context"
"encoding/json"
"errors"
"math/big"
"sync"
"time"

"github.com/ethereum/go-ethereum/common"
ethtypes "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/eth/filters"
abci "github.com/tendermint/tendermint/abci/types"
rpcclient "github.com/tendermint/tendermint/rpc/client"
"github.com/tendermint/tendermint/rpc/coretypes"
)

type filter struct {
fc filters.FilterCriteria
deadline *time.Timer
cursors map[common.Address]string
}

type FilterAPI struct {
tmClient rpcclient.Client
nextFilterID uint64
filtersMu sync.Mutex
filters map[uint64]filter
filterConfig *FilterConfig
}

type FilterConfig struct {
timeout time.Duration
}

func NewFilterAPI(tmClient rpcclient.Client, filterConfig *FilterConfig) *FilterAPI {
filters := make(map[uint64]filter)
api := &FilterAPI{
tmClient: tmClient,
nextFilterID: 1,
filtersMu: sync.Mutex{},
filters: filters,
filterConfig: filterConfig,
}

go api.timeoutLoop(filterConfig.timeout)

return api
}

func (a *FilterAPI) timeoutLoop(timeout time.Duration) {
ticker := time.NewTicker(timeout)
defer ticker.Stop()
for {
<-ticker.C
a.filtersMu.Lock()
for id, filter := range a.filters {
select {
case <-filter.deadline.C:
delete(a.filters, id)
default:
continue
}
}
a.filtersMu.Unlock()
}
}

func (a *FilterAPI) NewFilter(
_ context.Context,
crit filters.FilterCriteria,
) (*uint64, error) {
a.filtersMu.Lock()
defer a.filtersMu.Unlock()
curFilterID := a.nextFilterID
a.nextFilterID++
a.filters[curFilterID] = filter{
fc: crit,
deadline: time.NewTimer(a.filterConfig.timeout),
cursors: make(map[common.Address]string),
}
return &curFilterID, nil
}

func (a *FilterAPI) GetFilterChanges(
ctx context.Context,
filterID uint64,
) ([]*ethtypes.Log, error) {
a.filtersMu.Lock()
filter, ok := a.filters[filterID]
a.filtersMu.Unlock()
if !ok {
return nil, errors.New("filter does not exist")
}

if !filter.deadline.Stop() {
// timer expired but filter is not yet removed in timeout loop
// receive timer value and reset timer
<-filter.deadline.C
}
filter.deadline.Reset(a.filterConfig.timeout)

res, cursors, err := a.getLogsOverAddresses(ctx, filter.fc, filter.cursors)
if err != nil {
return nil, err
}
a.filtersMu.Lock()
updatedFilter := a.filters[filterID]
updatedFilter.cursors = cursors
a.filters[filterID] = updatedFilter
a.filtersMu.Unlock()
return res, nil
}

func (a *FilterAPI) GetFilterLogs(
ctx context.Context,
filterID uint64,
) ([]*ethtypes.Log, error) {
a.filtersMu.Lock()
filter, ok := a.filters[filterID]
a.filtersMu.Unlock()
if !ok {
return nil, errors.New("filter does not exist")
}

if !filter.deadline.Stop() {
// timer expired but filter is not yet removed in timeout loop
// receive timer value and reset timer
<-filter.deadline.C
}
filter.deadline.Reset(a.filterConfig.timeout)

noCursors := make(map[common.Address]string)
res, cursors, err := a.getLogsOverAddresses(ctx, filter.fc, noCursors)
if err != nil {
return nil, err
}
a.filtersMu.Lock()
updatedFilter := a.filters[filterID]
updatedFilter.cursors = cursors
a.filters[filterID] = updatedFilter
a.filtersMu.Unlock()
return res, nil
}

func (a *FilterAPI) GetLogs(
ctx context.Context,
crit filters.FilterCriteria,
) ([]*ethtypes.Log, error) {
logs, _, err := a.getLogsOverAddresses(
ctx,
crit,
make(map[common.Address]string),
)
return logs, err
}

// pulls logs from tendermint client over multiple addresses.
func (a *FilterAPI) getLogsOverAddresses(
ctx context.Context,
crit filters.FilterCriteria,
cursors map[common.Address]string,
) ([]*ethtypes.Log, map[common.Address]string, error) {
res := make([]*ethtypes.Log, 0)
if len(crit.Addresses) == 0 {
crit.Addresses = append(crit.Addresses, common.Address{})
}
updatedAddrToCursor := make(map[common.Address]string)
for _, address := range crit.Addresses {
var cursor string
if _, ok := cursors[address]; !ok {
cursor = ""
} else {
cursor = cursors[address]
}
resAddr, cursor, err := a.getLogs(
ctx,
crit.BlockHash,
crit.FromBlock,
crit.ToBlock,
address,
crit.Topics,
cursor,
)
if err != nil {
return nil, nil, err
}
res = append(res, resAddr...)
updatedAddrToCursor[address] = cursor
}
return res, updatedAddrToCursor, nil
}

// pulls logs from tendermint client for a single address.
func (a *FilterAPI) getLogs(
ctx context.Context,
blockHash *common.Hash,
fromBlock *big.Int,
toBlock *big.Int,
address common.Address,
topics [][]common.Hash,
cursor string,
) ([]*ethtypes.Log, string, error) {
q := NewQueryBuilder()
if blockHash != nil {
q = q.FilterBlockHash(blockHash.Hex())
}
if fromBlock != nil {
q = q.FilterBlockNumberStart(fromBlock.Int64())
}
if toBlock != nil {
q = q.FilterBlockNumberEnd(toBlock.Int64())
}
if (address != common.Address{}) {
q = q.FilterContractAddress(address.Hex())
}
if len(topics) > 0 {
topicsStrs := make([][]string, len(topics))
for i, topic := range topics {
topicsStrs[i] = make([]string, len(topic))
for j, t := range topic {
topicsStrs[i][j] = t.Hex()
}
}
q = q.FilterTopics(topicsStrs)
}
hasMore := true
logs := []*ethtypes.Log{}
for hasMore {
res, err := a.tmClient.Events(ctx, &coretypes.RequestEvents{
Filter: &coretypes.EventFilter{Query: q.Build()},
After: cursor,
})
if err != nil {
return nil, "", err
}
hasMore = res.More
cursor = res.Newest
for _, log := range res.Items {
abciEvent := abci.Event{}
err := json.Unmarshal(log.Data, &abciEvent)
if err != nil {
return nil, "", err
}
ethLog, err := encodeEventToLog(abciEvent)
if err != nil {
return nil, "", err
}
logs = append(logs, ethLog)
}
}
return logs, cursor, nil
}

func (a *FilterAPI) UninstallFilter(
_ context.Context,
filterID uint64,
) bool {
a.filtersMu.Lock()
defer a.filtersMu.Unlock()
_, found := a.filters[filterID]
if !found {
return false
}
delete(a.filters, filterID)
return true
}
304 changes: 304 additions & 0 deletions evmrpc/filter_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,304 @@
package evmrpc

import (
"testing"
"time"

"github.com/ethereum/go-ethereum/common"
"github.com/stretchr/testify/require"
)

func TestFilterNew(t *testing.T) {
t.Parallel()
tests := []struct {
name string
fromBlock string
toBlock string
blockHash common.Hash
addrs []common.Address
topics [][]common.Hash
wantErr bool
}{
{
name: "happy path",
fromBlock: "0x1",
toBlock: "0x2",
addrs: []common.Address{common.HexToAddress("0x123")},
topics: [][]common.Hash{{common.HexToHash("0x456")}},
wantErr: false,
},
{
name: "error: block hash and block range both given",
fromBlock: "0x1",
toBlock: "0x2",
blockHash: common.HexToHash("0xabc"),
wantErr: true,
},
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
filterCriteria := map[string]interface{}{
"fromBlock": tt.fromBlock,
"toBlock": tt.toBlock,
"address": tt.addrs,
"topics": tt.topics,
}
if tt.blockHash != (common.Hash{}) {
filterCriteria["blockHash"] = tt.blockHash.Hex()
}
if len(tt.fromBlock) > 0 || len(tt.toBlock) > 0 {
filterCriteria["fromBlock"] = tt.fromBlock
filterCriteria["toBlock"] = tt.toBlock
}
resObj := sendRequestGood(t, "newFilter", filterCriteria)
if tt.wantErr {
_, ok := resObj["error"]
require.True(t, ok)
} else {
got := resObj["result"].(float64)
// make sure next filter id is not equal to this one
resObj := sendRequestGood(t, "newFilter", filterCriteria)
got2 := resObj["result"].(float64)
require.NotEqual(t, got, got2)
}
})
}
}

func TestFilterUninstall(t *testing.T) {
t.Parallel()
// uninstall existing filter
filterCriteria := map[string]interface{}{
"fromBlock": "0x1",
"toBlock": "0xa",
}
resObj := sendRequestGood(t, "newFilter", filterCriteria)
filterId := int(resObj["result"].(float64))
require.GreaterOrEqual(t, filterId, 1)

resObj = sendRequest(t, TestPort, "uninstallFilter", filterId)
uninstallSuccess := resObj["result"].(bool)
require.True(t, uninstallSuccess)

// uninstall non-existing filter
nonExistingFilterId := 100
resObj = sendRequest(t, TestPort, "uninstallFilter", nonExistingFilterId)
uninstallSuccess = resObj["result"].(bool)
require.False(t, uninstallSuccess)
}

func TestFilterGetLogs(t *testing.T) {
t.Parallel()
tests := []struct {
name string
blockHash common.Hash
fromBlock string
toBlock string
addrs []common.Address
topics [][]common.Hash
wantErr bool
wantLen int
check func(t *testing.T, log map[string]interface{})
}{
{
name: "filter by single address",
fromBlock: "0x2",
toBlock: "0x2",
addrs: []common.Address{common.HexToAddress("0x1111111111111111111111111111111111111112")},
wantErr: false,
check: func(t *testing.T, log map[string]interface{}) {
require.Equal(t, "0x1111111111111111111111111111111111111112", log["address"].(string))
},
wantLen: 1,
},
{
name: "filter by single topic",
blockHash: common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000000"),
fromBlock: "0x3",
toBlock: "0x3",
topics: [][]common.Hash{{common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000123")}},
wantErr: false,
check: func(t *testing.T, log map[string]interface{}) {
require.Equal(t, "0x0000000000000000000000000000000000000000000000000000000000000123", log["topics"].([]interface{})[0].(string))
},
wantLen: 1,
},
{
name: "multiple addresses, multiple topics",
blockHash: common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000000"),
fromBlock: "0x2",
toBlock: "0x2",
addrs: []common.Address{
common.HexToAddress("0x1111111111111111111111111111111111111112"),
common.HexToAddress("0x1111111111111111111111111111111111111113"),
},
topics: [][]common.Hash{
{common.Hash(common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000123"))},
{common.Hash(common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000456"))},
},
wantErr: false,
check: func(t *testing.T, log map[string]interface{}) {
if log["address"].(string) != "0x1111111111111111111111111111111111111112" && log["address"].(string) != "0x1111111111111111111111111111111111111113" {
t.Fatalf("address %s not in expected list", log["address"].(string))
}
firstTopic := log["topics"].([]interface{})[0].(string)
secondTopic := log["topics"].([]interface{})[1].(string)
require.Equal(t, "0x0000000000000000000000000000000000000000000000000000000000000123", firstTopic)
require.Equal(t, "0x0000000000000000000000000000000000000000000000000000000000000456", secondTopic)
},
wantLen: 2,
},
{
name: "wildcard first topic",
blockHash: common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000000"),
fromBlock: "0x2",
toBlock: "0x2",
topics: [][]common.Hash{
{},
{common.Hash(common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000456"))},
},
wantErr: false,
check: func(t *testing.T, log map[string]interface{}) {
secondTopic := log["topics"].([]interface{})[1].(string)
require.Equal(t, "0x0000000000000000000000000000000000000000000000000000000000000456", secondTopic)
},
wantLen: 1,
},
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
filterCriteria := map[string]interface{}{
"fromBlock": tt.fromBlock,
"toBlock": tt.toBlock,
"address": tt.addrs,
"topics": tt.topics,
}
if tt.blockHash != (common.Hash{}) {
filterCriteria["blockHash"] = tt.blockHash.Hex()
}
if len(tt.fromBlock) > 0 || len(tt.toBlock) > 0 {
filterCriteria["fromBlock"] = tt.fromBlock
filterCriteria["toBlock"] = tt.toBlock
}
resObj := sendRequestGood(t, "getLogs", filterCriteria)
if tt.wantErr {
_, ok := resObj["error"]
require.True(t, ok)
} else {
got := resObj["result"].([]interface{})
for _, log := range got {
logObj := log.(map[string]interface{})
tt.check(t, logObj)
}
require.Equal(t, len(got), tt.wantLen)
}
})
}
}

func TestFilterGetFilterLogs(t *testing.T) {
t.Parallel()
filterCriteria := map[string]interface{}{
"fromBlock": "0x4",
"toBlock": "0x4",
}
resObj := sendRequestGood(t, "newFilter", filterCriteria)
filterId := int(resObj["result"].(float64))

resObj = sendRequest(t, TestPort, "getFilterLogs", filterId)
logs := resObj["result"].([]interface{})
require.Equal(t, 1, len(logs))
for _, log := range logs {
logObj := log.(map[string]interface{})
require.Equal(t, "0x4", logObj["blockNumber"].(string))
}

// error: filter id does not exist
nonexistentFilterId := 1000
resObj = sendRequest(t, TestPort, "getFilterLogs", nonexistentFilterId)
_, ok := resObj["error"]
require.True(t, ok)
}

func TestFilterGetFilterChanges(t *testing.T) {
t.Parallel()
filterCriteria := map[string]interface{}{
"fromBlock": "0x5",
}
resObj := sendRequest(t, TestPort, "newFilter", filterCriteria)
filterId := int(resObj["result"].(float64))

resObj = sendRequest(t, TestPort, "getFilterChanges", filterId)
logs := resObj["result"].([]interface{})
require.Equal(t, 1, len(logs))
logObj := logs[0].(map[string]interface{})
require.Equal(t, "0x5", logObj["blockNumber"].(string))

// another query
resObj = sendRequest(t, TestPort, "getFilterChanges", filterId)
logs = resObj["result"].([]interface{})
require.Equal(t, 1, len(logs))
logObj = logs[0].(map[string]interface{})
require.Equal(t, "0x6", logObj["blockNumber"].(string))

// error: filter id does not exist
nonExistingFilterId := 1000
resObj = sendRequest(t, TestPort, "getFilterChanges", nonExistingFilterId)
_, ok := resObj["error"]
require.True(t, ok)
}

func TestFilterExpiration(t *testing.T) {
t.Parallel()
filterCriteria := map[string]interface{}{
"fromBlock": "0x1",
"toBlock": "0xa",
}
resObj := sendRequestGood(t, "newFilter", filterCriteria)
filterId := int(resObj["result"].(float64))

// wait for filter to expire
time.Sleep(2 * filterTimeoutDuration)

resObj = sendRequest(t, TestPort, "getFilterLogs", filterId)
_, ok := resObj["error"]
require.True(t, ok)
}

func TestFilterGetFilterLogsKeepsFilterAlive(t *testing.T) {
t.Parallel()
filterCriteria := map[string]interface{}{
"fromBlock": "0x1",
"toBlock": "0xa",
}
resObj := sendRequestGood(t, "newFilter", filterCriteria)
filterId := int(resObj["result"].(float64))

for i := 0; i < 5; i++ {
// should keep filter alive
resObj = sendRequestGood(t, "getFilterLogs", filterId)
_, ok := resObj["error"]
require.False(t, ok)
time.Sleep(filterTimeoutDuration / 2)
}
}

func TestFilterGetFilterChangesKeepsFilterAlive(t *testing.T) {
t.Parallel()
filterCriteria := map[string]interface{}{
"fromBlock": "0x1",
"toBlock": "0xa",
}
resObj := sendRequestGood(t, "newFilter", filterCriteria)
filterId := int(resObj["result"].(float64))

for i := 0; i < 5; i++ {
// should keep filter alive
resObj = sendRequestGood(t, "getFilterChanges", filterId)
_, ok := resObj["error"]
require.False(t, ok)
time.Sleep(filterTimeoutDuration / 2)
}
}
5 changes: 5 additions & 0 deletions evmrpc/server.go
Original file line number Diff line number Diff line change
@@ -23,6 +23,7 @@ func NewEVMHTTPServer(
ctxProvider func(int64) sdk.Context,
txConfig client.TxConfig,
simulationConfig *SimulateConfig,
filterConfig *FilterConfig,
) (EVMServer, error) {
httpServer := newHTTPServer(logger, timeouts)
if err := httpServer.setListenAddr(addr, port); err != nil {
@@ -57,6 +58,10 @@ func NewEVMHTTPServer(
Namespace: "eth",
Service: NewSimulationAPI(ctxProvider, k, tmClient, simulationConfig),
},
{
Namespace: "eth",
Service: NewFilterAPI(tmClient, filterConfig),
},
}
if err := httpServer.enableRPC(apis, httpConfig{
// TODO: add CORS configs and virtual host configs
39 changes: 39 additions & 0 deletions evmrpc/subscribe.go
Original file line number Diff line number Diff line change
@@ -2,9 +2,11 @@ package evmrpc

import (
"context"
"errors"
"fmt"
"strings"

"github.com/sei-protocol/sei-chain/utils"
"github.com/sei-protocol/sei-chain/x/evm/types"
rpcclient "github.com/tendermint/tendermint/rpc/client"
"github.com/tendermint/tendermint/rpc/coretypes"
@@ -68,11 +70,48 @@ func (q *QueryBuilder) FilterTopic(topic string) *QueryBuilder {
return q
}

func (q *QueryBuilder) FilterTopics(topics [][]string) *QueryBuilder {
if len(topics) == 0 {
return q
}
pattern, err := getTopicsRegex(topics)
if err != nil {
panic(err)
}
q.conditions = append(q.conditions, fmt.Sprintf("%s.%s = MATCHES '%s'", types.EventTypeEVMLog, types.AttributeTypeTopics, pattern))
return q
}

func getTopicsRegex(topics [][]string) (string, error) {
if len(topics) == 0 {
return "", errors.New("topics array must be at least length 1")
}

topicRegex := func(topic []string) string {
if len(topic) == 0 {
return ""
}
return fmt.Sprintf("(%s)", strings.Join(topic, "|"))
}

return fmt.Sprintf("\\[%s.*\\]", strings.Join(utils.Map(topics, topicRegex), "[^\\,]*,")), nil
}

func (q *QueryBuilder) FilterBlockNumber(blockNumber int64) *QueryBuilder {
q.conditions = append(q.conditions, fmt.Sprintf("%s.%s = '%d'", types.EventTypeEVMLog, types.AttributeTypeBlockNumber, blockNumber))
return q
}

func (q *QueryBuilder) FilterBlockNumberStart(blockNumber int64) *QueryBuilder {
q.conditions = append(q.conditions, fmt.Sprintf("%s.%s >= '%d'", types.EventTypeEVMLog, types.AttributeTypeBlockNumber, blockNumber))
return q
}

func (q *QueryBuilder) FilterBlockNumberEnd(blockNumber int64) *QueryBuilder {
q.conditions = append(q.conditions, fmt.Sprintf("%s.%s <= '%d'", types.EventTypeEVMLog, types.AttributeTypeBlockNumber, blockNumber))
return q
}

func (q *QueryBuilder) FilterTxIndex(txIndex int64) *QueryBuilder {
q.conditions = append(q.conditions, fmt.Sprintf("%s.%s = '%d'", types.EventTypeEVMLog, types.AttributeTypeTxIndex, txIndex))
return q
63 changes: 63 additions & 0 deletions evmrpc/subscribe_test.go
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@ package evmrpc

import (
"context"
"regexp"
"testing"

"github.com/stretchr/testify/require"
@@ -40,3 +41,65 @@ func mockQueryBuilder() *QueryBuilder {
q.FilterTopic("topic b")
return q
}

func TestGetTopicsRegex(t *testing.T) {
tests := []struct {
name string
topics [][]string
wantErr bool
wantMatch []string
wantNotMatch []string
}{
{
name: "error: topics length 0",
topics: [][]string{},
wantErr: true,
},
{
name: "match first topic",
topics: [][]string{{"a"}},
wantErr: false,
wantMatch: []string{"[a]", "[a,b]", "[a,a,a,a]"},
wantNotMatch: []string{"b", "[b]", "[b,a]", "[a,b"},
},
{
name: "match first topic with OR",
topics: [][]string{{"a", "b"}}, // first topic can be a or b
wantErr: false,
wantMatch: []string{"[a]", "[a,b]", "[a,c,c,c]", "[b]", "[b,c]", "[b,c,c,c]"},
wantNotMatch: []string{"b", "[c]", "[c,a]", "[c,b"},
},
{
name: "match second topic",
topics: [][]string{{}, {"a"}},
wantErr: false,
wantMatch: []string{"[b,a]", "[c,a]", "[a,a,a]"},
wantNotMatch: []string{"b,a]", "[a,b,a]"},
},
{
name: "match second and fourth topic",
topics: [][]string{{""}, {"a", "c"}, {""}, {"b", "d"}},
wantErr: false,
wantMatch: []string{"[d,a,c,b]", "[c,a,c,d,c]", "[a,c,b,d]"},
wantNotMatch: []string{"[a,a,a,a]", "[a,b]", "[c,a,b,c]"},
},
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := getTopicsRegex(tt.topics)
regex := regexp.MustCompile(got)
if tt.wantErr {
require.NotNil(t, err)
return
}
require.Nil(t, err)
for _, toMatch := range tt.wantMatch {
require.True(t, regex.MatchString(toMatch))
}
for _, toNotMatch := range tt.wantNotMatch {
require.False(t, regex.MatchString(toNotMatch))
}
})
}
}
247 changes: 213 additions & 34 deletions evmrpc/testutils.go
Original file line number Diff line number Diff line change
@@ -9,6 +9,8 @@ import (
"io"
"math/big"
"net/http"
"regexp"
"strconv"
"strings"
"testing"
"time"
@@ -48,6 +50,9 @@ var Tx sdk.Tx

var SConfig = SimulateConfig{GasCap: 10000000}

var filterTimeoutDuration = 500 * time.Millisecond
var FConfig = FilterConfig{timeout: filterTimeoutDuration}

type MockClient struct {
mock.Client
}
@@ -93,6 +98,7 @@ func (c *MockClient) BlockByHash(context.Context, bytes.HexBytes) (*coretypes.Re
}

func (c *MockClient) BlockResults(context.Context, *int64) (*coretypes.ResultBlockResults, error) {
abciEvent := NewABCIEventBuilder().SetBlockNum(8).Build()
return &coretypes.ResultBlockResults{
TxsResults: []*abci.ExecTxResult{
{
@@ -102,37 +108,9 @@ func (c *MockClient) BlockResults(context.Context, *int64) (*coretypes.ResultBlo
}(),
GasWanted: 10,
GasUsed: 5,
Events: []abci.Event{{
Type: types.EventTypeEVMLog,
Attributes: []abci.EventAttribute{{
Key: []byte(types.AttributeTypeContractAddress),
Value: []byte("0x1111111111111111111111111111111111111111111111111111111111111111"),
}, {
Key: []byte(types.AttributeTypeBlockHash),
Value: []byte("0x1111111111111111111111111111111111111111111111111111111111111111"),
}, {
Key: []byte(types.AttributeTypeBlockNumber),
Value: []byte("8"),
}, {
Key: []byte(types.AttributeTypeData),
Value: []byte("xyz"),
}, {
Key: []byte(types.AttributeTypeIndex),
Value: []byte("1"),
}, {
Key: []byte(types.AttributeTypeTxIndex),
Value: []byte("2"),
}, {
Key: []byte(types.AttributeTypeRemoved),
Value: []byte("true"),
}, {
Key: []byte(types.AttributeTypeTopics),
Value: []byte("0x1111111111111111111111111111111111111111111111111111111111111111,0x1111111111111111111111111111111111111111111111111111111111111112"),
}, {
Key: []byte(types.AttributeTypeTxHash),
Value: []byte("0x1111111111111111111111111111111111111111111111111111111111111113"),
}},
}},
Events: []abci.Event{
abciEvent,
},
},
},
}, nil
@@ -142,6 +120,81 @@ func (c *MockClient) Subscribe(context.Context, string, string, ...int) (<-chan
return make(chan coretypes.ResultEvent, 1), nil
}

func (c *MockClient) Events(_ context.Context, req *coretypes.RequestEvents) (*coretypes.ResultEvents, error) {
eb := NewABCIEventBuilder()

// assume cursor is block number for testing purposes
var cursor string
if req.After != "" {
cursorAfter, err := strconv.Atoi(req.After)
if err != nil {
panic("invalid cursor")
}
nextBlockNum := cursorAfter + 1
eb = eb.SetBlockNum(nextBlockNum)
cursor = strconv.FormatInt(int64(nextBlockNum), 10)
} else {
var startBlock int
re := regexp.MustCompile(`evm_log.block_number >= '(\d+?)'`)
matches := re.FindStringSubmatch(req.Filter.Query)
if len(matches) == 2 {
var err error
startBlock, err = strconv.Atoi(matches[1])
if err != nil {
return nil, err
}
eb = eb.SetBlockNum(startBlock)
cursor = strconv.FormatInt(int64(startBlock), 10)
}
}

var blockHash string
re := regexp.MustCompile(`evm_log.block_hash = '(.+?)'`)
matches := re.FindStringSubmatch(req.Filter.Query)
if len(matches) == 2 {
blockHash = matches[1]
eb = eb.SetBlockHash(blockHash)
}

var contractAddress string
re = regexp.MustCompile(`evm_log.contract_address = '(.+?)'.*`)
matches = re.FindStringSubmatch(req.Filter.Query)
if len(matches) == 2 {
contractAddress = matches[1]
eb = eb.SetContractAddress(contractAddress)
}

// hardcode topic matches to match up with tests since doing the regex is too complicated
if strings.Contains(req.Filter.Query, "evm_log.topics = MATCHES '\\[(0x0000000000000000000000000000000000000000000000000000000000000123).*\\]'") {
eb = eb.SetTopics([]string{"0x0000000000000000000000000000000000000000000000000000000000000123"})
} else if strings.Contains(req.Filter.Query, "evm_log.topics = MATCHES '\\[(0x0000000000000000000000000000000000000000000000000000000000000123)[^\\,]*,(0x0000000000000000000000000000000000000000000000000000000000000456).*\\]'") {
eb = eb.SetTopics([]string{"0x0000000000000000000000000000000000000000000000000000000000000123", "0x0000000000000000000000000000000000000000000000000000000000000456"})
} else if strings.Contains(req.Filter.Query, "evm_log.topics = MATCHES '\\[[^\\,]*,(0x0000000000000000000000000000000000000000000000000000000000000456).*\\]'") {
eb = eb.SetTopics([]string{"0x0000000000000000000000000000000000000000000000000000000000000123", "0x0000000000000000000000000000000000000000000000000000000000000456"})
}

return buildSingleResultEvent(eb.Build(), false, cursor, "event"), nil
}

func buildSingleResultEvent(abciEvent abci.Event, more bool, cursor string, event string) *coretypes.ResultEvents {
eventData, err := json.Marshal(abciEvent)
if err != nil {
panic(err)
}
return &coretypes.ResultEvents{
Items: []*coretypes.EventItem{
{
Cursor: cursor,
Event: event,
Data: eventData,
},
},
More: more,
Oldest: cursor,
Newest: cursor,
}
}

func (c *MockClient) BroadcastTx(context.Context, tmtypes.Tx) (*coretypes.ResultBroadcastTx, error) {
return &coretypes.ResultBroadcastTx{Code: 0}, nil
}
@@ -176,14 +229,14 @@ var Ctx sdk.Context
func init() {
types.RegisterInterfaces(EncodingConfig.InterfaceRegistry)
EVMKeeper, _, Ctx = keeper.MockEVMKeeper()
httpServer, err := NewEVMHTTPServer(log.NewNopLogger(), TestAddr, TestPort, rpc.DefaultHTTPTimeouts, &MockClient{}, EVMKeeper, func(int64) sdk.Context { return Ctx }, TxConfig, &SConfig)
httpServer, err := NewEVMHTTPServer(log.NewNopLogger(), TestAddr, TestPort, rpc.DefaultHTTPTimeouts, &MockClient{}, EVMKeeper, func(int64) sdk.Context { return Ctx }, TxConfig, &SConfig, &FConfig)
if err != nil {
panic(err)
}
if err := httpServer.Start(); err != nil {
panic(err)
}
badHTTPServer, err := NewEVMHTTPServer(log.NewNopLogger(), TestAddr, TestBadPort, rpc.DefaultHTTPTimeouts, &MockBadClient{}, EVMKeeper, func(int64) sdk.Context { return Ctx }, TxConfig, &SConfig)
badHTTPServer, err := NewEVMHTTPServer(log.NewNopLogger(), TestAddr, TestBadPort, rpc.DefaultHTTPTimeouts, &MockBadClient{}, EVMKeeper, func(int64) sdk.Context { return Ctx }, TxConfig, &SConfig, &FConfig)
if err != nil {
panic(err)
}
@@ -306,6 +359,27 @@ func formatParam(p interface{}) string {
return fmt.Sprintf("%f", v)
case string:
return fmt.Sprintf("\"%s\"", v)
case common.Address:
return fmt.Sprintf("\"%s\"", v)
case []common.Address:
wrapper := func(i common.Address) string {
return formatParam(i)
}
return fmt.Sprintf("[%s]", strings.Join(utils.Map(v, wrapper), ","))
case common.Hash:
return fmt.Sprintf("\"%s\"", v)
case []common.Hash:
wrapper := func(i common.Hash) string {
return formatParam(i)
}
return fmt.Sprintf("[%s]", strings.Join(utils.Map(v, wrapper), ","))
case [][]common.Hash:
wrapper := func(i []common.Hash) string {
return formatParam(i)
}
return fmt.Sprintf("[%s]", strings.Join(utils.Map(v, wrapper), ","))
case []string:
return fmt.Sprintf("[%s]", strings.Join(v, ","))
case []interface{}:
return fmt.Sprintf("[%s]", strings.Join(utils.Map(v, formatParam), ","))
case map[string]interface{}:
@@ -315,6 +389,111 @@ func formatParam(p interface{}) string {
}
return fmt.Sprintf("{%s}", strings.Join(kvs, ","))
default:
return fmt.Sprintf("%s", p)
panic("did not match on type")
}
}

type ABCIEventBuilder struct {
contractAddress string
blockHash string
blockNum int
data string
index int
txIndex int
removed bool
topics []string
txHash common.Hash
}

func NewABCIEventBuilder() *ABCIEventBuilder {
return &ABCIEventBuilder{
contractAddress: "0x1111111111111111111111111111111111111111111111111111111111111111",
blockHash: "0x1111111111111111111111111111111111111111111111111111111111111111",
blockNum: 8,
data: "xyz",
index: 1,
txIndex: 2,
removed: true,
topics: []string{"0x1111111111111111111111111111111111111111111111111111111111111111,0x1111111111111111111111111111111111111111111111111111111111111112"},
txHash: common.HexToHash("0x1111111111111111111111111111111111111111111111111111111111111113"),
}
}

func (b *ABCIEventBuilder) SetContractAddress(contractAddress string) *ABCIEventBuilder {
b.contractAddress = contractAddress
return b
}

func (b *ABCIEventBuilder) SetBlockHash(blockHash string) *ABCIEventBuilder {
b.blockHash = blockHash
return b
}

func (b *ABCIEventBuilder) SetBlockNum(blockNum int) *ABCIEventBuilder {
b.blockNum = blockNum
return b
}

func (b *ABCIEventBuilder) SetData(data string) *ABCIEventBuilder {
b.data = data
return b
}

func (b *ABCIEventBuilder) SetIndex(index int) *ABCIEventBuilder {
b.index = index
return b
}

func (b *ABCIEventBuilder) SetTxIndex(txIndex int) *ABCIEventBuilder {
b.txIndex = txIndex
return b
}

func (b *ABCIEventBuilder) SetRemoved(removed bool) *ABCIEventBuilder {
b.removed = removed
return b
}

func (b *ABCIEventBuilder) SetTopics(topics []string) *ABCIEventBuilder {
b.topics = topics
return b
}

func (b *ABCIEventBuilder) SetTxHash(txHash common.Hash) *ABCIEventBuilder {
b.txHash = txHash
return b
}

func (b *ABCIEventBuilder) Build() abci.Event {
return abci.Event{
Type: types.EventTypeEVMLog,
Attributes: []abci.EventAttribute{{
Key: []byte(types.AttributeTypeContractAddress),
Value: []byte(b.contractAddress),
}, {
Key: []byte(types.AttributeTypeBlockHash),
Value: []byte(b.blockHash),
}, {
Key: []byte(types.AttributeTypeBlockNumber),
Value: []byte(fmt.Sprintf("%d", b.blockNum)),
}, {
Key: []byte(types.AttributeTypeData),
Value: []byte(b.data),
}, {
Key: []byte(types.AttributeTypeIndex),
Value: []byte(fmt.Sprintf("%d", b.index)),
}, {
Key: []byte(types.AttributeTypeTxIndex),
Value: []byte(fmt.Sprintf("%d", b.txIndex)),
}, {
Key: []byte(types.AttributeTypeRemoved),
Value: []byte(fmt.Sprintf("%t", b.removed)),
}, {
Key: []byte(types.AttributeTypeTopics),
Value: []byte(strings.Join(b.topics, ",")),
}, {
Key: []byte(types.AttributeTypeTxHash),
Value: []byte(b.txHash.Hex()),
}},
}
}