@@ -1676,20 +1676,17 @@ declare_syscall!(
1676
1676
memory_mapping: & mut MemoryMapping ,
1677
1677
) -> Result <u64 , EbpfError > {
1678
1678
use solana_sdk:: alt_bn128:: prelude:: { ALT_BN128_ADD , ALT_BN128_MUL , ALT_BN128_PAIRING } ;
1679
- type DynAltBnFunction = Box <dyn for <' r> Fn ( & ' r [ u8 ] ) -> Result <Vec <u8 >, AltBn128Error >>;
1680
1679
1681
1680
let budget = invoke_context. get_compute_budget( ) ;
1682
1681
1683
- let ( cost, output, calculation ) : ( u64 , usize , DynAltBnFunction ) = match group_op {
1682
+ let ( cost, output) : ( u64 , usize ) = match group_op {
1684
1683
ALT_BN128_ADD => (
1685
1684
budget. alt_bn128_addition_cost,
1686
1685
ALT_BN128_ADDITION_OUTPUT_LEN ,
1687
- Box :: new( alt_bn128_addition) ,
1688
1686
) ,
1689
1687
ALT_BN128_MUL => (
1690
1688
budget. alt_bn128_multiplication_cost,
1691
1689
ALT_BN128_MULTIPLICATION_OUTPUT_LEN ,
1692
- Box :: new( alt_bn128_multiplication) ,
1693
1690
) ,
1694
1691
ALT_BN128_PAIRING => {
1695
1692
let ele_len = input_size. saturating_div( ALT_BN128_PAIRING_ELEMENT_LEN as u64 ) ;
@@ -1703,16 +1700,13 @@ declare_syscall!(
1703
1700
. saturating_add( budget. sha256_base_cost)
1704
1701
. saturating_add( input_size)
1705
1702
. saturating_add( ALT_BN128_PAIRING_OUTPUT_LEN as u64 ) ;
1706
- (
1707
- cost,
1708
- ALT_BN128_PAIRING_OUTPUT_LEN ,
1709
- Box :: new( alt_bn128_pairing) ,
1710
- )
1703
+ ( cost, ALT_BN128_PAIRING_OUTPUT_LEN )
1711
1704
}
1712
1705
_ => {
1713
1706
return Err ( SyscallError :: InvalidAttribute . into( ) ) ;
1714
1707
}
1715
1708
} ;
1709
+
1716
1710
invoke_context. get_compute_meter( ) . consume( cost) ?;
1717
1711
1718
1712
let input = translate_slice:: <u8 >(
@@ -1731,7 +1725,16 @@ declare_syscall!(
1731
1725
invoke_context. get_check_size( ) ,
1732
1726
) ?;
1733
1727
1734
- let result_point = match ( * calculation) ( input) {
1728
+ let calculation = match group_op {
1729
+ ALT_BN128_ADD => alt_bn128_addition,
1730
+ ALT_BN128_MUL => alt_bn128_multiplication,
1731
+ ALT_BN128_PAIRING => alt_bn128_pairing,
1732
+ _ => {
1733
+ return Err ( SyscallError :: InvalidAttribute . into( ) ) ;
1734
+ }
1735
+ } ;
1736
+
1737
+ let result_point = match calculation( input) {
1735
1738
Ok ( result_point) => result_point,
1736
1739
Err ( e) => {
1737
1740
return Ok ( e. into( ) ) ;
0 commit comments