diff --git a/abi/RewardController.abi b/abi/RewardController.abi index 95e38bb..c750f47 100644 --- a/abi/RewardController.abi +++ b/abi/RewardController.abi @@ -1 +1 @@ -[{"name": "OracleUpdated", "inputs": [{"name": "updater", "type": "address", "indexed": false}, {"name": "chain_id", "type": "uint64", "indexed": false}, {"name": "new_value", "type": "uint256", "indexed": false}, {"name": "deviation", "type": "uint256", "indexed": false}, {"name": "time_since", "type": "uint256", "indexed": false}, {"name": "time_reward", "type": "uint256", "indexed": false}, {"name": "deviation_reward", "type": "uint256", "indexed": false}, {"name": "reward_mult", "type": "int256", "indexed": false}], "anonymous": false, "type": "event"}, {"stateMutability": "nonpayable", "type": "function", "name": "add_authority", "inputs": [{"name": "account", "type": "address"}], "outputs": []}, {"stateMutability": "nonpayable", "type": "function", "name": "remove_authority", "inputs": [{"name": "account", "type": "address"}], "outputs": []}, {"stateMutability": "nonpayable", "type": "function", "name": "set_scales", "inputs": [{"name": "scales", "type": "tuple[]", "components": [{"name": "chain_id", "type": "uint64"}, {"name": "scale", "type": "uint256"}]}], "outputs": []}, {"stateMutability": "nonpayable", "type": "function", "name": "set_scale", "inputs": [{"name": "chain_id", "type": "uint64"}, {"name": "scale", "type": "uint256"}], "outputs": []}, {"stateMutability": "nonpayable", "type": "function", "name": "modify_parameters_addr", "inputs": [{"name": "parameter", "type": "string"}, {"name": "addr", "type": "address"}], "outputs": []}, {"stateMutability": "nonpayable", "type": "function", "name": "modify_parameters_int", "inputs": [{"name": "parameter", "type": "string"}, {"name": "val", "type": "int256"}], "outputs": []}, {"stateMutability": "nonpayable", "type": "function", "name": "modify_parameters_control_output", "inputs": [{"name": "parameter", "type": "string"}, {"name": "val", "type": "int80"}], "outputs": []}, {"stateMutability": "nonpayable", "type": "function", "name": "modify_parameters_uint", "inputs": [{"name": "parameter", "type": "string"}, {"name": "val", "type": "uint256"}], "outputs": []}, {"stateMutability": "pure", "type": "function", "name": "test_decode_head", "inputs": [{"name": "dat", "type": "bytes"}], "outputs": [{"name": "", "type": "uint8"}, {"name": "", "type": "uint64"}, {"name": "", "type": "uint16"}, {"name": "", "type": "uint48"}, {"name": "", "type": "uint64"}]}, {"stateMutability": "pure", "type": "function", "name": "decode", "inputs": [{"name": "dat", "type": "bytes"}, {"name": "tip_typ", "type": "uint16"}], "outputs": [{"name": "", "type": "uint8"}, {"name": "", "type": "uint64"}, {"name": "", "type": "uint240"}, {"name": "", "type": "uint240"}, {"name": "", "type": "uint48"}, {"name": "", "type": "uint64"}]}, {"stateMutability": "view", "type": "function", "name": "bound_pi_output", "inputs": [{"name": "pi_output", "type": "int256"}], "outputs": [{"name": "", "type": "int256"}]}, {"stateMutability": "view", "type": "function", "name": "clamp_error_integral", "inputs": [{"name": "bounded_pi_output", "type": "int256"}, {"name": "error_integral", "type": "int256"}, {"name": "new_error_integral", "type": "int256"}, {"name": "new_area", "type": "int256"}], "outputs": [{"name": "", "type": "int256"}]}, {"stateMutability": "view", "type": "function", "name": "get_new_error_integral", "inputs": [{"name": "cid", "type": "uint64"}, {"name": "error", "type": "int256"}], "outputs": [{"name": "", "type": "int256"}, {"name": "", "type": "int256"}]}, {"stateMutability": "view", "type": "function", "name": "get_raw_pi_output", "inputs": [{"name": "error", "type": "int256"}, {"name": "errorI", "type": "int256"}], "outputs": [{"name": "", "type": "int256"}, {"name": "", "type": "int256"}, {"name": "", "type": "int256"}]}, {"stateMutability": "pure", "type": "function", "name": "error", "inputs": [{"name": "target", "type": "int256"}, {"name": "measured", "type": "int256"}], "outputs": [{"name": "", "type": "int256"}]}, {"stateMutability": "view", "type": "function", "name": "calc_deviation", "inputs": [{"name": "cid", "type": "uint64"}, {"name": "new_value", "type": "uint256"}, {"name": "current_value", "type": "uint256"}], "outputs": [{"name": "", "type": "uint256"}]}, {"stateMutability": "nonpayable", "type": "function", "name": "update_oracles", "inputs": [{"name": "dat_many", "type": "bytes"}, {"name": "n", "type": "uint256"}], "outputs": [{"name": "", "type": "tuple[64]", "components": [{"name": "time_reward", "type": "uint256"}, {"name": "deviation_reward", "type": "uint256"}]}]}, {"stateMutability": "nonpayable", "type": "function", "name": "update_oracle", "inputs": [{"name": "dat", "type": "bytes"}], "outputs": [{"name": "", "type": "uint256"}, {"name": "", "type": "uint256"}]}, {"stateMutability": "view", "type": "function", "name": "round_rewards", "inputs": [{"name": "time_reward", "type": "uint256"}, {"name": "deviation_reward", "type": "uint256"}], "outputs": [{"name": "", "type": "uint256"}, {"name": "", "type": "uint256"}]}, {"stateMutability": "view", "type": "function", "name": "calc_reward", "inputs": [{"name": "time_since", "type": "int256"}, {"name": "deviation", "type": "int256"}], "outputs": [{"name": "", "type": "int256"}, {"name": "", "type": "int256"}]}, {"stateMutability": "view", "type": "function", "name": "calc_time_reward", "inputs": [{"name": "time_since", "type": "int256"}], "outputs": [{"name": "", "type": "int256"}]}, {"stateMutability": "view", "type": "function", "name": "calc_deviation_reward", "inputs": [{"name": "time_since", "type": "int256"}], "outputs": [{"name": "", "type": "int256"}]}, {"stateMutability": "nonpayable", "type": "function", "name": "test_add_value", "inputs": [{"name": "chain_id", "type": "uint64"}, {"name": "new_value", "type": "uint256"}], "outputs": []}, {"stateMutability": "view", "type": "function", "name": "get_window_size", "inputs": [{"name": "chain_id", "type": "uint64"}], "outputs": [{"name": "", "type": "uint256"}]}, {"stateMutability": "nonpayable", "type": "function", "name": "add_value", "inputs": [{"name": "chain_id", "type": "uint64"}, {"name": "new_value", "type": "uint256"}, {"name": "count", "type": "uint256"}, {"name": "window_size", "type": "uint256"}], "outputs": []}, {"stateMutability": "view", "type": "function", "name": "get_average", "inputs": [{"name": "chain_id", "type": "uint64"}], "outputs": [{"name": "", "type": "uint256"}]}, {"stateMutability": "nonpayable", "type": "function", "name": "resize_buffer", "inputs": [{"name": "chain_id", "type": "uint64"}, {"name": "new_window_size", "type": "uint256"}], "outputs": []}, {"stateMutability": "nonpayable", "type": "function", "name": "test_update", "inputs": [{"name": "cid", "type": "uint64"}, {"name": "error", "type": "int256"}], "outputs": [{"name": "", "type": "int256"}, {"name": "", "type": "int256"}, {"name": "", "type": "int256"}]}, {"stateMutability": "view", "type": "function", "name": "get_new_pi_output", "inputs": [{"name": "cid", "type": "uint64"}, {"name": "error", "type": "int256"}], "outputs": [{"name": "", "type": "int256"}, {"name": "", "type": "int256"}, {"name": "", "type": "int256"}]}, {"stateMutability": "view", "type": "function", "name": "BASEFEE_REWARD_TYPE", "inputs": [], "outputs": [{"name": "", "type": "uint16"}]}, {"stateMutability": "view", "type": "function", "name": "MAX_PAYLOADS", "inputs": [], "outputs": [{"name": "", "type": "uint16"}]}, {"stateMutability": "view", "type": "function", "name": "authorities", "inputs": [{"name": "arg0", "type": "address"}], "outputs": [{"name": "", "type": "bool"}]}, {"stateMutability": "view", "type": "function", "name": "tip_reward_type", "inputs": [], "outputs": [{"name": "", "type": "uint16"}]}, {"stateMutability": "view", "type": "function", "name": "control_output", "inputs": [], "outputs": [{"name": "", "type": "tuple", "components": [{"name": "kp", "type": "int80"}, {"name": "ki", "type": "int80"}, {"name": "co_bias", "type": "int80"}]}]}, {"stateMutability": "view", "type": "function", "name": "output_upper_bound", "inputs": [], "outputs": [{"name": "", "type": "int256"}]}, {"stateMutability": "view", "type": "function", "name": "output_lower_bound", "inputs": [], "outputs": [{"name": "", "type": "int256"}]}, {"stateMutability": "view", "type": "function", "name": "target_time_since", "inputs": [], "outputs": [{"name": "", "type": "uint256"}]}, {"stateMutability": "view", "type": "function", "name": "min_reward", "inputs": [], "outputs": [{"name": "", "type": "uint256"}]}, {"stateMutability": "view", "type": "function", "name": "max_reward", "inputs": [], "outputs": [{"name": "", "type": "uint256"}]}, {"stateMutability": "view", "type": "function", "name": "min_time_reward", "inputs": [], "outputs": [{"name": "", "type": "int256"}]}, {"stateMutability": "view", "type": "function", "name": "max_time_reward", "inputs": [], "outputs": [{"name": "", "type": "int256"}]}, {"stateMutability": "view", "type": "function", "name": "min_deviation_reward", "inputs": [], "outputs": [{"name": "", "type": "int256"}]}, {"stateMutability": "view", "type": "function", "name": "max_deviation_reward", "inputs": [], "outputs": [{"name": "", "type": "int256"}]}, {"stateMutability": "view", "type": "function", "name": "default_window_size", "inputs": [], "outputs": [{"name": "", "type": "uint256"}]}, {"stateMutability": "view", "type": "function", "name": "oracle", "inputs": [], "outputs": [{"name": "", "type": "address"}]}, {"stateMutability": "view", "type": "function", "name": "error_integral", "inputs": [{"name": "arg0", "type": "uint64"}], "outputs": [{"name": "", "type": "int256"}]}, {"stateMutability": "view", "type": "function", "name": "last_output", "inputs": [{"name": "arg0", "type": "uint64"}], "outputs": [{"name": "", "type": "int256"}]}, {"stateMutability": "view", "type": "function", "name": "rewards", "inputs": [{"name": "arg0", "type": "address"}], "outputs": [{"name": "", "type": "uint256"}]}, {"stateMutability": "view", "type": "function", "name": "total_rewards", "inputs": [], "outputs": [{"name": "", "type": "uint256"}]}, {"stateMutability": "view", "type": "function", "name": "scales", "inputs": [{"name": "arg0", "type": "uint64"}], "outputs": [{"name": "", "type": "uint256"}]}, {"stateMutability": "view", "type": "function", "name": "coeff", "inputs": [], "outputs": [{"name": "", "type": "tuple", "components": [{"name": "zero", "type": "int96"}, {"name": "one", "type": "int96"}, {"name": "two", "type": "int96"}, {"name": "three", "type": "int96"}]}]}, {"stateMutability": "view", "type": "function", "name": "intercept", "inputs": [], "outputs": [{"name": "", "type": "int256"}]}, {"stateMutability": "nonpayable", "type": "constructor", "inputs": [{"name": "_kp", "type": "int80"}, {"name": "_ki", "type": "int80"}, {"name": "_co_bias", "type": "int80"}, {"name": "_output_upper_bound", "type": "int256"}, {"name": "_output_lower_bound", "type": "int256"}, {"name": "_target_time_since", "type": "uint256"}, {"name": "_tip_reward_type", "type": "uint16"}, {"name": "_min_reward", "type": "uint256"}, {"name": "_max_reward", "type": "uint256"}, {"name": "_default_window_size", "type": "uint256"}, {"name": "oracle", "type": "address"}, {"name": "_coeff", "type": "int96[4]"}], "outputs": []}] +[{"name": "OracleUpdated", "inputs": [{"name": "updater", "type": "address", "indexed": false}, {"name": "chain_id", "type": "uint64", "indexed": false}, {"name": "new_value", "type": "uint240", "indexed": false}, {"name": "deviation", "type": "uint256", "indexed": false}, {"name": "time_since", "type": "uint256", "indexed": false}, {"name": "time_reward", "type": "uint256", "indexed": false}, {"name": "deviation_reward", "type": "uint256", "indexed": false}, {"name": "reward_mult", "type": "int256", "indexed": false}], "anonymous": false, "type": "event"}, {"stateMutability": "nonpayable", "type": "function", "name": "add_authority", "inputs": [{"name": "account", "type": "address"}], "outputs": []}, {"stateMutability": "nonpayable", "type": "function", "name": "remove_authority", "inputs": [{"name": "account", "type": "address"}], "outputs": []}, {"stateMutability": "nonpayable", "type": "function", "name": "set_scales", "inputs": [{"name": "scales", "type": "tuple[]", "components": [{"name": "chain_id", "type": "uint64"}, {"name": "scale", "type": "uint256"}]}], "outputs": []}, {"stateMutability": "nonpayable", "type": "function", "name": "set_scale", "inputs": [{"name": "chain_id", "type": "uint64"}, {"name": "scale", "type": "uint256"}], "outputs": []}, {"stateMutability": "nonpayable", "type": "function", "name": "freeze", "inputs": [], "outputs": []}, {"stateMutability": "nonpayable", "type": "function", "name": "unfreeze", "inputs": [], "outputs": []}, {"stateMutability": "nonpayable", "type": "function", "name": "modify_parameters_addr", "inputs": [{"name": "parameter", "type": "string"}, {"name": "addr", "type": "address"}], "outputs": []}, {"stateMutability": "nonpayable", "type": "function", "name": "modify_parameters_int", "inputs": [{"name": "parameter", "type": "string"}, {"name": "val", "type": "int256"}], "outputs": []}, {"stateMutability": "nonpayable", "type": "function", "name": "modify_parameters_control_output", "inputs": [{"name": "parameter", "type": "string"}, {"name": "val", "type": "int80"}], "outputs": []}, {"stateMutability": "nonpayable", "type": "function", "name": "modify_parameters_uint", "inputs": [{"name": "parameter", "type": "string"}, {"name": "val", "type": "uint256"}], "outputs": []}, {"stateMutability": "pure", "type": "function", "name": "test_decode_head", "inputs": [{"name": "dat", "type": "bytes"}], "outputs": [{"name": "", "type": "uint8"}, {"name": "", "type": "uint64"}, {"name": "", "type": "uint16"}, {"name": "", "type": "uint48"}, {"name": "", "type": "uint64"}]}, {"stateMutability": "pure", "type": "function", "name": "decode", "inputs": [{"name": "dat", "type": "bytes"}, {"name": "tip_typ", "type": "uint16"}], "outputs": [{"name": "", "type": "uint8"}, {"name": "", "type": "uint64"}, {"name": "", "type": "uint240"}, {"name": "", "type": "uint240"}, {"name": "", "type": "uint48"}, {"name": "", "type": "uint64"}]}, {"stateMutability": "view", "type": "function", "name": "bound_pi_output", "inputs": [{"name": "pi_output", "type": "int256"}], "outputs": [{"name": "", "type": "int256"}]}, {"stateMutability": "view", "type": "function", "name": "clamp_error_integral", "inputs": [{"name": "bounded_pi_output", "type": "int256"}, {"name": "error_integral", "type": "int256"}, {"name": "new_error_integral", "type": "int256"}, {"name": "new_area", "type": "int256"}], "outputs": [{"name": "", "type": "int256"}]}, {"stateMutability": "view", "type": "function", "name": "get_new_error_integral", "inputs": [{"name": "cid", "type": "uint64"}, {"name": "error", "type": "int256"}], "outputs": [{"name": "", "type": "int256"}, {"name": "", "type": "int256"}]}, {"stateMutability": "view", "type": "function", "name": "get_raw_pi_output", "inputs": [{"name": "error", "type": "int256"}, {"name": "errorI", "type": "int256"}], "outputs": [{"name": "", "type": "int256"}, {"name": "", "type": "int256"}, {"name": "", "type": "int256"}]}, {"stateMutability": "pure", "type": "function", "name": "error", "inputs": [{"name": "target", "type": "int256"}, {"name": "measured", "type": "int256"}], "outputs": [{"name": "", "type": "int256"}]}, {"stateMutability": "view", "type": "function", "name": "calc_deviation", "inputs": [{"name": "cid", "type": "uint64"}, {"name": "new_value", "type": "uint256"}, {"name": "current_value", "type": "uint256"}], "outputs": [{"name": "", "type": "uint256"}]}, {"stateMutability": "view", "type": "function", "name": "get_updaters_chunk", "inputs": [{"name": "start", "type": "uint256"}, {"name": "count", "type": "uint256"}], "outputs": [{"name": "", "type": "address[256]"}, {"name": "", "type": "uint256[256]"}]}, {"stateMutability": "nonpayable", "type": "function", "name": "update_many", "inputs": [{"name": "dat", "type": "bytes"}], "outputs": [{"name": "", "type": "tuple[32]", "components": [{"name": "chain_id", "type": "uint64"}, {"name": "height", "type": "uint64"}, {"name": "gas_price", "type": "uint240"}, {"name": "time_reward", "type": "uint256"}, {"name": "deviation_reward", "type": "uint256"}]}]}, {"stateMutability": "view", "type": "function", "name": "calc_reward", "inputs": [{"name": "time_since", "type": "int256"}, {"name": "deviation", "type": "int256"}], "outputs": [{"name": "", "type": "int256"}, {"name": "", "type": "int256"}]}, {"stateMutability": "view", "type": "function", "name": "calc_time_reward", "inputs": [{"name": "time_since", "type": "int256"}], "outputs": [{"name": "", "type": "int256"}]}, {"stateMutability": "view", "type": "function", "name": "calc_deviation_reward", "inputs": [{"name": "time_since", "type": "int256"}], "outputs": [{"name": "", "type": "int256"}]}, {"stateMutability": "nonpayable", "type": "function", "name": "test_add_value", "inputs": [{"name": "chain_id", "type": "uint64"}, {"name": "new_value", "type": "uint256"}], "outputs": []}, {"stateMutability": "view", "type": "function", "name": "get_window_size", "inputs": [{"name": "chain_id", "type": "uint64"}], "outputs": [{"name": "", "type": "uint256"}]}, {"stateMutability": "view", "type": "function", "name": "get_average", "inputs": [{"name": "chain_id", "type": "uint64"}], "outputs": [{"name": "", "type": "uint256"}]}, {"stateMutability": "nonpayable", "type": "function", "name": "resize_buffer", "inputs": [{"name": "chain_id", "type": "uint64"}, {"name": "new_window_size", "type": "uint256"}], "outputs": []}, {"stateMutability": "nonpayable", "type": "function", "name": "test_update", "inputs": [{"name": "cid", "type": "uint64"}, {"name": "error", "type": "int256"}], "outputs": [{"name": "", "type": "int256"}, {"name": "", "type": "int256"}, {"name": "", "type": "int256"}]}, {"stateMutability": "view", "type": "function", "name": "get_new_pi_output", "inputs": [{"name": "cid", "type": "uint64"}, {"name": "error", "type": "int256"}], "outputs": [{"name": "", "type": "int256"}, {"name": "", "type": "int256"}, {"name": "", "type": "int256"}]}, {"stateMutability": "view", "type": "function", "name": "BASEFEE_REWARD_TYPE", "inputs": [], "outputs": [{"name": "", "type": "uint16"}]}, {"stateMutability": "view", "type": "function", "name": "MAX_PAYLOADS", "inputs": [], "outputs": [{"name": "", "type": "uint256"}]}, {"stateMutability": "view", "type": "function", "name": "MAX_UPDATERS", "inputs": [], "outputs": [{"name": "", "type": "uint32"}]}, {"stateMutability": "view", "type": "function", "name": "MAX_PAYLOAD_SIZE", "inputs": [], "outputs": [{"name": "", "type": "uint256"}]}, {"stateMutability": "view", "type": "function", "name": "authorities", "inputs": [{"name": "arg0", "type": "address"}], "outputs": [{"name": "", "type": "bool"}]}, {"stateMutability": "view", "type": "function", "name": "tip_reward_type", "inputs": [], "outputs": [{"name": "", "type": "uint16"}]}, {"stateMutability": "view", "type": "function", "name": "control_output", "inputs": [], "outputs": [{"name": "", "type": "tuple", "components": [{"name": "kp", "type": "int80"}, {"name": "ki", "type": "int80"}, {"name": "co_bias", "type": "int80"}]}]}, {"stateMutability": "view", "type": "function", "name": "output_upper_bound", "inputs": [], "outputs": [{"name": "", "type": "int256"}]}, {"stateMutability": "view", "type": "function", "name": "output_lower_bound", "inputs": [], "outputs": [{"name": "", "type": "int256"}]}, {"stateMutability": "view", "type": "function", "name": "target_time_since", "inputs": [], "outputs": [{"name": "", "type": "uint256"}]}, {"stateMutability": "view", "type": "function", "name": "min_reward", "inputs": [], "outputs": [{"name": "", "type": "uint256"}]}, {"stateMutability": "view", "type": "function", "name": "max_reward", "inputs": [], "outputs": [{"name": "", "type": "uint256"}]}, {"stateMutability": "view", "type": "function", "name": "min_time_reward", "inputs": [], "outputs": [{"name": "", "type": "int256"}]}, {"stateMutability": "view", "type": "function", "name": "max_time_reward", "inputs": [], "outputs": [{"name": "", "type": "int256"}]}, {"stateMutability": "view", "type": "function", "name": "min_deviation_reward", "inputs": [], "outputs": [{"name": "", "type": "int256"}]}, {"stateMutability": "view", "type": "function", "name": "max_deviation_reward", "inputs": [], "outputs": [{"name": "", "type": "int256"}]}, {"stateMutability": "view", "type": "function", "name": "default_window_size", "inputs": [], "outputs": [{"name": "", "type": "uint256"}]}, {"stateMutability": "view", "type": "function", "name": "has_updated", "inputs": [{"name": "arg0", "type": "address"}], "outputs": [{"name": "", "type": "bool"}]}, {"stateMutability": "view", "type": "function", "name": "updaters", "inputs": [{"name": "arg0", "type": "uint256"}], "outputs": [{"name": "", "type": "address"}]}, {"stateMutability": "view", "type": "function", "name": "n_updaters", "inputs": [], "outputs": [{"name": "", "type": "uint32"}]}, {"stateMutability": "view", "type": "function", "name": "frozen", "inputs": [], "outputs": [{"name": "", "type": "bool"}]}, {"stateMutability": "view", "type": "function", "name": "oracle", "inputs": [], "outputs": [{"name": "", "type": "address"}]}, {"stateMutability": "view", "type": "function", "name": "error_integral", "inputs": [{"name": "arg0", "type": "uint64"}], "outputs": [{"name": "", "type": "int256"}]}, {"stateMutability": "view", "type": "function", "name": "last_output", "inputs": [{"name": "arg0", "type": "uint64"}], "outputs": [{"name": "", "type": "int256"}]}, {"stateMutability": "view", "type": "function", "name": "rewards", "inputs": [{"name": "arg0", "type": "address"}], "outputs": [{"name": "", "type": "uint256"}]}, {"stateMutability": "view", "type": "function", "name": "total_rewards", "inputs": [], "outputs": [{"name": "", "type": "uint256"}]}, {"stateMutability": "view", "type": "function", "name": "scales", "inputs": [{"name": "arg0", "type": "uint64"}], "outputs": [{"name": "", "type": "uint256"}]}, {"stateMutability": "view", "type": "function", "name": "coeff", "inputs": [], "outputs": [{"name": "", "type": "tuple", "components": [{"name": "zero", "type": "int96"}, {"name": "one", "type": "int96"}, {"name": "two", "type": "int96"}, {"name": "three", "type": "int96"}]}]}, {"stateMutability": "view", "type": "function", "name": "intercept", "inputs": [], "outputs": [{"name": "", "type": "int256"}]}, {"stateMutability": "nonpayable", "type": "constructor", "inputs": [{"name": "_kp", "type": "int80"}, {"name": "_ki", "type": "int80"}, {"name": "_co_bias", "type": "int80"}, {"name": "_output_upper_bound", "type": "int256"}, {"name": "_output_lower_bound", "type": "int256"}, {"name": "_target_time_since", "type": "uint256"}, {"name": "_tip_reward_type", "type": "uint16"}, {"name": "_min_reward", "type": "uint256"}, {"name": "_max_reward", "type": "uint256"}, {"name": "_default_window_size", "type": "uint256"}, {"name": "oracle", "type": "address"}, {"name": "_coeff", "type": "int96[4]"}], "outputs": []}] diff --git a/contracts/RewardController.vy b/contracts/RewardController.vy index 01c2da9..275be2b 100644 --- a/contracts/RewardController.vy +++ b/contracts/RewardController.vy @@ -3,13 +3,13 @@ interface IOracle: def get(systemid: uint8, cid: uint64, typ: uint16) -> (uint256, uint64, uint48): view - #def storeValues(dat: DynArray[uint8, 256]): nonpayable def storeValues(dat: Bytes[16384]): nonpayable + def storeValuesWithReceipt(dat: Bytes[16384]) -> DynArray[RecordReceipt, MAX_PAYLOADS]: nonpayable event OracleUpdated: updater: address chain_id: uint64 - new_value: uint256 + new_value: uint240 deviation: uint256 time_since: uint256 time_reward: uint256 @@ -35,12 +35,19 @@ struct Reward: time_reward: uint256 deviation_reward: uint256 +struct EnhancedReward: + chain_id: uint64 + height: uint64 + gas_price: uint240 + time_reward: uint256 + deviation_reward: uint256 + struct TotalRewards: updater: address total_rewards: uint256 BASEFEE_REWARD_TYPE: public(constant(uint16)) = 107 -MAX_PAYLOADS: public(constant(uint16)) = 64 +MAX_PAYLOADS: public(constant(uint256)) = 32 MAX_UPDATERS: public(constant(uint32)) = 2**16 MAX_PAYLOAD_SIZE: public(constant(uint256)) = 16384 @@ -67,12 +74,8 @@ n_updaters: public(uint32) frozen: public(bool) oracle: public(IOracle) -#error_integral: public(int256) error_integral: public(HashMap[uint64, int256]) last_output: public(HashMap[uint64, int256]) -#last_p_output: public(HashMap[uint64, int256]) -#last_i_output: public(HashMap[uint64, int256]) -#last_update_time: public(HashMap[uint64, uint256]) rewards: public(HashMap[address, uint256]) total_rewards: public(uint256) @@ -83,7 +86,6 @@ index: HashMap[uint64, uint256] # Pointer to next insert position (0 to N-1) count: HashMap[uint64, uint256] # Number of elements inserted so far, up to N rolling_sum: HashMap[uint64, uint256] # Sum of last N values for efficient averaging -#coeff: public(int96[4]) coeff: public(Coefficients) intercept: public(int256) @@ -260,7 +262,6 @@ def _decode(dat: Bytes[MAX_PAYLOAD_SIZE], tip_typ: uint16) -> (uint8, uint64, ui return sid, cid, basefee_val, tip_val, ts, h - @internal @view def _riemann_sum(x: int256, y: int256)-> int256: @@ -397,130 +398,120 @@ def get_updaters_chunk(start: uint256, count: uint256) -> (address[256], uint256 return result_updaters, result_rewards -@external -def update_oracles(dat_many: Bytes[MAX_PAYLOAD_SIZE], n: uint256)-> Reward[MAX_PAYLOADS]: - return self._update_oracles(dat_many, n) - -@internal -def _update_oracles(dat_many: Bytes[MAX_PAYLOAD_SIZE], n: uint256)-> Reward[MAX_PAYLOADS]: - assert not self.frozen, "rewards contract is frozen" - self._add_updater(msg.sender) - offset: uint256 = 0 - plen: uint16 = 0 - - time_reward: uint256 = 0 - deviation_reward: uint256 = 0 - - rewards: Reward[MAX_PAYLOADS] = empty(Reward[MAX_PAYLOADS]) - - dat_p: Bytes[MAX_PAYLOAD_SIZE] = b"" - l: uint256 = len(dat_many) - - for i: uint256 in range(n, bound=16): - dat_p = slice(dat_many, offset, l-offset) - plen = self._decode_plen(dat_p) - if plen == 0: - assert i == n - 1, "plen is zero before n is reached" - break - - payload_size: uint256 = 32 + convert(plen, uint256)*32 + 65 - time_reward, deviation_reward = self._update_oracle(dat_p, payload_size) - #time_reward, deviation_reward = self._update_oracle(slice(dat_p, offset, offset + payload_size), payload_size) - rewards[i] = Reward(time_reward=time_reward, deviation_reward=deviation_reward) - - # add full payload size - offset += 32 + convert(plen, uint256)*32 + 65 - - return rewards +struct RecordReceipt: + systemid: uint8 + cid: uint64 + typ: uint16 + old_height: uint64 + old_timestamp: uint48 + old_value: uint240 + new_height: uint64 + new_timestamp: uint48 + new_value: uint240 @external -def update_oracle(dat: Bytes[MAX_PAYLOAD_SIZE])-> Reward: - assert not self.frozen, "rewards contract is frozen" - self._add_updater(msg.sender) - return self._update_oracles(dat, 1)[0] - -@internal -def copy_bytes_to_dynarray(src: Bytes[MAX_PAYLOAD_SIZE], start: uint256, length: uint256) -> DynArray[uint8, MAX_PAYLOAD_SIZE]: - assert start + length <= len(src), "out of bounds" - - result: DynArray[uint8, MAX_PAYLOAD_SIZE] = [] - for i: uint256 in range(length, bound=MAX_PAYLOAD_SIZE): - b: uint8 = convert(slice(src, start + i, 1), uint8) - result.append(b) - - return result - -@internal -def _update_oracle_stub(dat: Bytes[MAX_PAYLOAD_SIZE], l: uint256)-> (uint256, uint256): - tip_typ: uint16 = self.tip_reward_type - return 0, 0 - -@internal -def _update_oracle(dat: Bytes[MAX_PAYLOAD_SIZE], l: uint256)-> (uint256, uint256): - tip_typ: uint16 = self.tip_reward_type - sid: uint8 = 0 +def update_many(dat: Bytes[MAX_PAYLOAD_SIZE])-> EnhancedReward[MAX_PAYLOADS]: + receipts: DynArray[RecordReceipt, MAX_PAYLOADS] = extcall self.oracle.storeValuesWithReceipt(dat) + rewards: EnhancedReward[MAX_PAYLOADS] = empty(EnhancedReward[MAX_PAYLOADS]) cid: uint64 = 0 typ: uint16 = 0 - new_basefee_value: uint240 = 0 - new_tip_value: uint240 = 0 - new_ts: uint48 = 0 - new_height: uint64 = 0 - - # decode data and get new values - sid, cid, new_basefee_value, new_tip_value, new_ts, new_height = self._decode(dat, tip_typ) - - new_tip_value_u: uint256 = convert(new_tip_value, uint256) - new_basefee_value_u: uint256 = convert(new_basefee_value, uint256) - new_gasprice_value: uint256 = new_basefee_value_u + new_tip_value_u - - current_gasprice_value: uint256 = 0 - current_basefee_value: uint256 = 0 - current_tip_value: uint256 = 0 - current_height: uint64 = 0 - current_ts: uint48 = 0 - - # current oracle values - (current_basefee_value, current_height, current_ts) = staticcall self.oracle.get(sid, cid, BASEFEE_REWARD_TYPE) - (current_tip_value, current_height, current_ts) = staticcall self.oracle.get(sid, cid, tip_typ) - current_gasprice_value = current_basefee_value + current_tip_value - - if not (new_height > current_height or (new_height == current_height and new_ts > current_ts)): - return 0, 0 - - # calculate deviation and staleness(time_since) for new values - deviation: uint256 = self._calc_deviation(cid, new_gasprice_value, current_gasprice_value) - time_since: uint256 = convert(new_ts - current_ts, uint256) * EIGHTEEN_DECIMAL_NUMBER_U - - # calculate reward + rec: RecordReceipt = empty(RecordReceipt) + old_tip_val: uint240 = 0 + old_bf_val: uint240 = 0 + new_tip_val: uint240 = 0 + new_bf_val: uint240 = 0 + + bf_found: bool = False + tip_found: bool = False + + current_gasprice: uint240 = 0 + new_gasprice: uint240 = 0 + deviation: uint256 = 0 + time_since: uint256 = 0 time_reward: int256 = 0 deviation_reward: int256 = 0 - time_reward, deviation_reward = self._calc_reward(convert(time_since, int256)//1000, convert(deviation, int256)) - - # calculate reward multiplier - reward_mult: int256 = self._calc_reward_mult(cid, time_since//1000) - - # adjust rewards with multiplier - time_reward_adj: int256 = reward_mult * time_reward // EIGHTEEN_DECIMAL_NUMBER - deviation_reward_adj: int256 = reward_mult * deviation_reward // EIGHTEEN_DECIMAL_NUMBER - - time_reward_adj_u: uint256 = convert(time_reward_adj, uint256) - deviation_reward_adj_u: uint256 = convert(deviation_reward_adj, uint256) - - # store rewards - self.rewards[msg.sender] += time_reward_adj_u + deviation_reward_adj_u - self.total_rewards += time_reward_adj_u + deviation_reward_adj_u - - log OracleUpdated(updater=msg.sender, chain_id=cid, new_value=new_gasprice_value, - deviation=deviation, time_since=time_since, - time_reward=time_reward_adj_u, deviation_reward=deviation_reward_adj_u, - reward_mult=reward_mult) + reward_mult: int256 = 0 + time_reward_adj: int256 = 0 + deviation_reward_adj: int256 = 0 + time_reward_adj_u: uint256 = 0 + deviation_reward_adj_u: uint256 = 0 + + # self.tip_reward_type + # BASEFEE_REWARD_TYPE + idx: uint256 = 0 + for i: uint256 in range(len(receipts), bound=MAX_PAYLOADS): + rec = receipts[i] + + if rec.typ == self.tip_reward_type: + old_tip_val = rec.old_value + new_tip_val = rec.new_value + tip_found = True + elif rec.typ == BASEFEE_REWARD_TYPE: + old_bf_val = rec.old_value + new_bf_val = rec.new_value + bf_found = True + + # tip and bf found for this cid, time to process + if not (tip_found and bf_found): + continue + + # reset these + tip_found = False + bf_found = False + + current_gasprice = old_tip_val + old_bf_val + + # no update + if rec.old_timestamp == rec.new_timestamp: + rewards[idx] = EnhancedReward(chain_id=rec.cid, + height=rec.old_height, + gas_price=current_gasprice, + time_reward=0, + deviation_reward=0) + continue + + new_gasprice = new_tip_val + new_bf_val + + # calculate deviation and staleness(time_since) for new values + deviation = self._calc_deviation(rec.cid, convert(new_gasprice, uint256), convert(current_gasprice, uint256)) + + time_since = convert(rec.new_timestamp - rec.old_timestamp, uint256) * EIGHTEEN_DECIMAL_NUMBER_U + + # calculate reward + time_reward, deviation_reward = self._calc_reward(convert(time_since, int256)//1000, convert(deviation, int256)) + + # calculate reward multiplier + reward_mult = self._calc_reward_mult(rec.cid, time_since//1000) + + # adjust rewards with multiplier + time_reward_adj = reward_mult * time_reward // EIGHTEEN_DECIMAL_NUMBER + deviation_reward_adj = reward_mult * deviation_reward // EIGHTEEN_DECIMAL_NUMBER + + time_reward_adj_u = convert(time_reward_adj, uint256) + deviation_reward_adj_u = convert(deviation_reward_adj, uint256) + + # store rewards + self.rewards[msg.sender] += time_reward_adj_u + deviation_reward_adj_u + self.total_rewards += time_reward_adj_u + deviation_reward_adj_u + + log OracleUpdated(updater=msg.sender, chain_id=rec.cid, new_value=new_gasprice, + deviation=deviation, time_since=time_since, + time_reward=time_reward_adj_u, deviation_reward=deviation_reward_adj_u, + reward_mult=reward_mult) + + rewards[idx] = EnhancedReward(chain_id=rec.cid, + height=rec.old_height, + gas_price=current_gasprice, + time_reward=time_reward_adj_u, + deviation_reward=deviation_reward_adj_u) + idx += 1 - # send new values to oracle - #extcall self.oracle.storeValues(dat) - extcall self.oracle.storeValues(slice(dat, 0, l)) - #extcall self.oracle.storeValues(self.copy_bytes_to_dynarray(dat, 0, l)) + return rewards - return time_reward_adj_u, deviation_reward_adj_u +@internal +def _update_oracle_stub(dat: Bytes[MAX_PAYLOAD_SIZE], l: uint256)-> (uint256, uint256): + tip_typ: uint16 = self.tip_reward_type + return 0, 0 @external @view @@ -575,10 +566,6 @@ def _get_window_size(chain_id: uint64) -> uint256: return self.default_window_size return value -#@external -#def add_value(chain_id: uint64, new_value: uint256, count: uint256, window_size: uint256): -# self._add_value(chain_id, new_value, count, window_size) - @internal def _add_value(chain_id: uint64, new_value: uint256, count: uint256, window_size: uint256): #Add a new value to the circular buffer and update rolling sum. @@ -666,22 +653,12 @@ def _update(cid: uint64, error: int256) -> (int256, int256, int256): bounded_pi_output: int256 = self._bound_pi_output(pi_output) - #self.error_integral[cid] = self._clamp_error_integral(cid, bounded_pi_output, new_error_integral, new_area) self.error_integral[cid] = self._clamp_error_integral(bounded_pi_output, error_integral, new_error_integral, error) - # could maybe remove these to save gas - #self.last_update_time[cid] = block.timestamp self.last_output[cid] = bounded_pi_output - #self.last_p_output[cid] = p_output - #self.last_i_output[cid] = i_output return (bounded_pi_output, p_output, i_output) -#@external -#@view -#def last_update(cid: uint64) -> (uint256, int256, int256, int256): -# return (self.last_update_time[cid], self.last_output[cid], self.last_p_output[cid], self.last_i_output[cid]) - @external @view def get_new_pi_output(cid: uint64, error: int256) -> (int256, int256, int256): @@ -702,8 +679,3 @@ def _get_new_pi_output(cid: uint64, error: int256) -> (int256, int256, int256): bounded_pi_output: int256 = self._bound_pi_output(pi_output) return (bounded_pi_output, p_output, i_output) - -#@external -#@view -#def elapsed(cid: uint64) -> uint256: -# return block.timestamp - self.last_update_time[cid] diff --git a/scripts/oracles.py b/scripts/oracles.py index a406792..4d84447 100644 --- a/scripts/oracles.py +++ b/scripts/oracles.py @@ -1,3 +1,3 @@ # Blocknative Gas Oracles on each chain -oracle_addresses = {11155111: '0xCc936bE977BeDb5140C5584d8B6043C9068622A6'} +oracle_addresses = {11155111: '0x954d74dD0383084fDdD79B860bE0Ec2eC3f01129'} diff --git a/scripts/set_scales.py b/scripts/set_scales.py index 503cfbc..3dbf552 100644 --- a/scripts/set_scales.py +++ b/scripts/set_scales.py @@ -13,7 +13,7 @@ from scripts import params from scripts.oracles import oracle_addresses -REWARDS = '0x812cb53503f7232574cb6900ccbd58dd551f3300' +REWARDS = '0xd1aC001f243E61682167D1177fAd4182C956E493' controller = project.RewardController.at(REWARDS) def set_scales(account, controller, params): diff --git a/scripts/update_multi.py b/scripts/update_multi.py index 0fe5cf4..0f4e683 100644 --- a/scripts/update_multi.py +++ b/scripts/update_multi.py @@ -14,11 +14,9 @@ from scripts.oracles import oracle_addresses SEPOLIA_ORACLE = oracle_addresses[11155111]#'0xCc936bE977BeDb5140C5584d8B6043C9068622A6' -REWARDS = '0x812cb53503f7232574cb6900ccbd58dd551f3300' +REWARDS = '0xd1aC001f243E61682167D1177fAd4182C956E493' controller = project.RewardController.at(REWARDS) -oracle_sepolia = Contract(SEPOLIA_ORACLE, abi=gas_oracle_v2_abi) - # Gasnet w3 = Web3(HTTPProvider('https://rpc.gas.network')) address = '0x4245Cb7c690B650a38E680C9BcfB7814D42BfD32' @@ -41,14 +39,15 @@ # read gasnet dat_1: bytes = oracle_gasnet.functions.getValues(sid, cid_1).call() dat_2: bytes = oracle_gasnet.functions.getValues(sid, cid_2).call() -dat = dat_1 + dat_2 +d = b'0000000000000000000000000000000' +dat = dat_1 + d + dat_2 -rewards = controller.update_oracles.call(dat, 2) +rewards = controller.update_many.call(dat) print("pending rewards") print(rewards) # update oracle w/ gasnet payload -tx = controller.update_oracles(dat, 2, sender=account, raise_on_revert=True, gas=3000000) +tx = controller.update_many(dat, sender=account, raise_on_revert=True, gas=3000000) tx.show_trace(True) print(tx.events) diff --git a/tests/abis.py b/tests/abis.py index cc2655b..16f9e2b 100644 --- a/tests/abis.py +++ b/tests/abis.py @@ -1 +1,2 @@ gas_oracle_v2_abi = '[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"uint8","name":"systemid","type":"uint8"},{"internalType":"uint64","name":"cid","type":"uint64"},{"internalType":"uint16","name":"typ","type":"uint16"}],"name":"get","outputs":[{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint64","name":"height","type":"uint64"},{"internalType":"uint48","name":"timestamp","type":"uint48"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint8","name":"systemid","type":"uint8"},{"internalType":"uint64","name":"cid","type":"uint64"},{"internalType":"uint16","name":"typ","type":"uint16"},{"internalType":"uint48","name":"tin","type":"uint48"}],"name":"getInTime","outputs":[{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint64","name":"height","type":"uint64"},{"internalType":"uint48","name":"timestamp","type":"uint48"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint8","name":"systemid","type":"uint8"},{"internalType":"uint64","name":"cid","type":"uint64"},{"internalType":"uint16","name":"typ","type":"uint16"}],"name":"getRecord","outputs":[{"components":[{"internalType":"uint64","name":"height","type":"uint64"},{"internalType":"uint48","name":"timestamp","type":"uint48"},{"internalType":"uint240","name":"value","type":"uint240"}],"internalType":"struct Oracle.Record","name":"r","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint8","name":"systemid","type":"uint8"},{"internalType":"uint64","name":"cid","type":"uint64"},{"internalType":"uint16","name":"typ","type":"uint16"}],"name":"getValue","outputs":[{"internalType":"uint256","name":"value","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"s","type":"address"}],"name":"setSignerAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes","name":"dat","type":"bytes"}],"name":"storeValues","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"o","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}]' +gas_oracle_v3_abi = '[{"type":"constructor","inputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"get","inputs":[{"name":"systemid","type":"uint8","internalType":"uint8"},{"name":"cid","type":"uint64","internalType":"uint64"},{"name":"typ","type":"uint16","internalType":"uint16"}],"outputs":[{"name":"value","type":"uint256","internalType":"uint256"},{"name":"height","type":"uint64","internalType":"uint64"},{"name":"timestamp","type":"uint48","internalType":"uint48"}],"stateMutability":"view"},{"type":"function","name":"getInTime","inputs":[{"name":"systemid","type":"uint8","internalType":"uint8"},{"name":"cid","type":"uint64","internalType":"uint64"},{"name":"typ","type":"uint16","internalType":"uint16"},{"name":"tin","type":"uint48","internalType":"uint48"}],"outputs":[{"name":"value","type":"uint256","internalType":"uint256"},{"name":"height","type":"uint64","internalType":"uint64"},{"name":"timestamp","type":"uint48","internalType":"uint48"}],"stateMutability":"view"},{"type":"function","name":"getRecord","inputs":[{"name":"systemid","type":"uint8","internalType":"uint8"},{"name":"cid","type":"uint64","internalType":"uint64"},{"name":"typ","type":"uint16","internalType":"uint16"}],"outputs":[{"name":"r","type":"tuple","internalType":"struct Oracle.Record","components":[{"name":"height","type":"uint64","internalType":"uint64"},{"name":"timestamp","type":"uint48","internalType":"uint48"},{"name":"value","type":"uint240","internalType":"uint240"}]}],"stateMutability":"view"},{"type":"function","name":"getRecords","inputs":[{"name":"keys","type":"uint88[]","internalType":"uint88[]"}],"outputs":[{"name":"records","type":"tuple[]","internalType":"struct Oracle.Record[]","components":[{"name":"height","type":"uint64","internalType":"uint64"},{"name":"timestamp","type":"uint48","internalType":"uint48"},{"name":"value","type":"uint240","internalType":"uint240"}]}],"stateMutability":"view"},{"type":"function","name":"getRecords","inputs":[{"name":"keys","type":"tuple[]","internalType":"struct Oracle.RecordKey[]","components":[{"name":"systemid","type":"uint8","internalType":"uint8"},{"name":"cid","type":"uint64","internalType":"uint64"},{"name":"typ","type":"uint16","internalType":"uint16"}]}],"outputs":[{"name":"records","type":"tuple[]","internalType":"struct Oracle.Record[]","components":[{"name":"height","type":"uint64","internalType":"uint64"},{"name":"timestamp","type":"uint48","internalType":"uint48"},{"name":"value","type":"uint240","internalType":"uint240"}]}],"stateMutability":"view"},{"type":"function","name":"getValue","inputs":[{"name":"systemid","type":"uint8","internalType":"uint8"},{"name":"cid","type":"uint64","internalType":"uint64"},{"name":"typ","type":"uint16","internalType":"uint16"}],"outputs":[{"name":"value","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"ownerSetValues","inputs":[{"name":"systemid","type":"uint8","internalType":"uint8"},{"name":"cid","type":"uint64","internalType":"uint64"},{"name":"typ","type":"uint16","internalType":"uint16"},{"name":"timestamp","type":"uint48","internalType":"uint48"},{"name":"height","type":"uint64","internalType":"uint64"},{"name":"value","type":"uint240","internalType":"uint240"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"setSignerAddress","inputs":[{"name":"s","type":"address","internalType":"address"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"setSignerAddress","inputs":[{"name":"s","type":"address","internalType":"address"},{"name":"access","type":"bool","internalType":"bool"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"storeValues","inputs":[{"name":"dat","type":"bytes","internalType":"bytes"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"storeValuesWithReceipt","inputs":[{"name":"dat","type":"bytes","internalType":"bytes"}],"outputs":[{"name":"receipts","type":"tuple[]","internalType":"struct Oracle.RecordReceipt[]","components":[{"name":"record","type":"tuple","internalType":"struct Oracle.RecordKey","components":[{"name":"systemid","type":"uint8","internalType":"uint8"},{"name":"cid","type":"uint64","internalType":"uint64"},{"name":"typ","type":"uint16","internalType":"uint16"}]},{"name":"old_record","type":"tuple","internalType":"struct Oracle.Record","components":[{"name":"height","type":"uint64","internalType":"uint64"},{"name":"timestamp","type":"uint48","internalType":"uint48"},{"name":"value","type":"uint240","internalType":"uint240"}]},{"name":"new_record","type":"tuple","internalType":"struct Oracle.Record","components":[{"name":"height","type":"uint64","internalType":"uint64"},{"name":"timestamp","type":"uint48","internalType":"uint48"},{"name":"value","type":"uint240","internalType":"uint240"}]}]}],"stateMutability":"nonpayable"},{"type":"function","name":"transferOwnership","inputs":[{"name":"o","type":"address","internalType":"address"}],"outputs":[],"stateMutability":"nonpayable"}]' diff --git a/tests/addresses.py b/tests/addresses.py index 180cda5..4adbfdb 100644 --- a/tests/addresses.py +++ b/tests/addresses.py @@ -1,6 +1,7 @@ # Blocknative Gas Oracles on each chain #oracle_addresses = {11155111: '0xCc936bE977BeDb5140C5584d8B6043C9068622A6'} -oracle_addresses = {11155111: '0xca7bC053A0Df76DbcA0Ee01670f72ff7198ab49A'} +#oracle_addresses = {11155111: '0xca7bC053A0Df76DbcA0Ee01670f72ff7198ab49A'} +oracle_addresses = {11155111: '0x954d74dD0383084fDdD79B860bE0Ec2eC3f01129'} gasnet_contract = '0x4245Cb7c690B650a38E680C9BcfB7814D42BfD32' diff --git a/tests/fixture.py b/tests/fixture.py index 1a3ff2b..6233248 100644 --- a/tests/fixture.py +++ b/tests/fixture.py @@ -3,14 +3,13 @@ import params from addresses import oracle_addresses -from abis import gas_oracle_v2_abi +from abis import gas_oracle_v3_abi SEPOLIA_ORACLE = oracle_addresses[11155111] @pytest.fixture def oracle(owner, project): oracle = owner.deploy(project.oracle, sender=owner) - #oracle.set_value(1, 1000*10**18, 200, sender=owner) return oracle @pytest.fixture @@ -20,7 +19,7 @@ def store(owner, project): @pytest.fixture def oracle_sepolia(owner, project): - contract = Contract(SEPOLIA_ORACLE, abi=gas_oracle_v2_abi) + contract = Contract(SEPOLIA_ORACLE, abi=gas_oracle_v3_abi) return contract @pytest.fixture diff --git a/tests/test_fork.py b/tests/test_fork.py index 85499df..19e0138 100644 --- a/tests/test_fork.py +++ b/tests/test_fork.py @@ -124,7 +124,6 @@ def test_multi(self, owner, store, oracle_sepolia, controller_sepolia, chain): # update tx = controller_sepolia.update_oracles(payload_multi, 2, sender=owner, raise_on_revert=True) - #print(tx.show_trace(False)) events = list(tx.decode_logs()) e_1 = events[0] @@ -156,6 +155,58 @@ def test_multi(self, owner, store, oracle_sepolia, controller_sepolia, chain): # everything was a duplicate so no rewards assert len(events) == 0 + def test_multi_receipt(self, owner, store, oracle_sepolia, controller_sepolia, chain): + + w3 = Web3(HTTPProvider(GASNET_RPC)) + + with open('tests/gasnet_oracle_v2.json') as f: + abi = json.load(f)['abi'] + + oracle_gasnet = w3.eth.contract(address=GASNET_ORACLE, abi=abi) + + sid = 2 + cid_1 = 42161 + cid_2 = 10 + basefee_typ = 107 + tip_typ = 322 + + # read gasnet + payload_1: bytes = oracle_gasnet.functions.getValues(sid, cid_1).call() + payload_2: bytes = oracle_gasnet.functions.getValues(sid, cid_2).call() + b = b'0000000000000000000000000000000' + payload_multi = payload_1 + b + payload_2 + + tx = controller_sepolia.update_many(payload_multi, raise_on_revert=True, sender=owner) + tx.show_trace(True) + + events = list(tx.decode_logs()) + assert len(events) == 2 + assert events[0].chain_id == cid_1 + assert events[1].chain_id == cid_2 + + chain.mine(1, timestamp=chain.pending_timestamp+12) + + # get current oracle values + current_basefee_value_1, current_height_1, current_ts_1 = oracle_sepolia.get(sid, cid_1, basefee_typ) + current_tip_value_1, current_height_1, current_ts_1 = oracle_sepolia.get(sid, cid_1, tip_typ) + print(f"{current_basefee_value_1=}") + print(f"{current_tip_value_1=}") + print(f"{current_ts_1=}") + print(f"{current_height_1=}") + current_basefee_value_2, current_height_2, current_ts_2 = oracle_sepolia.get(sid, cid_2, basefee_typ) + current_tip_value_2, current_height_2, current_ts_2 = oracle_sepolia.get(sid, cid_2, tip_typ) + print(f"{current_basefee_value_2=}") + print(f"{current_tip_value_2=}") + print(f"{current_ts_2=}") + print(f"{current_height_2=}") + + # update w same payload + tx = controller_sepolia.update_many(payload_multi, sender=owner, raise_on_revert=True) + #print(tx.show_trace(False)) + + events = list(tx.decode_logs()) + assert len(events) == 0 + def test_ts(self, owner, store, oracle_sepolia, controller_sepolia, chain): w3 = Web3(HTTPProvider(GASNET_RPC))