Skip to content
This repository has been archived by the owner on Nov 6, 2022. It is now read-only.

Commit

Permalink
make debugprint write
Browse files Browse the repository at this point in the history
  • Loading branch information
rachel-bousfield committed Dec 6, 2021
1 parent 1df425f commit e0902a4
Show file tree
Hide file tree
Showing 21 changed files with 31 additions and 29 deletions.
2 changes: 1 addition & 1 deletion arb_os/accounts.mini
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public view write func accounts_notifyParamsChanged() { // called if the chai
// safeGetGlobalAccountStore gets a copy of the global account store, if we are not in a user tx
// if we're in a user tx, this will error, which will revert the tx
// that should never happen, but we check to be safe
public view func safeGetGlobalAccountStore() -> AccountStore {
public view write func safeGetGlobalAccountStore() -> AccountStore {
if ! evmCallStack_isEmpty() {
asm(668) { debugprint };
error;
Expand Down
2 changes: 1 addition & 1 deletion arb_os/arbos-upgrade.mexe

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion arb_os/arbos.mexe

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions arb_os/evmCallStack.mini
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public write func evmCallStack_init() {
returnFromCallNestingDepth = 0;
}

public view func getRetryBufferInCurrentContext() -> RetryBuffer {
public view write func getRetryBufferInCurrentContext() -> RetryBuffer {
let astore = if let Some(frame) = globalCallStack {
frame.accountStore
} else {
Expand Down Expand Up @@ -1541,7 +1541,7 @@ public view write func evmCallStack_setAccount(addr: address, acct: Account) ->
}
}

public view func evmCallStack_getAccountInCurrentContext(addr: address) -> Account {
public view write func evmCallStack_getAccountInCurrentContext(addr: address) -> Account {
accountStore_get(evmCallStack_getAccountStoreInCurrentContext(), addr)
}

Expand All @@ -1557,7 +1557,7 @@ public view write func evmCallStack_setAccountInCurrentContext(addr: address, ac
}
}

public view func evmCallStack_getAccountStoreInCurrentContext() -> AccountStore {
public view write func evmCallStack_getAccountStoreInCurrentContext() -> AccountStore {
if let Some(topFrame) = globalCallStack {
accountStore_set(topFrame.accountStore, topFrame.runningAs, topFrame.runningAsAccount)
} else {
Expand Down
12 changes: 6 additions & 6 deletions arb_os/gasAccounting.mini
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ view func setRetryablePrices(oldRetryablePrices: RetryablePrices) -> RetryablePr
}
}

public view func gasAccounting_getPricesInWei(aggregatorAddr: address) -> (uint, uint, uint, uint, uint, uint) {
public view write func gasAccounting_getPricesInWei(aggregatorAddr: address) -> (uint, uint, uint, uint, uint, uint) {
// This is intended to return data to users, so we add the network fee, in order to return the total price they'll pay.
let prices = gasAccountingInfo.currentPrices;
let addNetworkFeeRate = gasAccountingInfo.feeConfig.baseFeeMultiplier;
Expand All @@ -308,11 +308,11 @@ public view func gasAccounting_getPricesInWei(aggregatorAddr: address) -> (uint,
)
}

view func gasAccounting_getTxBaseFeeWei(aggregatorAddr: option<address>) -> uint {
view write func gasAccounting_getTxBaseFeeWei(aggregatorAddr: option<address>) -> uint {
safeMul(getL1GasPriceEstimate(), gasAccounting_getTxBaseFeeL1Gas(aggregatorAddr))
}

public view func gasAccounting_getTxBaseFeeL1Gas(maybeAggregatorAddr: option<address>) -> uint {
public view write func gasAccounting_getTxBaseFeeL1Gas(maybeAggregatorAddr: option<address>) -> uint {
if feesEnabled() {
let aggregatorAddr = if let Some(addr) = maybeAggregatorAddr {
addr
Expand Down Expand Up @@ -353,7 +353,7 @@ public view func getCurrentBlockGasLimit() -> uint {
gasAccountingInfo.gasAllocatedToThisBlock
}

public view func gasAccounting_getPricesInArbGas(aggregatorAddr: address) -> (uint, uint, uint) {
public view write func gasAccounting_getPricesInArbGas(aggregatorAddr: address) -> (uint, uint, uint) {
let prices = gasAccountingInfo.currentPrices;
let arbGasPrice = prices.perArbGasTotal;
let baseFeeMultiplier = gasAccountingInfo.feeConfig.baseFeeMultiplier;
Expand Down Expand Up @@ -585,7 +585,7 @@ public view write func gasAccounting_endTxCharges(
))
}

view func tryGasRepayments(
view write func tryGasRepayments(
totalGasRemaining: uint,
gasUsedForCompute: uint,
gasUsedForStorage: uint,
Expand Down Expand Up @@ -1215,7 +1215,7 @@ public func deferredPayments_add(dp: DeferredPayments, escrowKey: uint, recipien
stack_push(dp, (escrowKey, recipient, amount))
}

public func deferredPayments_apply(acctStore: AccountStore, dp: DeferredPayments) -> option<AccountStore> {
public write func deferredPayments_apply(acctStore: AccountStore, dp: DeferredPayments) -> option<AccountStore> {
loop {
if let Some(res) = stack_pop(dp) {
let (*dp, item) = res;
Expand Down
2 changes: 1 addition & 1 deletion arb_os/tracing.mini
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public func evmTracer_new() -> EvmTracer {
}
}

public view func evmTracer_emit() {
public view write func evmTracer_emit() {
let val = any(());
let theStack = outbox_getEvmTracer().recordStack;
loop {
Expand Down
2 changes: 1 addition & 1 deletion arb_os/upgrade.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion looptest/upgrade2_base.mexe

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion looptest/upgrade2_new.mexe

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion looptest/upgrade2_old.mexe

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/compile/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ pub struct CompileStruct {
pub warnings_are_errors: bool,
#[clap(short, long)]
pub output: Option<String>,
#[clap(short = 'O', long, default_value = "7168")]
#[clap(short = 'O', long, default_value = "0")]
pub optimization_level: usize,
#[clap(short, long)]
pub format: Option<String>,
Expand Down
1 change: 1 addition & 0 deletions src/compile/typecheck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,7 @@ impl AbstractSyntaxTree for TypeCheckedStatement {
fn is_write(&mut self, type_tree: &TypeTree) -> bool {
match &mut self.kind {
TypeCheckedStatementKind::AssignGlobal(_, _) => true,
TypeCheckedStatementKind::DebugPrint(_) => true,
_ => self
.child_nodes()
.iter_mut()
Expand Down
1 change: 1 addition & 0 deletions src/mavm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1119,6 +1119,7 @@ impl Opcode {
pub fn is_write(&self, _: &TypeTree) -> bool {
match self {
Opcode::AVMOpcode(AVMOpcode::Log)
| Opcode::AVMOpcode(AVMOpcode::DebugPrint)
| Opcode::AVMOpcode(AVMOpcode::Inbox)
| Opcode::AVMOpcode(AVMOpcode::InboxPeek)
| Opcode::AVMOpcode(AVMOpcode::Send)
Expand Down
2 changes: 1 addition & 1 deletion stdlib/bytearraytest.mini
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ write func main() {
asm(tests()) { log };
}

func tests() -> uint {
write func tests() -> uint {

let buf = newbuffer();
let buf2 = setbuffer8(buf, 10000, 12);
Expand Down
2 changes: 1 addition & 1 deletion stdlib/priorityq.mini
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public func priorityq_insert(pq: PriorityQ, item: any, priority: uint) -> Priori
pq_pushUp(newpq, index)
}

public func priorityq_printAsArray(pq: PriorityQ) -> uint {
public write func priorityq_printAsArray(pq: PriorityQ) -> uint {
let ret = pq.size;
let cont = pq.contents;
let i = 0;
Expand Down
2 changes: 1 addition & 1 deletion stdlib/rlptest.mini
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ write func main(kind: uint, value: any) {
testRlpHasher();
}

sensitive func testRlpHasher() {
sensitive write func testRlpHasher() {
let seqNum = 0;
let gasPrice = 31;
let gasLimit = uint(hash(0));
Expand Down
2 changes: 1 addition & 1 deletion stdlib2/priorityq.mini
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public func priorityq_insert<T>(pq: PriorityQ<T>, item: T, priority: uint) -> Pr
pq_pushUp::<T>(newpq, index)
}

public func priorityq_printAsArray<T>(pq: PriorityQ<T>) -> uint {
public write func priorityq_printAsArray<T>(pq: PriorityQ<T>) -> uint {
let ret = pq.size;
let cont = pq.contents;
let i = 0;
Expand Down
2 changes: 1 addition & 1 deletion upgradetests/regcopy_new.mexe
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"arbos_version":51,"code":[{"opcode":59,"immediate":{"Tuple":[]},"debug_info":{"location":null,"attributes":{"breakpoint":false}}},{"opcode":51,"immediate":{"Tuple":[]},"debug_info":{"location":null,"attributes":{"breakpoint":false}}},{"opcode":56,"immediate":null,"debug_info":{"location":{"line":6,"column":5,"absolute":102,"file_id":5167093027911251668},"attributes":{"breakpoint":false}}},{"opcode":56,"immediate":{"Tuple":[]},"debug_info":{"location":{"line":6,"column":5,"absolute":102,"file_id":5167093027911251668},"attributes":{"breakpoint":false}}},{"opcode":64,"immediate":null,"debug_info":{"location":null,"attributes":{"breakpoint":false}}},{"opcode":144,"immediate":null,"debug_info":{"location":null,"attributes":{"breakpoint":false}}},{"opcode":64,"immediate":null,"debug_info":{"location":null,"attributes":{"breakpoint":false}}},{"opcode":82,"immediate":null,"debug_info":{"location":null,"attributes":{"breakpoint":false}}},{"opcode":144,"immediate":null,"debug_info":{"location":null,"attributes":{"breakpoint":false}}},{"opcode":82,"immediate":null,"debug_info":{"location":null,"attributes":{"breakpoint":false}}},{"opcode":20,"immediate":{"Int":"3"},"debug_info":{"location":null,"attributes":{"breakpoint":false}}},{"opcode":53,"immediate":{"CodePoint":{"Internal":17}},"debug_info":{"location":{"line":9,"column":4,"absolute":218,"file_id":5167093027911251668},"attributes":{"breakpoint":false}}},{"opcode":57,"immediate":{"Int":"0"},"debug_info":{"location":{"line":10,"column":8,"absolute":262,"file_id":5167093027911251668},"attributes":{"breakpoint":false}}},{"opcode":48,"immediate":null,"debug_info":{"location":{"line":10,"column":8,"absolute":262,"file_id":5167093027911251668},"attributes":{"breakpoint":false}}},{"opcode":57,"immediate":null,"debug_info":{"location":{"line":10,"column":8,"absolute":262,"file_id":5167093027911251668},"attributes":{"breakpoint":false}}},{"opcode":52,"immediate":null,"debug_info":{"location":{"line":10,"column":8,"absolute":262,"file_id":5167093027911251668},"attributes":{"breakpoint":false}}},{"opcode":52,"immediate":{"CodePoint":{"Internal":17}},"debug_info":{"location":{"line":9,"column":4,"absolute":218,"file_id":5167093027911251668},"attributes":{"breakpoint":false}}},{"opcode":57,"immediate":{"Int":"1"},"debug_info":{"location":{"line":12,"column":4,"absolute":286,"file_id":5167093027911251668},"attributes":{"breakpoint":false}}},{"opcode":48,"immediate":null,"debug_info":{"location":{"line":12,"column":4,"absolute":286,"file_id":5167093027911251668},"attributes":{"breakpoint":false}}},{"opcode":57,"immediate":null,"debug_info":{"location":{"line":12,"column":4,"absolute":286,"file_id":5167093027911251668},"attributes":{"breakpoint":false}}},{"opcode":52,"immediate":null,"debug_info":{"location":{"line":12,"column":4,"absolute":286,"file_id":5167093027911251668},"attributes":{"breakpoint":false}}}],"static_val":{"Tuple":[]},"globals":[{"id":18446744073709551615,"name":"_jump_table","tipe":"Any","offset":null,"debug_info":{"location":null,"attributes":{"breakpoint":false}}}],"file_info_chart":{"5167093027911251668":"regcopy_new","9360984261226144135":"core::kvs","11013747379006575874":"core::array"},"type_tree":{"inner":{"core, array, 0":[{"FixedArray":["Any",8]},"block"],"core, array, 1":[{"Struct":[{"name":"size","tipe":"Uint"},{"name":"topstep","tipe":"Uint"},{"name":"contents","tipe":{"Nominal":[["core","array"],0,[]]}}]},"array"],"core, array, 31":[{"Struct":[{"name":"bloc","tipe":{"Nominal":[["core","array"],0,[]]}},{"name":"val","tipe":"Any"}]},"arraySwapSubResult"],"core, array, 33":[{"Struct":[{"name":"f","tipe":{"Func":[{"view":false,"write":false,"sensitive":false,"closure":false,"public":false,"returns":true,"nargs":2,"nouts":1},["Any","Any"],{"Tuple":["Any","Any"]}]}},{"name":"val","tipe":"Any"}]},"opClosure"],"core, kvs, 0":[{"Struct":[{"name":"tree","tipe":{"Nominal":[["core","kvs"],2,[]]}},{"name":"size","tipe":"Uint"}]},"Kvs"],"core, kvs, 14":[{"Struct":[{"name":"kvs","tipe":{"FixedArray":["Any",8]}},{"name":"index","tipe":"Uint"},{"name":"next","tipe":{"Option":{"Nominal":[["core","kvs"],14,[]]}}}]},"Unwinder"],"core, kvs, 2":[{"FixedArray":["Any",8]},"KvsNode"],"core, kvs, 4":[{"Struct":[{"name":"key","tipe":"Any"},{"name":"value","tipe":{"Option":"Any"}}]},"KvsCell"],"regcopy_new, 0":[{"Struct":[{"name":"global1","tipe":"Uint"},{"name":"global2","tipe":{"Option":"Int"}},{"name":"jump_table","tipe":"Any"}]},"OldGlobals"]}}}
{"arbos_version":51,"code":[{"opcode":59,"immediate":{"Tuple":[]},"debug_info":{"location":null,"attributes":{"breakpoint":false}}},{"opcode":51,"immediate":{"Tuple":[]},"debug_info":{"location":null,"attributes":{"breakpoint":false}}},{"opcode":56,"immediate":null,"debug_info":{"location":{"line":6,"column":11,"absolute":108,"file_id":5167093027911251668},"attributes":{"breakpoint":false}}},{"opcode":56,"immediate":{"Tuple":[]},"debug_info":{"location":{"line":6,"column":11,"absolute":108,"file_id":5167093027911251668},"attributes":{"breakpoint":false}}},{"opcode":64,"immediate":null,"debug_info":{"location":null,"attributes":{"breakpoint":false}}},{"opcode":82,"immediate":null,"debug_info":{"location":null,"attributes":{"breakpoint":false}}},{"opcode":67,"immediate":null,"debug_info":{"location":null,"attributes":{"breakpoint":false}}},{"opcode":64,"immediate":null,"debug_info":{"location":null,"attributes":{"breakpoint":false}}},{"opcode":144,"immediate":null,"debug_info":{"location":null,"attributes":{"breakpoint":false}}},{"opcode":67,"immediate":null,"debug_info":{"location":null,"attributes":{"breakpoint":false}}},{"opcode":144,"immediate":null,"debug_info":{"location":null,"attributes":{"breakpoint":false}}},{"opcode":67,"immediate":{"Int":"3"},"debug_info":{"location":null,"attributes":{"breakpoint":false}}},{"opcode":82,"immediate":null,"debug_info":{"location":null,"attributes":{"breakpoint":false}}},{"opcode":20,"immediate":null,"debug_info":{"location":null,"attributes":{"breakpoint":false}}},{"opcode":53,"immediate":{"CodePoint":{"Internal":20}},"debug_info":{"location":{"line":9,"column":4,"absolute":222,"file_id":5167093027911251668},"attributes":{"breakpoint":false}}},{"opcode":57,"immediate":{"Int":"0"},"debug_info":{"location":{"line":10,"column":8,"absolute":265,"file_id":5167093027911251668},"attributes":{"breakpoint":false}}},{"opcode":48,"immediate":null,"debug_info":{"location":{"line":10,"column":8,"absolute":265,"file_id":5167093027911251668},"attributes":{"breakpoint":false}}},{"opcode":57,"immediate":null,"debug_info":{"location":{"line":10,"column":8,"absolute":265,"file_id":5167093027911251668},"attributes":{"breakpoint":false}}},{"opcode":52,"immediate":null,"debug_info":{"location":{"line":10,"column":8,"absolute":265,"file_id":5167093027911251668},"attributes":{"breakpoint":false}}},{"opcode":52,"immediate":{"CodePoint":{"Internal":20}},"debug_info":{"location":{"line":9,"column":4,"absolute":222,"file_id":5167093027911251668},"attributes":{"breakpoint":false}}},{"opcode":57,"immediate":{"Int":"1"},"debug_info":{"location":{"line":12,"column":4,"absolute":289,"file_id":5167093027911251668},"attributes":{"breakpoint":false}}},{"opcode":48,"immediate":null,"debug_info":{"location":{"line":12,"column":4,"absolute":289,"file_id":5167093027911251668},"attributes":{"breakpoint":false}}},{"opcode":57,"immediate":null,"debug_info":{"location":{"line":12,"column":4,"absolute":289,"file_id":5167093027911251668},"attributes":{"breakpoint":false}}},{"opcode":52,"immediate":null,"debug_info":{"location":{"line":12,"column":4,"absolute":289,"file_id":5167093027911251668},"attributes":{"breakpoint":false}}}],"static_val":{"Tuple":[]},"globals":[{"id":18446744073709551615,"name":"_jump_table","tipe":"Any","offset":null,"debug_info":{"location":null,"attributes":{"breakpoint":false}}}],"file_info_chart":{"5167093027911251668":"regcopy_new","9360984261226144135":"core::kvs","11013747379006575874":"core::array"},"type_tree":{"inner":{"core, array, 0":[{"FixedArray":["Any",8]},"block"],"core, array, 1":[{"Struct":[{"name":"size","tipe":"Uint"},{"name":"topstep","tipe":"Uint"},{"name":"contents","tipe":{"Nominal":[["core","array"],0,[]]}}]},"array"],"core, array, 31":[{"Struct":[{"name":"bloc","tipe":{"Nominal":[["core","array"],0,[]]}},{"name":"val","tipe":"Any"}]},"arraySwapSubResult"],"core, array, 33":[{"Struct":[{"name":"f","tipe":{"Func":[{"view":false,"write":false,"sensitive":false,"closure":false,"public":false,"returns":true,"nargs":2,"nouts":1},["Any","Any"],{"Tuple":["Any","Any"]}]}},{"name":"val","tipe":"Any"}]},"opClosure"],"core, kvs, 0":[{"Struct":[{"name":"tree","tipe":{"Nominal":[["core","kvs"],2,[]]}},{"name":"size","tipe":"Uint"}]},"Kvs"],"core, kvs, 14":[{"Struct":[{"name":"kvs","tipe":{"FixedArray":["Any",8]}},{"name":"index","tipe":"Uint"},{"name":"next","tipe":{"Option":{"Nominal":[["core","kvs"],14,[]]}}}]},"Unwinder"],"core, kvs, 2":[{"FixedArray":["Any",8]},"KvsNode"],"core, kvs, 4":[{"Struct":[{"name":"key","tipe":"Any"},{"name":"value","tipe":{"Option":"Any"}}]},"KvsCell"],"regcopy_new, 0":[{"Struct":[{"name":"global1","tipe":"Uint"},{"name":"global2","tipe":{"Option":"Int"}},{"name":"jump_table","tipe":"Any"}]},"OldGlobals"]}}}
8 changes: 4 additions & 4 deletions upgradetests/regcopy_new.mini
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ type OldGlobals = struct {
jump_table: any,
};

func main(old: OldGlobals) -> bool {
asm(old,) { debugprint };
asm(asm(old,) uint { tlen },) { debugprint };
if (asm(old,) uint { tlen } != 3) {
write func main(old: OldGlobals) -> bool {
asm(old) { debugprint };
asm(asm(old) uint { tlen },) { debugprint };
if (asm(old) uint { tlen } != 3) {
return false;
}
return true;
Expand Down
Loading

0 comments on commit e0902a4

Please sign in to comment.