Skip to main content

Other Restrictions

GetHashCode Usage

The GetHashCode method can only be called within other GetHashCode methods. Calling GetHashCode from other methods is not permitted. This restriction allows developers to implement custom GetHashCode methods for their own types and also supports protobuf-generated message types.

It is prohibited to modify any field within GetHashCode methods.

Execution Observer

aelf's contract patcher automatically includes a method call count observer for your contract. This feature prevents infinite method calls, such as recursion. During transaction execution, the observer counts the number of methods called. If this count exceeds 15,000, transaction execution pauses. Adjustments to this limit are managed by Parliament.

Additionally, aelf's contract patcher includes a method branch count observer for your contract. This prevents infinite loop scenarios by counting control transfers within your contract code during transaction execution. If the number of control transfers exceeds 15,000, transaction execution pauses. The control transfer opcodes in C# contracts are listed below.

OpcodeDescription
OpCodes.BeqBranch if equal
OpCodes.Beq_SBranch if equal (short form)
OpCodes.BgeBranch if greater than or equal
OpCodes.Bge_SBranch if greater than or equal (short form)
OpCodes.Bge_UnBranch if greater than or equal (unsigned)
OpCodes.Bge_Un_SBranch if greater than or equal (unsigned, short form)
OpCodes.BgtBranch if greater than
OpCodes.Bgt_SBranch if greater than (short form)
OpCodes.BleBranch if less than or equal
OpCodes.Ble_SBranch if less than or equal (short form)
OpCodes.Ble_UnBranch if less than or equal (unsigned)
OpCodes.BltBranch if less than
OpCodes.Bne_UnBranch if not equal (unsigned)
OpCodes.Bne_Un_SBranch if not equal (unsigned, short form)
OpCodes.BrBranch unconditional
OpCodes.BrfalseBranch if false
OpCodes.Brfalse_SBranch if false (short form)
OpCodes.BrtrueBranch if true
OpCodes.Brtrue_SBranch if true (short form)
OpCodes.Br_SBranch unconditional (short form)

State Size Limit

Data written to State is subject to a size limit enforced by aelf's contract patcher, set at 128 KB by default. This ensures contracts cannot store excessively large data. Any adjustments to this limit are decided by Parliament.