-
Notifications
You must be signed in to change notification settings - Fork 1
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
Add fheLib precompile with first fheAdd method #160
Conversation
case 0xf953e427: | ||
bwCompatBytes := input[4:minInt(69, len(input))] | ||
// state of fheAdd struct is never needed or accessed so we use nil | ||
return (*fheAdd)(nil).Run(accessibleState, caller, addr, bwCompatBytes, readOnly) |
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.
Nice, I didn't know about this
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.
This is static dispatch so in theory should be faster
core/vm/contracts_test.go
Outdated
isScalarByte = 0 | ||
} | ||
ret = append(ret, isScalarByte) | ||
// padding |
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.
Would something like
padding = make([]byte, 31)
ret = append(ret, padding...)
be better?
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.
@tremblaythibaultl yeah, we could do that, I was just paranoid about extra allocation for padding array but I hope compiler is smart enough these days to detect this. I added this to dfc0040 commit, padding is allocated only once as static variable.
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.
lgtm 👍
Fhe library precompiled, only with one method now.
I reuse code of current precompiles and just pass subslice of the previous solidity abi call convention to the existing precompile so everything works.
@tremblaythibaultl @dartdart26