Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

postage: add create endpoint #1142

Merged
merged 15 commits into from
Jan 26, 2021
Merged

postage: add create endpoint #1142

merged 15 commits into from
Jan 26, 2021

Conversation

ralph-pichler
Copy link
Member

@ralph-pichler ralph-pichler commented Jan 21, 2021

adds the /stamps/{amount}/{depth} endpoint where amount is the initial balance per chunk.

related changes:

  • chainId is now always queried when not running in standalone. even with swap disabled swap-endpoint is required.
  • swap is always disabled in standalone, even if swap is explicitly enabled

open issues:

  • currently postage stamps don't work at all with swap disabled as the token address is queried through the swap factory. this is only an issue if not standalone and --swap-enable=false.
  • package naming could be improved
  • bucketDepth is set incorrectly

@ralph-pichler ralph-pichler changed the title add create endpoint postage: add create endpoint Jan 21, 2021
Copy link
Member

@acud acud left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor comments. otherwise looks good

pkg/api/postage.go Show resolved Hide resolved
pkg/api/postage.go Outdated Show resolved Hide resolved
pkg/postage/postagecontract/contract.go Show resolved Hide resolved
batchID := createdEvent.BatchId[:]

c.postageService.Add(postage.NewStampIssuer(
"label",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zelig please elaborate what these are for and if we should even set them now

Copy link
Member

@zelig zelig Jan 26, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, please set them via query param and/or form-data .
They are meeant to support 2 dimensional classification of stamps.
The UX presented in the book can then be simply supported from js side,
https://gateway.ethswarm.org/bzz/latest.bookofswarm.eth/#subsection.6.1.3
with label being generated from:

*minimal (a few hours)– Useful for immediate delivery of pss messages or singleowner chunks part of ephemeral chat or other temporary files.
•temporary (week)– Files or mailboxed messages meant not to be stored long butto be picked up by third parties asynchronously.
•long term (year)– Default long term storage.
•forever (10years)– Important content not to be lost/forgotten; to survive thegrowth of the network and subsequent increase of batch depth even if theuploader remains completely offline.

and batch reuse strategy maybe

"keyid" can be recorded as the batch owner etheraddress that would be used to call the appropriate signer with the right batch owner key.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

label query param added. keyID is hex representation of owner address.

pkg/postage/postagecontract/contract.go Outdated Show resolved Hide resolved
pkg/postage/postagecontract/contract.go Show resolved Hide resolved
Copy link
Member

@acud acud left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one more thing - we should have an api test that covers this new endpoint - injecting a mock Interface and asserting it was called (or not) given different parameters.

@ralph-pichler
Copy link
Member Author

@acud basic api test added. which cases should we test here?

@ralph-pichler ralph-pichler marked this pull request as ready for review January 22, 2021 10:45
pkg/api/postage.go Show resolved Hide resolved
pkg/api/postage.go Outdated Show resolved Hide resolved
pkg/api/postage.go Outdated Show resolved Hide resolved
pkg/api/postage.go Outdated Show resolved Hide resolved
pkg/api/postage_test.go Outdated Show resolved Hide resolved
pkg/api/postage.go Outdated Show resolved Hide resolved
pkg/node/node.go Outdated Show resolved Hide resolved
pkg/node/node.go Outdated Show resolved Hide resolved

var postageContractService postagecontract.Interface
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some TLC to naming here please.. i got no better idea though

pkg/postage/postagecontract/contract.go Show resolved Hide resolved
) Interface {
return &postageContract{
owner: owner,
postageStampAddress: postageStampAddress,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the contract address no? please do not call it stamp address

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


var postageContractService postagecontract.Interface
if !o.Standalone {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

postageStampAddress is a misnomer below

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the contract is actually called PostageStamp. For now I went with postageContractAddress. We should also change the flag which currently is --postage-stamp-address but we should reach a decision on naming first as changing that also means changing the helm chart.


type batchCreatedEvent struct {
BatchId [32]byte
TotalAmount *big.Int
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets have one value called Value ok?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these names need to exactly match the contract names as the parser uses reflection underneath.

postageMock "github.com/ethersphere/bee/pkg/postage/mock"
"github.com/ethersphere/bee/pkg/postage/postagecontract"
"github.com/ethersphere/bee/pkg/settlement/swap/transaction"
transactionMock "github.com/ethersphere/bee/pkg/settlement/swap/transaction/mock"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

time to move transaction pkg out of swap

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed, but let's please do code moves in a separate PR after this

Copy link
Member

@acud acud left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ralph-pichler ralph-pichler merged commit 3e123b5 into storage-incentives Jan 26, 2021
@ralph-pichler ralph-pichler deleted the postage_api branch January 26, 2021 15:07
acud pushed a commit that referenced this pull request Jan 27, 2021
acud pushed a commit that referenced this pull request Feb 1, 2021
acud pushed a commit that referenced this pull request Feb 3, 2021
acud pushed a commit that referenced this pull request Feb 9, 2021
acud added a commit that referenced this pull request Apr 13, 2021
postage: new pkg for postage stamps, uploader stamping (#890)

* postage: new pkg for postage stamps, uploader stamping

* postage: amount->value, blockNumber big.Int-> uint64, stamp only has batch ID, not Batch

* postage: fix godoc and copyright

* postage, swarm:
 - swarm.Stamp as an interface
 - add postage/testing for mock Stamps
 - fix Stamp MarshalBinary to allow nil batch id and signature
 - add StampSize const

* postage: heed review feedback

Co-authored-by: acud <12988138+acud@users.noreply.github.com>

Storage incentives: add stamper putter to api

Postage BatchStore and BatchService (#1070)

Co-authored-by: zelig <viktor.tron@gmail.com>

add normalisedBalance to updater interface (#1108)

make value the normalised balance (#1111)

postage: add event listener (#1099)

Wire up postage stamp syncing (#1114)

localstore, shed: persist stamps (#1116)

add --postage to beeinfra.sh setup

pullsync, pushsync: add postage stamps (#1117)

postage: add create endpoint (#1142)

retrieve erc20 address from postage contract (#1169)

postage: check balance before attempting stamp creation (#1177)

postage: fix bucket depth (#1178)

api: use hex encoding in postage api (#1179)

increase page size (#1182)

postage: handle bucket depth error in api (#1183)

localstore: attach stamp to outgoing chunk (#1192)

update postage stamp contract addresses for new token (#1208)

batchstore: reserve (#1262)

* postage/batchstore: reserve logic

Co-authored-by: acud <12988138+acud@users.noreply.github.com>

stamp support in storage and protocols (#1321)

api: endpoints for stamp issuers (#1535)

retrieval: add stamps (#1552)

localstore reserve logic (#1322)

Co-authored-by: acud <12988138+acud@users.noreply.github.com>
acud added a commit that referenced this pull request Apr 15, 2021
postage: new pkg for postage stamps, uploader stamping (#890)

* postage: new pkg for postage stamps, uploader stamping

* postage: amount->value, blockNumber big.Int-> uint64, stamp only has batch ID, not Batch

* postage: fix godoc and copyright

* postage, swarm:
 - swarm.Stamp as an interface
 - add postage/testing for mock Stamps
 - fix Stamp MarshalBinary to allow nil batch id and signature
 - add StampSize const

* postage: heed review feedback

Co-authored-by: acud <12988138+acud@users.noreply.github.com>

Storage incentives: add stamper putter to api

Postage BatchStore and BatchService (#1070)

Co-authored-by: zelig <viktor.tron@gmail.com>

add normalisedBalance to updater interface (#1108)

make value the normalised balance (#1111)

postage: add event listener (#1099)

Wire up postage stamp syncing (#1114)

localstore, shed: persist stamps (#1116)

add --postage to beeinfra.sh setup

pullsync, pushsync: add postage stamps (#1117)

postage: add create endpoint (#1142)

retrieve erc20 address from postage contract (#1169)

postage: check balance before attempting stamp creation (#1177)

postage: fix bucket depth (#1178)

api: use hex encoding in postage api (#1179)

increase page size (#1182)

postage: handle bucket depth error in api (#1183)

localstore: attach stamp to outgoing chunk (#1192)

update postage stamp contract addresses for new token (#1208)

batchstore: reserve (#1262)

* postage/batchstore: reserve logic

Co-authored-by: acud <12988138+acud@users.noreply.github.com>

stamp support in storage and protocols (#1321)

api: endpoints for stamp issuers (#1535)

retrieval: add stamps (#1552)

localstore reserve logic (#1322)

Co-authored-by: acud <12988138+acud@users.noreply.github.com>
acud added a commit that referenced this pull request Apr 26, 2021
postage: new pkg for postage stamps, uploader stamping (#890)

* postage: new pkg for postage stamps, uploader stamping

* postage: amount->value, blockNumber big.Int-> uint64, stamp only has batch ID, not Batch

* postage: fix godoc and copyright

* postage, swarm:
 - swarm.Stamp as an interface
 - add postage/testing for mock Stamps
 - fix Stamp MarshalBinary to allow nil batch id and signature
 - add StampSize const

* postage: heed review feedback

Co-authored-by: acud <12988138+acud@users.noreply.github.com>

Storage incentives: add stamper putter to api

Postage BatchStore and BatchService (#1070)

Co-authored-by: zelig <viktor.tron@gmail.com>

add normalisedBalance to updater interface (#1108)

make value the normalised balance (#1111)

postage: add event listener (#1099)

Wire up postage stamp syncing (#1114)

localstore, shed: persist stamps (#1116)

add --postage to beeinfra.sh setup

pullsync, pushsync: add postage stamps (#1117)

postage: add create endpoint (#1142)

retrieve erc20 address from postage contract (#1169)

postage: check balance before attempting stamp creation (#1177)

postage: fix bucket depth (#1178)

api: use hex encoding in postage api (#1179)

increase page size (#1182)

postage: handle bucket depth error in api (#1183)

localstore: attach stamp to outgoing chunk (#1192)

update postage stamp contract addresses for new token (#1208)

batchstore: reserve (#1262)

* postage/batchstore: reserve logic

Co-authored-by: acud <12988138+acud@users.noreply.github.com>

stamp support in storage and protocols (#1321)

api: endpoints for stamp issuers (#1535)

retrieval: add stamps (#1552)

localstore reserve logic (#1322)

Co-authored-by: acud <12988138+acud@users.noreply.github.com>
acud added a commit that referenced this pull request Apr 27, 2021
postage: new pkg for postage stamps, uploader stamping (#890)

* postage: new pkg for postage stamps, uploader stamping

* postage: amount->value, blockNumber big.Int-> uint64, stamp only has batch ID, not Batch

* postage: fix godoc and copyright

* postage, swarm:
 - swarm.Stamp as an interface
 - add postage/testing for mock Stamps
 - fix Stamp MarshalBinary to allow nil batch id and signature
 - add StampSize const

* postage: heed review feedback

Co-authored-by: acud <12988138+acud@users.noreply.github.com>

Storage incentives: add stamper putter to api

Postage BatchStore and BatchService (#1070)

Co-authored-by: zelig <viktor.tron@gmail.com>

add normalisedBalance to updater interface (#1108)

make value the normalised balance (#1111)

postage: add event listener (#1099)

Wire up postage stamp syncing (#1114)

localstore, shed: persist stamps (#1116)

add --postage to beeinfra.sh setup

pullsync, pushsync: add postage stamps (#1117)

postage: add create endpoint (#1142)

retrieve erc20 address from postage contract (#1169)

postage: check balance before attempting stamp creation (#1177)

postage: fix bucket depth (#1178)

api: use hex encoding in postage api (#1179)

increase page size (#1182)

postage: handle bucket depth error in api (#1183)

localstore: attach stamp to outgoing chunk (#1192)

update postage stamp contract addresses for new token (#1208)

batchstore: reserve (#1262)

* postage/batchstore: reserve logic

Co-authored-by: acud <12988138+acud@users.noreply.github.com>

stamp support in storage and protocols (#1321)

api: endpoints for stamp issuers (#1535)

retrieval: add stamps (#1552)

localstore reserve logic (#1322)

Co-authored-by: acud <12988138+acud@users.noreply.github.com>
acud added a commit that referenced this pull request Apr 27, 2021
postage: new pkg for postage stamps, uploader stamping (#890)

* postage: new pkg for postage stamps, uploader stamping

* postage: amount->value, blockNumber big.Int-> uint64, stamp only has batch ID, not Batch

* postage: fix godoc and copyright

* postage, swarm:
 - swarm.Stamp as an interface
 - add postage/testing for mock Stamps
 - fix Stamp MarshalBinary to allow nil batch id and signature
 - add StampSize const

* postage: heed review feedback

Co-authored-by: acud <12988138+acud@users.noreply.github.com>

Storage incentives: add stamper putter to api

Postage BatchStore and BatchService (#1070)

Co-authored-by: zelig <viktor.tron@gmail.com>

add normalisedBalance to updater interface (#1108)

make value the normalised balance (#1111)

postage: add event listener (#1099)

Wire up postage stamp syncing (#1114)

localstore, shed: persist stamps (#1116)

add --postage to beeinfra.sh setup

pullsync, pushsync: add postage stamps (#1117)

postage: add create endpoint (#1142)

retrieve erc20 address from postage contract (#1169)

postage: check balance before attempting stamp creation (#1177)

postage: fix bucket depth (#1178)

api: use hex encoding in postage api (#1179)

increase page size (#1182)

postage: handle bucket depth error in api (#1183)

localstore: attach stamp to outgoing chunk (#1192)

update postage stamp contract addresses for new token (#1208)

batchstore: reserve (#1262)

* postage/batchstore: reserve logic

Co-authored-by: acud <12988138+acud@users.noreply.github.com>

stamp support in storage and protocols (#1321)

api: endpoints for stamp issuers (#1535)

retrieval: add stamps (#1552)

localstore reserve logic (#1322)

Co-authored-by: acud <12988138+acud@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants