Skip to content

Commit

Permalink
Merge pull request #5993 from onflow/bastian/update-atree-inlining-ca…
Browse files Browse the repository at this point in the history
…dence-v1.0-7
  • Loading branch information
turbolent authored May 29, 2024
2 parents 0ced3b1 + 9349bd1 commit 9506c3c
Show file tree
Hide file tree
Showing 135 changed files with 3,650 additions and 1,981 deletions.
1 change: 1 addition & 0 deletions access/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ type API interface {
GetBlockByID(ctx context.Context, id flow.Identifier) (*flow.Block, flow.BlockStatus, error)

GetCollectionByID(ctx context.Context, id flow.Identifier) (*flow.LightCollection, error)
GetFullCollectionByID(ctx context.Context, id flow.Identifier) (*flow.Collection, error)

SendTransaction(ctx context.Context, tx *flow.TransactionBody) error
GetTransaction(ctx context.Context, id flow.Identifier) (*flow.TransactionBody, error)
Expand Down
27 changes: 27 additions & 0 deletions access/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,33 @@ func (h *Handler) GetCollectionByID(
}, nil
}

func (h *Handler) GetFullCollectionByID(
ctx context.Context,
req *access.GetFullCollectionByIDRequest,
) (*access.FullCollectionResponse, error) {
metadata := h.buildMetadataResponse()

id, err := convert.CollectionID(req.GetId())
if err != nil {
return nil, status.Errorf(codes.InvalidArgument, "invalid collection id: %v", err)
}

col, err := h.api.GetFullCollectionByID(ctx, id)
if err != nil {
return nil, err
}

transactions, err := convert.FullCollectionToMessage(col)
if err != nil {
return nil, status.Error(codes.Internal, err.Error())
}

return &access.FullCollectionResponse{
Transactions: transactions,
Metadata: metadata,
}, nil
}

// SendTransaction submits a transaction to the network.
func (h *Handler) SendTransaction(
ctx context.Context,
Expand Down
26 changes: 26 additions & 0 deletions access/mock/api.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion cmd/bootstrap/cmd/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func constructRootBlock(rootHeader *flow.Header, setup *flow.EpochSetup, commit
Receipts: nil,
Results: nil,
// TODO: shortcut in bootstrapping; we will probably have to start with a non-empty KV store in the future
ProtocolStateID: kvstore.NewDefaultKVStore(inmem.ProtocolStateFromEpochServiceEvents(setup, commit).ID()).ID(),
ProtocolStateID: kvstore.NewDefaultKVStore(inmem.EpochProtocolStateFromServiceEvents(setup, commit).ID()).ID(),
})
return block
}
Expand Down
5 changes: 3 additions & 2 deletions cmd/bootstrap/cmd/partner_infos.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/onflow/flow-go/model/bootstrap"
"github.com/onflow/flow-go/model/encodable"
"github.com/onflow/flow-go/model/flow"
"github.com/onflow/flow-go/module/grpcclient"
)

const (
Expand Down Expand Up @@ -117,12 +118,12 @@ func getFlowClient() *client.Client {
insecureClient = false
}

config, err := common.NewFlowClientConfig(flagANAddress, strings.TrimPrefix(flagANNetworkKey, "0x"), flow.ZeroID, insecureClient)
config, err := grpcclient.NewFlowClientConfig(flagANAddress, strings.TrimPrefix(flagANNetworkKey, "0x"), flow.ZeroID, insecureClient)
if err != nil {
log.Fatal().Err(err).Msgf("could not get flow client config with address (%s) and network key (%s)", flagANAddress, flagANNetworkKey)
}

flowClient, err := common.FlowClient(config)
flowClient, err := grpcclient.FlowClient(config)
if err != nil {
log.Fatal().Err(err).Msgf("could not get flow client with address (%s) and network key (%s)", flagANAddress, flagANNetworkKey)
}
Expand Down
11 changes: 6 additions & 5 deletions cmd/collection/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import (
modulecompliance "github.com/onflow/flow-go/module/compliance"
"github.com/onflow/flow-go/module/epochs"
confinalizer "github.com/onflow/flow-go/module/finalizer/consensus"
"github.com/onflow/flow-go/module/grpcclient"
"github.com/onflow/flow-go/module/mempool"
epochpool "github.com/onflow/flow-go/module/mempool/epochs"
"github.com/onflow/flow-go/module/mempool/herocache"
Expand Down Expand Up @@ -98,7 +99,7 @@ func main() {

// epoch qc contract client
machineAccountInfo *bootstrap.NodeMachineAccountInfo
flowClientConfigs []*common.FlowClientConfig
flowClientConfigs []*grpcclient.FlowClientConfig
insecureAccessAPI bool
accessNodeIDS []string
apiRatelimits map[string]int
Expand Down Expand Up @@ -284,7 +285,7 @@ func main() {
return fmt.Errorf("failed to validate flag --access-node-ids %w", err)
}

flowClientConfigs, err = common.FlowClientConfigs(anIDS, insecureAccessAPI, node.State.Sealed())
flowClientConfigs, err = grpcclient.FlowClientConfigs(anIDS, insecureAccessAPI, node.State.Sealed())
if err != nil {
return fmt.Errorf("failed to prepare flow client connection configs for each access node id %w", err)
}
Expand All @@ -293,7 +294,7 @@ func main() {
}).
Component("machine account config validator", func(node *cmd.NodeConfig) (module.ReadyDoneAware, error) {
// @TODO use fallback logic for flowClient similar to DKG/QC contract clients
flowClient, err := common.FlowClient(flowClientConfigs[0])
flowClient, err := grpcclient.FlowClient(flowClientConfigs[0])
if err != nil {
return nil, fmt.Errorf("failed to get flow client connection option for access node (0): %s %w", flowClientConfigs[0].AccessAddress, err)
}
Expand Down Expand Up @@ -682,11 +683,11 @@ func createQCContractClient(node *cmd.NodeConfig, machineAccountInfo *bootstrap.
}

// createQCContractClients creates priority ordered array of QCContractClient
func createQCContractClients(node *cmd.NodeConfig, machineAccountInfo *bootstrap.NodeMachineAccountInfo, flowClientOpts []*common.FlowClientConfig) ([]module.QCContractClient, error) {
func createQCContractClients(node *cmd.NodeConfig, machineAccountInfo *bootstrap.NodeMachineAccountInfo, flowClientOpts []*grpcclient.FlowClientConfig) ([]module.QCContractClient, error) {
qcClients := make([]module.QCContractClient, 0)

for _, opt := range flowClientOpts {
flowClient, err := common.FlowClient(opt)
flowClient, err := grpcclient.FlowClient(opt)
if err != nil {
return nil, fmt.Errorf("failed to create flow client for qc contract client with options: %s %w", flowClientOpts, err)
}
Expand Down
13 changes: 7 additions & 6 deletions cmd/consensus/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import (
dkgmodule "github.com/onflow/flow-go/module/dkg"
"github.com/onflow/flow-go/module/epochs"
finalizer "github.com/onflow/flow-go/module/finalizer/consensus"
"github.com/onflow/flow-go/module/grpcclient"
"github.com/onflow/flow-go/module/mempool"
consensusMempools "github.com/onflow/flow-go/module/mempool/consensus"
"github.com/onflow/flow-go/module/mempool/stdmap"
Expand Down Expand Up @@ -99,7 +100,7 @@ func main() {

// DKG contract client
machineAccountInfo *bootstrap.NodeMachineAccountInfo
flowClientConfigs []*common.FlowClientConfig
flowClientConfigs []*grpcclient.FlowClientConfig
insecureAccessAPI bool
accessNodeIDS []string

Expand Down Expand Up @@ -408,7 +409,7 @@ func main() {
return fmt.Errorf("failed to validate flag --access-node-ids %w", err)
}

flowClientConfigs, err = common.FlowClientConfigs(anIDS, insecureAccessAPI, node.State.Sealed())
flowClientConfigs, err = grpcclient.FlowClientConfigs(anIDS, insecureAccessAPI, node.State.Sealed())
if err != nil {
return fmt.Errorf("failed to prepare flow client connection configs for each access node id %w", err)
}
Expand All @@ -417,7 +418,7 @@ func main() {
}).
Component("machine account config validator", func(node *cmd.NodeConfig) (module.ReadyDoneAware, error) {
// @TODO use fallback logic for flowClient similar to DKG/QC contract clients
flowClient, err := common.FlowClient(flowClientConfigs[0])
flowClient, err := grpcclient.FlowClient(flowClientConfigs[0])
if err != nil {
return nil, fmt.Errorf("failed to get flow client connection option for access node (0): %s %w", flowClientConfigs[0].AccessAddress, err)
}
Expand Down Expand Up @@ -716,7 +717,7 @@ func main() {
}).
Component("consensus participant", func(node *cmd.NodeConfig) (module.ReadyDoneAware, error) {
mutableProtocolState := protocol_state.NewMutableProtocolState(
node.Storage.EpochProtocolState,
node.Storage.EpochProtocolStateEntries,
node.Storage.ProtocolKVStore,
node.State.Params(),
node.Storage.Headers,
Expand Down Expand Up @@ -981,11 +982,11 @@ func createDKGContractClient(node *cmd.NodeConfig, machineAccountInfo *bootstrap
}

// createDKGContractClients creates an array dkgContractClient that is sorted by retry fallback priority
func createDKGContractClients(node *cmd.NodeConfig, machineAccountInfo *bootstrap.NodeMachineAccountInfo, flowClientOpts []*common.FlowClientConfig) ([]module.DKGContractClient, error) {
func createDKGContractClients(node *cmd.NodeConfig, machineAccountInfo *bootstrap.NodeMachineAccountInfo, flowClientOpts []*grpcclient.FlowClientConfig) ([]module.DKGContractClient, error) {
dkgClients := make([]module.DKGContractClient, 0)

for _, opt := range flowClientOpts {
flowClient, err := common.FlowClient(opt)
flowClient, err := grpcclient.FlowClient(opt)
if err != nil {
return nil, fmt.Errorf("failed to create flow client for dkg contract client with options: %s %w", flowClientOpts, err)
}
Expand Down
5 changes: 3 additions & 2 deletions cmd/dynamic_startup.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/onflow/flow-go/cmd/util/cmd/common"
"github.com/onflow/flow-go/model/bootstrap"
"github.com/onflow/flow-go/model/flow"
"github.com/onflow/flow-go/module/grpcclient"
"github.com/onflow/flow-go/state/protocol"
badgerstate "github.com/onflow/flow-go/state/protocol/badger"
utilsio "github.com/onflow/flow-go/utils/io"
Expand Down Expand Up @@ -92,11 +93,11 @@ func DynamicStartPreInit(nodeConfig *NodeConfig) error {
// CASE 2.2: Use Dynamic Startup to bootstrap.

// get flow client with secure client connection to download protocol snapshot from access node
config, err := common.NewFlowClientConfig(nodeConfig.DynamicStartupANAddress, nodeConfig.DynamicStartupANPubkey, flow.ZeroID, false)
config, err := grpcclient.NewFlowClientConfig(nodeConfig.DynamicStartupANAddress, nodeConfig.DynamicStartupANPubkey, flow.ZeroID, false)
if err != nil {
return fmt.Errorf("failed to create flow client config for node dynamic startup pre-init: %w", err)
}
flowClient, err := common.FlowClient(config)
flowClient, err := grpcclient.FlowClient(config)
if err != nil {
return fmt.Errorf("failed to create flow client for node dynamic startup pre-init: %w", err)
}
Expand Down
Loading

0 comments on commit 9506c3c

Please sign in to comment.