-
Notifications
You must be signed in to change notification settings - Fork 562
fix(rpc): cache back access list within same block #1585
Conversation
Hi @mmsqe, so what is the root cause? |
some old tnx make use of cached warmAccess within same block before this fix which use less gas, might need a config for patch height here. |
@mmsqe I see, totally understood, ty for your detailed explanation |
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #1585 +/- ##
==========================================
+ Coverage 68.35% 68.40% +0.04%
==========================================
Files 110 110
Lines 10181 10225 +44
==========================================
+ Hits 6959 6994 +35
- Misses 2819 2827 +8
- Partials 403 404 +1
|
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.
Hey @mmsqe ! Left some comments, was curious about your approach to solving the problem described in the ticket. There are also several CI issues, most importantly that many of the integration tests are failing (most likely because of your changes in state_transition.go
and grpc_query.go
?) It also might be a good idea to add your own tests for this functionality. This PR probably belongs in draft mode for now.
@@ -255,6 +255,9 @@ message QueryTraceTxRequest { | |||
bytes proposer_address = 8 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.ConsAddress"]; | |||
// chain_id is the the eip155 chain id parsed from the requested block header | |||
int64 chain_id = 9; | |||
// fix_clear_access_list_height defines the upgrade height for fix clear access list before processing each | |||
// transaction | |||
int64 fix_clear_access_list_height = 10; |
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.
Why does this constant have to be included in the .proto
file for this request? Why can't it be included in the code elsewhere?
@@ -279,6 +282,9 @@ message QueryTraceBlockRequest { | |||
bytes proposer_address = 8 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.ConsAddress"]; | |||
// chain_id is the eip155 chain id parsed from the requested block header | |||
int64 chain_id = 9; | |||
// fix_clear_access_list_height defines the upgrade height for fix clear access list before processing each | |||
// transaction | |||
int64 fix_clear_access_list_height = 10; |
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.
Same question as above.
signer := ethtypes.MakeSigner(cfg.ChainConfig, big.NewInt(ctx.BlockHeight())) | ||
|
||
height := ctx.BlockHeight() | ||
patch := height < req.FixClearAccessListHeight |
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.
Here, I see that you are accessing the FixClearAccessListHeight
from the request itself. Similar to the question above: why does the constant have to come from the request? Why can't it be stored elsewhere, ex. in the code for the evm keeper itself, to avoid changing the proto files and json-rpc configuration overall?
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.
Cut off height config might be different based on chain, and not sure if env variable is better way than JSONRPCConfig for keeper to access?
Most test fail due to duplicate register proto type when fixing, but I find the upgrade also have issue. |
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.
Thanks for your work on this! Left some more comments
// GetTxTraceResultForBlock returns TxTraceResult and | ||
// statedb with cached address list when need patch and |
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.
Can you complete the sentence you have started here?
return k.ApplyMessageWithStateDB(ctx, msg, tracer, commit, cfg, txConfig, nil) | ||
} | ||
|
||
func (k *Keeper) ApplyMessageWithStateDB(ctx sdk.Context, |
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.
Please add a docstring here
} | ||
|
||
// SetAddressToAccessList overwrite with new access list | ||
func (s *StateDB) SetAddressToAccessList(accessList *accessList) { |
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.
IMO including "address" here can be confusing
func (s *StateDB) SetAddressToAccessList(accessList *accessList) { | |
func (s *StateDB) SetAccessList(accessList *accessList) { |
// GetAddressToAccessList return full access list | ||
func (s *StateDB) GetAddressToAccessList() *accessList { |
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.
Currently not sure on the implication of the unexported-return
warning - this seems like bad practice. Is there maybe a better way to handle this?
// GetAddressToAccessList return full access list | |
func (s *StateDB) GetAddressToAccessList() *accessList { | |
// GetAccessList return full access list | |
func (s *StateDB) GetAccessList() *accessList { |
@@ -396,6 +396,16 @@ func (s *StateDB) AddAddressToAccessList(addr common.Address) { | |||
} | |||
} | |||
|
|||
// GetAddressToAccessList return full access list | |||
func (s *StateDB) GetAddressToAccessList() *accessList { | |||
return s.accessList |
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 should be tested, especially with the golangci-lint warning
continue | ||
} | ||
txConfig.LogIndex += uint(len(rsp.Logs)) | ||
lastDB, _ = k.GetTxTraceResultForTx(ctx, tx, signer, cfg, txConfig, patch, lastDB) |
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.
lastDB, _ = k.GetTxTraceResultForTx(ctx, tx, signer, cfg, txConfig, patch, lastDB) | |
//#nosec G703 -- if an error is returned, just continue with the next iteration | |
lastDB, _ = k.GetTxTraceResultForTx(ctx, tx, signer, cfg, txConfig, patch, lastDB) |
if err != nil { | ||
result.Error = err.Error() | ||
} else { | ||
txConfig.LogIndex = logIndex |
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.
Why assign txConfig.LogIndex
here when it doesn't get returned or used in the rest of the function?
Sorry I forgot to close this PR, since #1603 might be more generic to handle these kind of bug or migrate, thanks for the review. |
Closes: #1583
Description
For contributor use:
docs/
) or specification (x/<module>/spec/
)godoc
comments.Unreleased
section inCHANGELOG.md
Files changed
in the Github PR explorerFor admin use:
WIP
,R4R
,docs
, etc)