-
Notifications
You must be signed in to change notification settings - Fork 38
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
feat: implement new apis and refactoring #28
Conversation
new eth apis - GetStorageAt - GetCode refactor - Restricted the scope of access for each namespace API (instead of accessing the backend directly, now access is through a scoped wrapper) - Also renamed files and repositioned some methods within the backend directory to better reflect their purpose
temp disable txpool api because we don't have any implementation
Co-authored-by: zsystm <[email protected]>
ran the followings for this commit: - go mod tidy - go work sync
current version of cometbft which minievm uses have a bug(cometbft/cometbft#3264 (comment)) which makes transaction broadcasting unavailable.
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.
Aside from the comments regarding the cometBFT bump and the GNU license, LGTM.
@@ -280,7 +282,7 @@ replace ( | |||
|
|||
// initia custom | |||
replace ( | |||
github.com/cometbft/cometbft => github.com/initia-labs/cometbft v0.0.0-20240621094738-408dc5262680 | |||
github.com/cometbft/cometbft => github.com/initia-labs/cometbft v0.0.0-20240704071957-c46468756c01 //v0.0.0-20240621094738-408dc5262680 |
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.
It seems that the target base branch and main branch of this PR are not yet using the specified version of cometBFT. Since there isn't a separate cometBFT bump PR, it would be helpful to add a more detailed explanation of the reason for the bump in this PR description. diff c46468756c01...408dc5262680
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.
@dongsam
I have added the reasoning for bumping up cometBFT version.
updated cometBFT version to initia-labs/cometbft v0.38.x which includes this commit
without the above commit, broadcasting tx always fails, cannot process any transactions.
check the cometbft/cometbft#3261 for details
// This file is part of Evmos' Ethermint library. | ||
// | ||
// The Ethermint library is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU Lesser General Public License as published by |
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.
use code under the GNU license, there may be a requirement that the distribution must also follow the GNU license. However, since minievm currently uses a non-GNU license, it is important to clearly state in the PR description that GNU code from evmos/ethermint is being used. This will help the repository maintainer to be aware of this.
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.
@dongsam
I have added License issue
section to the PR description.
This PR includes some codes that are derived from the Ethermint, which is licensed under the GNU Lesser General Public License (LGPL) v3. Minievm uses the Business Source License (BSL) 1.1, this could potentially lead to a license conflict.
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.
This can be problem hmm, I think we can rewrite filter logics to do not use comet but directly subscribe from indexer.
I will change this part after merging it.
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.
LGTM; left some comments but that parts will be changed in next PR, so let's merge it first and I will make new PR to change filter system to do not use comet.
continue | ||
} | ||
|
||
logs := evmtypes.Logs.ToEthLogs(ethResp.Logs) |
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.
I think Logs does not contain tx hash or block hash infos, so the subscriber has no way to retrieve the tx data or block data with this logs.
so maybe we need to fill the infos like GetLogsByHeight
for _, tx := range txs {
receipt, err := b.app.EVMIndexer().TxReceiptByHash(queryCtx, tx.Hash)
if err != nil {
return nil, err
}
logs := receipt.Logs
for idx, log := range logs {
log.BlockHash = blockHeader.Hash()
log.BlockNumber = height
log.TxHash = tx.Hash
log.Index = uint(idx)
log.TxIndex = receipt.TransactionIndex
}
blockLogs = append(blockLogs, logs)
}
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.
also we don't know eth tx hash at this step, we need to convert cosmos tx to eth tx and get the eth tx hash and use that hash to get receipt.
|
||
api.filtersMu.Lock() | ||
if f, found := api.filters[headerSub.ID()]; found { | ||
f.hashes = append(f.hashes, common.BytesToHash(data.Header.Hash())) |
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.
cometbft block hash different from evm block hash, we try to mimic same logic with to generate block hash
Line 101 in b6a073a
blockHash := blockHeader.Hash() |
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.
so good to get evm block hash with block number
// This file is part of Evmos' Ethermint library. | ||
// | ||
// The Ethermint library is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU Lesser General Public License as published by |
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.
This can be problem hmm, I think we can rewrite filter logics to do not use comet but directly subscribe from indexer.
I will change this part after merging it.
* wip * wip2 * feat: json-rpc signing * direction * add indexer * enable jsonrpc * add precision checking logic * fix test * reterive value from the msg * fix: handle unit conversion in cosmos to ethereum tx (#24) whenever ethereum tx is converted into cosmos tx by ConvertEthereumTxToCosmosTx, the value is converted to cosmos fee unit from wei. so when convert the cosmos tx to back the original ethereum tx, we should convert the value back to wei to get original ethereum tx. * fix pubkey recover * fix test * feat: implement new apis and refactoring (#28) * feat: new eth apis, refactor: code structures new eth apis - GetStorageAt - GetCode refactor - Restricted the scope of access for each namespace API (instead of accessing the backend directly, now access is through a scoped wrapper) - Also renamed files and repositioned some methods within the backend directory to better reflect their purpose * fix: not implemented txpool api temp disable txpool api because we don't have any implementation * fix: change event type for extract logs * add cap for filters * add filter system and apis * fix comment Co-authored-by: zsystm <[email protected]> * delete unused interfaces and comments * fix varible and function naming * add TODO comments * delete unused functions * add error handling * Set websocket params to prevent timeout * fix: change GetLogsByHeight interface * chore: change variable names from tm to comet * docs: add comments about websocket client params * fix: go.mod and go.work.sum ran the followings for this commit: - go mod tidy - go work sync * update: cometbft dep current version of cometbft which minievm uses have a bug(cometbft/cometbft#3264 (comment)) which makes transaction broadcasting unavailable. --------- Co-authored-by: jason song <[email protected]> Co-authored-by: jasonsong0 <[email protected]> * feat: directly subscribe logs from indexer (#34) * change filter system to directly subscribe from indexer * use mutex and pass logs in bulk * fix dependency problems * add readme * update readme --------- Co-authored-by: suha jin <[email protected]> Co-authored-by: zsystm <[email protected]> Co-authored-by: jason song <[email protected]> Co-authored-by: jasonsong0 <[email protected]>
Implement new APIs
Refactoring
Fix
extractLogsFromEvents
always returns an empty arrayEventTypeEVM
EventTypeCreate
andEventTypeCall
Improvements for Future Consideration
getFilterChanges
instead of comet websocket connection and pubsubBump-up cometBFT version
License issue
Furth
Proof of works
setup minitiad for testing
mv minitiad-setup $HOME/.minitia
init1cml96vmptgw99syqrrz8az79xer2pcgptzssde
0xc6fe5d33615a1c52c08018c47e8bc53646a0e101
88cbead91aee890d27bf06e003ade3d4e952427e88f88d31d61d3ef5e5d54305
umin
: 0xb22eAAbf5a3377abDe553f23eA6d82709BA948E0make install
minitiad start
eth_getCode
Request:
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getCode","params":["0xb22eAAbf5a3377abDe553f23eA6d82709BA948E0", "latest"],"id":1}' -H "Content-Type: application/json" http://localhost:8545
Response:
{"jsonrpc":"2.0","id":1,"result":"0x60806...(skipped)"}
(skipped)
: I wrote ‘skipped’ for convenience, but the original return value is the bytecode of the contract. It was too long, so I shortened it.eth_getStorageAt
Request:
Response:
{"jsonrpc":"2.0","id":1,"result":"0x00000000000000000000000000000000000000000000021e19e0c9bab2400000"}
eth_newFilter
0xc08d8192da03aafc8c516e35cc4b0cfd2c139f96
before calling thisRequest:
Response:
{"jsonrpc":"2.0","id":1,"result":"0xd6f8af542b4b3c699a354336358e4700"}
eth_getFilterLogs
Request:
curl -X POST -H "Content-Type: application/json" --data '{"method":"eth_getFilterLogs","params":["0xd6f8af542b4b3c699a354336358e4700"],"id":1,"jsonrpc":"2.0"}' http://localhost:8545
Response:
eth_newBlockFilter
Request:
curl -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_newBlockFilter","params":[],"id":1}' http://localhost:8545
Response:
{"jsonrpc":"2.0","id":1,"result":"0x47bf8617648970968c2481aa433c2836"}
eth_getFilterChanges
Request:
curl -X POST -H "Content-Type: application/json" --data '{"method":"eth_getFilterChanges","params":["0x47bf8617648970968c2481aa433c2836"],"id":1,"jsonrpc":"2.0"}' http://localhost:8545
Response:
{"jsonrpc":"2.0","id":1,"result":["0x44c80c0041d93a5866a448a0d48762f8406e9df6354b099c2469137181d5649a"]}
eth_uninstallFilter
eth_getLogs
Request:
curl -X POST -H "Content-Type: application/json" --data '{"method":"eth_getLogs","params":[{"blockHash":"0x6ebdf8f6a2ccf6c9b9aead31589524949e8e63c16e938f07100725e02c219432"}],"id":1,"jsonrpc":"2.0"}' http://localhost:8545
Result: