Skip to content

Conversation

@howjmay
Copy link
Member

@howjmay howjmay commented Jan 7, 2025

In ProtocolConfig there are two more const will affect us. They are

  • max_size_written_objects
  • max_serialized_tx_effects_size_bytes

The 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_bytes regulates the size of Move execution result, which is impossible for us to get too.

@howjmay howjmay force-pushed the check-tx-size branch 6 times, most recently from 4f0ba54 to a0f777a Compare January 15, 2025 15:57
@howjmay howjmay changed the base branch from develop to cons-recv-l1 January 15, 2025 15:58
@howjmay howjmay force-pushed the check-tx-size branch 6 times, most recently from e19853f to 1322639 Compare January 15, 2025 16:21
@lmoe lmoe added the backlog label Jan 17, 2025
@howjmay howjmay force-pushed the cons-recv-l1 branch 14 times, most recently from 07cf079 to 34f4a52 Compare January 28, 2025 13:16
@howjmay howjmay force-pushed the cons-recv-l1 branch 2 times, most recently from 6dd67e6 to d33550b Compare January 28, 2025 13:50
@howjmay howjmay force-pushed the check-tx-size branch 4 times, most recently from 1f8dfab to 850cb67 Compare January 31, 2025 16:37
@howjmay howjmay force-pushed the cons-recv-l1 branch 5 times, most recently from 6cb4c65 to 711eb24 Compare February 11, 2025 11:03
Base automatically changed from cons-recv-l1 to develop February 12, 2025 18:11
@howjmay howjmay force-pushed the check-tx-size branch 4 times, most recently from 6f3709c to 78838ec Compare February 21, 2025 23:21
@howjmay howjmay marked this pull request as ready for review February 21, 2025 23:23
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())
Copy link
Contributor

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.

vmctx.chainInfo = governance.NewStateReaderFromChainState(vmctx.stateDraft).GetChainInfo(vmctx.ChainID())
}

// checkTransactionSize panics with ErrMaxTransactionSizeExceeded if the estimated transaction size exceeds the limit
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// checkTransactionSize panics with ErrMaxTransactionSizeExceeded if the estimated transaction size exceeds the limit
// checkTransactionSize returns ErrMaxTransactionSizeExceeded if the estimated transaction size exceeds the limit

Comment on lines 484 to 486
const maxTxSizeBytes = 128 * 1024
const maxInputObjects = 2048
const maxProgrammableTxCommands = 1024
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These numbers are arbitrary?

Copy link
Member Author

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

Copy link
Member Author

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()
Copy link
Contributor

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:

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
}

Copy link
Member Author

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

@howjmay howjmay force-pushed the check-tx-size branch 2 times, most recently from 8469790 to e0b46d2 Compare March 13, 2025 19:43
@howjmay howjmay requested a review from dessaya March 13, 2025 20:01
@howjmay howjmay merged commit fd752e7 into develop Mar 13, 2025
2 of 5 checks passed
@howjmay howjmay deleted the check-tx-size branch March 13, 2025 22:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants