Skip to content

Commit

Permalink
feat: access logic trie
Browse files Browse the repository at this point in the history
  • Loading branch information
Ferenc Sárai authored and aranyia committed Jul 9, 2024
1 parent 92de285 commit 29a1cc6
Show file tree
Hide file tree
Showing 39 changed files with 4,547 additions and 71 deletions.
7 changes: 6 additions & 1 deletion cmd/bee/cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
chaincfg "github.com/ethersphere/bee/v2/pkg/config"
"github.com/ethersphere/bee/v2/pkg/crypto"
"github.com/ethersphere/bee/v2/pkg/crypto/clef"
"github.com/ethersphere/bee/v2/pkg/dynamicaccess"
"github.com/ethersphere/bee/v2/pkg/keystore"
filekeystore "github.com/ethersphere/bee/v2/pkg/keystore/file"
memkeystore "github.com/ethersphere/bee/v2/pkg/keystore/mem"
Expand Down Expand Up @@ -293,7 +294,7 @@ func buildBeeNode(ctx context.Context, c *command, cmd *cobra.Command, logger lo
neighborhoodSuggester = c.config.GetString(optionNameNeighborhoodSuggester)
}

b, err := node.NewBee(ctx, c.config.GetString(optionNameP2PAddr), signerConfig.publicKey, signerConfig.signer, networkID, logger, signerConfig.libp2pPrivateKey, signerConfig.pssPrivateKey, &node.Options{
b, err := node.NewBee(ctx, c.config.GetString(optionNameP2PAddr), signerConfig.publicKey, signerConfig.signer, networkID, logger, signerConfig.libp2pPrivateKey, signerConfig.pssPrivateKey, signerConfig.session, &node.Options{
DataDir: c.config.GetString(optionNameDataDir),
CacheCapacity: c.config.GetUint64(optionNameCacheCapacity),
DBOpenFilesLimit: c.config.GetUint64(optionNameDBOpenFilesLimit),
Expand Down Expand Up @@ -373,6 +374,7 @@ type signerConfig struct {
publicKey *ecdsa.PublicKey
libp2pPrivateKey *ecdsa.PrivateKey
pssPrivateKey *ecdsa.PrivateKey
session dynamicaccess.Session
}

func waitForClef(logger log.Logger, maxRetries uint64, endpoint string) (externalSigner *external.ExternalSigner, err error) {
Expand Down Expand Up @@ -403,6 +405,7 @@ func (c *command) configureSigner(cmd *cobra.Command, logger log.Logger) (config
var signer crypto.Signer
var password string
var publicKey *ecdsa.PublicKey
var session dynamicaccess.Session
if p := c.config.GetString(optionNamePassword); p != "" {
password = p
} else if pf := c.config.GetString(optionNamePasswordFile); pf != "" {
Expand Down Expand Up @@ -475,6 +478,7 @@ func (c *command) configureSigner(cmd *cobra.Command, logger log.Logger) (config
}
signer = crypto.NewDefaultSigner(swarmPrivateKey)
publicKey = &swarmPrivateKey.PublicKey
session = dynamicaccess.NewDefaultSession(swarmPrivateKey)
}

logger.Info("swarm public key", "public_key", hex.EncodeToString(crypto.EncodeSecp256k1PublicKey(publicKey)))
Expand Down Expand Up @@ -513,6 +517,7 @@ func (c *command) configureSigner(cmd *cobra.Command, logger log.Logger) (config
publicKey: publicKey,
libp2pPrivateKey: libp2pPrivateKey,
pssPrivateKey: pssPrivateKey,
session: session,
}, nil
}

Expand Down
165 changes: 165 additions & 0 deletions openapi/Swarm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,135 @@ paths:
default:
description: Default response

"/grantee":
post:
summary: "Create grantee list"
tags:
- ACT
parameters:
- in: header
schema:
$ref: "SwarmCommon.yaml#/components/parameters/SwarmPostageBatchId"
name: swarm-postage-batch-id
required: true
- in: header
schema:
$ref: "SwarmCommon.yaml#/components/parameters/SwarmTagParameter"
name: swarm-tag
required: false
- in: header
schema:
$ref: "SwarmCommon.yaml#/components/parameters/SwarmPinParameter"
name: swarm-pin
required: false
- in: header
schema:
$ref: "SwarmCommon.yaml#/components/parameters/SwarmDeferredUpload"
name: swarm-deferred-upload
required: false
- in: header
schema:
$ref: "SwarmCommon.yaml#/components/parameters/SwarmActHistoryAddress"
name: swarm-act-history-address
required: false
requestBody:
required: true
content:
application/json:
schema:
$ref: "SwarmCommon.yaml#/components/schemas/ActGranteesCreateRequest"
responses:
"201":
description: Ok
content:
application/json:
schema:
$ref: "SwarmCommon.yaml#/components/schemas/ActGranteesOperationResponse"
"400":
$ref: "SwarmCommon.yaml#/components/responses/400"
"500":
$ref: "SwarmCommon.yaml#/components/responses/500"

"/grantee/{reference}":
get:
summary: "Get grantee list"
tags:
- ACT
parameters:
- in: path
name: reference
schema:
$ref: "SwarmCommon.yaml#/components/schemas/SwarmEncryptedReference"
required: true
description: Grantee list reference
responses:
"200":
description: Ok
content:
application/json:
schema:
type: array
items:
$ref: "SwarmCommon.yaml#/components/schemas/PublicKey"
"404":
$ref: "SwarmCommon.yaml#/components/responses/404"
"500":
$ref: "SwarmCommon.yaml#/components/responses/500"
patch:
summary: "Update grantee list"
description: "Add or remove grantees from an existing grantee list"
tags:
- ACT
parameters:
- in: path
name: reference
schema:
$ref: "SwarmCommon.yaml#/components/schemas/SwarmEncryptedReference"
required: true
description: Grantee list reference
- in: header
schema:
$ref: "SwarmCommon.yaml#/components/parameters/SwarmActHistoryAddress"
name: swarm-act-history-address
required: true
- in: header
schema:
$ref: "SwarmCommon.yaml#/components/parameters/SwarmPostageBatchId"
name: swarm-postage-batch-id
required: true
- in: header
schema:
$ref: "SwarmCommon.yaml#/components/parameters/SwarmTagParameter"
name: swarm-tag
required: false
- in: header
schema:
$ref: "SwarmCommon.yaml#/components/parameters/SwarmPinParameter"
name: swarm-pin
required: false
- in: header
schema:
$ref: "SwarmCommon.yaml#/components/parameters/SwarmDeferredUpload"
name: swarm-deferred-upload
required: false
requestBody:
required: true
content:
application/json:
schema:
$ref: "SwarmCommon.yaml#/components/schemas/ActGranteesPatchRequest"
responses:
"200":
description: Ok
content:
application/json:
schema:
$ref: "SwarmCommon.yaml#/components/schemas/ActGranteesOperationResponse"
"400":
$ref: "SwarmCommon.yaml#/components/responses/400"
"500":
$ref: "SwarmCommon.yaml#/components/responses/500"

"/bytes":
post:
summary: "Upload data"
Expand Down Expand Up @@ -167,6 +296,9 @@ paths:
- $ref: "SwarmCommon.yaml#/components/parameters/SwarmRedundancyStrategyParameter"
- $ref: "SwarmCommon.yaml#/components/parameters/SwarmRedundancyFallbackModeParameter"
- $ref: "SwarmCommon.yaml#/components/parameters/SwarmChunkRetrievalTimeoutParameter"
- $ref: "SwarmCommon.yaml#/components/parameters/SwarmActTimestamp"
- $ref: "SwarmCommon.yaml#/components/parameters/SwarmActPublisher"
- $ref: "SwarmCommon.yaml#/components/parameters/SwarmActHistoryAddress"
responses:
"200":
description: Retrieved content specified by reference
Expand All @@ -190,6 +322,9 @@ paths:
$ref: "SwarmCommon.yaml#/components/schemas/SwarmAddress"
required: true
description: Swarm address of chunk
- $ref: "SwarmCommon.yaml#/components/parameters/SwarmActTimestamp"
- $ref: "SwarmCommon.yaml#/components/parameters/SwarmActPublisher"
- $ref: "SwarmCommon.yaml#/components/parameters/SwarmActHistoryAddress"
responses:
"200":
description: Chunk exists
Expand All @@ -208,6 +343,8 @@ paths:
parameters:
- $ref: "SwarmCommon.yaml#/components/parameters/SwarmTagParameter"
- $ref: "SwarmCommon.yaml#/components/parameters/SwarmPostageBatchId"
- $ref: "SwarmCommon.yaml#/components/parameters/SwarmAct"
- $ref: "SwarmCommon.yaml#/components/parameters/SwarmActHistoryAddress"
requestBody:
description: Chunk binary data that has to have at least 8 bytes.
content:
Expand All @@ -223,6 +360,8 @@ paths:
description: Tag UID if it was passed to the request `swarm-tag` header.
schema:
$ref: "SwarmCommon.yaml#/components/schemas/Uid"
"swarm-act-history-address":
$ref: "SwarmCommon.yaml#/components/headers/SwarmActHistoryAddress"
content:
application/json:
schema:
Expand Down Expand Up @@ -279,6 +418,8 @@ paths:
- $ref: "SwarmCommon.yaml#/components/parameters/SwarmPostageBatchId"
- $ref: "SwarmCommon.yaml#/components/parameters/SwarmDeferredUpload"
- $ref: "SwarmCommon.yaml#/components/parameters/SwarmRedundancyLevelParameter"
- $ref: "SwarmCommon.yaml#/components/parameters/SwarmAct"
- $ref: "SwarmCommon.yaml#/components/parameters/SwarmActHistoryAddress"
requestBody:
content:
multipart/form-data:
Expand All @@ -305,6 +446,8 @@ paths:
$ref: "SwarmCommon.yaml#/components/headers/SwarmTag"
"etag":
$ref: "SwarmCommon.yaml#/components/headers/ETag"
"swarm-act-history-address":
$ref: "SwarmCommon.yaml#/components/headers/SwarmActHistoryAddress"
content:
application/json:
schema:
Expand Down Expand Up @@ -334,6 +477,9 @@ paths:
- $ref: "SwarmCommon.yaml#/components/parameters/SwarmRedundancyStrategyParameter"
- $ref: "SwarmCommon.yaml#/components/parameters/SwarmRedundancyFallbackModeParameter"
- $ref: "SwarmCommon.yaml#/components/parameters/SwarmChunkRetrievalTimeoutParameter"
- $ref: "SwarmCommon.yaml#/components/parameters/SwarmActTimestamp"
- $ref: "SwarmCommon.yaml#/components/parameters/SwarmActPublisher"
- $ref: "SwarmCommon.yaml#/components/parameters/SwarmActHistoryAddress"
responses:
"200":
description: Ok
Expand Down Expand Up @@ -363,6 +509,9 @@ paths:
$ref: "SwarmCommon.yaml#/components/schemas/SwarmAddress"
required: true
description: Swarm address of chunk
- $ref: "SwarmCommon.yaml#/components/parameters/SwarmActTimestamp"
- $ref: "SwarmCommon.yaml#/components/parameters/SwarmActPublisher"
- $ref: "SwarmCommon.yaml#/components/parameters/SwarmActHistoryAddress"
responses:
"200":
description: Chunk exists
Expand Down Expand Up @@ -749,6 +898,8 @@ paths:
$ref: "SwarmCommon.yaml#/components/parameters/SwarmPostageBatchId"
name: swarm-postage-batch-id
required: true
- $ref: "SwarmCommon.yaml#/components/parameters/SwarmAct"
- $ref: "SwarmCommon.yaml#/components/parameters/SwarmActHistoryAddress"
requestBody:
required: true
description: The SOC binary data is composed of the span (8 bytes) and the at most 4KB payload.
Expand All @@ -764,6 +915,9 @@ paths:
application/json:
schema:
$ref: "SwarmCommon.yaml#/components/schemas/ReferenceResponse"
headers:
"swarm-act-history-address":
$ref: "SwarmCommon.yaml#/components/headers/SwarmActHistoryAddress"
"400":
$ref: "SwarmCommon.yaml#/components/responses/400"
"401":
Expand Down Expand Up @@ -801,13 +955,18 @@ paths:
description: "Feed indexing scheme (default: sequence)"
- $ref: "SwarmCommon.yaml#/components/parameters/SwarmPinParameter"
- $ref: "SwarmCommon.yaml#/components/parameters/SwarmPostageBatchId"
- $ref: "SwarmCommon.yaml#/components/parameters/SwarmAct"
- $ref: "SwarmCommon.yaml#/components/parameters/SwarmActHistoryAddress"
responses:
"201":
description: Created
content:
application/json:
schema:
$ref: "SwarmCommon.yaml#/components/schemas/ReferenceResponse"
headers:
"swarm-act-history-address":
$ref: "SwarmCommon.yaml#/components/headers/SwarmActHistoryAddress"
"400":
$ref: "SwarmCommon.yaml#/components/responses/400"
"401":
Expand Down Expand Up @@ -1150,6 +1309,9 @@ paths:
$ref: "SwarmCommon.yaml#/components/parameters/SwarmCache"
name: swarm-cache
required: false
- $ref: "SwarmCommon.yaml#/components/parameters/SwarmActTimestamp"
- $ref: "SwarmCommon.yaml#/components/parameters/SwarmActPublisher"
- $ref: "SwarmCommon.yaml#/components/parameters/SwarmActHistoryAddress"
responses:
"200":
description: Retrieved chunk content
Expand Down Expand Up @@ -1177,6 +1339,9 @@ paths:
$ref: "SwarmCommon.yaml#/components/schemas/SwarmAddress"
required: true
description: Swarm address of chunk
- $ref: "SwarmCommon.yaml#/components/parameters/SwarmActTimestamp"
- $ref: "SwarmCommon.yaml#/components/parameters/SwarmActPublisher"
- $ref: "SwarmCommon.yaml#/components/parameters/SwarmActHistoryAddress"
responses:
"200":
description: Chunk exists
Expand Down
Loading

0 comments on commit 29a1cc6

Please sign in to comment.