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
Transaction Validation #736
base: develop
Are you sure you want to change the base?
Conversation
…saction Scala's Short.MaxValue is equivalent to the maximum a 16 bit signed integer can hold
2183f20
to
d5206fc
Compare
678472f
to
a4e5a92
Compare
set_hook can only be called once, this means displaying an error multiple times causes a panic in sigma-rust. ignoring seems like the best solution
When converting a signed integer i8 like -1 (0xff) to a bigger signed integer like i64, the 2's complement representation will be padded with ff (0xffffffff...). Thus if input[7] for example is -1, when it is |'ed, all high bits will be set to 1. Converting u8 0xff to i64 0xff leads to correct conversion (0x000000...ff) This fixes validation for transactions like https://ergexplorer.com/transactions#7f838c5060185125cb554323401d87c0fc135a0c5fc545f9e315ffc38b97b06e
9f1d83e
to
8614bab
Compare
The current indexOf implementation doesn't match the behavior of the one in sigmastate-interpreter. The previous version wrongly treated the second argument as a fallback index whereas it is actually the position in the array to start searching from
Some mainnet transactions like 9f4d40607a561c14a504c96919362f150fca3337ab43219d9a683f1617b74b0a have proofs that are smaller than usual but still valid. Relevant sigmastate-interpreter commit ScorexFoundation/sigmastate-interpreter@ef6ff08
In v5.0 onwards flatMap can have any arbitrary lambda in body as long as it returns a Coll[T]
This brings down TransactionContext creation for transactions with 32767 inputs down from ~1.2 seconds to ~160 milliseconds
This reduces validation time for some transactions like 34fecabe033ca5b516ddaf99a251baf1a580db5be1ccd7ca41bfcd953bb1923f from 11 seconds down to ~1.2
6a556e1
to
7529e70
Compare
Dependencies and rust-analyzer are broken on older rust version. Also bump hashbrown due to ahash's nightly features breaking on older versions
Should be good to go now! Some notes:
|
@@ -24,15 +24,20 @@ pub(crate) static INDEX_OF_EVAL_FN: EvalFn = |_env, _ctx, obj, args| { | |||
.get(0) | |||
.cloned() | |||
.ok_or_else(|| EvalError::NotFound("indexOf: missing first arg".to_string()))?; | |||
let fallback_index = args |
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.
indexOf now has the same semantics as scala version, https://github.com/ScorexFoundation/sigmastate-interpreter/blob/efa68e7079393d70d25d43dd63dfba9a18d03415/data/shared/src/main/scala/sigma/ast/methods.scala#L880
/// When using sigma-rust where heights are always unsigned, this error may be because creation height was set to be >= 2147483648 | ||
NegativeHeight, | ||
#[error("Output box size {0} > maximum {}", ErgoBox::MAX_BOX_SIZE)] | ||
/// Box size is > [ErgoBox::MAX_SCRIPT_SIZE] |
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.
MAX_BOX_SIZE
Please fix linter issues |
Initial stateless validation work (things we can validate without needing blockchain context). Also includes a fix where we were allowing as many as u16::MAX inputs/outputs (65535) when ergo only allows i16::MAX (Short.MaxValue in scala) which is (32767). https://github.com/ergoplatform/ergo/blob/48239ef98ced06617dc21a0eee5670235e362933/ergo-core/src/main/scala/org/ergoplatform/modifiers/mempool/ErgoTransaction.scala#L93