Skip to content

Commit

Permalink
[agg_v2] Adding aggregator_v2.move with sequential (fallback) logic (#…
Browse files Browse the repository at this point in the history
…10397)

* [agg_v2] Adding aggregator_v2.move and fallback logic

Self-contained logic that can be landed on main, and so ecosystem PRs can land
independently of the rest of the aggregator changes

Copied from aggregators_v2 branch

Fixing tests and more comments

gas fixes and limit to string length

* addressing comments/updates

* fix lint

---------
  • Loading branch information
igor-aptos authored Oct 19, 2023
1 parent 7805954 commit 7ba0e69
Show file tree
Hide file tree
Showing 9 changed files with 1,338 additions and 233 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,17 @@ crate::gas_schedule::macros::define_gas_parameters!(
[aggregator_destroy_base: InternalGas, "aggregator.destroy.base", 10000],
[aggregator_factory_new_aggregator_base: InternalGas, "aggregator_factory.new_aggregator.base", 10000],

[aggregator_v2_create_aggregator_base: InternalGas, {12.. => "aggregator_v2.create_aggregator.base"}, 10000],
[aggregator_v2_try_add_base: InternalGas, {12.. => "aggregator_v2.try_add.base"}, 6000],
[aggregator_v2_try_sub_base: InternalGas, {12.. => "aggregator_v2.try_sub.base"}, 6000],
[aggregator_v2_read_base: InternalGas, {12.. => "aggregator_v2.read.base"}, 12000],
[aggregator_v2_snapshot_base: InternalGas, {12.. => "aggregator_v2.snapshot.base"}, 6000],

[aggregator_v2_create_snapshot_base: InternalGas, {11.. => "aggregator_v2.create_snapshot.base"}, 6000],
[aggregator_v2_copy_snapshot_base: InternalGas, {11.. => "aggregator_v2.copy_snapshot.base"}, 6000],
[aggregator_v2_read_snapshot_base: InternalGas, {11.. => "aggregator_v2.read_snapshot.base"}, 6000],
[aggregator_v2_read_snapshot_base: InternalGas, {11.. => "aggregator_v2.read_snapshot.base"}, 12000],
[aggregator_v2_string_concat_base: InternalGas, {11.. => "aggregator_v2.string_concat.base"}, 6000],
[aggregator_v2_string_concat_per_byte: InternalGasPerByte, { 12.. =>"aggregator_v2.string_concat.per_byte" }, 20],

[object_exists_at_base: InternalGas, { 7.. => "object.exists_at.base" }, 5000],
// These are dummy value, they copied from storage gas in aptos-core/aptos-vm/src/aptos_vm_impl.rs
Expand Down
11 changes: 7 additions & 4 deletions aptos-move/e2e-move-tests/src/tests/aggregator_v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@ use crate::{
initialize, verify_copy_snapshot, verify_copy_string_snapshot, verify_string_concat,
verify_string_snapshot_concat,
},
assert_success,
assert_abort, assert_success,
tests::common,
MoveHarness,
};
use aptos_framework::natives::aggregator_natives::aggregator_v2::{
EAGGREGATOR_FUNCTION_NOT_YET_SUPPORTED, EUNSUPPORTED_AGGREGATOR_SNAPSHOT_TYPE,
};
use aptos_language_e2e_tests::account::Account;

fn setup() -> (MoveHarness, Account) {
Expand All @@ -20,14 +23,14 @@ fn setup() -> (MoveHarness, Account) {
fn test_copy_snapshot() {
let (mut h, acc) = setup();
let txn = verify_copy_snapshot(&mut h, &acc);
assert_success!(h.run(txn));
assert_abort!(h.run(txn), EAGGREGATOR_FUNCTION_NOT_YET_SUPPORTED);
}

#[test]
fn test_copy_string_snapshot() {
let (mut h, acc) = setup();
let txn = verify_copy_string_snapshot(&mut h, &acc);
assert_success!(h.run(txn));
assert_abort!(h.run(txn), EAGGREGATOR_FUNCTION_NOT_YET_SUPPORTED);
}

#[test]
Expand All @@ -41,5 +44,5 @@ fn test_string_concat() {
fn test_string_snapshot_concat() {
let (mut h, acc) = setup();
let txn = verify_string_snapshot_concat(&mut h, &acc);
assert_success!(h.run(txn));
assert_abort!(h.run(txn), EUNSUPPORTED_AGGREGATOR_SNAPSHOT_TYPE);
}
Loading

0 comments on commit 7ba0e69

Please sign in to comment.