Skip to content

Commit

Permalink
disable proxy access check by default
Browse files Browse the repository at this point in the history
  • Loading branch information
augustbleeds committed Oct 24, 2024
1 parent fd4d3c8 commit 91ff429
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 9 deletions.
2 changes: 1 addition & 1 deletion contracts/src/access_control/access_controller.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ mod AccessController {
#[constructor]
fn constructor(ref self: ContractState, owner_address: ContractAddress) {
self.ownable.initializer(owner_address);
self.access_control.initializer();
self.access_control.initializer(true);
}

#[abi(embed_v0)]
Expand Down
2 changes: 1 addition & 1 deletion contracts/src/emergency/sequencer_uptime_feed.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ mod SequencerUptimeFeed {
ref self: ContractState, initial_status: u128, owner_address: ContractAddress
) {
self.ownable.initializer(owner_address);
self.access_control.initializer();
self.access_control.initializer(true);
let round_id = 1_u128;
let timestamp = starknet::info::get_block_timestamp();
let from_address = EthAddress {
Expand Down
4 changes: 2 additions & 2 deletions contracts/src/libraries/access_control.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ mod AccessControlComponent {
impl Ownable: OwnableComponent::HasComponent<TContractState>,
+Drop<TContractState>,
> of InternalTrait<TContractState> {
fn initializer(ref self: ComponentState<TContractState>) {
self._check_enabled.write(true);
fn initializer(ref self: ComponentState<TContractState>, check_enabled: bool) {
self._check_enabled.write(check_enabled);
self.emit(Event::AccessControlEnabled(AccessControlEnabled {}));
}

Expand Down
2 changes: 1 addition & 1 deletion contracts/src/ocr2/aggregator.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ mod Aggregator {
description: felt252
) {
self.ownable.initializer(owner);
self.access_control.initializer();
self.access_control.initializer(true);
self._link_token.write(link);
self._billing_access_controller.write(billing_access_controller);

Expand Down
3 changes: 2 additions & 1 deletion contracts/src/ocr2/aggregator_proxy.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,8 @@ mod AggregatorProxy {
#[constructor]
fn constructor(ref self: ContractState, owner: ContractAddress, address: ContractAddress) {
self.ownable.initializer(owner);
self.access_control.initializer();
self.access_control.initializer(false);
self.access_control.disable_access_check();
self._set_aggregator(address);
}

Expand Down
10 changes: 7 additions & 3 deletions contracts/src/tests/test_aggregator_proxy.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ use chainlink::ocr2::aggregator_proxy::AggregatorProxy;
use chainlink::ocr2::aggregator_proxy::AggregatorProxy::{
AggregatorProxyImpl, AggregatorProxyInternal, UpgradeableImpl
};
use chainlink::libraries::access_control::AccessControlComponent::AccessControlImpl;
use chainlink::libraries::access_control::{
IAccessControllerDispatcher, IAccessControllerDispatcherTrait,
AccessControlComponent::AccessControlImpl
};
use chainlink::ocr2::aggregator::Round;
use chainlink::utils::split_felt;
use chainlink::tests::test_ownable::should_implement_ownable;
Expand Down Expand Up @@ -89,6 +92,9 @@ fn test_access_control() {

let (aggregatorProxyAddr, _) = declare("AggregatorProxy").unwrap().deploy(@calldata).unwrap();

// proxy by default disables the access check, so we re-enable for testing purposes
IAccessControllerDispatcher { contract_address: aggregatorProxyAddr }.enable_access_check();

should_implement_access_control(aggregatorProxyAddr, account);
}

Expand Down Expand Up @@ -124,7 +130,6 @@ fn test_query_latest_round_data() {
}

#[test]
#[should_panic(expected: ('user does not have read access',))]
fn test_query_latest_round_data_without_access() {
let (owner, mockAggregatorAddr, mockAggregator, _, _) = setup();
let mut state = STATE();
Expand All @@ -140,7 +145,6 @@ fn test_query_latest_round_data_without_access() {
}

#[test]
#[should_panic(expected: ('user does not have read access',))]
fn test_query_latest_answer_without_access() {
let (owner, mockAggregatorAddr, mockAggregator, _, _) = setup();
let mut state = STATE();
Expand Down

0 comments on commit 91ff429

Please sign in to comment.