期中模拟卷 B|机制与应用 16-20
现有材料范围内的非官方复习,含英文术语、成立条件与自拟练习解析。
手机上宽表格可左右滑动;自测答案默认收起,点击题目下方按钮查看。
非官方自拟模拟卷 B,正式考试范围、题型、时长和开闭卷要求以讲师通知为准。 按现有期中前密码学基础、L01-L05 与 Lab 1 编写,借鉴所提供往年期末卷的可见设问结构;不加入期中后专题。本卷不是往年期中真题或押题。
全卷 100 分,建议练习 100 分钟。Part A 为自拟单选 15 题共 30 分;Part B 共 70 分。原参考文件没有选择题正文,不能据此预测实际选择规则。每题答案和给分点默认收起,自评分不等于教师评分。
统一前提:Solidity 0.8.30、默认 checked arithmetic;采用普通 EOA 交易模型,不讨论账户代码委托。代码仅用于教学;除题目说明外,gas 充足、无隐藏操作、无额外费用。计算按题面精确数值。
读题词:attacker = 攻击者;justify = 给出原因;at least = 至少;strictly = 严格;resulting state = 结果状态。问题中的“攻击者”不是哈希性质的名称。
来源代号:C01 是密码学基础;L01-L05 对应逐讲注解。答案回查页码均为原 PDF 页序。英文同义表达与机制正确的替代答案可以成立。
B 卷导航:单选题 1-8 · 单选题 9-15 · 机制与应用 16-20 · 重入推演 21 · 升级 状态与钱包 22-24
机制与应用 16-20
B16 · Q16 Who does what? [4 marks]
A DApp uses a browser interface, a wallet, an RPC-connected Ethereum node, and an active validator. Briefly describe one distinct responsibility of each during a user’s contract interaction. Do not assume that merely running an RPC node makes it a validator.
B16 · 查看答案与解析
Q16 · Component responsibilities [4 marks]
推理过程:把一次操作按交接顺序讲:前端整理“想做什么” → 钱包确认并签名 → RPC 节点接收、查询或传播请求 → 活跃验证者按分配参与提议和投票。RPC 是远程调用接口,validator 是共识职责;一个软件提供 RPC,不代表它已经质押、激活并承担验证者任务。
Model answer: The browser interface displays information and prepares an interaction request. The wallet asks for authorization and signs with the user’s key. The RPC node exposes chain queries and accepts a transaction for propagation; running a full node also involves checking blocks. An active validator performs assigned consensus duties, such as proposing a block or attesting to a valid chain view.
给分:四个角色各 1 分。不能把 wallet 写成“保管链上 ETH 的数据库”,不能把 RPC node 与 validator 自动画等号。词:prepare / authorize / propagate / validate / attest。回查:L04a p.8-18;L05 p.41-55;L02 p.90-104。
B17 · Q17 Public-chain guarantees [4 marks]
An application advertises: “Our records are on a public blockchain, so nobody needs to trust anybody and all private variables are secret.” Evaluate the two claims separately. For each, state a relevant blockchain property and explain why it does or does not support the claim.
B17 · 查看答案与解析
Q17 · Evaluate both guarantees [4 marks]
推理过程:把广告拆成两个主张分别回答。① 公开记录可被核验,减少对中心记账者的依赖,但合约仍可能写错,外部数据仍可能失实,升级者仍可能改变行为。② private 只限制 Solidity 代码访问方式,没有加密存储。两个主张都把一种局部保证扩大成了全面保证。
Model answer: Public verification and protocol-enforced execution can reduce reliance on a central record keeper. They do not remove trust in contract correctness, external-data sources or upgrade governance. Solidity private restricts source-level access; it does not encrypt public-chain storage or make it secret from observers.
给分:可独立核验/减少中心记账依赖 1;仍存具体信任假设 1;private 的访问限制含义 1;不提供机密性及原因 1。说“不可篡改所以零信任”不得第二分。回查:L01 p.44-53;L04b p.17、p.33;L05 p.3-6。
B18 · Q18 From a button click to a confirmed result [13 marks]
A user calls pledge(uint256 campaignId) on an already deployed crowdfunding contract. The function is payable, updates storage, and emits a Pledged event on success.
(a) [10 marks] Describe the transaction flow step by step: preparation and signing, submission, selection and execution in a block, validation by other nodes, and the information returned to the DApp. Distinguish transaction data, resulting state and the receipt. Explain where consensus/finality enters the process.
(b) [3 marks] A preview using eth_call succeeds, and broadcasting later returns a transaction hash. A developer immediately displays “Donation successfully finalized.” Give three distinct reasons why this conclusion is premature.
Answering reminder: Explaining a process means identifying who acts, what is checked or changed, and what evidence exists at each stage. A list of product names alone is not a process explanation.
B18 · 查看答案与解析
Q18(a) · Transaction flow [10 marks]
推理过程:先把主线读成“准备请求 → 授权签名 → 传播 → 入块执行 → 核对结果 → 等待所需最终性”。每一步补齐执行者与证据。交易 data 是请求怎样调用,state 是执行后的余额与数据,receipt(交易收据)是本次执行结果;三者不能互换。下面每个得分点都对应这条主线的一步或一个区别。
Model answer / suggested marking points:
- The frontend uses the ABI to encode the function selector and campaign ID, and identifies the target contract and attached ETH value. [1]
- The wallet prepares the transaction, including nonce, chain ID, gas limit and fee caps, and obtains authorization to sign. [1]
- The signed transaction is submitted to an RPC node and may propagate through the network. A returned hash identifies it, not its execution outcome. [1]
- A producer chooses valid transactions and an order, subject to nonce, fee, balance and block-capacity constraints. [1]
- The EVM executes the call in that ordered state and meters gas; the outcome depends on that state and execution context. [1]
- On success, the specified value transfer, storage changes and event logs persist. On an uncaught revert, execution effects are rolled back, while used gas is charged and the included transaction consumes its nonce. [1]
- Other validating nodes check the proposed block and verify the execution results according to protocol rules. They do not simply trust the producer’s claimed state. [1]
- The transaction is the requested action; the resulting state is the post-execution account/contract state. [1]
- The DApp checks a receipt for inclusion and execution status, gas information and logs rather than treating the transaction hash as proof of success. [1]
- Fork choice and checkpoint voting determine the accepted chain view and finality. Inclusion or a success receipt alone is not finality; the DApp applies its required finality policy. [1]
中文:概念流程允许不同拆法;收据可在最终性之前就能读到,不应写成“先 finalized,才可能产生 receipt”。回查:L02 p.25-59、p.98-104、p.122;L04a p.8-18;L05 Web3 部分。
Q18(b) · Three premature conclusions [3 marks]
推理过程:按时间线拆三次跳步:① 模拟只说明在选定状态下能执行,不代表稍后状态相同。② 拿到交易哈希只是有了交易标识,不代表已入块并成功。③ 即使已有成功收据,也尚不能仅凭它推出最终性。每点分别补一种证据,不能把三点都写成“还没确认”。
English: (1) The simulation used a selected state/context; the actual transaction may execute later in a changed state. (2) A hash returned on submission proves neither inclusion nor successful execution. (3) Even successful inclusion does not alone establish finality.
各点 1 分。simulation / inclusion / execution success / finality 是不同层次,不用三种说法重复“还没上链”。
B19 · Q19 Work, stake and validator duties [12 marks]
(a) [4 marks] In Bitcoin’s proof-of-work model, explain how a miner searches for a valid block and why finding a valid header is harder than checking it. Does finding one guarantee that it becomes part of the eventual accepted history? Explain briefly.
(b) [6 marks] Describe the Ethereum validator’s path from a qualifying stake deposit to activation and active duties. Explain both block proposal and attestation, including how validators are assigned duties and why not every validator proposes every slot. Use the classroom’s 32 ETH entry example, but do not assume that historical queue rates or waiting times are permanent protocol constants.
(c) [2 marks] One selected proposer produces a block and one validator attests to it. That attester holds less than one third of total active effective balance. Does this alone establish finality? State the missing type of evidence and one example of slashable behavior, using the correct time unit or checkpoint relation.
B19 · 查看答案与解析
Q19(a) · Proof of work [4 marks]
推理过程:PoW(工作量证明)像按同一判定规则反复试候选:修改 nonce(区块头试算值)等区块头输入,计算哈希,看是否满足 target(目标阈值)。搜索者不知道哪次能中,要反复试;验证者已有候选,只需哈希并比较。最后还要检查其余区块内容和分支竞争,不能由“找到合格区块头”跳到“最终历史一定选它”。
English: The miner assembles a candidate block and varies header inputs, including the nonce, searching for a header hash that satisfies the target rule. It generally takes many trials to find a qualifying hash, while checking a candidate requires computing its hash and comparing it with the target. A valid PoW header is not sufficient if the rest of the block is invalid. Even a fully valid block can lose to a competing branch; Bitcoin’s accepted history depends on valid chainwork and subsequent extensions, not merely on discovering one block.
给分:候选区块及目标检查 1;试错与 nonce 1;查验比搜索容易 1;不是保证最终进入接受历史,说明有效性/竞争分支条件 1。不用背某个十六进制 target。回查:L02 p.60-73。
Q19(b) · Activation and duties [6 marks]
推理过程:按资格与任务两阶段讲:先满足存款等要求并经过处理、激活队列;激活后才承担协议分配的职责。proposal(区块提议)是选中者提出区块,attestation(验证者证明 / 投票)是验证者表达链头与检查点意见。slot(时隙)是一个出块时间窗口,epoch(时段)包含多个时隙;不是每个验证者每个窗口都提议区块。
English:
- The participant makes the qualifying deposit and supplies the required validator information; the lecture uses a 32 ETH entry example. [1]
- The deposit must be recognized and the validator must become eligible through the relevant processing/activation queues. Deposit inclusion is not immediate activation; delays depend on the protocol version and queue state. [1]
- After activation, the validator runs the necessary software and receives protocol-assigned duties. [1]
- A proposer is selected for a slot using protocol randomness with effective-balance weighting. Not every active validator is selected to propose every slot. [1]
- The proposer builds and broadcasts a block; other nodes check its validity. A missed proposal can leave a slot without a block. [1]
- Validators perform assigned attestation duties, voting on their chain view and checkpoint information. These votes support fork choice and finality under the protocol’s weighting and checkpoint rules. [1]
中文:按课件示例解释 entry threshold,不把“恰好 32 ETH”升级成所有版本所有验证者的永久余额上限。proposal 是提议区块;attestation 是证明/投票,不是所有人轮流挖矿。题目没有要求记忆队列吞吐、APR 或罚款系数,不能凭跨页截图拼一个永久常量。
回查:L02 p.76-97、p.100-104、p.123,连同末尾校订阅读。
Q19(c) · Finality and slashable behavior [2 marks]
推理过程:先看已有证据:一个提议,加一个权重不足三分之一的投票。再看最终性要求:相应超多数权重支持的检查点链接及最终确定条件。前者明显不能替代后者。举罚没例子时必须写清违规关系,例如同一验证者对同一目标时段签出不同证明,不能只写“投两次”。
English: No. Finality needs the appropriate supermajority-weighted checkpoint links and finalization conditions; one proposal and one attestation are insufficient. One slashable example is signing two different attestation data objects with the same target epoch.
给分:否定并点出超多数权重/检查点条件 1;准确罚没例子 1。也接受“同一 slot 的冲突区块提议”,或“source/target 区间严格包围”。不接受“同一块投了两次”这种未区分相同消息与冲突数据的描述。
词:head ≠ justified checkpoint ≠ finalized checkpoint;slot ≠ epoch。回查:L02 p.109-110、p.122 及校订。
B20 · Q20 Does a contract solve the whole business problem? [3 marks]
A charity replaces a centrally managed crowdfunding platform with an Ethereum contract. The contract can release funds automatically when an encoded funding threshold is reached. The charity claims this also guarantees that the promised physical aid will be delivered.
State one benefit, one remaining limitation, and one practical safeguard. Your safeguard should address the limitation you identified; do not claim that it eliminates every trust assumption.
B20 · 查看答案与解析
Q20 · Crowdfunding and physical delivery [3 marks]
推理过程:让收益、限制、措施一一对应:合约能按资金门槛自动执行拨款,这是规则执行的收益;实物有没有送到,属于链外事实,这是剩余限制;因此措施应围绕交付证据,如独立核验后分阶段放款。单说“再上链一次”没有增加真实交付证据,也就没有解决这个缺口。
English: A contract can transparently enforce the encoded funding and release rules, reducing reliance on an operator to apply those rules correctly. It cannot directly establish that physical aid was delivered. A staged escrow with independently checked delivery evidence and a defined dispute process can reduce that risk, but users still rely on the evidence providers and governance.
给分:一个具体机制收益 1;链下交付真实性限制 1;匹配限制且保留信任边界的措施 1。独立审计、分阶段拨款、争议处理等合理组合可替代,不要求照抄 escrow。题目要求提出措施,例子是应用推理,不是新协议考点。回查:L04a p.30-34;L01 的 DApp/区块链适用性讨论。
个人整理的学习笔记,不是官方材料;数字与结论以课件和讲师为准。