Skip to content

Commit

Permalink
geodnet test fix
Browse files Browse the repository at this point in the history
  • Loading branch information
huangzhiran committed Jan 9, 2025
1 parent a03c5b5 commit a92732e
Show file tree
Hide file tree
Showing 13 changed files with 122 additions and 427 deletions.
2 changes: 2 additions & 0 deletions datasource/clickhouse.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ func (p *Clickhouse) conv(dt *db.Task) (*task.Task, error) {
DevicePubKey: pubkey,
Payload: []byte(dt.Payload),
Signature: sig,
PayloadHash: common.HexToHash(dt.PayloadHash),
TaskHash: common.HexToHash(dt.TaskHash),
}, nil
}

Expand Down
14 changes: 7 additions & 7 deletions docs/geod.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@ need the tools for interacting with smart contracts

### Testnet

#### bind dapp
#### bind w3bstream project
```bash
cast send 0x74309Bc83fF7Ba8aBaB901936927976792a6d9B6 "bindDapp(uint256,address)" 942 0xB2Dda5D9E65E44749409E209d8b7b15fb4e82147 --private-key "your private key" --rpc-url "https://babel-api.testnet.iotex.io" --legacy
cast send 0xB564996622CE5610b9cF4ed35160f406185d7d0b "register(uint256)" 942 --private-key "your private key" --rpc-url "https://babel-api.testnet.iotex.io" --legacy
```

#### bind w3bstream project
```bash
cast send 0x74309Bc83fF7Ba8aBaB901936927976792a6d9B6 "register(uint256)" 942 --private-key "your private key" --rpc-url "https://babel-api.testnet.iotex.io" --legacy
cast send 0x7D3158166E9298fC47beA036fE162fEA17632E5D "updateConfig(uint256,string,bytes32)" 942 ipfs://ipfs.mainnet.iotex.io/QmUHfDnvWrr2wiC78dw85xfctzawNWAN1TEbzosxwHdzYC 0x8153291c230dd107f102f75e826a11d9d4a8ac3f0f4e1c3619e547f82a94410e --private-key "your private key" --rpc-url "https://babel-api.testnet.iotex.io" --legacy
```
```bash
cast send 0x0abec44FC786e8da12267Db5fdeB4311AD1A0A8A "updateConfig(uint256,string,bytes32)" 942 ipfs://ipfs.mainnet.iotex.io/QmUHfDnvWrr2wiC78dw85xfctzawNWAN1TEbzosxwHdzYC 0x8153291c230dd107f102f75e826a11d9d4a8ac3f0f4e1c3619e547f82a94410e --private-key "your private key" --rpc-url "https://babel-api.testnet.iotex.io" --legacy
cast send 0x7D3158166E9298fC47beA036fE162fEA17632E5D "resume(uint256)" 942 --private-key "your private key" --rpc-url "https://babel-api.testnet.iotex.io" --legacy
```

#### bind dapp
```bash
cast send 0x0abec44FC786e8da12267Db5fdeB4311AD1A0A8A "resume(uint256)" 942 --private-key "your private key" --rpc-url "https://babel-api.testnet.iotex.io" --legacy
cast send 0x19dD7163Ad80fE550C97Affef49E1995B24941B1 "bindDapp(uint256,address)" 942 0xB2Dda5D9E65E44749409E209d8b7b15fb4e82147 --private-key "your private key" --rpc-url "https://babel-api.testnet.iotex.io" --legacy
```
6 changes: 4 additions & 2 deletions service/apinode/api/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,13 +162,13 @@ func (s *httpServer) createTask(c *gin.Context) {
return
}

_, hash, hashAlg, _, err := HashTask(req, cfg)
payloadHash, finalHash, hashAlg, _, err := HashTask(req, cfg)
if err != nil {
slog.Error("failed to hash request", "error", err)
c.JSON(http.StatusBadRequest, newErrResp(errors.Wrap(err, "failed to hash request")))
return
}
recovered, sigAlg, err := recover(hash, sig, cfg)
recovered, sigAlg, err := recover(finalHash, sig, cfg)
if err != nil {
slog.Error("failed to recover public key", "error", err)
c.JSON(http.StatusBadRequest, newErrResp(errors.Wrap(err, "invalid signature; could not recover public key")))
Expand Down Expand Up @@ -212,6 +212,8 @@ func (s *httpServer) createTask(c *gin.Context) {
Signature: hexutil.Encode(sig),
SignatureAlgorithm: sigAlg,
HashAlgorithm: hashAlg,
PayloadHash: hexutil.Encode(payloadHash[:]),
TaskHash: hexutil.Encode(finalHash[:]),
CreatedAt: time.Now(),
},
); err != nil {
Expand Down
4 changes: 4 additions & 0 deletions service/apinode/db/clickhouse.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ type Task struct {
Signature string `ch:"signature" gorm:"not null"`
SignatureAlgorithm string `ch:"signature_algorithm" gorm:"not null"`
HashAlgorithm string `ch:"hash_algorithm" gorm:"not null"`
PayloadHash string `ch:"payload_hash" gorm:"not null"`
TaskHash string `ch:"task_hash" gorm:"not null"`
CreatedAt time.Time `ch:"created_at" gorm:"not null"`
PrevTaskID string `ch:"previous_task_id" gorm:"not null"`
}
Expand Down Expand Up @@ -63,6 +65,8 @@ func migrateCH(conn driver.Conn) error {
signature String NOT NULL,
signature_algorithm String NOT NULL,
hash_algorithm String NOT NULL,
payload_hash String NOT NULL,
task_hash String NOT NULL,
created_at DateTime NOT NULL,
previous_task_id String NOT NULL
)
Expand Down
Loading

0 comments on commit a92732e

Please sign in to comment.