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

re-implement shared-state from scratch in modern C++ #1067

Merged
merged 6 commits into from
Feb 6, 2024

Conversation

G10h4ck
Copy link
Member

@G10h4ck G10h4ck commented Jan 20, 2024

Add shared-state-async package with almost complete shared-state modern C++ re-implementation, peer discovery is the only things that haven't been implemented yet in C++ and rely still on the shell script copied directly at compile time from the Lua shared-state package.

To show how to port the shared-state plugins to the new implementation also bat-hosts have been ported to the new implementation.

@G10h4ck G10h4ck added this to the mesh-wide milestone Jan 20, 2024
@G10h4ck G10h4ck force-pushed the shared_state_async branch from 1598b10 to 484f7bb Compare January 22, 2024 15:54
@G10h4ck G10h4ck changed the title WIP: reimplemente shared-state from scratch in modern C++ WIP: re-implement shared-state from scratch in modern C++ Jan 22, 2024
@codecov-commenter
Copy link

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (d0c498f) 79.69% compared to head (5506399) 79.55%.
Report is 6 commits behind head on master.

❗ Current head 5506399 differs from pull request most recent head 449e2ac. Consider uploading reports for the commit 449e2ac to get more accurate results

Files Patch % Lines
...ed-state-bat_hosts/files/usr/lib/lua/bat-hosts.lua 75.00% 1 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1067      +/-   ##
==========================================
- Coverage   79.69%   79.55%   -0.14%     
==========================================
  Files          53       53              
  Lines        4550     4549       -1     
==========================================
- Hits         3626     3619       -7     
- Misses        924      930       +6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@G10h4ck G10h4ck changed the title WIP: re-implement shared-state from scratch in modern C++ re-implement shared-state from scratch in modern C++ Jan 22, 2024
Comment on lines +4 to +39
-- local utils = require('lime.utils')
-- local test_utils = require('tests.utils')
-- local shared_state = require('shared-state')
--
-- it('test get_bathost #bathost', function()
-- shared_state.DATA_DIR = test_utils.setup_test_dir()
-- local sharedState = shared_state.SharedState:new('bat-hosts')
-- sharedState:insert({
-- ["02:95:39:ab:cd:00"] = "LiMe_abcd00_wlan1_mesh",
-- ["52:00:00:ab:cd:a0"] = "LiMe_abcd01_wlan2_mesh_17",
-- ["d6:67:58:8e:cd:92"] = "LiMe_abcd02_wlan0_adhoc_29",
-- ["12:00:00:00:00:00"] = "LiMe_abcd03_wlan1_adhoc"
-- })
-- local ifaces = {'wlan1-mesh', 'wlan2-mesh', 'wlan2-mesh_17', 'wlan0-adhoc_29', 'wlan1-adhoc'}
-- stub(utils, "get_ifnames", function () return ifaces end)
-- assert.is.same({hostname='LiMe-abcd00', iface='wlan1-mesh'}, bat_hosts.get_bathost('02:95:39:ab:cd:00'))
-- assert.is.same({hostname='LiMe-abcd01', iface='wlan2-mesh_17'}, bat_hosts.get_bathost('52:00:00:ab:cd:a0'))
-- assert.is.same({hostname='LiMe-abcd02', iface='wlan0-adhoc_29'}, bat_hosts.get_bathost('d6:67:58:8e:cd:92'))
-- assert.is.same({hostname='LiMe-abcd03', iface='wlan1-adhoc'}, bat_hosts.get_bathost('12:00:00:00:00:00'))
-- local ipv6ll = utils.mac2ipv6linklocal('52:00:00:ab:cd:00') .. '%wlan1-mesh'
-- local dataTypeOfSync = nil
-- local urlsOfSync = nil
-- local function syncMock (self, urls)
-- dataTypeOfSync = self.dataType
-- urlsOfSync = urls
-- self:insert({['52:00:00:ab:cd:00'] = "Lime_abcd04_wlan1_mesh"})
-- end
-- stub(shared_state.SharedState, "sync", syncMock)
-- local bathost = bat_hosts.get_bathost('52:00:00:ab:cd:00', 'wlan1-mesh')
-- assert.is.same(urlsOfSync, { ipv6ll })
-- assert.is.equal(dataTypeOfSync, 'bat-hosts')
-- assert.is.same({hostname='Lime-abcd04', iface='wlan1-mesh'}, bathost)
-- assert.is_nil(bat_hosts.get_bathost('00:aa:bb:cc:dd:00', 'wlan1'))
-- assert.is_nil(bat_hosts.get_bathost('00:aa:bb:cc:dd:00'))
-- end)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Commented code. Should this tests work?

Copy link
Member Author

Choose a reason for hiding this comment

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

nope, because it relies on Lua shared-state

Copy link
Collaborator

@javierbrk javierbrk left a comment

Choose a reason for hiding this comment

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

Excellent, this is the first step, with the example provided porting of other modules should be trivial.

Copy link
Contributor

@nicoechaniz nicoechaniz left a comment

Choose a reason for hiding this comment

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

...

@G10h4ck G10h4ck merged commit e322985 into libremesh:master Feb 6, 2024
1 check passed
a-gave added a commit to a-gave/lime-packages that referenced this pull request Mar 1, 2024
Add a new packages repository at:
- http://github.com/libremesh/lime-feed/tree/gh-pages/master/packages/$ARCH_PACKAGES
- http://feed.libremesh.org/master/packages/$ARCH_PACKAGES
That includes packages precompiled by openwrt-sdk for each specific architecture

This is currently required only for the package 'shared-state-async'
After this merge libremesh#1067
imagebuilder builds fail, using the default set of packages, unless you are building for x86_64

update the imagebuilder build guide on README.md
update lime-system/files/etc/uci-defaults/92_add-lime-repos to use also the new repo
a-gave added a commit to a-gave/lime-packages that referenced this pull request Mar 2, 2024
Add a new packages repository at:
- http://github.com/libremesh/lime-feed/tree/gh-pages/master/packages/$ARCH_PACKAGES
- http://feed.libremesh.org/master/packages/$ARCH_PACKAGES
That includes packages precompiled by openwrt-sdk for each specific architecture

This is currently required only for the package 'shared-state-async'
After this merge libremesh#1067
imagebuilder builds fail, using the default set of packages, unless you are building for x86_64

update the imagebuilder build guide on README.md
update lime-system/files/etc/uci-defaults/92_add-lime-repos to use also the new repo
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.

5 participants