Skip to main content
PSUT / IoTEngineering learning studio
WORKSPACE
Offline-first portalDr. Mohammad Alja’afreh
Cyber Defense StudioIoT Security and PrivacyExperimentsWorkspaces
ENGINEERING WORKSPACE
Home/Engineering Workspaces/B10 · Advanced Solidity: roles and modifiers
IoTPSUT IoT Engineering StudioPrincess Sumaya University for Technology · Dr. Mohammad Alja’afreh
Blockchain for IoT · advanced laboratory
Blockchain for IoT

Advanced Solidity: roles and modifiers

Ask Dr. Mohammad · B10 →

Implement owner-only delegation, operator permissions and revocation with explicit custom errors.

Design experiment & verify evidence →
B10 · Laboratory mentorAsk about the current experiment, its algorithms or Python notebook.
Ask Dr. MohammadAdaptive practice
Learning workflow · Advanced blockchainB10 · Advanced Solidity: roles and modifiers

Related course access: IoT Security and Privacy — same laboratory, notebook and completion record.

B10 · Academic orientation

Scope and objectives

Scope of the experiment

Implement owner-only delegation, operator permissions and revocation with explicit custom errors.

The focus of this experiment is to trace role assignments and Solidity modifiers. Students then predict permitted and reverted state transitions, and verify least-privilege contract tests and explain admin trust. The Concepts view explains the operation before the practical work; the Simulation view is used to examine reference and changed inputs, not to substitute for actual measurements.

Learning objectives

  • Trace role assignments and Solidity modifiers.
  • Predict permitted and reverted state transitions.
  • Verify least-privilege contract tests and explain admin trust.
  • Identify the configured inputs (Caller; Action) and record the corresponding observed outputs with units where applicable.
  • Compare the reference calculation or decision with an independent implementation or authorized observation; state any discrepancy and the applicable model boundary.

Expected learning outcomes

On completion, students can trace role assignments and Solidity modifiers, predict permitted and reverted state transitions, and verify least-privilege contract tests and explain admin trust.

Required deliverables

Submit the derivation or state trace for the named operation, the exact reference and changed configurations, the associated simulator or practical evidence, and a short validation statement addressing verify least-privilege contract tests and explain admin trust. Separate predicted values from observations.

Prerequisite knowledge and related learning

Review the following catalogue prerequisites before starting. After completion, continue to Merkle batch commitments.

Environment and experimental methodology

The listed browser model and experiment-specific local Python, Solidity or EVM workflow, where provided. Do not treat a model as a deployed ledger.

Begin with a manual prediction, record the baseline, change one independent condition at a time, and compare the resulting trace or measurements with the original prediction. Record observations and uncertainty separately from reference values. Follow the experiment’s specific procedure, safety limits, and acceptance checks.

B10 · learning outcome

Understand the experiment

Scientific architecture · Advanced Solidity: roles and modifiers

Solidity modifiers and roles — Caller / msg.sender; Role mapping / owner, operator, viewer; Modifier / required permission?; Authorized / storage update; Unauthorized / revert, no write
Scientific concept map: Owner — Delegates operator; Operator — Device action; Viewer — Read-only identity; Modifier — Check actor role; State — Commit or custom error.

Scientific foundations and analytical reasoning

Modifiers enforce a predicate before function execution; roles can change over time. Revocation affects future calls, not past event history.

Before operating the equipment or executing the program, derive the expected outcome using the required theoretical work in Experiment. Use the diagram to identify the variables and system boundaries.

Scientific theory · Modifiers and state transitions

Solidity modifiers enforce conditions around function bodies; role checks should use authenticated caller context. A mapping associates keys with values and defaults to zero-initialized values for unset entries. Revoking a role changes future authorization, not previously emitted logs. Checked arithmetic in Solidity 0.8+ reverts on overflow unless explicitly unchecked.

Worked example and engineering interpretation

If address A has the required role and B does not, only A can invoke the protected write under that policy. After revocation, A's next call must be rejected. Compare state and receipt before and after both authorized and unauthorized calls in the local contract.

Engineering principles · additional worked teaching example

A role modifier checks authorization before executing protected state transitions. Ownership transfer and role grant/revoke are different operations; unauthorized calls must leave protected storage unchanged.

From theory to experiment

Predict the reference result before operating the workbench; check the actual intermediate state, units and constraints. The existing simulation, implementation and procedure below are distinct sources of evidence.

How to investigate Advanced Solidity: roles and modifiers

Implement owner-only delegation, operator permissions and revocation with explicit custom errors.

Analytical investigation means collecting an observation, identifying the mechanism, using a calculation or state trace to explain it, and checking your conclusion against evidence. Controlled comparison means changing one independent variable, holding the remaining relevant conditions constant, and measuring a dependent variable against a baseline. Experimental validation means comparing a predicted result to a reproducible observation or assertion; agreement inside a model does not certify hardware. Evidence-based reasoning connects a specific observation to a theoretical rule and states uncertainty, not merely an opinion. Performance characterization records a named metric and its units across conditions; sensitivity analysis changes one parameter across several values. A threat assessment links an asset, threat, consequence and evidence to a mitigation.

Experiment-specific guided practice

Objective: Implement owner-only delegation, operator permissions and revocation with explicit custom errors.

  1. Open RoleRegistry.sol in Remix, compile with 0.8.28, Shanghai, optimizer disabled; select Remix VM, account 0, VALUE 0, deploy RoleRegistry. Copy account 1 (operator), account 2 (device) and account 3 (viewer) addresses from the Remix account selector.
  2. As account 0, call setOperator(account 1, true), then setDevice(account 2, true). Expected: operators(account 1) and active(account 2) return true.
  3. Switch to account 1 and call setDevice(account 2, false). Expected: successful receipt, active(account 2)=false. Switch to account 3 and try setDevice(account 2, true). Expected: NotOwnerOrOperator revert, state remains false. A generic failure is inconclusive.
  4. As account 1, attempt setOperator(account 3,true). Expected NotOwner. As account 0, revoke account 1 with setOperator(account 1,false); switch back to account 1 and attempt setDevice(account 2,true). Expected NotOwnerOrOperator. Restore state as account 0. Record receipts and state.

Reference check: Owner call updates mapping and emits DeviceStatus; outsider call reverts and leaves state unchanged. Save the actual Remix transaction receipts separately.

Model boundary: Browser is a state-machine model, not a Solidity compiler or EVM. Solidity 0.8 uses checked arithmetic by default; do not use selfdestruct as a general upgrade mechanism.

Independent task and submission evidence

2. As account 0, call setOperator(account 1, true), then setDevice(account 2, true). Expected: operators(account 1) and active(account 2) return true. Record the named input, prediction, actual output and one limitation; restore the original condition and repeat.

Before execution write the independent variable and its levels, dependent observation with units where applicable, baseline, controlled variables, measurement method and expected result. For a state machine use state/event/output rather than inventing a numeric metric. Record failures and repeat the baseline. A weak conclusion is “it works”; a supported conclusion names the changed setting, observed value/state, corresponding rule and one limitation.

TrialChanged settingFixed settingsPredicted resultActual observation / unitsEvidence / uncertainty
A: baselineReferenceRecordPredictRecordRecord
B: one changeRecordSame as APredictRecordRecord
A: repeatRestoreSame as APredictRecordRecord

Completion: submit the filled table, relevant simulator screenshot or terminal/notebook output, reasoning with units/assumptions, and one limitation. Preserve the independent assessment questions; this guide does not fill their answers.

Implement owner-only delegation, operator permissions and revocation with explicit custom errors.

Browser model starts from a fresh policy state each time. It is not compiled Solidity, and actual revert selectors and receipts require Remix or local EVM.

Worked engineering reasoning and boundary conditions

Engineering reference configuration: Caller = operator; Action = set. In the classroom model, Decision = Accepted; Role = operator; State changed = Yes. Each scenario starts with a fresh state. Owner manages operators; owner or delegated operator manages device status. Rejected transactions must not change state. Browser model starts from a fresh policy state each time. It is not compiled Solidity, and actual revert selectors and receipts require Remix or local EVM.

Use the diagram to follow the calculation or state progression. Keep the teaching configuration separate from the independent exercise values; compare observations with the actual model and implementation.

Concept animation · independent state notebook

Explore the teaching example independently of the simulator. Each step reveals an operation, data relationship or calculated state. The Simulation view has separate editable inputs.

Advanced Solidity: roles and modifiers: independent state notebook123Calculated state 1ItemInitial stateValuenode-1 active; operator delegatedExplanation

Step 1 of 3 · Calculated state 1

Calculated state 1

Item
Initial state
Value
node-1 active; operator delegated
Explanation

Teaching example only; inspect live calculations or real practical evidence separately.

Recall the concept before revealing its explanation.

0 / 3 revealed
B10 · 01 / 08What is a modifier?Reveal explanation
Engineering explanation

Reusable condition executed around a function body.

B10 · 02 / 08Why use a distinct operator role?Reveal explanation
Engineering explanation

Delegate device management without granting role-management authority.

B10 · 03 / 08What proves rejection?Reveal explanation
Engineering explanation

Expected revert, failed receipt when submitted, and unchanged state.

B10 · 04 / 08Why separate owner and operator privileges?Reveal explanation
Engineering reasoning

An operator can be allowed to manage a device without receiving permission to delegate roles.

B10 · 05 / 08Why test role revocation as well as delegation?Reveal explanation
Engineering reasoning

Revocation should remove the previously granted authority; verify subsequent rejection and state preservation.

B10 · 06 / 08A Solidity operator is revoked. Select every technically valid statement. A. Test permission before and after revocation. B. Only an authorized administrative caller should change roles. C. A modifier guarantees correct behavior without any runtime test. D. A revoked role must retain all privileges.Reveal explanation
Applied scenario

Correct: A. Test permission before and after revocation.; B. Only an authorized administrative caller should change roles.

B10 · 07 / 08In Advanced Solidity: roles and modifiers, which reference and changed settings are prescribed for Caller?Reveal explanation
Controlled configuration

Caller: operator → viewer; hold the remaining settings fixed.

B10 · 08 / 08What expected result distinguishes the reference and changed trials in Advanced Solidity: roles and modifiers?Reveal explanation
Expected observation

Operator disables the active device; viewer is rejected; state remains unchanged. Owner may delegate or revoke operators.

Loading experiment-specific apparatus…
Previous model / additional reference tools
Simulation task

Implement owner-only delegation, operator permissions and revocation with explicit custom errors.

Explore the model using its own controls. Record a prediction before changing a condition. Compare the reference with a changed condition, then use the Experiment tab for the procedure, acceptance criteria and notebook. Model outputs and physical observations must remain separate.

Interactive engineering workbenchB10 · Existing model
Interactive workbench

Predict, configure and observe

Loading executable simulation…

B10 · Model-linked instrumentation

Visual observation lens

Back to controls ↑

Readout from the original computational model; not physical measurements.

Loading instrument…

Awaiting model display.

Experimental instrumentation · A/B

Compare two model conditions

Capture a baseline, change one experimental condition, run the model if required and capture the comparison. Snapshots contain visible controls and display text, not physical sensor readings. Review before exporting.

Open simulation view
Baseline A
Not captured
Comparison B
Not captured

Capture a baseline to begin.

Evidence portfolio →
V19.0 · Contextual AI workspace

Ask your engineering assistants

B10 · current context

Ask Dr. Mohammad locally, or prepare an experiment-aware prompt for ChatGPT, Gemini or Claude. The external providers open in their own tabs; nothing is automatically submitted.

Dr. Mohammad · offline
Dr. Mohammad

Offline curriculum-grounded assistance.

Open local tutor
Advanced Solidity: roles and modifiers

Public course objective, displayed commands, source excerpts and procedure. Private assessment content is not collected.

Prepare a contextual AI prompt

0 characters

Common secret and email patterns are redacted on preparation; this is not a comprehensive privacy filter. Review the entire editable prompt, including student work and unpublished research, before sharing. The providers apply their own accounts, privacy settings and limits.

Prepare → review → copy & open your selected provider → paste and submit there.

Independent theoretical exercises

Before the simulation or practical, solve both experiment-specific tasks. List the given inputs, show the intermediate calculation or state trace, identify the expected observation, and state a limitation. Show formulas and intermediate calculations where relevant, or draw the requested state/sequence diagram. These are independent classroom fixtures; where they differ from the reference configuration below, do not treat them as measured values. Compare your predictions with the corresponding experiment afterwards.

01 · Predict and derive using the given inputs

Construct a permission matrix for owner, operator and observer for delegate, set and revoke using the supplied contract.

02 · Compare or justify using evidence

Trace delegate operator→set→revoke→set; predict successful and failed state changes and corresponding receipts.

03 · Debugging

Debugging · Independent work

A function changes a limit before testing an operator flag, then returns false instead of reverting. Explain the flaw and correction.

Work is saved locally when browser storage is available. Export it for submission; no remote upload or automatic grade is assigned.

Expanded independent theoretical exercise bank

Progress from calculation and interpretation to diagnosis and controlled engineering design. Complete the questions without opening the simulation first; show intermediate steps.

Intermediate · Explain a changed-input result

Independent theoretical exercise · B10-01

Use the reference configuration (Caller = operator; Action = set), but change Caller = owner. The model reports Role = owner. Explain the governing rule and assumptions that make this output plausible; identify an independent verification method.

Intermediate · Interpret a state transition

Independent theoretical exercise · B10-02

The reference model reports Role: operator. Under Caller = owner it reports owner. Explain which configured condition changed and what the two outputs establish, and what they do not establish.

Intermediate · Interpret a technical trace

Independent theoretical exercise · B10-03

For Action = grant, the model supplies this excerpt from Calculated trace: Item · Value · Explanation Initial state · node-1 active; operator delegated · Requested · grant · Final state · Unchanged · Count rows whose Value value is exactly “node-1 active; operator delegated”, and identify the displayed row numbers. Explain what the count describes.

Advanced · Reverse reasoning

Independent theoretical exercise · B10-04

An observation is Decision = NotOwner. Candidate A uses Caller = operator; Action = set. Candidate B changes the listed settings (Action = grant) and keeps the remaining settings fixed. Which is consistent with the observation? If both can explain it, say what additional evidence is required.

Advanced · Diagnose a reported mismatch

Independent theoretical exercise · B10-05

A student configures Caller = viewer while preserving all other reference settings, but copies the reference report of Decision = Accepted. Evaluate whether the report is justified. Identify the first configuration/output check to perform.

Challenging · Design a controlled verification

Independent theoretical exercise · B10-06

Design a controlled comparison for Advanced Solidity: roles and modifiers using reference Caller = operator; Action = set and test Caller = owner. Specify the changed setting(s), measured metric Role, controls, repetitions, an acceptance check and what evidence can distinguish an actual implementation from the model.

Step-by-step experimental procedure

Implement owner-only delegation, operator permissions and revocation with explicit custom errors.

1 · Reference workbench configuration

Use the named reference workbench and its reference inputs. Additional live instruments may have different controls; use the matching instrument. Record virtual and practical results separately.

Calleroperator
Actionset

2 · Perform the investigation in order

  1. Open RoleRegistry.sol in Remix, compile with 0.8.28, Shanghai, optimizer disabled; select Remix VM, account 0, VALUE 0, deploy RoleRegistry. Copy account 1 (operator), account 2 (device) and account 3 (viewer) addresses from the Remix account selector.
  2. As account 0, call setOperator(account 1, true), then setDevice(account 2, true). Expected: operators(account 1) and active(account 2) return true.
  3. Switch to account 1 and call setDevice(account 2, false). Expected: successful receipt, active(account 2)=false. Switch to account 3 and try setDevice(account 2, true). Expected: NotOwnerOrOperator revert, state remains false. A generic failure is inconclusive.
  4. As account 1, attempt setOperator(account 3,true). Expected NotOwner. As account 0, revoke account 1 with setOperator(account 1,false); switch back to account 1 and attempt setDevice(account 2,true). Expected NotOwnerOrOperator. Restore state as account 0. Record receipts and state.

3 · Compare controlled trials

TrialIndependent changeExpected checkObservation
ReferenceUse reference inputs aboveOperator disables the active device; viewer is rejected; state remains unchanged. Owner may delegate or revoke operators.Record actual result
Controlled changeCaller = viewerOperator disables the active device; viewer is rejected; state remains unchanged. Owner may delegate or revoke operators.Record actual result

4 · Analyze and report

Browser model starts from a fresh policy state each time. It is not compiled Solidity, and actual revert selectors and receipts require Remix or local EVM.

Required evidence: Record the advanced solidity: roles and modifiers comparison and justify the changed outcome from the calculated trace.

Model boundary: Browser model starts from a fresh policy state each time. It is not compiled Solidity, and actual revert selectors and receipts require Remix or local EVM.

Controlled investigation · reproducible evidence

Method. Use the existing reference workbench configuration and the named controlled changes below. A controlled variable stays fixed while the independent variable is intentionally changed; the dependent variable is the resulting observed output. First predict each trial from the Concepts page. Run the baseline, then change only the specified setting and record the outcome. For deterministic traces one execution per case and a repeated verification are sufficient; for timing or stochastic measurements repeat at least five times, recording each run, median and range. Reset to the reference state between independent comparisons.

TrialIndependent changeDependent observation
ReferenceUse reference inputs aboveRecord actual outcome and units
Controlled changeCaller = viewerRecord actual outcome and units

Evidence: attach the completed comparison table, one trace or screenshot per condition, and actual practical terminal/hardware evidence where applicable. Explain any prediction mismatch and distinguish modeled behavior from measured results.

Loading laboratory-specific procedure…

Complete practical procedure & acceptance

✓ Expected baseline and controlled change: Operator disables the active device; viewer is rejected; state remains unchanged. Owner may delegate or revoke operators.

  1. Open RoleRegistry.sol in Remix, compile with 0.8.28, Shanghai, optimizer disabled; select Remix VM, account 0, VALUE 0, deploy RoleRegistry. Copy account 1 (operator), account 2 (device) and account 3 (viewer) addresses from the Remix account selector.
  2. As account 0, call setOperator(account 1, true), then setDevice(account 2, true). Expected: operators(account 1) and active(account 2) return true.
  3. Switch to account 1 and call setDevice(account 2, false). Expected: successful receipt, active(account 2)=false. Switch to account 3 and try setDevice(account 2, true). Expected: NotOwnerOrOperator revert, state remains false. A generic failure is inconclusive.
  4. As account 1, attempt setOperator(account 3,true). Expected NotOwner. As account 0, revoke account 1 with setOperator(account 1,false); switch back to account 1 and attempt setDevice(account 2,true). Expected NotOwnerOrOperator. Restore state as account 0. Record receipts and state.
  5. Export observed evidence, restore baseline and record limitations. Do not treat browser-model output as actual hardware or EVM evidence.

Experimental notebook

Record your own results. Values are not prefilled or independently verified.

Solidity source

Download RoleRegistry.sol · Open Remix IDE

SOLIDITY · Source code
// SPDX-License-Identifier: MIT
pragma solidity 0.8.28;
/// @notice Teaching registry using fictional device addresses. No funds or private data.
contract RoleRegistry {
    address public immutable owner;
    mapping(address => bool) public operators;
    mapping(address => bool) public active;
    error NotOwner();
    error NotOwnerOrOperator();
    error InvalidAddress();
    event OperatorStatus(address indexed operator, bool enabled);
    event DeviceStatus(address indexed device, bool enabled);
    constructor() { owner = msg.sender; }
    modifier onlyOwner() { if (msg.sender != owner) revert NotOwner(); _; }
    modifier onlyManager() { if (msg.sender != owner && !operators[msg.sender]) revert NotOwnerOrOperator(); _; }
    function setOperator(address operator, bool enabled) external onlyOwner {
        if (operator == address(0)) revert InvalidAddress();
        operators[operator] = enabled; emit OperatorStatus(operator, enabled);
    }
    function setDevice(address device, bool enabled) external onlyManager {
        if (device == address(0)) revert InvalidAddress();
        active[device] = enabled; emit DeviceStatus(device, enabled);
    }
}

Record & discuss

Notebook exports use related core lab B05; the supplementary ID is retained in the evidence. Technical reference.

Learning progress

Mark complete only after documenting your observations. This is not a verified result or official grade.

View prerequisites and related learning

Python / Google Colab laboratory

B10 · 9 notebook cells · 2 executable Python cells

Complete the theoretical investigation first. Run the cells in order, record actual outputs and compare against your prediction.

How to execute

  1. Download this notebook and open Google Colab. Select File → Upload notebook and choose the downloaded .ipynb.
  2. Read the Markdown instructions before each executable cell. Use a Python runtime, run cells from top to bottom, and resolve imports if necessary.
  3. Perform the baseline and controlled changes. Save the notebook with actual outputs and your written interpretation.

Execution scope: Browser is a state-machine model, not a Solidity compiler or EVM. Solidity 0.8 uses checked arithmetic by default; do not use selfdestruct as a general upgrade mechanism. Default computational cells passed isolated local Python execution; physical equipment and live services require separate verification.

01Instructions · Markdown
# B10 · Advanced Solidity: roles and modifiers **PSUT IoT Engineering Studio — Dr. Mohammad Alja’afreh** ## 1. Scientific objective Implement owner-only delegation, operator permissions and revocation with explicit custom errors. Complete the analytical worksheet in the portal first. Record your predictions before running this notebook. This notebook is a bounded local computational investigation; use the portal’s separate WSL, hardware or Remix procedure for real interfaces.
02Instructions · Markdown
## Experiment-specific preparation Implement owner-only delegation, operator permissions and revocation with explicit custom errors. **Reference procedure (use the matching simulator/WSL tool where named, not an unrelated service):** 1. Open RoleRegistry.sol in Remix, compile with 0.8.28, Shanghai, optimizer disabled; select Remix VM, account 0, VALUE 0, deploy RoleRegistry. Copy account 1 (operator), account 2 (device) and account 3 (viewer) addresses from the Remix account selector. 2. As account 0, call setOperator(account 1, true), then setDevice(account 2, true). Expected: operators(account 1) and active(account 2) return true. 3. Switch to account 1 and call setDevice(account 2, false). Expected: successful receipt, active(account 2)=false. Switch to account 3 and try setDevice(account 2, true). Expected: NotOwnerOrOperator revert, state remains false. A generic failure is inconclusive. 4. As account 1, attempt setOperator(account 3,true). Expected NotOwner. As account 0, revoke account 1 with setOperator(account 1,false); switch back to account 1 and attempt setDevice(account 2,true). Expected NotOwnerOrOperator. Restore state as account 0. Record receipts and state. **Evidence:** Owner call updates mapping and emits DeviceStatus; outsider call reverts and leaves state unchanged. Save the actual Remix transaction receipts separately. **Boundary:** Browser is a state-machine model, not a Solidity compiler or EVM. Solidity 0.8 uses checked arithmetic by default; do not use selfdestruct as a general upgrade mechanism.
03Instructions · Markdown
## 2. Reference configuration and investigation 1. Open RoleRegistry.sol in Remix, compile with 0.8.28, Shanghai, optimizer disabled; select Remix VM, account 0, VALUE 0, deploy RoleRegistry. Copy account 1 (operator), account 2 (device) and account 3 (viewer) addresses from the Remix account selector. 2. As account 0, call setOperator(account 1, true), then setDevice(account 2, true). Expected: operators(account 1) and active(account 2) return true. 3. Switch to account 1 and call setDevice(account 2, false). Expected: successful receipt, active(account 2)=false. Switch to account 3 and try setDevice(account 2, true). Expected: NotOwnerOrOperator revert, state remains false. A generic failure is inconclusive. 4. As account 1, attempt setOperator(account 3,true). Expected NotOwner. As account 0, revoke account 1 with setOperator(account 1,false); switch back to account 1 and attempt setDevice(account 2,true). Expected NotOwnerOrOperator. Restore state as account 0. Record receipts and state. Run cells in order; do not substitute model results for physical measurements.
04Instructions · Markdown
## 3. Model owner/operator access decisions.
05Python · executable cell
PYTHON · Code cell
# =====================================================================
# B10 | Code cell 01 | Advanced Solidity: roles and modifiers
# Purpose: 3. Model owner/operator access decisions.
# Inputs: the explicit fixture/settings below and any preceding cell state.
# Output: inspect printed values, returned records or assertions; record evidence.
# =====================================================================
# Define the reusable operation register; keep its logic separate from the trial.
def register(caller,active):
    if caller!="owner":return active,"NotOwner"
    return True,"Registered"
# Check the expected invariant so a mismatch fails visibly instead of appearing successful.
assert register("owner",False)==(True,"Registered")
# Check the expected invariant so a mismatch fails visibly instead of appearing successful.
assert register("viewer",False)==(False,"NotOwner")
Ask Dr. Mohammad about this cell
06Instructions · Markdown
## 4. Model delegation and revocation; verify state is unchanged on denial.
07Python · executable cell
PYTHON · Code cell
# =====================================================================
# B10 | Code cell 02 | Advanced Solidity: roles and modifiers
# Purpose: 4. Model delegation and revocation; verify state is unchanged on denial.
# Inputs: the explicit fixture/settings below and any preceding cell state.
# Output: inspect printed values, returned records or assertions; record evidence.
# =====================================================================
# Set operators for the next computation or reference condition.
operators=set()
# Define the reusable operation delegate; keep its logic separate from the trial.
def delegate(caller,person,allowed):
    if caller!="owner":return False
    if allowed:operators.add(person)
    else:operators.discard(person)
    return True
# Check the expected invariant so a mismatch fails visibly instead of appearing successful.
assert delegate("owner","operator",True)
# Check the expected invariant so a mismatch fails visibly instead of appearing successful.
assert not delegate("viewer","guest",True)
# Check the expected invariant so a mismatch fails visibly instead of appearing successful.
assert delegate("owner","operator",False) and not operators
Ask Dr. Mohammad about this cell
08Instructions · Markdown
## Experimental analysis and submission 1. Record the reference input, predicted output and actual result. 2. Modify one independent variable and run the relevant cells again. 3. Explain the result using the theory and identify model limitations. 4. Save the notebook with outputs and retain the separate theoretical worksheet. **Your derivation and conclusion:** (Complete independently.)
09Instructions · Markdown
## Guided reasoning and evidence A controlled comparison changes one independent input while keeping the other relevant inputs fixed; the dependent variable is the recorded output. Use this lab’s reference condition above. **Independent task:** 2. As account 0, call setOperator(account 1, true), then setDevice(account 2, true). Expected: operators(account 1) and active(account 2) return true. Record the named input, prediction, actual output and one limitation; restore the original condition and repeat. | Trial | Input/configuration | Prediction | Observation | Evidence / limitation | |---|---|---|---|---| | A | Reference | | | | | B | Changed input | | | | | A repeat | Reference | | | | A conclusion is supported only when it cites the recorded values or observed states and explains them with the experiment theory.
Shared research workbenches · network designer & advanced studies
Concurrent-device simulation & Monte Carlo research
Distributed digital twin · topology, protocol & battery research