没有合适的资源?快使用搜索试试~ 我知道了~
CS251 Final Exam 2021
0 下载量 160 浏览量
2023-12-24
20:26:33
上传
评论
收藏 164KB PDF 举报
温馨提示
试读
12页
You may use any (non-human) resource to answer the questions. You may not collaborate with others.
资源推荐
资源详情
资源评论
CS251 Final Exam 2021
Due Wednesday, Dec. 8, 2021, 11:59pm on gradescope
Instructions:
You may use any (non-human) resource to answer
the questions. You may not collaborate with others.
Your Name:
SUNet ID: @stanford.edu
In accordance with both the letter and the spirit
of the Stanford Honor Code, I neither received nor
provided any assistance on this exam.
Signature:
• The exam has 6 questions totaling 100 points.
• You have until the deadline to complete them.
• Please submit your answers on Gradescope (D5GKRX)
• Keep your answers concise.
1 /18
2 /20
3 /20
4 /16
5 /15
6 /11
Total /100
Page 1 of 12
Problem 1. [18 points]: Questions from all over.
A) Briefly explain why a Rollup system stores all transaction data on chain? What would
go wrong if transaction data were discarded and not stored anywhere?
B) Consider the following Solidity code:
pragma solidity ^0.8.0;
contract ERC20 is IERC20 {
mapping(address => uint256) private _balances;
event Transfer(address indexed from, address indexed to, uint256 value);
function _transfer(address sender, address recipient, uint256 amount) {
emit Transfer(sender, recipient, amount);
}}
Suppose this code is deployed in two contracts: a contract at address X and a contract
at address Y . Which of the following can read the state of _balances in contract X?
Circle the correct answer(s).
A Code in the _transfer() function in contract ERC20 at address X
B Code in the _transfer() function in contract ERC20 at address Y
C An enduser using etherscan.io
C) Continuing with part (B), which of the following can read the log entry Transfer
emitted when the function _transfer() is called? Circle the correct answer(s).
A Code in the function getBalance() defined in contract ERC20 at address X
B Code in the function getBalance() defined in contract ERC20 at address Y
C An enduser using etherscan.io
Page 2 of 12
D) Two Ethereum transactions, tx
1
and tx
2
, are submitted to the network at the same time.
Transaction tx
1
has maxPriorityFee set to y and transaction tx
2
has maxPriorityFee
set to 2y. Will tx
2
necessarily be executed on chain before tx
1
? Justify your answer. You
can assume that maxFee for both tx
1
and tx
2
is greater than baseFee + maxPriorityFee.
E) Alice wants to buy a car from dealer Bob. She sends 1 BTC to Bob’s Bitcoin address.
Bob waits for a transaction where (i) the input is from Alice’s address, and (ii) one of
the outputs is a UTXO bound to Bob’s address with a value of 1 BTC. As soon as Bob
sees this transaction on the Bitcoin blockchain, he gives Alice the keys, and she drives
away. Is this safe? Could Alice get the car for free? If so, explain why. If not, explain
what Bob should do to ensure that he gets paid.
F) Alice owns a brand new Tesla Model Y. Can she currently use her car as collateral for
a loan in the Compound system? (without selling the car) If yes, explain how. If no,
explain why not.
Page 3 of 12
剩余11页未读,继续阅读
资源评论
FeelTouchLabs
- 粉丝: 1w+
- 资源: 78
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功