diff --git a/Cargo.lock b/Cargo.lock index 805fcf8305..49d0c85a53 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6493,7 +6493,7 @@ dependencies = [ ] [[package]] -name = "solana-bundle" +name = "solana-bundle-execution" version = "2.2.0" dependencies = [ "anchor-lang", @@ -6861,7 +6861,7 @@ dependencies = [ "solana-accounts-db", "solana-bloom", "solana-builtins-default-costs", - "solana-bundle", + "solana-bundle-execution", "solana-client", "solana-compute-budget", "solana-connection-cache", @@ -8132,7 +8132,7 @@ dependencies = [ "soketto", "solana-account-decoder", "solana-accounts-db", - "solana-bundle", + "solana-bundle-execution", "solana-client", "solana-entry", "solana-faucet", @@ -8217,6 +8217,7 @@ dependencies = [ "serde_derive", "serde_json", "solana-account-decoder-client-types", + "solana-bundle-execution", "solana-inline-spl", "solana-sdk", "solana-transaction-status-client-types", diff --git a/Cargo.toml b/Cargo.toml index cbf50a44c1..318ae2169a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -414,7 +414,7 @@ solana-borsh = { path = "sdk/borsh", version = "=2.2.0" } solana-bpf-loader-program = { path = "programs/bpf_loader", version = "=2.2.0" } solana-bucket-map = { path = "bucket_map", version = "=2.2.0" } solana-builtins-default-costs = { path = "builtins-default-costs", version = "=2.2.0" } -solana-bundle = { path = "bundle-execution", version = "=2.2.0" } +solana-bundle-execution = { path = "bundle-execution", version = "=2.2.0" } agave-cargo-registry = { path = "cargo-registry", version = "=2.2.0" } solana-clap-utils = { path = "clap-utils", version = "=2.2.0" } solana-clap-v3-utils = { path = "clap-v3-utils", version = "=2.2.0" } diff --git a/bundle-execution/Cargo.toml b/bundle-execution/Cargo.toml index 7b2860e44b..d5621517e5 100644 --- a/bundle-execution/Cargo.toml +++ b/bundle-execution/Cargo.toml @@ -1,7 +1,7 @@ [package] -name = "solana-bundle" -description = "Library related to handling bundles" -documentation = "https://docs.rs/solana-bundle" +name = "solana-bundle-execution" +description = "Library related to executing bundles" +documentation = "https://docs.rs/solana-bundle-execution" readme = "../README.md" version = { workspace = true } authors = { workspace = true } @@ -35,4 +35,4 @@ solana-runtime = { workspace = true, features = ["dev-context-only-utils"] } [lib] crate-type = ["lib"] -name = "solana_bundle" +name = "solana_bundle_execution" diff --git a/ci/order-crates-for-publishing.py b/ci/order-crates-for-publishing.py index 6bfda2b29d..ade2e226c7 100755 --- a/ci/order-crates-for-publishing.py +++ b/ci/order-crates-for-publishing.py @@ -92,20 +92,51 @@ def should_add(package, dependency, wrong_self_dev_dependencies): and not is_path_dev_dep(dependency) ) +def find_cycle(graph): + """ + Find a cycle in the dependency graph using Tarjan's algorithm. + Returns the first cycle found as a list, or None if no cycles exist. + """ + def dfs(node, path, visited): + if node in path: + cycle_start = path.index(node) + return path[cycle_start:] + [node] + + if node in visited: + return None + + visited.add(node) + path.append(node) + + for neighbor in graph[node]: + if neighbor not in graph: + continue + cycle = dfs(neighbor, path, visited) + if cycle: + return cycle + + path.pop() + return None + + visited = set() + for start in graph: + if start not in visited: + cycle = dfs(start, [], visited) + if cycle: + return cycle + return None + def get_packages(): metadata = load_metadata() - manifest_path = dict() - - # Build dictionary of packages and their immediate solana-only dependencies dependency_graph = dict() wrong_self_dev_dependencies = list() for pkg in metadata['packages']: - manifest_path[pkg['name']] = pkg['manifest_path']; + manifest_path[pkg['name']] = pkg['manifest_path'] dependency_graph[pkg['name']] = [ x['name'] for x in pkg['dependencies'] if should_add(pkg, x, wrong_self_dev_dependencies) - ]; + ] # Check for direct circular dependencies circular_dependencies = set() @@ -118,21 +149,26 @@ def get_packages(): sys.stderr.write('Error: Circular dependency: {}\n'.format(dependency)) for dependency in wrong_self_dev_dependencies: sys.stderr.write('Error: wrong dev-context-only-utils circular dependency. try: ' + - '{} = {{ path = ".", features = {} }}\n' - .format(dependency['name'], json.dumps(dependency['features'])) - ) + '{} = {{ path = ".", features = {} }}\n' + .format(dependency['name'], json.dumps(dependency['features'])) + ) if len(circular_dependencies) != 0 or len(wrong_self_dev_dependencies) != 0: sys.exit(1) # Order dependencies sorted_dependency_graph = [] - max_iterations = pow(len(dependency_graph),2) + max_iterations = pow(len(dependency_graph), 2) while dependency_graph: deleted_packages = [] if max_iterations == 0: - # One day be more helpful and find the actual cycle for the user... - sys.exit('Error: Circular dependency suspected between these packages: \n {}\n'.format('\n '.join(dependency_graph.keys()))) + # Find the actual cycle + cycle = find_cycle(dependency_graph) + if cycle: + cycle_str = ' -> '.join(cycle) + sys.exit('Error: Circular dependency detected:\n{}\n'.format(cycle_str)) + else: + sys.exit('Error: Dependency resolution failed but no cycle found. This might indicate a bug.') max_iterations -= 1 @@ -146,8 +182,7 @@ def get_packages(): deleted_packages.append(package) sorted_dependency_graph.append((package, manifest_path[package])) - dependency_graph = {p: d for p, d in dependency_graph.items() if not p in deleted_packages } - + dependency_graph = {p: d for p, d in dependency_graph.items() if not p in deleted_packages} return sorted_dependency_graph diff --git a/core/Cargo.toml b/core/Cargo.toml index 1c936335f0..4896e12f8e 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -53,7 +53,7 @@ serde_derive = { workspace = true } solana-accounts-db = { workspace = true } solana-bloom = { workspace = true } solana-builtins-default-costs = { workspace = true } -solana-bundle = { workspace = true } +solana-bundle-execution = { workspace = true } solana-client = { workspace = true } solana-compute-budget = { workspace = true } solana-connection-cache = { workspace = true } @@ -114,7 +114,7 @@ serde_json = { workspace = true } serial_test = { workspace = true } solana-accounts-db = { workspace = true } ## See order-crates-for-publishing.py for using this unusual `path = "."` -solana-bundle = { workspace = true } +solana-bundle-execution = { workspace = true } solana-core = { path = ".", features = ["dev-context-only-utils"] } solana-cost-model = { workspace = true, features = ["dev-context-only-utils"] } solana-ledger = { workspace = true, features = ["dev-context-only-utils"] } diff --git a/programs/sbf/Cargo.lock b/programs/sbf/Cargo.lock index bbfac69535..c0c6b7e208 100644 --- a/programs/sbf/Cargo.lock +++ b/programs/sbf/Cargo.lock @@ -5281,7 +5281,7 @@ dependencies = [ ] [[package]] -name = "solana-bundle" +name = "solana-bundle-execution" version = "2.2.0" dependencies = [ "anchor-lang", @@ -5488,7 +5488,7 @@ dependencies = [ "solana-accounts-db", "solana-bloom", "solana-builtins-default-costs", - "solana-bundle", + "solana-bundle-execution", "solana-client", "solana-compute-budget", "solana-connection-cache", @@ -6387,7 +6387,7 @@ dependencies = [ "soketto", "solana-account-decoder", "solana-accounts-db", - "solana-bundle", + "solana-bundle-execution", "solana-client", "solana-entry", "solana-faucet", @@ -6462,6 +6462,7 @@ dependencies = [ "serde_derive", "serde_json", "solana-account-decoder-client-types", + "solana-bundle-execution", "solana-inline-spl", "solana-sdk", "solana-transaction-status-client-types", diff --git a/rpc-client-api/Cargo.toml b/rpc-client-api/Cargo.toml index e1eee85110..90bd259586 100644 --- a/rpc-client-api/Cargo.toml +++ b/rpc-client-api/Cargo.toml @@ -21,6 +21,7 @@ serde = { workspace = true } serde_derive = { workspace = true } serde_json = { workspace = true } solana-account-decoder-client-types = { workspace = true } +solana-bundle-execution = { workspace = true } solana-inline-spl = { workspace = true } solana-sdk = { workspace = true } solana-transaction-status-client-types = { workspace = true } diff --git a/rpc/Cargo.toml b/rpc/Cargo.toml index 11a01cc80c..4b4c2fea68 100644 --- a/rpc/Cargo.toml +++ b/rpc/Cargo.toml @@ -31,7 +31,7 @@ serde_json = { workspace = true } soketto = { workspace = true } solana-account-decoder = { workspace = true } solana-accounts-db = { workspace = true } -solana-bundle = { workspace = true } +solana-bundle-execution = { workspace = true } solana-client = { workspace = true } solana-entry = { workspace = true } solana-faucet = { workspace = true }