bnb-chain / BEPs

BNB Evolution Proposals
832 stars 558 forks source link

BEP-366: Atomic object update #346

Closed alexgao001 closed 8 months ago

alexgao001 commented 10 months ago
  BEP: 366
  Title: Greenfield Atomic Object Update
  Status: Under progress
  Type: Standards
  Created: 2024-01-18

BEP-366: Greenfield Atomic Object Update

1. Summary

This proposal seeks to enhance the efficiency and reliability of object modifications in the Greenfield network by introducing atomic object updates. This update will improve the management of objects in Greenfield by ensuring atomicity, and consistency.

2. Motivation

Currently, users face the inconvenience of having to delete and recreate objects in Greenfield in order to replace their content. This process results in the updated object being assigned a new ID, causing associated policies to be lost since they are based on object ID. This restriction also applies to Resource Mirror. Consequently, users are required to re-enforce policies and re-trigger mirroring on the updated object if they had previously done so. The proposed solution aims to address these issues and offer a more efficient and seamless object update process.

3. Status

This BEP is under progress

4. Specification

4.1 Requirements

4.2 Implementation

4.2.1. Change To Current Model

4.2.1. New Model And Message

4.3 Workflow

The steps to update an object are illustrated below. To users, it is similar when compared to the current create-upload object process.

workflow
  1. Users send the transaction to Greenfield with the message MsgUpdateObjectContent. This stores the updated object metadata via shadowObjectInfo and flags the object as updating without changing the objectInfo on-chain.

  2. Users upload the updated object to the primary SP. The SP will validate if the object can be updated and authenticate the user's account permission.

  3. The SP should keep the original and updated object data simultaneously. Version in ObjectInfo or ShadowObjectInfo is also used to identify the object data persistence to ensure there is no conflict. Users should be able to GET the original object data at this moment as the version field has not changed.

  4. The primary SP sends the sealing object transaction to the Greenfield blockchain, changes to objectInfo will take effect according to meta stored in shadowObjectInfo with version increment. Users will be able to GET the updated object data. In the case where SP fails to seal the object after retries, it would send tx RejectSealobject to Greenfield to reject the users request. The metadata ShadowObjectInfo will be removed from chain, updated object data will be removed from SP.

4.4 Fees & User Charges

The current policy regarding user charges is as follows: When users create and upload an object, a minimum of 6 months storage fee is reserved on Greenfield. This fee is then paid to the Storage Providers' accounts through stream payment. If objects are stored for more than 6 months, the storage fee will be calculated based on the actual time. This rule applies to updating objects as well. When users update an object, Greenfield will deduct the payment for the original object from users’s account and reserve at least 6 months of storage fee for the updated object, taking into account the new object size. It's important for users to be aware that each time an object is updated, there will be associated costs.

5. License

The content is licensed under CC0.