-
Notifications
You must be signed in to change notification settings - Fork 8
feat: Check transaction size #445
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
Conversation
4f0ba54 to
a0f777a
Compare
e19853f to
1322639
Compare
1322639 to
5c18415
Compare
07cf079 to
34f4a52
Compare
6dd67e6 to
d33550b
Compare
1f8dfab to
850cb67
Compare
6cb4c65 to
711eb24
Compare
6f3709c to
78838ec
Compare
packages/vm/vmimpl/runreq.go
Outdated
| const maxProgrammableTxCommands = 1024 | ||
| ptb := vmctx.txbuilder.ViewPTB() | ||
| if ptb.Inputs.Len() > maxInputObjects { | ||
| return fmt.Errorf("ptb input len: %d, exceed max_input_objects", ptb.Inputs.Len()) |
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 returned error must be vmexceptions.ErrMaxTransactionSizeExceeded.
packages/vm/vmimpl/runreq.go
Outdated
| vmctx.chainInfo = governance.NewStateReaderFromChainState(vmctx.stateDraft).GetChainInfo(vmctx.ChainID()) | ||
| } | ||
|
|
||
| // checkTransactionSize panics with ErrMaxTransactionSizeExceeded if the estimated transaction size exceeds the limit |
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.
| // checkTransactionSize panics with ErrMaxTransactionSizeExceeded if the estimated transaction size exceeds the limit | |
| // checkTransactionSize returns ErrMaxTransactionSizeExceeded if the estimated transaction size exceeds the limit |
packages/vm/vmimpl/runreq.go
Outdated
| const maxTxSizeBytes = 128 * 1024 | ||
| const maxInputObjects = 2048 | ||
| const maxProgrammableTxCommands = 1024 |
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.
These numbers are arbitrary?
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.
no they are values from iota repo
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 constants here come from struct ProtocolConfig in crates/iota-protocol-config/src/lib.rs
| } | ||
|
|
||
| func (txb *AnchorTransactionBuilder) ViewPTB() *iotago.ProgrammableTransactionBuilder { | ||
| return txb.ptb.Clone() |
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.
There is a lot of stuff that is added to the PTB when BuildTransactionEssence is called. That is not being included here? In that case the estimation will be always lower than the real size.
Look at the stardast implementation:
wasp/packages/vm/vmimpl/runreq.go
Lines 514 to 521 in 06b7a38
| func (vmctx *vmContext) checkTransactionSize() error { | |
| essence, _ := vmctx.BuildTransactionEssence(state.L1CommitmentNil, false) | |
| tx := transaction.MakeAnchorTransaction(essence, &iotago.Ed25519Signature{}) | |
| if tx.Size() > parameters.L1().MaxPayloadSize { | |
| return vmexceptions.ErrMaxTransactionSizeExceeded | |
| } | |
| return nil | |
| } |
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 reformed the way to check the tx size. I build the tx every time the check func is called
8469790 to
e0b46d2
Compare
In
ProtocolConfigthere are two more const will affect us. They areThe problem is we can't know how many object we have written (mutated, created, unwrapped) during execution, because we dont know the size of AssetBag.
And the
max_serialized_tx_effects_size_bytesregulates the size of Move execution result, which is impossible for us to get too.