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

Create payload disperser #1159

Merged
merged 25 commits into from
Jan 29, 2025
Merged

Create payload disperser #1159

merged 25 commits into from
Jan 29, 2025

Conversation

litt3
Copy link
Contributor

@litt3 litt3 commented Jan 24, 2025

Why are these changes needed?

  • This PR implements the PUT side of the v2 client
  • In service of expediency in getting this PayloadDispersal API merged, I've decided to defer writing unit tests until a future PR
    • integration tests will provide better coverage anyway
    • I want to get this up for review ASAP, since @EthenNotEthan is starting with proxy integration, and it would be nice to have basic APIs set
    • I may end up adding some unit tests before this PR merges after all, depending on how long the review process stretches

Checks

  • I've made sure the tests are passing. Note that there might be a few flaky tests, in that case, please comment that they are not relevant.
  • I've checked the new test coverage and the coverage percentage didn't drop.
  • Testing Strategy
    • Unit tests
    • Integration tests
    • This PR is not tested :(

litt3 added 2 commits January 24, 2025 14:35
Signed-off-by: litt3 <[email protected]>
@litt3 litt3 self-assigned this Jan 24, 2025
@litt3 litt3 marked this pull request as ready for review January 24, 2025 21:21
api/clients/codecs/blob_codec.go Show resolved Hide resolved
api/clients/v2/payload_disperser.go Outdated Show resolved Hide resolved
api/clients/v2/payload_disperser.go Show resolved Hide resolved
api/clients/v2/payload_disperser.go Outdated Show resolved Hide resolved
api/clients/v2/payload_disperser.go Outdated Show resolved Hide resolved
api/clients/v2/payload_client_config.go Outdated Show resolved Hide resolved
PayloadPolynomialForm codecs.PolynomialForm

// The timeout duration for contract calls
ContractCallTimeout time.Duration
Copy link
Contributor

Choose a reason for hiding this comment

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

prob should mention a default. Typically I define a defaultPayloadClientConfig struct with the default values, and assign those in the constructor for any value that wasn't set.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it might be worth adding some guidelines for configuration classes to the style guide.

Copy link
Contributor Author

@litt3 litt3 Jan 27, 2025

Choose a reason for hiding this comment

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

@samlaf Could you clarify what config architecture you're proposing here? Creating a constructor for the struct? Creating a method which checks and sets missing defaults?

Copy link
Contributor

Choose a reason for hiding this comment

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

Added TODO for me to add this to style guide: #1137 (comment)

In terms of my personal preference, I like:

  • no constructor for config structs (that's very much against the point of having extendability, which requires using go's default zero value initialization)
  • having the constructor validate the config and inject default values over zero values (note: this requires care that zero values are always meaningless, which is not always the case!)
  • validation + injecting defualt values can be part of a separate function if it's a large config struct that would overwhelm the rest of constructor logic

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no constructor for config structs (that's very much against the point of having extendability, which requires using go's default zero value initialization)

Could you explain what you mean by this? What's the problem with having a constructor for ConfigA, and if ConfigA extends ConfigB, call the constructor for ConfigB in the constructor of ConfigA?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I created some config utilities in 959e4564. LMK what you think

Copy link
Contributor

Choose a reason for hiding this comment

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

LGTM! Having a default constructor is totally fine, and is actually a good idea! What I meant is that users shouldn't be constructing the config by using a constructor of the type

func NewConfig(fieldA, fieldB, fieldC, fieldD,...) Config {
   return Config{
      fieldA,
      fieldB,
      ...
      }
}

Because this is dumb

api/clients/v2/payload_disperser.go Outdated Show resolved Hide resolved
api/clients/v2/payload_disperser.go Outdated Show resolved Hide resolved
api/clients/v2/payload_disperser.go Show resolved Hide resolved
api/clients/v2/payload_disperser.go Outdated Show resolved Hide resolved
api/clients/v2/payload_retriever_config.go Outdated Show resolved Hide resolved
api/clients/v2/verification/eigenda_cert.go Outdated Show resolved Hide resolved
api/clients/v2/payload_disperser.go Outdated Show resolved Hide resolved
api/clients/v2/payload_disperser.go Show resolved Hide resolved
Comment on lines +194 to +195
// This call to the disperser doesn't have a dedicated timeout configured.
// If this call fails to return in a timely fashion, the timeout configured for the poll loop will trigger
Copy link
Contributor

Choose a reason for hiding this comment

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

is this actually true?

Copy link
Contributor Author

@litt3 litt3 Jan 27, 2025

Choose a reason for hiding this comment

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

There is a timeout set on the context being passed into pollBlobStatusUntilCertified.

If that timeout triggers, it will abort this GetBlobStatus call if necessary, and abort the polling loop, right?

previousStatus = newStatus
}

switch newStatus {
Copy link
Contributor

Choose a reason for hiding this comment

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

let's add a TODO specifying that we'll need to add more in-depth response status processing to derive failover errors

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure I understand what you mean by "derive failover errors".

Do you mean we will need to expand the types of status returned from the top level SendPayload method, beyond what's included in the existing BlobStatus enum?

Copy link
Contributor

@ethenotethan ethenotethan Jan 27, 2025

Choose a reason for hiding this comment

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

so we'll need to interpret terminal status status in a meaningful way to map them into a failover error which tells the proxy to return a status 503 response which a rollup batcher can interpret as "go use other DA"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm. Is it not true that any error in dispersal would require resorting to failover? If not, what class of error would you expect to not result in failover, and what would be the strategy to handle it? Retries? (trying to understand likely outcomes, to be able to write a helpful TODO)

Copy link
Contributor

Choose a reason for hiding this comment

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

we already have a strategy or framework in-place for this that we can extend from. Would recommend just adding a general todo vs re-articulating a methodology that was months of research

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added the TODO

api/clients/v2/verification/cert_verifier.go Outdated Show resolved Hide resolved
api/clients/v2/payload_disperser.go Outdated Show resolved Hide resolved
api/clients/v2/payload_client_config.go Outdated Show resolved Hide resolved
api/clients/v2/payload_client_config.go Outdated Show resolved Hide resolved
api/clients/v2/payload_client_config.go Outdated Show resolved Hide resolved
api/clients/v2/payload_disperser.go Outdated Show resolved Hide resolved
api/clients/v2/payload_disperser.go Outdated Show resolved Hide resolved
@samlaf samlaf mentioned this pull request Jan 27, 2025
5 tasks
Signed-off-by: litt3 <[email protected]>
Copy link
Contributor

@samlaf samlaf left a comment

Choose a reason for hiding this comment

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

The changes that I had requested have been made, so approving.

Copy link
Contributor

@ethenotethan ethenotethan left a comment

Choose a reason for hiding this comment

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

LGTM

@litt3 litt3 merged commit aed7735 into Layr-Labs:master Jan 29, 2025
8 checks passed
@litt3 litt3 deleted the payload-disperser branch January 29, 2025 22:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants