Skip to content
This repository has been archived by the owner on May 11, 2024. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'origin/main' into eip4844
Browse files Browse the repository at this point in the history
  • Loading branch information
davidtaikocha committed Jan 23, 2024
2 parents dc54c0c + 0e8aa05 commit 7aacb28
Show file tree
Hide file tree
Showing 11 changed files with 128 additions and 128 deletions.
18 changes: 9 additions & 9 deletions docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const docTemplate = `{
"name": "MIT",
"url": "https://github.com/taikoxyz/taiko-client/blob/main/LICENSE.md"
},
"version": "{{.JsonRPC}}"
"version": "{{.Version}}"
},
"host": "{{.Host}}",
"basePath": "{{.BasePath}}",
Expand All @@ -40,15 +40,15 @@ const docTemplate = `{
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/prover_server.CreateAssignmentRequestBody"
"$ref": "#/definitions/server.CreateAssignmentRequestBody"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/prover_server.ProposeBlockResponse"
"$ref": "#/definitions/server.ProposeBlockResponse"
}
},
"422": {
Expand All @@ -74,7 +74,7 @@ const docTemplate = `{
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/prover_server.Status"
"$ref": "#/definitions/server.Status"
}
}
}
Expand All @@ -85,7 +85,7 @@ const docTemplate = `{
"big.Int": {
"type": "object"
},
"github_com_taikoxyz_taiko-client_bindings_encoding.TierFee": {
"encoding.TierFee": {
"type": "object",
"properties": {
"fee": {
Expand All @@ -96,7 +96,7 @@ const docTemplate = `{
}
}
},
"prover_server.CreateAssignmentRequestBody": {
"server.CreateAssignmentRequestBody": {
"type": "object",
"properties": {
"expiry": {
Expand All @@ -108,7 +108,7 @@ const docTemplate = `{
"tierFees": {
"type": "array",
"items": {
"$ref": "#/definitions/github_com_taikoxyz_taiko-client_bindings_encoding.TierFee"
"$ref": "#/definitions/encoding.TierFee"
}
},
"txListHash": {
Expand All @@ -119,7 +119,7 @@ const docTemplate = `{
}
}
},
"prover_server.ProposeBlockResponse": {
"server.ProposeBlockResponse": {
"type": "object",
"properties": {
"maxBlockID": {
Expand All @@ -139,7 +139,7 @@ const docTemplate = `{
}
}
},
"prover_server.Status": {
"server.Status": {
"type": "object",
"properties": {
"maxExpiry": {
Expand Down
16 changes: 8 additions & 8 deletions docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/prover_server.CreateAssignmentRequestBody"
"$ref": "#/definitions/server.CreateAssignmentRequestBody"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/prover_server.ProposeBlockResponse"
"$ref": "#/definitions/server.ProposeBlockResponse"
}
},
"422": {
Expand All @@ -65,7 +65,7 @@
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/prover_server.Status"
"$ref": "#/definitions/server.Status"
}
}
}
Expand All @@ -76,7 +76,7 @@
"big.Int": {
"type": "object"
},
"github_com_taikoxyz_taiko-client_bindings_encoding.TierFee": {
"encoding.TierFee": {
"type": "object",
"properties": {
"fee": {
Expand All @@ -87,7 +87,7 @@
}
}
},
"prover_server.CreateAssignmentRequestBody": {
"server.CreateAssignmentRequestBody": {
"type": "object",
"properties": {
"expiry": {
Expand All @@ -99,7 +99,7 @@
"tierFees": {
"type": "array",
"items": {
"$ref": "#/definitions/github_com_taikoxyz_taiko-client_bindings_encoding.TierFee"
"$ref": "#/definitions/encoding.TierFee"
}
},
"txListHash": {
Expand All @@ -110,7 +110,7 @@
}
}
},
"prover_server.ProposeBlockResponse": {
"server.ProposeBlockResponse": {
"type": "object",
"properties": {
"maxBlockID": {
Expand All @@ -130,7 +130,7 @@
}
}
},
"prover_server.Status": {
"server.Status": {
"type": "object",
"properties": {
"maxExpiry": {
Expand Down
16 changes: 8 additions & 8 deletions docs/swagger.yaml
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
definitions:
big.Int:
type: object
github_com_taikoxyz_taiko-client_bindings_encoding.TierFee:
encoding.TierFee:
properties:
fee:
$ref: '#/definitions/big.Int'
tier:
type: integer
type: object
prover_server.CreateAssignmentRequestBody:
server.CreateAssignmentRequestBody:
properties:
expiry:
type: integer
feeToken:
type: string
tierFees:
items:
$ref: '#/definitions/github_com_taikoxyz_taiko-client_bindings_encoding.TierFee'
$ref: '#/definitions/encoding.TierFee'
type: array
txListHash:
items:
type: integer
type: array
type: object
prover_server.ProposeBlockResponse:
server.ProposeBlockResponse:
properties:
maxBlockID:
type: integer
Expand All @@ -36,7 +36,7 @@ definitions:
type: integer
type: array
type: object
prover_server.Status:
server.Status:
properties:
maxExpiry:
type: integer
Expand Down Expand Up @@ -71,14 +71,14 @@ paths:
name: body
required: true
schema:
$ref: '#/definitions/prover_server.CreateAssignmentRequestBody'
$ref: '#/definitions/server.CreateAssignmentRequestBody'
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/prover_server.ProposeBlockResponse'
$ref: '#/definitions/server.ProposeBlockResponse'
"422":
description: prover does not have capacity
schema:
Expand All @@ -95,6 +95,6 @@ paths:
"200":
description: OK
schema:
$ref: '#/definitions/prover_server.Status'
$ref: '#/definitions/server.Status'
summary: Get current prover server status
swagger: "2.0"
15 changes: 0 additions & 15 deletions internal/testutils/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"time"

"github.com/cenkalti/backoff/v4"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/core/types"
Expand Down Expand Up @@ -156,20 +155,6 @@ func ProposeAndInsertValidBlock(
return event
}

func DepositEtherToL2(s *ClientTestSuite, depositerPrivKey *ecdsa.PrivateKey, recipient common.Address) {
config, err := s.RPCClient.TaikoL1.GetConfig(nil)
s.Nil(err)

opts, err := bind.NewKeyedTransactorWithChainID(depositerPrivKey, s.RPCClient.L1ChainID)
s.Nil(err)
opts.Value = config.EthDepositMinAmount

for i := 0; i < int(config.EthDepositMinCountPerBlock); i++ {
_, err = s.RPCClient.TaikoL1.DepositEtherToL2(opts, recipient)
s.Nil(err)
}
}

// NewTestProverServer starts a new prover server that has channel listeners to respond and react
// to requests for capacity, which provers can call.
func NewTestProverServer(
Expand Down
52 changes: 29 additions & 23 deletions internal/testutils/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,35 +96,41 @@ func (s *ClientTestSuite) SetupTest() {
_, err = rpc.WaitReceipt(context.Background(), rpcCli.L1, tx)
s.Nil(err)

decimal, err := rpcCli.TaikoToken.Decimals(nil)
s.Nil(err)

// Increase allowance for AssignmentHook and TaikoL1
opts, err = bind.NewKeyedTransactorWithChainID(l1ProverPrivKey, rpcCli.L1ChainID)
s.Nil(err)

bigInt := new(big.Int).Exp(big.NewInt(1_000_000_000), new(big.Int).SetUint64(uint64(decimal)), nil)
_, err = rpcCli.TaikoToken.Approve(
opts,
common.HexToAddress(os.Getenv("ASSIGNMENT_HOOK_ADDRESS")),
bigInt,
)
s.Nil(err)

_, err = rpcCli.TaikoToken.Approve(
opts,
common.HexToAddress(os.Getenv("TAIKO_L1_ADDRESS")),
bigInt,
)
s.Nil(err)

_, err = rpc.WaitReceipt(context.Background(), rpcCli.L1, tx)
s.Nil(err)
s.setAllowance(l1ProverPrivKey)
s.setAllowance(ownerPrivKey)
}
s.Nil(rpcCli.L1.CallContext(context.Background(), &s.testnetL1SnapshotID, "evm_snapshot"))
s.NotEmpty(s.testnetL1SnapshotID)
}

func (s *ClientTestSuite) setAllowance(key *ecdsa.PrivateKey) {
decimal, err := s.RPCClient.TaikoToken.Decimals(nil)
s.Nil(err)

bigInt := new(big.Int).Exp(big.NewInt(1_000_000_000), new(big.Int).SetUint64(uint64(decimal)), nil)

opts, err := bind.NewKeyedTransactorWithChainID(key, s.RPCClient.L1ChainID)
s.Nil(err)

_, err = s.RPCClient.TaikoToken.Approve(
opts,
common.HexToAddress(os.Getenv("ASSIGNMENT_HOOK_ADDRESS")),
bigInt,
)
s.Nil(err)

tx, err := s.RPCClient.TaikoToken.Approve(
opts,
common.HexToAddress(os.Getenv("TAIKO_L1_ADDRESS")),
bigInt,
)
s.Nil(err)

_, err = rpc.WaitReceipt(context.Background(), s.RPCClient.L1, tx)
s.Nil(err)
}

func (s *ClientTestSuite) setAddress(ownerPrivKey *ecdsa.PrivateKey, name [32]byte, address common.Address) {
var (
salt = RandomHash()
Expand Down
7 changes: 4 additions & 3 deletions prover/db/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
)

var (
blockKeyPrefix = "block-"
blockKeyPrefix = "block"
separator = "++"
)

Expand All @@ -21,12 +21,13 @@ type SignedBlockData struct {
}

// BuildBlockKey will build a block key for a signed block
func BuildBlockKey(blockTimestamp uint64) []byte {
func BuildBlockKey(blockTimestamp uint64, blockNumber uint64) []byte {
return bytes.Join(
[][]byte{
[]byte(blockKeyPrefix),
[]byte(strconv.Itoa(int(blockTimestamp))),
}, []byte{})
[]byte(strconv.Itoa(int(blockNumber))),
}, []byte(separator))
}

// BuildBlockValue will build a block value for a signed block
Expand Down
2 changes: 1 addition & 1 deletion prover/db/db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
)

func Test_BuildBlockKey(t *testing.T) {
assert.Equal(t, []byte("block-1"), BuildBlockKey(1))
assert.Equal(t, []byte("block++1++300"), BuildBlockKey(1, 300))
}

func Test_BuildBlockValue(t *testing.T) {
Expand Down
12 changes: 4 additions & 8 deletions prover/guardian_prover_sender/guardian_prover.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,17 +101,13 @@ func (s *GuardianProverBlockSender) SignAndSendBlock(ctx context.Context, blockI
return err
}

if err := s.db.Put(
db.BuildBlockKey(header.Time),
return s.db.Put(
db.BuildBlockKey(header.Time, header.Number.Uint64()),
db.BuildBlockValue(header.Hash().Bytes(),
signed,
blockID,
),
); err != nil {
return err
}

return nil
)
}

// sendSignedBlockReq is the actual method that sends the signed block to the health check server.
Expand Down Expand Up @@ -173,7 +169,7 @@ func (s *GuardianProverBlockSender) sign(ctx context.Context, blockID *big.Int)
return nil, nil, err
}

exists, err := s.db.Has(db.BuildBlockKey(header.Time))
exists, err := s.db.Has(db.BuildBlockKey(header.Time, header.Number.Uint64()))
if err != nil {
return nil, nil, err
}
Expand Down
Loading

0 comments on commit 7aacb28

Please sign in to comment.