refactor: use scheduler quotes for signing - #1125
Conversation
| {error, | ||
| #{ | ||
| <<"status">> := 422, | ||
| <<"require-codec">> := <<"tx@1.0">>, |
There was a problem hiding this comment.
Any reason not to just return the message with the commitment-spec already at the outer wrapper? I think you can also just say field-reward and maybe field-anchor, which the tx@1.0 device will already pick up and honor in the correct place.
| <<"require-codec">> := <<"tx@1.0">>, | ||
| <<"commitment-spec">> := #{ | ||
| <<"commitment-device">> := <<"tx@1.0">>, | ||
| <<"tx-header">> := #{ |
There was a problem hiding this comment.
Hopefully the above would render the tx-header here unnecessary -- we just take the result and hb_message:commit(MsgToAssign, QuoteRes, Opts)?
| {error, | ||
| #{ | ||
| <<"status">> := 422, | ||
| <<"require-codec">> := <<"tx@1.0">>, |
There was a problem hiding this comment.
Comment ordering is getting crazy here, but if we do the other two comments in this zone, then I think require-codec can essentially be removed from the downgrade path. That might require some tweaks elsewhere but should be contained if so. Benefit is that the response is a straightforward commitment spec we can just hb_message:commit with
There was a problem hiding this comment.
agreed 100%, great points, working on it!
| NormMsg = normalize_message(AugmentedMsg, Opts), | ||
| SignedNormMsg = sign_result(NormMsg, TargetProcess, Codec, Opts), | ||
| NormMsg = normalize_message(MsgToPush, Opts), | ||
| SignedNormMsg = apply_security( |
| hb_ao:resolve( | ||
| {as, <<"process@1.0">>, TargetProcess}, | ||
| #{ <<"path">> => <<"as">>, <<"as">> => <<"scheduler">> }, | ||
| QuoteOpts | ||
| ), |
There was a problem hiding this comment.
This is making me lean more towards using just HEAD /schedule for that call? Then your whole flow here (including the device info part) is just HEAD TargetProc/schedule. If it specifies a commitment-device then you know you can use it as a commitment spec, if it doesn't do then we do the default flow.
| Info = hb_device:info(Scheduler, QuoteOpts), | ||
| true ?= lists:member(<<"quote">>, maps:get(exports, Info, [])), |
There was a problem hiding this comment.
We generally only use hb_device in the kernel if possible. I think here (the above route notwithstanding) the idea would just be to try the /quote and match on {ok, Quote} ?= ...
| {ToSign, CommitSpec} = | ||
| case Spec of | ||
| _ when is_map(Spec) -> | ||
| {normalize_message(Msg, Opts), |
|
thanks for the feedback @samcamwilliams -- in latest commit i addressed the
the flow is (pseudocode): so HEAD without a commitment device keeps the default flow, and a retry uses the whole flat 422 response as the spec. the retry is bounded -- the scheduler still just supplies the native fields and submits the signed tx live probed again on Arweave L1:
|
| {ok, TX} = to(hb_private:reset(Msg), Req, Opts), | ||
| TABM = hb_private:reset(Msg), | ||
| TX0 = | ||
| case hb_util:int(hb_maps:get(<<"field-data_size">>, Req, -1, Opts)) of |
There was a problem hiding this comment.
Why is this needed out of interest?
There was a problem hiding this comment.
replaced the separate header-building path with normal shared tx encoding and explicit validation
| dev_tx_to:fields_to_tx(TX, ?FIELD_PREFIX, Fields, Opts). | ||
|
|
||
| %% @doc Encode message tags when the signing request specifies zero data size. | ||
| header(TABM, Opts) -> |
There was a problem hiding this comment.
Similar question to above -- necessary now?
| <<"commitment-device">> => <<"tx@1.0">>, | ||
| <<"field-format">> => 2, | ||
| <<"field-target">> => Target, | ||
| <<"field-quantity">> => 1, | ||
| <<"field-reward">> => Reward, | ||
| <<"field-anchor">> => hb_util:encode(Anchor), | ||
| <<"field-data_size">> => 0, | ||
| <<"field-data_root">> => <<>>, |
There was a problem hiding this comment.
IIRC don't most/all of the keys already use the fields by default? Or is that not how it works? If not, then the thing to check would be that they are promoted to first-class keys in the base message upon decode normally.
There was a problem hiding this comment.
yes they are -- i reused that mapping and added decode assertions
| <<"field-quantity">> => 1, | ||
| <<"field-reward">> => Reward, | ||
| <<"field-anchor">> => hb_util:encode(Anchor), | ||
| <<"field-data_size">> => 0, |
There was a problem hiding this comment.
I get where we are trying to go here but any ideas about a nicer root? We are just trying to communicate that we shouldn't include a TX data body? Is the plan to pick that up in dev_tx on the other node and throw if the user tries to sign where the spec says there must be data-size: 0?
There was a problem hiding this comment.
yes, now it throw before signing when the encoded tx contain payload data or nonzero size/root metadata
this PR refactor moves the Arweave fee/anchor lookup out of
dev_push, addressing #1101 (comment)push asks the selected scheduler for a
/quote. the arweave-scheduler@1.0 returns a commitment spec with the reward and anchor, andtx@1.0build the native tx. authority selection still chooses the local signing wallet -- and the scheduler submit the signed txschedulers without
/quotekeep the existing codec negotiation (422)live probe on Arweave:
P1's
/pushproduced the outgoing tx, and P2 computed it at slot 1 with the expected message andfrom-process