← COMP5565 全部讲次
Q11

期末练习|A 单选题

期末自拟练习,英文题干,逐题折叠中文解析、英文参考答案与课件页码。

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

使用边界:期末自拟练习,非官方材料。没有往年期末卷可对照,题型、分值和时长只是练习安排;正式范围、题型、时长和开闭卷要求以讲师通知为准。题干全部自拟;课件与官方文档说法不同时按课件作答,并在解析里注明差异。

复习资料:范围与以太坊、Solidity 要点 · Fabric 与选型要点 · 必背与闪卡

先做题再看解析:A 单选题 · B 短题 · C 长题

统一约定:Solidity 为 0.8.x,默认检查算术溢出;Fabric 题按课件的读写集与版本模型。页码一律用 PDF 页序。

练习安排:15 题,每题 2 分,建议 25 分钟。

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

来源代号:L02 = Lecture2.pdf;L03 = Lecture3.pdf;L04b = Lecture 4.1.pdf;L05 = Lecture 5.pdf;L06 = Lecture 6 - v3.pdf;L07 = Lecture 7.pdf;L08 = Lecture 8.pdf。来源为对应逐讲注解。

A · 单选题

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

A1 · Permissioned chains

Which statements about permissioned blockchains are correct?

I. Because membership is controlled, a classic BFT-style consensus protocol is sufficient.
II. Nodes are not rewarded with a native cryptocurrency, so no mining reward is needed.
III. Any anonymous node may join as a validator; this is how permissioned chains resist Sybil attacks.

A. I only
B. I and II
C. II and III
D. I, II and III

A1 · 查看答案与解析

A1 · B(I and II)。

推理过程:I 对:成员受控,节点数少且身份已知,经典 BFT 共识就够用。II 对:许可链不靠挖矿奖励激励节点,Fabric 也没有原生加密货币。III 错:许可链防 Sybil 靠的正是受控成员、证书、MSP 和治理,匿名节点不能随意加入。

English: Permissioned chains control membership, so classic BFT consensus is enough and no rewards or fees are needed. Sybil attacks are prevented by controlled membership and certificates.

回查:L06 p.8–9、p.19、p.21–23。

A2 · Endorsing peers

In the execute phase of Fabric’s execute-order-validate flow, which statements about an endorsing peer are correct?

I. It simulates the chaincode against its local copy of the world state.
II. It updates its own ledger with the simulated result before replying.
III. It returns the read-write set together with its signature.

A. I only
B. I and III
C. II and III
D. I, II and III

A2 · 查看答案与解析

A2 · B(I and III)。

推理过程:I 对:背书节点在本地世界状态上模拟执行链码。III 对:模拟结果是读写集,节点签名后返回给客户端。II 错:背书阶段只模拟、不更新账本;账本要等排序出块、验证通过后才更新。

English: Endorsing peers simulate the chaincode on their local world state and return a signed read-write set. They do not update the ledger.

回查:L06 p.49–51。

A3 · Ordering service

According to the Fabric lecture, what does the ordering service do?

A. It re-executes the chaincode to confirm each endorsement.
B. It puts transactions into one total order, cuts blocks and delivers them to peers.
C. It runs the version (MVCC) check and drops stale transactions before building a block.
D. It keeps the world state so that clients can query current values from it.

A3 · 查看答案与解析

A3 · B。

推理过程:课件里排序服务只做三件事:全序、打包成块、分发给 peer。A 错:排序节点不执行链码,也不背书。C 错:版本(MVCC)检查由各 peer 在验证阶段做,排序节点不丢弃过期交易。D 错:世界状态在 peer 上,课件称排序服务 stateless。课件 vs 官方:课件说排序服务不检查交易内容;官方文档里排序服务会按通道的写入策略核对提交者身份,但仍不执行链码、不查读写集。

English: The ordering service establishes a total order of transactions, packages them into blocks and distributes the blocks. It does not execute chaincode or keep the world state.

回查:L06 p.26、p.52–53、p.73、p.87。

A4 · A transaction that fails validation

A committing peer finds that transaction T fails the version (MVCC) check. Which statements are correct?

I. T stays in the block that the peer appends to its blockchain.
II. T’s write set is still applied to the world state.
III. T is marked invalid.

A. I only
B. II only
C. I and III
D. II and III

A4 · 查看答案与解析

A4 · C(I and III)。

推理过程:I 对:无效交易仍留在区块里,链上留有记录。III 对:peer 把它标记为 invalid。II 错:无效交易的写集不改世界状态,否则版本检查就失去意义。

English: An invalid transaction stays in the block and is marked invalid, but its write set does not update the world state.

回查:L06 p.23、p.30、p.54。

A5 · Endorsement policy

A chaincode definition uses the policy OR(AND('Org1MSP.peer','Org2MSP.peer'),'Org3MSP.peer'). Which endorsement sets satisfy it?

I. One peer of Org1 and one peer of Org2
II. One peer of Org3 only
III. Two peers of Org2

A. I only
B. I and II
C. II and III
D. I, II and III

A5 · 查看答案与解析

A5 · B(I and II)。

推理过程:策略读作「Org1 与 Org2 同时背书」或「Org3 单独背书」。I 满足前一支,II 满足后一支。III 错:两个 Org2 peer 仍缺 Org1,AND 不成立,也没有 Org3。

English: OR(AND(Org1, Org2), Org3) is satisfied by Org1 and Org2 together, or by Org3 alone.

回查:L06 p.64–66。

A6 · Channels

Peer P1 joins only channel C1. Peer P2 joins channels C1 and C2. Which statements are correct?

I. P2 keeps a separate ledger for C1 and for C2.
II. P1 can read C2’s transactions because it shares C1 with P2.
III. All peers of C1 see C1’s transactions in the same order.

A. I only
B. I and III
C. II and III
D. I, II and III

A6 · 查看答案与解析

A6 · B(I and III)。

推理过程:I 对:每个通道是独立的区块链,加入两个通道的 peer 维护两本账本。III 对:同一通道内所有 peer 看到相同的交易顺序。II 错:通道之间有隐私隔离,P1 没加入 C2 就读不到 C2,和谁共享 C1 无关。

English: Each channel is a separate blockchain. A peer may join several channels and keeps one ledger per channel. Peers outside a channel cannot see its transactions.

回查:L06 p.91–94。

A7 · Root CA

Which statements about a root CA certificate are correct?

I. It is self-signed.
II. The verifier must already trust it, for example by having it pre-installed.
III. It is signed by an intermediate CA lower in the chain.

A. I only
B. I and II
C. II and III
D. I, II and III

A7 · 查看答案与解析

A7 · B(I and II)。

推理过程:I 对:根 CA 证书由自己签名。II 对:信任链要停在一张验证方事先信任的根证书上,所以根证书须预装。III 错:签名方向相反,根 CA 签中间 CA,中间 CA 再签终端证书。

English: A root CA certificate is self-signed and must be pre-installed as a trust anchor. Root CAs sign intermediate CAs, which sign end-entity certificates.

回查:L07 p.17–18、p.49。

A8 · Local and channel MSP

Which statements about Local MSP and Channel MSP are correct?

I. A Local MSP lives on a node’s file system and can hold that node’s private key.
II. A Channel MSP stores the private keys of every member so the channel can check signatures.
III. Every organisation that participates in a channel needs a Channel MSP definition.

A. I only
B. I and III
C. II and III
D. I, II and III

A8 · 查看答案与解析

A8 · B(I and III)。

推理过程:I 对:Local MSP 在节点或用户的文件系统里,keystore 存本地私钥。III 对:参加通道的每个组织都要有 Channel MSP,通道才能识别它的成员。II 错:Channel MSP 由共识在通道内同步,只含证书等公开信息,不含任何私钥。

English: A Local MSP is per node or user, stored on the file system, and includes the private key. A Channel MSP is shared at channel level and holds no private keys; every participating organisation needs one.

回查:L07 p.28、p.61–64。

A9 · Six-question flow

Four logistics firms each write shipment records, and all writers are known. All four agree to rely on one always-online third party, trusted by every firm, to run the shared database. What does the six-question flow conclude?

A. Private permissioned blockchain
B. Public permissioned blockchain
C. Permissionless blockchain
D. Do not use a blockchain

A9 · 查看答案与解析

A9 · D。

推理过程:存状态 yes,多写入方 yes,第三问「能否用一直在线、可信的第三方」答 yes,流程在这里直接出局:Don’t use。A、B 要求第三问答 no 且写入方不全可信;C 要求写入方未知。题面写明各方都信任这个第三方,所以走不到后面几问。

English: If an always-online trusted third party is acceptable, use it; a blockchain is not needed.

回查:L08 p.4–5。

A10 · Proof of stake

Which statements about Ethereum proof of stake are correct?

I. Attestations are weighted by stake, so the two-thirds majority is counted by deposited stake, not by head count.
II. The RANDAO value of epoch N is used in epoch N+2.
III. Finality takes two epochs, about 13 minutes.

A. I only
B. I and II
C. II and III
D. I, II and III

A10 · 查看答案与解析

A10 · D(I, II and III)。

推理过程:I 对:attestation 按存款加权,2/3 指存款总额。II 对:epoch N 的 RANDAO 用在 epoch N+2,两个 epoch 的延迟用来防操纵。III 对:最终性约 2 个 epoch,2 × 6.4 分钟约 13 分钟。

English: Votes are weighted by stake; RANDAO from epoch N seeds epoch N+2; finality takes about two epochs, roughly 13 minutes.

回查:L02 p.93–94、p.100–101、p.122。

A11 · Slashable behaviour

Which validator behaviours are slashable offences in the lecture?

I. Proposing two different blocks for the same slot
II. Making an attestation whose source–target span strictly surrounds an earlier attestation of the same validator
III. Staying offline and missing attestations for several epochs

A. I only
B. I and II
C. II and III
D. I, II and III

A11 · 查看答案与解析

A11 · B(I and II)。

推理过程:课件列出三种可罚没行为:double proposal、double vote、surround vote。I 是 double proposal,II 是 surround vote。III 错:离线只是少拿奖励或被扣惩罚,不在这三种罚没行为里。

English: Slashable offences are double proposal, double vote and surround vote. Being offline is not one of them.

回查:L02 p.107–110。

A12 · Delegatecall context

EOA Alice calls contract B. B uses delegatecall to run code from contract C. While C’s code runs, what is msg.sender, and whose storage is written?

A. msg.sender is B; C’s storage is written.
B. msg.sender is Alice; C’s storage is written.
C. msg.sender is Alice; B’s storage is written.
D. msg.sender is B; B’s storage is written.

A12 · 查看答案与解析

A12 · C。

推理过程:delegatecall 把 C 的代码搬到 B 的上下文里跑:msg.sender 保留进入 B 时的调用者 Alice,读写的是 B 的存储。A 是普通 call 的结果。B 混了两种调用:sender 按 delegatecall 算,存储却按 call 算。D 的 sender 写成了 B;B 只发起 delegatecall,没有成为新一层调用者。

English: With delegatecall, C’s code runs in B’s context: msg.sender stays Alice and B’s storage changes.

回查:L04b p.68–70。

A13 · Token standards

Which statements about ERC-20 and ERC-721 are correct?

I. Each ERC-721 token has a unique tokenId and an ownerOf lookup.
II. ERC-20 tokens are native Ether-like assets held in each account’s balance field.
III. approve, allowance and transferFrom let another address spend tokens on the owner’s behalf.

A. I only
B. I and III
C. II and III
D. I, II and III

A13 · 查看答案与解析

A13 · B(I and III)。

推理过程:I 对:ERC-721 每个 token 有唯一 tokenId,可用 ownerOf 查归属。III 对:approve / allowance / transferFrom 三件套让合约替你花币。II 错:ERC-20 代币不是原生资产,余额记在代币合约自己的映射表里,账户状态里的 balance 只记 ether。

English: An ERC-20 token is a balance table inside a contract. ERC-721 gives each token a unique tokenId with ownerOf. approve, allowance and transferFrom allow delegated spending.

回查:L03 p.17、p.20、p.28、p.30–33。

A14 · Access control

withdrawAll() must be callable only by the contract owner. Which design matches the lectures?

A. require(tx.origin == owner); at the start of the function
B. require(msg.sender == owner); inside an onlyOwner modifier
C. Declare owner as private so no one else can learn the owner’s address
D. Mark withdrawAll() as internal and let anyone reach it through fallback

A14 · 查看答案与解析

A14 · B。

推理过程:权限检查看直接调用者 msg.sender,写成 onlyOwner 修饰器复用。A 错:用 tx.origin 判断权限会被钓鱼合约利用,owner 被骗调用恶意合约时检查照样通过。C 错:private 只限制其他合约访问,链上数据全公开。D 错:fallback 谁都能触发,等于把函数开放给所有人。

English: Check msg.sender in an onlyOwner modifier. Never use tx.origin for authorisation; private does not hide data.

回查:L04b p.24、p.33、p.43–44;L05 p.31–34。

A15 · receive and fallback

A contract defines both receive() external payable and fallback() external payable. A transaction sends 1 ether with non-empty calldata whose selector matches no function. Which function runs?

A. receive
B. fallback
C. Neither; the call reverts
D. Both, receive first

A15 · 查看答案与解析

A15 · B。

推理过程:receive 只处理 calldata 为空的调用。calldata 非空且不匹配任何函数时走 fallback,它是 payable,所以能收下 1 ether。A 错:receive 的条件是空 calldata。C 错:只有没有可用的 fallback(或 fallback 不是 payable 却收到 ether)才会回退。D 错:一次调用只进入一个函数。

English: Empty calldata goes to receive; non-empty calldata that matches no function goes to fallback.

回查:L04b p.29–31。

作答后怎么复盘

先记录错题号,按 Fabric 流程 / 读写集 / 身份与证书 / 选型 / 以太坊共识 / Solidity 语法 六类归档。展开解析看错因,再把每个 I/II/III 陈述单独判一次对错,说出错在哪个词。

下一页 →
Q12 期末练习|B 短题

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