diff --git a/README.md b/README.md index d4e8504..06ed0c7 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ To ensure compatibility with the node version, check the following versions: | L1 Node | MiniMove | MiniWasm | MiniEVM | | ------- | -------- | -------- | ------- | -| v0.6.1+ | v0.6.4+ | v0.6.4+ | v0.6.6+ | +| v0.6.4+ | v0.6.5+ | v0.6.5+ | v0.6.7+ | ### Build and Configure @@ -85,7 +85,7 @@ opinitd reset-heights [bot-name] ### Reset Node Height -To reset bot's specific node height info to 0 , use the following command: +To reset bot's specific node height info to 0, use the following command: ```bash opinitd reset-height [bot-name] [node-type] diff --git a/challenger/README.md b/challenger/README.md index b066bdb..610b1ab 100644 --- a/challenger/README.md +++ b/challenger/README.md @@ -41,12 +41,12 @@ To configure the Challenger, fill in the values in the `~/.opinit/challenger.jso // It can be useful when you don't want to use TxSearch. "disable_auto_set_l1_height": false, // L1StartHeight is the height to start the l1 node. - "l1_start_height": 0, - // L2StartHeight is the height to start the l2 node. If it is 0, it will start from the latest height. + "l1_start_height": 1, + // L2StartHeight is the height to start the l2 node. // If the latest height stored in the db is not 0, this config is ignored. // L2 starts from the last submitted output l2 block number + 1 before L2StartHeight. // L1 starts from the block number of the output tx + 1 - "l2_start_height": 0, + "l2_start_height": 1, } ``` @@ -184,9 +184,23 @@ curl localhost:3001/status ### Challenges ```bash -curl localhost:3001/challenges/{page} +curl localhost:3001/challenges ``` +default options +- `limit`: 10 +- `next`: "" +- `order`: desc + +```go +type QueryChallengesResponse struct { + Challenges []Challenge `json:"challenges"` + Next *string `json:"next,omitempty"` +} +``` + +If `next` exists, you can continue querying by inserting it as the `next`. + ```json [ { diff --git a/challenger/challenger.go b/challenger/challenger.go index 31b0405..097ca51 100644 --- a/challenger/challenger.go +++ b/challenger/challenger.go @@ -97,13 +97,13 @@ func (c *Challenger) Initialize(ctx types.Context) error { zap.Duration("submission_interval", bridgeInfo.BridgeConfig.SubmissionInterval), ) - hostProcessedHeight, childProcessedHeight, processedOutputIndex, err := c.getProcessedHeights(ctx, bridgeInfo.BridgeId) + l1StartHeight, l2StartHeight, startOutputIndex, err := c.getNodeStartHeights(ctx, bridgeInfo.BridgeId) if err != nil { return err } var initialBlockTime time.Time - hostInitialBlockTime, err := c.host.Initialize(ctx, hostProcessedHeight, c.child, *bridgeInfo, c) + hostInitialBlockTime, err := c.host.Initialize(ctx, l1StartHeight-1, c.child, *bridgeInfo, c) if err != nil { return err } @@ -111,7 +111,7 @@ func (c *Challenger) Initialize(ctx types.Context) error { initialBlockTime = hostInitialBlockTime } - childInitialBlockTime, err := c.child.Initialize(ctx, childProcessedHeight, processedOutputIndex+1, c.host, *bridgeInfo, c) + childInitialBlockTime, err := c.child.Initialize(ctx, l2StartHeight-1, startOutputIndex, c.host, *bridgeInfo, c) if err != nil { return err } @@ -227,35 +227,39 @@ func (c *Challenger) RegisterQuerier() { }) } -func (c *Challenger) getProcessedHeights(ctx types.Context, bridgeId uint64) (l1ProcessedHeight int64, l2ProcessedHeight int64, processedOutputIndex uint64, err error) { +func (c *Challenger) getNodeStartHeights(ctx types.Context, bridgeId uint64) (l1StartHeight int64, l2StartHeight int64, startOutputIndex uint64, err error) { if c.host.Node().GetSyncedHeight() != 0 && c.child.Node().GetSyncedHeight() != 0 { return 0, 0, 0, nil } - var outputL1BlockNumber int64 + var outputL1Height, outputL2Height int64 + var outputIndex uint64 + // get the last submitted output height before the start height from the host - if c.cfg.L2StartHeight != 0 { + if c.cfg.L2StartHeight > 1 { output, err := c.host.QueryLastFinalizedOutput(ctx, bridgeId) if err != nil { return 0, 0, 0, err } else if output != nil { - outputL1BlockNumber = types.MustUint64ToInt64(output.OutputProposal.L1BlockNumber) - l2ProcessedHeight = types.MustUint64ToInt64(output.OutputProposal.L2BlockNumber) - processedOutputIndex = output.OutputIndex + outputL1Height = types.MustUint64ToInt64(output.OutputProposal.L1BlockNumber) + outputL2Height = types.MustUint64ToInt64(output.OutputProposal.L2BlockNumber) + outputIndex = output.OutputIndex } } + l2StartHeight = outputL2Height + 1 + startOutputIndex = outputIndex + 1 if c.cfg.DisableAutoSetL1Height { - l1ProcessedHeight = c.cfg.L1StartHeight + l1StartHeight = c.cfg.L1StartHeight } else { // get the bridge start height from the host - l1ProcessedHeight, err = c.host.QueryCreateBridgeHeight(ctx, bridgeId) + l1StartHeight, err = c.host.QueryCreateBridgeHeight(ctx, bridgeId) if err != nil { return 0, 0, 0, err } - if l2ProcessedHeight > 0 { - l1Sequence, err := c.child.QueryNextL1Sequence(ctx, l2ProcessedHeight-1) + if l2StartHeight > 1 { + l1Sequence, err := c.child.QueryNextL1Sequence(ctx, l2StartHeight-1) if err != nil { return 0, 0, 0, err } @@ -271,19 +275,16 @@ func (c *Challenger) getProcessedHeights(ctx types.Context, bridgeId uint64) (l1 } } - if depositTxHeight > l1ProcessedHeight { - l1ProcessedHeight = depositTxHeight + if depositTxHeight > l1StartHeight { + l1StartHeight = depositTxHeight } - if outputL1BlockNumber != 0 && outputL1BlockNumber < l1ProcessedHeight { - l1ProcessedHeight = outputL1BlockNumber + if outputL1Height != 0 && outputL1Height < l1StartHeight { + l1StartHeight = outputL1Height + 1 } } } - if l1ProcessedHeight > 0 { - l1ProcessedHeight-- - } - return l1ProcessedHeight, l2ProcessedHeight, processedOutputIndex, err + return } func (c Challenger) DB() types.DB { diff --git a/challenger/types/config.go b/challenger/types/config.go index 97e9442..24fec14 100644 --- a/challenger/types/config.go +++ b/challenger/types/config.go @@ -75,8 +75,8 @@ func DefaultConfig() *Config { RPCAddress: "tcp://localhost:27657", }, DisableAutoSetL1Height: false, - L1StartHeight: 0, - L2StartHeight: 0, + L1StartHeight: 1, + L2StartHeight: 1, } } @@ -101,12 +101,12 @@ func (cfg Config) Validate() error { return err } - if cfg.L1StartHeight < 0 { - return errors.New("l1 start height must be greater than or equal to 0") + if cfg.L1StartHeight <= 0 { + return errors.New("l1 start height must be greater than 0") } - if cfg.L2StartHeight < 0 { - return errors.New("l2 start height must be greater than or equal to 0") + if cfg.L2StartHeight <= 0 { + return errors.New("l2 start height must be greater than 0") } return nil } diff --git a/executor/README.md b/executor/README.md index 7dbac0f..b507e03 100644 --- a/executor/README.md +++ b/executor/README.md @@ -78,15 +78,15 @@ To configure the Executor, fill in the values in the `~/.opinit/executor.json` f // It can be useful when you don't want to use TxSearch. "disable_auto_set_l1_height": false, // L1StartHeight is the height to start the l1 node. - "l1_start_height": 0, - // L2StartHeight is the height to start the l2 node. If it is 0, it will start from the latest height. + "l1_start_height": 1, + // L2StartHeight is the height to start the l2 node. // If the latest height stored in the db is not 0, this config is ignored. // L2 starts from the last submitted output l2 block number + 1 before L2StartHeight. // L1 starts from the block number of the output tx + 1 - "l2_start_height": 0, - // StartBatchHeight is the height to start the batch. If it is 0, it will start from the latest height. + "l2_start_height": 1, + // StartBatchHeight is the height to start the batch. // If the latest height stored in the db is not 0, this config is ignored. - "batch_start_height": 0, + "batch_start_height": 1, // DisableDeleteFutureWithdrawal is the flag to disable the deletion of future withdrawal. // when the bot is rolled back, it will delete the future withdrawals from DB. // If it is true, it will not delete the future withdrawals. @@ -229,21 +229,22 @@ When a tree is finalized, `Child` stores the leaf nodes and internal nodes of th ```go type QueryWithdrawalResponse struct { - // fields required to withdraw funds - BridgeId uint64 `json:"bridge_id"` - OutputIndex uint64 `json:"output_index"` - WithdrawalProofs [][]byte `json:"withdrawal_proofs"` - Sender string `json:"sender"` - Sequence uint64 `json:"sequence"` - Amount string `json:"amount"` - Version []byte `json:"version"` - StorageRoot []byte `json:"storage_root"` - LatestBlockHash []byte `json:"latest_block_hash"` - - // extra info - BlockNumber int64 `json:"block_number"` - Receiver string `json:"receiver"` - WithdrawalHash []byte `json:"withdrawal_hash"` +// fields required to withdraw funds + Sequence uint64 `json:"sequence"` + To string `json:"to"` + From string `json:"from"` + Amount types.Coin `json:"amount"` + OutputIndex uint64 `json:"output_index"` + BridgeId uint64 `json:"bridge_id"` + WithdrawalProofs [][]byte `json:"withdrawal_proofs"` + Version []byte `json:"version"` + StorageRoot []byte `json:"storage_root"` + LastBlockHash []byte `json:"last_block_hash"` + + // extra info + TxTime int64 `json:"tx_time"` + TxHeight int64 `json:"tx_height"` + TxHash string `json:"tx_hash"` } ``` @@ -414,7 +415,7 @@ curl localhost:3000/status ### Withdrawals ```bash -curl localhost:3000/withdrawal/{sequence} | jq . > ./withdrawal-info.json +curl localhost:3000/withdrawal/{sequence} | jq 'del(.tx_time, .tx_height, .tx_hash)' > ./withdrawal-info.json initiad tx ophost finalize-token-withdrawal ./withdrawal-info.json --gas= --gas-prices= --chain-id= --from= ``` @@ -430,6 +431,11 @@ type QueryWithdrawalResponse struct { Version []byte `json:"version"` StorageRoot []byte `json:"storage_root"` LastBlockHash []byte `json:"last_block_hash"` + + // extra info + TxTime int64 `json:"tx_time"` + TxHeight int64 `json:"tx_height"` + TxHash string `json:"tx_hash"` } ``` @@ -446,6 +452,7 @@ default options type QueryWithdrawalsResponse struct { Withdrawals []QueryWithdrawalResponse `json:"withdrawals"` Next uint64 `json:"next"` - Total uint64 `json:"total"` } -``` \ No newline at end of file +``` + +If `next` exists, you can continue querying by inserting it as the `offset`. \ No newline at end of file diff --git a/node/process.go b/node/process.go index d0b9307..0dcbbfd 100644 --- a/node/process.go +++ b/node/process.go @@ -35,7 +35,6 @@ func (n *Node) blockProcessLooper(ctx types.Context, processType nodetypes.Block latestHeight := status.SyncInfo.LatestBlockHeight if n.syncedHeight >= latestHeight { - ctx.Logger().Warn("already synced", zap.Int64("synced_height", n.syncedHeight), zap.Int64("latest_height", latestHeight)) continue } diff --git a/server/server.go b/server/server.go index 7a7fd85..a4e7812 100644 --- a/server/server.go +++ b/server/server.go @@ -14,10 +14,9 @@ type Server struct { func NewServer(cfg types.ServerConfig) *Server { app := fiber.New() app.Use(cors.New(cors.Config{ - AllowOrigins: cfg.AllowOrigins, - AllowHeaders: cfg.AllowHeaders, - AllowMethods: cfg.AllowMethods, - AllowCredentials: true, + AllowOrigins: cfg.AllowOrigins, + AllowHeaders: cfg.AllowHeaders, + AllowMethods: cfg.AllowMethods, })) return &Server{