Skip to content

Commit

Permalink
go update
Browse files Browse the repository at this point in the history
  • Loading branch information
dmkozh committed Mar 1, 2024
1 parent 2920d57 commit 87f54f7
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 39 deletions.
5 changes: 5 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ rust-version = "1.74.0"

[workspace.dependencies.soroban-env-host]
version = "=20.2.2"
# git = "https://github.com/stellar/rs-soroban-env"
# rev = "1bfc0f2a2ee134efc1e1b0d5270281d0cba61c2e"
path = "../rs-soroban-env/soroban-env-host"
git = "https://github.com/stellar/rs-soroban-env"
rev = "8c9ab83c406bd86f56d52eae3e39dccf6b45b3da"
# path = "../rs-soroban-env/soroban-env-host"

[workspace.dependencies.soroban-simulation]
version = "=20.2.2"
# git = "https://github.com/stellar/rs-soroban-env"
# rev = "1bfc0f2a2ee134efc1e1b0d5270281d0cba61c2e"
path = "../rs-soroban-env/soroban-simulation"
git = "https://github.com/stellar/rs-soroban-env"
rev = "8c9ab83c406bd86f56d52eae3e39dccf6b45b3da"
# path = "../rs-soroban-env/soroban-simulation"

[workspace.dependencies.soroban-spec]
version = "=20.3.1"
Expand Down
54 changes: 21 additions & 33 deletions cmd/soroban-rpc/internal/preflight/preflight.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package preflight

import (
"context"
"errors"
"fmt"
"runtime/cgo"
"time"
Expand Down Expand Up @@ -150,6 +149,23 @@ func GetPreflight(ctx context.Context, params PreflightParameters) (Preflight, e
}
}

func getLedgerInfo(params PreflightParameters) (C.ledger_info_t, error) {
simulationLedgerSeq, err := getSimulationLedgerSeq(params.LedgerEntryReadTx)
if err != nil {
return C.ledger_info_t{}, err
}

li := C.ledger_info_t{
network_passphrase: C.CString(params.NetworkPassphrase),
sequence_number: C.uint32_t(simulationLedgerSeq),
protocol_version: 20,
timestamp: C.uint64_t(time.Now().Unix()),
// Current base reserve is 0.5XLM (in stroops)
base_reserve: 5_000_000,
}
return li, nil
}

func getFootprintTtlPreflight(params PreflightParameters) (Preflight, error) {
opBodyXDR, err := params.OpBody.MarshalBinary()
if err != nil {
Expand All @@ -164,17 +180,16 @@ func getFootprintTtlPreflight(params PreflightParameters) (Preflight, error) {
handle := cgo.NewHandle(snapshotSourceHandle{params.LedgerEntryReadTx, params.Logger})
defer handle.Delete()

simulationLedgerSeq, err := getSimulationLedgerSeq(params.LedgerEntryReadTx)
li, err := getLedgerInfo(params)
if err != nil {
return Preflight{}, err
}

res := C.preflight_footprint_ttl_op(
C.uintptr_t(handle),
C.uint64_t(params.BucketListSize),
opBodyCXDR,
footprintCXDR,
C.uint32_t(simulationLedgerSeq),
li,

Check failure on line 192 in cmd/soroban-rpc/internal/preflight/preflight.go

View workflow job for this annotation

GitHub Actions / Unit tests (ubuntu-20.04, 1.21)

not enough arguments in call to (_Cfunc_preflight_footprint_ttl_op)

Check failure on line 192 in cmd/soroban-rpc/internal/preflight/preflight.go

View workflow job for this annotation

GitHub Actions / Unit tests (ubuntu-22.04, 1.21)

not enough arguments in call to (_Cfunc_preflight_footprint_ttl_op)

Check failure on line 192 in cmd/soroban-rpc/internal/preflight/preflight.go

View workflow job for this annotation

GitHub Actions / Integration tests (ubuntu-20.04, 1.21, .*CLI.*)

not enough arguments in call to (_Cfunc_preflight_footprint_ttl_op)

Check failure on line 192 in cmd/soroban-rpc/internal/preflight/preflight.go

View workflow job for this annotation

GitHub Actions / Integration tests (ubuntu-22.04, 1.21, ^Test(([^C])|(C[^L])|(CL[^I])).*$)

not enough arguments in call to (_Cfunc_preflight_footprint_ttl_op)

Check failure on line 192 in cmd/soroban-rpc/internal/preflight/preflight.go

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, x86_64-unknown-linux-gnu, amd64)

not enough arguments in call to (_Cfunc_preflight_footprint_ttl_op)

Check failure on line 192 in cmd/soroban-rpc/internal/preflight/preflight.go

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, aarch64-unknown-linux-gnu, arm64)

not enough arguments in call to (_Cfunc_preflight_footprint_ttl_op)

Check failure on line 192 in cmd/soroban-rpc/internal/preflight/preflight.go

View workflow job for this annotation

GitHub Actions / Integration tests (ubuntu-22.04, 1.21, .*CLI.*)

not enough arguments in call to (_Cfunc_preflight_footprint_ttl_op)

Check failure on line 192 in cmd/soroban-rpc/internal/preflight/preflight.go

View workflow job for this annotation

GitHub Actions / Integration tests (ubuntu-20.04, 1.21, ^Test(([^C])|(C[^L])|(CL[^I])).*$)

not enough arguments in call to (_Cfunc_preflight_footprint_ttl_op)
)

FreeGoXDR(opBodyCXDR)
Expand Down Expand Up @@ -206,46 +221,19 @@ func getInvokeHostFunctionPreflight(params PreflightParameters) (Preflight, erro
return Preflight{}, err
}
sourceAccountCXDR := CXDR(sourceAccountXDR)

hasConfig, stateArchivalConfig, _, err := db.GetLedgerEntry(params.LedgerEntryReadTx, xdr.LedgerKey{
Type: xdr.LedgerEntryTypeConfigSetting,
ConfigSetting: &xdr.LedgerKeyConfigSetting{
ConfigSettingId: xdr.ConfigSettingIdConfigSettingStateArchival,
},
})
if err != nil {
return Preflight{}, err
}
if !hasConfig {
return Preflight{}, errors.New("state archival config setting missing in ledger storage")
}

simulationLedgerSeq, err := getSimulationLedgerSeq(params.LedgerEntryReadTx)
li, err := getLedgerInfo(params)
if err != nil {
return Preflight{}, err
}

stateArchival := stateArchivalConfig.Data.MustConfigSetting().MustStateArchivalSettings()
li := C.ledger_info_t{
network_passphrase: C.CString(params.NetworkPassphrase),
sequence_number: C.uint32_t(simulationLedgerSeq),
protocol_version: 20,
timestamp: C.uint64_t(time.Now().Unix()),
// Current base reserve is 0.5XLM (in stroops)
base_reserve: 5_000_000,
min_temp_entry_ttl: C.uint(stateArchival.MinTemporaryTtl),
min_persistent_entry_ttl: C.uint(stateArchival.MinPersistentTtl),
max_entry_ttl: C.uint(stateArchival.MaxEntryTtl),
}

handle := cgo.NewHandle(snapshotSourceHandle{params.LedgerEntryReadTx, params.Logger})
defer handle.Delete()
resourceConfig := C.resource_config_t{
instruction_leeway: C.uint64_t(params.ResourceConfig.InstructionLeeway),
}

res := C.preflight_invoke_hf_op(
C.uintptr_t(handle),
C.uint64_t(params.BucketListSize),
invokeHostFunctionCXDR,
sourceAccountCXDR,
li,
Expand Down

0 comments on commit 87f54f7

Please sign in to comment.