diff --git a/.github/workflows/contracts-l1-tests.yaml b/.github/workflows/contracts-l1-tests.yaml new file mode 100644 index 0000000000000..4bf7c87397b05 --- /dev/null +++ b/.github/workflows/contracts-l1-tests.yaml @@ -0,0 +1,49 @@ +name: L1 Contracts Tests + +on: + pull_request: + push: + branches: + - "celo-integration*" + - "main" + - "develop" + workflow_dispatch: + +jobs: + contracts-test: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Install Foundry + uses: foundry-rs/foundry-toolchain@v1 + with: + version: nightly-654c8f01721e43dbc8a53c7a3b022548cb82b2f9 + + - name: Install Just + uses: extractions/setup-just@v2 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: '1.23' + + - name: Install dependencies + working-directory: packages/contracts-bedrock + run: just install + + - name: Build go-ffi + working-directory: packages/contracts-bedrock + run: just build-go-ffi + + - name: Check formatting + working-directory: packages/contracts-bedrock + run: forge fmt --check + + - name: Run L1 contracts tests + working-directory: packages/contracts-bedrock + run: forge test --match-path "test/L1/*.t.sol" -vv + diff --git a/espresso/.env b/espresso/.env index 26de758565de3..f72d1f6a9908d 100644 --- a/espresso/.env +++ b/espresso/.env @@ -43,6 +43,9 @@ BATCH_AUTHENTICATOR_OWNER_PRIVATE_KEY=0x7c852118294e51e653712a81e05800f419141751 # cast wallet address --mnemonic "test test ... junk" --hd-path "m/44'/60'/0'/0/1" PROPOSER_ADDRESS=0x70997970C51812dc3A010C7d01b50e0d17dc79C8 +# cast wallet address --mnemonic "test test ... junk" --hd-path "m/44'/60'/0'/0/5" +NON_TEE_BATCHER_ADDRESS=0x9965507D1a55bcC2695C58ba16FB37d819B0A4dc + L1_CHAIN_ID=11155111 L2_CHAIN_ID=22266222 diff --git a/espresso/scripts/prepare-allocs.sh b/espresso/scripts/prepare-allocs.sh index 8a827be6be3ef..1dce7713be2b9 100755 --- a/espresso/scripts/prepare-allocs.sh +++ b/espresso/scripts/prepare-allocs.sh @@ -73,7 +73,10 @@ op-deployer init --l1-chain-id "${L1_CHAIN_ID}" \ --outdir ${DEPLOYER_DIR} dasel put -f "${DEPLOYER_DIR}/intent.toml" -s .chains.[0].espressoEnabled -t bool -v true -dasel put -f "${DEPLOYER_DIR}/intent.toml" -s .chains.[0].preApprovedBatcherKey -v "${OPERATOR_ADDRESS}" +# Use a distinct address for the non-TEE batcher to satisfy the BatchInbox constructor +# In devnet we reuse the proposer address for the non-TEE batcher role. +dasel put -f "${DEPLOYER_DIR}/intent.toml" -s .chains.[0].nonTeeBatcher -v "${OPERATOR_ADDRESS}" +dasel put -f "${DEPLOYER_DIR}/intent.toml" -s .chains.[0].teeBatcher -v "${OPERATOR_ADDRESS}" dasel put -f "${DEPLOYER_DIR}/intent.toml" -s .l1ContractsLocator -v "${ARTIFACTS_DIR}" dasel put -f "${DEPLOYER_DIR}/intent.toml" -s .l2ContractsLocator -v "${ARTIFACTS_DIR}" dasel put -f "${DEPLOYER_DIR}/intent.toml" -s .opcmAddress -v `jq -r .opcmAddress < ${DEPLOYER_DIR}/bootstrap_implementations.json` diff --git a/op-batcher/bindings/batch_authenticator.go b/op-batcher/bindings/batch_authenticator.go index fdd512720c2c4..8664456ee6d29 100644 --- a/op-batcher/bindings/batch_authenticator.go +++ b/op-batcher/bindings/batch_authenticator.go @@ -31,8 +31,8 @@ var ( // BatchAuthenticatorMetaData contains all meta data concerning the BatchAuthenticator contract. var BatchAuthenticatorMetaData = &bind.MetaData{ - ABI: "[{\"type\":\"constructor\",\"inputs\":[{\"name\":\"_espressoTEEVerifier\",\"type\":\"address\",\"internalType\":\"contractEspressoTEEVerifier\"},{\"name\":\"_preApprovedBatcher\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"authenticateBatchInfo\",\"inputs\":[{\"name\":\"commitment\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"_signature\",\"type\":\"bytes\",\"internalType\":\"bytes\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"decodeAttestationTbs\",\"inputs\":[{\"name\":\"attestation\",\"type\":\"bytes\",\"internalType\":\"bytes\"}],\"outputs\":[{\"name\":\"\",\"type\":\"bytes\",\"internalType\":\"bytes\"},{\"name\":\"\",\"type\":\"bytes\",\"internalType\":\"bytes\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"espressoTEEVerifier\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"contractEspressoTEEVerifier\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"nitroValidator\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"contractINitroValidator\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"owner\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"preApprovedBatcher\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"registerSigner\",\"inputs\":[{\"name\":\"attestationTbs\",\"type\":\"bytes\",\"internalType\":\"bytes\"},{\"name\":\"signature\",\"type\":\"bytes\",\"internalType\":\"bytes\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"registerSignerWithoutAttestationVerification\",\"inputs\":[{\"name\":\"pcr0Hash\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"attestationTbs\",\"type\":\"bytes\",\"internalType\":\"bytes\"},{\"name\":\"signature\",\"type\":\"bytes\",\"internalType\":\"bytes\"},{\"name\":\"enclaveAddress\",\"type\":\"address\",\"internalType\":\"address\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"renounceOwnership\",\"inputs\":[],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"transferOwnership\",\"inputs\":[{\"name\":\"newOwner\",\"type\":\"address\",\"internalType\":\"address\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"validBatchInfo\",\"inputs\":[{\"name\":\"\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"}],\"outputs\":[{\"name\":\"\",\"type\":\"bool\",\"internalType\":\"bool\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"version\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"string\",\"internalType\":\"string\"}],\"stateMutability\":\"view\"},{\"type\":\"event\",\"name\":\"Initialized\",\"inputs\":[{\"name\":\"version\",\"type\":\"uint8\",\"indexed\":false,\"internalType\":\"uint8\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"OwnershipTransferred\",\"inputs\":[{\"name\":\"previousOwner\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"newOwner\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"}],\"anonymous\":false}]", - Bin: "0x60e0806040523461011357604081611515803803809161001f828561012a565b8339810103126101135780516001600160a01b038116918282036101135760200151916001600160a01b03831683036101135760049260209260a05260805260405192838092631b01498560e31b82525afa90811561011f575f916100d9575b506001600160a01b031660c0526040516113b3908161016282396080518181816102de0152610b94015260a0518181816101950152818161051f0152818161076b0152610cfd015260c0518181816109020152610c030152f35b90506020813d602011610117575b816100f46020938361012a565b8101031261011357516001600160a01b0381168103610113575f61007f565b5f80fd5b3d91506100e7565b6040513d5f823e3d90fd5b601f909101601f19168101906001600160401b0382119082101761014d57604052565b634e487b7160e01b5f52604160045260245ffdfe6080806040526004361015610012575f80fd5b5f905f3560e01c90816302afd6e314610c27575080631b076a4c14610bb85780631f568b1814610b4957806354fd4d5014610aca578063715018a614610a2c5780638da5cb5b146109da578063a903a27714610849578063ba58e82a146106df578063f2fde38b14610590578063f81f208314610543578063fa14fe6d146104d45763fc619e41146100a2575f80fd5b346104d15760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104d15760043560243567ffffffffffffffff81116104cf576100f76100fe913690600401610e21565b3691610f3a565b8051604010156104a25760608101805160f81c80158015610498575b6103db575b505061014b61014373ffffffffffffffffffffffffffffffffffffffff928461109f565b9190916110d4565b16801561037d576040517fd80a4c2800000000000000000000000000000000000000000000000000000000815260208160048173ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000165afa9081156103455773ffffffffffffffffffffffffffffffffffffffff916020918691610350575b506024604051809481937f0123d0c1000000000000000000000000000000000000000000000000000000008352876004840152165afa908115610345578491610306575b501590816102c5575b5061026757815260656020526040812060017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0082541617905580f35b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600e60248201527f496e76616c6964207369676e65720000000000000000000000000000000000006044820152fd5b905073ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001614155f61022b565b90506020813d60201161033d575b8161032160209383610e4f565b8101031261033957518015158103610339575f610222565b8380fd5b3d9150610314565b6040513d86823e3d90fd5b6103709150823d8411610376575b6103688183610e4f565b810190610f70565b5f6101de565b503d61035e565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f496e76616c6964207369676e61747572650000000000000000000000000000006044820152fd5b601b0160ff811161046b5782516040101561043e5773ffffffffffffffffffffffffffffffffffffffff9261014b927fff000000000000000000000000000000000000000000000000000000000000006101439360f81b16871a9053925061011f565b6024857f4e487b710000000000000000000000000000000000000000000000000000000081526032600452fd5b6024857f4e487b710000000000000000000000000000000000000000000000000000000081526011600452fd5b506001811461011a565b6024837f4e487b710000000000000000000000000000000000000000000000000000000081526032600452fd5b825b80fd5b50346104d157807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104d157602060405173ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000168152f35b50346104d15760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104d15760ff60406020926004358152606584522054166040519015158152f35b50346104d15760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104d15760043573ffffffffffffffffffffffffffffffffffffffff81168091036106db576105e9611020565b80156106575773ffffffffffffffffffffffffffffffffffffffff603354827fffffffffffffffffffffffff0000000000000000000000000000000000000000821617603355167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08380a380f35b60846040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152fd5b5080fd5b50346104d15760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104d1578060043567ffffffffffffffff811161084657610730903690600401610e21565b9060243567ffffffffffffffff811161084357610751903690600401610e21565b92909173ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001690813b1561083f57856107db9361080b8296604051988997889687957f35ecb4c1000000000000000000000000000000000000000000000000000000008752606060048801526064870191610f9c565b917ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc858403016024860152610f9c565b6001604483015203925af18015610834576108235750f35b8161082d91610e4f565b6104d15780f35b6040513d84823e3d90fd5b8580fd5b50505b50fd5b50346104d15760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104d15760043567ffffffffffffffff81116106db5781366023830112156104d1576108ae6108e9923690602481600401359101610f3a565b604051809381927fa903a277000000000000000000000000000000000000000000000000000000008352602060048401526024830190610ef7565b038173ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000165afa9182156109ce5780918193610962575b6109508361095e86604051938493604085526040850190610ef7565b908382036020850152610ef7565b0390f35b915091503d8083833e6109758183610e4f565b8101916040828403126104d157815167ffffffffffffffff81116106db578361099f918401610fda565b9160208101519167ffffffffffffffff83116104d157506109509361095e926109c89201610fda565b92610934565b604051903d90823e3d90fd5b50346104d157807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104d157602073ffffffffffffffffffffffffffffffffffffffff60335416604051908152f35b50346104d157807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104d157610a63611020565b8073ffffffffffffffffffffffffffffffffffffffff6033547fffffffffffffffffffffffff00000000000000000000000000000000000000008116603355167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a380f35b50346104d157807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104d1575061095e604051610b0b604082610e4f565b600581527f312e302e300000000000000000000000000000000000000000000000000000006020820152604051918291602083526020830190610ef7565b50346104d157807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104d157602060405173ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000168152f35b50346104d157807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104d157602060405173ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000168152f35b905034610dfe5760807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610dfe5760243567ffffffffffffffff8111610dfe57610c78903690600401610e21565b909160443567ffffffffffffffff8111610dfe57610c9a903690600401610e21565b936064359273ffffffffffffffffffffffffffffffffffffffff8416809403610dfe577fd80a4c2800000000000000000000000000000000000000000000000000000000815260208160048173ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000165afa8015610df35773ffffffffffffffffffffffffffffffffffffffff915f91610e02575b501691823b15610dfe575f94610d9d94610dcd8793604051998a98899788967f02afd6e30000000000000000000000000000000000000000000000000000000088526004356004890152608060248901526084880191610f9c565b917ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc868403016044870152610f9c565b90606483015203925af18015610df357610de5575080f35b610df191505f90610e4f565b005b6040513d5f823e3d90fd5b5f80fd5b610e1b915060203d602011610376576103688183610e4f565b5f610d42565b9181601f84011215610dfe5782359167ffffffffffffffff8311610dfe5760208381860195010111610dfe57565b90601f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0910116810190811067ffffffffffffffff821117610e9057604052565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b67ffffffffffffffff8111610e9057601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01660200190565b907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f602080948051918291828752018686015e5f8582860101520116010190565b929192610f4682610ebd565b91610f546040519384610e4f565b829481845281830111610dfe578281602093845f960137010152565b90816020910312610dfe575173ffffffffffffffffffffffffffffffffffffffff81168103610dfe5790565b601f82602094937fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe093818652868601375f8582860101520116010190565b81601f82011215610dfe57805190610ff182610ebd565b92610fff6040519485610e4f565b82845260208383010111610dfe57815f9260208093018386015e8301015290565b73ffffffffffffffffffffffffffffffffffffffff60335416330361104157565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602060248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152fd5b9060418151145f146110cb576110c791602082015190606060408401519301515f1a906112f7565b9091565b50505f90600290565b60058110156112ca57806110e55750565b6001810361114b5760646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601860248201527f45434453413a20696e76616c6964207369676e617475726500000000000000006044820152fd5b600281036111b15760646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152fd5b6003810361123d5760846040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c60448201527f75650000000000000000000000000000000000000000000000000000000000006064820152fd5b60041461124657565b60846040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202776272076616c60448201527f75650000000000000000000000000000000000000000000000000000000000006064820152fd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602160045260245ffd5b907f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0841161139b5760ff1690601b82141580611390575b611385576020935f93608093604051938452868401526040830152606082015282805260015afa15610df3575f5173ffffffffffffffffffffffffffffffffffffffff81161561137d57905f90565b505f90600190565b505050505f90600490565b50601c82141561132e565b505050505f9060039056fea164736f6c634300081c000a", + ABI: "[{\"type\":\"constructor\",\"inputs\":[{\"name\":\"_espressoTEEVerifier\",\"type\":\"address\",\"internalType\":\"contractEspressoTEEVerifier\"},{\"name\":\"_preApprovedBatcher\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"_owner\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"authenticateBatchInfo\",\"inputs\":[{\"name\":\"commitment\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"_signature\",\"type\":\"bytes\",\"internalType\":\"bytes\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"decodeAttestationTbs\",\"inputs\":[{\"name\":\"attestation\",\"type\":\"bytes\",\"internalType\":\"bytes\"}],\"outputs\":[{\"name\":\"\",\"type\":\"bytes\",\"internalType\":\"bytes\"},{\"name\":\"\",\"type\":\"bytes\",\"internalType\":\"bytes\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"espressoTEEVerifier\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"contractEspressoTEEVerifier\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"nitroValidator\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"contractINitroValidator\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"owner\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"preApprovedBatcher\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"registerSigner\",\"inputs\":[{\"name\":\"attestationTbs\",\"type\":\"bytes\",\"internalType\":\"bytes\"},{\"name\":\"signature\",\"type\":\"bytes\",\"internalType\":\"bytes\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"registerSignerWithoutAttestationVerification\",\"inputs\":[{\"name\":\"pcr0Hash\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"attestationTbs\",\"type\":\"bytes\",\"internalType\":\"bytes\"},{\"name\":\"signature\",\"type\":\"bytes\",\"internalType\":\"bytes\"},{\"name\":\"enclaveAddress\",\"type\":\"address\",\"internalType\":\"address\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"renounceOwnership\",\"inputs\":[],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"transferOwnership\",\"inputs\":[{\"name\":\"newOwner\",\"type\":\"address\",\"internalType\":\"address\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"validBatchInfo\",\"inputs\":[{\"name\":\"\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"}],\"outputs\":[{\"name\":\"\",\"type\":\"bool\",\"internalType\":\"bool\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"version\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"string\",\"internalType\":\"string\"}],\"stateMutability\":\"view\"},{\"type\":\"event\",\"name\":\"OwnershipTransferred\",\"inputs\":[{\"name\":\"previousOwner\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"newOwner\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"}],\"anonymous\":false}]", + Bin: "0x60e06040523461006e5761001a61001461017e565b91610271565b610022610073565b611c65610426823960805181818161031d015261145e015260a0518181816108b801528181610ac501528181610e92015261135d015260c05181818161026b0152610d780152611c6590f35b610079565b60405190565b5f80fd5b601f801991011690565b634e487b7160e01b5f52604160045260245ffd5b906100a59061007d565b810190811060018060401b038211176100bd57604052565b610087565b906100d56100ce610073565b928361009b565b565b5f80fd5b60018060a01b031690565b6100ef906100db565b90565b6100fb906100e6565b90565b610107816100f2565b0361010e57565b5f80fd5b9050519061011f826100fe565b565b61012a816100e6565b0361013157565b5f80fd5b9050519061014282610121565b565b90916060828403126101795761017661015f845f8501610112565b9361016d8160208601610135565b93604001610135565b90565b6100d7565b61019c61208b80380380610191816100c2565b928339810190610144565b909192565b6101ab90516100f2565b90565b90565b6101c56101c06101ca926100db565b6101ae565b6100db565b90565b6101d6906101b1565b90565b6101e2906101cd565b90565b60e01b90565b6101f4906100e6565b90565b610200816101eb565b0361020757565b5f80fd5b90505190610218826101f7565b565b9060208282031261023357610230915f0161020b565b90565b6100d7565b5f0190565b610245610073565b3d5f823e3d90fd5b610256906101cd565b90565b610262906101b1565b90565b61026e90610259565b90565b906102af929161027f610323565b60a052608052602061029961029460a06101a1565b6101d9565b63d80a4c28906102a7610073565b9485926101e5565b825281806102bf60048201610238565b03915afa801561031e576102e16102e6916102ee945f916102f0575b5061024d565b610265565b60c0526103b5565b565b610311915060203d8111610317575b610309818361009b565b81019061021a565b5f6102db565b503d6102ff565b61023d565b61033361032e610418565b6103b5565b565b5f1c90565b60018060a01b031690565b61035161035691610335565b61033a565b90565b6103639054610345565b90565b5f1b90565b9061037c60018060a01b0391610366565b9181191691161790565b61038f906101cd565b90565b90565b906103aa6103a56103b192610386565b610392565b825461036b565b9055565b6103be5f610359565b6103c8825f610395565b906103fc6103f67f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e093610386565b91610386565b91610405610073565b8061040f81610238565b0390a3565b5f90565b610420610414565b50339056fe60806040526004361015610013575b6109b7565b61001d5f356100dc565b806302afd6e3146100d75780631b076a4c146100d25780631f568b18146100cd57806354fd4d50146100c8578063715018a6146100c35780638da5cb5b146100be578063a903a277146100b9578063ba58e82a146100b4578063f2fde38b146100af578063f81f2083146100aa578063fa14fe6d146100a55763fc619e410361000e57610983565b610908565b610881565b61079e565b610749565b6106b4565b610556565b610523565b6104ee565b610361565b6102e6565b610220565b60e01c90565b60405190565b5f80fd5b5f80fd5b5f80fd5b90565b610100816100f4565b0361010757565b5f80fd5b90503590610118826100f7565b565b5f80fd5b5f80fd5b5f80fd5b909182601f830112156101605781359167ffffffffffffffff831161015b57602001926001830284011161015657565b610122565b61011e565b61011a565b60018060a01b031690565b61017990610165565b90565b61018581610170565b0361018c57565b5f80fd5b9050359061019d8261017c565b565b9190608083820312610216576101b7815f850161010b565b92602081013567ffffffffffffffff811161021157826101d8918301610126565b929093604083013567ffffffffffffffff811161020c576101fe83610209928601610126565b939094606001610190565b90565b6100f0565b6100f0565b6100ec565b5f0190565b346102555761023f61023336600461019f565b94939093929192610ab6565b6102476100e2565b806102518161021b565b0390f35b6100e8565b5f91031261026457565b6100ec565b7f000000000000000000000000000000000000000000000000000000000000000090565b90565b6102a461029f6102a992610165565b61028d565b610165565b90565b6102b590610290565b90565b6102c1906102ac565b90565b6102cd906102b8565b9052565b91906102e4905f602085019401906102c4565b565b34610316576102f636600461025a565b610312610301610269565b6103096100e2565b918291826102d1565b0390f35b6100e8565b7f000000000000000000000000000000000000000000000000000000000000000090565b61034890610170565b9052565b919061035f905f6020850194019061033f565b565b346103915761037136600461025a565b61038d61037c61031b565b6103846100e2565b9182918261034c565b0390f35b6100e8565b601f801991011690565b634e487b7160e01b5f52604160045260245ffd5b906103be90610396565b810190811067ffffffffffffffff8211176103d857604052565b6103a0565b906103f06103e96100e2565b92836103b4565b565b67ffffffffffffffff81116104105761040c602091610396565b0190565b6103a0565b90610427610422836103f2565b6103dd565b918252565b5f7f312e302e30000000000000000000000000000000000000000000000000000000910152565b61045d6005610415565b9061046a6020830161042c565b565b610474610453565b90565b61047f61046c565b90565b61048a610477565b90565b5190565b60209181520190565b90825f9392825e0152565b6104c46104cd6020936104d2936104bb8161048d565b93848093610491565b9586910161049a565b610396565b0190565b6104eb9160208201915f8184039101526104a5565b90565b3461051e576104fe36600461025a565b61051a610509610482565b6105116100e2565b918291826104d6565b0390f35b6100e8565b346105515761053336600461025a565b61053b610c34565b6105436100e2565b8061054d8161021b565b0390f35b6100e8565b346105865761056636600461025a565b610582610571610c73565b6105796100e2565b9182918261034c565b0390f35b6100e8565b5f80fd5b67ffffffffffffffff81116105ad576105a9602091610396565b0190565b6103a0565b90825f939282370152565b909291926105d26105cd8261058f565b6103dd565b938185526020850190828401116105ee576105ec926105b2565b565b61058b565b9080601f830112156106115781602061060e933591016105bd565b90565b61011a565b90602082820312610646575f82013567ffffffffffffffff81116106415761063e92016105f3565b90565b6100f0565b6100ec565b5190565b60209181520190565b6106776106806020936106859361066e8161064b565b9384809361064f565b9586910161049a565b610396565b0190565b90916106a36106b19360408401908482035f860152610658565b916020818403910152610658565b90565b346106e5576106cc6106c7366004610616565b610d5b565b906106e16106d86100e2565b92839283610689565b0390f35b6100e8565b9091604082840312610744575f82013567ffffffffffffffff811161073f5783610715918401610126565b929093602082013567ffffffffffffffff811161073a576107369201610126565b9091565b6100f0565b6100f0565b6100ec565b3461077b5761076561075c3660046106ea565b92919091610e8a565b61076d6100e2565b806107778161021b565b0390f35b6100e8565b9060208282031261079957610796915f01610190565b90565b6100ec565b346107cc576107b66107b1366004610780565b611028565b6107be6100e2565b806107c88161021b565b0390f35b6100e8565b906020828203126107ea576107e7915f0161010b565b90565b6100ec565b6107f8906100f4565b90565b90610805906107ef565b5f5260205260405f2090565b1c90565b60ff1690565b61082b9060086108309302610811565b610815565b90565b9061083e915461081b565b90565b610857906108526001915f926107fb565b610833565b90565b151590565b6108689061085a565b9052565b919061087f905f6020850194019061085f565b565b346108b1576108ad61089c6108973660046107d1565b610841565b6108a46100e2565b9182918261086c565b0390f35b6100e8565b7f000000000000000000000000000000000000000000000000000000000000000090565b6108e3906102ac565b90565b6108ef906108da565b9052565b9190610906905f602085019401906108e6565b565b346109385761091836600461025a565b6109346109236108b6565b61092b6100e2565b918291826108f3565b0390f35b6100e8565b91909160408184031261097e57610956835f830161010b565b92602082013567ffffffffffffffff8111610979576109759201610126565b9091565b6100f0565b6100ec565b346109b25761099c61099636600461093d565b916112da565b6109a46100e2565b806109ae8161021b565b0390f35b6100e8565b5f80fd5b5f80fd5b60e01b90565b6109ce90610170565b90565b6109da816109c5565b036109e157565b5f80fd5b905051906109f2826109d1565b565b90602082820312610a0d57610a0a915f016109e5565b90565b6100ec565b610a1a6100e2565b3d5f823e3d90fd5b610a2b906102ac565b90565b5f910312610a3857565b6100ec565b610a46906100f4565b9052565b9190610a6481610a5d81610a699561064f565b80956105b2565b610396565b0190565b9695939094610a9e88606095610aac95610a91610ab49a5f60808601950190610a3d565b8b830360208d0152610a4a565b9188830360408a0152610a4a565b94019061033f565b565b9194909293610aff6020610ae97f00000000000000000000000000000000000000000000000000000000000000006108da565b63d80a4c2890610af76100e2565b9384926109bf565b82528180610b0f6004820161021b565b03915afa8015610bdf57610b2a915f91610bb1575b50610a22565b926302afd6e390949695919295843b15610bac575f96610b5e948894610b6993610b526100e2565b9b8c9a8b998a986109bf565b885260048801610a6d565b03925af18015610ba757610b7b575b50565b610b9a905f3d8111610ba0575b610b9281836103b4565b810190610a2e565b5f610b78565b503d610b88565b610a12565b6109bb565b610bd2915060203d8111610bd8575b610bca81836103b4565b8101906109f4565b5f610b24565b503d610bc0565b610a12565b610bec6115ee565b610bf4610c21565b565b90565b610c0d610c08610c1292610bf6565b61028d565b610165565b90565b610c1e90610bf9565b90565b610c32610c2d5f610c15565b611664565b565b610c3c610be4565b565b5f90565b5f1c90565b60018060a01b031690565b610c5e610c6391610c42565b610c47565b90565b610c709054610c52565b90565b610c7b610c3e565b50610c855f610c66565b90565b606090565b90929192610ca2610c9d8261058f565b6103dd565b93818552602085019082840111610cbe57610cbc9261049a565b565b61058b565b9080601f83011215610ce157816020610cde93519101610c8d565b90565b61011a565b919091604081840312610d3e575f81015167ffffffffffffffff8111610d395783610d12918301610cc3565b92602082015167ffffffffffffffff8111610d3457610d319201610cc3565b90565b6100f0565b6100f0565b6100ec565b610d589160208201915f818403910152610658565b90565b905f610dc392610d69610c88565b50610d72610c88565b50610d9c7f00000000000000000000000000000000000000000000000000000000000000006102b8565b610db863a903a277610dac6100e2565b968794859384936109bf565b835260048301610d43565b03915afa8015610e03575f80939091610ddc575b509190565b9050610dfb9192503d805f833e610df381836103b4565b810190610ce6565b91905f610dd7565b610a12565b634e487b7160e01b5f52602160045260245ffd5b60021115610e2657565b610e08565b90610e3582610e1c565b565b610e4090610e2b565b90565b610e4c90610e37565b9052565b959492610e8894610e72610e809360409560608b01918b83035f8d0152610a4a565b9188830360208a0152610a4a565b940190610e43565b565b929192610eb67f00000000000000000000000000000000000000000000000000000000000000006108da565b906335ecb4c190929493600191833b15610f3857610ef5610eea935f97938894610ede6100e2565b9a8b998a9889976109bf565b875260048701610e50565b03925af18015610f3357610f07575b50565b610f26905f3d8111610f2c575b610f1e81836103b4565b810190610a2e565b5f610f04565b503d610f14565b610a12565b6109bb565b610f4e90610f496115ee565b610ff8565b565b60207f6464726573730000000000000000000000000000000000000000000000000000917f4f776e61626c653a206e6577206f776e657220697320746865207a65726f20615f8201520152565b610faa6026604092610491565b610fb381610f50565b0190565b610fcc9060208101905f818303910152610f9d565b90565b15610fd657565b610fde6100e2565b62461bcd60e51b815280610ff460048201610fb7565b0390fd5b611026906110218161101a61101461100f5f610c15565b610170565b91610170565b1415610fcf565b611664565b565b61103190610f3d565b565b61103e9136916105bd565b90565b634e487b7160e01b5f52603260045260245ffd5b9061105f8261064b565b81101561107157600160209102010190565b611041565b90565b90565b61109061108b61109592611076565b61028d565b611079565b90565b60ff60f81b1690565b6110ab9051611098565b90565b60f81c90565b60ff1690565b6110ce6110c96110d3926110b4565b61028d565b6110b4565b90565b6110e26110e7916110ae565b6110ba565b90565b6110fe6110f961110392610bf6565b61028d565b6110b4565b90565b90565b61111d61111861112292611106565b61028d565b6110b4565b90565b90565b61113c61113761114192611125565b61028d565b6110b4565b90565b634e487b7160e01b5f52601160045260245ffd5b61116461116a916110b4565b916110b4565b019060ff821161117657565b611144565b60f81b90565b61119561119061119a926110b4565b61117b565b611098565b90565b5f7f496e76616c6964207369676e6174757265000000000000000000000000000000910152565b6111d16011602092610491565b6111da8161119d565b0190565b6111f39060208101905f8183039101526111c4565b90565b6111ff8161085a565b0361120657565b5f80fd5b90505190611217826111f6565b565b906020828203126112325761122f915f0161120a565b90565b6100ec565b5f7f496e76616c6964207369676e6572000000000000000000000000000000000000910152565b61126b600e602092610491565b61127481611237565b0190565b61128d9060208101905f81830391015261125e565b90565b5f1b90565b906112a160ff91611290565b9181191691161790565b6112b49061085a565b90565b90565b906112cf6112ca6112d6926112ab565b6112b7565b8254611295565b9055565b916112e89061133392611033565b61130c611307611302836112fc604061107c565b90611055565b6110a1565b6110d6565b8061131f6113195f6110ea565b916110b4565b148015611552575b611517575b50826116c3565b8061134e6113486113435f610c15565b610170565b91610170565b146114f55761139760206113817f00000000000000000000000000000000000000000000000000000000000000006108da565b63d80a4c289061138f6100e2565b9384926109bf565b825281806113a76004820161021b565b03915afa80156114f0576113c86020916113f2935f916114c3575b50610a22565b630123d0c1906113e785926113db6100e2565b958694859384936109bf565b83526004830161034c565b03915afa80156114be5761140e915f91611490575b501561085a565b9081611454575b50611432576114309061142b60019160016107fb565b6112ba565b565b61143a6100e2565b62461bcd60e51b81528061145060048201611278565b0390fd5b90506114886114827f0000000000000000000000000000000000000000000000000000000000000000610170565b91610170565b14155f611415565b6114b1915060203d81116114b7575b6114a981836103b4565b810190611219565b5f611407565b503d61149f565b610a12565b6114e39150833d81116114e9575b6114db81836103b4565b8101906109f4565b5f6113c2565b503d6114d1565b610a12565b6114fd6100e2565b62461bcd60e51b815280611513600482016111de565b0390fd5b61152e61153391611528601b611128565b90611158565b611181565b61154b826115456040935f1a9361107c565b90611055565b535f61132c565b50806115676115616001611109565b916110b4565b14611327565b5f7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572910152565b6115a060208092610491565b6115a98161156d565b0190565b6115c29060208101905f818303910152611594565b90565b156115cc57565b6115d46100e2565b62461bcd60e51b8152806115ea600482016115ad565b0390fd5b6116186115f9610c73565b61161261160c6116076116e4565b610170565b91610170565b146115c5565b565b9061162b60018060a01b0391611290565b9181191691161790565b61163e906102ac565b90565b90565b9061165961165461166092611635565b611641565b825461161a565b9055565b61166d5f610c66565b611677825f611644565b906116ab6116a57f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e093611635565b91611635565b916116b46100e2565b806116be8161021b565b0390a3565b6116e1916116d9916116d3610c3e565b5061171c565b91909161196b565b90565b6116ec610c3e565b503390565b5f90565b90565b61170c611707611711926116f5565b61028d565b611079565b90565b5f90565b5f90565b611724610c3e565b5061172d6116f1565b506117378261064b565b61174a61174460416116f8565b91611079565b145f1461178f576117899161175d611714565b50611766611714565b5061176f611718565b506020810151606060408301519201515f1a909192611b34565b91909190565b505061179a5f610c15565b90600290565b600511156117aa57565b610e08565b906117b9826117a0565b565b60207f7565000000000000000000000000000000000000000000000000000000000000917f45434453413a20696e76616c6964207369676e6174757265202776272076616c5f8201520152565b6118156022604092610491565b61181e816117bb565b0190565b6118379060208101905f818303910152611808565b90565b60207f7565000000000000000000000000000000000000000000000000000000000000917f45434453413a20696e76616c6964207369676e6174757265202773272076616c5f8201520152565b6118946022604092610491565b61189d8161183a565b0190565b6118b69060208101905f818303910152611887565b90565b5f7f45434453413a20696e76616c6964207369676e6174757265206c656e67746800910152565b6118ed601f602092610491565b6118f6816118b9565b0190565b61190f9060208101905f8183039101526118e0565b90565b5f7f45434453413a20696e76616c6964207369676e61747572650000000000000000910152565b6119466018602092610491565b61194f81611912565b0190565b6119689060208101905f818303910152611939565b90565b8061197e6119785f6117af565b916117af565b145f146119885750565b8061199c61199660016117af565b916117af565b145f146119c5576119ab6100e2565b62461bcd60e51b8152806119c160048201611953565b0390fd5b806119d96119d360026117af565b916117af565b145f14611a02576119e86100e2565b62461bcd60e51b8152806119fe600482016118fa565b0390fd5b80611a16611a1060036117af565b916117af565b145f14611a3f57611a256100e2565b62461bcd60e51b815280611a3b600482016118a1565b0390fd5b611a52611a4c60046117af565b916117af565b14611a5957565b611a616100e2565b62461bcd60e51b815280611a7760048201611822565b0390fd5b611a8f611a8a611a9492611079565b61028d565b611079565b90565b611aa3611aa891610c42565b611a7b565b90565b90565b611ac2611abd611ac792611aab565b61028d565b611079565b90565b90565b611ae1611adc611ae692611aca565b61028d565b6110b4565b90565b611af2906110b4565b9052565b611b2b611b3294611b21606094989795611b17608086019a5f870190610a3d565b6020850190611ae9565b6040830190610a3d565b0190610a3d565b565b929190611b3f610c3e565b50611b486116f1565b50611b5283611a97565b611b84611b7e7f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0611aae565b91611079565b11611c455780611b9d611b97601b611128565b916110b4565b141580611c29575b611c1657611bc45f936020959293611bbb6100e2565b94859485611af6565b838052039060015afa15611c1157611bdc5f51611290565b80611bf7611bf1611bec5f610c15565b610170565b91610170565b14611c0157905f90565b50611c0b5f610c15565b90600190565b610a12565b50505050611c235f610c15565b90600490565b5080611c3e611c38601c611acd565b916110b4565b1415611ba5565b50505050611c525f610c15565b9060039056fea164736f6c634300081e000a", } // BatchAuthenticatorABI is the input ABI used to generate the binding from. @@ -44,7 +44,7 @@ var BatchAuthenticatorABI = BatchAuthenticatorMetaData.ABI var BatchAuthenticatorBin = BatchAuthenticatorMetaData.Bin // DeployBatchAuthenticator deploys a new Ethereum contract, binding an instance of BatchAuthenticator to it. -func DeployBatchAuthenticator(auth *bind.TransactOpts, backend bind.ContractBackend, _espressoTEEVerifier common.Address, _preApprovedBatcher common.Address) (common.Address, *types.Transaction, *BatchAuthenticator, error) { +func DeployBatchAuthenticator(auth *bind.TransactOpts, backend bind.ContractBackend, _espressoTEEVerifier common.Address, _preApprovedBatcher common.Address, _owner common.Address) (common.Address, *types.Transaction, *BatchAuthenticator, error) { parsed, err := BatchAuthenticatorMetaData.GetAbi() if err != nil { return common.Address{}, nil, nil, err @@ -53,7 +53,7 @@ func DeployBatchAuthenticator(auth *bind.TransactOpts, backend bind.ContractBack return common.Address{}, nil, nil, errors.New("GetABI returned nil") } - address, tx, contract, err := bind.DeployContract(auth, *parsed, common.FromHex(BatchAuthenticatorBin), backend, _espressoTEEVerifier, _preApprovedBatcher) + address, tx, contract, err := bind.DeployContract(auth, *parsed, common.FromHex(BatchAuthenticatorBin), backend, _espressoTEEVerifier, _preApprovedBatcher, _owner) if err != nil { return common.Address{}, nil, nil, err } @@ -525,140 +525,6 @@ func (_BatchAuthenticator *BatchAuthenticatorTransactorSession) TransferOwnershi return _BatchAuthenticator.Contract.TransferOwnership(&_BatchAuthenticator.TransactOpts, newOwner) } -// BatchAuthenticatorInitializedIterator is returned from FilterInitialized and is used to iterate over the raw logs and unpacked data for Initialized events raised by the BatchAuthenticator contract. -type BatchAuthenticatorInitializedIterator struct { - Event *BatchAuthenticatorInitialized // Event containing the contract specifics and raw log - - contract *bind.BoundContract // Generic contract to use for unpacking event data - event string // Event name to use for unpacking event data - - logs chan types.Log // Log channel receiving the found contract events - sub ethereum.Subscription // Subscription for errors, completion and termination - done bool // Whether the subscription completed delivering logs - fail error // Occurred error to stop iteration -} - -// Next advances the iterator to the subsequent event, returning whether there -// are any more events found. In case of a retrieval or parsing error, false is -// returned and Error() can be queried for the exact failure. -func (it *BatchAuthenticatorInitializedIterator) Next() bool { - // If the iterator failed, stop iterating - if it.fail != nil { - return false - } - // If the iterator completed, deliver directly whatever's available - if it.done { - select { - case log := <-it.logs: - it.Event = new(BatchAuthenticatorInitialized) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - default: - return false - } - } - // Iterator still in progress, wait for either a data or an error event - select { - case log := <-it.logs: - it.Event = new(BatchAuthenticatorInitialized) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - case err := <-it.sub.Err(): - it.done = true - it.fail = err - return it.Next() - } -} - -// Error returns any retrieval or parsing error occurred during filtering. -func (it *BatchAuthenticatorInitializedIterator) Error() error { - return it.fail -} - -// Close terminates the iteration process, releasing any pending underlying -// resources. -func (it *BatchAuthenticatorInitializedIterator) Close() error { - it.sub.Unsubscribe() - return nil -} - -// BatchAuthenticatorInitialized represents a Initialized event raised by the BatchAuthenticator contract. -type BatchAuthenticatorInitialized struct { - Version uint8 - Raw types.Log // Blockchain specific contextual infos -} - -// FilterInitialized is a free log retrieval operation binding the contract event 0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498. -// -// Solidity: event Initialized(uint8 version) -func (_BatchAuthenticator *BatchAuthenticatorFilterer) FilterInitialized(opts *bind.FilterOpts) (*BatchAuthenticatorInitializedIterator, error) { - - logs, sub, err := _BatchAuthenticator.contract.FilterLogs(opts, "Initialized") - if err != nil { - return nil, err - } - return &BatchAuthenticatorInitializedIterator{contract: _BatchAuthenticator.contract, event: "Initialized", logs: logs, sub: sub}, nil -} - -// WatchInitialized is a free log subscription operation binding the contract event 0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498. -// -// Solidity: event Initialized(uint8 version) -func (_BatchAuthenticator *BatchAuthenticatorFilterer) WatchInitialized(opts *bind.WatchOpts, sink chan<- *BatchAuthenticatorInitialized) (event.Subscription, error) { - - logs, sub, err := _BatchAuthenticator.contract.WatchLogs(opts, "Initialized") - if err != nil { - return nil, err - } - return event.NewSubscription(func(quit <-chan struct{}) error { - defer sub.Unsubscribe() - for { - select { - case log := <-logs: - // New log arrived, parse the event and forward to the user - event := new(BatchAuthenticatorInitialized) - if err := _BatchAuthenticator.contract.UnpackLog(event, "Initialized", log); err != nil { - return err - } - event.Raw = log - - select { - case sink <- event: - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - } - }), nil -} - -// ParseInitialized is a log parse operation binding the contract event 0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498. -// -// Solidity: event Initialized(uint8 version) -func (_BatchAuthenticator *BatchAuthenticatorFilterer) ParseInitialized(log types.Log) (*BatchAuthenticatorInitialized, error) { - event := new(BatchAuthenticatorInitialized) - if err := _BatchAuthenticator.contract.UnpackLog(event, "Initialized", log); err != nil { - return nil, err - } - event.Raw = log - return event, nil -} - // BatchAuthenticatorOwnershipTransferredIterator is returned from FilterOwnershipTransferred and is used to iterate over the raw logs and unpacked data for OwnershipTransferred events raised by the BatchAuthenticator contract. type BatchAuthenticatorOwnershipTransferredIterator struct { Event *BatchAuthenticatorOwnershipTransferred // Event containing the contract specifics and raw log diff --git a/op-batcher/bindings/batch_inbox.go b/op-batcher/bindings/batch_inbox.go index 2d230320feb6c..b7170ed946bbb 100644 --- a/op-batcher/bindings/batch_inbox.go +++ b/op-batcher/bindings/batch_inbox.go @@ -31,8 +31,8 @@ var ( // BatchInboxMetaData contains all meta data concerning the BatchInbox contract. var BatchInboxMetaData = &bind.MetaData{ - ABI: "[{\"type\":\"constructor\",\"inputs\":[{\"name\":\"_batchAuthenticator\",\"type\":\"address\",\"internalType\":\"contractIBatchAuthenticator\"}],\"stateMutability\":\"nonpayable\"},{\"type\":\"fallback\",\"stateMutability\":\"nonpayable\"}]", - Bin: "0x60a0604052348015600e575f5ffd5b506040516103f03803806103f0833981016040819052602b91603b565b6001600160a01b03166080526066565b5f60208284031215604a575f5ffd5b81516001600160a01b0381168114605f575f5ffd5b9392505050565b60805161036c6100845f395f8181609d01526101d0015261036c5ff3fe608060405234801561000f575f5ffd5b505f491561018857604080515f80825260208201909252905b804915610067578181496040516020016100439291906102b4565b6040516020818303038152906040529150808061005f906102ce565b915050610028565b815160208301206040517ff81f2083000000000000000000000000000000000000000000000000000000008152600481018290527f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff169063f81f208390602401602060405180830381865afa1580156100f7573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061011b919061032a565b610186576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601260248201527f496e76616c696420626c6f62206261746368000000000000000000000000000060448201526064015b60405180910390fd5b005b5f5f36604051610199929190610350565b6040519081900381207ff81f20830000000000000000000000000000000000000000000000000000000082526004820181905291507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff169063f81f208390602401602060405180830381865afa15801561022a573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061024e919061032a565b610186576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f496e76616c69642063616c6c6461746120626174636800000000000000000000604482015260640161017d565b5f83518060208601845e9190910191825250602001919050565b5f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203610323577f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b5060010190565b5f6020828403121561033a575f5ffd5b81518015158114610349575f5ffd5b9392505050565b818382375f910190815291905056fea164736f6c634300081c000a", + ABI: "[{\"type\":\"constructor\",\"inputs\":[{\"name\":\"_teeBatcher\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"_nonTeeBatcher\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"_batchAuthenticator\",\"type\":\"address\",\"internalType\":\"contractIBatchAuthenticator\"}],\"stateMutability\":\"nonpayable\"},{\"type\":\"fallback\",\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"activeIsTee\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"bool\",\"internalType\":\"bool\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"batchAuthenticator\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"contractIBatchAuthenticator\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"nonTeeBatcher\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"switchBatcher\",\"inputs\":[],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"teeBatcher\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"}]", + Bin: "0x60e060405234801561000f575f5ffd5b50604051610c86380380610c868339818101604052810190610031919061022e565b5f73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415801561009957505f73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b6100d8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016100cf906102d8565b60405180910390fd5b8273ffffffffffffffffffffffffffffffffffffffff1660808173ffffffffffffffffffffffffffffffffffffffff16815250508173ffffffffffffffffffffffffffffffffffffffff1660a08173ffffffffffffffffffffffffffffffffffffffff16815250508073ffffffffffffffffffffffffffffffffffffffff1660c08173ffffffffffffffffffffffffffffffffffffffff168152505060015f5f6101000a81548160ff0219169083151502179055505050506102f6565b5f5ffd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6101c282610199565b9050919050565b6101d2816101b8565b81146101dc575f5ffd5b50565b5f815190506101ed816101c9565b92915050565b5f6101fd826101b8565b9050919050565b61020d816101f3565b8114610217575f5ffd5b50565b5f8151905061022881610204565b92915050565b5f5f5f6060848603121561024557610244610195565b5b5f610252868287016101df565b9350506020610263868287016101df565b92505060406102748682870161021a565b9150509250925092565b5f82825260208201905092915050565b7f4261746368496e626f783a207a65726f206261746368657200000000000000005f82015250565b5f6102c260188361027e565b91506102cd8261028e565b602082019050919050565b5f6020820190508181035f8301526102ef816102b6565b9050919050565b60805160a05160c05161094c61033a5f395f81816101e6015281816102e001526104bf01525f8181606f015261044f01525f81816095015261049b015261094c5ff3fe608060405234801561000f575f5ffd5b5060043610610059575f3560e01c80637877a9ed146103ba578063b1bd4285146103d8578063bc347f47146103f6578063d909ba7c14610400578063e75845731461041e5761005a565b5b5f5f5f9054906101000a900460ff16610093577f00000000000000000000000000000000000000000000000000000000000000006100b5565b7f00000000000000000000000000000000000000000000000000000000000000005b90508073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610125576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161011c9061053b565b60405180910390fd5b5f5f9054906101000a900460ff16156103b8575f5f1b5f49146102c3575f5f67ffffffffffffffff81111561015d5761015c610559565b5b6040519080825280601f01601f19166020018201604052801561018f5781602001600182028036833780820191505090505b5090505f5f90505b5f5f1b8149146101d9578181496040516020016101b5929190610601565b604051602081830303815290604052915080806101d19061065e565b915050610197565b5f828051906020012090507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663f81f2083826040518263ffffffff1660e01b815260040161023d91906106b4565b602060405180830381865afa158015610258573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061027c9190610706565b6102bb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016102b29061077b565b60405180910390fd5b5050506103b7565b5f5f366040516102d49291906107cb565b604051809103902090507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663f81f2083826040518263ffffffff1660e01b815260040161033791906106b4565b602060405180830381865afa158015610352573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906103769190610706565b6103b5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103ac9061082d565b60405180910390fd5b505b5b005b6103c261043c565b6040516103cf919061085a565b60405180910390f35b6103e061044d565b6040516103ed91906108b2565b60405180910390f35b6103fe610471565b005b610408610499565b60405161041591906108b2565b60405180910390f35b6104266104bd565b6040516104339190610926565b60405180910390f35b5f5f9054906101000a900460ff1681565b7f000000000000000000000000000000000000000000000000000000000000000081565b5f5f9054906101000a900460ff16155f5f6101000a81548160ff021916908315150217905550565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f000000000000000000000000000000000000000000000000000000000000000081565b5f82825260208201905092915050565b7f4261746368496e626f783a20756e617574686f72697a656420626174636865725f82015250565b5f6105256020836104e1565b9150610530826104f1565b602082019050919050565b5f6020820190508181035f83015261055281610519565b9050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b5f81519050919050565b5f81905092915050565b8281835e5f83830152505050565b5f6105b282610586565b6105bc8185610590565b93506105cc81856020860161059a565b80840191505092915050565b5f819050919050565b5f819050919050565b6105fb6105f6826105d8565b6105e1565b82525050565b5f61060c82856105a8565b915061061882846105ea565b6020820191508190509392505050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b5f819050919050565b5f61066882610655565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff820361069a57610699610628565b5b600182019050919050565b6106ae816105d8565b82525050565b5f6020820190506106c75f8301846106a5565b92915050565b5f5ffd5b5f8115159050919050565b6106e5816106d1565b81146106ef575f5ffd5b50565b5f81519050610700816106dc565b92915050565b5f6020828403121561071b5761071a6106cd565b5b5f610728848285016106f2565b91505092915050565b7f496e76616c696420626c6f6220626174636800000000000000000000000000005f82015250565b5f6107656012836104e1565b915061077082610731565b602082019050919050565b5f6020820190508181035f83015261079281610759565b9050919050565b828183375f83830152505050565b5f6107b28385610590565b93506107bf838584610799565b82840190509392505050565b5f6107d78284866107a7565b91508190509392505050565b7f496e76616c69642063616c6c64617461206261746368000000000000000000005f82015250565b5f6108176016836104e1565b9150610822826107e3565b602082019050919050565b5f6020820190508181035f8301526108448161080b565b9050919050565b610854816106d1565b82525050565b5f60208201905061086d5f83018461084b565b92915050565b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f61089c82610873565b9050919050565b6108ac81610892565b82525050565b5f6020820190506108c55f8301846108a3565b92915050565b5f819050919050565b5f6108ee6108e96108e484610873565b6108cb565b610873565b9050919050565b5f6108ff826108d4565b9050919050565b5f610910826108f5565b9050919050565b61092081610906565b82525050565b5f6020820190506109395f830184610917565b9291505056fea164736f6c634300081c000a", } // BatchInboxABI is the input ABI used to generate the binding from. @@ -44,7 +44,7 @@ var BatchInboxABI = BatchInboxMetaData.ABI var BatchInboxBin = BatchInboxMetaData.Bin // DeployBatchInbox deploys a new Ethereum contract, binding an instance of BatchInbox to it. -func DeployBatchInbox(auth *bind.TransactOpts, backend bind.ContractBackend, _batchAuthenticator common.Address) (common.Address, *types.Transaction, *BatchInbox, error) { +func DeployBatchInbox(auth *bind.TransactOpts, backend bind.ContractBackend, _teeBatcher common.Address, _nonTeeBatcher common.Address, _batchAuthenticator common.Address) (common.Address, *types.Transaction, *BatchInbox, error) { parsed, err := BatchInboxMetaData.GetAbi() if err != nil { return common.Address{}, nil, nil, err @@ -53,7 +53,7 @@ func DeployBatchInbox(auth *bind.TransactOpts, backend bind.ContractBackend, _ba return common.Address{}, nil, nil, errors.New("GetABI returned nil") } - address, tx, contract, err := bind.DeployContract(auth, *parsed, common.FromHex(BatchInboxBin), backend, _batchAuthenticator) + address, tx, contract, err := bind.DeployContract(auth, *parsed, common.FromHex(BatchInboxBin), backend, _teeBatcher, _nonTeeBatcher, _batchAuthenticator) if err != nil { return common.Address{}, nil, nil, err } @@ -202,6 +202,151 @@ func (_BatchInbox *BatchInboxTransactorRaw) Transact(opts *bind.TransactOpts, me return _BatchInbox.Contract.contract.Transact(opts, method, params...) } +// ActiveIsTee is a free data retrieval call binding the contract method 0x7877a9ed. +// +// Solidity: function activeIsTee() view returns(bool) +func (_BatchInbox *BatchInboxCaller) ActiveIsTee(opts *bind.CallOpts) (bool, error) { + var out []interface{} + err := _BatchInbox.contract.Call(opts, &out, "activeIsTee") + + if err != nil { + return *new(bool), err + } + + out0 := *abi.ConvertType(out[0], new(bool)).(*bool) + + return out0, err + +} + +// ActiveIsTee is a free data retrieval call binding the contract method 0x7877a9ed. +// +// Solidity: function activeIsTee() view returns(bool) +func (_BatchInbox *BatchInboxSession) ActiveIsTee() (bool, error) { + return _BatchInbox.Contract.ActiveIsTee(&_BatchInbox.CallOpts) +} + +// ActiveIsTee is a free data retrieval call binding the contract method 0x7877a9ed. +// +// Solidity: function activeIsTee() view returns(bool) +func (_BatchInbox *BatchInboxCallerSession) ActiveIsTee() (bool, error) { + return _BatchInbox.Contract.ActiveIsTee(&_BatchInbox.CallOpts) +} + +// BatchAuthenticator is a free data retrieval call binding the contract method 0xe7584573. +// +// Solidity: function batchAuthenticator() view returns(address) +func (_BatchInbox *BatchInboxCaller) BatchAuthenticator(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _BatchInbox.contract.Call(opts, &out, "batchAuthenticator") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// BatchAuthenticator is a free data retrieval call binding the contract method 0xe7584573. +// +// Solidity: function batchAuthenticator() view returns(address) +func (_BatchInbox *BatchInboxSession) BatchAuthenticator() (common.Address, error) { + return _BatchInbox.Contract.BatchAuthenticator(&_BatchInbox.CallOpts) +} + +// BatchAuthenticator is a free data retrieval call binding the contract method 0xe7584573. +// +// Solidity: function batchAuthenticator() view returns(address) +func (_BatchInbox *BatchInboxCallerSession) BatchAuthenticator() (common.Address, error) { + return _BatchInbox.Contract.BatchAuthenticator(&_BatchInbox.CallOpts) +} + +// NonTeeBatcher is a free data retrieval call binding the contract method 0xb1bd4285. +// +// Solidity: function nonTeeBatcher() view returns(address) +func (_BatchInbox *BatchInboxCaller) NonTeeBatcher(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _BatchInbox.contract.Call(opts, &out, "nonTeeBatcher") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// NonTeeBatcher is a free data retrieval call binding the contract method 0xb1bd4285. +// +// Solidity: function nonTeeBatcher() view returns(address) +func (_BatchInbox *BatchInboxSession) NonTeeBatcher() (common.Address, error) { + return _BatchInbox.Contract.NonTeeBatcher(&_BatchInbox.CallOpts) +} + +// NonTeeBatcher is a free data retrieval call binding the contract method 0xb1bd4285. +// +// Solidity: function nonTeeBatcher() view returns(address) +func (_BatchInbox *BatchInboxCallerSession) NonTeeBatcher() (common.Address, error) { + return _BatchInbox.Contract.NonTeeBatcher(&_BatchInbox.CallOpts) +} + +// TeeBatcher is a free data retrieval call binding the contract method 0xd909ba7c. +// +// Solidity: function teeBatcher() view returns(address) +func (_BatchInbox *BatchInboxCaller) TeeBatcher(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _BatchInbox.contract.Call(opts, &out, "teeBatcher") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// TeeBatcher is a free data retrieval call binding the contract method 0xd909ba7c. +// +// Solidity: function teeBatcher() view returns(address) +func (_BatchInbox *BatchInboxSession) TeeBatcher() (common.Address, error) { + return _BatchInbox.Contract.TeeBatcher(&_BatchInbox.CallOpts) +} + +// TeeBatcher is a free data retrieval call binding the contract method 0xd909ba7c. +// +// Solidity: function teeBatcher() view returns(address) +func (_BatchInbox *BatchInboxCallerSession) TeeBatcher() (common.Address, error) { + return _BatchInbox.Contract.TeeBatcher(&_BatchInbox.CallOpts) +} + +// SwitchBatcher is a paid mutator transaction binding the contract method 0xbc347f47. +// +// Solidity: function switchBatcher() returns() +func (_BatchInbox *BatchInboxTransactor) SwitchBatcher(opts *bind.TransactOpts) (*types.Transaction, error) { + return _BatchInbox.contract.Transact(opts, "switchBatcher") +} + +// SwitchBatcher is a paid mutator transaction binding the contract method 0xbc347f47. +// +// Solidity: function switchBatcher() returns() +func (_BatchInbox *BatchInboxSession) SwitchBatcher() (*types.Transaction, error) { + return _BatchInbox.Contract.SwitchBatcher(&_BatchInbox.TransactOpts) +} + +// SwitchBatcher is a paid mutator transaction binding the contract method 0xbc347f47. +// +// Solidity: function switchBatcher() returns() +func (_BatchInbox *BatchInboxTransactorSession) SwitchBatcher() (*types.Transaction, error) { + return _BatchInbox.Contract.SwitchBatcher(&_BatchInbox.TransactOpts) +} + // Fallback is a paid mutator transaction binding the contract fallback function. // // Solidity: fallback() returns() diff --git a/op-deployer/pkg/deployer/opcm/espresso.go b/op-deployer/pkg/deployer/opcm/espresso.go index 9bd2fdd4c3896..6c917bf1fea79 100644 --- a/op-deployer/pkg/deployer/opcm/espresso.go +++ b/op-deployer/pkg/deployer/opcm/espresso.go @@ -16,9 +16,10 @@ type DeployAWSNitroVerifierOutput struct { } type DeployEspressoInput struct { - Salt common.Hash - PreApprovedBatcherKey common.Address - NitroTEEVerifier common.Address + Salt common.Hash + NitroTEEVerifier common.Address + TeeBatcher common.Address + NonTeeBatcher common.Address } type DeployEspressoOutput struct { diff --git a/op-deployer/pkg/deployer/pipeline/espresso.go b/op-deployer/pkg/deployer/pipeline/espresso.go index 1702c7bfe5374..5a0ee689e08b8 100644 --- a/op-deployer/pkg/deployer/pipeline/espresso.go +++ b/op-deployer/pkg/deployer/pipeline/espresso.go @@ -48,9 +48,10 @@ func DeployEspresso(env *Env, intent *state.Intent, st *state.State, chainID com } eo, err = opcm.DeployEspresso(env.L1ScriptHost, opcm.DeployEspressoInput{ - Salt: st.Create2Salt, - PreApprovedBatcherKey: chainIntent.PreApprovedBatcherKey, - NitroTEEVerifier: nvo.NitroTEEVerifierAddress, + Salt: st.Create2Salt, + NitroTEEVerifier: nvo.NitroTEEVerifierAddress, + TeeBatcher: chainIntent.TeeBatcher, + NonTeeBatcher: chainIntent.NonTeeBatcher, }, batchAuthenticatorOwnwerAddress) if err != nil { return fmt.Errorf("failed to deploy espresso contracts: %w", err) diff --git a/op-deployer/pkg/deployer/state/chain_intent.go b/op-deployer/pkg/deployer/state/chain_intent.go index 600e6e65f3046..938c3c8213e9b 100644 --- a/op-deployer/pkg/deployer/state/chain_intent.go +++ b/op-deployer/pkg/deployer/state/chain_intent.go @@ -76,8 +76,9 @@ type ChainIntent struct { L2DevGenesisParams *L2DevGenesisParams `json:"l2DevGenesisParams,omitempty" toml:"l2DevGenesisParams,omitempty"` // Espresso-specific fields - EspressoEnabled bool `json:"espressoEnabled,omitzero" toml:"espressoEnabled,omitzero"` - PreApprovedBatcherKey common.Address `json:"preApprovedBatcherKey,omitzero" toml:"preApprovedBatcherKey,omitzero"` + EspressoEnabled bool `json:"espressoEnabled,omitzero" toml:"espressoEnabled,omitzero"` + NonTeeBatcher common.Address `json:"nonTeeBatcher,omitzero" toml:"nonTeeBatcher,omitzero"` + TeeBatcher common.Address `json:"teeBatcher,omitzero" toml:"teeBatcher,omitzero"` } type ChainRoles struct { diff --git a/op-e2e/config/init.go b/op-e2e/config/init.go index 0754bdf36769f..220d736ebb6d6 100644 --- a/op-e2e/config/init.go +++ b/op-e2e/config/init.go @@ -36,7 +36,10 @@ import ( _ "embed" ) -const ESPRESSO_PRE_APPROVED_BATCHER_PRIVATE_KEY = "5fede428b9506dee864b0d85aefb2409f4728313eb41da4121409299c487f816" +const ESPRESSO_NON_TEE_BATCHER_PRIVATE_KEY = "5fede428b9506dee864b0d85aefb2409f4728313eb41da4121409299c487f816" + +// cast wallet address --mnemonic "test test ... junk" --hd-path "m/44'/60'/0'/0/5" +const TEE_BATCHER_ADDRESS = "0x9965507D1a55bcC2695C58ba16FB37d819B0A4dc" // legacy geth log levels - the geth command line --verbosity flag wasn't // migrated to use slog's numerical levels. @@ -287,17 +290,15 @@ func initAllocType(root string, allocType AllocType) { } } - if allocType == AllocTypeEspressoWithoutEnclave { - batcherPk, err := crypto.HexToECDSA(ESPRESSO_PRE_APPROVED_BATCHER_PRIVATE_KEY) + // Configure Espresso allocation types + if allocType == AllocTypeEspresso || allocType == AllocTypeEspressoWithoutEnclave || allocType == AllocTypeEspressoWithEnclave { + batcherPk, err := crypto.HexToECDSA(ESPRESSO_NON_TEE_BATCHER_PRIVATE_KEY) if err != nil { panic(fmt.Errorf("failed to parse batcher private key: %w", err)) } intent.Chains[0].EspressoEnabled = true - intent.Chains[0].PreApprovedBatcherKey = crypto.PubkeyToAddress(batcherPk.PublicKey) - } - - if allocType == AllocTypeEspressoWithEnclave { - intent.Chains[0].EspressoEnabled = true + intent.Chains[0].NonTeeBatcher = crypto.PubkeyToAddress(batcherPk.PublicKey) + intent.Chains[0].TeeBatcher = common.HexToAddress(TEE_BATCHER_ADDRESS) } baseUpgradeSchedule := map[string]any{ diff --git a/op-e2e/system/e2esys/setup.go b/op-e2e/system/e2esys/setup.go index b99b6ddbffbbc..9b8e87a04d68d 100644 --- a/op-e2e/system/e2esys/setup.go +++ b/op-e2e/system/e2esys/setup.go @@ -1016,12 +1016,12 @@ func (cfg SystemConfig) Start(t *testing.T, startOpts ...StartOption) (*System, batcherTargetNumFrames = 1 } - testingBatcherPk, err := crypto.HexToECDSA(config.ESPRESSO_PRE_APPROVED_BATCHER_PRIVATE_KEY) + testingBatcherPk, err := crypto.HexToECDSA(config.ESPRESSO_NON_TEE_BATCHER_PRIVATE_KEY) if err != nil { return nil, fmt.Errorf("failed to parse pre-approved batcher private key: %w", err) } espressoCfg := espresso.CLIConfig{ - Enabled: (cfg.AllocType == config.AllocTypeEspressoWithEnclave) || (cfg.AllocType == config.AllocTypeEspressoWithoutEnclave), + Enabled: (cfg.AllocType == config.AllocTypeEspresso) || (cfg.AllocType == config.AllocTypeEspressoWithEnclave) || (cfg.AllocType == config.AllocTypeEspressoWithoutEnclave), PollInterval: 250 * time.Millisecond, L1URL: sys.EthInstances[RoleL1].UserRPC().RPC(), RollupL1URL: sys.EthInstances[RoleL1].UserRPC().RPC(), diff --git a/packages/contracts-bedrock/interfaces/L1/IBatchInbox.sol b/packages/contracts-bedrock/interfaces/L1/IBatchInbox.sol index afddfcc3c1e8b..296552db8ae94 100644 --- a/packages/contracts-bedrock/interfaces/L1/IBatchInbox.sol +++ b/packages/contracts-bedrock/interfaces/L1/IBatchInbox.sol @@ -6,5 +6,5 @@ interface IBatchInbox { function version() external view returns (string memory); - function __constructor__(address _batchAuthenticator) external; + function __constructor__(address _teeBatcher, address _nonTeeBatcher, address _batchAuthenticator) external; } diff --git a/packages/contracts-bedrock/scripts/deploy/DeployEspresso.s.sol b/packages/contracts-bedrock/scripts/deploy/DeployEspresso.s.sol index 0b1ee985b06b6..5db93f356c1a6 100644 --- a/packages/contracts-bedrock/scripts/deploy/DeployEspresso.s.sol +++ b/packages/contracts-bedrock/scripts/deploy/DeployEspresso.s.sol @@ -14,8 +14,9 @@ import { EspressoTEEVerifier } from "@espresso-tee-contracts/EspressoTEEVerifier contract DeployEspressoInput is BaseDeployIO { bytes32 internal _salt; - address internal _preApprovedBatcherKey; address internal _nitroTEEVerifier; + address internal _teeBatcher; + address internal _nonTeeBatcher; function set(bytes4 _sel, bytes32 _val) public { if (_sel == this.salt.selector) _salt = _val; @@ -23,10 +24,12 @@ contract DeployEspressoInput is BaseDeployIO { } function set(bytes4 _sel, address _val) public { - if (_sel == this.preApprovedBatcherKey.selector) { - _preApprovedBatcherKey = _val; - } else if (_sel == this.nitroTEEVerifier.selector) { + if (_sel == this.nitroTEEVerifier.selector) { _nitroTEEVerifier = _val; + } else if (_sel == this.teeBatcher.selector) { + _teeBatcher = _val; + } else if (_sel == this.nonTeeBatcher.selector) { + _nonTeeBatcher = _val; } else { revert("DeployEspressoInput: unknown selector"); } @@ -41,8 +44,12 @@ contract DeployEspressoInput is BaseDeployIO { return _nitroTEEVerifier; } - function preApprovedBatcherKey() public view returns (address) { - return _preApprovedBatcherKey; + function teeBatcher() public view returns (address) { + return _teeBatcher; + } + + function nonTeeBatcher() public view returns (address) { + return _nonTeeBatcher; } } @@ -90,7 +97,6 @@ contract DeployEspresso is Script { returns (IBatchAuthenticator) { bytes32 salt = input.salt(); - address preApprovedBatcherKey = input.preApprovedBatcherKey(); vm.broadcast(msg.sender); IBatchAuthenticator impl = IBatchAuthenticator( DeployUtils.create2({ @@ -98,7 +104,7 @@ contract DeployEspresso is Script { _salt: salt, _args: DeployUtils.encodeConstructor( abi.encodeCall( - IBatchAuthenticator.__constructor__, (address(teeVerifier), preApprovedBatcherKey, owner) + IBatchAuthenticator.__constructor__, (address(teeVerifier), input.nonTeeBatcher(), owner) ) ) }) @@ -135,7 +141,10 @@ contract DeployEspresso is Script { _name: "BatchInbox", _salt: salt, _args: DeployUtils.encodeConstructor( - abi.encodeCall(IBatchInbox.__constructor__, (address(batchAuthenticator))) + abi.encodeCall( + IBatchInbox.__constructor__, + (input.teeBatcher(), input.nonTeeBatcher(), address(batchAuthenticator)) + ) ) }) ); diff --git a/packages/contracts-bedrock/src/L1/BatchInbox.sol b/packages/contracts-bedrock/src/L1/BatchInbox.sol index d9650326cdca4..91bb343f668b2 100644 --- a/packages/contracts-bedrock/src/L1/BatchInbox.sol +++ b/packages/contracts-bedrock/src/L1/BatchInbox.sol @@ -3,30 +3,84 @@ pragma solidity 0.8.28; import { IBatchAuthenticator } from "interfaces/L1/IBatchAuthenticator.sol"; +/// @title BatchInbox +/// @notice Receives batches from either a TEE batcher or a non-TEE batcher and enforces +/// that TEE batches are authenticated by the configured batch authenticator. contract BatchInbox { - IBatchAuthenticator immutable batchAuthenticator; + /// @notice Address of the TEE-based batcher. + address public immutable teeBatcher; - constructor(IBatchAuthenticator _batchAuthenticator) { + /// @notice Address of the non-TEE (fallback) batcher. + address public immutable nonTeeBatcher; + + /// @notice Contract responsible for authenticating TEE batch commitments. + IBatchAuthenticator public immutable batchAuthenticator; + + /// @notice Flag indicating which batcher is currently active. + /// @dev When true the TEE batcher is active; when false the non-TEE batcher is active. + bool public activeIsTee; + + /// @notice Initializes the contract with the TEE and non-TEE batcher addresses + /// and the batch authenticator. + /// @param _teeBatcher Address of the TEE batcher. + /// @param _nonTeeBatcher Address of the non-TEE batcher. + /// @param _batchAuthenticator Address of the batch authenticator contract. + constructor(address _teeBatcher, address _nonTeeBatcher, IBatchAuthenticator _batchAuthenticator) { + require(_teeBatcher != address(0) && _nonTeeBatcher != address(0), "BatchInbox: zero batcher"); + //require(_teeBatcher != _nonTeeBatcher, "BatchInbox: identical batchers"); + teeBatcher = _teeBatcher; + nonTeeBatcher = _nonTeeBatcher; batchAuthenticator = _batchAuthenticator; + // By default, start with the TEE batcher active + activeIsTee = true; } + /// @notice Toggles the active batcher between the TEE and non-TEE batcher. + function switchBatcher() external { + activeIsTee = !activeIsTee; + } + + /// @notice Fallback entry point for batch submissions. + /// @dev Enforces that the caller matches the currently active batcher and, when + /// the TEE batcher is active, that the batch commitment is approved by + /// the batch authenticator. For non-TEE batches, only the caller check + /// is enforced. fallback() external { - if (blobhash(0) != 0) { - bytes memory concatenatedHashes = new bytes(0); - uint256 currentBlob = 0; - while (blobhash(currentBlob) != 0) { - concatenatedHashes = bytes.concat(concatenatedHashes, blobhash(currentBlob)); - currentBlob++; - } - bytes32 hash = keccak256(concatenatedHashes); - if (!batchAuthenticator.validBatchInfo(hash)) { - revert("Invalid blob batch"); + address expectedBatcher = activeIsTee ? teeBatcher : nonTeeBatcher; + if (msg.sender != expectedBatcher) { + revert("BatchInbox: unauthorized batcher"); + } + + // Only TEE batchers require authentication + if (activeIsTee) { + if (blobhash(0) != 0) { + bytes memory concatenatedHashes = new bytes(0); + uint256 currentBlob = 0; + while (blobhash(currentBlob) != 0) { + concatenatedHashes = bytes.concat(concatenatedHashes, blobhash(currentBlob)); + currentBlob++; + } + bytes32 hash = keccak256(concatenatedHashes); + if (!batchAuthenticator.validBatchInfo(hash)) { + revert("Invalid blob batch"); + } + } else { + bytes32 hash = keccak256(msg.data); + if (!batchAuthenticator.validBatchInfo(hash)) { + revert("Invalid calldata batch"); + } } + } + } + + /// @notice Returns the currently active batcher and whether it is the TEE batcher. + /// @return active Address of the currently active batcher. + /// @return isTee True if the active batcher is the TEE batcher, false if it is the non-TEE batcher. + function _activeBatcher() internal view returns (address active, bool isTee) { + if (activeIsTee) { + return (teeBatcher, true); } else { - bytes32 hash = keccak256(msg.data); - if (!batchAuthenticator.validBatchInfo(hash)) { - revert("Invalid calldata batch"); - } + return (nonTeeBatcher, false); } } } diff --git a/packages/contracts-bedrock/test/L1/BatchInbox.t.sol b/packages/contracts-bedrock/test/L1/BatchInbox.t.sol new file mode 100644 index 0000000000000..990d3d8a1777f --- /dev/null +++ b/packages/contracts-bedrock/test/L1/BatchInbox.t.sol @@ -0,0 +1,191 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.28; + +// Testing +import { Test } from "forge-std/Test.sol"; + +// Contracts +import { BatchInbox } from "src/L1/BatchInbox.sol"; +import { IBatchAuthenticator } from "interfaces/L1/IBatchAuthenticator.sol"; + +/// @title MockBatchAuthenticator +/// @notice Mock implementation for testing - only implements validBatchInfo +contract MockBatchAuthenticator { + mapping(bytes32 => bool) private validHashes; + + function setValidBatchInfo(bytes32 hash, bool valid) external { + validHashes[hash] = valid; + } + + function validBatchInfo(bytes32 hash) external view returns (bool) { + return validHashes[hash]; + } +} + +/// @title BatchInbox_Test +/// @notice Base test contract with common setup +contract BatchInbox_Test is Test { + BatchInbox public inbox; + MockBatchAuthenticator public authenticator; + + address public teeBatcher = address(0x1234); + address public nonTeeBatcher = address(0x5678); + address public deployer = address(0xABCD); + address public unauthorized = address(0xDEAD); + + function setUp() public virtual { + authenticator = new MockBatchAuthenticator(); + inbox = new BatchInbox(teeBatcher, nonTeeBatcher, IBatchAuthenticator(address(authenticator))); + } +} + +/// @title BatchInbox_Constructor_Test +/// @notice Tests for the BatchInbox constructor +contract BatchInbox_Constructor_Test is Test { + address teeBatcher = address(0x1234); + address nonTeeBatcher = address(0x5678); + address batchAuthenticator = address(0x9ABC); + + /// @notice Test that constructor reverts when TEE batcher is zero address + function test_constructor_revertsWhenTeeBatcherIsZero() external { + vm.expectRevert("BatchInbox: zero batcher"); + new BatchInbox(address(0), nonTeeBatcher, IBatchAuthenticator(batchAuthenticator)); + } + + /// @notice Test that constructor reverts when non-TEE batcher is zero address + function test_constructor_revertsWhenNonTeeBatcherIsZero() external { + vm.expectRevert("BatchInbox: zero batcher"); + new BatchInbox(teeBatcher, address(0), IBatchAuthenticator(batchAuthenticator)); + } + + /// @notice Test that constructor reverts when both batchers are zero addresses + function test_constructor_revertsWhenBothBatchersAreZero() external { + vm.expectRevert("BatchInbox: zero batcher"); + new BatchInbox(address(0), address(0), IBatchAuthenticator(batchAuthenticator)); + } + + /// @notice Test that constructor reverts when TEE and non-TEE batcher addresses are identical + function test_constructor_revertsWhenBatchersAreEqual() external { + address same = address(0xBEEF); + vm.expectRevert("BatchInbox: identical batchers"); + new BatchInbox(same, same, IBatchAuthenticator(batchAuthenticator)); + } + + /// @notice Test that constructor succeeds with valid addresses + function test_constructor_succeedsWithValidAddresses() external { + BatchInbox testInbox = new BatchInbox(teeBatcher, nonTeeBatcher, IBatchAuthenticator(batchAuthenticator)); + + assertEq(testInbox.teeBatcher(), teeBatcher, "TEE batcher should match"); + assertEq(testInbox.nonTeeBatcher(), nonTeeBatcher, "Non-TEE batcher should match"); + assertEq(address(testInbox.batchAuthenticator()), batchAuthenticator, "Batch authenticator should match"); + assertTrue(testInbox.activeIsTee(), "Active batcher should be TEE by default"); + } +} + +/// @title BatchInbox_SwitchBatcher_Test +/// @notice Tests for switching between batchers +contract BatchInbox_SwitchBatcher_Test is BatchInbox_Test { + /// @notice Test that switchBatcher toggles the active batcher + function test_switchBatcher_togglesActiveBatcher() external { + // Initially TEE batcher is active + assertTrue(inbox.activeIsTee(), "Should start with TEE batcher active"); + + // Switch to non-TEE batcher + inbox.switchBatcher(); + assertFalse(inbox.activeIsTee(), "Should switch to non-TEE batcher"); + + // Switch back to TEE batcher + inbox.switchBatcher(); + assertTrue(inbox.activeIsTee(), "Should switch back to TEE batcher"); + } +} + +/// @title BatchInbox_Fallback_Test +/// @notice Tests for the fallback function +contract BatchInbox_Fallback_Test is BatchInbox_Test { + /// @notice Test that non-TEE batcher can post after switching + function test_fallback_nonTeeBatcherCanPostAfterSwitch() external { + // Switch to non-TEE batcher + inbox.switchBatcher(); + + // Non-TEE batcher should be able to post + vm.prank(nonTeeBatcher); + (bool success,) = address(inbox).call("hello"); + assertTrue(success, "Non-TEE batcher should be able to post"); + } + + /// @notice Test that inactive batcher reverts + function test_fallback_inactiveBatcherReverts() external { + // Switch to non-TEE batcher (making TEE batcher inactive) + inbox.switchBatcher(); + + // TEE batcher (now inactive) should revert + vm.prank(teeBatcher); + (bool success, bytes memory returnData) = address(inbox).call("unauthorized"); + assertFalse(success, "Should revert"); + // Check the revert reason + assertEq( + string(returnData), string(abi.encodeWithSignature("Error(string)", "BatchInbox: unauthorized batcher")) + ); + } + + /// @notice Test that TEE batcher requires authentication + function test_fallback_teeBatcherRequiresAuthentication() external { + // TEE batcher is active by default + bytes memory data = "needs-auth"; + bytes32 hash = keccak256(data); + + // Don't set the hash as valid in authenticator + authenticator.setValidBatchInfo(hash, false); + + // TEE batcher should revert due to invalid authentication + vm.prank(teeBatcher); + (bool success, bytes memory returnData) = address(inbox).call(data); + assertFalse(success, "Should revert"); + // Check the revert reason + assertEq(string(returnData), string(abi.encodeWithSignature("Error(string)", "Invalid calldata batch"))); + } + + /// @notice Test that TEE batcher succeeds with valid authentication + function test_fallback_teeBatcherSucceedsWithValidAuth() external { + // TEE batcher is active by default + bytes memory data = "valid-batch"; + bytes32 hash = keccak256(data); + + // Set the hash as valid in authenticator + authenticator.setValidBatchInfo(hash, true); + + // TEE batcher should succeed + vm.prank(teeBatcher); + (bool success,) = address(inbox).call(data); + assertTrue(success, "TEE batcher should succeed with valid auth"); + } + + /// @notice Test that non-TEE batcher doesn't require authentication + function test_fallback_nonTeeBatcherDoesNotRequireAuth() external { + // Switch to non-TEE batcher + inbox.switchBatcher(); + + bytes memory data = "no-auth-needed"; + // Don't set any authentication + + // Non-TEE batcher should succeed without authentication + vm.prank(nonTeeBatcher); + (bool success,) = address(inbox).call(data); + assertTrue(success, "Non-TEE batcher should not require auth"); + } + + /// @notice Test that unauthorized address cannot post + function test_fallback_unauthorizedAddressReverts() external { + // Try with unauthorized address when TEE is active + vm.prank(unauthorized); + (bool success,) = address(inbox).call("unauthorized"); + assertFalse(success, "Unauthorized should revert when TEE is active"); + + // Switch to non-TEE and try again + inbox.switchBatcher(); + vm.prank(unauthorized); + (success,) = address(inbox).call("unauthorized"); + assertFalse(success, "Unauthorized should revert when non-TEE is active"); + } +}