rpc: add eth_callMany#1
Conversation
There was a problem hiding this comment.
So erigon doesn't support eth_call on pending blocks? If that's the case, we can ignore the support for pending blocks.
|
I followed your comment and updated the code correspondingly. Could you review my revision when you're free? Thank you! |
|
I left some comments on python tests. Could you make changes on this PR accordingly to address those comments? |
yiteng-guo
left a comment
There was a problem hiding this comment.
Please remove changes that are unrelated tot this PR.
There was a problem hiding this comment.
let's give this a new name since we changed the RPC call name?
There was a problem hiding this comment.
can't you just return in the for-loop?
There was a problem hiding this comment.
Could you explain what txCtx is used for? This txCtx is still the firstMsg txCtx. Could that be a problem?
There was a problem hiding this comment.
txCtx is for tracking the origin of a certain transaction, so we probably want to initialize a new evm for each transaction.
There was a problem hiding this comment.
I see. Then we probably want to call transactions.GetEvmContext for each transaction?
69214f5 to
21b115b
Compare
| transactionIndex := -1 | ||
|
|
||
| if simulateContext.TransactionIndex != nil { | ||
| transactionIndex = *simulateContext.TransactionIndex | ||
| } | ||
|
|
||
| if transactionIndex == -1 { | ||
| transactionIndex = len(block.Transactions()) | ||
| } |
There was a problem hiding this comment.
Let's add comments here to document -1 is a speical value?
There was a problem hiding this comment.
I see. Then we probably want to call transactions.GetEvmContext for each transaction?
| firstMsg, err := bundles[0].Transactions[0].ToMessage(api.GasCap, nil) | ||
| rules := chainConfig.Rules(blockNum) | ||
|
|
||
| if len(replayTransactions) > 0 { | ||
| firstMsg, err = replayTransactions[0].AsMessage(*signer, nil, rules) | ||
| } |
There was a problem hiding this comment.
As I mentioned in the other comment, I think a cleaner way to implement this is to call transactions.GetEvmContext for each transaction. Then you don't need to save this firstMsg.
| blockCtx, txCtx := transactions.GetEvmContext(firstMsg, parent, simulateContext.BlockNumber.RequireCanonical, tx, contractHasTEVM) | ||
| evm = vm.NewEVM(blockCtx, txCtx, st, chainConfig, vm.Config{Debug: false}) |
| blockCtx.GetHash = func(i uint64) common.Hash { | ||
| if hash, ok := overrideBlockHash[i]; ok { | ||
| return hash | ||
| } | ||
| hash, err := rawdb.ReadCanonicalHash(tx, i) | ||
| if err != nil { | ||
| log.Debug("Can't get block hash by number", "number", i, "only-canonical", true) | ||
| } | ||
| return hash | ||
| } |
There was a problem hiding this comment.
Can't we just set this once before the for-loop?
For this PR, I implemented
callIntraBundleto simulate bundles at an arbitrary blockchain index and its corresponding testing suiteeth_block_test.go.For a sample python test,
Using this testing script, we could obtain the reserves of USD-ETH UNI V2 Pair. Since it's highly liquid, there are multiple sync events in the same block. With the intra-block simulation, we could get the intermediate reserves.