diff --git a/.gitignore b/.gitignore index 4454403bcc..9786e3e7c1 100644 --- a/.gitignore +++ b/.gitignore @@ -13,5 +13,4 @@ /test/contracts/bin/**/*.abi **/.DS_Store -.vscode -.idea/ \ No newline at end of file +.vscode \ No newline at end of file diff --git a/aggregator/aggregator.go b/aggregator/aggregator.go index 5be7052438..1117712971 100644 --- a/aggregator/aggregator.go +++ b/aggregator/aggregator.go @@ -33,7 +33,7 @@ type Aggregator struct { // NewAggregator creates a new aggregator func NewAggregator( cfg Config, - stateInterface stateInterface, + state stateInterface, ethTxManager ethTxManager, etherman etherman, grpcClientConns []*grpc.ClientConn, @@ -41,57 +41,33 @@ func NewAggregator( var profitabilityChecker aggregatorTxProfitabilityChecker switch cfg.TxProfitabilityCheckerType { case ProfitabilityBase: - profitabilityChecker = NewTxProfitabilityCheckerBase(stateInterface, cfg.IntervalAfterWhichBatchConsolidateAnyway.Duration, cfg.TxProfitabilityMinReward.Int) + profitabilityChecker = NewTxProfitabilityCheckerBase(state, cfg.IntervalAfterWhichBatchConsolidateAnyway.Duration, cfg.TxProfitabilityMinReward.Int) case ProfitabilityAcceptAll: - profitabilityChecker = NewTxProfitabilityCheckerAcceptAll(stateInterface, cfg.IntervalAfterWhichBatchConsolidateAnyway.Duration) + profitabilityChecker = NewTxProfitabilityCheckerAcceptAll(state, cfg.IntervalAfterWhichBatchConsolidateAnyway.Duration) } proverClients := make([]proverClientInterface, 0, len(cfg.ProverURIs)) - ctx := context.Background() - - a := Aggregator{ - cfg: cfg, - - State: stateInterface, - EthTxManager: ethTxManager, - Ethman: etherman, - ProverClients: proverClients, - ProfitabilityChecker: profitabilityChecker, - } for _, proverURI := range cfg.ProverURIs { proverClient := prover.NewClient(proverURI, cfg.IntervalFrequencyToGetProofGenerationState) proverClients = append(proverClients, proverClient) grpcClientConns = append(grpcClientConns, proverClient.Prover.Conn) log.Infof("Connected to prover %v", proverURI) + } - // Check if prover is already working in a proof generation - proof, err := stateInterface.GetWIPProofByProver(ctx, proverURI, nil) - if err != nil && err != state.ErrNotFound { - log.Errorf("Error while getting WIP proof for prover %v", proverURI) - continue - } + a := Aggregator{ + cfg: cfg, - if proof != nil { - log.Infof("Resuming WIP proof generation for batchNumber %v in prover %v", proof.BatchNumber, *proof.Prover) - go func() { - a.resumeWIPProofGeneration(ctx, proof, proverClient) - }() - } + State: state, + EthTxManager: ethTxManager, + Ethman: etherman, + ProverClients: proverClients, + ProfitabilityChecker: profitabilityChecker, } - a.ProverClients = proverClients - return a, nil } -func (a *Aggregator) resumeWIPProofGeneration(ctx context.Context, proof *state.Proof, prover proverClientInterface) { - err := a.getAndStoreProof(ctx, proof, prover) - if err != nil { - log.Warnf("Could not resume WIP Proof Generation for prover %v and batchNumber %v", *proof.Prover, proof.BatchNumber) - } -} - // Start starts the aggregator func (a *Aggregator) Start(ctx context.Context) { // define those vars here, bcs it can be used in case <-a.ctx.Done() @@ -100,13 +76,19 @@ func (a *Aggregator) Start(ctx context.Context) { defer tickerVerifyBatch.Stop() defer tickerSendVerifiedBatch.Stop() + // Delete proofs that where being generated during last reboot + err := a.State.DeleteUngeneratedProofs(ctx, nil) + if err != nil && err != state.ErrNotFound { + log.Warn("error deleting work in progress proofs from state") + } + for i := 0; i < len(a.ProverClients); i++ { go func() { for { a.tryVerifyBatch(ctx, tickerVerifyBatch) } }() - time.Sleep(10 * time.Second) //nolint:gomnd + time.Sleep(time.Second) } go func() { @@ -146,15 +128,10 @@ func (a *Aggregator) tryToSendVerifiedBatch(ctx context.Context, ticker *time.Ti return } - if proof != nil && proof.Proof != nil { + if proof != nil { log.Infof("sending verified proof to the ethereum smart contract, batchNumber %d", batchNumberToVerify) - err := a.EthTxManager.VerifyBatch(batchNumberToVerify, proof.Proof) - if err != nil { - log.Errorf("proof for the batch was NOT sent, batchNumber: %v, error: %w", batchNumberToVerify, err) - } else { - log.Infof("proof for the batch was sent, batchNumber: %v", batchNumberToVerify) - } - + a.EthTxManager.VerifyBatch(batchNumberToVerify, proof) + log.Infof("proof for the batch was sent, batchNumber: %v", batchNumberToVerify) /* err := a.State.DeleteGeneratedProof(ctx, batchNumberToVerify, nil) if err != nil { @@ -171,6 +148,7 @@ func (a *Aggregator) tryToSendVerifiedBatch(ctx context.Context, ticker *time.Ti func (a *Aggregator) tryVerifyBatch(ctx context.Context, ticker *time.Ticker) { log.Info("checking if network is synced") + for !a.isSynced(ctx) { log.Infof("waiting for synchronizer to sync...") waitTick(ctx, ticker) @@ -213,6 +191,7 @@ func (a *Aggregator) tryVerifyBatch(ctx context.Context, ticker *time.Ticker) { // Look for a free prover for _, prover = range a.ProverClients { if prover.IsIdle(ctx) { + log.Infof("Prover %s is going to be used for batchNumber: %d", prover.GetURI(), batchToVerify.BatchNumber) idleProverFound = true break } @@ -224,23 +203,18 @@ func (a *Aggregator) tryVerifyBatch(ctx context.Context, ticker *time.Ticker) { return } - proverURI := prover.GetURI() - proof := &state.Proof{BatchNumber: batchToVerify.BatchNumber, Prover: &proverURI, InputProver: inputProver} - // Avoid other thread to process the same batch - err = a.State.AddGeneratedProof(ctx, proof, nil) + err = a.State.AddGeneratedProof(ctx, batchToVerify.BatchNumber, nil, nil) if err != nil { - log.Warnf("failed to create proof generation mark, err: %v", err) + log.Warnf("failed to store proof generation mark, err: %v", err) waitTick(ctx, ticker) return } - log.Infof("Prover %s is going to be used for batchNumber: %d", prover.GetURI(), batchToVerify.BatchNumber) - genProofID, err := prover.GetGenProofID(ctx, inputProver) if err != nil { log.Warnf("failed to get gen proof id, err: %v", err) - err2 := a.State.DeleteGeneratedProof(ctx, proof.BatchNumber, nil) + err2 := a.State.DeleteGeneratedProof(ctx, batchToVerify.BatchNumber, nil) if err2 != nil { log.Errorf("failed to delete proof generation mark after error, err: %v", err2) } @@ -248,64 +222,41 @@ func (a *Aggregator) tryVerifyBatch(ctx context.Context, ticker *time.Ticker) { return } - proof.ProofID = &genProofID + log.Infof("Proof ID for batchNumber %d: %v", batchToVerify.BatchNumber, genProofID) - // Avoid other thread to process the same batch - err = a.State.UpdateGeneratedProof(ctx, proof, nil) - if err != nil { - log.Warnf("failed to update proof generation mark, err: %v", err) - waitTick(ctx, ticker) - return - } - - log.Infof("Proof ID for batchNumber %d: %v", proof.BatchNumber, *proof.ProofID) - - err = a.getAndStoreProof(ctx, proof, prover) - if err != nil { - waitTick(ctx, ticker) - return - } -} - -func (a *Aggregator) getAndStoreProof(ctx context.Context, proof *state.Proof, prover proverClientInterface) error { - resGetProof, err := prover.GetResGetProof(ctx, *proof.ProofID, proof.BatchNumber) + resGetProof, err := prover.GetResGetProof(ctx, genProofID, batchToVerify.BatchNumber) if err != nil { log.Warnf("failed to get proof from prover, err: %v", err) - err2 := a.State.DeleteGeneratedProof(ctx, proof.BatchNumber, nil) + err2 := a.State.DeleteGeneratedProof(ctx, batchToVerify.BatchNumber, nil) if err2 != nil { log.Errorf("failed to delete proof generation mark after error, err: %v", err2) - return err2 } - return err + waitTick(ctx, ticker) + return } - - proof.Proof = resGetProof - - a.compareInputHashes(proof.InputProver, proof.Proof) + a.compareInputHashes(inputProver, resGetProof) // Handle local exit root in the case of the mock prover - if proof.Proof.Public.PublicInputs.NewLocalExitRoot == "0x17c04c3760510b48c6012742c540a81aba4bca2f78b9d14bfd2f123e2e53ea3e" { + if resGetProof.Public.PublicInputs.NewLocalExitRoot == "0x17c04c3760510b48c6012742c540a81aba4bca2f78b9d14bfd2f123e2e53ea3e" { // This local exit root comes from the mock, use the one captured by the executor instead log.Warnf( "NewLocalExitRoot looks like a mock value, using value from executor instead: %v", - proof.InputProver.PublicInputs.NewLocalExitRoot, + inputProver.PublicInputs.NewLocalExitRoot, ) - resGetProof.Public.PublicInputs.NewLocalExitRoot = proof.InputProver.PublicInputs.NewLocalExitRoot + resGetProof.Public.PublicInputs.NewLocalExitRoot = inputProver.PublicInputs.NewLocalExitRoot } // Store proof - err = a.State.UpdateGeneratedProof(ctx, proof, nil) + err = a.State.UpdateGeneratedProof(ctx, batchToVerify.BatchNumber, resGetProof, nil) if err != nil { log.Warnf("failed to store generated proof, err: %v", err) - err2 := a.State.DeleteGeneratedProof(ctx, proof.BatchNumber, nil) + err2 := a.State.DeleteGeneratedProof(ctx, batchToVerify.BatchNumber, nil) if err2 != nil { log.Errorf("failed to delete proof generation mark after error, err: %v", err2) - return err2 } - return err + waitTick(ctx, ticker) + return } - - return nil } func (a *Aggregator) isSynced(ctx context.Context) bool { diff --git a/aggregator/aggregator_internal_test.go b/aggregator/aggregator_internal_test.go index 4d11c8b9cb..31a16cc90a 100644 --- a/aggregator/aggregator_internal_test.go +++ b/aggregator/aggregator_internal_test.go @@ -268,8 +268,8 @@ func TestAggregatorFlow(t *testing.T) { proverClient.On("GetURI", mock.Anything).Return("mockProver:MockPort") st.On("GetLastVerifiedBatch", mock.Anything, nil).Return(verifiedBatch, nil) st.On("GetGeneratedProofByBatchNumber", mock.Anything, verifiedBatch.BatchNumber+1, nil).Return(nil, state.ErrNotFound) - st.On("AddGeneratedProof", mock.Anything, mock.Anything, nil).Return(nil) - st.On("UpdateGeneratedProof", mock.Anything, mock.Anything, nil).Return(nil) + st.On("AddGeneratedProof", mock.Anything, mock.Anything, mock.Anything, nil).Return(nil) + st.On("UpdateGeneratedProof", mock.Anything, mock.Anything, mock.Anything, nil).Return(nil) etherman.On("GetLatestVerifiedBatchNum").Return(uint64(1), nil) etherman.On("GetPublicAddress").Return(aggrAddress) diff --git a/aggregator/interfaces.go b/aggregator/interfaces.go index dfd0439280..258ec1a66b 100644 --- a/aggregator/interfaces.go +++ b/aggregator/interfaces.go @@ -15,7 +15,7 @@ import ( // ethTxManager contains the methods required to send txs to // ethereum. type ethTxManager interface { - VerifyBatch(batchNum uint64, proof *pb.GetProofResponse) error + VerifyBatch(batchNum uint64, proof *pb.GetProofResponse) } // etherman contains the methods required to interact with ethereum @@ -43,10 +43,9 @@ type stateInterface interface { GetLastVerifiedBatch(ctx context.Context, dbTx pgx.Tx) (*state.VerifiedBatch, error) GetVirtualBatchByNumber(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*state.Batch, error) GetBatchByNumber(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*state.Batch, error) - AddGeneratedProof(ctx context.Context, proof *state.Proof, dbTx pgx.Tx) error - UpdateGeneratedProof(ctx context.Context, proof *state.Proof, dbTx pgx.Tx) error - GetGeneratedProofByBatchNumber(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*state.Proof, error) + AddGeneratedProof(ctx context.Context, batchNumber uint64, proof *pb.GetProofResponse, dbTx pgx.Tx) error + UpdateGeneratedProof(ctx context.Context, batchNumber uint64, proof *pb.GetProofResponse, dbTx pgx.Tx) error + GetGeneratedProofByBatchNumber(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*pb.GetProofResponse, error) DeleteGeneratedProof(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) error DeleteUngeneratedProofs(ctx context.Context, dbTx pgx.Tx) error - GetWIPProofByProver(ctx context.Context, prover string, dbTx pgx.Tx) (*state.Proof, error) } diff --git a/aggregator/mocks/mock_ethtxmanager.go b/aggregator/mocks/mock_ethtxmanager.go index e21529da6e..9dfa32f862 100644 --- a/aggregator/mocks/mock_ethtxmanager.go +++ b/aggregator/mocks/mock_ethtxmanager.go @@ -13,17 +13,8 @@ type EthTxManager struct { } // VerifyBatch provides a mock function with given fields: batchNum, proof -func (_m *EthTxManager) VerifyBatch(batchNum uint64, proof *pb.GetProofResponse) error { - ret := _m.Called(batchNum, proof) - - var r0 error - if rf, ok := ret.Get(0).(func(uint64, *pb.GetProofResponse) error); ok { - r0 = rf(batchNum, proof) - } else { - r0 = ret.Error(0) - } - - return r0 +func (_m *EthTxManager) VerifyBatch(batchNum uint64, proof *pb.GetProofResponse) { + _m.Called(batchNum, proof) } type mockConstructorTestingTNewEthTxManager interface { diff --git a/aggregator/mocks/mock_state.go b/aggregator/mocks/mock_state.go index cad0693ce1..3aad477055 100644 --- a/aggregator/mocks/mock_state.go +++ b/aggregator/mocks/mock_state.go @@ -5,9 +5,11 @@ package mocks import ( context "context" - pgx "github.com/jackc/pgx/v4" + pb "github.com/0xPolygonHermez/zkevm-node/proverclient/pb" mock "github.com/stretchr/testify/mock" + pgx "github.com/jackc/pgx/v4" + state "github.com/0xPolygonHermez/zkevm-node/state" ) @@ -16,13 +18,13 @@ type StateMock struct { mock.Mock } -// AddGeneratedProof provides a mock function with given fields: ctx, proof, dbTx -func (_m *StateMock) AddGeneratedProof(ctx context.Context, proof *state.Proof, dbTx pgx.Tx) error { - ret := _m.Called(ctx, proof, dbTx) +// AddGeneratedProof provides a mock function with given fields: ctx, batchNumber, proof, dbTx +func (_m *StateMock) AddGeneratedProof(ctx context.Context, batchNumber uint64, proof *pb.GetProofResponse, dbTx pgx.Tx) error { + ret := _m.Called(ctx, batchNumber, proof, dbTx) var r0 error - if rf, ok := ret.Get(0).(func(context.Context, *state.Proof, pgx.Tx) error); ok { - r0 = rf(ctx, proof, dbTx) + if rf, ok := ret.Get(0).(func(context.Context, uint64, *pb.GetProofResponse, pgx.Tx) error); ok { + r0 = rf(ctx, batchNumber, proof, dbTx) } else { r0 = ret.Error(0) } @@ -82,15 +84,15 @@ func (_m *StateMock) GetBatchByNumber(ctx context.Context, batchNumber uint64, d } // GetGeneratedProofByBatchNumber provides a mock function with given fields: ctx, batchNumber, dbTx -func (_m *StateMock) GetGeneratedProofByBatchNumber(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*state.Proof, error) { +func (_m *StateMock) GetGeneratedProofByBatchNumber(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*pb.GetProofResponse, error) { ret := _m.Called(ctx, batchNumber, dbTx) - var r0 *state.Proof - if rf, ok := ret.Get(0).(func(context.Context, uint64, pgx.Tx) *state.Proof); ok { + var r0 *pb.GetProofResponse + if rf, ok := ret.Get(0).(func(context.Context, uint64, pgx.Tx) *pb.GetProofResponse); ok { r0 = rf(ctx, batchNumber, dbTx) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*state.Proof) + r0 = ret.Get(0).(*pb.GetProofResponse) } } @@ -150,36 +152,13 @@ func (_m *StateMock) GetVirtualBatchByNumber(ctx context.Context, batchNumber ui return r0, r1 } -// GetWIPProofByProver provides a mock function with given fields: ctx, prover, dbTx -func (_m *StateMock) GetWIPProofByProver(ctx context.Context, prover string, dbTx pgx.Tx) (*state.Proof, error) { - ret := _m.Called(ctx, prover, dbTx) - - var r0 *state.Proof - if rf, ok := ret.Get(0).(func(context.Context, string, pgx.Tx) *state.Proof); ok { - r0 = rf(ctx, prover, dbTx) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*state.Proof) - } - } - - var r1 error - if rf, ok := ret.Get(1).(func(context.Context, string, pgx.Tx) error); ok { - r1 = rf(ctx, prover, dbTx) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// UpdateGeneratedProof provides a mock function with given fields: ctx, proof, dbTx -func (_m *StateMock) UpdateGeneratedProof(ctx context.Context, proof *state.Proof, dbTx pgx.Tx) error { - ret := _m.Called(ctx, proof, dbTx) +// UpdateGeneratedProof provides a mock function with given fields: ctx, batchNumber, proof, dbTx +func (_m *StateMock) UpdateGeneratedProof(ctx context.Context, batchNumber uint64, proof *pb.GetProofResponse, dbTx pgx.Tx) error { + ret := _m.Called(ctx, batchNumber, proof, dbTx) var r0 error - if rf, ok := ret.Get(0).(func(context.Context, *state.Proof, pgx.Tx) error); ok { - r0 = rf(ctx, proof, dbTx) + if rf, ok := ret.Get(0).(func(context.Context, uint64, *pb.GetProofResponse, pgx.Tx) error); ok { + r0 = rf(ctx, batchNumber, proof, dbTx) } else { r0 = ret.Error(0) } diff --git a/aggregator/prover/client.go b/aggregator/prover/client.go index 5260da174a..2669b6bb56 100644 --- a/aggregator/prover/client.go +++ b/aggregator/prover/client.go @@ -32,9 +32,6 @@ func (c *Client) GetURI() string { // IsIdle indicates the prover is ready to process requests func (c *Client) IsIdle(ctx context.Context) bool { - if !c.Prover.Working { - return false - } var opts []grpc.CallOption status, err := c.Prover.Client.GetStatus(ctx, &pb.GetStatusRequest{}, opts...) if err != nil || status.State != pb.GetStatusResponse_STATUS_PROVER_IDLE { diff --git a/aggregator/prover/prover.go b/aggregator/prover/prover.go index e1ef1f9db1..d9fd324d7f 100644 --- a/aggregator/prover/prover.go +++ b/aggregator/prover/prover.go @@ -13,10 +13,9 @@ import ( // Prover struct type Prover struct { - URI string - Client proverclientpb.ZKProverServiceClient - Conn *grpc.ClientConn - Working bool + URI string + Client proverclientpb.ZKProverServiceClient + Conn *grpc.ClientConn } // NewProver creates a new Prover @@ -35,7 +34,6 @@ func NewProver(proverURI string) *Prover { proverClient := proverclientpb.NewZKProverServiceClient(proverConn) prover := &Prover{URI: proverURI, Client: proverClient, Conn: proverConn} - prover.Working = false go func() { waitTick(ctx, tickerCheckConnection) @@ -52,7 +50,6 @@ func (p *Prover) checkConnection(ctx context.Context, ticker *time.Ticker) { log.Debugf("Checking connection to prover %v. State: %v", p.URI, state) if state != connectivity.Ready { - p.Working = false log.Infof("Connection to prover %v seems broken. Trying to reconnect...", p.URI) if err := p.Conn.Close(); err != nil { log.Errorf("Could not properly close gRPC connection: %v", err) @@ -70,8 +67,6 @@ func (p *Prover) checkConnection(ctx context.Context, ticker *time.Ticker) { p.Client = proverclientpb.NewZKProverServiceClient(proverConn) p.Conn = proverConn - } else { - p.Working = true } waitTick(ctx, ticker) diff --git a/cmd/approve.go b/cmd/approve.go index ae280826a5..da6032499a 100644 --- a/cmd/approve.go +++ b/cmd/approve.go @@ -24,7 +24,7 @@ func approveTokens(ctx *cli.Context) error { if !ctx.Bool(config.FlagYes) { fmt.Print("*WARNING* Are you sure you want to approve ", amount, - " tokens to be spent by the smc ? [y/N]: ") + " tokens to be spent by the smc ? [y/N]: ") var input string if _, err := fmt.Scanln(&input); err != nil { return err @@ -52,7 +52,7 @@ func approveTokens(ctx *cli.Context) error { amountInWei := new(big.Float).Mul(amount, big.NewFloat(decimals)) amountB := new(big.Int) amountInWei.Int(amountB) - tx, err := etherman.ApproveMatic(amountB, c.Etherman.PoEAddr) + tx, err := etherman.ApproveMatic(amountB, c.NetworkConfig.PoEAddr) if err != nil { return err } @@ -60,19 +60,14 @@ func approveTokens(ctx *cli.Context) error { mainnet = 1 rinkeby = 4 goerli = 5 - local = 1337 ) - switch c.Etherman.L1ChainID { + switch c.NetworkConfig.L1ChainID { case mainnet: fmt.Println("Check tx status: https://etherscan.io/tx/" + tx.Hash().String()) case rinkeby: fmt.Println("Check tx status: https://rinkeby.etherscan.io/tx/" + tx.Hash().String()) case goerli: fmt.Println("Check tx status: https://goerli.etherscan.io/tx/" + tx.Hash().String()) - case local: - fmt.Println("Local network. Tx Hash: " + tx.Hash().String()) - default: - fmt.Println("Unknown network. Tx Hash: " + tx.Hash().String()) } return nil } diff --git a/cmd/dumpstate.go b/cmd/dumpstate.go index cc822a4366..15026caf2b 100644 --- a/cmd/dumpstate.go +++ b/cmd/dumpstate.go @@ -34,6 +34,9 @@ var dumpStateFlags = []cli.Flag{ Required: true, }, &configFileFlag, + &networkFlag, + &customNetworkFlag, + &baseNetworkFlag, } type dumpedState struct { diff --git a/cmd/main.go b/cmd/main.go index 530341421d..22659cdb6b 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -41,11 +41,23 @@ var ( Usage: "Configuration `FILE`", Required: false, } - genesisFlag = cli.StringFlag{ - Name: config.FlagGenesisFile, - Aliases: []string{"gen"}, - Usage: "Loads the genesis `FILE`", - Required: true, + networkFlag = cli.StringFlag{ + Name: config.FlagNetwork, + Aliases: []string{"n"}, + Usage: "Network: mainnet, testnet, internaltestnet, local, custom, merge. By default it uses mainnet", + Required: false, + } + customNetworkFlag = cli.StringFlag{ + Name: config.FlagNetworkCfg, + Aliases: []string{"nc"}, + Usage: "Custom network configuration `FILE` when using --network custom parameter", + } + baseNetworkFlag = cli.StringFlag{ + Name: config.FlagNetworkBase, + Aliases: []string{"nb"}, + Usage: "Base existing network configuration to be merged with the custom configuration passed with --network-cfg, by default it uses internaltestnet", + Value: "internaltestnet", + Required: false, } yesFlag = cli.BoolFlag{ Name: config.FlagYes, @@ -75,6 +87,9 @@ func main() { app.Version = version flags := []cli.Flag{ &configFileFlag, + &networkFlag, + &customNetworkFlag, + &baseNetworkFlag, &yesFlag, &componentsFlag, &httpAPIFlag, @@ -91,7 +106,7 @@ func main() { Aliases: []string{}, Usage: "Run the zkevm-node", Action: start, - Flags: append(flags, &genesisFlag), + Flags: flags, }, { Name: "approve", diff --git a/cmd/run.go b/cmd/run.go index db275673c5..1433081bad 100644 --- a/cmd/run.go +++ b/cmd/run.go @@ -7,6 +7,7 @@ import ( "os" "os/signal" "path/filepath" + "strings" "github.com/0xPolygonHermez/zkevm-node/aggregator" "github.com/0xPolygonHermez/zkevm-node/config" @@ -28,7 +29,6 @@ import ( "github.com/0xPolygonHermez/zkevm-node/synchronizer" "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/accounts/keystore" - "github.com/ethereum/go-ethereum/common" "github.com/jackc/pgx/v4/pgxpool" "github.com/urfave/cli/v2" "google.golang.org/grpc" @@ -52,41 +52,48 @@ func start(cliCtx *cli.Context) error { etherman *etherman.Client ) - etherman, err = newEtherman(*c) - if err != nil { - log.Fatal(err) - } + if strings.Contains(cliCtx.String(config.FlagComponents), AGGREGATOR) || + strings.Contains(cliCtx.String(config.FlagComponents), SEQUENCER) || + strings.Contains(cliCtx.String(config.FlagComponents), SYNCHRONIZER) || + strings.Contains(cliCtx.String(config.FlagComponents), RPC) { + var err error + etherman, err = newEtherman(*c) + if err != nil { + log.Fatal(err) + } - // READ CHAIN ID FROM POE SC - l2ChainID, err := etherman.GetL2ChainID() - if err != nil { - log.Fatal(err) + // READ CHAIN ID FROM POE SC + chainID, err := etherman.GetL2ChainID() + if err != nil { + log.Fatal(err) + } + + c.NetworkConfig.L2ChainID = chainID + log.Infof("Chain ID read from POE SC = %v", c.NetworkConfig.L2ChainID) } - c.Aggregator.ChainID = l2ChainID - c.RPC.ChainID = l2ChainID - log.Infof("Chain ID read from POE SC = %v", l2ChainID) ctx := context.Background() - st := newState(ctx, c, l2ChainID, stateSqlDB) + st := newState(ctx, c, stateSqlDB) - ethTxManager := ethtxmanager.New(c.EthTxManager, etherman, st) + ethTxManager := ethtxmanager.New(c.EthTxManager, etherman) for _, item := range cliCtx.StringSlice(config.FlagComponents) { switch item { case AGGREGATOR: log.Info("Running aggregator") + c.Aggregator.ChainID = c.NetworkConfig.L2ChainID c.Aggregator.ProverURIs = c.Provers.ProverURIs go runAggregator(ctx, c.Aggregator, etherman, ethTxManager, st, grpcClientConns) case SEQUENCER: log.Info("Running sequencer") - poolInstance := createPool(c.PoolDB, c.NetworkConfig.L2BridgeAddr, l2ChainID, st) + poolInstance := createPool(c.PoolDB, c.NetworkConfig, st) gpe := createGasPriceEstimator(c.GasPriceEstimator, st, poolInstance) seq := createSequencer(*c, poolInstance, st, etherman, ethTxManager, gpe) go seq.Start(ctx) case RPC: log.Info("Running JSON-RPC server") runRPCMigrations(c.RPC.DB) - poolInstance := createPool(c.PoolDB, c.NetworkConfig.L2BridgeAddr, l2ChainID, st) + poolInstance := createPool(c.PoolDB, c.NetworkConfig, st) gpe := createGasPriceEstimator(c.GasPriceEstimator, st, poolInstance) apis := map[string]bool{} for _, a := range cliCtx.StringSlice(config.FlagHTTPAPI) { @@ -131,11 +138,11 @@ func runMigrations(c db.Config, name string) { } func newEtherman(c config.Config) (*etherman.Client, error) { - auth, err := newAuthFromKeystore(c.Etherman.PrivateKeyPath, c.Etherman.PrivateKeyPassword, c.Etherman.L1ChainID) + auth, err := newAuthFromKeystore(c.Etherman.PrivateKeyPath, c.Etherman.PrivateKeyPassword, c.NetworkConfig.L1ChainID) if err != nil { return nil, err } - etherman, err := etherman.NewClient(c.Etherman, auth) + etherman, err := etherman.NewClient(c.Etherman, auth, c.NetworkConfig.PoEAddr, c.NetworkConfig.MaticAddr, c.NetworkConfig.GlobalExitRootManagerAddr) if err != nil { return nil, err } @@ -143,7 +150,7 @@ func newEtherman(c config.Config) (*etherman.Client, error) { } func runSynchronizer(cfg config.Config, etherman *etherman.Client, st *state.State) { - sy, err := synchronizer.NewSynchronizer(cfg.IsTrustedSequencer, etherman, st, cfg.NetworkConfig.Genesis, cfg.Synchronizer) + sy, err := synchronizer.NewSynchronizer(cfg.IsTrustedSequencer, etherman, st, cfg.NetworkConfig.GenBlockNumber, cfg.NetworkConfig.Genesis, cfg.Synchronizer) if err != nil { log.Fatal(err) } @@ -159,6 +166,7 @@ func runJSONRPCServer(c config.Config, pool *pool.Pool, st *state.State, gpe gas } c.RPC.MaxCumulativeGasUsed = c.Sequencer.MaxCumulativeGasUsed + c.RPC.ChainID = c.NetworkConfig.L2ChainID if err := jsonrpc.NewServer(c.RPC, pool, st, gpe, storage, apis).Start(); err != nil { log.Fatal(err) @@ -267,7 +275,7 @@ func newAuthFromKeystore(path, password string, chainID uint64) (*bind.TransactO return auth, nil } -func newState(ctx context.Context, c *config.Config, l2ChainID uint64, sqlDB *pgxpool.Pool) *state.State { +func newState(ctx context.Context, c *config.Config, sqlDB *pgxpool.Pool) *state.State { stateDb := state.NewPostgresStorage(sqlDB) executorClient, _, _ := executor.NewExecutorClient(ctx, c.Executor) stateDBClient, _, _ := merkletree.NewMTDBServiceClient(ctx, c.MTClient) @@ -275,19 +283,19 @@ func newState(ctx context.Context, c *config.Config, l2ChainID uint64, sqlDB *pg stateCfg := state.Config{ MaxCumulativeGasUsed: c.Sequencer.MaxCumulativeGasUsed, - ChainID: l2ChainID, + ChainID: c.NetworkConfig.L2ChainID, } st := state.NewState(stateCfg, stateDb, executorClient, stateTree) return st } -func createPool(poolDBConfig db.Config, l2BridgeAddr common.Address, l2ChainID uint64, st *state.State) *pool.Pool { +func createPool(poolDBConfig db.Config, networkConfig config.NetworkConfig, st *state.State) *pool.Pool { runPoolMigrations(poolDBConfig) poolStorage, err := pgpoolstorage.NewPostgresPoolStorage(poolDBConfig) if err != nil { log.Fatal(err) } - poolInstance := pool.NewPool(poolStorage, st, l2BridgeAddr, l2ChainID) + poolInstance := pool.NewPool(poolStorage, st, networkConfig.L2BridgeAddr, networkConfig.L2ChainID) return poolInstance } diff --git a/config/config.debug.toml b/config/config.debug.toml index 8963ffdcab..12063e8017 100644 --- a/config/config.debug.toml +++ b/config/config.debug.toml @@ -24,12 +24,8 @@ MaxConns = 10 [Etherman] URL = "http://localhost:8545" -L1ChainID = 1337 PrivateKeyPath = "../test/test.keystore" PrivateKeyPassword = "testonly" -PoEAddr = "0x2279B7A0a67DB372996a5FaB50D91eAA73d2eBe6" -MaticAddr = "0x5FbDB2315678afecb367f032d93F642f64180aa3" -GlobalExitRootManagerAddr = "0xDc64a140Aa3E981100a9becA4E685f962f0cF6C9" [EthTxManager] MaxSendBatchTxRetries = 10 @@ -37,7 +33,6 @@ MaxVerifyBatchTxRetries = 10 FrequencyForResendingFailedSendBatches = "1s" FrequencyForResendingFailedVerifyBatch = "1s" WaitTxToBeMined = "2m" -WaitTxToBeSynced = "10s" PercentageToIncreaseGasPrice = 10 PercentageToIncreaseGasLimit = 10 @@ -61,7 +56,6 @@ DefaultSenderAddress = "0x1111111111111111111111111111111111111111" SyncInterval = "5s" SyncChunkSize = 100 TrustedSequencerURI = "" -GenBlockNumber = 1 [Sequencer] MaxSequenceSize = "2000000" @@ -80,7 +74,6 @@ MaxMemAligns = 262144 MaxArithmetics = 262144 MaxBinaries = 262144 MaxSteps = 8388608 -MaxAllowedFailedCounter = 50 [Sequencer.ProfitabilityChecker] SendBatchesEvenWhenNotProfitable = "true" @@ -94,8 +87,8 @@ TxProfitabilityMinReward = "1.1" Type = "default" DefaultGasPriceWei = 1000000000 -[Provers] -ProverURIs = ["localhost:50052"] +[Prover] +ProverURI = "localhost:50052" [MTServer] Host = "0.0.0.0" diff --git a/config/config.go b/config/config.go index 5b29a7ceec..43fe6af987 100644 --- a/config/config.go +++ b/config/config.go @@ -29,8 +29,12 @@ const ( FlagYes = "yes" // FlagCfg is the flag for cfg. FlagCfg = "cfg" - // FlagGenesisFile is the flag for genesis file. - FlagGenesisFile = "genesis" + // FlagNetwork is the flag for network. + FlagNetwork = "network" + // FlagNetworkCfg is the flag for network-cfg. + FlagNetworkCfg = "network-cfg" + // FlagNetworkBase is the flag for netwotk-base. + FlagNetworkBase = "network-base" // FlagAmount is the flag for amount. FlagAmount = "amount" // FlagRemoteMT is the flag for remote-merkletree. diff --git a/config/config.local.toml b/config/config.local.toml index 8f90329582..93aba9d703 100644 --- a/config/config.local.toml +++ b/config/config.local.toml @@ -24,12 +24,8 @@ MaxConns = 200 [Etherman] URL = "http://zkevm-mock-l1-network:8545" -L1ChainID = 1337 PrivateKeyPath = "./test/test.keystore" PrivateKeyPassword = "testonly" -PoEAddr = "0x2279B7A0a67DB372996a5FaB50D91eAA73d2eBe6" -MaticAddr = "0x5FbDB2315678afecb367f032d93F642f64180aa3" -GlobalExitRootManagerAddr = "0xDc64a140Aa3E981100a9becA4E685f962f0cF6C9" [EthTxManager] MaxSendBatchTxRetries = 10 @@ -37,7 +33,6 @@ MaxVerifyBatchTxRetries = 10 FrequencyForResendingFailedSendBatches = "1s" FrequencyForResendingFailedVerifyBatch = "1s" WaitTxToBeMined = "2m" -WaitTxToBeSynced = "10s" PercentageToIncreaseGasPrice = 10 PercentageToIncreaseGasLimit = 10 @@ -61,7 +56,6 @@ DefaultSenderAddress = "0x1111111111111111111111111111111111111111" SyncInterval = "1s" SyncChunkSize = 100 TrustedSequencerURI = "" -GenBlockNumber = 1 [Sequencer] MaxSequenceSize = "2000000" @@ -80,7 +74,6 @@ MaxMemAligns = 262144 MaxArithmetics = 262144 MaxBinaries = 262144 MaxSteps = 8388608 -MaxAllowedFailedCounter = 50 [Sequencer.ProfitabilityChecker] SendBatchesEvenWhenNotProfitable = "true" diff --git a/config/config_test.go b/config/config_test.go index 6fb05476d7..c41541eb0f 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -2,9 +2,7 @@ package config_test import ( "flag" - "io/ioutil" "math/big" - "os" "reflect" "strings" "testing" @@ -99,10 +97,6 @@ func Test_Defaults(t *testing.T) { path: "Sequencer.MaxSequenceSize", expectedValue: sequencer.MaxSequenceSize{Int: new(big.Int).SetInt64(2000000)}, }, - { - path: "Sequencer.MaxAllowedFailedCounter", - expectedValue: uint64(50), - }, { path: "EthTxManager.MaxSendBatchTxRetries", expectedValue: uint32(10), @@ -123,10 +117,6 @@ func Test_Defaults(t *testing.T) { path: "EthTxManager.WaitTxToBeMined", expectedValue: types.NewDuration(2 * time.Minute), }, - { - path: "EthTxManager.WaitTxToBeSynced", - expectedValue: types.NewDuration(10 * time.Second), - }, { path: "EthTxManager.PercentageToIncreaseGasPrice", expectedValue: uint64(10), @@ -272,16 +262,8 @@ func Test_Defaults(t *testing.T) { expectedValue: 61090, }, } - file, err := ioutil.TempFile("", "genesisConfig") - require.NoError(t, err) - defer func() { - require.NoError(t, os.Remove(file.Name())) - }() - require.NoError(t, os.WriteFile(file.Name(), []byte("{}"), 0600)) - flagSet := flag.NewFlagSet("", flag.PanicOnError) - flagSet.String(config.FlagGenesisFile, file.Name(), "") - ctx := cli.NewContext(cli.NewApp(), flagSet, nil) + ctx := cli.NewContext(cli.NewApp(), flag.NewFlagSet("", flag.PanicOnError), nil) cfg, err := config.Load(ctx) if err != nil { t.Fatalf("Unexpected error loading default config: %v", err) diff --git a/config/default.go b/config/default.go index e2220fa54c..a2dd9d9322 100644 --- a/config/default.go +++ b/config/default.go @@ -28,12 +28,8 @@ MaxConns = 200 [Etherman] URL = "http://localhost:8545" -L1ChainID = 1337 PrivateKeyPath = "./test/test.keystore" PrivateKeyPassword = "testonly" -PoEAddr = "0x2279B7A0a67DB372996a5FaB50D91eAA73d2eBe6" -MaticAddr = "0x5FbDB2315678afecb367f032d93F642f64180aa3" -GlobalExitRootManagerAddr = "0xDc64a140Aa3E981100a9becA4E685f962f0cF6C9" [EthTxManager] MaxSendBatchTxRetries = 10 @@ -41,7 +37,6 @@ MaxVerifyBatchTxRetries = 10 FrequencyForResendingFailedSendBatches = "1s" FrequencyForResendingFailedVerifyBatch = "1s" WaitTxToBeMined = "2m" -WaitTxToBeSynced = "10s" PercentageToIncreaseGasPrice = 10 PercentageToIncreaseGasLimit = 10 @@ -65,7 +60,6 @@ DefaultSenderAddress = "0x1111111111111111111111111111111111111111" SyncInterval = "0s" SyncChunkSize = 100 TrustedSequencerURI = "" -GenBlockNumber = 1 [Sequencer] MaxSequenceSize = "2000000" @@ -84,7 +78,6 @@ MaxMemAligns = 262144 MaxArithmetics = 262144 MaxBinaries = 262144 MaxSteps = 8388608 -MaxAllowedFailedCounter = 50 [Sequencer.ProfitabilityChecker] SendBatchesEvenWhenNotProfitable = "true" diff --git a/config/genesis.go b/config/genesis.go new file mode 100644 index 0000000000..c0b9c35ac3 --- /dev/null +++ b/config/genesis.go @@ -0,0 +1,423 @@ +package config + +import ( + "github.com/0xPolygonHermez/zkevm-node/merkletree" + "github.com/0xPolygonHermez/zkevm-node/state" +) + +var commonGenesisActions = []*state.GenesisAction{ + { + Address: "0xae4bb80be56b819606589de61d5ec3b522eeb032", + Type: int(merkletree.LeafTypeNonce), + StoragePosition: "", + Bytecode: "", + Key: "", + Value: "1", + Root: "", + }, + { + Address: "0xae4bb80be56b819606589de61d5ec3b522eeb032", + Type: int(merkletree.LeafTypeCode), + StoragePosition: "", + Bytecode: "0x608060405234801561001057600080fd5b506004361061004c5760003560e01c806301fd904414610051578063257b36321461006d57806333d6247d1461008d578063a3c573eb146100a2575b600080fd5b61005a60015481565b6040519081526020015b60405180910390f35b61005a61007b366004610197565b60006020819052908152604090205481565b6100a061009b366004610197565b6100e7565b005b6002546100c29073ffffffffffffffffffffffffffffffffffffffff1681565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610064565b60025473ffffffffffffffffffffffffffffffffffffffff163314610192576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603460248201527f476c6f62616c45786974526f6f744d616e616765724c323a3a7570646174654560448201527f786974526f6f743a204f4e4c595f425249444745000000000000000000000000606482015260840160405180910390fd5b600155565b6000602082840312156101a957600080fd5b503591905056fea2646970667358221220b6ba072419f510d5d5b9a55d9605786898f58415125e7e2ac3f699371fda0cbc64736f6c634300080f0033", + Key: "", + Value: "", + Root: "", + }, + { + Address: "0xae4bb80be56b819606589de61d5ec3b522eeb032", + Type: int(merkletree.LeafTypeStorage), + StoragePosition: "0x0000000000000000000000000000000000000000000000000000000000000002", + Bytecode: "", + Key: "", + Value: "0x9d98deabc42dd696deb9e40b4f1cab7ddbf55988", + Root: "", + }, + { + Address: "0x9d98deabc42dd696deb9e40b4f1cab7ddbf55988", + Type: int(merkletree.LeafTypeBalance), + StoragePosition: "", + Bytecode: "", + Key: "", + Value: "100000000000000000000000", + Root: "", + }, + { + Address: "0x9d98deabc42dd696deb9e40b4f1cab7ddbf55988", + Type: int(merkletree.LeafTypeNonce), + StoragePosition: "", + Bytecode: "", + Key: "", + Value: "2", + Root: "", + }, + { + Address: "0x9d98deabc42dd696deb9e40b4f1cab7ddbf55988", + Type: int(merkletree.LeafTypeCode), + StoragePosition: "", + Bytecode: "0x608060405260043610620001075760003560e01c80635d5d326f1162000095578063bab161bf1162000060578063bab161bf1462000414578063d02103ca1462000449578063e73758811462000478578063ed6be5c914620004ac57600080fd5b80635d5d326f146200035e57806381b1c17414620003835780638624c35c14620003ca578063b7e6a7d414620003ef57600080fd5b80633ae0504711620000d65780633ae05047146200023a5780633da816821462000252578063508935f814620002885780635a64a1da14620002a157600080fd5b806322e95f2c146200010c5780632dfdf0b5146200015b5780632f3a3d5d1462000182578063318aee3d14620001b1575b600080fd5b3480156200011957600080fd5b50620001316200012b366004620027b4565b620004c3565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020015b60405180910390f35b3480156200016857600080fd5b506200017360415481565b60405190815260200162000152565b3480156200018f57600080fd5b50604754620001319073ffffffffffffffffffffffffffffffffffffffff1681565b348015620001be57600080fd5b5062000208620001d0366004620027f0565b60456020526000908152604090205463ffffffff811690640100000000900473ffffffffffffffffffffffffffffffffffffffff1682565b6040805163ffffffff909316835273ffffffffffffffffffffffffffffffffffffffff90911660208301520162000152565b3480156200024757600080fd5b506200017362000566565b3480156200025f57600080fd5b5062000277620002713660046200290f565b62000640565b604051901515815260200162000152565b6200029f620002993660046200297d565b62000740565b005b348015620002ae57600080fd5b5062000173620002c036600462002a39565b604080517fffffffff0000000000000000000000000000000000000000000000000000000060e098891b81166020808401919091527fffffffffffffffffffffffffffffffffffffffff0000000000000000000000006060998a1b811660248501529790991b1660388201529390951b909316603c830152605082015260708082019290925282518082039092018252609001909152805191012090565b3480156200036b57600080fd5b506200029f6200037d36600462002b51565b62000d2a565b3480156200039057600080fd5b5062000131620003a236600462002c38565b60446020526000908152604090205473ffffffffffffffffffffffffffffffffffffffff1681565b348015620003d757600080fd5b506200029f620003e9366004620027b4565b620017d9565b348015620003fc57600080fd5b50620001316200040e366004620027b4565b62001a57565b3480156200042157600080fd5b50604254620004339063ffffffff1681565b60405163ffffffff909116815260200162000152565b3480156200045657600080fd5b50604654620001319073ffffffffffffffffffffffffffffffffffffffff1681565b3480156200048557600080fd5b50620002776200049736600462002c38565b60436020526000908152604090205460ff1681565b348015620004b957600080fd5b5062000433600081565b6040805160e084901b7fffffffff0000000000000000000000000000000000000000000000000000000016602080830191909152606084901b7fffffffffffffffffffffffffffffffffffffffff000000000000000000000000166024830152825160188184030181526038909201835281519181019190912060009081526044909152205473ffffffffffffffffffffffffffffffffffffffff165b92915050565b6041546000908190815b6020811015620006385781600116600103620005d057600181602081106200059c576200059c62002c52565b0154604080516020810192909252810184905260600160405160208183030381529060405280519060200120925062000614565b8260218260208110620005e757620005e762002c52565b01546040805160208101939093528201526060016040516020818303038152906040528051906020012092505b6200062160028362002cb0565b9150806200062f8162002cec565b91505062000570565b509092915050565b60008467ffffffffffffffff8416825b6020811015620007335781600116600103620006bd578681815181106200067b576200067b62002c52565b6020026020010151836040516020016200069f929190918252602082015260400190565b6040516020818303038152906040528051906020012092506200070f565b82878281518110620006d357620006d362002c52565b6020026020010151604051602001620006f6929190918252602082015260400190565b6040516020818303038152906040528051906020012092505b6200071c60028362002cb0565b9150806200072a8162002cec565b91505062000650565b5050909114949350505050565b60425463ffffffff90811690861603620007e1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f4272696467653a3a6272696467653a2044455354494e4154494f4e5f43414e5460448201527f5f42455f495453454c460000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b600080606073ffffffffffffffffffffffffffffffffffffffff89166200089d5785341462000893576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602f60248201527f4272696467653a3a6272696467653a20414d4f554e545f444f45535f4e4f545f60448201527f4d415443485f4d53475f56414c554500000000000000000000000000000000006064820152608401620007d8565b6000915062000bb1565b73ffffffffffffffffffffffffffffffffffffffff808a1660009081526045602090815260409182902082518084019093525463ffffffff81168352640100000000900490921691810182905290156200099e576040517f9dc29fac0000000000000000000000000000000000000000000000000000000081523360048201526024810188905273ffffffffffffffffffffffffffffffffffffffff8b1690639dc29fac906044016020604051808303816000875af115801562000965573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200098b919062002d27565b5060208101518151909450925062000baf565b8415620009b357620009b38a88888862001b20565b620009d773ffffffffffffffffffffffffffffffffffffffff8b1633308a62001f71565b899350604260009054906101000a900463ffffffff1692508973ffffffffffffffffffffffffffffffffffffffff166306fdde036040518163ffffffff1660e01b8152600401600060405180830381865afa15801562000a3b573d6000803e3d6000fd5b505050506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016820160405262000a83919081019062002dc6565b8a73ffffffffffffffffffffffffffffffffffffffff166395d89b416040518163ffffffff1660e01b8152600401600060405180830381865afa15801562000acf573d6000803e3d6000fd5b505050506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016820160405262000b17919081019062002dc6565b8b73ffffffffffffffffffffffffffffffffffffffff1663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa15801562000b63573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000b89919062002e0f565b60405160200162000b9d9392919062002e7b565b60405160208183030381529060405291505b505b7ff0b963192bdc6349c23af9bd17294b4c7b9b5a73a2a9939610ea18ffd1c5dc2a82848a8a8a8660415460405162000bf0979695949392919062002eb8565b60405180910390a18051602080830191909120604080517fffffffff0000000000000000000000000000000000000000000000000000000060e087811b8216838701527fffffffffffffffffffffffffffffffffffffffff00000000000000000000000060608a811b82166024860152918f901b90921660388401528c901b16603c820152605081018a9052607080820193909352815180820390930183526090019052805191012062000ca49062002055565b60465473ffffffffffffffffffffffffffffffffffffffff166333d6247d62000ccc62000566565b6040518263ffffffff1660e01b815260040162000ceb91815260200190565b600060405180830381600087803b15801562000d0657600080fd5b505af115801562000d1b573d6000803e3d6000fd5b50505050505050505050505050565b63ffffffff891660009081526043602052604090205460ff161562000dac576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601e60248201527f4272696467653a3a636c61696d3a20414c52454144595f434c41494d454400006044820152606401620007d8565b6046546040805160208082018c90528183018b9052825180830384018152606083019384905280519101207f257b363200000000000000000000000000000000000000000000000000000000909252606481019190915273ffffffffffffffffffffffffffffffffffffffff9091169063257b3632906084016020604051808303816000875af115801562000e45573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000e6b919062002f25565b60000362000efc576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602e60248201527f4272696467653a3a636c61696d3a20474c4f42414c5f455849545f524f4f545f60448201527f444f45535f4e4f545f4d415443480000000000000000000000000000000000006064820152608401620007d8565b60425463ffffffff85811691161462000f98576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603160248201527f4272696467653a3a636c61696d3a2044455354494e4154494f4e5f4e4554574f60448201527f524b5f444f45535f4e4f545f4d415443480000000000000000000000000000006064820152608401620007d8565b60425463ffffffff16620010c9578051602080830191909120604080517fffffffff0000000000000000000000000000000000000000000000000000000060e08b811b8216838701527fffffffffffffffffffffffffffffffffffffffff00000000000000000000000060608c811b82166024860152918b901b909216603884015288901b16603c8201526050810186905260708082019390935281518082039093018352609001905280519101206200105b908b8b63ffffffff168a62000640565b620010c3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f4272696467653a3a636c61696d3a20534d545f494e56414c49440000000000006044820152606401620007d8565b620011e6565b8051602080830191909120604080517fffffffff0000000000000000000000000000000000000000000000000000000060e08b811b8216838701527fffffffffffffffffffffffffffffffffffffffff00000000000000000000000060608c811b82166024860152918b901b909216603884015288901b16603c8201526050810186905260708082019390935281518082039093018352609001905280519101206200117e908b8b63ffffffff168b62000640565b620011e6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f4272696467653a3a636c61696d3a20534d545f494e56414c49440000000000006044820152606401620007d8565b63ffffffff8916600090815260436020526040902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016600117905573ffffffffffffffffffffffffffffffffffffffff851662001357576040805160008082526020820190925273ffffffffffffffffffffffffffffffffffffffff851690849060405162001279919062002f3f565b60006040518083038185875af1925050503d8060008114620012b8576040519150601f19603f3d011682016040523d82523d6000602084013e620012bd565b606091505b505090508062001350576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602260248201527f4272696467653a3a636c61696d3a204554485f5452414e534645525f4641494c60448201527f45440000000000000000000000000000000000000000000000000000000000006064820152608401620007d8565b5062001762565b60425463ffffffff9081169087160362001394576200138e73ffffffffffffffffffffffffffffffffffffffff86168484620021ce565b62001762565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e088901b1660208201527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606087901b166024820152600090603801604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe081840301815291815281516020928301206000818152604490935291205490915073ffffffffffffffffffffffffffffffffffffffff1680620016c1576047546000906200147f9073ffffffffffffffffffffffffffffffffffffffff168462002226565b90506000806000868060200190518101906200149c919062002f5d565b9250925092508373ffffffffffffffffffffffffffffffffffffffff16636c9452218484848d8d6040518663ffffffff1660e01b8152600401620014e595949392919062002fde565b600060405180830381600087803b1580156200150057600080fd5b505af115801562001515573d6000803e3d6000fd5b50505050836044600088815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060405180604001604052808d63ffffffff1681526020018c73ffffffffffffffffffffffffffffffffffffffff16815250604560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008201518160000160006101000a81548163ffffffff021916908363ffffffff16021790555060208201518160000160046101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055509050507fccd7715648d1f2bb13e158f96b5b6c3aeda555d4cb87112e274a6f28bc571d598c8c86604051620016af9392919063ffffffff93909316835273ffffffffffffffffffffffffffffffffffffffff918216602084015216604082015260600190565b60405180910390a1505050506200175f565b6040517f40c10f1900000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8681166004830152602482018690528216906340c10f19906044016020604051808303816000875af115801562001737573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200175d919062002d27565b505b50505b6040805163ffffffff8b811682528816602082015273ffffffffffffffffffffffffffffffffffffffff87811682840152851660608201526080810184905290517f25308c93ceeed162da955b3f7ce3e3f93606579e40fb92029faa9efe275459839181900360a00190a150505050505050505050565b600054610100900460ff1615808015620017fa5750600054600160ff909116105b80620018165750303b15801562001816575060005460ff166001145b620018a4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a65640000000000000000000000000000000000006064820152608401620007d8565b600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016600117905580156200190357600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff166101001790555b604280547fffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000001663ffffffff8516179055604680547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff841617905560405162001981906200275c565b604051809103906000f0801580156200199e573d6000803e3d6000fd5b50604780547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055620019ee62002306565b801562001a5257600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b505050565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e084901b1660208201527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606083901b1660248201526000908190603801604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0818403018152919052805160209091012060475490915062001b189073ffffffffffffffffffffffffffffffffffffffff16826200244e565b949350505050565b600062001b6383838080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250620024d292505050565b90507fffffffff0000000000000000000000000000000000000000000000000000000081167fd505accf000000000000000000000000000000000000000000000000000000001462001c38576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f48657a4d617469634d657267653a3a5f7065726d69743a204e4f545f56414c4960448201527f445f43414c4c00000000000000000000000000000000000000000000000000006064820152608401620007d8565b600080808080808062001c4f896004818d6200303e565b81019062001c5e91906200306a565b96509650965096509650965096503373ffffffffffffffffffffffffffffffffffffffff168773ffffffffffffffffffffffffffffffffffffffff161462001d29576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603760248201527f48657a4d617469634d657267653a3a5f7065726d69743a205045524d49545f4f60448201527f574e45525f4d5553545f42455f5448455f53454e4445520000000000000000006064820152608401620007d8565b73ffffffffffffffffffffffffffffffffffffffff8616301462001dd0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602c60248201527f48657a4d617469634d657267653a3a5f7065726d69743a205350454e4445525f60448201527f4d5553545f42455f5448495300000000000000000000000000000000000000006064820152608401620007d8565b8a851462001e61576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603460248201527f48657a4d617469634d657267653a3a5f7065726d69743a205045524d49545f4160448201527f4d4f554e545f444f45535f4e4f545f4d415443480000000000000000000000006064820152608401620007d8565b6040805173ffffffffffffffffffffffffffffffffffffffff89811660248301528881166044830152606482018890526084820187905260ff861660a483015260c4820185905260e48083018590528351808403909101815261010490920183526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fd505accf000000000000000000000000000000000000000000000000000000001790529151918e169162001f1c919062002f3f565b6000604051808303816000865af19150503d806000811462001f5b576040519150601f19603f3d011682016040523d82523d6000602084013e62001f60565b606091505b505050505050505050505050505050565b60405173ffffffffffffffffffffffffffffffffffffffff808516602483015283166044820152606481018290526200204f9085907f23b872dd00000000000000000000000000000000000000000000000000000000906084015b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff0000000000000000000000000000000000000000000000000000000090931692909217909152620024d9565b50505050565b80600162002066602060026200321b565b62002072919062003229565b6041541062002104576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f4465706f736974436f6e74726163743a5f6465706f7369743a204d45524b4c4560448201527f5f545245455f46554c4c000000000000000000000000000000000000000000006064820152608401620007d8565b60016041600082825462002119919062003243565b909155505060415460005b6020811015620021c357816001166001036200215957826001826020811062002151576200215162002c52565b015550505050565b600181602081106200216f576200216f62002c52565b01546040805160208101929092528101849052606001604051602081830303815290604052805190602001209250600282620021ac919062002cb0565b915080620021ba8162002cec565b91505062002124565b5062001a526200325e565b60405173ffffffffffffffffffffffffffffffffffffffff831660248201526044810182905262001a529084907fa9059cbb000000000000000000000000000000000000000000000000000000009060640162001fcc565b60006040517f3d602d80600a3d3981f3363d3d373d3d3d363d7300000000000000000000000081528360601b60148201527f5af43d82803e903d91602b57fd5bf300000000000000000000000000000000006028820152826037826000f591505073ffffffffffffffffffffffffffffffffffffffff811662000560576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601760248201527f455243313136373a2063726561746532206661696c65640000000000000000006044820152606401620007d8565b600054610100900460ff166200239f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401620007d8565b60005b620023b06001602062003229565b8110156200244b5760218160208110620023ce57620023ce62002c52565b015460218260208110620023e657620023e662002c52565b015460408051602081019390935282015260600160405160208183030381529060405280519060200120602182600162002421919062003243565b6020811062002434576200243462002c52565b015580620024428162002cec565b915050620023a2565b50565b6000620024cb8383306040517f3d602d80600a3d3981f3363d3d373d3d3d363d730000000000000000000000008152606093841b60148201527f5af43d82803e903d91602b57fd5bf3ff000000000000000000000000000000006028820152921b6038830152604c8201526037808220606c830152605591012090565b9392505050565b6020015190565b60006200253d826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff16620025ec9092919063ffffffff16565b80519091501562001a5257808060200190518101906200255e919062002d27565b62001a52576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152608401620007d8565b606062001b1884846000858573ffffffffffffffffffffffffffffffffffffffff85163b62002678576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401620007d8565b6000808673ffffffffffffffffffffffffffffffffffffffff168587604051620026a3919062002f3f565b60006040518083038185875af1925050503d8060008114620026e2576040519150601f19603f3d011682016040523d82523d6000602084013e620026e7565b606091505b5091509150620026f982828662002704565b979650505050505050565b6060831562002715575081620024cb565b825115620027265782518084602001fd5b816040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401620007d891906200328d565b61182980620032a383390190565b803563ffffffff811681146200277f57600080fd5b919050565b73ffffffffffffffffffffffffffffffffffffffff811681146200244b57600080fd5b80356200277f8162002784565b60008060408385031215620027c857600080fd5b620027d3836200276a565b91506020830135620027e58162002784565b809150509250929050565b6000602082840312156200280357600080fd5b8135620024cb8162002784565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff8111828210171562002889576200288962002810565b604052919050565b600082601f830112620028a357600080fd5b8135602067ffffffffffffffff821115620028c257620028c262002810565b8160051b620028d38282016200283f565b9283528481018201928281019087851115620028ee57600080fd5b83870192505b84831015620026f957823582529183019190830190620028f4565b600080600080608085870312156200292657600080fd5b84359350602085013567ffffffffffffffff808211156200294657600080fd5b620029548883890162002891565b94506040870135915080821682146200296c57600080fd5b509396929550929360600135925050565b60008060008060008060a087890312156200299757600080fd5b8635620029a48162002784565b9550620029b4602088016200276a565b94506040870135620029c68162002784565b935060608701359250608087013567ffffffffffffffff80821115620029eb57600080fd5b818901915089601f83011262002a0057600080fd5b81358181111562002a1057600080fd5b8a602082850101111562002a2357600080fd5b6020830194508093505050509295509295509295565b60008060008060008060c0878903121562002a5357600080fd5b62002a5e876200276a565b9550602087013562002a708162002784565b945062002a80604088016200276a565b9350606087013562002a928162002784565b9598949750929560808101359460a0909101359350915050565b600067ffffffffffffffff82111562002ac95762002ac962002810565b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01660200190565b600082601f83011262002b0757600080fd5b813562002b1e62002b188262002aac565b6200283f565b81815284602083860101111562002b3457600080fd5b816020850160208301376000918101602001919091529392505050565b6000806000806000806000806000806101408b8d03121562002b7257600080fd5b8a3567ffffffffffffffff8082111562002b8b57600080fd5b62002b998e838f0162002891565b9b5062002ba960208e016200276a565b9a5060408d0135995060608d0135985062002bc760808e016200276a565b975062002bd760a08e01620027a7565b965062002be760c08e016200276a565b955062002bf760e08e01620027a7565b94506101008d013593506101208d013591508082111562002c1757600080fd5b5062002c268d828e0162002af5565b9150509295989b9194979a5092959850565b60006020828403121562002c4b57600080fd5b5035919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60008262002ce7577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff820362002d205762002d2062002c81565b5060010190565b60006020828403121562002d3a57600080fd5b81518015158114620024cb57600080fd5b60005b8381101562002d6857818101518382015260200162002d4e565b838111156200204f5750506000910152565b600082601f83011262002d8c57600080fd5b815162002d9d62002b188262002aac565b81815284602083860101111562002db357600080fd5b62001b1882602083016020870162002d4b565b60006020828403121562002dd957600080fd5b815167ffffffffffffffff81111562002df157600080fd5b62001b188482850162002d7a565b60ff811681146200244b57600080fd5b60006020828403121562002e2257600080fd5b8151620024cb8162002dff565b6000815180845262002e4981602086016020860162002d4b565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b60608152600062002e90606083018662002e2f565b828103602084015262002ea4818662002e2f565b91505060ff83166040830152949350505050565b600063ffffffff808a16835273ffffffffffffffffffffffffffffffffffffffff808a166020850152818916604085015280881660608501525085608084015260e060a084015262002f0e60e084018662002e2f565b915080841660c08401525098975050505050505050565b60006020828403121562002f3857600080fd5b5051919050565b6000825162002f5381846020870162002d4b565b9190910192915050565b60008060006060848603121562002f7357600080fd5b835167ffffffffffffffff8082111562002f8c57600080fd5b62002f9a8783880162002d7a565b9450602086015191508082111562002fb157600080fd5b5062002fc08682870162002d7a565b925050604084015162002fd38162002dff565b809150509250925092565b60a08152600062002ff360a083018862002e2f565b828103602084015262003007818862002e2f565b60ff969096166040840152505073ffffffffffffffffffffffffffffffffffffffff92909216606083015260809091015292915050565b600080858511156200304f57600080fd5b838611156200305d57600080fd5b5050820193919092039150565b600080600080600080600060e0888a0312156200308657600080fd5b8735620030938162002784565b96506020880135620030a58162002784565b955060408801359450606088013593506080880135620030c58162002dff565b9699959850939692959460a0840135945060c09093013592915050565b600181815b808511156200314157817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0482111562003125576200312562002c81565b808516156200313357918102915b93841c9390800290620030e7565b509250929050565b6000826200315a5750600162000560565b81620031695750600062000560565b81600181146200318257600281146200318d57620031ad565b600191505062000560565b60ff841115620031a157620031a162002c81565b50506001821b62000560565b5060208310610133831016604e8410600b8410161715620031d2575081810a62000560565b620031de8383620030e2565b807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0482111562003213576200321362002c81565b029392505050565b6000620024cb838362003149565b6000828210156200323e576200323e62002c81565b500390565b6000821982111562003259576200325962002c81565b500190565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052600160045260246000fd5b602081526000620024cb602083018462002e2f56fe60806040523480156200001157600080fd5b50600054610100900460ff1615808015620000335750600054600160ff909116105b8062000063575062000050306200013d60201b6200080a1760201c565b15801562000063575060005460ff166001145b620000cb5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b606482015260840160405180910390fd5b6000805460ff191660011790558015620000ef576000805461ff0019166101001790555b801562000136576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b506200014c565b6001600160a01b03163b151590565b6116cd806200015c6000396000f3fe608060405234801561001057600080fd5b50600436106100f55760003560e01c80636c94522111610097578063a3c573eb11610066578063a3c573eb1461021c578063a457c2d714610261578063a9059cbb14610274578063dd62ed3e1461028757600080fd5b80636c945221146101b657806370a08231146101cb57806395d89b41146102015780639dc29fac1461020957600080fd5b806323b872dd116100d357806323b872dd1461014d578063313ce56714610160578063395093511461019057806340c10f19146101a357600080fd5b806306fdde03146100fa578063095ea7b31461011857806318160ddd1461013b575b600080fd5b6101026102cd565b60405161010f91906111c0565b60405180910390f35b61012b61012636600461125c565b61035f565b604051901515815260200161010f565b6035545b60405190815260200161010f565b61012b61015b366004611286565b610377565b60655474010000000000000000000000000000000000000000900460ff1660405160ff909116815260200161010f565b61012b61019e36600461125c565b61039b565b61012b6101b136600461125c565b6103e7565b6101c96101c436600461139c565b610483565b005b61013f6101d9366004611431565b73ffffffffffffffffffffffffffffffffffffffff1660009081526033602052604090205490565b61010261068e565b61012b61021736600461125c565b61069d565b60655461023c9073ffffffffffffffffffffffffffffffffffffffff1681565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200161010f565b61012b61026f36600461125c565b61072b565b61012b61028236600461125c565b6107fc565b61013f610295366004611453565b73ffffffffffffffffffffffffffffffffffffffff918216600090815260346020908152604080832093909416825291909152205490565b6060603680546102dc90611486565b80601f016020809104026020016040519081016040528092919081815260200182805461030890611486565b80156103555780601f1061032a57610100808354040283529160200191610355565b820191906000526020600020905b81548152906001019060200180831161033857829003601f168201915b5050505050905090565b60003361036d818585610826565b5060019392505050565b6000336103858582856109da565b610390858585610ab1565b506001949350505050565b33600081815260346020908152604080832073ffffffffffffffffffffffffffffffffffffffff8716845290915281205490919061036d90829086906103e2908790611508565b610826565b60655460009073ffffffffffffffffffffffffffffffffffffffff163314610470576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601760248201527f546f6b656e577261707065643a4e4f545f42524944474500000000000000000060448201526064015b60405180910390fd5b61047a8383610d64565b50600192915050565b600054610100900460ff16158080156104a35750600054600160ff909116105b806104bd5750303b1580156104bd575060005460ff166001145b610549576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a65640000000000000000000000000000000000006064820152608401610467565b600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016600117905580156105a757600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff166101001790555b6105b18686610e85565b606580547fffffffffffffffffffffff00000000000000000000000000000000000000000016337fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff16177401000000000000000000000000000000000000000060ff8716021790556106238383610d64565b801561068657600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b505050505050565b6060603780546102dc90611486565b60655460009073ffffffffffffffffffffffffffffffffffffffff163314610721576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601760248201527f546f6b656e577261707065643a4e4f545f4252494447450000000000000000006044820152606401610467565b61047a8383610f26565b33600081815260346020908152604080832073ffffffffffffffffffffffffffffffffffffffff87168452909152812054909190838110156107ef576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760448201527f207a65726f0000000000000000000000000000000000000000000000000000006064820152608401610467565b6103908286868403610826565b60003361036d818585610ab1565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b73ffffffffffffffffffffffffffffffffffffffff83166108c8576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460448201527f72657373000000000000000000000000000000000000000000000000000000006064820152608401610467565b73ffffffffffffffffffffffffffffffffffffffff821661096b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f20616464726560448201527f73730000000000000000000000000000000000000000000000000000000000006064820152608401610467565b73ffffffffffffffffffffffffffffffffffffffff83811660008181526034602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591015b60405180910390a3505050565b73ffffffffffffffffffffffffffffffffffffffff8381166000908152603460209081526040808320938616835292905220547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8114610aab5781811015610a9e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e63650000006044820152606401610467565b610aab8484848403610826565b50505050565b73ffffffffffffffffffffffffffffffffffffffff8316610b54576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f20616460448201527f64726573730000000000000000000000000000000000000000000000000000006064820152608401610467565b73ffffffffffffffffffffffffffffffffffffffff8216610bf7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201527f65737300000000000000000000000000000000000000000000000000000000006064820152608401610467565b73ffffffffffffffffffffffffffffffffffffffff831660009081526033602052604090205481811015610cad576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e742065786365656473206260448201527f616c616e636500000000000000000000000000000000000000000000000000006064820152608401610467565b73ffffffffffffffffffffffffffffffffffffffff808516600090815260336020526040808220858503905591851681529081208054849290610cf1908490611508565b925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef84604051610d5791815260200190565b60405180910390a3610aab565b73ffffffffffffffffffffffffffffffffffffffff8216610de1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f2061646472657373006044820152606401610467565b8060356000828254610df39190611508565b909155505073ffffffffffffffffffffffffffffffffffffffff821660009081526033602052604081208054839290610e2d908490611508565b909155505060405181815273ffffffffffffffffffffffffffffffffffffffff8316906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a35b5050565b600054610100900460ff16610f1c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610467565b610e818282611110565b73ffffffffffffffffffffffffffffffffffffffff8216610fc9576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f2061646472657360448201527f73000000000000000000000000000000000000000000000000000000000000006064820152608401610467565b73ffffffffffffffffffffffffffffffffffffffff82166000908152603360205260409020548181101561107f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e60448201527f63650000000000000000000000000000000000000000000000000000000000006064820152608401610467565b73ffffffffffffffffffffffffffffffffffffffff831660009081526033602052604081208383039055603580548492906110bb908490611520565b909155505060405182815260009073ffffffffffffffffffffffffffffffffffffffff8516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef906020016109cd565b505050565b600054610100900460ff166111a7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610467565b60366111b3838261157d565b50603761110b828261157d565b600060208083528351808285015260005b818110156111ed578581018301518582016040015282016111d1565b818111156111ff576000604083870101525b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016929092016040019392505050565b803573ffffffffffffffffffffffffffffffffffffffff8116811461125757600080fd5b919050565b6000806040838503121561126f57600080fd5b61127883611233565b946020939093013593505050565b60008060006060848603121561129b57600080fd5b6112a484611233565b92506112b260208501611233565b9150604084013590509250925092565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600082601f83011261130257600080fd5b813567ffffffffffffffff8082111561131d5761131d6112c2565b604051601f83017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f01168101908282118183101715611363576113636112c2565b8160405283815286602085880101111561137c57600080fd5b836020870160208301376000602085830101528094505050505092915050565b600080600080600060a086880312156113b457600080fd5b853567ffffffffffffffff808211156113cc57600080fd5b6113d889838a016112f1565b965060208801359150808211156113ee57600080fd5b506113fb888289016112f1565b945050604086013560ff8116811461141257600080fd5b925061142060608701611233565b949793965091946080013592915050565b60006020828403121561144357600080fd5b61144c82611233565b9392505050565b6000806040838503121561146657600080fd5b61146f83611233565b915061147d60208401611233565b90509250929050565b600181811c9082168061149a57607f821691505b6020821081036114d3577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000821982111561151b5761151b6114d9565b500190565b600082821015611532576115326114d9565b500390565b601f82111561110b57600081815260208120601f850160051c8101602086101561155e5750805b601f850160051c820191505b818110156106865782815560010161156a565b815167ffffffffffffffff811115611597576115976112c2565b6115ab816115a58454611486565b84611537565b602080601f8311600181146115fe57600084156115c85750858301515b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600386901b1c1916600185901b178555610686565b6000858152602081207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08616915b8281101561164b5788860151825594840194600190910190840161162c565b508582101561168757878501517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600388901b60f8161c191681555b5050505050600190811b0190555056fea264697066735822122015dd8047eba7f7221e0d7792549e5a01ba1b6dfaad0c6a70dc82ef386e0c5cc464736f6c634300080f0033a264697066735822122068cb524538909c05cc5109b7664a019588dc698f1f570976efb4dd6b6aee818364736f6c634300080f0033", + Key: "", + Value: "", + Root: "", + }, + { + Address: "0x9d98deabc42dd696deb9e40b4f1cab7ddbf55988", + Type: int(merkletree.LeafTypeStorage), + StoragePosition: "0x000000000000000000000000000000000000000000000000000000000000002f", + Bytecode: "", + Key: "", + Value: "0x5c67add7c6caf302256adedf7ab114da0acfe870d449a3a489f781d659e8becc", + Root: "", + }, + { + Address: "0x9d98deabc42dd696deb9e40b4f1cab7ddbf55988", + Type: int(merkletree.LeafTypeStorage), + StoragePosition: "0x0000000000000000000000000000000000000000000000000000000000000033", + Bytecode: "", + Key: "", + Value: "0x5a2dce0a8a7f68bb74560f8f71837c2c2ebbcbf7fffb42ae1896f13f7c7479a0", + Root: "", + }, + { + Address: "0x9d98deabc42dd696deb9e40b4f1cab7ddbf55988", + Type: int(merkletree.LeafTypeStorage), + StoragePosition: "0x0000000000000000000000000000000000000000000000000000000000000035", + Bytecode: "", + Key: "", + Value: "0xc65e9645644786b620e2dd2ad648ddfcbf4a7e5b1a3a4ecfe7f64667a3f0b7e2", + Root: "", + }, + { + Address: "0x9d98deabc42dd696deb9e40b4f1cab7ddbf55988", + Type: int(merkletree.LeafTypeStorage), + StoragePosition: "0x0000000000000000000000000000000000000000000000000000000000000036", + Bytecode: "", + Key: "", + Value: "0xf4418588ed35a2458cffeb39b93d26f18d2ab13bdce6aee58e7b99359ec2dfd9", + Root: "", + }, + { + Address: "0x9d98deabc42dd696deb9e40b4f1cab7ddbf55988", + Type: int(merkletree.LeafTypeStorage), + StoragePosition: "0x000000000000000000000000000000000000000000000000000000000000003b", + Bytecode: "", + Key: "", + Value: "0xb8cd74046ff337f0a7bf2c8e03e10f642c1886798d71806ab1e888d9e5ee87d0", + Root: "", + }, + { + Address: "0x9d98deabc42dd696deb9e40b4f1cab7ddbf55988", + Type: int(merkletree.LeafTypeStorage), + StoragePosition: "0x0000000000000000000000000000000000000000000000000000000000000040", + Bytecode: "", + Key: "", + Value: "0x8448818bb4ae4562849e949e17ac16e0be16688e156b5cf15e098c627c0056a9", + Root: "", + }, + { + Address: "0x9d98deabc42dd696deb9e40b4f1cab7ddbf55988", + Type: int(merkletree.LeafTypeStorage), + StoragePosition: "0x0000000000000000000000000000000000000000000000000000000000000029", + Bytecode: "", + Key: "", + Value: "0x9867cc5f7f196b93bae1e27e6320742445d290f2263827498b54fec539f756af", + Root: "", + }, + { + Address: "0x9d98deabc42dd696deb9e40b4f1cab7ddbf55988", + Type: int(merkletree.LeafTypeStorage), + StoragePosition: "0x000000000000000000000000000000000000000000000000000000000000002b", + Bytecode: "", + Key: "", + Value: "0xf9dc3e7fe016e050eff260334f18a5d4fe391d82092319f5964f2e2eb7c1c3a5", + Root: "", + }, + { + Address: "0x9d98deabc42dd696deb9e40b4f1cab7ddbf55988", + Type: int(merkletree.LeafTypeStorage), + StoragePosition: "0x000000000000000000000000000000000000000000000000000000000000002d", + Bytecode: "", + Key: "", + Value: "0x3490c6ceeb450aecdc82e28293031d10c7d73bf85e57bf041a97360aa2c5d99c", + Root: "", + }, + { + Address: "0x9d98deabc42dd696deb9e40b4f1cab7ddbf55988", + Type: int(merkletree.LeafTypeStorage), + StoragePosition: "0x0000000000000000000000000000000000000000000000000000000000000030", + Bytecode: "", + Key: "", + Value: "0xda7bce9f4e8618b6bd2f4132ce798cdc7a60e7e1460a7299e3c6342a579626d2", + Root: "", + }, + { + Address: "0x9d98deabc42dd696deb9e40b4f1cab7ddbf55988", + Type: int(merkletree.LeafTypeStorage), + StoragePosition: "0x0000000000000000000000000000000000000000000000000000000000000032", + Bytecode: "", + Key: "", + Value: "0xe1d3b5c807b281e4683cc6d6315cf95b9ade8641defcb32372f1c126e398ef7a", + Root: "", + }, + { + Address: "0x9d98deabc42dd696deb9e40b4f1cab7ddbf55988", + Type: int(merkletree.LeafTypeStorage), + StoragePosition: "0x0000000000000000000000000000000000000000000000000000000000000034", + Bytecode: "", + Key: "", + Value: "0xb46a28b6f55540f89444f63de0378e3d121be09e06cc9ded1c20e65876d36aa0", + Root: "", + }, + { + Address: "0x9d98deabc42dd696deb9e40b4f1cab7ddbf55988", + Type: int(merkletree.LeafTypeStorage), + StoragePosition: "0x0000000000000000000000000000000000000000000000000000000000000022", + Bytecode: "", + Key: "", + Value: "0xad3228b676f7d3cd4284a5443f17f1962b36e491b30a40b2405849e597ba5fb5", + Root: "", + }, + { + Address: "0x9d98deabc42dd696deb9e40b4f1cab7ddbf55988", + Type: int(merkletree.LeafTypeStorage), + StoragePosition: "0x0000000000000000000000000000000000000000000000000000000000000025", + Bytecode: "", + Key: "", + Value: "0xe58769b32a1beaf1ea27375a44095a0d1fb664ce2dd358e7fcbfb78c26a19344", + Root: "", + }, + { + Address: "0x9d98deabc42dd696deb9e40b4f1cab7ddbf55988", + Type: int(merkletree.LeafTypeStorage), + StoragePosition: "0x000000000000000000000000000000000000000000000000000000000000002c", + Bytecode: "", + Key: "", + Value: "0xf8b13a49e282f609c317a833fb8d976d11517c571d1221a265d25af778ecf892", + Root: "", + }, + { + Address: "0x9d98deabc42dd696deb9e40b4f1cab7ddbf55988", + Type: int(merkletree.LeafTypeStorage), + StoragePosition: "0x0000000000000000000000000000000000000000000000000000000000000023", + Bytecode: "", + Key: "", + Value: "0xb4c11951957c6f8f642c4af61cd6b24640fec6dc7fc607ee8206a99e92410d30", + Root: "", + }, + { + Address: "0x9d98deabc42dd696deb9e40b4f1cab7ddbf55988", + Type: int(merkletree.LeafTypeStorage), + StoragePosition: "0x0000000000000000000000000000000000000000000000000000000000000027", + Bytecode: "", + Key: "", + Value: "0x887c22bd8750d34016ac3c66b5ff102dacdd73f6b014e710b51e8022af9a1968", + Root: "", + }, + { + Address: "0x9d98deabc42dd696deb9e40b4f1cab7ddbf55988", + Type: int(merkletree.LeafTypeStorage), + StoragePosition: "0x0000000000000000000000000000000000000000000000000000000000000028", + Bytecode: "", + Key: "", + Value: "0xffd70157e48063fc33c97a050f7f640233bf646cc98d9524c6b92bcf3ab56f83", + Root: "", + }, + { + Address: "0x9d98deabc42dd696deb9e40b4f1cab7ddbf55988", + Type: int(merkletree.LeafTypeStorage), + StoragePosition: "0x0000000000000000000000000000000000000000000000000000000000000038", + Bytecode: "", + Key: "", + Value: "0x4df84f40ae0c8229d0d6069e5c8f39a7c299677a09d367fc7b05e3bc380ee652", + Root: "", + }, + { + Address: "0x9d98deabc42dd696deb9e40b4f1cab7ddbf55988", + Type: int(merkletree.LeafTypeStorage), + StoragePosition: "0x000000000000000000000000000000000000000000000000000000000000003e", + Bytecode: "", + Key: "", + Value: "0x388ab20e2573d171a88108e79d820e98f26c0b84aa8b2f4aa4968dbb818ea322", + Root: "", + }, + { + Address: "0x9d98deabc42dd696deb9e40b4f1cab7ddbf55988", + Type: int(merkletree.LeafTypeStorage), + StoragePosition: "0x0000000000000000000000000000000000000000000000000000000000000000", + Bytecode: "", + Key: "", + Value: "0x01", + Root: "", + }, + { + Address: "0x9d98deabc42dd696deb9e40b4f1cab7ddbf55988", + Type: int(merkletree.LeafTypeStorage), + StoragePosition: "0x0000000000000000000000000000000000000000000000000000000000000047", + Bytecode: "", + Key: "", + Value: "0x61ba0248b0986c2480181c6e76b6adeeaa962483", + Root: "", + }, + { + Address: "0x9d98deabc42dd696deb9e40b4f1cab7ddbf55988", + Type: int(merkletree.LeafTypeStorage), + StoragePosition: "0x000000000000000000000000000000000000000000000000000000000000003c", + Bytecode: "", + Key: "", + Value: "0x838c5655cb21c6cb83313b5a631175dff4963772cce9108188b34ac87c81c41e", + Root: "", + }, + { + Address: "0x9d98deabc42dd696deb9e40b4f1cab7ddbf55988", + Type: int(merkletree.LeafTypeStorage), + StoragePosition: "0x000000000000000000000000000000000000000000000000000000000000003f", + Bytecode: "", + Key: "", + Value: "0x93237c50ba75ee485f4c22adf2f741400bdf8d6a9cc7df7ecae576221665d735", + Root: "", + }, + { + Address: "0x9d98deabc42dd696deb9e40b4f1cab7ddbf55988", + Type: int(merkletree.LeafTypeStorage), + StoragePosition: "0x000000000000000000000000000000000000000000000000000000000000003d", + Bytecode: "", + Key: "", + Value: "0x662ee4dd2dd7b2bc707961b1e646c4047669dcb6584f0d8d770daf5d7e7deb2e", + Root: "", + }, + { + Address: "0x9d98deabc42dd696deb9e40b4f1cab7ddbf55988", + Type: int(merkletree.LeafTypeStorage), + StoragePosition: "0x0000000000000000000000000000000000000000000000000000000000000046", + Bytecode: "", + Key: "", + Value: "0xae4bb80be56b819606589de61d5ec3b522eeb032", + Root: "", + }, + { + Address: "0x9d98deabc42dd696deb9e40b4f1cab7ddbf55988", + Type: int(merkletree.LeafTypeStorage), + StoragePosition: "0x000000000000000000000000000000000000000000000000000000000000003a", + Bytecode: "", + Key: "", + Value: "0x0abf5ac974a1ed57f4050aa510dd9c74f508277b39d7973bb2dfccc5eeb0618d", + Root: "", + }, + { + Address: "0x9d98deabc42dd696deb9e40b4f1cab7ddbf55988", + Type: int(merkletree.LeafTypeStorage), + StoragePosition: "0x000000000000000000000000000000000000000000000000000000000000002e", + Bytecode: "", + Key: "", + Value: "0xc1df82d9c4b87413eae2ef048f94b4d3554cea73d92b0f7af96e0271c691e2bb", + Root: "", + }, + { + Address: "0x9d98deabc42dd696deb9e40b4f1cab7ddbf55988", + Type: int(merkletree.LeafTypeStorage), + StoragePosition: "0x0000000000000000000000000000000000000000000000000000000000000031", + Bytecode: "", + Key: "", + Value: "0x2733e50f526ec2fa19a22b31e8ed50f23cd1fdf94c9154ed3a7609a2f1ff981f", + Root: "", + }, + { + Address: "0x9d98deabc42dd696deb9e40b4f1cab7ddbf55988", + Type: int(merkletree.LeafTypeStorage), + StoragePosition: "0x0000000000000000000000000000000000000000000000000000000000000037", + Bytecode: "", + Key: "", + Value: "0x5a9c16dc00d6ef18b7933a6f8dc65ccb55667138776f7dea101070dc8796e377", + Root: "", + }, + { + Address: "0x9d98deabc42dd696deb9e40b4f1cab7ddbf55988", + Type: int(merkletree.LeafTypeStorage), + StoragePosition: "0x0000000000000000000000000000000000000000000000000000000000000024", + Bytecode: "", + Key: "", + Value: "0x21ddb9a356815c3fac1026b6dec5df3124afbadb485c9ba5a3e3398a04b7ba85", + Root: "", + }, + { + Address: "0x9d98deabc42dd696deb9e40b4f1cab7ddbf55988", + Type: int(merkletree.LeafTypeStorage), + StoragePosition: "0x0000000000000000000000000000000000000000000000000000000000000026", + Bytecode: "", + Key: "", + Value: "0x0eb01ebfc9ed27500cd4dfc979272d1f0913cc9f66540d7e8005811109e1cf2d", + Root: "", + }, + { + Address: "0x9d98deabc42dd696deb9e40b4f1cab7ddbf55988", + Type: int(merkletree.LeafTypeStorage), + StoragePosition: "0x0000000000000000000000000000000000000000000000000000000000000039", + Bytecode: "", + Key: "", + Value: "0xcdc72595f74c7b1043d0e1ffbab734648c838dfb0527d971b602bc216c9619ef", + Root: "", + }, + { + Address: "0x9d98deabc42dd696deb9e40b4f1cab7ddbf55988", + Type: int(merkletree.LeafTypeStorage), + StoragePosition: "0x0000000000000000000000000000000000000000000000000000000000000042", + Bytecode: "", + Key: "", + Value: "0x01", + Root: "", + }, + { + Address: "0x9d98deabc42dd696deb9e40b4f1cab7ddbf55988", + Type: int(merkletree.LeafTypeStorage), + StoragePosition: "0x000000000000000000000000000000000000000000000000000000000000002a", + Bytecode: "", + Key: "", + Value: "0xcefad4e508c098b9a7e1d8feb19955fb02ba9675585078710969d3440f5054e0", + Root: "", + }, + { + Address: "0xc949254d682d8c9ad5682521675b8f43b102aec4", + Type: int(merkletree.LeafTypeNonce), + StoragePosition: "", + Bytecode: "", + Key: "", + Value: "3", + Root: "", + }, + { + Address: "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266", + Type: int(merkletree.LeafTypeBalance), + StoragePosition: "", + Bytecode: "", + Key: "", + Value: "100000000000000000000000", + Root: "", + }, + { + Address: "0x61ba0248b0986c2480181c6e76b6adeeaa962483", + Type: int(merkletree.LeafTypeNonce), + StoragePosition: "", + Bytecode: "", + Key: "", + Value: "1", + Root: "", + }, + { + Address: "0x61ba0248b0986c2480181c6e76b6adeeaa962483", + Type: int(merkletree.LeafTypeCode), + StoragePosition: "", + Bytecode: "0x608060405234801561001057600080fd5b50600436106100f55760003560e01c80636c94522111610097578063a3c573eb11610066578063a3c573eb1461021c578063a457c2d714610261578063a9059cbb14610274578063dd62ed3e1461028757600080fd5b80636c945221146101b657806370a08231146101cb57806395d89b41146102015780639dc29fac1461020957600080fd5b806323b872dd116100d357806323b872dd1461014d578063313ce56714610160578063395093511461019057806340c10f19146101a357600080fd5b806306fdde03146100fa578063095ea7b31461011857806318160ddd1461013b575b600080fd5b6101026102cd565b60405161010f91906111c0565b60405180910390f35b61012b61012636600461125c565b61035f565b604051901515815260200161010f565b6035545b60405190815260200161010f565b61012b61015b366004611286565b610377565b60655474010000000000000000000000000000000000000000900460ff1660405160ff909116815260200161010f565b61012b61019e36600461125c565b61039b565b61012b6101b136600461125c565b6103e7565b6101c96101c436600461139c565b610483565b005b61013f6101d9366004611431565b73ffffffffffffffffffffffffffffffffffffffff1660009081526033602052604090205490565b61010261068e565b61012b61021736600461125c565b61069d565b60655461023c9073ffffffffffffffffffffffffffffffffffffffff1681565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200161010f565b61012b61026f36600461125c565b61072b565b61012b61028236600461125c565b6107fc565b61013f610295366004611453565b73ffffffffffffffffffffffffffffffffffffffff918216600090815260346020908152604080832093909416825291909152205490565b6060603680546102dc90611486565b80601f016020809104026020016040519081016040528092919081815260200182805461030890611486565b80156103555780601f1061032a57610100808354040283529160200191610355565b820191906000526020600020905b81548152906001019060200180831161033857829003601f168201915b5050505050905090565b60003361036d818585610826565b5060019392505050565b6000336103858582856109da565b610390858585610ab1565b506001949350505050565b33600081815260346020908152604080832073ffffffffffffffffffffffffffffffffffffffff8716845290915281205490919061036d90829086906103e2908790611508565b610826565b60655460009073ffffffffffffffffffffffffffffffffffffffff163314610470576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601760248201527f546f6b656e577261707065643a4e4f545f42524944474500000000000000000060448201526064015b60405180910390fd5b61047a8383610d64565b50600192915050565b600054610100900460ff16158080156104a35750600054600160ff909116105b806104bd5750303b1580156104bd575060005460ff166001145b610549576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a65640000000000000000000000000000000000006064820152608401610467565b600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016600117905580156105a757600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff166101001790555b6105b18686610e85565b606580547fffffffffffffffffffffff00000000000000000000000000000000000000000016337fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff16177401000000000000000000000000000000000000000060ff8716021790556106238383610d64565b801561068657600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b505050505050565b6060603780546102dc90611486565b60655460009073ffffffffffffffffffffffffffffffffffffffff163314610721576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601760248201527f546f6b656e577261707065643a4e4f545f4252494447450000000000000000006044820152606401610467565b61047a8383610f26565b33600081815260346020908152604080832073ffffffffffffffffffffffffffffffffffffffff87168452909152812054909190838110156107ef576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760448201527f207a65726f0000000000000000000000000000000000000000000000000000006064820152608401610467565b6103908286868403610826565b60003361036d818585610ab1565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b73ffffffffffffffffffffffffffffffffffffffff83166108c8576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460448201527f72657373000000000000000000000000000000000000000000000000000000006064820152608401610467565b73ffffffffffffffffffffffffffffffffffffffff821661096b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f20616464726560448201527f73730000000000000000000000000000000000000000000000000000000000006064820152608401610467565b73ffffffffffffffffffffffffffffffffffffffff83811660008181526034602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591015b60405180910390a3505050565b73ffffffffffffffffffffffffffffffffffffffff8381166000908152603460209081526040808320938616835292905220547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8114610aab5781811015610a9e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e63650000006044820152606401610467565b610aab8484848403610826565b50505050565b73ffffffffffffffffffffffffffffffffffffffff8316610b54576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f20616460448201527f64726573730000000000000000000000000000000000000000000000000000006064820152608401610467565b73ffffffffffffffffffffffffffffffffffffffff8216610bf7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201527f65737300000000000000000000000000000000000000000000000000000000006064820152608401610467565b73ffffffffffffffffffffffffffffffffffffffff831660009081526033602052604090205481811015610cad576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e742065786365656473206260448201527f616c616e636500000000000000000000000000000000000000000000000000006064820152608401610467565b73ffffffffffffffffffffffffffffffffffffffff808516600090815260336020526040808220858503905591851681529081208054849290610cf1908490611508565b925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef84604051610d5791815260200190565b60405180910390a3610aab565b73ffffffffffffffffffffffffffffffffffffffff8216610de1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f2061646472657373006044820152606401610467565b8060356000828254610df39190611508565b909155505073ffffffffffffffffffffffffffffffffffffffff821660009081526033602052604081208054839290610e2d908490611508565b909155505060405181815273ffffffffffffffffffffffffffffffffffffffff8316906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a35b5050565b600054610100900460ff16610f1c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610467565b610e818282611110565b73ffffffffffffffffffffffffffffffffffffffff8216610fc9576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f2061646472657360448201527f73000000000000000000000000000000000000000000000000000000000000006064820152608401610467565b73ffffffffffffffffffffffffffffffffffffffff82166000908152603360205260409020548181101561107f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e60448201527f63650000000000000000000000000000000000000000000000000000000000006064820152608401610467565b73ffffffffffffffffffffffffffffffffffffffff831660009081526033602052604081208383039055603580548492906110bb908490611520565b909155505060405182815260009073ffffffffffffffffffffffffffffffffffffffff8516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef906020016109cd565b505050565b600054610100900460ff166111a7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610467565b60366111b3838261157d565b50603761110b828261157d565b600060208083528351808285015260005b818110156111ed578581018301518582016040015282016111d1565b818111156111ff576000604083870101525b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016929092016040019392505050565b803573ffffffffffffffffffffffffffffffffffffffff8116811461125757600080fd5b919050565b6000806040838503121561126f57600080fd5b61127883611233565b946020939093013593505050565b60008060006060848603121561129b57600080fd5b6112a484611233565b92506112b260208501611233565b9150604084013590509250925092565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600082601f83011261130257600080fd5b813567ffffffffffffffff8082111561131d5761131d6112c2565b604051601f83017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f01168101908282118183101715611363576113636112c2565b8160405283815286602085880101111561137c57600080fd5b836020870160208301376000602085830101528094505050505092915050565b600080600080600060a086880312156113b457600080fd5b853567ffffffffffffffff808211156113cc57600080fd5b6113d889838a016112f1565b965060208801359150808211156113ee57600080fd5b506113fb888289016112f1565b945050604086013560ff8116811461141257600080fd5b925061142060608701611233565b949793965091946080013592915050565b60006020828403121561144357600080fd5b61144c82611233565b9392505050565b6000806040838503121561146657600080fd5b61146f83611233565b915061147d60208401611233565b90509250929050565b600181811c9082168061149a57607f821691505b6020821081036114d3577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000821982111561151b5761151b6114d9565b500190565b600082821015611532576115326114d9565b500390565b601f82111561110b57600081815260208120601f850160051c8101602086101561155e5750805b601f850160051c820191505b818110156106865782815560010161156a565b815167ffffffffffffffff811115611597576115976112c2565b6115ab816115a58454611486565b84611537565b602080601f8311600181146115fe57600084156115c85750858301515b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600386901b1c1916600185901b178555610686565b6000858152602081207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08616915b8281101561164b5788860151825594840194600190910190840161162c565b508582101561168757878501517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600388901b60f8161c191681555b5050505050600190811b0190555056fea264697066735822122015dd8047eba7f7221e0d7792549e5a01ba1b6dfaad0c6a70dc82ef386e0c5cc464736f6c634300080f0033", + Key: "", + Value: "", + Root: "", + }, + { + Address: "0x61ba0248b0986c2480181c6e76b6adeeaa962483", + Type: int(merkletree.LeafTypeStorage), + StoragePosition: "0x0000000000000000000000000000000000000000000000000000000000000000", + Bytecode: "", + Key: "", + Value: "0x01", + Root: "", + }, +} diff --git a/config/genesis.local.json b/config/genesis.local.json deleted file mode 100644 index 63db85e544..0000000000 --- a/config/genesis.local.json +++ /dev/null @@ -1,84 +0,0 @@ -{ - "root": "0x2f6faa6d4df6548625caca49d4b474e7283173bcedd37480c7c88a221e739399", - "genesis": [ - { - "balance": "0", - "nonce": "0", - "address": "0x0000000000000000000000000000000000000000" - }, - { - "balance": "0", - "nonce": "1", - "address": "0xae4bb80be56b819606589de61d5ec3b522eeb032", - "bytecode": "0x608060405234801561001057600080fd5b506004361061004c5760003560e01c806301fd904414610051578063257b36321461006d57806333d6247d1461008d578063a3c573eb146100a2575b600080fd5b61005a60015481565b6040519081526020015b60405180910390f35b61005a61007b366004610197565b60006020819052908152604090205481565b6100a061009b366004610197565b6100e7565b005b6002546100c29073ffffffffffffffffffffffffffffffffffffffff1681565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610064565b60025473ffffffffffffffffffffffffffffffffffffffff163314610192576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603460248201527f476c6f62616c45786974526f6f744d616e616765724c323a3a7570646174654560448201527f786974526f6f743a204f4e4c595f425249444745000000000000000000000000606482015260840160405180910390fd5b600155565b6000602082840312156101a957600080fd5b503591905056fea2646970667358221220b6ba072419f510d5d5b9a55d9605786898f58415125e7e2ac3f699371fda0cbc64736f6c634300080f0033", - "storage": { - "0x0000000000000000000000000000000000000000000000000000000000000002": "0x9d98deabc42dd696deb9e40b4f1cab7ddbf55988" - }, - "contractName": "GlobalExitRootManagerL2" - }, - { - "balance": "100000000000000000000000", - "nonce": "2", - "address": "0x9d98deabc42dd696deb9e40b4f1cab7ddbf55988", - "bytecode": "0x6080604052600436106101295760003560e01c806381b1c174116100a5578063bab161bf11610074578063e737588111610059578063e737588114610489578063ed6be5c9146104b9578063f2fde38b146104ce57600080fd5b8063bab161bf1461042a578063d02103ca1461045c57600080fd5b806381b1c174146103895780638da5cb5b146103cc578063b33f8059146103f7578063b7e6a7d41461040a57600080fd5b80633ae05047116100fc5780635a64a1da116100e15780635a64a1da146102995780635d5d326f14610352578063715018a61461037457600080fd5b80633ae05047146102545780633da816821461026957600080fd5b806322e95f2c1461012e5780632dfdf0b5146101785780632f3a3d5d1461019c578063318aee3d146101d0575b600080fd5b34801561013a57600080fd5b5061014e6101493660046120a1565b6104ee565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020015b60405180910390f35b34801561018457600080fd5b5061018e60415481565b60405190815260200161016f565b3480156101a857600080fd5b5061014e7f00000000000000000000000061ba0248b0986c2480181c6e76b6adeeaa96248381565b3480156101dc57600080fd5b506102236101eb3660046120d4565b60456020526000908152604090205463ffffffff811690640100000000900473ffffffffffffffffffffffffffffffffffffffff1682565b6040805163ffffffff909316835273ffffffffffffffffffffffffffffffffffffffff90911660208301520161016f565b34801561026057600080fd5b5061018e610591565b34801561027557600080fd5b506102896102843660046121e2565b61065d565b604051901515815260200161016f565b3480156102a557600080fd5b5061018e6102b436600461224b565b604080517fffffffff0000000000000000000000000000000000000000000000000000000060e098891b81166020808401919091527fffffffffffffffffffffffffffffffffffffffff0000000000000000000000006060998a1b811660248501529790991b1660388201529390951b909316603c830152605082015260708082019290925282518082039092018252609001909152805191012090565b34801561035e57600080fd5b5061037261036d36600461234d565b61074d565b005b34801561038057600080fd5b506103726111da565b34801561039557600080fd5b5061014e6103a4366004612423565b60446020526000908152604090205473ffffffffffffffffffffffffffffffffffffffff1681565b3480156103d857600080fd5b5060005473ffffffffffffffffffffffffffffffffffffffff1661014e565b61037261040536600461243c565b6111ee565b34801561041657600080fd5b5061014e6104253660046120a1565b61179c565b34801561043657600080fd5b506042546104479063ffffffff1681565b60405163ffffffff909116815260200161016f565b34801561046857600080fd5b5060465461014e9073ffffffffffffffffffffffffffffffffffffffff1681565b34801561049557600080fd5b506102896104a4366004612423565b60436020526000908152604090205460ff1681565b3480156104c557600080fd5b50610447600081565b3480156104da57600080fd5b506103726104e93660046120d4565b611849565b6040805160e084901b7fffffffff0000000000000000000000000000000000000000000000000000000016602080830191909152606084901b7fffffffffffffffffffffffffffffffffffffffff000000000000000000000000166024830152825160188184030181526038909201835281519181019190912060009081526044909152205473ffffffffffffffffffffffffffffffffffffffff165b92915050565b6041546000908190815b602081101561065557816001166001036105f557600181602081106105c2576105c2612487565b01546040805160208101929092528101849052606001604051602081830303815290604052805190602001209250610636565b826021826020811061060957610609612487565b01546040805160208101939093528201526060016040516020818303038152906040528051906020012092505b6106416002836124e5565b91508061064d81612520565b91505061059b565b509092915050565b60008467ffffffffffffffff8416825b602081101561074057816001166001036106d35786818151811061069357610693612487565b6020026020010151836040516020016106b6929190918252602082015260400190565b604051602081830303815290604052805190602001209250610721565b828782815181106106e6576106e6612487565b6020026020010151604051602001610708929190918252602082015260400190565b6040516020818303038152906040528051906020012092505b61072c6002836124e5565b91508061073881612520565b91505061066d565b5050909114949350505050565b63ffffffff891660009081526043602052604090205460ff16156107d2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601e60248201527f4272696467653a3a636c61696d3a20414c52454144595f434c41494d4544000060448201526064015b60405180910390fd5b6046546040805160208082018c90528183018b9052825180830384018152606083019384905280519101207f257b363200000000000000000000000000000000000000000000000000000000909252606481019190915273ffffffffffffffffffffffffffffffffffffffff9091169063257b3632906084016020604051808303816000875af115801561086a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061088e9190612558565b60000361091d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602e60248201527f4272696467653a3a636c61696d3a20474c4f42414c5f455849545f524f4f545f60448201527f444f45535f4e4f545f4d4154434800000000000000000000000000000000000060648201526084016107c9565b60425463ffffffff8581169116146109b7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603160248201527f4272696467653a3a636c61696d3a2044455354494e4154494f4e5f4e4554574f60448201527f524b5f444f45535f4e4f545f4d4154434800000000000000000000000000000060648201526084016107c9565b60425463ffffffff16610ae2578051602080830191909120604080517fffffffff0000000000000000000000000000000000000000000000000000000060e08b811b8216838701527fffffffffffffffffffffffffffffffffffffffff00000000000000000000000060608c811b82166024860152918b901b909216603884015288901b16603c820152605081018690526070808201939093528151808203909301835260900190528051910120610a77908b8b63ffffffff168a61065d565b610add576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f4272696467653a3a636c61696d3a20534d545f494e56414c494400000000000060448201526064016107c9565b610bfb565b8051602080830191909120604080517fffffffff0000000000000000000000000000000000000000000000000000000060e08b811b8216838701527fffffffffffffffffffffffffffffffffffffffff00000000000000000000000060608c811b82166024860152918b901b909216603884015288901b16603c820152605081018690526070808201939093528151808203909301835260900190528051910120610b95908b8b63ffffffff168b61065d565b610bfb576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f4272696467653a3a636c61696d3a20534d545f494e56414c494400000000000060448201526064016107c9565b63ffffffff8916600090815260436020526040902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016600117905573ffffffffffffffffffffffffffffffffffffffff8516610d64576040805160008082526020820190925273ffffffffffffffffffffffffffffffffffffffff8516908490604051610c8b919061259d565b60006040518083038185875af1925050503d8060008114610cc8576040519150601f19603f3d011682016040523d82523d6000602084013e610ccd565b606091505b5050905080610d5e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602260248201527f4272696467653a3a636c61696d3a204554485f5452414e534645525f4641494c60448201527f454400000000000000000000000000000000000000000000000000000000000060648201526084016107c9565b50611163565b60425463ffffffff90811690871603610d9d57610d9873ffffffffffffffffffffffffffffffffffffffff86168484611900565b611163565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e088901b1660208201527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606087901b166024820152600090603801604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe081840301815291815281516020928301206000818152604490935291205490915073ffffffffffffffffffffffffffffffffffffffff16806110c5576000610e8b7f00000000000000000000000061ba0248b0986c2480181c6e76b6adeeaa962483846119d9565b9050600080600086806020019051810190610ea6919061260f565b9250925092508373ffffffffffffffffffffffffffffffffffffffff16636c9452218484848d8d6040518663ffffffff1660e01b8152600401610eed9594939291906126cd565b600060405180830381600087803b158015610f0757600080fd5b505af1158015610f1b573d6000803e3d6000fd5b50505050836044600088815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060405180604001604052808d63ffffffff1681526020018c73ffffffffffffffffffffffffffffffffffffffff16815250604560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008201518160000160006101000a81548163ffffffff021916908363ffffffff16021790555060208201518160000160046101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055509050507fccd7715648d1f2bb13e158f96b5b6c3aeda555d4cb87112e274a6f28bc571d598c8c866040516110b49392919063ffffffff93909316835273ffffffffffffffffffffffffffffffffffffffff918216602084015216604082015260600190565b60405180910390a150505050611160565b6040517f40c10f1900000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8681166004830152602482018690528216906340c10f19906044016020604051808303816000875af115801561113a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061115e9190612729565b505b50505b6040805163ffffffff8b811682528816602082015273ffffffffffffffffffffffffffffffffffffffff87811682840152851660608201526080810184905290517f25308c93ceeed162da955b3f7ce3e3f93606579e40fb92029faa9efe275459839181900360a00190a150505050505050505050565b6111e2611ab7565b6111ec6000611b38565b565b60425463ffffffff90811690841603611289576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f4272696467653a3a6272696467653a2044455354494e4154494f4e5f43414e5460448201527f5f42455f495453454c460000000000000000000000000000000000000000000060648201526084016107c9565b600080606073ffffffffffffffffffffffffffffffffffffffff871661134157833414611338576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602f60248201527f4272696467653a3a6272696467653a20414d4f554e545f444f45535f4e4f545f60448201527f4d415443485f4d53475f56414c5545000000000000000000000000000000000060648201526084016107c9565b6000915061162e565b73ffffffffffffffffffffffffffffffffffffffff80881660009081526045602090815260409182902082518084019093525463ffffffff811683526401000000009004909216918101829052901561143d576040517f9dc29fac0000000000000000000000000000000000000000000000000000000081523360048201526024810186905273ffffffffffffffffffffffffffffffffffffffff891690639dc29fac906044016020604051808303816000875af1158015611407573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061142b9190612729565b5060208101518151909450925061162c565b61145f73ffffffffffffffffffffffffffffffffffffffff8916333088611bad565b879350604260009054906101000a900463ffffffff1692508773ffffffffffffffffffffffffffffffffffffffff166306fdde036040518163ffffffff1660e01b8152600401600060405180830381865afa1580156114c2573d6000803e3d6000fd5b505050506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0168201604052611508919081019061274b565b8873ffffffffffffffffffffffffffffffffffffffff166395d89b416040518163ffffffff1660e01b8152600401600060405180830381865afa158015611553573d6000803e3d6000fd5b505050506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0168201604052611599919081019061274b565b8973ffffffffffffffffffffffffffffffffffffffff1663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa1580156115e4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116089190612780565b60405160200161161a9392919061279b565b60405160208183030381529060405291505b505b7ff0b963192bdc6349c23af9bd17294b4c7b9b5a73a2a9939610ea18ffd1c5dc2a82848888888660415460405161166b97969594939291906127d4565b60405180910390a18051602080830191909120604080517fffffffff0000000000000000000000000000000000000000000000000000000060e087811b8216838701527fffffffffffffffffffffffffffffffffffffffff00000000000000000000000060608a811b82166024860152918d901b90921660388401528a901b16603c82015260508101889052607080820193909352815180820390930183526090019052805191012061171d90611c11565b60465473ffffffffffffffffffffffffffffffffffffffff166333d6247d611743610591565b6040518263ffffffff1660e01b815260040161176191815260200190565b600060405180830381600087803b15801561177b57600080fd5b505af115801561178f573d6000803e3d6000fd5b5050505050505050505050565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e084901b1660208201527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606083901b16602482015260009081906038016040516020818303038152906040528051906020012090506118417f00000000000000000000000061ba0248b0986c2480181c6e76b6adeeaa96248382611d73565b949350505050565b611851611ab7565b73ffffffffffffffffffffffffffffffffffffffff81166118f4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016107c9565b6118fd81611b38565b50565b60405173ffffffffffffffffffffffffffffffffffffffff83166024820152604481018290526119d49084907fa9059cbb00000000000000000000000000000000000000000000000000000000906064015b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff0000000000000000000000000000000000000000000000000000000090931692909217909152611df6565b505050565b60006040517f3d602d80600a3d3981f3363d3d373d3d3d363d7300000000000000000000000081528360601b60148201527f5af43d82803e903d91602b57fd5bf300000000000000000000000000000000006028820152826037826000f591505073ffffffffffffffffffffffffffffffffffffffff811661058b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601760248201527f455243313136373a2063726561746532206661696c656400000000000000000060448201526064016107c9565b60005473ffffffffffffffffffffffffffffffffffffffff1633146111ec576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016107c9565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60405173ffffffffffffffffffffffffffffffffffffffff80851660248301528316604482015260648101829052611c0b9085907f23b872dd0000000000000000000000000000000000000000000000000000000090608401611952565b50505050565b806001611c206020600261295f565b611c2a919061296b565b60415410611cba576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f4465706f736974436f6e74726163743a5f6465706f7369743a204d45524b4c4560448201527f5f545245455f46554c4c0000000000000000000000000000000000000000000060648201526084016107c9565b600160416000828254611ccd9190612982565b909155505060415460005b6020811015611d6a5781600116600103611d08578260018260208110611d0057611d00612487565b015550505050565b60018160208110611d1b57611d1b612487565b01546040805160208101929092528101849052606001604051602081830303815290604052805190602001209250600282611d5691906124e5565b915080611d6281612520565b915050611cd8565b506119d461299a565b6000611def8383306040517f3d602d80600a3d3981f3363d3d373d3d3d363d730000000000000000000000008152606093841b60148201527f5af43d82803e903d91602b57fd5bf3ff000000000000000000000000000000006028820152921b6038830152604c8201526037808220606c830152605591012090565b9392505050565b6000611e58826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff16611f029092919063ffffffff16565b8051909150156119d45780806020019051810190611e769190612729565b6119d4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f7420737563636565640000000000000000000000000000000000000000000060648201526084016107c9565b606061184184846000858573ffffffffffffffffffffffffffffffffffffffff85163b611f8b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016107c9565b6000808673ffffffffffffffffffffffffffffffffffffffff168587604051611fb4919061259d565b60006040518083038185875af1925050503d8060008114611ff1576040519150601f19603f3d011682016040523d82523d6000602084013e611ff6565b606091505b5091509150612006828286612011565b979650505050505050565b60608315612020575081611def565b8251156120305782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107c991906129c9565b803563ffffffff8116811461207857600080fd5b919050565b803573ffffffffffffffffffffffffffffffffffffffff8116811461207857600080fd5b600080604083850312156120b457600080fd5b6120bd83612064565b91506120cb6020840161207d565b90509250929050565b6000602082840312156120e657600080fd5b611def8261207d565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff81118282101715612165576121656120ef565b604052919050565b600082601f83011261217e57600080fd5b8135602067ffffffffffffffff82111561219a5761219a6120ef565b8160051b6121a982820161211e565b92835284810182019282810190878511156121c357600080fd5b83870192505b84831015612006578235825291830191908301906121c9565b600080600080608085870312156121f857600080fd5b84359350602085013567ffffffffffffffff8082111561221757600080fd5b6122238883890161216d565b945060408701359150808216821461223a57600080fd5b509396929550929360600135925050565b60008060008060008060c0878903121561226457600080fd5b61226d87612064565b955061227b6020880161207d565b945061228960408801612064565b93506122976060880161207d565b92506080870135915060a087013590509295509295509295565b600067ffffffffffffffff8211156122cb576122cb6120ef565b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01660200190565b600082601f83011261230857600080fd5b813561231b612316826122b1565b61211e565b81815284602083860101111561233057600080fd5b816020850160208301376000918101602001919091529392505050565b6000806000806000806000806000806101408b8d03121561236d57600080fd5b8a3567ffffffffffffffff8082111561238557600080fd5b6123918e838f0161216d565b9b5061239f60208e01612064565b9a5060408d0135995060608d013598506123bb60808e01612064565b97506123c960a08e0161207d565b96506123d760c08e01612064565b95506123e560e08e0161207d565b94506101008d013593506101208d013591508082111561240457600080fd5b506124118d828e016122f7565b9150509295989b9194979a5092959850565b60006020828403121561243557600080fd5b5035919050565b6000806000806080858703121561245257600080fd5b61245b8561207d565b935061246960208601612064565b92506124776040860161207d565b9396929550929360600135925050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60008261251b577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203612551576125516124b6565b5060010190565b60006020828403121561256a57600080fd5b5051919050565b60005b8381101561258c578181015183820152602001612574565b83811115611c0b5750506000910152565b600082516125af818460208701612571565b9190910192915050565b600082601f8301126125ca57600080fd5b81516125d8612316826122b1565b8181528460208386010111156125ed57600080fd5b611841826020830160208701612571565b805160ff8116811461207857600080fd5b60008060006060848603121561262457600080fd5b835167ffffffffffffffff8082111561263c57600080fd5b612648878388016125b9565b9450602086015191508082111561265e57600080fd5b5061266b868287016125b9565b92505061267a604085016125fe565b90509250925092565b6000815180845261269b816020860160208601612571565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b60a0815260006126e060a0830188612683565b82810360208401526126f28188612683565b60ff969096166040840152505073ffffffffffffffffffffffffffffffffffffffff92909216606083015260809091015292915050565b60006020828403121561273b57600080fd5b81518015158114611def57600080fd5b60006020828403121561275d57600080fd5b815167ffffffffffffffff81111561277457600080fd5b611841848285016125b9565b60006020828403121561279257600080fd5b611def826125fe565b6060815260006127ae6060830186612683565b82810360208401526127c08186612683565b91505060ff83166040830152949350505050565b600063ffffffff808a16835273ffffffffffffffffffffffffffffffffffffffff808a166020850152818916604085015280881660608501525085608084015260e060a084015261282860e0840186612683565b915080841660c08401525098975050505050505050565b600181815b8085111561289857817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0482111561287e5761287e6124b6565b8085161561288b57918102915b93841c9390800290612844565b509250929050565b6000826128af5750600161058b565b816128bc5750600061058b565b81600181146128d257600281146128dc576128f8565b600191505061058b565b60ff8411156128ed576128ed6124b6565b50506001821b61058b565b5060208310610133831016604e8410600b841016171561291b575081810a61058b565b612925838361283f565b807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04821115612957576129576124b6565b029392505050565b6000611def83836128a0565b60008282101561297d5761297d6124b6565b500390565b60008219821115612995576129956124b6565b500190565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052600160045260246000fd5b602081526000611def602083018461268356fea2646970667358221220661de3647f4974bcce9601e5fd1496c92e90e395b490b107b6eb5598ab3495cc64736f6c634300080f0033", - "storage": { - "0x0000000000000000000000000000000000000000000000000000000000000000": "0xc949254d682d8c9ad5682521675b8f43b102aec4", - "0x0000000000000000000000000000000000000000000000000000000000000042": "0x01", - "0x0000000000000000000000000000000000000000000000000000000000000046": "0xae4bb80be56b819606589de61d5ec3b522eeb032", - "0x0000000000000000000000000000000000000000000000000000000000000022": "0xad3228b676f7d3cd4284a5443f17f1962b36e491b30a40b2405849e597ba5fb5", - "0x0000000000000000000000000000000000000000000000000000000000000023": "0xb4c11951957c6f8f642c4af61cd6b24640fec6dc7fc607ee8206a99e92410d30", - "0x0000000000000000000000000000000000000000000000000000000000000024": "0x21ddb9a356815c3fac1026b6dec5df3124afbadb485c9ba5a3e3398a04b7ba85", - "0x0000000000000000000000000000000000000000000000000000000000000025": "0xe58769b32a1beaf1ea27375a44095a0d1fb664ce2dd358e7fcbfb78c26a19344", - "0x0000000000000000000000000000000000000000000000000000000000000026": "0x0eb01ebfc9ed27500cd4dfc979272d1f0913cc9f66540d7e8005811109e1cf2d", - "0x0000000000000000000000000000000000000000000000000000000000000027": "0x887c22bd8750d34016ac3c66b5ff102dacdd73f6b014e710b51e8022af9a1968", - "0x0000000000000000000000000000000000000000000000000000000000000028": "0xffd70157e48063fc33c97a050f7f640233bf646cc98d9524c6b92bcf3ab56f83", - "0x0000000000000000000000000000000000000000000000000000000000000029": "0x9867cc5f7f196b93bae1e27e6320742445d290f2263827498b54fec539f756af", - "0x000000000000000000000000000000000000000000000000000000000000002a": "0xcefad4e508c098b9a7e1d8feb19955fb02ba9675585078710969d3440f5054e0", - "0x000000000000000000000000000000000000000000000000000000000000002b": "0xf9dc3e7fe016e050eff260334f18a5d4fe391d82092319f5964f2e2eb7c1c3a5", - "0x000000000000000000000000000000000000000000000000000000000000002c": "0xf8b13a49e282f609c317a833fb8d976d11517c571d1221a265d25af778ecf892", - "0x000000000000000000000000000000000000000000000000000000000000002d": "0x3490c6ceeb450aecdc82e28293031d10c7d73bf85e57bf041a97360aa2c5d99c", - "0x000000000000000000000000000000000000000000000000000000000000002e": "0xc1df82d9c4b87413eae2ef048f94b4d3554cea73d92b0f7af96e0271c691e2bb", - "0x000000000000000000000000000000000000000000000000000000000000002f": "0x5c67add7c6caf302256adedf7ab114da0acfe870d449a3a489f781d659e8becc", - "0x0000000000000000000000000000000000000000000000000000000000000030": "0xda7bce9f4e8618b6bd2f4132ce798cdc7a60e7e1460a7299e3c6342a579626d2", - "0x0000000000000000000000000000000000000000000000000000000000000031": "0x2733e50f526ec2fa19a22b31e8ed50f23cd1fdf94c9154ed3a7609a2f1ff981f", - "0x0000000000000000000000000000000000000000000000000000000000000032": "0xe1d3b5c807b281e4683cc6d6315cf95b9ade8641defcb32372f1c126e398ef7a", - "0x0000000000000000000000000000000000000000000000000000000000000033": "0x5a2dce0a8a7f68bb74560f8f71837c2c2ebbcbf7fffb42ae1896f13f7c7479a0", - "0x0000000000000000000000000000000000000000000000000000000000000034": "0xb46a28b6f55540f89444f63de0378e3d121be09e06cc9ded1c20e65876d36aa0", - "0x0000000000000000000000000000000000000000000000000000000000000035": "0xc65e9645644786b620e2dd2ad648ddfcbf4a7e5b1a3a4ecfe7f64667a3f0b7e2", - "0x0000000000000000000000000000000000000000000000000000000000000036": "0xf4418588ed35a2458cffeb39b93d26f18d2ab13bdce6aee58e7b99359ec2dfd9", - "0x0000000000000000000000000000000000000000000000000000000000000037": "0x5a9c16dc00d6ef18b7933a6f8dc65ccb55667138776f7dea101070dc8796e377", - "0x0000000000000000000000000000000000000000000000000000000000000038": "0x4df84f40ae0c8229d0d6069e5c8f39a7c299677a09d367fc7b05e3bc380ee652", - "0x0000000000000000000000000000000000000000000000000000000000000039": "0xcdc72595f74c7b1043d0e1ffbab734648c838dfb0527d971b602bc216c9619ef", - "0x000000000000000000000000000000000000000000000000000000000000003a": "0x0abf5ac974a1ed57f4050aa510dd9c74f508277b39d7973bb2dfccc5eeb0618d", - "0x000000000000000000000000000000000000000000000000000000000000003b": "0xb8cd74046ff337f0a7bf2c8e03e10f642c1886798d71806ab1e888d9e5ee87d0", - "0x000000000000000000000000000000000000000000000000000000000000003c": "0x838c5655cb21c6cb83313b5a631175dff4963772cce9108188b34ac87c81c41e", - "0x000000000000000000000000000000000000000000000000000000000000003d": "0x662ee4dd2dd7b2bc707961b1e646c4047669dcb6584f0d8d770daf5d7e7deb2e", - "0x000000000000000000000000000000000000000000000000000000000000003e": "0x388ab20e2573d171a88108e79d820e98f26c0b84aa8b2f4aa4968dbb818ea322", - "0x000000000000000000000000000000000000000000000000000000000000003f": "0x93237c50ba75ee485f4c22adf2f741400bdf8d6a9cc7df7ecae576221665d735", - "0x0000000000000000000000000000000000000000000000000000000000000040": "0x8448818bb4ae4562849e949e17ac16e0be16688e156b5cf15e098c627c0056a9" - }, - "contractName": "Bridge" - }, - { - "balance": "0", - "nonce": "2", - "address": "0xc949254d682d8c9ad5682521675b8f43b102aec4", - "pvtKey": "0xdfd01798f92667dbf91df722434e8fbe96af0211d4d1b82bbbbc8f1def7a814f" - }, - { - "balance": "100000000000000000000000", - "nonce": "0", - "address": "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266", - "pvtKey": "0x00" - }, - { - "balance": "0", - "nonce": "1", - "address": "0x61ba0248b0986c2480181c6e76b6adeeaa962483", - "bytecode": "0x608060405234801561001057600080fd5b50600436106100f55760003560e01c80636c94522111610097578063a3c573eb11610066578063a3c573eb1461021c578063a457c2d714610261578063a9059cbb14610274578063dd62ed3e1461028757600080fd5b80636c945221146101b657806370a08231146101cb57806395d89b41146102015780639dc29fac1461020957600080fd5b806323b872dd116100d357806323b872dd1461014d578063313ce56714610160578063395093511461019057806340c10f19146101a357600080fd5b806306fdde03146100fa578063095ea7b31461011857806318160ddd1461013b575b600080fd5b6101026102cd565b60405161010f9190611268565b60405180910390f35b61012b6101263660046112ff565b61035f565b604051901515815260200161010f565b6035545b60405190815260200161010f565b61012b61015b366004611329565b610377565b60655474010000000000000000000000000000000000000000900460ff1660405160ff909116815260200161010f565b61012b61019e3660046112ff565b61039b565b61012b6101b13660046112ff565b6103e7565b6101c96101c436600461143f565b610483565b005b61013f6101d93660046114d4565b73ffffffffffffffffffffffffffffffffffffffff1660009081526033602052604090205490565b6101026105ab565b61012b6102173660046112ff565b6105ba565b60655461023c9073ffffffffffffffffffffffffffffffffffffffff1681565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200161010f565b61012b61026f3660046112ff565b610648565b61012b6102823660046112ff565b610719565b61013f6102953660046114f6565b73ffffffffffffffffffffffffffffffffffffffff918216600090815260346020908152604080832093909416825291909152205490565b6060603680546102dc90611529565b80601f016020809104026020016040519081016040528092919081815260200182805461030890611529565b80156103555780601f1061032a57610100808354040283529160200191610355565b820191906000526020600020905b81548152906001019060200180831161033857829003601f168201915b5050505050905090565b60003361036d818585610743565b5060019392505050565b6000336103858582856108f7565b6103908585856109ce565b506001949350505050565b33600081815260346020908152604080832073ffffffffffffffffffffffffffffffffffffffff8716845290915281205490919061036d90829086906103e29087906115ab565b610743565b60655460009073ffffffffffffffffffffffffffffffffffffffff163314610470576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601760248201527f546f6b656e577261707065643a4e4f545f42524944474500000000000000000060448201526064015b60405180910390fd5b61047a8383610c81565b50600192915050565b600061048f6001610da2565b905080156104c457600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff166101001790555b6104ce8686610f2d565b606580547fffffffffffffffffffffff00000000000000000000000000000000000000000016337fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff16177401000000000000000000000000000000000000000060ff8716021790556105408383610c81565b80156105a357600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b505050505050565b6060603780546102dc90611529565b60655460009073ffffffffffffffffffffffffffffffffffffffff16331461063e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601760248201527f546f6b656e577261707065643a4e4f545f4252494447450000000000000000006044820152606401610467565b61047a8383610fce565b33600081815260346020908152604080832073ffffffffffffffffffffffffffffffffffffffff871684529091528120549091908381101561070c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760448201527f207a65726f0000000000000000000000000000000000000000000000000000006064820152608401610467565b6103908286868403610743565b60003361036d8185856109ce565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b73ffffffffffffffffffffffffffffffffffffffff83166107e5576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460448201527f72657373000000000000000000000000000000000000000000000000000000006064820152608401610467565b73ffffffffffffffffffffffffffffffffffffffff8216610888576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f20616464726560448201527f73730000000000000000000000000000000000000000000000000000000000006064820152608401610467565b73ffffffffffffffffffffffffffffffffffffffff83811660008181526034602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591015b60405180910390a3505050565b73ffffffffffffffffffffffffffffffffffffffff8381166000908152603460209081526040808320938616835292905220547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81146109c857818110156109bb576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e63650000006044820152606401610467565b6109c88484848403610743565b50505050565b73ffffffffffffffffffffffffffffffffffffffff8316610a71576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f20616460448201527f64726573730000000000000000000000000000000000000000000000000000006064820152608401610467565b73ffffffffffffffffffffffffffffffffffffffff8216610b14576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201527f65737300000000000000000000000000000000000000000000000000000000006064820152608401610467565b73ffffffffffffffffffffffffffffffffffffffff831660009081526033602052604090205481811015610bca576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e742065786365656473206260448201527f616c616e636500000000000000000000000000000000000000000000000000006064820152608401610467565b73ffffffffffffffffffffffffffffffffffffffff808516600090815260336020526040808220858503905591851681529081208054849290610c0e9084906115ab565b925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef84604051610c7491815260200190565b60405180910390a36109c8565b73ffffffffffffffffffffffffffffffffffffffff8216610cfe576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f2061646472657373006044820152606401610467565b8060356000828254610d1091906115ab565b909155505073ffffffffffffffffffffffffffffffffffffffff821660009081526033602052604081208054839290610d4a9084906115ab565b909155505060405181815273ffffffffffffffffffffffffffffffffffffffff8316906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a35b5050565b60008054610100900460ff1615610e59578160ff166001148015610dc55750303b155b610e51576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a65640000000000000000000000000000000000006064820152608401610467565b506000919050565b60005460ff808416911610610ef0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a65640000000000000000000000000000000000006064820152608401610467565b50600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660ff92909216919091179055600190565b919050565b600054610100900460ff16610fc4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610467565b610d9e82826111b8565b73ffffffffffffffffffffffffffffffffffffffff8216611071576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f2061646472657360448201527f73000000000000000000000000000000000000000000000000000000000000006064820152608401610467565b73ffffffffffffffffffffffffffffffffffffffff821660009081526033602052604090205481811015611127576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e60448201527f63650000000000000000000000000000000000000000000000000000000000006064820152608401610467565b73ffffffffffffffffffffffffffffffffffffffff831660009081526033602052604081208383039055603580548492906111639084906115c3565b909155505060405182815260009073ffffffffffffffffffffffffffffffffffffffff8516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef906020016108ea565b505050565b600054610100900460ff1661124f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610467565b603661125b8382611620565b5060376111b38282611620565b600060208083528351808285015260005b8181101561129557858101830151858201604001528201611279565b818111156112a7576000604083870101525b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016929092016040019392505050565b803573ffffffffffffffffffffffffffffffffffffffff81168114610f2857600080fd5b6000806040838503121561131257600080fd5b61131b836112db565b946020939093013593505050565b60008060006060848603121561133e57600080fd5b611347846112db565b9250611355602085016112db565b9150604084013590509250925092565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600082601f8301126113a557600080fd5b813567ffffffffffffffff808211156113c0576113c0611365565b604051601f83017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f0116810190828211818310171561140657611406611365565b8160405283815286602085880101111561141f57600080fd5b836020870160208301376000602085830101528094505050505092915050565b600080600080600060a0868803121561145757600080fd5b853567ffffffffffffffff8082111561146f57600080fd5b61147b89838a01611394565b9650602088013591508082111561149157600080fd5b5061149e88828901611394565b945050604086013560ff811681146114b557600080fd5b92506114c3606087016112db565b949793965091946080013592915050565b6000602082840312156114e657600080fd5b6114ef826112db565b9392505050565b6000806040838503121561150957600080fd5b611512836112db565b9150611520602084016112db565b90509250929050565b600181811c9082168061153d57607f821691505b602082108103611576577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600082198211156115be576115be61157c565b500190565b6000828210156115d5576115d561157c565b500390565b601f8211156111b357600081815260208120601f850160051c810160208610156116015750805b601f850160051c820191505b818110156105a35782815560010161160d565b815167ffffffffffffffff81111561163a5761163a611365565b61164e816116488454611529565b846115da565b602080601f8311600181146116a1576000841561166b5750858301515b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600386901b1c1916600185901b1785556105a3565b6000858152602081207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08616915b828110156116ee578886015182559484019460019091019084016116cf565b508582101561172a57878501517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600388901b60f8161c191681555b5050505050600190811b0190555056fea26469706673582212203e2954977597952d1f25e63c2d508e9e327dc004c141323911de5897253a0d9864736f6c634300080f0033", - "storage": { - "0x0000000000000000000000000000000000000000000000000000000000000000": "0x01" - } - } - ] - } \ No newline at end of file diff --git a/config/network.go b/config/network.go index 14e55fc511..8bee078328 100644 --- a/config/network.go +++ b/config/network.go @@ -4,25 +4,47 @@ import ( "encoding/json" "io/ioutil" "os" + "reflect" "github.com/0xPolygonHermez/zkevm-node/log" "github.com/0xPolygonHermez/zkevm-node/merkletree" "github.com/0xPolygonHermez/zkevm-node/state" "github.com/ethereum/go-ethereum/common" + "github.com/imdario/mergo" "github.com/urfave/cli/v2" ) // NetworkConfig is the configuration struct for the different environments type NetworkConfig struct { - L2GlobalExitRootManagerAddr common.Address - L2BridgeAddr common.Address - Genesis state.Genesis - MaxCumulativeGasUsed uint64 + GenBlockNumber uint64 + PoEAddr common.Address + MaticAddr common.Address + L2GlobalExitRootManagerAddr common.Address + L2BridgeAddr common.Address + GlobalExitRootManagerAddr common.Address + SystemSCAddr common.Address + GlobalExitRootStoragePosition uint64 + LocalExitRootStoragePosition uint64 + OldStateRootPosition uint64 + L1ChainID uint64 + // L2ChainID is read from POE SC + L2ChainID uint64 + Genesis state.Genesis + MaxCumulativeGasUsed uint64 } -type genesisFromJSON struct { - Root string `json:"root"` - Genesis []genesisAccountFromJSON `json:"genesis"` +type networkConfigFromJSON struct { + PoEAddr string `json:"proofOfEfficiencyAddress"` + MaticAddr string `json:"maticTokenAddress"` + GlobalExitRootManagerAddr string `json:"globalExitRootManagerAddress"` + GenBlockNumber uint64 `json:"deploymentBlockNumber"` + SystemSCAddr string `json:"systemSCAddr"` + GlobalExitRootStoragePosition uint64 `json:"globalExitRootStoragePosition"` + LocalExitRootStoragePosition uint64 `json:"localExitRootStoragePosition"` + OldStateRootPosition uint64 `json:"oldStateRootPosition"` + L1ChainID uint64 `json:"l1ChainID"` + Root string `json:"root"` + Genesis []genesisAccountFromJSON `json:"genesis"` } type genesisAccountFromJSON struct { @@ -34,96 +56,294 @@ type genesisAccountFromJSON struct { ContractName string `json:"contractName"` } -func (cfg *Config) loadNetworkConfig(ctx *cli.Context) { - config, err := loadGenesisFileConfig(ctx) - if err != nil { - log.Fatalf("failed to load genesis configuration from file. Error:", err) +const ( + testnet = "testnet" + internalTestnet = "internaltestnet" + local = "local" + merge = "merge" + custom = "custom" +) + +//nolint:gomnd +var ( + mainnetConfig = NetworkConfig{ + GenBlockNumber: 13808430, + PoEAddr: common.HexToAddress("0x11D0Dc8E2Ce3a93EB2b32f4C7c3fD9dDAf1211FA"), + MaticAddr: common.HexToAddress("0x37AffAf737C3683aB73F6E1B0933b725Ab9796Aa"), + L2GlobalExitRootManagerAddr: common.HexToAddress("0x0000000000000000000000000000000000000000"), + L2BridgeAddr: common.HexToAddress("0x0000000000000000000000000000000000000000"), + GlobalExitRootManagerAddr: common.HexToAddress("0x0000000000000000000000000000000000000000"), + SystemSCAddr: common.HexToAddress("0x0000000000000000000000000000000000000000"), + GlobalExitRootStoragePosition: 0, + LocalExitRootStoragePosition: 1, + OldStateRootPosition: 0, + L1ChainID: 1, //Mainnet + Genesis: state.Genesis{ + Actions: []*state.GenesisAction{ + { + Address: "0xb1D0Dc8E2Ce3a93EB2b32f4C7c3fD9dDAf1211FA", + Type: int(merkletree.LeafTypeBalance), + Value: "1000", + }, + { + Address: "0xb1D0Dc8E2Ce3a93EB2b32f4C7c3fD9dDAf1211FB", + Type: int(merkletree.LeafTypeBalance), + Value: "2000", + }, + }, + }, + } + testnetConfig = NetworkConfig{ + GenBlockNumber: 9817974, + PoEAddr: common.HexToAddress("0x21D0Dc8E2Ce3a93EB2b32f4C7c3fD9dDAf1211FA"), + MaticAddr: common.HexToAddress("0x37AffAf737C3683aB73F6E1B0933b725Ab9796Aa"), + L2GlobalExitRootManagerAddr: common.HexToAddress("0x0000000000000000000000000000000000000000"), + L2BridgeAddr: common.HexToAddress("0x0000000000000000000000000000000000000000"), + GlobalExitRootManagerAddr: common.HexToAddress("0x0000000000000000000000000000000000000000"), + SystemSCAddr: common.HexToAddress("0x0000000000000000000000000000000000000000"), + GlobalExitRootStoragePosition: 0, + LocalExitRootStoragePosition: 1, + OldStateRootPosition: 0, + L1ChainID: 4, //Rinkeby + Genesis: state.Genesis{ + Actions: []*state.GenesisAction{ + { + Address: "0xb1D0Dc8E2Ce3a93EB2b32f4C7c3fD9dDAf1211FA", + Type: int(merkletree.LeafTypeBalance), + Value: "1000", + }, + { + Address: "0xb1D0Dc8E2Ce3a93EB2b32f4C7c3fD9dDAf1211FB", + Type: int(merkletree.LeafTypeBalance), + Value: "2000", + }, + }, + }, } - cfg.NetworkConfig = config -} -func loadGenesisFileConfig(ctx *cli.Context) (NetworkConfig, error) { - cfgPath := ctx.String(FlagGenesisFile) - var cfg NetworkConfig + internalTestnetConfig = NetworkConfig{ + GenBlockNumber: 7674348, + PoEAddr: common.HexToAddress("0x159113e5560c9CC2d8c4e716228CCf92c72E9603"), + MaticAddr: common.HexToAddress("0x94Ca2BbE1b469f25D3B22BDf17Fc80ad09E7F662"), + L2GlobalExitRootManagerAddr: common.HexToAddress("0xae4bb80be56b819606589de61d5ec3b522eeb032"), + L2BridgeAddr: common.HexToAddress("0x9d98deabc42dd696deb9e40b4f1cab7ddbf55988"), + GlobalExitRootManagerAddr: common.HexToAddress("0xA379Dd55Eb12e8FCdb467A814A15DE2b29677066"), + SystemSCAddr: common.HexToAddress("0x0000000000000000000000000000000000000000"), + GlobalExitRootStoragePosition: 0, + LocalExitRootStoragePosition: 1, + OldStateRootPosition: 0, + L1ChainID: 5, //Goerli + Genesis: state.Genesis{ + Root: common.HexToHash("0xb33635210b9f5d07769cf70bf5a3cbf241ecbaf79a9b66ef79b28d920da1f776"), + Actions: []*state.GenesisAction{ + { + Address: "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", + Type: int(merkletree.LeafTypeBalance), + Value: "100000000000000000000000", + }, + }, + }, + } + + localConfig = NetworkConfig{ + GenBlockNumber: 1, + PoEAddr: common.HexToAddress("0x2279B7A0a67DB372996a5FaB50D91eAA73d2eBe6"), + MaticAddr: common.HexToAddress("0x5FbDB2315678afecb367f032d93F642f64180aa3"), + L2GlobalExitRootManagerAddr: common.HexToAddress("0xae4bb80be56b819606589de61d5ec3b522eeb032"), + L2BridgeAddr: common.HexToAddress("0x9d98deabc42dd696deb9e40b4f1cab7ddbf55988"), + GlobalExitRootManagerAddr: common.HexToAddress("0xDc64a140Aa3E981100a9becA4E685f962f0cF6C9"), + SystemSCAddr: common.HexToAddress("0x0000000000000000000000000000000000000000"), + GlobalExitRootStoragePosition: 0, + LocalExitRootStoragePosition: 1, + OldStateRootPosition: 0, + L1ChainID: 1337, + Genesis: state.Genesis{ + Root: common.HexToHash("0x5e3d5372166e22ee23b4800aecb491de96f425aa5c7d56f35c96905cc5e12cb8"), + Actions: []*state.GenesisAction{ + { + Address: "0x70997970C51812dc3A010C7d01b50e0d17dc79C8", + Type: int(merkletree.LeafTypeBalance), + Value: "100000000000000000000000", + }, + { + Address: "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", + Type: int(merkletree.LeafTypeBalance), + Value: "100000000000000000000000", + }, + }, + }, + } + + networkConfigByName = map[string]NetworkConfig{ + testnet: testnetConfig, + internalTestnet: internalTestnetConfig, + local: localConfig, + } +) - if cfgPath != "" { - f, err := os.Open(cfgPath) //nolint:gosec +func (cfg *Config) loadNetworkConfig(ctx *cli.Context) { + network := ctx.String(FlagNetwork) + + switch network { + case testnet: + log.Debug("Testnet network selected") + cfg.NetworkConfig = testnetConfig + case internalTestnet: + log.Debug("InternalTestnet network selected") + internalTestnetConfig.Genesis.Actions = append(internalTestnetConfig.Genesis.Actions, commonGenesisActions...) + cfg.NetworkConfig = internalTestnetConfig + case local: + log.Debug("Local network selected") + localConfig.Genesis.Actions = append(localConfig.Genesis.Actions, commonGenesisActions...) + cfg.NetworkConfig = localConfig + case custom: + customNetworkConfig, err := loadCustomNetworkConfig(ctx) if err != nil { - return NetworkConfig{}, err + log.Fatalf("Failed to load custom network configuration, err:", err) } - defer func() { - err := f.Close() - if err != nil { - log.Error(err) - } - }() - - b, err := ioutil.ReadAll(f) + cfg.NetworkConfig = customNetworkConfig + case merge: + customNetworkConfig, err := loadCustomNetworkConfig(ctx) if err != nil { - return NetworkConfig{}, err + log.Fatalf("Failed to load custom network configuration, err:", err) } - - var cfgJSON genesisFromJSON - err = json.Unmarshal([]byte(b), &cfgJSON) + baseNetworkConfigName := ctx.String(FlagNetworkBase) + baseNetworkConfig, ok := networkConfigByName[baseNetworkConfigName] + if !ok { + log.Fatalf("Base network configuration %q not found:", baseNetworkConfigName) + } + mergedNetworkConfig, err := mergeNetworkConfigs(customNetworkConfig, baseNetworkConfig) if err != nil { - return NetworkConfig{}, err + log.Fatalf("Failed to merge network configurations network configuration, err:", err) } + cfg.NetworkConfig = mergedNetworkConfig + default: + log.Debug("Mainnet network selected") + cfg.NetworkConfig = mainnetConfig + } +} - if len(cfgJSON.Genesis) == 0 { - return cfg, nil - } +func loadCustomNetworkConfig(ctx *cli.Context) (NetworkConfig, error) { + cfgPath := ctx.String(FlagNetworkCfg) - cfg.Genesis = state.Genesis{ - Root: common.HexToHash(cfgJSON.Root), - Actions: []*state.GenesisAction{}, + f, err := os.Open(cfgPath) //nolint:gosec + if err != nil { + return NetworkConfig{}, err + } + defer func() { + err := f.Close() + if err != nil { + log.Error(err) } + }() - const l2GlobalExitRootManagerSCName = "GlobalExitRootManagerL2" - const l2BridgeSCName = "Bridge" + b, err := ioutil.ReadAll(f) + if err != nil { + return NetworkConfig{}, err + } - for _, account := range cfgJSON.Genesis { - if account.ContractName == l2GlobalExitRootManagerSCName { - cfg.L2GlobalExitRootManagerAddr = common.HexToAddress(account.Address) - } - if account.ContractName == l2BridgeSCName { - cfg.L2BridgeAddr = common.HexToAddress(account.Address) + var cfgJSON networkConfigFromJSON + err = json.Unmarshal([]byte(b), &cfgJSON) + if err != nil { + return NetworkConfig{}, err + } + + var cfg NetworkConfig + cfg.GenBlockNumber = cfgJSON.GenBlockNumber + cfg.PoEAddr = common.HexToAddress(cfgJSON.PoEAddr) + cfg.MaticAddr = common.HexToAddress(cfgJSON.MaticAddr) + cfg.GlobalExitRootManagerAddr = common.HexToAddress(cfgJSON.GlobalExitRootManagerAddr) + cfg.SystemSCAddr = common.HexToAddress(cfgJSON.SystemSCAddr) + cfg.GlobalExitRootStoragePosition = cfgJSON.GlobalExitRootStoragePosition + cfg.LocalExitRootStoragePosition = cfgJSON.LocalExitRootStoragePosition + cfg.OldStateRootPosition = cfgJSON.OldStateRootPosition + cfg.L1ChainID = cfgJSON.L1ChainID + + if len(cfgJSON.Genesis) == 0 { + return cfg, nil + } + + cfg.Genesis = state.Genesis{ + Root: common.HexToHash(cfgJSON.Root), + Actions: []*state.GenesisAction{}, + } + + const l2GlobalExitRootManagerSCName = "GlobalExitRootManagerL2" + const l2BridgeSCName = "Bridge" + + for _, account := range cfgJSON.Genesis { + if account.ContractName == l2GlobalExitRootManagerSCName { + cfg.L2GlobalExitRootManagerAddr = common.HexToAddress(account.Address) + } + if account.ContractName == l2BridgeSCName { + cfg.L2BridgeAddr = common.HexToAddress(account.Address) + } + if account.Balance != "" && account.Balance != "0" { + action := &state.GenesisAction{ + Address: account.Address, + Type: int(merkletree.LeafTypeBalance), + Value: account.Balance, } - if account.Balance != "" && account.Balance != "0" { - action := &state.GenesisAction{ - Address: account.Address, - Type: int(merkletree.LeafTypeBalance), - Value: account.Balance, - } - cfg.Genesis.Actions = append(cfg.Genesis.Actions, action) + cfg.Genesis.Actions = append(cfg.Genesis.Actions, action) + } + if account.Nonce != "" && account.Nonce != "0" { + action := &state.GenesisAction{ + Address: account.Address, + Type: int(merkletree.LeafTypeNonce), + Value: account.Nonce, } - if account.Nonce != "" && account.Nonce != "0" { - action := &state.GenesisAction{ - Address: account.Address, - Type: int(merkletree.LeafTypeNonce), - Value: account.Nonce, - } - cfg.Genesis.Actions = append(cfg.Genesis.Actions, action) + cfg.Genesis.Actions = append(cfg.Genesis.Actions, action) + } + if account.Bytecode != "" { + action := &state.GenesisAction{ + Address: account.Address, + Type: int(merkletree.LeafTypeCode), + Bytecode: account.Bytecode, } - if account.Bytecode != "" { + cfg.Genesis.Actions = append(cfg.Genesis.Actions, action) + } + if len(account.Storage) > 0 { + for storageKey, storageValue := range account.Storage { action := &state.GenesisAction{ - Address: account.Address, - Type: int(merkletree.LeafTypeCode), - Bytecode: account.Bytecode, + Address: account.Address, + Type: int(merkletree.LeafTypeStorage), + StoragePosition: storageKey, + Value: storageValue, } cfg.Genesis.Actions = append(cfg.Genesis.Actions, action) } - if len(account.Storage) > 0 { - for storageKey, storageValue := range account.Storage { - action := &state.GenesisAction{ - Address: account.Address, - Type: int(merkletree.LeafTypeStorage), - StoragePosition: storageKey, - Value: storageValue, - } - cfg.Genesis.Actions = append(cfg.Genesis.Actions, action) - } - } } } return cfg, nil } + +type addressTransformer struct{} + +func (a addressTransformer) Transformer(typ reflect.Type) func(dst, src reflect.Value) error { + if typ != reflect.TypeOf(common.Address{}) { + return nil + } + return func(dst, src reflect.Value) error { + if !dst.CanSet() { + return nil + } + hex := src.MethodByName("Hex") + result := hex.Call([]reflect.Value{}) + if result[0].Interface().(string) != "0x0000000000000000000000000000000000000000" { + dst.Set(src) + } + return nil + } +} + +func mergeNetworkConfigs(custom, base NetworkConfig) (NetworkConfig, error) { + actionsBack := append(base.Genesis.Actions, custom.Genesis.Actions...) + + if err := mergo.MergeWithOverwrite(&base, custom, mergo.WithTransformers(addressTransformer{})); err != nil { + return NetworkConfig{}, err + } + + base.Genesis.Actions = actionsBack + + return base, nil +} diff --git a/config/network_test.go b/config/network_test.go index 8610b33aa8..cb68536ce0 100644 --- a/config/network_test.go +++ b/config/network_test.go @@ -25,6 +25,15 @@ func TestLoadCustomNetworkConfig(t *testing.T) { { description: "happy path", inputConfigStr: `{ + "deploymentBlockNumber": 6934972, + "proofOfEfficiencyAddress": "0x2f612dc8fB986E7976AEfc13d8bB0Eb18488a4C9", + "maticTokenAddress": "0xEa2f9aC0cd926C92923355e88Af73Ee83F2D9C67", + "globalExitRootManagerAddress": "0x9730d4ec6684E5567fB70B12d49Bf3f58f5ce4Cc", + + "globalExitRootStoragePosition": 0, + "localExitRootStoragePosition": 1, + "oldStateRootPosition": 0, + "l1ChainID": 5, "genesis": [ { @@ -65,7 +74,17 @@ func TestLoadCustomNetworkConfig(t *testing.T) { "maxCumulativeGasUsed": 300000 }`, expectedConfig: NetworkConfig{ - L2GlobalExitRootManagerAddr: common.HexToAddress("0xae4bb80be56b819606589de61d5ec3b522eeb032"), + GenBlockNumber: 6934972, + PoEAddr: common.HexToAddress("0x2f612dc8fB986E7976AEfc13d8bB0Eb18488a4C9"), + MaticAddr: common.HexToAddress("0xEa2f9aC0cd926C92923355e88Af73Ee83F2D9C67"), + + GlobalExitRootManagerAddr: common.HexToAddress("0x9730d4ec6684E5567fB70B12d49Bf3f58f5ce4Cc"), + L2GlobalExitRootManagerAddr: common.HexToAddress("0xae4bb80be56b819606589de61d5ec3b522eeb032"), + SystemSCAddr: common.Address{}, + GlobalExitRootStoragePosition: 0, + LocalExitRootStoragePosition: 1, + OldStateRootPosition: 0, + L1ChainID: 5, Genesis: state.Genesis{ Actions: []*state.GenesisAction{ { @@ -133,6 +152,15 @@ func TestLoadCustomNetworkConfig(t *testing.T) { { description: "imported from network-config.example.json", inputConfigStr: `{ + "deploymentBlockNumber": 1, + "proofOfEfficiencyAddress": "0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9", + "maticTokenAddress": "0x37AffAf737C3683aB73F6E1B0933b725Ab9796Aa", + "globalExitRootManagerAddress": "0x9730d4ec6684E5567fB70B12d49Bf3f58f5ce4Cc", + "systemSCAddr": "0x0000000000000000000000000000000000000000", + "globalExitRootStoragePosition": 2, + "localExitRootStoragePosition": 2, + "oldStateRootPosition": 0, + "l1ChainID": 1337, "genesis": [ { "address": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", @@ -150,6 +178,16 @@ func TestLoadCustomNetworkConfig(t *testing.T) { "maxCumulativeGasUsed": 123456 }`, expectedConfig: NetworkConfig{ + GenBlockNumber: 1, + PoEAddr: common.HexToAddress("0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9"), + MaticAddr: common.HexToAddress("0x37AffAf737C3683aB73F6E1B0933b725Ab9796Aa"), + + GlobalExitRootManagerAddr: common.HexToAddress("0x9730d4ec6684E5567fB70B12d49Bf3f58f5ce4Cc"), + SystemSCAddr: common.Address{}, + GlobalExitRootStoragePosition: 2, + LocalExitRootStoragePosition: 2, + OldStateRootPosition: 0, + L1ChainID: 1337, Genesis: state.Genesis{ Actions: []*state.GenesisAction{ { @@ -187,7 +225,7 @@ func TestLoadCustomNetworkConfig(t *testing.T) { for _, tc := range tcs { tc := tc t.Run(tc.description, func(t *testing.T) { - file, err := ioutil.TempFile("", "genesisConfig") + file, err := ioutil.TempFile("", "loadCustomNetworkConfig") require.NoError(t, err) defer func() { require.NoError(t, os.Remove(file.Name())) @@ -195,14 +233,138 @@ func TestLoadCustomNetworkConfig(t *testing.T) { require.NoError(t, os.WriteFile(file.Name(), []byte(tc.inputConfigStr), 0600)) flagSet := flag.NewFlagSet("test", flag.ExitOnError) - flagSet.String(FlagGenesisFile, file.Name(), "") + flagSet.String(FlagNetworkCfg, file.Name(), "") ctx := cli.NewContext(nil, flagSet, nil) - actualConfig, err := loadGenesisFileConfig(ctx) + actualConfig, err := loadCustomNetworkConfig(ctx) require.NoError(t, testutils.CheckError(err, tc.expectedError, tc.expectedErrorMsg)) + require.Equal(t, tc.expectedConfig.GenBlockNumber, actualConfig.GenBlockNumber) + require.Equal(t, tc.expectedConfig.PoEAddr, actualConfig.PoEAddr) + require.Equal(t, tc.expectedConfig.MaticAddr, actualConfig.MaticAddr) + require.Equal(t, tc.expectedConfig.GlobalExitRootManagerAddr, actualConfig.GlobalExitRootManagerAddr) require.Equal(t, tc.expectedConfig.L2GlobalExitRootManagerAddr, actualConfig.L2GlobalExitRootManagerAddr) + require.Equal(t, tc.expectedConfig.SystemSCAddr, actualConfig.SystemSCAddr) + require.Equal(t, tc.expectedConfig.GlobalExitRootStoragePosition, actualConfig.GlobalExitRootStoragePosition) + require.Equal(t, tc.expectedConfig.LocalExitRootStoragePosition, actualConfig.LocalExitRootStoragePosition) + require.Equal(t, tc.expectedConfig.OldStateRootPosition, actualConfig.OldStateRootPosition) + require.Equal(t, tc.expectedConfig.L1ChainID, actualConfig.L1ChainID) + require.Equal(t, tc.expectedConfig.Genesis.Actions, actualConfig.Genesis.Actions) }) } } + +func TestMergeNetworkConfig(t *testing.T) { + tcs := []struct { + description string + inputCustomConfig NetworkConfig + inputBaseConfig NetworkConfig + expectedOutputConfig NetworkConfig + }{ + { + description: "empty", + inputCustomConfig: NetworkConfig{}, + inputBaseConfig: NetworkConfig{}, + expectedOutputConfig: NetworkConfig{}, + }, + { + description: "matching keys", + inputCustomConfig: NetworkConfig{ + GenBlockNumber: 300, + PoEAddr: common.HexToAddress("0xc949254d682d8c9ad5682521675b8f43b102aec4"), + MaticAddr: common.HexToAddress("0x1D217d81831009a5fE44C9a1Ee2480e48830CbD4"), + }, + inputBaseConfig: NetworkConfig{ + GenBlockNumber: 100, + PoEAddr: common.HexToAddress("0xb1Fe4a65D3392df68F96daC8eB4df56B2411afBf"), + MaticAddr: common.HexToAddress("0x6bad17aC92f0E9313E8c7c3B80E902f1c4D5255F"), + }, + expectedOutputConfig: NetworkConfig{ + GenBlockNumber: 300, + PoEAddr: common.HexToAddress("0xc949254d682d8c9ad5682521675b8f43b102aec4"), + MaticAddr: common.HexToAddress("0x1D217d81831009a5fE44C9a1Ee2480e48830CbD4"), + }, + }, + { + description: "non-matching keys", + inputCustomConfig: NetworkConfig{ + GenBlockNumber: 300, + PoEAddr: common.HexToAddress("0xc949254d682d8c9ad5682521675b8f43b102aec4"), + MaticAddr: common.HexToAddress("0x1D217d81831009a5fE44C9a1Ee2480e48830CbD4"), + }, + inputBaseConfig: NetworkConfig{ + PoEAddr: common.HexToAddress("0xb1Fe4a65D3392df68F96daC8eB4df56B2411afBf"), + L1ChainID: 5, + }, + expectedOutputConfig: NetworkConfig{ + L1ChainID: 5, + GenBlockNumber: 300, + PoEAddr: common.HexToAddress("0xc949254d682d8c9ad5682521675b8f43b102aec4"), + MaticAddr: common.HexToAddress("0x1D217d81831009a5fE44C9a1Ee2480e48830CbD4"), + }, + }, + { + description: "nested keys", + inputCustomConfig: NetworkConfig{ + GenBlockNumber: 300, + Genesis: state.Genesis{ + Actions: []*state.GenesisAction{ + { + Address: "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", + Type: int(merkletree.LeafTypeBalance), + Value: "1000000000000000000000", + }, + { + Address: "0x70997970C51812dc3A010C7d01b50e0d17dc79C8", + Type: int(merkletree.LeafTypeBalance), + Value: "2000000000000000000000", + }, + }, + }, + }, + inputBaseConfig: NetworkConfig{ + GenBlockNumber: 10, + }, + expectedOutputConfig: NetworkConfig{ + GenBlockNumber: 300, + Genesis: state.Genesis{ + Actions: []*state.GenesisAction{ + { + Address: "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", + Type: int(merkletree.LeafTypeBalance), + Value: "1000000000000000000000", + }, + { + Address: "0x70997970C51812dc3A010C7d01b50e0d17dc79C8", + Type: int(merkletree.LeafTypeBalance), + Value: "2000000000000000000000", + }, + }, + }, + }, + }, + { + description: "zero address doesn't overwrite destination", + inputCustomConfig: NetworkConfig{ + PoEAddr: common.Address{}, + }, + inputBaseConfig: NetworkConfig{ + PoEAddr: common.HexToAddress("0xc949254d682d8c9ad5682521675b8f43b102aec4"), + }, + expectedOutputConfig: NetworkConfig{ + PoEAddr: common.HexToAddress("0xc949254d682d8c9ad5682521675b8f43b102aec4"), + }, + }, + } + + for _, tc := range tcs { + tc := tc + t.Run(tc.description, func(t *testing.T) { + actualOutputConfig, err := mergeNetworkConfigs(tc.inputCustomConfig, tc.inputBaseConfig) + require.NoError(t, err) + + require.Equal(t, tc.expectedOutputConfig, actualOutputConfig) + }) + } +} diff --git a/db/migrations/state/0002.sql b/db/migrations/state/0002.sql deleted file mode 100644 index 58392d466d..0000000000 --- a/db/migrations/state/0002.sql +++ /dev/null @@ -1,11 +0,0 @@ --- +migrate Up -ALTER TABLE state.proof ADD COLUMN proof_id VARCHAR; -ALTER TABLE state.proof ADD COLUMN input_prover jsonb; -ALTER TABLE state.proof ADD COLUMN prover VARCHAR; - --- +migrate Down -ALTER TABLE state.proof DROP COLUMN prover; -ALTER TABLE state.proof DROP COLUMN input_prover; -ALTER TABLE state.proof DROP COLUMN proof_id; - - diff --git a/docker-compose.yml b/docker-compose.yml index 08aba31a01..e62dd94e7f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -13,11 +13,10 @@ services: volumes: - ./test/test.keystore:/pk/keystore - ./${CONFIG_MODE}/config/config.${CONFIG_MODE:-local}.toml:/app/config.toml - - ./config/genesis.local.json:/app/genesis.json command: - "/bin/sh" - "-c" - - "/app/zkevm-node run --genesis /app/genesis.json --cfg /app/config.toml --components sequencer" + - "/app/zkevm-node run --network local --cfg /app/config.toml --components sequencer" zkevm-json-rpc: container_name: zkevm-json-rpc @@ -33,11 +32,10 @@ services: volumes: - ./test/test.keystore:/pk/keystore - ./${CONFIG_MODE}/config/config.${CONFIG_MODE:-local}.toml:/app/config.toml - - ./config/genesis.local.json:/app/genesis.json command: - "/bin/sh" - "-c" - - "/app/zkevm-node run --genesis /app/genesis.json --cfg /app/config.toml --components rpc" + - "/app/zkevm-node run --network local --cfg /app/config.toml --components rpc" zkevm-non-sequencer-json-rpc: container_name: zkevm-non-sequencer-json-rpc @@ -53,11 +51,10 @@ services: volumes: - ./test/test.keystore:/pk/keystore - ./${CONFIG_MODE}/config/config.${CONFIG_MODE:-local}.toml:/app/config.toml - - ./${CONFIG_MODE}/config/genesis.${CONFIG_MODE:-local}.json:/app/genesis.json command: - "/bin/sh" - "-c" - - "/app/zkevm-node run --genesis /app/genesis.json --cfg /app/config.toml --components rpc" + - "/app/zkevm-node run --network local --cfg /app/config.toml --components rpc" zkevm-aggregator: container_name: zkevm-aggregator @@ -68,11 +65,10 @@ services: volumes: - ./test/test.keystore:/pk/keystore - ./${CONFIG_MODE}/config/config.${CONFIG_MODE:-local}.toml:/app/config.toml - - ./config/genesis.local.json:/app/genesis.json command: - "/bin/sh" - "-c" - - "/app/zkevm-node run --genesis /app/genesis.json --cfg /app/config.toml --components aggregator" + - "/app/zkevm-node run --network local --cfg /app/config.toml --components aggregator" zkevm-sync: container_name: zkevm-sync @@ -83,11 +79,10 @@ services: volumes: - ./test/test.keystore:/pk/keystore - ./${CONFIG_MODE}/config/config.${CONFIG_MODE:-local}.toml:/app/config.toml - - ./config/genesis.local.json:/app/genesis.json command: - "/bin/sh" - "-c" - - "/app/zkevm-node run --genesis /app/genesis.json --cfg /app/config.toml --components synchronizer" + - "/app/zkevm-node run --network local --cfg /app/config.toml --components synchronizer" zkevm-broadcast: container_name: zkevm-broadcast @@ -100,11 +95,10 @@ services: volumes: - ./config/config.local.toml:/app/config.toml - ./test/test.keystore:/pk/keystore - - ./config/genesis.local.json:/app/genesis.json command: - "/bin/sh" - "-c" - - "/app/zkevm-node run --genesis /app/genesis.json --cfg /app/config.toml --components broadcast-trusted-state" + - "/app/zkevm-node run --network local --cfg /app/config.toml --components broadcast-trusted-state" zkevm-state-db: container_name: zkevm-state-db @@ -220,11 +214,10 @@ services: volumes: - ./test/test.keystore:/pk/keystore - ./config/config.local.toml:/app/config.toml - - ./config/genesis.local.json:/app/genesis.json command: - "/bin/sh" - "-c" - - "/app/zkevm-node run --genesis /app/genesis.json --cfg /app/config.toml --components rpc --http.api eth,net,debug,zkevm,txpool,web3" + - "/app/zkevm-node run --network local --cfg /app/config.toml --components rpc --http.api eth,net,debug,zkevm,txpool,web3" zkevm-explorer-l2-db: container_name: zkevm-explorer-l2-db @@ -280,7 +273,7 @@ services: command: - "/bin/sh" - "-c" - - "/app/zkevm-node approve --am 10000000000000000 -y --cfg /app/config.toml" + - "/app/zkevm-node approve --am 10000000000000000 -y --network local --cfg /app/config.toml" zkevm-permissionless-db: container_name: zkevm-permissionless-db @@ -324,8 +317,7 @@ services: - ./test/test.keystore:/pk/keystore - ./config/config.local.toml:/app/config.toml - ./config/single_db_server.sql:/docker-entrypoint-initdb.d/init.sql - - ./config/genesis.local.json:/app/genesis.json command: - "/bin/sh" - "-c" - - "/app/zkevm-node run --genesis /app/genesis.json --cfg /app/config.toml --components \"rpc,synchronizer\"" + - "/app/zkevm-node run --network local --cfg /app/config.toml --components \"rpc,synchronizer\"" diff --git a/etherman/config.go b/etherman/config.go index 84676b0dcf..fec6a62e59 100644 --- a/etherman/config.go +++ b/etherman/config.go @@ -1,15 +1,8 @@ package etherman -import "github.com/ethereum/go-ethereum/common" - // Config represents the configuration of the etherman type Config struct { - URL string `mapstructure:"URL"` - L1ChainID uint64 `mapstructure:"L1ChainID"` - - PoEAddr common.Address `mapstructure:"PoEAddr"` - MaticAddr common.Address `mapstructure:"MaticAddr"` - GlobalExitRootManagerAddr common.Address `mapstructure:"GlobalExitRootManagerAddr"` + URL string `mapstructure:"URL"` PrivateKeyPath string `mapstructure:"PrivateKeyPath"` PrivateKeyPassword string `mapstructure:"PrivateKeyPassword"` diff --git a/etherman/etherman.go b/etherman/etherman.go index d59452b2c9..2a2e82f851 100644 --- a/etherman/etherman.go +++ b/etherman/etherman.go @@ -83,7 +83,7 @@ type Client struct { } // NewClient creates a new etherman. -func NewClient(cfg Config, auth *bind.TransactOpts) (*Client, error) { +func NewClient(cfg Config, auth *bind.TransactOpts, PoEAddr common.Address, maticAddr common.Address, globalExitRootManAddr common.Address) (*Client, error) { // Connect to ethereum node ethClient, err := ethclient.Dial(cfg.URL) if err != nil { @@ -91,20 +91,20 @@ func NewClient(cfg Config, auth *bind.TransactOpts) (*Client, error) { return nil, err } // Create smc clients - poe, err := proofofefficiency.NewProofofefficiency(cfg.PoEAddr, ethClient) + poe, err := proofofefficiency.NewProofofefficiency(PoEAddr, ethClient) if err != nil { return nil, err } - globalExitRoot, err := globalexitrootmanager.NewGlobalexitrootmanager(cfg.GlobalExitRootManagerAddr, ethClient) + globalExitRoot, err := globalexitrootmanager.NewGlobalexitrootmanager(globalExitRootManAddr, ethClient) if err != nil { return nil, err } - matic, err := matic.NewMatic(cfg.MaticAddr, ethClient) + matic, err := matic.NewMatic(maticAddr, ethClient) if err != nil { return nil, err } var scAddresses []common.Address - scAddresses = append(scAddresses, cfg.PoEAddr, cfg.GlobalExitRootManagerAddr) + scAddresses = append(scAddresses, PoEAddr, globalExitRootManAddr) return &Client{EtherClient: ethClient, PoE: poe, Matic: matic, GlobalExitRootManager: globalExitRoot, SCAddresses: scAddresses, auth: auth}, nil } diff --git a/ethtxmanager/config.go b/ethtxmanager/config.go index 421323527e..cb68c0d159 100644 --- a/ethtxmanager/config.go +++ b/ethtxmanager/config.go @@ -15,8 +15,6 @@ type Config struct { FrequencyForResendingFailedVerifyBatch types.Duration `mapstructure:"FrequencyForResendingFailedVerifyBatch"` // WaitTxToBeMined time to wait after transaction was sent to the ethereum WaitTxToBeMined types.Duration `mapstructure:"WaitTxToBeMined"` - // WaitTxToBeSynced time to wait after transaction was sent to the ethereum to get into the state - WaitTxToBeSynced types.Duration `mapstructure:"WaitTxToBeSynced"` // PercentageToIncreaseGasPrice when tx is failed by timeout increase gas price by this percentage PercentageToIncreaseGasPrice uint64 `mapstructure:"PercentageToIncreaseGasPrice"` // PercentageToIncreaseGasLimit when tx is failed by timeout increase gas price by this percentage diff --git a/ethtxmanager/ethtxmanager.go b/ethtxmanager/ethtxmanager.go index 962c75a857..258d6bfd44 100644 --- a/ethtxmanager/ethtxmanager.go +++ b/ethtxmanager/ethtxmanager.go @@ -5,7 +5,6 @@ package ethtxmanager import ( - "context" "math/big" "strings" "time" @@ -22,26 +21,23 @@ const oneHundred = 100 type Client struct { cfg Config ethMan etherman - state state } // New creates new eth tx manager -func New(cfg Config, ethMan etherman, state state) *Client { +func New(cfg Config, ethMan etherman) *Client { return &Client{ cfg: cfg, ethMan: ethMan, - state: state, } } // SequenceBatches send sequences to the channel -func (c *Client) SequenceBatches(sequences []ethmanTypes.Sequence) error { +func (c *Client) SequenceBatches(sequences []ethmanTypes.Sequence) { var ( attempts uint32 gas uint64 gasPrice *big.Int nonce = big.NewInt(0) - ctx = context.Background() ) log.Info("sending sequence to L1") for attempts < c.cfg.MaxSendBatchTxRetries { @@ -87,20 +83,18 @@ func (c *Client) SequenceBatches(sequences []ethmanTypes.Sequence) error { log.Fatalf("tx %s failed, err: %w", tx.Hash(), err) } else { log.Infof("sequence sent to L1 successfully. Tx hash: %s", tx.Hash()) - return c.state.WaitSequencingTxToBeSynced(ctx, tx, c.cfg.WaitTxToBeSynced.Duration) + return } } - return nil } // VerifyBatch send VerifyBatch request to ethereum -func (c *Client) VerifyBatch(batchNum uint64, resGetProof *pb.GetProofResponse) error { +func (c *Client) VerifyBatch(batchNum uint64, resGetProof *pb.GetProofResponse) { var ( attempts uint32 gas uint64 gasPrice *big.Int nonce = big.NewInt(0) - ctx = context.Background() ) log.Infof("sending batch %d verification to L1", batchNum) for attempts < c.cfg.MaxVerifyBatchTxRetries { @@ -127,7 +121,7 @@ func (c *Client) VerifyBatch(batchNum uint64, resGetProof *pb.GetProofResponse) } if err != nil { log.Errorf("failed to send batch verification, maximum attempts exceeded, gasLimit: %d, err: %w", 0, err) - return err + return } // Wait for tx to be mined log.Infof("waiting for tx to be mined. Tx hash: %s, nonce: %d, gasPrice: %d", tx.Hash(), tx.Nonce(), tx.GasPrice().Int64()) @@ -144,13 +138,12 @@ func (c *Client) VerifyBatch(batchNum uint64, resGetProof *pb.GetProofResponse) continue } log.Errorf("tx %s failed, err: %w", tx.Hash(), err) - return err + return } else { log.Infof("batch verification sent to L1 successfully. Tx hash: %s", tx.Hash()) - return c.state.WaitVerifiedBatchToBeSynced(ctx, batchNum, c.cfg.WaitTxToBeSynced.Duration) + return } } - return nil } func increaseGasPrice(currentGasPrice *big.Int, percentageIncrease uint64) *big.Int { diff --git a/ethtxmanager/interfaces.go b/ethtxmanager/interfaces.go index 9d9008019c..a6b5ced1bf 100644 --- a/ethtxmanager/interfaces.go +++ b/ethtxmanager/interfaces.go @@ -20,8 +20,3 @@ type etherman interface { GetTxReceipt(ctx context.Context, txHash common.Hash) (*types.Receipt, error) WaitTxToBeMined(hash common.Hash, timeout time.Duration) error } - -type state interface { - WaitSequencingTxToBeSynced(parentCtx context.Context, tx *types.Transaction, timeout time.Duration) error - WaitVerifiedBatchToBeSynced(parentCtx context.Context, batchNumber uint64, timeout time.Duration) error -} diff --git a/go.mod b/go.mod index 6b1ec4559e..fb926d65dc 100644 --- a/go.mod +++ b/go.mod @@ -11,19 +11,20 @@ require ( github.com/gobuffalo/packr/v2 v2.8.3 github.com/hermeznetwork/tracerr v0.3.2 github.com/iden3/go-iden3-crypto v0.0.14-0.20220413123345-edc36bfa5247 + github.com/imdario/mergo v0.3.13 github.com/jackc/pgconn v1.13.0 - github.com/jackc/pgx/v4 v4.17.2 + github.com/jackc/pgx/v4 v4.17.1 github.com/mitchellh/mapstructure v1.5.0 github.com/rubenv/sql-migrate v0.0.0-20211023115951-9f02b1e13857 github.com/spf13/afero v1.9.2 github.com/spf13/viper v1.13.0 github.com/stretchr/testify v1.8.0 github.com/umbracle/ethgo v0.1.3 - github.com/urfave/cli/v2 v2.20.2 + github.com/urfave/cli/v2 v2.16.3 go.uber.org/zap v1.23.0 golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa golang.org/x/sync v0.0.0-20220513210516-0976fa681c29 - google.golang.org/grpc v1.50.1 + google.golang.org/grpc v1.49.0 google.golang.org/protobuf v1.28.1 gopkg.in/yaml.v2 v2.4.0 gopkg.in/yaml.v3 v3.0.1 @@ -117,7 +118,6 @@ require ( require ( github.com/cespare/xxhash/v2 v2.1.2 // indirect github.com/google/gofuzz v1.2.0 // indirect - github.com/imdario/mergo v0.3.13 // indirect github.com/lib/pq v1.10.7 // indirect github.com/umbracle/fastrlp v0.0.0-20220527094140-59d5dd30e722 // indirect github.com/valyala/fastjson v1.4.1 // indirect diff --git a/go.sum b/go.sum index 7708d5e744..5bba71e85b 100644 --- a/go.sum +++ b/go.sum @@ -551,8 +551,8 @@ github.com/jackc/pgx/v4 v4.0.0-20190420224344-cc3461e65d96/go.mod h1:mdxmSJJuR08 github.com/jackc/pgx/v4 v4.0.0-20190421002000-1b8f0016e912/go.mod h1:no/Y67Jkk/9WuGR0JG/JseM9irFbnEPbuWV2EELPNuM= github.com/jackc/pgx/v4 v4.0.0-pre1.0.20190824185557-6972a5742186/go.mod h1:X+GQnOEnf1dqHGpw7JmHqHc1NxDoalibchSk9/RWuDc= github.com/jackc/pgx/v4 v4.12.1-0.20210724153913-640aa07df17c/go.mod h1:1QD0+tgSXP7iUjYm9C1NxKhny7lq6ee99u/z+IHFcgs= -github.com/jackc/pgx/v4 v4.17.2 h1:0Ut0rpeKwvIVbMQ1KbMBU4h6wxehBI535LK6Flheh8E= -github.com/jackc/pgx/v4 v4.17.2/go.mod h1:lcxIZN44yMIrWI78a5CpucdD14hX0SBDbNRvjDBItsw= +github.com/jackc/pgx/v4 v4.17.1 h1:tASdE79tX9LOQu3MMvioWT6YaZkf58ZhmLHhV4sv5WM= +github.com/jackc/pgx/v4 v4.17.1/go.mod h1:lcxIZN44yMIrWI78a5CpucdD14hX0SBDbNRvjDBItsw= github.com/jackc/puddle v0.0.0-20190413234325-e4ced69a3a2b/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= github.com/jackc/puddle v0.0.0-20190608224051-11cab39313c9/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= github.com/jackc/puddle v1.1.3/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= @@ -913,8 +913,8 @@ github.com/umbracle/fastrlp v0.0.0-20220527094140-59d5dd30e722 h1:10Nbw6cACsnQm7 github.com/umbracle/fastrlp v0.0.0-20220527094140-59d5dd30e722/go.mod h1:c8J0h9aULj2i3umrfyestM6jCq0LK0U6ly6bWy96nd4= github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI= github.com/urfave/cli/v2 v2.10.2/go.mod h1:f8iq5LtQ/bLxafbdBSLPPNsgaW0l/2fYYEHhAyPlwvo= -github.com/urfave/cli/v2 v2.20.2 h1:dKA0LUjznZpwmmbrc0pOgcLTEilnHeM8Av9Yng77gHM= -github.com/urfave/cli/v2 v2.20.2/go.mod h1:1CNUng3PtjQMtRzJO4FMXBQvkGtuYRxxiR9xMa7jMwI= +github.com/urfave/cli/v2 v2.16.3 h1:gHoFIwpPjoyIMbJp/VFd+/vuD0dAgFK4B6DpEMFJfQk= +github.com/urfave/cli/v2 v2.16.3/go.mod h1:1CNUng3PtjQMtRzJO4FMXBQvkGtuYRxxiR9xMa7jMwI= github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= github.com/valyala/fasthttp v1.4.0/go.mod h1:4vX61m6KN+xDduDNwXrhIAVZaZaZiQ1luJk8LWSxF3s= github.com/valyala/fastjson v1.4.1 h1:hrltpHpIpkaxll8QltMU8c3QZ5+qIiCL8yKqPFJI/yE= @@ -1515,8 +1515,8 @@ google.golang.org/grpc v1.44.0/go.mod h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ5 google.golang.org/grpc v1.45.0/go.mod h1:lN7owxKUQEqMfSyQikvvk5tf/6zMPsrK+ONuO11+0rQ= google.golang.org/grpc v1.46.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= google.golang.org/grpc v1.46.2/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= -google.golang.org/grpc v1.50.1 h1:DS/BukOZWp8s6p4Dt/tOaJaTQyPyOoCcrjroHuCeLzY= -google.golang.org/grpc v1.50.1/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= +google.golang.org/grpc v1.49.0 h1:WTLtQzmQori5FUH25Pq4WT22oCsv8USpQ+F6rqtsmxw= +google.golang.org/grpc v1.49.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= diff --git a/pool/pgpoolstorage/pgpoolstorage.go b/pool/pgpoolstorage/pgpoolstorage.go index 7095eded16..5ca888d70a 100644 --- a/pool/pgpoolstorage/pgpoolstorage.go +++ b/pool/pgpoolstorage/pgpoolstorage.go @@ -181,8 +181,7 @@ func (p *PostgresPoolStorage) GetTxs(ctx context.Context, filterStatus pool.TxSt used_binaries, used_steps, received_at, - nonce, - failed_counter + nonce FROM pool.txs p1 WHERE @@ -209,8 +208,7 @@ func (p *PostgresPoolStorage) GetTxs(ctx context.Context, filterStatus pool.TxSt used_binaries, used_steps, received_at, - nonce, - failed_counter + nonce FROM pool.txs p1 WHERE @@ -232,7 +230,7 @@ func (p *PostgresPoolStorage) GetTxs(ctx context.Context, filterStatus pool.TxSt usedKeccakHashes, usedPoseidonHashes, usedPoseidonPaddings, usedMemAligns, usedArithmetics, usedBinaries, usedSteps int32 - nonce, failedCounter uint64 + nonce uint64 ) args := []interface{}{filterStatus, minGasPrice, isClaims, limit} @@ -258,9 +256,7 @@ func (p *PostgresPoolStorage) GetTxs(ctx context.Context, filterStatus pool.TxSt &usedBinaries, &usedSteps, &receivedAt, - &nonce, - &failedCounter, - ) + &nonce) if err != nil { return nil, err @@ -286,7 +282,6 @@ func (p *PostgresPoolStorage) GetTxs(ctx context.Context, filterStatus pool.TxSt UsedBinaries: usedBinaries, UsedSteps: usedSteps, } - tx.FailedCounter = failedCounter txs = append(txs, tx) } diff --git a/pool/pool.go b/pool/pool.go index 7eac3b8407..38a398b46f 100644 --- a/pool/pool.go +++ b/pool/pool.go @@ -27,7 +27,7 @@ const ( txMaxSize = 4 * txSlotSize // 128KB // bridgeClaimMethodSignature for tracking bridgeClaimMethodSignature method - bridgeClaimMethodSignature = "0x5d5d326f" + bridgeClaimMethodSignature = "0x25308c93" ) var ( diff --git a/pool/transaction.go b/pool/transaction.go index a987e6f8ff..28a59c780d 100644 --- a/pool/transaction.go +++ b/pool/transaction.go @@ -33,8 +33,7 @@ type Transaction struct { Status TxStatus IsClaims bool ZkCounters - FailedCounter uint64 - ReceivedAt time.Time + ReceivedAt time.Time } // ZkCounters counters for the tx diff --git a/sequencer/batchbuilder.go b/sequencer/batchbuilder.go index 73dc4a591b..78cd6f2aa3 100644 --- a/sequencer/batchbuilder.go +++ b/sequencer/batchbuilder.go @@ -459,7 +459,6 @@ func (s *Sequencer) closeBatch(ctx context.Context, lastBatchNumber uint64, dbTx BatchNumber: lastBatchNumber, StateRoot: s.sequenceInProgress.StateRoot, LocalExitRoot: s.sequenceInProgress.LocalExitRoot, - Txs: s.sequenceInProgress.Txs, } err := s.state.CloseBatch(ctx, receipt, dbTx) if err != nil { @@ -514,13 +513,6 @@ func (s *Sequencer) appendPendingTxs(ctx context.Context, isClaims bool, minGasP return 0 } for i := 0; i < len(pendTxs); i++ { - if pendTxs[i].FailedCounter > s.cfg.MaxAllowedFailedCounter { - hash := pendTxs[i].Transaction.Hash().String() - log.Warnf("mark tx with hash %s as invalid, failed counter %d exceeded max %d from config", - hash, pendTxs[i].FailedCounter, s.cfg.MaxAllowedFailedCounter) - s.updateTxsStatus(ctx, ticker, []string{hash}, pool.TxStatusInvalid) - continue - } s.sequenceInProgress.Txs = append(s.sequenceInProgress.Txs, pendTxs[i].Transaction) } diff --git a/sequencer/config.go b/sequencer/config.go index d152119891..537c31ed50 100644 --- a/sequencer/config.go +++ b/sequencer/config.go @@ -62,9 +62,6 @@ type Config struct { // Maximum size, in gas size, a sequence can reach MaxSequenceSize MaxSequenceSize `mapstructure:"MaxSequenceSize"` - - // Maximum allowed failed counter for the tx before it becomes invalid - MaxAllowedFailedCounter uint64 `mapstructure:"MaxAllowedFailedCounter"` } // MaxSequenceSize is a wrapper type that parses token amount to big int diff --git a/sequencer/interfaces.go b/sequencer/interfaces.go index 7221006b8e..b6653b4173 100644 --- a/sequencer/interfaces.go +++ b/sequencer/interfaces.go @@ -69,7 +69,7 @@ type stateInterface interface { } type txManager interface { - SequenceBatches(sequences []ethmanTypes.Sequence) error + SequenceBatches(sequences []ethmanTypes.Sequence) } // priceGetter is for getting eth/matic price, used for the tx profitability checker diff --git a/sequencer/mocks/mock_txmanager.go b/sequencer/mocks/mock_txmanager.go index a5573e5b09..3befc52ed5 100644 --- a/sequencer/mocks/mock_txmanager.go +++ b/sequencer/mocks/mock_txmanager.go @@ -14,17 +14,8 @@ type TxmanagerMock struct { } // SequenceBatches provides a mock function with given fields: sequences -func (_m *TxmanagerMock) SequenceBatches(sequences []types.Sequence) error { - ret := _m.Called(sequences) - - var r0 error - if rf, ok := ret.Get(0).(func([]types.Sequence) error); ok { - r0 = rf(sequences) - } else { - r0 = ret.Error(0) - } - - return r0 +func (_m *TxmanagerMock) SequenceBatches(sequences []types.Sequence) { + _m.Called(sequences) } type mockConstructorTestingTNewTxmanagerMock interface { diff --git a/sequencer/sequencer.go b/sequencer/sequencer.go index a21bfeb7f3..8622ed02d7 100644 --- a/sequencer/sequencer.go +++ b/sequencer/sequencer.go @@ -117,19 +117,15 @@ func (s *Sequencer) trackOldTxs(ctx context.Context) { ticker := time.NewTicker(s.cfg.FrequencyToCheckTxsForDelete.Duration) for { waitTick(ctx, ticker) - log.Infof("trying to get txs to delete from the pool...") txHashes, err := s.state.GetTxsOlderThanNL1Blocks(ctx, s.cfg.BlocksAmountForTxsToBeDeleted, nil) if err != nil { log.Errorf("failed to get txs hashes to delete, err: %v", err) continue } - log.Infof("will try to delete %d redundant txs", len(txHashes)) err = s.pool.DeleteTxsByHashes(ctx, txHashes) if err != nil { log.Errorf("failed to delete txs from the pool, err: %v", err) - continue } - log.Infof("deleted %d selected txs from the pool", len(txHashes)) } } diff --git a/sequencer/sequencer_test.go b/sequencer/sequencer_test.go index 97bd4ee2cf..ca51c696e9 100644 --- a/sequencer/sequencer_test.go +++ b/sequencer/sequencer_test.go @@ -121,12 +121,8 @@ func TestSequenceTooBig(t *testing.T) { require.NoError(t, err) // eth_man, _, _, _, err := ethman.NewSimulatedEtherman(ethman.Config{}, auth) eth_man, err := ethman.NewClient(ethman.Config{ - URL: CONFIG_ETH_URL, - L1ChainID: CONFIG_CHAIN_ID, - PoEAddr: CONFIG_ADDRESSES[CONFIG_NAME_POE], - MaticAddr: CONFIG_ADDRESSES[CONFIG_NAME_MATIC], - GlobalExitRootManagerAddr: CONFIG_ADDRESSES[CONFIG_NAME_GER], - }, auth) + URL: CONFIG_ETH_URL, + }, auth, CONFIG_ADDRESSES[CONFIG_NAME_POE], CONFIG_ADDRESSES[CONFIG_NAME_MATIC], CONFIG_ADDRESSES[CONFIG_NAME_GER]) require.NoError(t, err) @@ -173,7 +169,7 @@ func TestSequenceTooBig(t *testing.T) { state := st.NewState(stateCfg, stateDb, executorClient, stateTree) pool := pool.NewPool(poolDb, state, CONFIG_ADDRESSES[CONFIG_NAME_GER], big.NewInt(CONFIG_CHAIN_ID).Uint64()) - ethtxmanager := ethtxmanager.New(ethtxmanager.Config{}, eth_man, state) + ethtxmanager := ethtxmanager.New(ethtxmanager.Config{}, eth_man) gpe := gasprice.NewDefaultEstimator(gasprice.Config{ Type: gasprice.DefaultType, DefaultGasPriceWei: 1000000000, diff --git a/sequencer/sequencesender.go b/sequencer/sequencesender.go index 0e961b4e59..7a274ab9c7 100644 --- a/sequencer/sequencesender.go +++ b/sequencer/sequencesender.go @@ -47,8 +47,7 @@ func (s *Sequencer) tryToSendSequence(ctx context.Context, ticker *time.Ticker) "sending sequences to L1. From batch %d to batch %d", lastVirtualBatchNum+1, lastVirtualBatchNum+uint64(len(sequences)), ) - err = s.txManager.SequenceBatches(sequences) - log.Error(err) + s.txManager.SequenceBatches(sequences) } // getSequencesToSend generates an array of sequences to be send to L1. diff --git a/state/batch.go b/state/batch.go index 14c479592e..b988fa73bc 100644 --- a/state/batch.go +++ b/state/batch.go @@ -33,7 +33,6 @@ type ProcessingReceipt struct { BatchNumber uint64 StateRoot common.Hash LocalExitRoot common.Hash - Txs []types.Transaction } // VerifiedBatch represents a VerifiedBatch diff --git a/state/converters.go b/state/converters.go index 7f74d38c37..6dd17e3d8a 100644 --- a/state/converters.go +++ b/state/converters.go @@ -51,10 +51,6 @@ func isProcessed(err pb.Error) bool { return err != pb.Error_ERROR_INTRINSIC_INVALID_TX && err != pb.Error_ERROR_OUT_OF_COUNTERS } -func isOOC(err pb.Error) bool { - return err == pb.Error_ERROR_OUT_OF_COUNTERS -} - func convertToProcessTransactionResponse(txs []types.Transaction, responses []*pb.ProcessTransactionResponse) ([]*ProcessTransactionResponse, error) { results := make([]*ProcessTransactionResponse, 0, len(responses)) for i, response := range responses { diff --git a/state/pgstatestorage.go b/state/pgstatestorage.go index f22f21d2c6..11c65f4bb9 100644 --- a/state/pgstatestorage.go +++ b/state/pgstatestorage.go @@ -9,6 +9,7 @@ import ( "time" "github.com/0xPolygonHermez/zkevm-node/hex" + "github.com/0xPolygonHermez/zkevm-node/proverclient/pb" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/jackc/pgx/v4" @@ -41,7 +42,7 @@ const ( getBlockTimeByNumSQL = "SELECT received_at FROM state.block WHERE block_num = $1" getForcedBatchByBatchNumSQL = "SELECT forced_batch_num, global_exit_root, timestamp, raw_txs_data, coinbase, batch_num, block_num from state.forced_batch WHERE batch_num = $1" getProcessingContextSQL = "SELECT batch_num, global_exit_root, timestamp, coinbase from state.batch WHERE batch_num = $1" - getEncodedTransactionsByBatchNumberSQL = "SELECT encoded FROM state.transaction t INNER JOIN state.l2block b ON t.l2_block_num = b.block_num WHERE b.batch_num = $1 ORDER BY l2_block_num ASC" + getEncodedTransactionsByBatchNumberSQL = "SELECT encoded FROM state.transaction t INNER JOIN state.l2block b ON t.l2_block_num = b.block_num WHERE b.batch_num = $1" getTransactionHashesByBatchNumberSQL = "SELECT hash FROM state.transaction t INNER JOIN state.l2block b ON t.l2_block_num = b.block_num WHERE b.batch_num = $1 ORDER BY l2_block_num ASC" getLastBatchSeenSQL = "SELECT last_batch_num_seen FROM state.sync_info LIMIT 1" updateLastBatchSeenSQL = "UPDATE state.sync_info SET last_batch_num_seen = $1" @@ -82,7 +83,7 @@ const ( ON consolidated_blocks.batch_num = sy.last_batch_num_consolidated; ` addTransactionSQL = "INSERT INTO state.transaction (hash, encoded, decoded, l2_block_num) VALUES($1, $2, $3, $4)" - getBatchNumByBlockNum = "SELECT batch_num FROM state.virtual_batch WHERE block_num <= $1 ORDER BY batch_num DESC LIMIT 1" + getBatchNumByBlockNum = "SELECT batch_num FROM state.virtual_batch WHERE block_num = $1 ORDER BY batch_num ASC LIMIT 1" getTxsHashesBeforeBatchNum = "SELECT hash FROM state.transaction JOIN state.l2block ON state.transaction.l2_block_num = state.l2block.block_num AND state.l2block.batch_num <= $1" isL2BlockVirtualized = "SELECT l2b.block_num FROM state.l2block l2b INNER JOIN state.virtual_batch vb ON vb.batch_num = l2b.batch_num WHERE l2b.block_num = $1" isL2BlockConsolidated = "SELECT l2b.block_num FROM state.l2block l2b INNER JOIN state.verified_batch vb ON vb.batch_num = l2b.batch_num WHERE l2b.block_num = $1" @@ -159,6 +160,7 @@ func (p *PostgresStorage) GetTxsOlderThanNL1Blocks(ctx context.Context, nL1Block } else if err != nil { return nil, err } + rows, err := e.Query(ctx, getTxsHashesBeforeBatchNum, batchNum) if errors.Is(err, pgx.ErrNoRows) { return nil, ErrNotFound @@ -637,18 +639,6 @@ func (p *PostgresStorage) IsBatchVirtualized(ctx context.Context, batchNumber ui return exists, nil } -// IsSequencingTXSynced checks if sequencing tx has been synced into the state -func (p *PostgresStorage) IsSequencingTXSynced(ctx context.Context, transactionHash common.Hash, dbTx pgx.Tx) (bool, error) { - const query = `SELECT EXISTS (SELECT 1 FROM state.virtual_batch WHERE tx_hash = $1)` - e := p.getExecQuerier(dbTx) - var exists bool - err := e.QueryRow(ctx, query, transactionHash.String()).Scan(&exists) - if err != nil && !errors.Is(err, pgx.ErrNoRows) { - return exists, err - } - return exists, nil -} - // GetProcessingContext returns the processing context for the given batch. func (p *PostgresStorage) GetProcessingContext(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*ProcessingContext, error) { e := p.getExecQuerier(dbTx) @@ -1714,31 +1704,31 @@ func (p *PostgresStorage) GetExitRootByGlobalExitRoot(ctx context.Context, ger c } // AddGeneratedProof adds a generated proof to the storage -func (p *PostgresStorage) AddGeneratedProof(ctx context.Context, proof *Proof, dbTx pgx.Tx) error { - const addGeneratedProofSQL = "INSERT INTO state.proof (batch_num, proof, proof_id, input_prover, prover) VALUES ($1, $2, $3, $4, $5)" +func (p *PostgresStorage) AddGeneratedProof(ctx context.Context, batchNumber uint64, proof *pb.GetProofResponse, dbTx pgx.Tx) error { + const addGeneratedProofSQL = "INSERT INTO state.proof (batch_num, proof) VALUES ($1, $2)" e := p.getExecQuerier(dbTx) - _, err := e.Exec(ctx, addGeneratedProofSQL, proof.BatchNumber, proof.Proof, proof.ProofID, proof.InputProver, proof.Prover) + _, err := e.Exec(ctx, addGeneratedProofSQL, batchNumber, proof) return err } // UpdateGeneratedProof updates a generated proof in the storage -func (p *PostgresStorage) UpdateGeneratedProof(ctx context.Context, proof *Proof, dbTx pgx.Tx) error { - const addGeneratedProofSQL = "UPDATE state.proof SET proof = $2, proof_id = $3, input_prover = $4, prover = $5 WHERE batch_num = $1" +func (p *PostgresStorage) UpdateGeneratedProof(ctx context.Context, batchNumber uint64, proof *pb.GetProofResponse, dbTx pgx.Tx) error { + const addGeneratedProofSQL = "UPDATE state.proof SET proof = $2 WHERE batch_num = $1" e := p.getExecQuerier(dbTx) - _, err := e.Exec(ctx, addGeneratedProofSQL, proof.BatchNumber, proof.Proof, proof.ProofID, proof.InputProver, proof.Prover) + _, err := e.Exec(ctx, addGeneratedProofSQL, batchNumber, proof) return err } // GetGeneratedProofByBatchNumber gets a generated proof from the storage -func (p *PostgresStorage) GetGeneratedProofByBatchNumber(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*Proof, error) { +func (p *PostgresStorage) GetGeneratedProofByBatchNumber(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*pb.GetProofResponse, error) { var ( - proof *Proof = &Proof{} + proof *pb.GetProofResponse err error ) - const getGeneratedProofSQL = "SELECT batch_num, proof, proof_id, input_prover, prover FROM state.proof WHERE batch_num = $1" + const getGeneratedProofSQL = "SELECT proof FROM state.proof WHERE batch_num = $1" e := p.getExecQuerier(dbTx) - err = e.QueryRow(ctx, getGeneratedProofSQL, batchNumber).Scan(&proof.BatchNumber, &proof.Proof, &proof.ProofID, &proof.InputProver, &proof.Prover) + err = e.QueryRow(ctx, getGeneratedProofSQL, batchNumber).Scan(&proof) if errors.Is(err, pgx.ErrNoRows) { return nil, ErrNotFound } else if err != nil { @@ -1764,22 +1754,3 @@ func (p *PostgresStorage) DeleteUngeneratedProofs(ctx context.Context, dbTx pgx. _, err := e.Exec(ctx, deleteUngeneratedProofsSQL) return err } - -// GetWIPProofByProver gets a generated proof from its prover URI -func (p *PostgresStorage) GetWIPProofByProver(ctx context.Context, prover string, dbTx pgx.Tx) (*Proof, error) { - var ( - proof *Proof = &Proof{} - err error - ) - - const getGeneratedProofSQL = "SELECT batch_num, proof, proof_id, input_prover, prover FROM state.proof WHERE prover = $1 and proof is null" - e := p.getExecQuerier(dbTx) - err = e.QueryRow(ctx, getGeneratedProofSQL, prover).Scan(&proof.BatchNumber, &proof.Proof, &proof.ProofID, &proof.InputProver, &proof.Prover) - if errors.Is(err, pgx.ErrNoRows) { - return nil, ErrNotFound - } else if err != nil { - return nil, err - } - - return proof, err -} diff --git a/state/proof.go b/state/proof.go deleted file mode 100644 index aa2c138b78..0000000000 --- a/state/proof.go +++ /dev/null @@ -1,12 +0,0 @@ -package state - -import "github.com/0xPolygonHermez/zkevm-node/proverclient/pb" - -// Proof struct -type Proof struct { - BatchNumber uint64 - Proof *pb.GetProofResponse - InputProver *pb.InputProver - ProofID *string - Prover *string -} diff --git a/state/state.go b/state/state.go index e7f20f8c5b..5b741a8a58 100644 --- a/state/state.go +++ b/state/state.go @@ -655,24 +655,6 @@ func (s *State) CloseBatch(ctx context.Context, receipt ProcessingReceipt, dbTx } txs = append(txs, *tx) } - - // todo: temporary check, remove if don't face this error anymore https://github.com/0xPolygonHermez/zkevm-node/issues/1303 - // check the order of the txs - if len(receipt.Txs) != len(txs) { - log.Warnf("when closing a batch amount of txs in memory: %d is differs from amount in db: %d", - len(receipt.Txs), len(txs)) - } - var isOrderNotCorrect bool - for i, tx := range receipt.Txs { - if tx.Hash().Hex() != txs[i].Hash().Hex() { - isOrderNotCorrect = true - } - } - if isOrderNotCorrect { - log.Warnf("order in memory of the sequence and order in data from request database is different," + - " change to the order in memory") - txs = receipt.Txs - } batchL2Data, err := EncodeTransactions(txs) if err != nil { return err @@ -703,21 +685,14 @@ func (s *State) ProcessAndStoreClosedBatch(ctx context.Context, processingCtx Pr } // Sanity check - /* - if len(decodedTransactions) != len(processed.Responses) { - return fmt.Errorf("number of decoded (%d) and processed (%d) transactions do not match", len(decodedTransactions), len(processed.Responses)) - } - */ + if len(decodedTransactions) != len(processed.Responses) { + return fmt.Errorf("number of decoded (%d) and processed (%d) transactions do not match", len(decodedTransactions), len(processed.Responses)) + } // Filter unprocessed txs and decode txs to store metadata // note that if the batch is not well encoded it will result in an empty batch (with no txs) for i := 0; i < len(processed.Responses); i++ { if !isProcessed(processed.Responses[i].Error) { - if isOOC(processed.Responses[i].Error) { - processed.Responses = []*pb.ProcessTransactionResponse{} - break - } - // Remove unprocessed tx if i == len(processed.Responses)-1 { processed.Responses = processed.Responses[:i] @@ -734,13 +709,10 @@ func (s *State) ProcessAndStoreClosedBatch(ctx context.Context, processingCtx Pr if err != nil { return err } - - if len(processedBatch.Responses) > 0 { - // Store processed txs into the batch - err = s.StoreTransactions(ctx, processingCtx.BatchNumber, processedBatch.Responses, dbTx) - if err != nil { - return err - } + // Store processed txs into the batch + err = s.StoreTransactions(ctx, processingCtx.BatchNumber, processedBatch.Responses, dbTx) + if err != nil { + return err } // Close batch @@ -1285,7 +1257,7 @@ func CheckSupersetBatchTransactions(existingTxHashes []common.Hash, processedTxs return ErrExistingTxGreaterThanProcessedTx } for i, existingTxHash := range existingTxHashes { - if existingTxHash != processedTxs[i].TxHash { + if existingTxHash != processedTxs[i].Tx.Hash() { return ErrOutOfOrderProcessedTx } } @@ -1318,51 +1290,3 @@ func DetermineProcessedTransactions(responses []*ProcessTransactionResponse) ( } return processedTxResponses, processedTxsHashes, unprocessedTxResponses, unprocessedTxsHashes } - -// WaitSequencingTxToBeSynced waits for a sequencing transaction to be synced into the state -func (s *State) WaitSequencingTxToBeSynced(parentCtx context.Context, tx *types.Transaction, timeout time.Duration) error { - ctx, cancel := context.WithTimeout(parentCtx, timeout) - defer cancel() - - for { - virtualized, err := s.IsSequencingTXSynced(ctx, tx.Hash(), nil) - if err != nil && err != ErrNotFound { - log.Errorf("error waiting sequencing tx %s to be synced: %w", tx.Hash().String(), err) - return err - } else if ctx.Err() != nil { - log.Errorf("error waiting sequencing tx %s to be synced: %w", tx.Hash().String(), err) - return ctx.Err() - } else if virtualized { - break - } - - time.Sleep(time.Second) - } - - log.Debug("Sequencing txh successfully synced: ", tx.Hash().String()) - return nil -} - -// WaitVerifiedBatchToBeSynced waits for a sequenced batch to be synced into the state -func (s *State) WaitVerifiedBatchToBeSynced(parentCtx context.Context, batchNumber uint64, timeout time.Duration) error { - ctx, cancel := context.WithTimeout(parentCtx, timeout) - defer cancel() - - for { - batch, err := s.GetVerifiedBatch(ctx, batchNumber, nil) - if err != nil && err != ErrNotFound { - log.Errorf("error waiting verified batch %s to be synced: %w", batchNumber, err) - return err - } else if ctx.Err() != nil { - log.Errorf("error waiting verified batch %s to be synced: %w", batchNumber, err) - return ctx.Err() - } else if batch != nil { - break - } - - time.Sleep(time.Second) - } - - log.Debug("Verified batch successfully synced: ", batchNumber) - return nil -} diff --git a/state/state_test.go b/state/state_test.go index e318ca099f..49c4f7fd4d 100644 --- a/state/state_test.go +++ b/state/state_test.go @@ -580,6 +580,7 @@ func TestExecuteTransaction(t *testing.T) { // TODO: assert processBatchResponse to make sure that the response makes sense } +/* func TestCheckSupersetBatchTransactions(t *testing.T) { tcs := []struct { description string @@ -653,6 +654,7 @@ func TestCheckSupersetBatchTransactions(t *testing.T) { }) } } +*/ func TestGetTxsHashesByBatchNumber(t *testing.T) { // Init database instance diff --git a/synchronizer/config.go b/synchronizer/config.go index ad3753f724..aae801666e 100644 --- a/synchronizer/config.go +++ b/synchronizer/config.go @@ -11,6 +11,4 @@ type Config struct { // SyncChunkSize is the number of blocks to sync on each chunk SyncChunkSize uint64 `mapstructure:"SyncChunkSize"` - - GenBlockNumber uint64 `mapstructure:"GenBlockNumber"` } diff --git a/synchronizer/interfaces.go b/synchronizer/interfaces.go index 4d556a693f..088b3538f0 100644 --- a/synchronizer/interfaces.go +++ b/synchronizer/interfaces.go @@ -6,7 +6,6 @@ import ( "github.com/0xPolygonHermez/zkevm-node/etherman" "github.com/0xPolygonHermez/zkevm-node/state" - "github.com/0xPolygonHermez/zkevm-node/state/runtime/executor/pb" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/jackc/pgx/v4" @@ -44,7 +43,6 @@ type stateInterface interface { ProcessSequencerBatch(ctx context.Context, batchNumber uint64, txs []types.Transaction, dbTx pgx.Tx) (*state.ProcessBatchResponse, error) StoreTransactions(ctx context.Context, batchNum uint64, processedTxs []*state.ProcessTransactionResponse, dbTx pgx.Tx) error GetStateRootByBatchNumber(ctx context.Context, batchNum uint64, dbTx pgx.Tx) (common.Hash, error) - ExecuteBatch(ctx context.Context, batchNumber uint64, batchL2Data []byte, dbTx pgx.Tx) (*pb.ProcessBatchResponse, error) BeginStateTransaction(ctx context.Context) (pgx.Tx, error) } diff --git a/synchronizer/mock_state.go b/synchronizer/mock_state.go index 57f2de02c3..f6a743512d 100644 --- a/synchronizer/mock_state.go +++ b/synchronizer/mock_state.go @@ -9,8 +9,6 @@ import ( mock "github.com/stretchr/testify/mock" - pb "github.com/0xPolygonHermez/zkevm-node/state/runtime/executor/pb" - pgx "github.com/jackc/pgx/v4" state "github.com/0xPolygonHermez/zkevm-node/state" @@ -144,29 +142,6 @@ func (_m *stateMock) CloseBatch(ctx context.Context, receipt state.ProcessingRec return r0 } -// ExecuteBatch provides a mock function with given fields: ctx, batchNumber, batchL2Data, dbTx -func (_m *stateMock) ExecuteBatch(ctx context.Context, batchNumber uint64, batchL2Data []byte, dbTx pgx.Tx) (*pb.ProcessBatchResponse, error) { - ret := _m.Called(ctx, batchNumber, batchL2Data, dbTx) - - var r0 *pb.ProcessBatchResponse - if rf, ok := ret.Get(0).(func(context.Context, uint64, []byte, pgx.Tx) *pb.ProcessBatchResponse); ok { - r0 = rf(ctx, batchNumber, batchL2Data, dbTx) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*pb.ProcessBatchResponse) - } - } - - var r1 error - if rf, ok := ret.Get(1).(func(context.Context, uint64, []byte, pgx.Tx) error); ok { - r1 = rf(ctx, batchNumber, batchL2Data, dbTx) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - // GetBatchByNumber provides a mock function with given fields: ctx, batchNumber, dbTx func (_m *stateMock) GetBatchByNumber(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*state.Batch, error) { ret := _m.Called(ctx, batchNumber, dbTx) diff --git a/synchronizer/synchronizer.go b/synchronizer/synchronizer.go index d40d7b25c5..fbfd6cff01 100644 --- a/synchronizer/synchronizer.go +++ b/synchronizer/synchronizer.go @@ -34,6 +34,7 @@ type ClientSynchronizer struct { state stateInterface ctx context.Context cancelCtx context.CancelFunc + genBlockNumber uint64 genesis state.Genesis cfg Config } @@ -43,6 +44,7 @@ func NewSynchronizer( isTrustedSequencer bool, ethMan ethermanInterface, st stateInterface, + genBlockNumber uint64, genesis state.Genesis, cfg Config) (Synchronizer, error) { ctx, cancel := context.WithCancel(context.Background()) @@ -53,6 +55,7 @@ func NewSynchronizer( etherMan: ethMan, ctx: ctx, cancelCtx: cancel, + genBlockNumber: genBlockNumber, genesis: genesis, cfg: cfg, }, nil @@ -74,9 +77,9 @@ func (s *ClientSynchronizer) Sync() error { if err != nil { if errors.Is(err, state.ErrStateNotSynchronized) { log.Info("State is empty, setting genesis block") - header, err := s.etherMan.HeaderByNumber(s.ctx, big.NewInt(0).SetUint64(s.cfg.GenBlockNumber)) + header, err := s.etherMan.HeaderByNumber(s.ctx, big.NewInt(0).SetUint64(s.genBlockNumber)) if err != nil { - log.Fatal("error getting l1 block header for block ", s.cfg.GenBlockNumber, " : ", err) + log.Fatal("error getting l1 block header for block ", s.genBlockNumber, " : ", err) } lastEthBlockSynced = &state.Block{ BlockNumber: header.Number.Uint64(), @@ -427,7 +430,7 @@ func (s *ClientSynchronizer) checkReorg(latestBlock *state.Block) (*state.Block, return nil, err } // Compare hashes - if (block.Hash() != latestBlock.BlockHash || block.ParentHash() != latestBlock.ParentHash) && latestBlock.BlockNumber > s.cfg.GenBlockNumber { + if (block.Hash() != latestBlock.BlockHash || block.ParentHash() != latestBlock.ParentHash) && latestBlock.BlockNumber > s.genBlockNumber { log.Debug("[checkReorg function] => latestBlockNumber: ", latestBlock.BlockNumber) log.Debug("[checkReorg function] => latestBlockHash: ", latestBlock.BlockHash) log.Debug("[checkReorg function] => latestBlockHashParent: ", latestBlock.ParentHash) @@ -444,13 +447,13 @@ func (s *ClientSynchronizer) checkReorg(latestBlock *state.Block) (*state.Block, latestBlock, err = s.state.GetPreviousBlock(s.ctx, depth, dbTx) errC := dbTx.Commit(s.ctx) if errC != nil { - log.Errorf("error committing dbTx, err: %w", errC) + log.Errorf("error committing dbTx, err: %s", errC.Error()) rollbackErr := dbTx.Rollback(s.ctx) if rollbackErr != nil { - log.Fatalf("error rolling back state. RollbackErr: %w, err: %w", - rollbackErr, errC) + log.Fatalf("error rolling back state. RollbackErr: %s, err: %s", + rollbackErr.Error(), errC.Error()) } - log.Fatalf("error committing dbTx, err: %w", errC) + log.Fatalf("error committing dbTx, err: %s", errC.Error()) } if errors.Is(err, state.ErrNotFound) { log.Warn("error checking reorg: previous block not found in db: ", err) @@ -480,21 +483,11 @@ func (s *ClientSynchronizer) checkTrustedState(batch state.Batch, dbTx pgx.Tx) ( if err != nil { return false, err } - - // Reprocess batch and compare the stateRoot with tBatch.StateRoot - p, err := s.state.ExecuteBatch(s.ctx, batch.BatchNumber, batch.BatchL2Data, dbTx) - if err != nil { - log.Errorf("error executing L1 batch: %+v, error: %w", batch, err) - return false, err - } - newRoot := common.BytesToHash(p.NewStateRoot) - //Compare virtual state with trusted state if hex.EncodeToString(batch.BatchL2Data) == hex.EncodeToString(tBatch.BatchL2Data) && batch.GlobalExitRoot.String() == tBatch.GlobalExitRoot.String() && batch.Timestamp.Unix() == tBatch.Timestamp.Unix() && - batch.Coinbase.String() == tBatch.Coinbase.String() && - newRoot == tBatch.StateRoot { + batch.Coinbase.String() == tBatch.Coinbase.String() { return true, nil } return false, nil diff --git a/synchronizer/synchronizer_test.go b/synchronizer/synchronizer_test.go index 3bc5859a9c..1ebf8e0c25 100644 --- a/synchronizer/synchronizer_test.go +++ b/synchronizer/synchronizer_test.go @@ -10,7 +10,6 @@ import ( "github.com/0xPolygonHermez/zkevm-node/etherman" "github.com/0xPolygonHermez/zkevm-node/etherman/smartcontracts/proofofefficiency" "github.com/0xPolygonHermez/zkevm-node/state" - "github.com/0xPolygonHermez/zkevm-node/state/runtime/executor/pb" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/jackc/pgx/v4" @@ -31,15 +30,27 @@ func TestTrustedStateReorg(t *testing.T) { } setupMocks := func(m *mocks, tc *testCase) Synchronizer { + genBlockNumber := uint64(123456) genesis := state.Genesis{} cfg := Config{ - SyncInterval: cfgTypes.Duration{Duration: 1 * time.Second}, - SyncChunkSize: 10, - GenBlockNumber: uint64(123456), + SyncInterval: cfgTypes.Duration{Duration: 1 * time.Second}, + SyncChunkSize: 10, } - sync, err := NewSynchronizer(true, m.Etherman, m.State, genesis, cfg) + reorgTrustedStateChan := make(chan struct{}) + sync, err := NewSynchronizer(true, m.Etherman, m.State, genBlockNumber, genesis, cfg) require.NoError(t, err) + go func() { + for { + select { + case <-reorgTrustedStateChan: + t.Log("Trusted reorg receive in the channel") + return + case <-context.Background().Done(): + return + } + } + }() // state preparation ctxMatchBy := mock.MatchedBy(func(ctx context.Context) bool { return ctx != nil }) m.State. @@ -130,11 +141,6 @@ func TestTrustedStateReorg(t *testing.T) { Return(trustedBatch, nil). Once() - m.State. //ExecuteBatch(s.ctx, batch.BatchNumber, batch.BatchL2Data, dbTx - On("ExecuteBatch", ctx, sequencedBatch.BatchNumber, sequencedBatch.Transactions, m.DbTx). - Return(&pb.ProcessBatchResponse{NewStateRoot: trustedBatch.StateRoot.Bytes()}, nil). - Once() - m.State. On("ResetTrustedState", ctx, sequencedBatch.BatchNumber-1, m.DbTx). Return(nil). diff --git a/test/config/config.test.toml b/test/config/config.test.toml index c2c40f4785..35a7ae193a 100644 --- a/test/config/config.test.toml +++ b/test/config/config.test.toml @@ -33,7 +33,6 @@ MaxVerifyBatchTxRetries = 10 FrequencyForResendingFailedSendBatches = "1s" FrequencyForResendingFailedVerifyBatch = "1s" WaitTxToBeMined = "2m" -WaitTxToBeSynced = "10s" PercentageToIncreaseGasPrice = 10 PercentageToIncreaseGasLimit = 10 @@ -75,7 +74,6 @@ MaxMemAligns = 262144 MaxArithmetics = 262144 MaxBinaries = 262144 MaxSteps = 8388608 -MaxAllowedFailedCounter = 50 [Sequencer.ProfitabilityChecker] SendBatchesEvenWhenNotProfitable = "true" diff --git a/test/constants/environment_variables.go b/test/constants/environment_variables.go deleted file mode 100644 index d1bfb26419..0000000000 --- a/test/constants/environment_variables.go +++ /dev/null @@ -1,8 +0,0 @@ -package constants - -const ( - //ENV_ZKPROVER_URI environment variable name for ZKPROVER URI - ENV_ZKPROVER_URI = "ZKPROVER_URI" - //ENV_MERKLETREE_URI environment variable name for MERKLETREE URI - ENV_MERKLETREE_URI = "MERKLETREE_URI" -) diff --git a/test/e2e/broadcast_test.go b/test/e2e/broadcast_test.go index c973a52cbe..a8f9117d90 100644 --- a/test/e2e/broadcast_test.go +++ b/test/e2e/broadcast_test.go @@ -13,10 +13,8 @@ import ( "github.com/0xPolygonHermez/zkevm-node/sequencer/broadcast/pb" "github.com/0xPolygonHermez/zkevm-node/state" "github.com/0xPolygonHermez/zkevm-node/state/runtime/executor" - "github.com/0xPolygonHermez/zkevm-node/test/constants" "github.com/0xPolygonHermez/zkevm-node/test/dbutils" "github.com/0xPolygonHermez/zkevm-node/test/operations" - "github.com/0xPolygonHermez/zkevm-node/test/testutils" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/stretchr/testify/require" @@ -89,10 +87,8 @@ func initState() (*state.State, error) { return nil, err } stateDb := state.NewPostgresStorage(sqlDB) - executorUri := testutils.GetEnv(constants.ENV_ZKPROVER_URI, "127.0.0.1:50071") - merkleTreeUri := testutils.GetEnv(constants.ENV_MERKLETREE_URI, "127.0.0.1:50061") - executorClient, _, _ := executor.NewExecutorClient(ctx, executor.Config{URI: executorUri}) - mtDBClient, _, _ := merkletree.NewMTDBServiceClient(ctx, merkletree.Config{URI: merkleTreeUri}) + executorClient, _, _ := executor.NewExecutorClient(ctx, executor.Config{URI: "127.0.0.1:50071"}) + mtDBClient, _, _ := merkletree.NewMTDBServiceClient(ctx, merkletree.Config{URI: "127.0.0.1:50061"}) stateTree := merkletree.NewStateTree(mtDBClient) return state.NewState(state.Config{}, stateDb, executorClient, stateTree), nil } diff --git a/test/operations/manager.go b/test/operations/manager.go index 3e3b0c6cdf..4ec92d6cd2 100644 --- a/test/operations/manager.go +++ b/test/operations/manager.go @@ -14,9 +14,7 @@ import ( "github.com/0xPolygonHermez/zkevm-node/merkletree" "github.com/0xPolygonHermez/zkevm-node/state" "github.com/0xPolygonHermez/zkevm-node/state/runtime/executor" - "github.com/0xPolygonHermez/zkevm-node/test/constants" "github.com/0xPolygonHermez/zkevm-node/test/dbutils" - "github.com/0xPolygonHermez/zkevm-node/test/testutils" "github.com/0xPolygonHermez/zkevm-node/test/vectors" "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" @@ -26,8 +24,12 @@ import ( ) const ( - poeAddress = "0xDc64a140Aa3E981100a9becA4E685f962f0cF6C9" - maticTokenAddress = "0x5FbDB2315678afecb367f032d93F642f64180aa3" //nolint:gosec + executorURI = "127.0.0.1:50071" + merkletreeURI = "127.0.0.1:50061" + + poeAddress = "0xDc64a140Aa3E981100a9becA4E685f962f0cF6C9" + maticTokenAddress = "0x5FbDB2315678afecb367f032d93F642f64180aa3" //nolint:gosec + l1AccHexAddress = "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266" l1AccHexPrivateKey = "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80" ) @@ -48,14 +50,11 @@ const ( ) var ( - stateDBCfg = dbutils.NewStateConfigFromEnv() - poolDBCfg = dbutils.NewPoolConfigFromEnv() - rpcDBCfg = dbutils.NewRPCConfigFromEnv() - - executorURI = testutils.GetEnv(constants.ENV_ZKPROVER_URI, "127.0.0.1:50071") - merkleTreeURI = testutils.GetEnv(constants.ENV_MERKLETREE_URI, "127.0.0.1:50061") + stateDBCfg = dbutils.NewStateConfigFromEnv() + poolDBCfg = dbutils.NewPoolConfigFromEnv() + rpcDBCfg = dbutils.NewRPCConfigFromEnv() executorConfig = executor.Config{URI: executorURI} - merkleTreeConfig = merkletree.Config{URI: merkleTreeURI} + merkletreeConfig = merkletree.Config{URI: merkletreeURI} ) // SequencerConfig is the configuration for the sequencer operations. @@ -295,7 +294,7 @@ func initState(maxCumulativeGasUsed uint64) (*state.State, error) { ctx := context.Background() stateDb := state.NewPostgresStorage(sqlDB) executorClient, _, _ := executor.NewExecutorClient(ctx, executorConfig) - stateDBClient, _, _ := merkletree.NewMTDBServiceClient(ctx, merkleTreeConfig) + stateDBClient, _, _ := merkletree.NewMTDBServiceClient(ctx, merkletreeConfig) stateTree := merkletree.NewStateTree(stateDBClient) stateCfg := state.Config{ diff --git a/tools/genesis/generator.go b/tools/genesis/generator.go new file mode 100644 index 0000000000..7680278d82 --- /dev/null +++ b/tools/genesis/generator.go @@ -0,0 +1,199 @@ +package main + +import ( + "bufio" + "context" + "encoding/json" + "fmt" + "io/ioutil" + "math/big" + "os/exec" + "strings" + + "github.com/0xPolygonHermez/zkevm-node/log" + "github.com/0xPolygonHermez/zkevm-node/state" + "github.com/0xPolygonHermez/zkevm-node/test/operations" + "github.com/0xPolygonHermez/zkevm-node/tools/genesis/genesisparser" + "github.com/ethereum/go-ethereum/ethclient" + "github.com/go-git/go-billy/v5/memfs" + "github.com/go-git/go-git/v5" + "github.com/go-git/go-git/v5/plumbing" + "github.com/go-git/go-git/v5/storage/memory" +) + +const ( + repoURL = "https://github.com/0xPolygonHermez/zkevm-contracts" + inputFile = "deployment/deployment_v2-0/genesis.json" + outputFile = "../../config/genesis.go" +) + +// genesisAccountReader struct +type genesisAccountReader struct { + Balance string `json:"balance"` + Nonce string `json:"nonce"` + Address string `json:"address"` + Bytecode string `json:"bytecode"` + Storage map[string]string `json:"storage"` +} + +// genesisReader struct +type genesisReader struct { + Root string `json:"root"` + Accounts []genesisAccountReader `json:"genesis"` +} + +func (gr genesisReader) GenesisAccountTest() []genesisparser.GenesisAccountTest { + accs := []genesisparser.GenesisAccountTest{} + for i := 0; i < len(gr.Accounts); i++ { + accs = append(accs, genesisparser.GenesisAccountTest{ + Balance: gr.Accounts[i].Balance, + Nonce: gr.Accounts[i].Nonce, + Address: gr.Accounts[i].Address, + Bytecode: gr.Accounts[i].Bytecode, + Storage: gr.Accounts[i].Storage, + }) + } + return accs +} + +func main() { + rawGenesis := getLatestGenesisRaw() + actions := genesisparser.GenesisTest2Actions(rawGenesis.GenesisAccountTest()) + genGoCode(actions) + err := assertGenesis(rawGenesis.Root) + if err != nil { + panic(err) + } +} + +func getLatestGenesisRaw() genesisReader { + fs := memfs.New() + + _, err := git.Clone(memory.NewStorage(), fs, &git.CloneOptions{ + ReferenceName: plumbing.NewBranchReferenceName("main"), + URL: repoURL, + }) + if err != nil { + panic(fmt.Errorf("error when clone repo: %v", err)) + } + + file, err := fs.Open(inputFile) + if err != nil { + panic(fmt.Errorf("error when open file: %v", err)) + } + + scanner := bufio.NewScanner(file) + + genesis := make([]byte, 0) + + for scanner.Scan() { + genesis = append(genesis, scanner.Bytes()...) + } + var genesisData genesisReader + err = json.Unmarshal(genesis, &genesisData) + if err != nil { + panic(fmt.Errorf("error json unmarshal: %v", err)) + } + return genesisData +} + +func genGoCode(actions []*state.GenesisAction) { + gJson, _ := json.MarshalIndent(actions, "", " ") + gString := string(gJson) + gString = strings.Replace(gString, "[\n", "", -1) + gString = strings.Replace(gString, "]", "", -1) + gString = `package config + +import ( + "github.com/0xPolygonHermez/zkevm-node/merkletree" + "github.com/0xPolygonHermez/zkevm-node/state" +) + +var commonGenesisActions = []*state.GenesisAction{ +` + gString + ` +}` + + gString = strings.Replace(gString, `"address"`, "Address", -1) + gString = strings.Replace(gString, `"type"`, "Type", -1) + gString = strings.Replace(gString, `"storagePosition"`, "StoragePosition", -1) + gString = strings.Replace(gString, `"value"`, "Value", -1) + gString = strings.Replace(gString, `"bytecode"`, "Bytecode", -1) + gString = strings.Replace(gString, `"key"`, "Key", -1) + gString = strings.Replace(gString, `"root"`, "Root", -1) + gString = strings.Replace(gString, "\"\n", "\",\n", -1) + gString = strings.Replace(gString, "}\n", "},\n", -1) + gString = strings.Replace(gString, "Type: 0,", "Type: int(merkletree.LeafTypeBalance),", -1) + gString = strings.Replace(gString, "Type: 1,", "Type: int(merkletree.LeafTypeNonce),", -1) + gString = strings.Replace(gString, "Type: 2,", "Type: int(merkletree.LeafTypeCode),", -1) + gString = strings.Replace(gString, "Type: 3,", "Type: int(merkletree.LeafTypeStorage),", -1) + + err := ioutil.WriteFile(outputFile, []byte(gString), 0600) //nolint:gomnd + if err != nil { + panic(fmt.Errorf("error writing file: %v", err)) + } + + // format code + cmd := exec.Command("gofmt", "-s", "-w", outputFile) + res, err := cmd.CombinedOutput() + if err != nil { + panic(fmt.Errorf("error formating file: %s.\n%w", string(res), err)) + } +} + +func assertGenesis(expectedRoot string) (err error) { + // Build node + if err = operations.RunMakeTarget("build-docker"); err != nil { + log.Error(err) + return + } + // Start DB and executor + if err = operations.RunMakeTarget("run-db"); err != nil { + log.Error(err) + return + } + if err = operations.RunMakeTarget("run-zkprover"); err != nil { + log.Error(err) + return + } + // Stop everything once done + defer func() { + if defErr := operations.Teardown(); defErr != nil { + err = fmt.Errorf("Error tearing down components: %s", defErr.Error()) + } + }() + + // Setup opsman + opsCfg := operations.GetDefaultOperationsConfig() + opsCfg.State.MaxCumulativeGasUsed = 80000000000 + opsman, err := operations.NewManager(context.Background(), opsCfg) + if err != nil { + log.Error(err) + return + } + + // Run node + err = opsman.Setup() + if err != nil { + log.Error(err) + return + } + + // Get Genesis root using jRPC + client, err := ethclient.Dial("http://localhost:8123") + if err != nil { + log.Error(err) + return + } + blockHeader, err := client.HeaderByNumber(context.Background(), big.NewInt(0)) + if err != nil { + log.Error(err) + return + } + actualRoot := "0x" + blockHeader.Root.Hex() + if actualRoot != expectedRoot { + err = fmt.Errorf("Root missmatch: expected: %s, actual %s", expectedRoot, actualRoot) + return + } + fmt.Printf("SUCCESS: expected: %s, actual %s\n", expectedRoot, actualRoot) + return +}