← COMP5565 全部讲次
Q02

期中复习题|B 单选题

英文题干,逐题折叠中文解析、英文参考答案与适用条件。

手机上宽表格可左右滑动;自测答案默认收起,点击题目下方按钮查看。

使用边界:2026-10-13 期中复习,非官方材料;正式范围、题型、时长和开闭卷要求以讲师通知为准。保留课件版本、适用条件与补充标注。

复习资料:密码学、账户与 Gas · 共识、钱包与代币 · Solidity、调用与代理 · DApp 签名与英文作答

先做题再看解析:A 判断题 · B 单选题 · C 计算题 · D 代码推演 · E 简答与 X 选做补练

统一约定:除题目另说,Solidity 为 0.8.30、默认检查算术溢出;账户按普通 EOA 发起交易的课堂模型,不讨论账户代码委托。代码是隔离的教学片段,不是生产合约;假设有足够 gas,且不存在题面未给出的外部操作。金额计算忽略题面之外的费用。页码回查一律使用 PDF 页序。

自查分值仅供练习,不代表教师评分标准;先作答,再展开每题答案。

来源代号:C01 = Lecture crypto foundation.pdf;L01 = Lecture1.pdf;L02 = Lecture2.pdf;L03 = Lecture3.pdf;L04a = Lecture 4.0.pdf;L04b = Lecture 4.1.pdf;L05 = Lecture 5.pdf。页码都是 PDF 页序。来源为对应逐讲注解;标“补充”的部分另列标准文档。所有题干均为自拟。

B · 单选题

每题 2 分,无多选。Choose the one best answer.

B1 · Single best answer

Which tuple represents the four account-state fields discussed in the Ethereum lecture?

A. address, privateKey, publicKey, balance
B. nonce, balance, storageRoot, codeHash
C. nonce, gasLimit, baseFee, signature
D. stateRoot, transactionRoot, receiptRoot, timestamp

B1 · 查看答案与解析

B1 · B。 nonce / balance / storageRoot / codeHash。地址是账户标识,不是这四字段之一;私钥不存进公开账户状态。L02 p.19-21。

推理过程:按对象排除:A 把账户标识和私钥材料混进公开状态;C 混入交易的费用与签名信息;D 混入区块层面的根哈希和时间戳。B 才全部是账户状态字段:nonce(账户计数器)、balance(余额)、storageRoot(存储根)、codeHash(代码哈希)。先认清“账户这一层”,再背四个名字。普通 EOA 的账户 nonce 是下一笔可接受交易的序号;交易字段里的 nonce 要与它匹配。

B2 · Single best answer

Which transaction is a contract-creation transaction in the classroom model?

A. A transaction sent to the all-zero address with empty data.
B. Any transaction carrying nonempty data.
C. A transaction with an absent destination and creation code in its data.
D. Any transaction signed by an account that has never sent a transaction.

B2 · 查看答案与解析

B2 · C。 创建交易的 destination 缺省,data 携带创建代码。向全零地址转账不等于创建合约,普通函数调用也能有非空 data。L02 p.41;L04b p.3-5。

推理过程:看两个条件是否同时成立:没有普通接收地址,并在 data 中携带创建代码,符合 C。A 的全零地址仍是一个指定地址;B 的非空 data 也可能用于调用已有合约;D 的“从未发过交易”描述账户历史,不决定这笔交易是不是部署。调用工厂合约可以在执行中创建子合约,但那仍不是本题所问的顶层“合约创建交易”类型。

B3 · Single best answer

Which pair of attestations by the same validator satisfies the double-vote condition?

A. Two identical copies of the same attestation data.
B. Any two attestations with the same source epoch.
C. Two attestations made in different target epochs.
D. Two distinct attestation data objects with the same target epoch.

B3 · 查看答案与解析

B3 · D。 Double vote 要同时满足 distinct attestation data 和 same target epoch。完全相同的证明被重复传播不等于两份冲突证明;source 相同也不足以认定双投。L02 p.109 与概念校订。

推理过程:先固定“同一验证者”,再检查两项:证明数据不同、target epoch(目标时段)相同,故选 D。A 只是相同数据再传一次;B 只给相同 source(源检查点),缺少目标条件;C 的 target 不同,不满足双重投票条件。不要把双重投票译成笼统的“重复发消息”。

B4 · Single best answer

What is a standard ABI function selector?

A. The first four bytes of the Keccak-256 hash of the canonical function signature.
B. The caller’s ECDSA signature.
C. The last twenty bytes of the implementation address.
D. A hash of the function’s source code and return value.

B4 · 查看答案与解析

B4 · A。 例如 transfer(address,uint256) 是 canonical function signature;selector 是其 Keccak-256 的前 4 字节。这里的 function signature 不是数字签名。L04b p.23、p.71;补充 ABI 规范。

推理过程:先写规范化函数签名文本,例如 transfer(address,uint256),再取 Keccak-256,最后取前 4 字节,这才是 selector(函数选择器)。B 是数字签名;C 是地址字节;D 把源码与返回值拿来哈希。它们都不是 ABI 规定的函数识别方法。

B5 · Single best answer

Under ordinary ERC-20 semantics, what does approve(spender, amount) do?

A. It immediately transfers amount tokens to spender.
B. It sets the spender’s allowance; approval alone does not transfer tokens.
C. It gives the spender the token owner’s private key.
D. It guarantees that every later transferFrom succeeds.

B5 · 查看答案与解析

B5 · B。 approve 设置额度,实际转移由后续有效的 transferFrom 等操作完成,还须余额和授权等条件成立。L03 p.20、p.28;ERC-20。

推理过程:approve 修改的是 allowance(授权额度)记录,故选 B。A 把授权误当转账;C 把额度授权误当泄露私钥;D 忽略了后续余额不足等可能性。可把它读成“允许对方以后代我转多少”,实际转移仍要后续有效调用。

B6 · Single best answer

Which statement about an eth_call simulation is correct?

A. It commits simulated state changes to the blockchain.
B. It guarantees that a later transaction executes with the same state.
C. It executes against a selected state without committing those state changes.
D. It never runs EVM code.

B6 · 查看答案与解析

B6 · C。 eth_call 做执行模拟,不提交其中的状态变化;状态可能在之后变化,所以不担保真正发交易时也成功。它与 Solidity 的 view 不是同一个概念。L05 p.47-48;补充 Ethereum JSON-RPC。

推理过程:eth_call 让节点在选定状态上试运行 EVM 代码,但不把试算的状态变化提交上链,故选 C。A 错在“提交”;D 错在“没有执行代码”;B 错在忽略真正交易执行前状态可能变化。simulation(模拟)提供一次试算结果,不是未来结果的保证。

B7 · Single best answer

Why is publishing only H(choice) a weak hiding mechanism when choice is Rock, Paper, or Scissors?

A. Every hash function is reversible.
B. A 256-bit digest reveals the sender’s private key.
C. Hash collisions must occur among the three choices.
D. An observer can hash all three candidate choices and compare them.

B7 · 查看答案与解析

B7 · D。 三种候选逐一哈希即可枚举,不需要反转哈希,也不需要找碰撞。秘密输入空间太小,不能只凭“哈希不可逆”就保证 hiding。L03 p.12-14。

推理过程:观察者分别算 H(rock)、H(paper)、H(scissors),再与公布值比较即可,故选 D。这是正向枚举候选输入;A 的反向破解不需要,B 的私钥泄露无依据,C 的碰撞也不是攻击前提。hiding(隐藏性)失败的原因是候选太少。

B8 · Single best answer

What does a successful transaction receipt establish by itself?

A. The transaction executed successfully in the block represented by that receipt; this alone is not a proof of finality.
B. The transaction can never be affected by any reorganization.
C. Every user has already seen the new state.
D. The application has no security vulnerabilities.

B8 · 查看答案与解析

B8 · A。 receipt 的成功状态与 finality 是两种事实。还需说明链、区块和所用确认/最终性条件;不能从收据推导程序无漏洞。L02 p.122 的最终性、L05 p.48 的 Web3 交易流程。

推理过程:收据记录的是该区块中这笔交易的执行结果,因此 A 的范围恰当。B 把入块成功升级成不可重组;C 把执行结果升级成所有用户都看到了;D 把执行没报错升级成业务没有漏洞。receipt(交易收据)和 finality(最终性)回答不同的问题。

作答后怎么复盘

先记录错题号,再分成 概念 / 英文限定词 / 算术与单位 / 调用帧与状态 / 版本与条件 五类。展开对应题目的解析看错因,遮住答案后换一组数字或条件再答一次。不要只背 T/F 和选项字母。

下一页 →
Q03 期中复习题|C 计算题

个人整理的学习笔记,不是官方材料;数字与结论以课件和讲师为准。