The 256-bit maths host fns say in their docs that an error is returned, but from the guest perspective no error is returned rather a trap occurs.
|
{ |
|
"export": "n", |
|
"name": "u256_add", |
|
"args": [ |
|
{ |
|
"name": "lhs", |
|
"type": "U256Val" |
|
}, |
|
{ |
|
"name": "rhs", |
|
"type": "U256Val" |
|
} |
|
], |
|
"return": "U256Val", |
|
"docs": "Performs checked integer addition. Computes `lhs + rhs`, returning `ScError` if overflow occurred. " |
|
}, |
|
{ |
|
"export": "o", |
|
"name": "u256_sub", |
|
"args": [ |
|
{ |
|
"name": "lhs", |
|
"type": "U256Val" |
|
}, |
|
{ |
|
"name": "rhs", |
|
"type": "U256Val" |
|
} |
|
], |
|
"return": "U256Val", |
|
"docs": "Performs checked integer subtraction. Computes `lhs - rhs`, returning `ScError` if overflow occurred. " |
|
}, |
|
{ |
|
"export": "p", |
|
"name": "u256_mul", |
|
"args": [ |
|
{ |
|
"name": "lhs", |
|
"type": "U256Val" |
|
}, |
|
{ |
|
"name": "rhs", |
|
"type": "U256Val" |
|
} |
|
], |
|
"return": "U256Val", |
|
"docs": "Performs checked integer multiplication. Computes `lhs * rhs`, returning `ScError` if overflow occurred. " |
|
}, |
|
{ |
|
"export": "q", |
|
"name": "u256_div", |
|
"args": [ |
|
{ |
|
"name": "lhs", |
|
"type": "U256Val" |
|
}, |
|
{ |
|
"name": "rhs", |
|
"type": "U256Val" |
|
} |
|
], |
|
"return": "U256Val", |
|
"docs": "Performs checked integer division. Computes `lhs / rhs`, returning `ScError` if `rhs == 0` or overflow occurred. " |
|
}, |
|
{ |
|
"export": "r", |
|
"name": "u256_rem_euclid", |
|
"args": [ |
|
{ |
|
"name": "lhs", |
|
"type": "U256Val" |
|
}, |
|
{ |
|
"name": "rhs", |
|
"type": "U256Val" |
|
} |
|
], |
|
"return": "U256Val", |
|
"docs": "Performs checked Euclidean modulo. Computes `lhs % rhs`, returning `ScError` if `rhs == 0` or overflow occurred. " |
|
}, |
|
{ |
|
"export": "s", |
|
"name": "u256_pow", |
|
"args": [ |
|
{ |
|
"name": "lhs", |
|
"type": "U256Val" |
|
}, |
|
{ |
|
"name": "rhs", |
|
"type": "U32Val" |
|
} |
|
], |
|
"return": "U256Val", |
|
"docs": "Performs checked exponentiation. Computes `lhs.exp(rhs)`, returning `ScError` if overflow occurred. " |
|
}, |
|
{ |
|
"export": "t", |
|
"name": "u256_shl", |
|
"args": [ |
|
{ |
|
"name": "lhs", |
|
"type": "U256Val" |
|
}, |
|
{ |
|
"name": "rhs", |
|
"type": "U32Val" |
|
} |
|
], |
|
"return": "U256Val", |
|
"docs": "Performs checked shift left. Computes `lhs << rhs`, returning `ScError` if `rhs` is larger than or equal to the number of bits in `lhs`." |
|
}, |
|
{ |
|
"export": "u", |
|
"name": "u256_shr", |
|
"args": [ |
|
{ |
|
"name": "lhs", |
|
"type": "U256Val" |
|
}, |
|
{ |
|
"name": "rhs", |
|
"type": "U32Val" |
|
} |
|
], |
|
"return": "U256Val", |
|
"docs": "Performs checked shift right. Computes `lhs >> rhs`, returning `ScError` if `rhs` is larger than or equal to the number of bits in `lhs`." |
|
}, |
|
{ |
|
"export": "v", |
|
"name": "i256_add", |
|
"args": [ |
|
{ |
|
"name": "lhs", |
|
"type": "I256Val" |
|
}, |
|
{ |
|
"name": "rhs", |
|
"type": "I256Val" |
|
} |
|
], |
|
"return": "I256Val", |
|
"docs": "Performs checked integer addition. Computes `lhs + rhs`, returning `ScError` if overflow occurred. " |
|
}, |
|
{ |
|
"export": "w", |
|
"name": "i256_sub", |
|
"args": [ |
|
{ |
|
"name": "lhs", |
|
"type": "I256Val" |
|
}, |
|
{ |
|
"name": "rhs", |
|
"type": "I256Val" |
|
} |
|
], |
|
"return": "I256Val", |
|
"docs": "Performs checked integer subtraction. Computes `lhs - rhs`, returning `ScError` if overflow occurred. " |
|
}, |
|
{ |
|
"export": "x", |
|
"name": "i256_mul", |
|
"args": [ |
|
{ |
|
"name": "lhs", |
|
"type": "I256Val" |
|
}, |
|
{ |
|
"name": "rhs", |
|
"type": "I256Val" |
|
} |
|
], |
|
"return": "I256Val", |
|
"docs": "Performs checked integer multiplication. Computes `lhs * rhs`, returning `ScError` if overflow occurred. " |
|
}, |
|
{ |
|
"export": "y", |
|
"name": "i256_div", |
|
"args": [ |
|
{ |
|
"name": "lhs", |
|
"type": "I256Val" |
|
}, |
|
{ |
|
"name": "rhs", |
|
"type": "I256Val" |
|
} |
|
], |
|
"return": "I256Val", |
|
"docs": "Performs checked integer division. Computes `lhs / rhs`, returning `ScError` if `rhs == 0` or overflow occurred. " |
|
}, |
|
{ |
|
"export": "z", |
|
"name": "i256_rem_euclid", |
|
"args": [ |
|
{ |
|
"name": "lhs", |
|
"type": "I256Val" |
|
}, |
|
{ |
|
"name": "rhs", |
|
"type": "I256Val" |
|
} |
|
], |
|
"return": "I256Val", |
|
"docs": "Performs checked Euclidean modulo. Computes `lhs % rhs`, returning `ScError` if `rhs == 0` or overflow occurred. " |
|
}, |
|
{ |
|
"export": "A", |
|
"name": "i256_pow", |
|
"args": [ |
|
{ |
|
"name": "lhs", |
|
"type": "I256Val" |
|
}, |
|
{ |
|
"name": "rhs", |
|
"type": "U32Val" |
|
} |
|
], |
|
"return": "I256Val", |
|
"docs": "Performs checked exponentiation. Computes `lhs.exp(rhs)`, returning `ScError` if overflow occurred. " |
|
}, |
|
{ |
|
"export": "B", |
|
"name": "i256_shl", |
|
"args": [ |
|
{ |
|
"name": "lhs", |
|
"type": "I256Val" |
|
}, |
|
{ |
|
"name": "rhs", |
|
"type": "U32Val" |
|
} |
|
], |
|
"return": "I256Val", |
|
"docs": "Performs checked shift left. Computes `lhs << rhs`, returning `ScError` if `rhs` is larger than or equal to the number of bits in `lhs`." |
|
}, |
|
{ |
|
"export": "C", |
|
"name": "i256_shr", |
|
"args": [ |
|
{ |
|
"name": "lhs", |
|
"type": "I256Val" |
|
}, |
|
{ |
|
"name": "rhs", |
|
"type": "U32Val" |
|
} |
|
], |
|
"return": "I256Val", |
|
"docs": "Performs checked shift right. Computes `lhs >> rhs`, returning `ScError` if `rhs` is larger than or equal to the number of bits in `lhs`." |
Typically the env.json docs are written from the perspective of the guest, and fns that trap typically say Traps if ....
|
"docs": "Get the value for a key from a map. Traps if key is not found." |
We should update the docs to indicate the maths fns trap.
Originally posted by @leighmcculloch in #1659
The 256-bit maths host fns say in their docs that an error is returned, but from the guest perspective no error is returned rather a trap occurs.
rs-soroban-env/soroban-env-common/env.json
Lines 443 to 697 in 97546e0
Typically the env.json docs are written from the perspective of the guest, and fns that trap typically say
Traps if ....rs-soroban-env/soroban-env-common/env.json
Line 794 in 97546e0
We should update the docs to indicate the maths fns trap.
Originally posted by @leighmcculloch in #1659