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
R4R: Add new error type and script center for customized scripts feature #146
Conversation
e530afc
to
2bb80c7
Compare
79b5570
to
118cb73
Compare
118cb73
to
19787e0
Compare
x/auth/script.go
Outdated
|
||
type Script func(ctx sdk.Context, tx sdk.Msg) sdk.Error | ||
|
||
var scriptsCenter = map[string][]Script{} |
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.
scriptsCenter
. the name is a bit weird..
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.
Any suggested names?
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.
scriptsHub
is better
63fc93a
to
69361ca
Compare
x/auth/script.go
Outdated
sdk "github.com/cosmos/cosmos-sdk/types" | ||
) | ||
|
||
type Script func(ctx sdk.Context, tx sdk.Msg) sdk.Error |
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.
if you want this Script
a common script object, you should not put it here.
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.
auth is not a good package to put the Script
type.
Any suggested package? |
6b27f86
to
adbd17b
Compare
baseapp/baseapp.go
Outdated
sdk.CacheMultiStore, sdk.AccountCache) { | ||
// Get the context | ||
ctx := getState(app, mode).Ctx.WithTxBytes(txBytes) | ||
ctx := getState(app, mode).Ctx.WithTxBytes(txBytes).WithTx(tx) |
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 suggest we do not cache this Tx, as this is to tax ALL transactions for just a few of transactions among all the send.
We can still decode the Tx from txBytes when we figure out the receive address is really set the flag, which should be only a very small subset of the total transaction universe.
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.
The tx
is just an interface. It won't call cause too much data copy operation.
Previously, I have done an optimization as you said. But for future scripts, it's much likely they need to decode tx too. Now the implementation can provide a general solution for all future scripts. So I think it is better. @rickyyangz What do you think about 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.
make sense. but can we have a small test on how much it takes for a context.WithTx(tx)?
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.
as discussed, let us remove the WithTxBytes
as it is no use for us. cosmos itself uses it for the gas calculation which is no need for us. So we can make room for the WithTx
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.
The WithTx
itself is not very costly, but adding more contexts will make the context query slower as the context is a chain and query starts from the last context.
So we need to consider the order of these contexts.
The benchmark result is not stable. But it seems that the |
3710685
to
af3c3e7
Compare
3acb7d5
to
3f88023
Compare
Resolve comment about avariable name
log empty script
Remove unit withTxBytes
e851218
to
88e7c3c
Compare
R4R: Add new error type and script center for customized scripts feature
Add new error type for BEP12
bnb-chain/node#605