Commit 206f6033 authored by Maurelian's avatar Maurelian Committed by GitHub

ctb: Fix outdated references to 'withdrawal contract' (#3497)

Co-authored-by: default avatarmergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
parent 9bb9fb28
---
'@eth-optimism/contracts-bedrock': patch
'@eth-optimism/core-utils': patch
'@eth-optimism/integration-tests-bedrock': patch
'@eth-optimism/sdk': patch
---
Fix outdated references to 'withdrawal contract'
This diff is collapsed.
......@@ -219,10 +219,10 @@ func FinalizeWithdrawalParameters(ctx context.Context, l2client ProofClient, txH
BlockNumber: new(big.Int).Set(header.Number),
Data: ev.Data,
OutputRootProof: bindings.TypesOutputRootProof{
Version: [32]byte{}, // Empty for version 1
StateRoot: header.Root,
WithdrawerStorageRoot: p.StorageHash,
LatestBlockhash: header.Hash(),
Version: [32]byte{}, // Empty for version 1
StateRoot: header.Root,
MessagePasserStorageRoot: p.StorageHash,
LatestBlockhash: header.Hash(),
},
WithdrawalProof: withdrawalProof,
}, nil
......@@ -235,7 +235,8 @@ var (
AddressType, _ = abi.NewType("address", "", nil)
)
// WithdrawalHash computes the hash of the withdrawal that was stored in the L2 withdrawal contract state.
// WithdrawalHash computes the hash of the withdrawal that was stored in the L2toL1MessagePasser
// contract state.
// TODO:
// - I don't like having to use the ABI Generated struct
// - There should be a better way to run the ABI encoding
......
......@@ -119,8 +119,8 @@ contract OptimismPortal is Initializable, ResourceMetering, Semver {
*
* @param _tx Withdrawal transaction to finalize.
* @param _l2BlockNumber L2 block number of the outputRoot.
* @param _outputRootProof Inclusion proof of the withdrawer contracts storage root.
* @param _withdrawalProof Inclusion proof for the given withdrawal in the withdrawer contract.
* @param _outputRootProof Inclusion proof of the L2ToL1MessagePasser contract's storage root.
* @param _withdrawalProof Inclusion proof of the withdrawal in L2ToL1MessagePasser contract.
*/
function finalizeWithdrawalTransaction(
Types.WithdrawalTransaction memory _tx,
......@@ -163,13 +163,13 @@ contract OptimismPortal is Initializable, ResourceMetering, Semver {
// and to prevent replay attacks.
bytes32 withdrawalHash = Hashing.hashWithdrawal(_tx);
// Verify that the hash of this withdrawal was stored in the withdrawal contract on L2. If
// this is true, then we know that this withdrawal was actually triggered on L2 can can
// therefore be relayed on L1.
// Verify that the hash of this withdrawal was stored in the L2toL1MessagePasser contract on
// L2. If this is true, then we know that this withdrawal was actually triggered on L2
// and can therefore be relayed on L1.
require(
_verifyWithdrawalInclusion(
withdrawalHash,
_outputRootProof.withdrawerStorageRoot,
_outputRootProof.messagePasserStorageRoot,
_withdrawalProof
),
"OptimismPortal: invalid withdrawal inclusion proof"
......
......@@ -164,7 +164,7 @@ library Hashing {
abi.encode(
_outputRootProof.version,
_outputRootProof.stateRoot,
_outputRootProof.withdrawerStorageRoot,
_outputRootProof.messagePasserStorageRoot,
_outputRootProof.latestBlockhash
)
);
......
......@@ -23,7 +23,7 @@ library Types {
struct OutputRootProof {
bytes32 version;
bytes32 stateRoot;
bytes32 withdrawerStorageRoot;
bytes32 messagePasserStorageRoot;
bytes32 latestBlockhash;
}
......
......@@ -538,7 +538,7 @@ contract FFIInterface is Test {
function hashOutputRootProof(
bytes32 _version,
bytes32 _stateRoot,
bytes32 _withdrawerStorageRoot,
bytes32 _messagePasserStorageRoot,
bytes32 _latestBlockhash
) external returns (bytes32) {
string[] memory cmds = new string[](7);
......@@ -547,7 +547,7 @@ contract FFIInterface is Test {
cmds[2] = "hashOutputRootProof";
cmds[3] = Strings.toHexString(uint256(_version));
cmds[4] = Strings.toHexString(uint256(_stateRoot));
cmds[5] = Strings.toHexString(uint256(_withdrawerStorageRoot));
cmds[5] = Strings.toHexString(uint256(_messagePasserStorageRoot));
cmds[6] = Strings.toHexString(uint256(_latestBlockhash));
bytes memory result = vm.ffi(cmds);
......
......@@ -90,13 +90,13 @@ contract Hashing_Test is CommonTest {
function test_hashOutputRootProof_differential(
bytes32 _version,
bytes32 _stateRoot,
bytes32 _withdrawerStorageRoot,
bytes32 _messagePasserStorageRoot,
bytes32 _latestBlockhash
) external {
Types.OutputRootProof memory proof = Types.OutputRootProof({
version: _version,
stateRoot: _stateRoot,
withdrawerStorageRoot: _withdrawerStorageRoot,
messagePasserStorageRoot: _messagePasserStorageRoot,
latestBlockhash: _latestBlockhash
});
......@@ -105,7 +105,7 @@ contract Hashing_Test is CommonTest {
bytes32 _hash = ffi.hashOutputRootProof(
_version,
_stateRoot,
_withdrawerStorageRoot,
_messagePasserStorageRoot,
_latestBlockhash
);
......
......@@ -293,7 +293,7 @@ contract OptimismPortal_FinalizeWithdrawal_Test is Portal_Initializer {
_outputRootProof = Types.OutputRootProof({
version: bytes32(uint256(0)),
stateRoot: _stateRoot,
withdrawerStorageRoot: _storageRoot,
messagePasserStorageRoot: _storageRoot,
latestBlockhash: bytes32(uint256(0))
});
_proposedBlockNumber = oracle.nextBlockNumber();
......@@ -432,7 +432,7 @@ contract OptimismPortal_FinalizeWithdrawal_Test is Portal_Initializer {
Types.OutputRootProof memory outputRootProof = Types.OutputRootProof({
version: bytes32(0),
stateRoot: stateRoot,
withdrawerStorageRoot: storageRoot,
messagePasserStorageRoot: storageRoot,
latestBlockhash: bytes32(0)
});
vm.mockCall(
......@@ -494,7 +494,7 @@ contract OptimismPortal_FinalizeWithdrawal_Test is Portal_Initializer {
Types.OutputRootProof memory outputRootProof = Types.OutputRootProof({
version: bytes32(0),
stateRoot: stateRoot,
withdrawerStorageRoot: storageRoot,
messagePasserStorageRoot: storageRoot,
latestBlockhash: bytes32(0)
});
......@@ -555,7 +555,7 @@ contract OptimismPortal_FinalizeWithdrawal_Test is Portal_Initializer {
Types.OutputRootProof memory proof = Types.OutputRootProof({
version: bytes32(uint256(0)),
stateRoot: stateRoot,
withdrawerStorageRoot: storageRoot,
messagePasserStorageRoot: storageRoot,
latestBlockhash: bytes32(uint256(0))
});
......
......@@ -146,7 +146,7 @@ const command = args[0]
case 'hashOutputRootProof': {
const version = hexZeroPad(BigNumber.from(args[1]).toHexString(), 32)
const stateRoot = hexZeroPad(BigNumber.from(args[2]).toHexString(), 32)
const withdrawerStorageRoot = hexZeroPad(
const messagePasserStorageRoot = hexZeroPad(
BigNumber.from(args[3]).toHexString(),
32
)
......@@ -158,7 +158,7 @@ const command = args[0]
const hash = hashOutputRootProof({
version,
stateRoot,
withdrawerStorageRoot,
messagePasserStorageRoot,
latestBlockhash,
})
const output = utils.defaultAbiCoder.encode(['bytes32'], [hash])
......@@ -211,7 +211,7 @@ const command = args[0]
const outputRoot = hashOutputRootProof({
version: constants.HashZero,
stateRoot: bufferToHex(world.root),
withdrawerStorageRoot: bufferToHex(storage.root),
messagePasserStorageRoot: bufferToHex(storage.root),
latestBlockhash: constants.HashZero,
})
......
......@@ -25,7 +25,7 @@ export interface BedrockOutputData {
export interface OutputRootProof {
version: string
stateRoot: string
withdrawerStorageRoot: string
messagePasserStorageRoot: string
latestBlockhash: string
}
......@@ -162,7 +162,7 @@ export const hashOutputRootProof = (proof: OutputRootProof): string => {
[
proof.version,
proof.stateRoot,
proof.withdrawerStorageRoot,
proof.messagePasserStorageRoot,
proof.latestBlockhash,
]
)
......
......@@ -241,7 +241,7 @@ describe('Withdrawals', () => {
{
version: constants.HashZero,
stateRoot: targetStateRoot,
withdrawerStorageRoot: proof.storageHash,
messagePasserStorageRoot: proof.storageHash,
latestBlockhash: targetHash,
},
rlp.encode(proof.storageProof[0].proof),
......
......@@ -1306,7 +1306,7 @@ export class CrossChainMessenger {
// TODO: Handle multiple versions in the future
version: ethers.constants.HashZero,
stateRoot: block.stateRoot,
withdrawerStorageRoot: stateTrieProof.storageRoot,
messagePasserStorageRoot: stateTrieProof.storageRoot,
latestBlockhash: block.hash,
},
withdrawalProof: ethers.utils.RLP.encode(stateTrieProof.storageProof),
......@@ -1691,7 +1691,7 @@ export class CrossChainMessenger {
[
proof.outputRootProof.version,
proof.outputRootProof.stateRoot,
proof.outputRootProof.withdrawerStorageRoot,
proof.outputRootProof.messagePasserStorageRoot,
proof.outputRootProof.latestBlockhash,
],
proof.withdrawalProof,
......
......@@ -82,10 +82,10 @@ where:
inclusion in the pre-image of the `latest_block_hash`. This reduces the merkle proof depth and cost of accessing the
L2 state root on L1.
1. The `withdrawal_storage_root` (`bytes32`) elevates the Merkle-Patricia-Trie ([MPT][g-mpt]) root of the [L2 Withdrawal
contract](./withdrawals.md#the-l2tol1messagepasser-contract) storage. Instead of making an MPT proof for a withdrawal
against the state root (proving first the storage root of the L2 withdrawal contract against the state root, then
the withdrawal against that storage root), we can prove against the L2 withdrawal contract's storage root directly,
1. The `withdrawal_storage_root` (`bytes32`) elevates the Merkle-Patricia-Trie ([MPT][g-mpt]) root of the [Message
Passer contract](./withdrawals.md#the-l2tol1messagepasser-contract) storage. Instead of making an MPT proof for a
withdrawal against the state root (proving first the storage root of the L2toL1MessagePasser against the state root,
then the withdrawal against that storage root), we can prove against the L2toL1MessagePasser's storage root directly,
thus reducing the verification cost of withdrawals on L1.
## L2 Output Oracle Smart Contract
......
......@@ -21,9 +21,9 @@ more specific terms to differentiate:
- A *withdrawal finalizing transaction* refers specifically to an L1 transaction which finalizes and relays the
withdrawal.
Withdrawals are initiated on L2 via a call to the Withdrawals predeploy contract, which records the important properties
of the message in its storage. Withdrawals are finalized on L1 via a call to the `L2WithdrawalVerifier` contract, which
proves the inclusion of this withdrawal message.
Withdrawals are initiated on L2 via a call to the Message Passer predeploy contract, which records the important
properties of the message in its storage. Withdrawals are finalized on L1 via a call to the `L2WithdrawalVerifier`
contract, which proves the inclusion of this withdrawal message.
In this way, withdrawals are different from [deposits][g-deposits] which make use of a special transaction type in the
[execution engine][g-execution-engine] client. Rather, withdrawals transaction must use smart contracts on L1 for
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment