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

add gas fee payer by adding a new payload type #8904

Merged
merged 31 commits into from
Jul 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
5bcb383
first update
gerben-stavenga Jun 29, 2023
8993f16
Use RawTransactionWithData
gerben-stavenga Jun 30, 2023
564c64f
fix all locations
gerben-stavenga Jun 30, 2023
153c0b3
introduce the gas fee authenticator
davidiw Jul 1, 2023
8035f1c
[fee-payer] plumb through the VM and framework
davidiw Jul 3, 2023
529dfc1
move tests pass
davidiw Jul 3, 2023
341a74c
fix prover
gerben-stavenga Jul 3, 2023
04f3578
fix order
gerben-stavenga Jul 3, 2023
ae18471
Merge branch 'main' into gerben-fee-payer
gerben-stavenga Jul 3, 2023
0f535ea
regen
gerben-stavenga Jul 3, 2023
884b378
Add
gerben-stavenga Jul 3, 2023
e2dfc10
restore sdk/src/types.rs
gerben-stavenga Jul 3, 2023
3ec2125
remove old comment
gerben-stavenga Jul 3, 2023
7512ad2
split test/remove println
gerben-stavenga Jul 3, 2023
b7ad826
remove unnecessary payload
davidiw Jul 3, 2023
a08294b
Redo protos
gerben-stavenga Jul 4, 2023
7512d0d
remove more
gerben-stavenga Jul 4, 2023
531c014
undo changes
gerben-stavenga Jul 4, 2023
2c2124e
Merge branch 'main' into gerben-fee-payer
gerben-stavenga Jul 4, 2023
90d0465
Merge branch 'main' into gerben-fee-payer
gregnazario Jul 4, 2023
fc8bf30
Add spec
gerben-stavenga Jul 4, 2023
fcfdcfe
add test
gerben-stavenga Jul 4, 2023
ba958a0
rest api
gerben-stavenga Jul 4, 2023
3b7dcbf
api test
gerben-stavenga Jul 4, 2023
48e890d
regen
gerben-stavenga Jul 4, 2023
9d41347
regen
gerben-stavenga Jul 4, 2023
72e7a93
lint
gerben-stavenga Jul 4, 2023
16b19c3
reinsert seq too big test
gerben-stavenga Jul 4, 2023
c789507
regen
gerben-stavenga Jul 4, 2023
0a8302a
regen
gerben-stavenga Jul 4, 2023
b1f8bb8
prover improvement
gerben-stavenga Jul 4, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 74 additions & 1 deletion api/doc/spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -12420,6 +12420,56 @@
}
}
},
"FeePayerSignature": {
"type": "object",
"description": "Fee payer signature for fee payer transactions\n\nThis allows you to have transactions across multiple accounts and with a fee payer",
"required": [
"sender",
"secondary_signer_addresses",
"secondary_signers",
"fee_payer_address",
"fee_payer_signer"
],
"properties": {
"sender": {
"$ref": "#/components/schemas/AccountSignature"
},
"secondary_signer_addresses": {
"type": "array",
"description": "The other involved parties' addresses",
"items": {
"$ref": "#/components/schemas/Address"
}
},
"secondary_signers": {
"type": "array",
"description": "The associated signatures, in the same order as the secondary addresses",
"items": {
"$ref": "#/components/schemas/AccountSignature"
}
},
"fee_payer_address": {
"allOf": [
{
"$ref": "#/components/schemas/Address"
},
{
"description": "The address of the paying party"
}
]
},
"fee_payer_signer": {
"allOf": [
{
"$ref": "#/components/schemas/AccountSignature"
},
{
"description": "The signature of the fee payer"
}
]
}
}
},
"GasEstimation": {
"type": "object",
"description": "Struct holding the outputs of the estimate gas API",
Expand Down Expand Up @@ -13394,14 +13444,18 @@
},
{
"$ref": "#/components/schemas/TransactionSignature_MultiAgentSignature"
},
{
"$ref": "#/components/schemas/TransactionSignature_FeePayerSignature"
}
],
"discriminator": {
"propertyName": "type",
"mapping": {
"ed25519_signature": "#/components/schemas/TransactionSignature_Ed25519Signature",
"multi_ed25519_signature": "#/components/schemas/TransactionSignature_MultiEd25519Signature",
"multi_agent_signature": "#/components/schemas/TransactionSignature_MultiAgentSignature"
"multi_agent_signature": "#/components/schemas/TransactionSignature_MultiAgentSignature",
"fee_payer_signature": "#/components/schemas/TransactionSignature_FeePayerSignature"
}
}
},
Expand All @@ -13424,6 +13478,25 @@
}
]
},
"TransactionSignature_FeePayerSignature": {
"allOf": [
{
"type": "object",
"required": [
"type"
],
"properties": {
"type": {
"type": "string",
"example": "fee_payer_signature"
}
}
},
{
"$ref": "#/components/schemas/FeePayerSignature"
}
]
},
"TransactionSignature_MultiAgentSignature": {
"allOf": [
{
Expand Down
46 changes: 46 additions & 0 deletions api/doc/spec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9316,6 +9316,40 @@ components:
$ref: '#/components/schemas/U64'
account_address:
$ref: '#/components/schemas/Address'
FeePayerSignature:
type: object
description: |-
Fee payer signature for fee payer transactions

This allows you to have transactions across multiple accounts and with a fee payer
required:
- sender
- secondary_signer_addresses
- secondary_signers
- fee_payer_address
- fee_payer_signer
properties:
sender:
$ref: '#/components/schemas/AccountSignature'
secondary_signer_addresses:
type: array
description: The other involved parties' addresses
items:
$ref: '#/components/schemas/Address'
secondary_signers:
type: array
description: The associated signatures, in the same order as the secondary
addresses
items:
$ref: '#/components/schemas/AccountSignature'
fee_payer_address:
allOf:
- $ref: '#/components/schemas/Address'
- description: The address of the paying party
fee_payer_signer:
allOf:
- $ref: '#/components/schemas/AccountSignature'
- description: The signature of the fee payer
GasEstimation:
type: object
description: Struct holding the outputs of the estimate gas API
Expand Down Expand Up @@ -10088,12 +10122,14 @@ components:
- $ref: '#/components/schemas/TransactionSignature_Ed25519Signature'
- $ref: '#/components/schemas/TransactionSignature_MultiEd25519Signature'
- $ref: '#/components/schemas/TransactionSignature_MultiAgentSignature'
- $ref: '#/components/schemas/TransactionSignature_FeePayerSignature'
discriminator:
propertyName: type
mapping:
ed25519_signature: '#/components/schemas/TransactionSignature_Ed25519Signature'
multi_ed25519_signature: '#/components/schemas/TransactionSignature_MultiEd25519Signature'
multi_agent_signature: '#/components/schemas/TransactionSignature_MultiAgentSignature'
fee_payer_signature: '#/components/schemas/TransactionSignature_FeePayerSignature'
TransactionSignature_Ed25519Signature:
allOf:
- type: object
Expand All @@ -10104,6 +10140,16 @@ components:
type: string
example: ed25519_signature
- $ref: '#/components/schemas/Ed25519Signature'
TransactionSignature_FeePayerSignature:
allOf:
- type: object
required:
- type
properties:
type:
type: string
example: fee_payer_signature
- $ref: '#/components/schemas/FeePayerSignature'
TransactionSignature_MultiAgentSignature:
allOf:
- type: object
Expand Down
67 changes: 67 additions & 0 deletions api/src/tests/transactions_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,74 @@ async fn test_multi_agent_signed_transaction() {
.post("/transactions", resp)
.await;
}
/* works when feature is enabled
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn test_fee_payer_signed_transaction() {
let mut context = new_test_context(current_function_name!());
let account = context.gen_account();
let secondary = context.gen_account();
let factory = context.transaction_factory();
let mut root_account = context.root_account().await;

// Create secondary signer account
context
.commit_block(&[context.create_user_account_by(&mut root_account, &secondary)])
.await;

// Create a new account with a multi-agent signer
let txn = root_account.sign_fee_payer_with_transaction_builder(
vec![], &secondary,
factory.create_user_account(account.public_key()),
);

let body = bcs::to_bytes(&txn).unwrap();
let resp = context
.expect_status_code(202)
.post_bcs_txn("/transactions", body)
.await;

let (sender, secondary_signers,fee_payer_signer) = match txn.authenticator() {
TransactionAuthenticator::FeePayer {
sender,
secondary_signer_addresses: _,
secondary_signers,
fee_payer_address: _,
fee_payer_signer
} => (sender, secondary_signers, fee_payer_signer),
_ => panic!(
"expecting TransactionAuthenticator::MultiAgent, but got: {:?}",
txn.authenticator()
),
};
assert_json(
resp["signature"].clone(),
json!({
"type": "fee_payer_signature",
"sender": {
"type": "ed25519_signature",
"public_key": format!("0x{}", hex::encode(sender.public_key_bytes())),
"signature": format!("0x{}", hex::encode(sender.signature_bytes())),
},
"secondary_signer_addresses": [
],
"secondary_signers": [
],
"fee_payer_address": secondary.address().to_hex_literal(),
"fee_payer_signer": {
"type": "ed25519_signature",
"public_key": format!("0x{}",hex::encode(fee_payer_signer.public_key_bytes())),
"signature": format!("0x{}", hex::encode(fee_payer_signer.signature_bytes())),
},
}),
);

// ensure fee payer txns can be submitted into mempool by JSON format
context
.expect_status_code(202)
.post("/transactions", resp)
.await;
}
*/
#[ignore]
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn test_multi_ed25519_signed_transaction() {
Expand Down
16 changes: 8 additions & 8 deletions api/types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ pub use table::{RawTableItemRequest, TableItemRequest};
pub use transaction::{
AccountSignature, BlockMetadataTransaction, DeleteModule, DeleteResource, DeleteTableItem,
DirectWriteSet, Ed25519Signature, EncodeSubmissionRequest, EntryFunctionPayload, Event,
GasEstimation, GasEstimationBcs, GenesisPayload, GenesisTransaction, ModuleBundlePayload,
MultiAgentSignature, MultiEd25519Signature, MultisigPayload, MultisigTransactionPayload,
PendingTransaction, ScriptPayload, ScriptWriteSet, SubmitTransactionRequest, Transaction,
TransactionData, TransactionId, TransactionInfo, TransactionOnChainData, TransactionPayload,
TransactionSignature, TransactionSigningMessage, TransactionsBatchSingleSubmissionFailure,
TransactionsBatchSubmissionResult, UserCreateSigningMessageRequest, UserTransaction,
UserTransactionRequest, VersionedEvent, WriteModule, WriteResource, WriteSet, WriteSetChange,
WriteSetPayload, WriteTableItem,
FeePayerSignature, GasEstimation, GasEstimationBcs, GenesisPayload, GenesisTransaction,
ModuleBundlePayload, MultiAgentSignature, MultiEd25519Signature, MultisigPayload,
MultisigTransactionPayload, PendingTransaction, ScriptPayload, ScriptWriteSet,
SubmitTransactionRequest, Transaction, TransactionData, TransactionId, TransactionInfo,
TransactionOnChainData, TransactionPayload, TransactionSignature, TransactionSigningMessage,
TransactionsBatchSingleSubmissionFailure, TransactionsBatchSubmissionResult,
UserCreateSigningMessageRequest, UserTransaction, UserTransactionRequest, VersionedEvent,
WriteModule, WriteResource, WriteSet, WriteSetChange, WriteSetPayload, WriteTableItem,
};
pub use view::ViewRequest;
pub use wrappers::{EventGuid, IdentifierWrapper, StateKeyWrapper};
Expand Down
Loading