一. 交易执行细节
1 合约部署
在节点启动之前,会先去部署 L1 上的合约,L2 上的合约是预部署的,接口部分有 solidity 来编写,实现是由 go 代码来实现的,合约实现对应的 go 代码为 precompiles 项目的代码目录,接口定义为 /nitro/contracts/src/precompiles 的代码。
2.1 L1 上的合约部署
合约部署代码入口为/nitro/cmd/deploy/deploy.go
,
调用链:arbnode.DeployOnL1
-> deployRollupCreator
-> deployBridgeCreator deployChallengeFactory DeployRollupAdminLogic DeployRollupUserLogic
等
核心代码示例如下文章来源:https://www.toymoban.com/news/detail-624638.html
deployPtr, err := arbnode.DeployOnL1(
ctx,
l1client,
l1TransactionOpts,
sequencerAddress,
*authorizevalidators,
headerReaderConfig,
machineConfig,
arbnode.GenerateRollupConfig(*prod, common.HexToHash(*wasmmoduleroot), ownerAddress, l2ChainId, loserEscrowAddress),
)
rollupCreator, rollupCreatorAddress, validatorUtils, validatorWalletCreator, err := deployRollupCreator(ctx, l1Reader, deployAuth)
if err != nil {
return nil, fmt.Errorf("error deploying rollup creator: %w", err)
}
func deployRollupCreator(ctx context.Context, l1Reader *headerreader.HeaderReader, auth *bind.TransactOpts) (*rollupgen.RollupCreator, common.Address, common.Address, common.Address, error) {
bridgeCreator, err := deployBridgeCreator(ctx, l1Reader, auth)
if err != nil {
return nil, common.Address{}, common.Address{}, common.Address{}, err
}
ospEntryAddr, challengeManagerAddr, err := deployChallengeFactory(ctx, l1Reader, auth)
if err != nil {
return nil, common.Address{}, common.Address{}, common.Address{}, err
}
......
1.2 L2 上的合约部署
预部署合约, 执行 docker exec nitro_sequencer_1 cat /config/deployment.json
的时候会去部署一些合约, 部署生成的合约如下:文章来源地址https://www.toymoban.com/news/detail-624638.html
{
"l1Network": {
"blockTime": 10,
"chainID": 1337,
"explorerUrl": "",
"isCustom": true,
"name": "EthLocal",
"partnerChainIDs": [
412346,
412346
],
"rpcURL": "http://localhost:8545"
},
"l2Network": {
"chainID": 412346,
"confirmPeriodBlocks": 20,
"ethBridge": {
"bridge": "0x815b0ce130aa4c1db18ba0c4c92fcfbf6062ab08",
"inbox": "0x07061a11d42da58c7bd08ddbf4ef6e60232ba966",
"outbox": "0xE7098C657B3Ee7c92939f20A4E308efCdd656163",
"rollup": "0x532016aa3f129f35214559723aa7a0faa435f7ce",
"sequencerInbox": "0xda7b4b25cac35e41f62cf79744b7e4d50f177b64"
},
"explorerUrl": "",
"isArbitrum": true,
"isCustom": true,
"name": "ArbLocal",
"partnerChainID": 1337,
"rpcURL": "http://localhost:8547",
"retryableLifetimeSeconds": 604800,
"depositTimeout": 900000,
"tokenBridge": {
"l1CustomGateway": "0xDe67138B609Fbca38FcC2673Bbc5E33d26C5B584",
"l1ERC20Gateway": "0x0Bdb0992B3872DF911260BfB60D72607eb22d5d4",
"l1GatewayRouter": "0x4535771b8D5C43100f126EdACfEc7eb60d391312",
"l1MultiCall": "0x36BeF5fD671f2aA8686023dE4797A7dae3082D5F",
"l1ProxyAdmin": "0xF7818cd5f5Dc379965fD1C66b36C0C4D788E7cDB",
"l1Weth": "0x24067223381F042fF36fb87818196dB4D2C56E9B",
"l1WethGateway": "0xBa3d12E370a4b592AAF0CA1EF09971D196c27aAd",
"l2CustomGateway": "0x0Bdb0992B3872DF911260BfB60D72607eb22d5d4",
"l2ERC20Gateway": "0x4535771b8D5C43100f126EdACfEc7eb60d391312",
"l2GatewayRouter": "0xF7818cd5f5Dc379965fD1C66b36C0C4D788E7cDB",
"l2Multicall": "0x14a00f381A870878Ae6A055C656520FF2Cbff985",
"l2ProxyAdmin": "0x8c366Cfd28bC93729e14Da4fcf94d20862A7f266",
"l2Weth": "0x9b890cA9dE3D317b16
到了这里,关于Arbitrum 的 Nitro 项目启动和交易执行源码解析的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!