diff --git a/src/ballet/bn254/fd_poseidon.c b/src/ballet/bn254/fd_poseidon.c index 9f82a288a2..20043c6b69 100644 --- a/src/ballet/bn254/fd_poseidon.c +++ b/src/ballet/bn254/fd_poseidon.c @@ -98,7 +98,8 @@ fd_poseidon_append( fd_poseidon_t * pos, if( FD_UNLIKELY( pos->cnt >= FD_POSEIDON_MAX_WIDTH ) ) { return NULL; } - if( FD_UNLIKELY( sz>32UL ) ) { + /* Empty input and non-field are errors. Short element is extended with 0s. */ + if( FD_UNLIKELY( sz==0 || sz>32UL ) ) { return NULL; } diff --git a/src/ballet/bn254/test_poseidon.c b/src/ballet/bn254/test_poseidon.c index 11c05a609b..9e6c1f45d3 100644 --- a/src/ballet/bn254/test_poseidon.c +++ b/src/ballet/bn254/test_poseidon.c @@ -231,19 +231,6 @@ int main( int argc, fd_poseidon_fini( pos, res ); FD_TEST(memcmp(res, FLIST[12], FD_POSEIDON_HASH_SZ) == 0); - /* - fd_poseidon_hash(1) 9.530K/s/core 104927.617 ns/call - fd_poseidon_hash(2) 5.372K/s/core 186157.594 ns/call - fd_poseidon_hash(4) 2.213K/s/core 451814.312 ns/call - fd_poseidon_hash(6) 1.159K/s/core 862762.500 ns/call - fd_poseidon_hash(12) 0.349K/s/core 2869402.500 ns/call - - fd_poseidon_hash(1) 25.282K/s/core 39553.863 ns/call - fd_poseidon_hash(2) 15.764K/s/core 63437.676 ns/call - fd_poseidon_hash(4) 7.002K/s/core 142807.094 ns/call - fd_poseidon_hash(6) 3.658K/s/core 273403.594 ns/call - fd_poseidon_hash(12) 1.116K/s/core 896352.188 ns/call - */ /* benchmark */ char cstr[128]; ulong iter = 1000UL; diff --git a/src/flamenco/features/fd_features_generated.c b/src/flamenco/features/fd_features_generated.c index 636be87700..e810e0a9ed 100644 --- a/src/flamenco/features/fd_features_generated.c +++ b/src/flamenco/features/fd_features_generated.c @@ -1087,6 +1087,12 @@ fd_feature_id_t const ids[] = { /* 3opE3EzAKnUftUDURkzMgwpNgimBAypW1mNDYH4x4Zg7 */ .name = "reward_full_priority_fee" }, + { .index = offsetof(fd_features_t, simplify_alt_bn128_syscall_error_codes)>>3, + .id = {"\xff\xdc\x9f\x8d\x03\xe9\xa9\x8b\x11\x73\xd7\xf4\x57\x73\x30\xb9\x37\xc4\x25\xcd\xa9\xd8\xc1\x3e\xcc\xb7\x16\x4a\x1a\xfd\xf9\xec"}, + /* JDn5q3GBeqzvUa7z67BbmVHVdE3EbUAjvFep3weR3jxX */ + .name = "simplify_alt_bn128_syscall_error_codes", + .hardcoded = 1 }, + { .index = offsetof(fd_features_t, abort_on_invalid_curve)>>3, .id = {"\xdd\x72\x21\x65\xad\x48\xe1\xaf\xda\x46\x3f\x70\xf5\xe7\x27\xdf\x99\x16\x8f\xf9\xbb\xcb\x52\x76\xdb\x98\x53\x4e\x33\xf1\xf5\x86"}, /* FuS3FPfJDKSNot99ECLXtp3rueq36hMNStJkPJwWodLh */ @@ -1294,7 +1300,8 @@ fd_feature_id_query( ulong prefix ) { case 0xf711255aedfe2d0d: return &ids[ 190 ]; case 0x81f658d2653a6051: return &ids[ 191 ]; case 0xf1f206f6027db529: return &ids[ 192 ]; - case 0xafe148ad652172dd: return &ids[ 193 ]; + case 0x8ba9e9038d9fdcff: return &ids[ 193 ]; + case 0xafe148ad652172dd: return &ids[ 194 ]; default: break; } @@ -1496,6 +1503,7 @@ FD_STATIC_ASSERT( offsetof( fd_features_t, remove_rounding_in_fee_calculation FD_STATIC_ASSERT( offsetof( fd_features_t, enable_tower_sync_ix )>>3==190UL, layout ); FD_STATIC_ASSERT( offsetof( fd_features_t, deprecate_unused_legacy_vote_plumbing )>>3==191UL, layout ); FD_STATIC_ASSERT( offsetof( fd_features_t, reward_full_priority_fee )>>3==192UL, layout ); -FD_STATIC_ASSERT( offsetof( fd_features_t, abort_on_invalid_curve )>>3==193UL, layout ); +FD_STATIC_ASSERT( offsetof( fd_features_t, simplify_alt_bn128_syscall_error_codes )>>3==193UL, layout ); +FD_STATIC_ASSERT( offsetof( fd_features_t, abort_on_invalid_curve )>>3==194UL, layout ); FD_STATIC_ASSERT( sizeof( fd_features_t )>>3==FD_FEATURE_ID_CNT, layout ); diff --git a/src/flamenco/features/fd_features_generated.h b/src/flamenco/features/fd_features_generated.h index 62b7f3ad33..5b57765d8d 100644 --- a/src/flamenco/features/fd_features_generated.h +++ b/src/flamenco/features/fd_features_generated.h @@ -6,7 +6,7 @@ /* FEATURE_ID_CNT is the number of features in ids */ -#define FD_FEATURE_ID_CNT (194UL) +#define FD_FEATURE_ID_CNT (195UL) union fd_features { @@ -206,6 +206,7 @@ union fd_features { /* 0xf711255aedfe2d0d */ ulong enable_tower_sync_ix; /* 0x81f658d2653a6051 */ ulong deprecate_unused_legacy_vote_plumbing; /* 0xf1f206f6027db529 */ ulong reward_full_priority_fee; + /* 0x8ba9e9038d9fdcff */ ulong simplify_alt_bn128_syscall_error_codes; /* 0xafe148ad652172dd */ ulong abort_on_invalid_curve; }; diff --git a/src/flamenco/features/feature_map.json b/src/flamenco/features/feature_map.json index a50d268292..dd5d154063 100644 --- a/src/flamenco/features/feature_map.json +++ b/src/flamenco/features/feature_map.json @@ -192,5 +192,6 @@ {"name":"enable_tower_sync_ix","pubkey":"tSynMCspg4xFiCj1v3TDb4c7crMR5tSBhLz4sF7rrNA"}, {"name":"deprecate_unused_legacy_vote_plumbing","pubkey":"6Uf8S75PVh91MYgPQSHnjRAPQq6an5BDv9vomrCwDqLe"}, {"name":"reward_full_priority_fee","pubkey":"3opE3EzAKnUftUDURkzMgwpNgimBAypW1mNDYH4x4Zg7"}, + {"name":"simplify_alt_bn128_syscall_error_codes","pubkey": "JDn5q3GBeqzvUa7z67BbmVHVdE3EbUAjvFep3weR3jxX","hardcoded":1,"comment":"only impl the activated path"}, {"name":"abort_on_invalid_curve","pubkey":"FuS3FPfJDKSNot99ECLXtp3rueq36hMNStJkPJwWodLh"} ] diff --git a/src/flamenco/vm/syscall/fd_vm_syscall_crypto.c b/src/flamenco/vm/syscall/fd_vm_syscall_crypto.c index f5f3d22da6..032ad1f8e0 100644 --- a/src/flamenco/vm/syscall/fd_vm_syscall_crypto.c +++ b/src/flamenco/vm/syscall/fd_vm_syscall_crypto.c @@ -252,11 +252,12 @@ fd_vm_syscall_sol_poseidon( void * _vm, We must be careful in returning the correct fatal vs soft error. - The special case of vals_len==0 returns a soft_error, so for simplicity + The special case of vals_len==0 returns success, so for simplicity we capture it explicitly. */ if( FD_UNLIKELY( !vals_len ) ) { - goto soft_error; + ret = 0; + return FD_VM_SUCCESS; } /* First loop to memory map. This can return a fatal error. */